ObjectivelyMVC
Object oriented MVC framework for SDL3 and GNU C
Loading...
Searching...
No Matches
TableHeaderView.c
Go to the documentation of this file.
1/*
2 * ObjectivelyMVC: Object oriented MVC framework for SDL3 and 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 SDL_Point points[2];
42
43 points[0].x = frame.x;
44 points[0].y = frame.y + frame.h;
45
46 points[1].x = frame.x + frame.w;
47 points[1].y = frame.y + frame.h;
48
49 $(renderer, drawLine, points, &self->borderColor);
50}
51
52#pragma mark - TableHeaderView
53
59 return (TableHeaderView *) super(TableRowView, self, initWithTableView, tableView);
60}
61
62#pragma mark - Class lifecycle
63
67static void initialize(Class *clazz) {
68
69 ((ViewInterface *) clazz->interface)->render = render;
70
71 ((TableHeaderViewInterface *) clazz->interface)->initWithTableView = initWithTableView;
72}
73
78Class *_TableHeaderView(void) {
79 static Class *clazz;
80 static Once once;
81
82 do_once(&once, {
83 clazz = _initialize(&(const ClassDef) {
84 .name = "TableHeaderView",
85 .superclass = _TableRowView(),
86 .instanceSize = sizeof(TableHeaderView),
87 .interfaceOffset = offsetof(TableHeaderView, interface),
88 .interfaceSize = sizeof(TableHeaderViewInterface),
90 });
91 });
92
93 return clazz;
94}
95
96#undef _Class
97
static void drawLine(const Renderer *self, const SDL_Point *points, const SDL_Color *color)
Definition Renderer.c:114
static TableHeaderView * initWithTableView(TableHeaderView *self, TableView *tableView)
Class * _TableHeaderView(void)
static void render(View *self, Renderer *renderer)
static void initialize(Class *clazz)
Header rows for TableViews.
Class * _TableRowView(void)
static SDL_Rect renderFrame(const View *self)
Definition View.c:1455
Renderer extends Object with ObjectivelyMVC's UI rendering layer.
Definition Renderer.h:70
The header row is a specialized TableRow depicting the TableColumn handles.
Rows for TableViews.
TableViews provide sortable, tabular presentations of data.
Definition TableView.h:122
Views are the fundamental building blocks of ObjectivelyMVC user interfaces.
Definition View.h:134
SDL_Color borderColor
The border color.
Definition View.h:165