ObjectivelyMVC 0.1.0
Object oriented MVC framework for OpenGL, SDL2 and GNU C
Macros | Functions
TabViewItem.c File Reference
#include <assert.h>
#include <string.h>
#include "TabViewItem.h"

Go to the source code of this file.

Macros

#define _Class   _TabViewItem
 

Functions

Class * _TabViewItem (void)
 
static void dealloc (Object *self)
 
static void initialize (Class *clazz)
 
static TabViewIteminitWithIdentifier (TabViewItem *self, const char *identifier)
 
static TabViewIteminitWithView (TabViewItem *self, View *view)
 
static void setState (TabViewItem *self, int state)
 

Macro Definition Documentation

◆ _Class

#define _Class   _TabViewItem

Definition at line 29 of file TabViewItem.c.

Function Documentation

◆ _TabViewItem()

Class * _TabViewItem ( void  )

Definition at line 121 of file TabViewItem.c.

121 {
122 static Class *clazz;
123 static Once once;
124
125 do_once(&once, {
126 clazz = _initialize(&(const ClassDef) {
127 .name = "TabViewItem",
128 .superclass = _Object(),
129 .instanceSize = sizeof(TabViewItem),
130 .interfaceOffset = offsetof(TabViewItem, interface),
131 .interfaceSize = sizeof(TabViewItemInterface),
133 });
134 });
135
136 return clazz;
137}
static void initialize(Class *clazz)
Definition: TabViewItem.c:108
TabViewItems embed Views in a TabView.
Definition: TabViewItem.h:51

◆ dealloc()

static void dealloc ( Object *  self)
static
See also
Object::dealloc(Object *)

Definition at line 36 of file TabViewItem.c.

36 {
37
38 TabViewItem *this = (TabViewItem *) self;
39
40 free(this->identifier);
41
42 release(this->label);
43 release(this->view);
44
45 super(Object, self, dealloc);
46}
static void dealloc(Object *self)
Definition: TabViewItem.c:36

◆ initialize()

static void initialize ( Class *  clazz)
static
See also
Class::initialize(Class *)

Definition at line 108 of file TabViewItem.c.

108 {
109
110 ((ObjectInterface *) clazz->interface)->dealloc = dealloc;
111
112 ((TabViewItemInterface *) clazz->interface)->initWithIdentifier = initWithIdentifier;
113 ((TabViewItemInterface *) clazz->interface)->initWithView = initWithView;
114 ((TabViewItemInterface *) clazz->interface)->setState = setState;
115}
setState(TabViewItem *self, int state)
Sets this TabViewItem's state, which may alter its appearance.
Definition: TabViewItem.c:92
TabViewItem * initWithView(TabViewItem *self, View *view)
Initializes this TabViewItem with the specified View.
Definition: TabViewItem.c:77
TableColumn * initWithIdentifier(TableColumn *self, const char *identifier)
Initializes this TableColumn with the given identifier.
Definition: TableColumn.c:56

◆ initWithIdentifier()

static TabViewItem * initWithIdentifier ( TabViewItem self,
const char *  identifier 
)
static

Definition at line 54 of file TabViewItem.c.

54 {
55
56 self = (TabViewItem *) super(Object, self, init);
57 if (self) {
58 self->identifier = strdup(identifier);
59 assert(self->identifier);
60
61 self->label = $(alloc(Label), initWithText, self->identifier, NULL);
62 assert(self->label);
63
64 self->view = $(alloc(View), initWithFrame, NULL);
65 assert(self->view);
66
67 $(self, setState, TabStateDefault);
68 }
69
70 return self;
71}
@ TabStateDefault
Definition: TabViewItem.h:40
Box * initWithFrame(Box *self, const SDL_Rect *frame)
Initializes this Box with the given frame.
Definition: Box.c:92
CollectionView * init(CollectionView *self, const SDL_Rect *frame)
Initializes this CollectionView with the specified frame and style.
Labels provide a configurable container for Text.
Definition: Label.h:40
Label * initWithText(Label *self, const char *text, Font *font)
Initializes this Label with the given text and Font.
Definition: Label.c:96
View * view
The View this TabViewItem embeds.
Definition: TabViewItem.h:82
Label * label
The Label used to select this tab.
Definition: TabViewItem.h:72
char * identifier
The identifier.
Definition: TabViewItem.h:67
Views are the fundamental building blocks of ObjectivelyMVC user interfaces.
Definition: View.h:133

◆ initWithView()

static TabViewItem * initWithView ( TabViewItem self,
View view 
)
static

Definition at line 77 of file TabViewItem.c.

77 {
78
79 self = $(self, initWithIdentifier, view->identifier ?: classnameof(self));
80 if (self) {
81 release(self->view);
82 self->view = retain(view);
83 }
84
85 return self;
86}
char * identifier
An optional identifier.
Definition: View.h:201

◆ setState()

static void setState ( TabViewItem self,
int  state 
)
static

Definition at line 92 of file TabViewItem.c.

92 {
93
94 self->state = state;
95
96 if (self->state & TabStateSelected) {
97 $((View *) self->label, addClassName, "selected");
98 } else {
99 $((View *) self->label, removeClassName, "selected");
100 }
101}
@ TabStateSelected
Definition: TabViewItem.h:41
int state
The bit mask of TabState.
Definition: TabViewItem.h:77
void addClassName(View *self, const char *className)
Adds the given class name to this View.
Definition: View.c:120
void removeClassName(View *self, const char *className)
Removes the given class name to this View.
Definition: View.c:1158