ObjectivelyMVC 0.1.0
Object oriented MVC framework for OpenGL, SDL2 and GNU C
Public Member Functions | Data Fields | Protected Attributes
TabViewItem Struct Reference

TabViewItems embed Views in a TabView. More...

#include <TabViewItem.h>

Inheritance diagram for TabViewItem:

Public Member Functions

Class * _TabViewItem (void)
 The TabViewItem archetype. More...
 
TabViewIteminitWithIdentifier (TabViewItem *self, const char *identifier)
 Initializes this TabViewItem with the specified identifier. More...
 
TabViewIteminitWithView (TabViewItem *self, View *view)
 Initializes this TabViewItem with the specified View. More...
 
 setState (TabViewItem *self, int state)
 Sets this TabViewItem's state, which may alter its appearance. More...
 

Data Fields

char * identifier
 The identifier. More...
 
Labellabel
 The Label used to select this tab. More...
 
Object object
 The superclass. More...
 
int state
 The bit mask of TabState. More...
 
Viewview
 The View this TabViewItem embeds. More...
 

Protected Attributes

TabViewItemInterface * interface
 The interface. More...
 

Detailed Description

TabViewItems embed Views in a TabView.

Definition at line 51 of file TabViewItem.h.

Member Function Documentation

◆ _TabViewItem()

Class * _TabViewItem ( void  )

The TabViewItem archetype.

Returns
The TabViewItem Class.

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
TabViewItemInterface * interface
The interface.
Definition: TabViewItem.h:62

◆ initWithIdentifier()

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

Initializes this TabViewItem with the specified identifier.

Parameters
selfThe TabViewItem.
identifierThe identifier.
Returns
The initialized TabViewItem, or NULL on error.
Remarks
Designated initializer.

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}
static View * init(View *self)
Definition: Box.c:67
static Box * initWithFrame(Box *self, const SDL_Rect *frame)
Definition: Box.c:92
static Label * initWithText(Label *self, const char *text, Font *font)
Definition: Label.c:96
@ TabStateDefault
Definition: TabViewItem.h:40
Labels provide a configurable container for Text.
Definition: Label.h:40
setState(TabViewItem *self, int state)
Sets this TabViewItem's state, which may alter its appearance.
Definition: TabViewItem.c:92
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()

TabViewItem * initWithView ( TabViewItem self,
View view 
)

Initializes this TabViewItem with the specified View.

Parameters
selfThe TabViewItem.
viewThe View to embed.
Returns
The initialized TabViewItem, or NULL on error.

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}
TabViewItem * initWithIdentifier(TabViewItem *self, const char *identifier)
Initializes this TabViewItem with the specified identifier.
Definition: TabViewItem.c:54
char * identifier
An optional identifier.
Definition: View.h:201

◆ setState()

setState ( TabViewItem self,
int  state 
)

Sets this TabViewItem's state, which may alter its appearance.

Parameters
selfThe TabViewItem.
stateThe state.
Remarks
Subclasses may override this method to apply custom styling.

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
static void removeClassName(View *self, const char *className)
Definition: View.c:1158
static void addClassName(View *self, const char *className)
Definition: View.c:120
int state
The bit mask of TabState.
Definition: TabViewItem.h:77

Field Documentation

◆ identifier

char* TabViewItem::identifier

The identifier.

Definition at line 67 of file TabViewItem.h.

◆ interface

TabViewItemInterface* TabViewItem::interface
protected

The interface.

Definition at line 62 of file TabViewItem.h.

◆ label

Label* TabViewItem::label

The Label used to select this tab.

Definition at line 72 of file TabViewItem.h.

◆ object

Object TabViewItem::object

The superclass.

Definition at line 56 of file TabViewItem.h.

◆ state

int TabViewItem::state

The bit mask of TabState.

Definition at line 77 of file TabViewItem.h.

◆ view

View* TabViewItem::view

The View this TabViewItem embeds.

Definition at line 82 of file TabViewItem.h.


The documentation for this struct was generated from the following files: