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

TabViews allow for the display of multiple pages of information within a single view. More...

#include <TabView.h>

Inheritance diagram for TabView:
View

Public Member Functions

Class * _TabView (void)
 The TabView archetype. More...
 
void addTab (TabView *self, TabViewItem *tab)
 Adds the specified TabViewItem to this TabView. More...
 
TabViewinitWithFrame (TabView *self, const SDL_Rect *frame)
 Initializes this TabView with the specified frame. More...
 
void removeTab (TabView *self, TabViewItem *tab)
 Removes the specified TabViewItem from this TabView. More...
 
void selectTab (TabView *self, TabViewItem *tab)
 Selects the specified TabViewItem. More...
 
TabViewItemtabWithIdentifier (const TabView *self, const char *identifier)
 
- Public Member Functions inherited from View
Class * _View (void)
 The View archetype. More...
 
_Bool acceptsFirstResponder (const View *self)
 
void addClassName (View *self, const char *className)
 Adds the given class name to this View. More...
 
void addSubview (View *self, View *subview)
 Adds a subview to this view, to be drawn above its siblings. More...
 
void addSubviewRelativeTo (View *self, View *subview, View *other, ViewPosition position)
 Adds a subview to this view, positioned relatively to other. More...
 
 ancestorWithIdentifier (const View *self, const char *identifier)
 
void applyStyle (View *self, const Style *style)
 Applies the given Style to this View. More...
 
void applyTheme (View *self, const Theme *theme)
 Applies the given Theme to this View. More...
 
void applyThemeIfNeeded (View *self, const Theme *theme)
 Recursively applies the Theme to this View and its subviews. More...
 
void attachStylesheet (View *self, SDL_Window *window)
 Attaches this View's Stylesheet to the Theme associated with the given window. More...
 
void awakeWithCharacters (View *self, const char *chars)
 Wakes this View with the given null-terminated JSON C string. More...
 
void awakeWithData (View *self, const Data *data)
 Wakes this View with the specified JSON Data. More...
 
void awakeWithDictionary (View *self, const Dictionary *dictionary)
 Wakes this View with the specified Dictionary. More...
 
void awakeWithResource (View *self, const Resource *resource)
 Wakes this View with the specified Resource. More...
 
void awakeWithResourceName (View *self, const char *name)
 Wakes this View with the Resource by the specified name. More...
 
void becomeFirstResponder (View *self)
 Become the first responder in the View hierarchy. More...
 
_Bool bind (View *self, const Inlet *inlets, const Dictionary *dictionary)
 Performs data binding for the Inlets described in dictionary. More...
 
SDL_Rect bounds (const View *self)
 
void bringSubviewToFront (View *self, View *subview)
 Brings the specified subview to the front. More...
 
SDL_Rect clippingFrame (const View *self)
 
_Bool containsPoint (const View *self, const SDL_Point *point)
 
int depth (const View *self)
 
 descendantWithIdentifier (const View *self, const char *identifier)
 
void detachStylesheet (View *self, SDL_Window *window)
 Detaches this View's Stylesheet from the Theme associated with the given window. More...
 
void didMoveToWindow (View *self, SDL_Window *window)
 Informs this View that it has been added to the View hierachy of the given window. More...
 
_Bool didReceiveEvent (const View *self, const SDL_Event *event)
 
void * draw (View *self, Renderer *renderer)
 Draws this View. More...
 
void enumerate (const View *self, ViewEnumerator enumerator, ident data)
 
void enumerate (View *self, ViewEnumerator enumerator, ident data)
 Enumerates this View and its descendants, applying enumerator to each. More...
 
void enumerateAdjacent (const View *self, ViewEnumerator enumerator, ident data)
 Enumerates adjacent siblings of this View, applying enumerator to each. More...
 
void enumerateAncestors (const View *self, ViewEnumerator enumerator, ident data)
 Enumerates all ancestors of this View, applying enumerator to each. More...
 
void enumerateDescendants (const View *self, ViewEnumerator enumerator, ident data)
 Enumerates all descendants of this View, applying enumerator to each. More...
 
void enumerateSelection (View *self, const char *rule, ViewEnumerator enumerator, ident data)
 Enumerates all Views in the selection matched by rule, applying enumerator to each. More...
 
void enumerateSiblings (const View *self, ViewEnumerator enumerator, ident data)
 Enumerates all siblings of this View, applying enumerator to each. More...
 
void enumerateSubviews (const View *self, ViewEnumerator enumerator, ident data)
 Enumerates all subviews of this View, applying enumerator to each. More...
 
void enumerateSuperview (const View *self, ViewEnumerator enumerator, ident data)
 Enumerates the superview of this View, if any, applying enumerator to it. More...
 
ViewfirstResponder (SDL_Window *window)
 
_Bool hasClassName (const View *self, cosnt char *className)
 
