ObjectivelyMVC
Object oriented MVC framework for SDL3 and GNU C
Loading...
Searching...
No Matches
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.
 
TabViewIteminitWithIdentifier (TabViewItem *self, const char *identifier)
 Initializes this TabViewItem with the specified identifier.
 
TabViewIteminitWithView (TabViewItem *self, View *view)
 Initializes this TabViewItem with the specified View.
 
 setState (TabViewItem *self, int state)
 Sets this TabViewItem's state, which may alter its appearance.
 

Data Fields

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

Protected Attributes

TabViewItemInterface * interface
 The interface.
 

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 122 of file TabViewItem.c.

122 {
123 static Class *clazz;
124 static Once once;
125
126 do_once(&once, {
127 clazz = _initialize(&(const ClassDef) {
128 .name = "TabViewItem",
129 .superclass = _Object(),
130 .instanceSize = sizeof(TabViewItem),
131 .interfaceOffset = offsetof(TabViewItem, interface),
132 .interfaceSize = sizeof(TabViewItemInterface),
134 });
135 });
136
137 return clazz;
138}
static void initialize(Class *clazz)
Definition Box.c:123
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 55 of file TabViewItem.c.

55 {
56
57 self = (TabViewItem *) super(Object, self, init);
58 if (self) {
59 self->identifier = strdup(identifier);
60 assert(self->identifier);
61
62 self->label = $(alloc(Label), initWithText, self->identifier, NULL);
63 assert(self->label);
64
65 self->view = $(alloc(View), initWithFrame, NULL);
66 assert(self->view);
67
68 $(self, setState, TabStateDefault);
69 }
70
71 return self;
72}
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:97
@ 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:93
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:134

◆ 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 78 of file TabViewItem.c.

78 {
79
80 self = $(self, initWithIdentifier, view->identifier ?: classnameof(self));
81 if (self) {
82 release(self->view);
83 self->view = retain(view);
84 }
85
86 return self;
87}
TabViewItem * initWithIdentifier(TabViewItem *self, const char *identifier)
Initializes this TabViewItem with the specified identifier.
Definition TabViewItem.c:55
char * identifier
An optional identifier.
Definition View.h:202

◆ 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 93 of file TabViewItem.c.

93 {
94
95 self->state = state;
96
97 if (self->state & TabStateSelected) {
98 $((View *) self->label, addClassName, "selected");
99 } else {
100 $((View *) self->label, removeClassName, "selected");
101 }
102}
@ TabStateSelected
Definition TabViewItem.h:41
static void removeClassName(View *self, const char *className)
Definition View.c:1344
static void addClassName(View *self, const char *className)
Definition View.c:159
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: