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

Go to the source code of this file.

Macros

#define _Class   _TabViewController
 

Functions

Class * _TabViewController (void)
 
static void addChildViewController (ViewController *self, ViewController *childViewController)
 
static void dealloc (Object *self)
 
static TabViewControllerinit (TabViewController *self)
 
static void initialize (Class *clazz)
 
static void loadView (ViewController *self)
 
static void removeChildViewController (ViewController *self, ViewController *childViewController)
 
static TabViewItemtabForViewController (const TabViewController *self, const ViewController *viewController)
 
static _Bool tabForViewController_predicate (const ident obj, ident data)
 Predicate for tabViewItemFor. More...
 

Macro Definition Documentation

◆ _Class

#define _Class   _TabViewController

Definition at line 28 of file TabViewController.c.

Function Documentation

◆ _TabViewController()

Class * _TabViewController ( void  )

Definition at line 148 of file TabViewController.c.

148 {
149 static Class *clazz;
150 static Once once;
151
152 do_once(&once, {
153 clazz = _initialize(&(const ClassDef) {
154 .name = "TabViewController",
155 .superclass = _ViewController(),
156 .instanceSize = sizeof(TabViewController),
157 .interfaceOffset = offsetof(TabViewController, interface),
158 .interfaceSize = sizeof(TabViewControllerInterface),
160 });
161 });
162
163 return clazz;
164}
static void initialize(Class *clazz)
TabViewControllers arrange and manage their child ViewControllers in a tab view interface.
Class * _ViewController(void)
The ViewController archetype.

◆ addChildViewController()

static void addChildViewController ( ViewController self,
ViewController childViewController 
)
static
See also
ViewController::addChildViewController(ViewController *, ViewController *)

Definition at line 68 of file TabViewController.c.

68 {
69
70 super(ViewController, self, addChildViewController, childViewController);
71
72 TabViewController *this = (TabViewController *) self;
73
74 TabViewItem *tab = $(alloc(TabViewItem), initWithView, childViewController->view);
75
76 $(this->tabView, addTab, tab);
77
78 release(tab);
79}
void addTab(TabView *self, TabViewItem *tab)
Adds the specified TabViewItem to this TabView.
Definition: TabView.c:131
TabViewItems embed Views in a TabView.
Definition: TabViewItem.h:51
TabViewItem * initWithView(TabViewItem *self, View *view)
Initializes this TabViewItem with the specified View.
Definition: TabViewItem.c:77
A ViewController manages a View and its descendants.
View * view
The main view.
void addChildViewController(ViewController *self, ViewController *childViewController)
Adds the specified child ViewController to this ViewController.

◆ dealloc()

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

Definition at line 35 of file TabViewController.c.

35 {
36
37 TabViewController *this = (TabViewController *) self;
38
39 release(this->tabView);
40
41 super(Object, self, dealloc);
42}
static void dealloc(Object *self)

◆ init()

static TabViewController * init ( TabViewController self)
static

Definition at line 101 of file TabViewController.c.

101 {
102 return (TabViewController *) super(ViewController, self, init);
103}
CollectionView * init(CollectionView *self, const SDL_Rect *frame)
Initializes this CollectionView with the specified frame and style.

◆ initialize()

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

Definition at line 132 of file TabViewController.c.

132 {
133
134 ((ObjectInterface *) clazz->interface)->dealloc = dealloc;
135
136 ((ViewControllerInterface *) clazz->interface)->loadView = loadView;
137 ((ViewControllerInterface *) clazz->interface)->addChildViewController = addChildViewController;
138 ((ViewControllerInterface *) clazz->interface)->removeChildViewController = removeChildViewController;
139
140 ((TabViewControllerInterface *) clazz->interface)->init = init;
141 ((TabViewControllerInterface *) clazz->interface)->tabForViewController = tabForViewController;
142}
TabViewItem * tabForViewController(const TabViewController *self, const ViewController *viewController)
Returns the TabViewItem for the specified child ViewController, or NULL.
void loadView(ViewController *self)
Loads this ViewController's View.
void removeChildViewController(ViewController *self, ViewController *childViewController)
Removes the specified child ViewController from this ViewController.

◆ loadView()

static void loadView ( ViewController self)
static
See also
ViewController::loadView(ViewController *)

Definition at line 49 of file TabViewController.c.

49 {
50
51 super(ViewController, self, loadView);
52
54
55 TabViewController *this = (TabViewController *) self;
56
57 this->tabView = $(alloc(TabView), initWithFrame, NULL);
58 assert(this->tabView);
59
60 this->tabView->delegate.self = this;
61
62 $(self->view, addSubview, (View *) this->tabView);
63}
@ ViewAutoresizingContain
Definition: View.h:91
Box * initWithFrame(Box *self, const SDL_Rect *frame)
Initializes this Box with the given frame.
Definition: Box.c:92
TabViews allow for the display of multiple pages of information within a single view.
Definition: TabView.h:79
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
int autoresizingMask
The ViewAutoresizing bitmask.
Definition: View.h:154

◆ removeChildViewController()

static void removeChildViewController ( ViewController self,
ViewController childViewController 
)
static
See also
ViewController::removeChildViewController(ViewController *, ViewController *)

Definition at line 84 of file TabViewController.c.

84 {
85
86 super(ViewController, self, removeChildViewController, childViewController);
87
88 TabViewController *this = (TabViewController *) self;
89
90 TabViewItem *tab = $(this, tabForViewController, childViewController);
91
92 $(this->tabView, removeTab, tab);
93}
void removeTab(TabView *self, TabViewItem *tab)
Removes the specified TabViewItem from this TabView.
Definition: TabView.c:181

◆ tabForViewController()

static TabViewItem * tabForViewController ( const TabViewController self,
const ViewController viewController 
)
static

Definition at line 116 of file TabViewController.c.

116 {
117
118 assert(viewController);
119
120 if (viewController->view) {
121 return $((Array *) self->tabView->tabs, findObject, tabForViewController_predicate, (ident) viewController->view);
122 }
123
124 return NULL;
125}
static _Bool tabForViewController_predicate(const ident obj, ident data)
Predicate for tabViewItemFor.
TabView * tabView
The TabView.
MutableArray * tabs
The TabViewItems.
Definition: TabView.h:115

◆ tabForViewController_predicate()

static _Bool tabForViewController_predicate ( const ident  obj,
ident  data 
)
static

Predicate for tabViewItemFor.

Definition at line 108 of file TabViewController.c.

108 {
109 return ((TabViewItem *) obj)->view == data;
110}