ViewhitTest (const View *self, const SDL_Point *point)
 Performs a hit test against this View and its descendants for the given point. More...
 
Viewinit (View *self)
 Initializes this View. More...
 
ViewinitWithFrame (View *self, const SDL_Rect *frame)
 Initializes this View with the specified frame. More...
 
void invalidateStyle (View *self)
 Invalidates the computed Style for this View and its descendants. More...
 
_Bool isContainer (const View *self)
 
_Bool isDescendantOfView (const View *self, const View *view)
 
_Bool isFirstResponder (const View *self)
 
_Bool isVisible (const View *self)
 
void layoutIfNeeded (View *self)
 Recursively updates the layout of this View and its subviews. More...
 
 layoutSubviews (View *self)
 Performs layout for this View's immediate subviews. More...
 
_Bool matchesSelector (const View *self, const SimpleSelector *simpleSelector)
 
void moveToWindow (View *self, SDL_Window *window)
 Moves this View to the View hierarchy of the given window. More...
 
String * path (const View *self)
 
void removeAllClassNames (View *self)
 Removes all class names from this View. More...
 
void removeAllSubviews (View *self)
 Removes all subviews from this View. More...
 
void removeClassName (View *self, const char *className)
 Removes the given class name to this View. More...
 
void removeFromSuperview (View *self)
 Removes this View from its superview. More...
 
void removeSubview (View *self, View *subview)
 Removes the given subview from this View. More...
 
void render (View *self, Renderer *renderer)
 Renders this View using the given renderer. More...
 
void renderDeviceDidReset (View *self)
 Informs this View that the render device has reset. More...
 
void renderDeviceWillReset (View *self)
 Informs this View that the render device will reset. More...
 
SDL_Rect renderFrame (const View *self)
 
void replaceSubview (View *self, View *subview, View *replacement)
 Replaces the specified subview with the given replacement. More...
 
void resignFirstResponder (View *self)
 Resigns first responder priority. More...
 
void resize (View *self, const SDL_Size *size)
 Resizes this View to the specified size. More...
 
void resolve (View *self, Outlet *outlets)
 Resolves the given Outlets from this View's hierarchy. More...
 
void respondToEvent (View *self, const SDL_Event *event)
 Responds to the specified event. More...
 
Set * select (View *self, const char *rule)
 Resolves all descendants (including this View) that match the given Selector rule. More...
 
void setFirstResponder (SDL_Window *window, View *view)
 Sets the first responder for the given window. More...
 
SDL_Size size (const View *self)
 
SDL_Size sizeThatContains (const View *self)
 
void sizeThatFits (const View *self)
 
void sizeToContain (View *self)
 Resizes this View to contain its subviews. More...
 
void sizeToFit (View *self)
 Resizes this View to fit its subviews. More...
 
 subviewWithIdentifier (const View *self, const char *identifier)
 
void updateBindings (View *self)
 Updates data bindings, prompting the appropriate layout changes. More...
 
SDL_Rect viewport (const View *self)
 
ViewviewWithCharacters (const char *chars, Outlet *outlets)
 Instantiates a View initialized with the given null-terminated JSON C string. More...
 
ViewviewWithData (const Data *data, Outlet *outlets)
 Instantiates a View initialized with the contents of data. More...
 
ViewviewWithDictionary (const Dictionary *dictionary, Outlet *outlets)
 Instantiates a View initialized with the attributes described in dictionary. More...
 
ViewviewWithResource (const Resource *resource, Outlet *outlets)
 Instantiates a View initialized with the JSON data in resource. More...
 
ViewviewWithResourceName (const char *name, Outlet *outlets)
 Instantiates a View initialized with the JSON Resource with the specified name. More...
 
Array * visibleSubviews (const View *self)
 
void warn (View *self, const char *fmt,...)
 Appends a warning for this View. More...
 
void willMoveToWindow (View *self, SDL_Window *window)
 Informs this View that it will be added to the View hierarchy for the given window. More...
 

Data Fields

TabViewDelegate delegate
 The TabViewDelegate. More...
 
TabViewItemselectedTab
 The selected TabViewItem. More...
 
StackView stackView
 The superclass. More...
 
PageViewtabPageView
 The tab content container. More...
 
MutableArray * tabs
 The TabViewItems. More...
 
StackViewtabSelectionView
 The tab selection container. More...
 
- Data Fields inherited from View
ViewAlignment alignment
 The alignment. More...
 
int autoresizingMask
 The ViewAutoresizing bitmask. More...
 
SDL_Color backgroundColor
 The background color. More...
 
SDL_Color borderColor
 The border color. More...
 
int borderWidth
 The border width. More...
 
MutableSet * classNames
 The class names. More...
 
_Bool clipsSubviews
 If true, subviews will be clipped to this View's frame. More...
 
