ObjectivelyMVC
Object oriented MVC framework for SDL3 and GNU C
Loading...
Searching...
No Matches
CollectionItemView.c File Reference
#include <assert.h>
#include "CollectionItemView.h"

Go to the source code of this file.

Macros

#define _Class   _CollectionItemView
 

Functions

Class * _CollectionItemView (void)
 
static void dealloc (Object *self)
 
static void initialize (Class *clazz)
 
static CollectionItemViewinitWithFrame (CollectionItemView *self, const SDL_Rect *frame)
 
static bool matchesSelector (const View *self, const SimpleSelector *simpleSelector)
 
static void setSelected (CollectionItemView *self, bool isSelected)
 

Macro Definition Documentation

◆ _Class

#define _Class   _CollectionItemView

Definition at line 28 of file CollectionItemView.c.

Function Documentation

◆ _CollectionItemView()

Class * _CollectionItemView ( void  )

Definition at line 137 of file CollectionItemView.c.

137 {
138 static Class *clazz;
139 static Once once;
140
141 do_once(&once, {
142 clazz = _initialize(&(const ClassDef) {
143 .name = "CollectionItemView",
144 .superclass = _View(),
145 .instanceSize = sizeof(CollectionItemView),
146 .interfaceOffset = offsetof(CollectionItemView, interface),
147 .interfaceSize = sizeof(CollectionItemViewInterface),
149 });
150 });
151
152 return clazz;
153}
static void initialize(Class *clazz)
Class * _View(void)
Definition View.c:2067
CollectionViewItems are a visual representation of an item within a CollectionView.

◆ dealloc()

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

Definition at line 35 of file CollectionItemView.c.

35 {
36
38
39 release(this->imageView);
40 release(this->selectionOverlay);
41 release(this->text);
42
43 super(Object, self, dealloc);
44}
static void dealloc(Object *self)

◆ initialize()

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

Definition at line 123 of file CollectionItemView.c.

123 {
124
125 ((ObjectInterface *) clazz->interface)->dealloc = dealloc;
126
127 ((ViewInterface *) clazz->interface)->matchesSelector = matchesSelector;
128
129 ((CollectionItemViewInterface *) clazz->interface)->initWithFrame = initWithFrame;
130 ((CollectionItemViewInterface *) clazz->interface)->setSelected = setSelected;
131}
static void setSelected(CollectionItemView *self, bool isSelected)
static bool matchesSelector(const View *self, const SimpleSelector *simpleSelector)
static CollectionItemView * initWithFrame(CollectionItemView *self, const SDL_Rect *frame)
void setSelected(CollectionItemView *self, bool isSelected)
Sets the selected state of this item.

◆ initWithFrame()

static CollectionItemView * initWithFrame ( CollectionItemView self,
const SDL_Rect *  frame 
)
static

Definition at line 77 of file CollectionItemView.c.

77 {
78
79 self = (CollectionItemView *) super(View, self, initWithFrame, frame);
80 if (self) {
81 self->imageView = $(alloc(ImageView), initWithFrame, frame);
82 assert(self->imageView);
83
85
86 $((View *) self, addSubview, (View *) self->imageView);
87
88 self->text = $(alloc(Text), initWithText, NULL, NULL);
89 assert(self->text);
90
91 self->text->view.alignment = ViewAlignmentMiddleCenter;
92
93 $((View *) self, addSubview, (View *) self->text);
94
95 self->selectionOverlay = $(alloc(View), initWithFrame, NULL);
96 assert(self->selectionOverlay);
97
98 $(self->selectionOverlay, addClassName, "selectionOverlay");
99
100 self->selectionOverlay->autoresizingMask = ViewAutoresizingFill;
101
102 $((View *) self, addSubview, self->selectionOverlay);
103
104 self->view.clipsSubviews = true;
105 }
106
107 return self;
108}
static Label * initWithText(Label *self, const char *text, Font *font)
Definition Label.c:97
static void addSubview(View *self, View *subview)
Definition PageView.c:49
static void addClassName(View *self, const char *className)
Definition View.c:159
@ ViewAutoresizingFill
Definition View.h:90
@ ViewAlignmentMiddleCenter
Definition View.h:73
ImageView * imageView
The ImageView.
ImageViews render an Image in the context of a View hierarchy.
Definition ImageView.h:45
View view
The superclass.
Definition ImageView.h:50
Text rendered with TrueType fonts.
Definition Text.h:69
Views are the fundamental building blocks of ObjectivelyMVC user interfaces.
Definition View.h:134
bool clipsSubviews
If true, subviews will be clipped to this View's frame.
Definition View.h:181
ViewAlignment alignment
The alignment.
Definition View.h:150
int autoresizingMask
The ViewAutoresizing bitmask.
Definition View.h:155

◆ matchesSelector()

static bool matchesSelector ( const View self,
const SimpleSelector simpleSelector 
)
static
See also
View::matchesSelector(const View *, const SimpleSelector *)

Definition at line 51 of file CollectionItemView.c.

51 {
52
53 assert(simpleSelector);
54
55 const CollectionItemView *this = (CollectionItemView *) self;
56 const char *pattern = simpleSelector->pattern;
57
58 switch (simpleSelector->type) {
60 if (strcmp("selected", pattern) == 0) {
61 return this->isSelected;
62 }
63 break;
64 default:
65 break;
66 }
67
68 return super(View, self, matchesSelector, simpleSelector);
69}
static bool isSelected(const Control *self)
Definition Control.c:335
@ SimpleSelectorTypePseudo
SimpleSelectorType type
The SimpleSelectorType.
char * pattern
The pattern, as provided by the user.

◆ setSelected()

static void setSelected ( CollectionItemView self,
bool  isSelected 
)
static

Definition at line 114 of file CollectionItemView.c.

114 {
115 self->isSelected = isSelected;
116}
bool isSelected
True when this item is selected, false otherwise.