ObjectivelyMVC 0.1.0
Object oriented MVC framework for OpenGL, SDL2 and GNU C
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
TableCellView.c
Go to the documentation of this file.
1/*
2 * ObjectivelyMVC: Object oriented MVC framework for OpenGL, SDL2 and GNU C.
3 * Copyright (C) 2014 Jay Dolan <jay@jaydolan.com>
4 *
5 * This software is provided 'as-is', without any express or implied
6 * warranty. In no event will the authors be held liable for any damages
7 * arising from the use of this software.
8 *
9 * Permission is granted to anyone to use this software for any purpose,
10 * including commercial applications, and to alter it and redistribute it
11 * freely, subject to the following restrictions:
12 *
13 * 1. The origin of this software must not be misrepresented; you must not
14 * claim that you wrote the original software. If you use this software
15 * in a product, an acknowledgment in the product documentation would be
16 * appreciated but is not required.
17 *
18 * 2. Altered source versions must be plainly marked as such, and must not be
19 * misrepresented as being the original software.
20 *
21 * 3. This notice may not be removed or altered from any source distribution.
22 */
23
24#include <assert.h>
25
26#include "TableCellView.h"
27
28#define _Class _TableCellView
29
30#pragma mark - Object
31
35static void dealloc(Object *self) {
36
37 TableCellView *this = (TableCellView *) self;
38
39 release(this->text);
40
41 super(Object, self, dealloc);
42}
43
44#pragma mark - TableCellView
45
50static TableCellView *initWithFrame(TableCellView *self, const SDL_Rect *frame) {
51
52 self = (TableCellView *) super(View, self, initWithFrame, frame);
53 if (self) {
54 self->text = $(alloc(Text), initWithText, NULL, NULL);
55 assert(self->text);
56
57 $((View *) self, addSubview, (View *) self->text);
58 }
59
60 return self;
61}
62
63#pragma mark - Class lifecycle
64
68static void initialize(Class *clazz) {
69
70 ((ObjectInterface *) clazz->interface)->dealloc = dealloc;
71
72 ((TableCellViewInterface *) clazz->interface)->initWithFrame = initWithFrame;
73}
74
79Class *_TableCellView(void) {
80 static Class *clazz;
81 static Once once;
82
83 do_once(&once, {
84 clazz = _initialize(&(const ClassDef) {
85 .name = "TableCellView",
86 .superclass = _View(),
87 .instanceSize = sizeof(TableCellView),
88 .interfaceOffset = offsetof(TableCellView, interface),
89 .interfaceSize = sizeof(TableCellViewInterface),
91 });
92 });
93
94 return clazz;
95}
96
97#undef _Class
98
static void dealloc(Object *self)
Definition: TableCellView.c:35
static void initialize(Class *clazz)
Definition: TableCellView.c:68
Each row in a TableView is comprised of TableCellViews.
Box * initWithFrame(Box *self, const SDL_Rect *frame)
Initializes this Box with the given frame.
Definition: Box.c:92
Label * initWithText(Label *self, const char *text, Font *font)
Initializes this Label with the given text and Font.
Definition: Label.c:96
Each row in a TableView is comprised of TableCellViews.
Definition: TableCellView.h:41
Class * _TableCellView(void)
The TableCellView archetype.
Definition: TableCellView.c:79
Text * text
The text.
Definition: TableCellView.h:57
Text rendered with TrueType fonts.
Definition: Text.h:41
Views are the fundamental building blocks of ObjectivelyMVC user interfaces.
Definition: View.h:133
Class * _View(void)
The View archetype.
Definition: View.c:1769
void addSubview(View *self, View *subview)
Adds a subview to this view, to be drawn above its siblings.
Definition: PageView.c:35