StylecomputedStyle
 The computed Style of this View. More...
 
SDL_Rect frame
 The frame, relative to the superview. More...
 
_Bool hidden
 If true, this View is not drawn. More...
 
char * identifier
 An optional identifier. More...
 
SDL_Size maxSize
 The maximum size this View may be resized to during layout. More...
 
SDL_Size minSize
 The minimum size this View may be resized to during layout. More...
 
_Bool needsApplyTheme
 If true, this View will apply the Theme before it is drawn. More...
 
_Bool needsLayout
 If true, this View will layout its subviews before it is drawn. More...
 
ViewnextResponder
 The next responder, or event handler, in the chain. More...
 
Object object
 The superclass. More...
 
ViewPadding padding
 The padding. More...
 
Stylestyle
 The element-level Style of this View. More...
 
Stylesheetstylesheet
 An optional Stylesheet. More...
 
MutableArray * subviews
 The immediate subviews. More...
 
Viewsuperview
 The super View. More...
 
ViewControllerviewController
 The ViewController. More...
 
MutableArray * warnings
 The warnings this View generated. More...
 
SDL_Window * window
 The window. More...
 

Protected Attributes

TabViewInterface * interface
 The interface. More...
 
- Protected Attributes inherited from View
ViewInterface * interface
 The interface. More...
 

Detailed Description

TabViews allow for the display of multiple pages of information within a single view.

Definition at line 79 of file TabView.h.

Member Function Documentation

◆ _TabView()

Class * _TabView ( void  )

The TabView archetype.

Returns
The TabView Class.

Definition at line 301 of file TabView.c.

301 {
302 static Class *clazz;
303 static Once once;
304
305 do_once(&once, {
306 clazz = _initialize(&(const ClassDef) {
307 .name = "TabView",
308 .superclass = _StackView(),
309 .instanceSize = sizeof(TabView),
310 .interfaceOffset = offsetof(TabView, interface),
311 .interfaceSize = sizeof(TabViewInterface),
313 });
314 });
315
316 return clazz;
317}
Class * _StackView(void)
Definition: StackView.c:262
static void initialize(Class *clazz)
Definition: TabView.c:282
TabViews allow for the display of multiple pages of information within a single view.
Definition: TabView.h:79
TabViewInterface * interface
The interface.
Definition: TabView.h:90

◆ addTab()

void addTab ( TabView self,
TabViewItem tab 
)

Adds the specified TabViewItem to this TabView.

Parameters
selfThe TabView.
tabThe TabViewItem.

Definition at line 131 of file TabView.c.

131 {
132
133 assert(tab);
134
135 $(self->tabs, addObject, tab);
136
137 $((View *) self->tabSelectionView, addSubview, (View *) tab->label);
138 $((View *) self->tabPageView, addSubview, tab->view);
139
140 if (self->delegate.didAddTab) {
141 self->delegate.didAddTab(self, tab);
142 }
143
144 if (self->selectedTab == NULL) {
145 $(self, selectTab, tab);
146 }
147}
void(* didAddTab)(TabView *tabView, TabViewItem *tab)
Called when a tab is added.
Definition: TabView.h:57
PageView * tabPageView
The tab content container.
Definition: TabView.h:105
TabViewItem * selectedTab
The selected TabViewItem.
Definition: TabView.h:100
MutableArray * tabs
The TabViewItems.
Definition: TabView.h:115
StackView * tabSelectionView
The tab selection container.
Definition: TabView.h:110
TabViewDelegate delegate
The TabViewDelegate.
Definition: TabView.h:95
void selectTab(TabView *self, TabViewItem *tab)
Selects the specified TabViewItem.
Definition: TabView.c:225
View * view
The View this TabViewItem embeds.
Definition: TabViewItem.h:82
Label * label
The Label used to select this tab.
Definition: TabViewItem.h:72
Views are the fundamental building blocks of ObjectivelyMVC user interfaces.
Definition: View.h:133
void addSubview(View *self, View *subview)
Adds a subview to this view, to be drawn above its siblings.
Definition: PageView.c:35

◆ initWithFrame()

TabView * initWithFrame ( TabView self,
const SDL_Rect *  frame 
)

Initializes this TabView with the specified frame.

Parameters
selfThe TabView.
frameThe frame.
Returns
The initialized TabView, or NULL on error.

Definition at line 153 of file TabView.c.

