27#include <Objectively/String.h>
31#define _Class _TabView
42 memset(&this->delegate, 0,
sizeof(this->delegate));
44 release(this->tabPageView);
45 release(this->tabSelectionView);
58 const String *identifier = $((Dictionary *) obj, objectForKeyPath,
"identifier");
69 $((
View *) data, bind, inlets, obj);
89 $(self, bind, inlets, dictionary);
91 const Array *tabs = $(dictionary, objectForKeyPath,
"tabs");
109 if (event->type == SDL_EVENT_MOUSE_BUTTON_UP) {
113 const Array *tabs = (Array *) this->tabs;
114 for (
size_t i = 0; i < tabs->count; i++) {
126 if (event->button.clicks) {
137#pragma mark - TabView
147 $(self->
tabs, addObject, tab);
173 self->
tabs = $$(Array, array);
203 $(self->
tabs, removeObject, tab);
222 int state = tab->
state;
224 if (tab == ((
TabView *) data)->selectedTab) {
241 const Array *
tabs = (Array *) self->
tabs;
289#pragma mark - Class lifecycle
296 ((ObjectInterface *) clazz->interface)->dealloc =
dealloc;
299 ((ViewInterface *) clazz->interface)->init =
init;
300 ((ViewInterface *) clazz->interface)->respondToEvent =
respondToEvent;
302 ((TabViewInterface *) clazz->interface)->addTab =
addTab;
303 ((TabViewInterface *) clazz->interface)->initWithFrame =
initWithFrame;
304 ((TabViewInterface *) clazz->interface)->removeTab =
removeTab;
305 ((TabViewInterface *) clazz->interface)->selectTab =
selectTab;
318 clazz = _initialize(&(
const ClassDef) {
321 .instanceSize =
sizeof(
TabView),
322 .interfaceSize =
sizeof(TabViewInterface),
static void initialize(Class *clazz)
static View * init(View *self)
static void awakeWithDictionary(View *self, const Dictionary *dictionary)
static void dealloc(Object *self)
static Box * initWithFrame(Box *self, const SDL_Rect *frame)
static bool respondToEvent(View *self, const SDL_Event *event)
static void setCurrentPage(PageView *self, View *currentPage)
static void addTab(TabView *self, TabViewItem *tab)
static TabView * initWithFrame(TabView *self, const SDL_Rect *frame)
static View * init(View *self)
static void awakeWithDictionary(View *self, const Dictionary *dictionary)
static bool respondToEvent(View *self, const SDL_Event *event)
static void awakeWithDictionary_tabs(const Array *array, ident obj, ident data)
ArrayEnumerator for awaking TabViewItems.
static void removeTab(TabView *self, TabViewItem *tab)
static void selectTab_enumerate(const Array *array, ident obj, ident data)
ArrayEnumerator for selectTab.
static void selectTab(TabView *self, TabViewItem *tab)
static bool tabWithIdentifier_predicate(const ident obj, ident data)
NULL-safe Predicate for tabWithIdentifier.
static void dealloc(Object *self)
static TabViewItem * tabWithIdentifier(const TabView *self, const char *identifier)
static void initialize(Class *clazz)
Tabbed pages within a single View.
static void setState(TabViewItem *self, int state)
static TableColumn * initWithIdentifier(TableColumn *self, const char *identifier)
@ ViewEventMouseButtonUp
A View has received a mouse button up event.
@ ViewEventClick
A Control received one or more click events.
#define MakeInlets(...)
Creates a null-termianted array of Inlets.
#define MakeInlet(name, type, dest, data)
Creates an Inlet with the specified parameters.
static void resignTouchResponder(View *self)
static bool didReceiveEvent(const View *self, const SDL_Event *event)
static void enumerate(View *self, ViewEnumerator enumerator, ident data)
static void emitViewEvent(View *self, ViewEvent code, ident data)
Inlets enable inbound data binding of View attributes through JSON.
PageViews manage their subviews as pages in a book.
StackViews are containers that manage the arrangement of their subviews.
void(* didAddTab)(TabView *tabView, TabViewItem *tab)
Called when a tab is added.
void(* didSelectTab)(TabView *tabView, TabViewItem *tab)
Called when a tab is selected.
void(* willRemoveTab)(TabView *tabView, TabViewItem *tab)
Called when a tab is to be removed.
TabViews allow for the display of multiple pages of information within a single view.
PageView * tabPageView
The tab content container.
TabViewItem * selectedTab
The selected TabViewItem.
StackView * tabSelectionView
The tab selection container.
TabView * initWithFrame(TabView *self, const SDL_Rect *frame)
Initializes this TabView with the specified frame.
Array * tabs
The TabViewItems.
TabViewDelegate delegate
The TabViewDelegate.
void selectTab(TabView *self, TabViewItem *tab)
Selects the specified TabViewItem.
TabViewItems embed Views in a TabView.
int state
The bit mask of TabState.
View * view
The View this TabViewItem embeds.
Label * label
The Label used to select this tab.
char * identifier
The identifier.
Views are the fundamental building blocks of ObjectivelyMVC user interfaces.
void setNeedsLayout(View *self)
Marks this View as needing layout before it is next drawn.
void addSubview(View *self, View *subview)
Adds a subview to this view, to be drawn above its siblings.
void addClassName(View *self, const char *className)
Adds the given class name to this View.
char * identifier
An optional identifier.
void enumerate(const View *self, ViewEnumerator enumerator, ident data)
SDL_Rect frame
The frame, relative to the superview.
void removeSubview(View *self, View *subview)
Removes the given subview from this View.