ObjectivelyMVC 0.1.0
Object oriented MVC framework for OpenGL, SDL2 and GNU C
TableHeaderView.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 "TableHeaderView.h"
27
28#define _Class _TableHeaderView
29
30#pragma mark - View
31
35static void render(View *self, Renderer *renderer) {
36
37 super(View, self, render, renderer);
38
39 const SDL_Rect frame = $(self, renderFrame);
40
41 $(renderer, setDrawColor, &self->borderColor);
42
43 SDL_Point points[2];
44
45 points[0].x = frame.x;
46 points[0].y = frame.y + frame.h;
47
48 points[1].x = frame.x + frame.w;
49 points[1].y = frame.y + frame.h;
50
51 $(renderer, drawLine, points);
52
53 $(renderer, setDrawColor, &Colors.White);
54}
55
56#pragma mark - TableHeaderView
57
63 return (TableHeaderView *) super(TableRowView, self, initWithTableView, tableView);
64}
65
66#pragma mark - Class lifecycle
67
71static void initialize(Class *clazz) {
72
73 ((ViewInterface *) clazz->interface)->render = render;
74
75 ((TableHeaderViewInterface *) clazz->interface)->initWithTableView = initWithTableView;
76}
77
82Class *_TableHeaderView(void) {
83 static Class *clazz;
84 static Once once;
85
86 do_once(&once, {
87 clazz = _initialize(&(const ClassDef) {
88 .name = "TableHeaderView",
89 .superclass = _TableRowView(),
90 .instanceSize = sizeof(TableHeaderView),
91 .interfaceOffset = offsetof(TableHeaderView, interface),
92 .interfaceSize = sizeof(TableHeaderViewInterface),
94 });
95 });
96
97 return clazz;
98}
99
100#undef _Class
101
static void initialize(Class *clazz)
Header rows for TableViews.
W3C Color constants.
Definition: Colors.h:37
SDL_Color White
Definition: Colors.h:185
The Renderer is responsible for rasterizing the View hierarchy of a WindowController.
Definition: Renderer.h:50
void drawLine(const Renderer *self, const SDL_Point *points)
Draws a line segment between two points using GL_LINE_STRIP.
Definition: Renderer.c:94
void setDrawColor(Renderer *self, const SDL_Color *color)
Sets the primary color for drawing operations.
Definition: Renderer.c:281
The header row is a specialized TableRow depicting the TableColumn handles.
TableHeaderView * initWithTableView(TableHeaderView *self, TableView *tableView)
Initializes this TableHeaderView with the give table.
Class * _TableHeaderView(void)
The TableHeaderView archetype.
Rows for TableViews.
Definition: TableRowView.h:44
Class * _TableRowView(void)
The TableRowView archetype.
Definition: TableRowView.c:162
TableViews provide sortable, tabular presentations of data.
Definition: TableView.h:122
Views are the fundamental building blocks of ObjectivelyMVC user interfaces.
Definition: View.h:133
SDL_Color borderColor
The border color.
Definition: View.h:164
SDL_Rect renderFrame(const View *self)
Definition: View.c:1275
void render(View *self, Renderer *renderer)
Renders this View using the given renderer.
Definition: Control.c:131