153 {
154
155 self = (TabView *) super(StackView, self, initWithFrame, frame);
156 if (self) {
157
158 self->tabPageView = $(alloc(PageView), initWithFrame, NULL);
159 assert(self->tabPageView);
160
161 self->tabs = $$(MutableArray, array);
162 assert(self->tabs);
163
164 self->tabSelectionView = $(alloc(StackView), initWithFrame, NULL);
165 assert(self->tabSelectionView);
166
167 $((View *) self->tabSelectionView, addClassName, "tabSelectionView");
168 $((View *) self, addSubview, (View *) self->tabSelectionView);
169
170 $((View *) self->tabPageView, addClassName, "tabPageView");
171 $((View *) self, addSubview, (View *) self->tabPageView);
172 }
173
174 return self;
175}
PageViews manage their subviews as pages in a book.
Definition: PageView.h:60
StackViews are containers that manage the arrangement of their subviews.
Definition: StackView.h:68
TabView * initWithFrame(TabView *self, const SDL_Rect *frame)
Initializes this TabView with the specified frame.
Definition: TabView.c:153
void addClassName(View *self, const char *className)
Adds the given class name to this View.
Definition: View.c:120
SDL_Rect frame
The frame, relative to the superview.
Definition: View.h:190

◆ removeTab()

void removeTab ( TabView self,
TabViewItem tab 
)

Removes the specified TabViewItem from this TabView.

Parameters
selfThe TabView.
tabThe TabViewItem.

Definition at line 181 of file TabView.c.

181 {
182
183 assert(tab);
184
185 if (self->delegate.willRemoveTab) {
186 self->delegate.willRemoveTab(self, tab);
187 }
188
189 retain(tab);
190
191 $(self->tabs, removeObject, tab);
192
193 $((View *) self->tabSelectionView, removeSubview, (View *) tab->label);
194 $((View *) self->tabPageView, removeSubview, tab->view);
195
196 if (self->selectedTab == tab) {
197 $(self, selectTab, NULL);
198 }
199
200 release(tab);
201}
void(* willRemoveTab)(TabView *tabView, TabViewItem *tab)
Called when a tab is to be removed.
Definition: TabView.h:71
void removeSubview(View *self, View *subview)
Removes the given subview from this View.
Definition: PageView.c:58

◆ selectTab()

void selectTab ( TabView self,
TabViewItem tab 
)

Selects the specified TabViewItem.

Parameters
selfThe TabView.
tabThe TabViewItem.

Definition at line 225 of file TabView.c.

225 {
226
227 if (self->selectedTab != tab) {
228
229 const Array *tabs = (Array *) self->tabs;
230
231 if (tab) {
232 self->selectedTab = tab;
233 } else {
234 self->selectedTab = $(tabs, firstObject);
235 }
236
237 $(tabs, enumerateObjects, selectTab_enumerate, self);
238
239 if (self->selectedTab) {
240 $(self->tabPageView, setCurrentPage, self->selectedTab->view);
241
242 if (self->delegate.didSelectTab) {
243 self->delegate.didSelectTab(self, self->selectedTab);
244 }
245 }
246
247 self->stackView.view.needsLayout = true;
248 }
249}
static void setCurrentPage(PageView *self, View *currentPage)
Definition: PageView.c:116
static void selectTab_enumerate(const Array *array, ident obj, ident data)
ArrayEnumerator for selectTab.
Definition: TabView.c:206
View view
The superclass.
Definition: StackView.h:73
void(* didSelectTab)(TabView *tabView, TabViewItem *tab)
Called when a tab is selected.
Definition: TabView.h:64
StackView stackView
The superclass.
Definition: TabView.h:84
_Bool needsLayout
If true, this View will layout its subviews before it is drawn.
Definition: View.h:221

◆ tabWithIdentifier()

TabViewItem * tabWithIdentifier ( const TabView self,
const char *  identifier 
)
Parameters
selfThe TabView.
identifierThe identifier of the desired TabViewItem.
Returns
The TabViewItem with the specified identifier.

Definition at line 273 of file TabView.c.

273 {
274 return $((Array *) self->tabs, findObject, tabWithIdentifier_predicate, (ident) identifier);
275}
static _Bool tabWithIdentifier_predicate(const ident obj, ident data)
NULL-safe Predicate for tabWithIdentifier.
Definition: TabView.c:254
char * identifier
An optional identifier.
Definition: View.h:201

Field Documentation

◆ delegate

TabViewDelegate TabView::delegate

The TabViewDelegate.

Definition at line 95 of file TabView.h.

◆ interface

TabViewInterface* TabView::interface
protected

The interface.

Definition at line 90 of file TabView.h.

◆ selectedTab

TabViewItem* TabView::selectedTab

The selected TabViewItem.

Definition at line 100 of file TabView.h.

◆ stackView

StackView TabView::stackView

The superclass.

Definition at line 84 of file TabView.h.

◆ tabPageView

PageView* TabView::tabPageView

The tab content container.

Definition at line 105 of file TabView.h.

◆ tabs

MutableArray* TabView::tabs

The TabViewItems.

Definition at line 115 of file TabView.h.

◆ tabSelectionView

StackView* TabView::tabSelectionView

The tab selection container.

Definition at line 110 of file TabView.h.


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