28#include "../Assets/check.png.h"
30#define _Class _Checkbox
43 memset(&this->delegate, 0,
sizeof(this->delegate));
66 $(self, bind, inlets, dictionary);
87 const View *box = (
View *) this->box;
89 switch (event->type) {
90 case SDL_EVENT_MOUSE_BUTTON_DOWN:
96 case SDL_EVENT_MOUSE_BUTTON_UP:
99 self->
state &= ~ControlStateHighlighted;
100 if (this->delegate.didToggle) {
101 this->delegate.didToggle(
this);
107 case SDL_EVENT_KEY_DOWN:
108 switch (event->key.key) {
114 self->
state &= ~ControlStateHighlighted;
115 if (this->delegate.didToggle) {
116 this->delegate.didToggle(
this);
126#pragma mark - Checkbox
154#pragma mark - Class lifecycle
161 ((ObjectInterface *) clazz->interface)->dealloc =
dealloc;
164 ((ViewInterface *) clazz->interface)->init =
init;
166 ((ControlInterface *) clazz->interface)->captureEvent =
captureEvent;
189 clazz = _initialize(&(
const ClassDef) {
193 .interfaceOffset = offsetof(
Checkbox, interface),
194 .interfaceSize =
sizeof(CheckboxInterface),
static void destroy(Class *clazz)
static View * init(View *self)
static void awakeWithDictionary(View *self, const Dictionary *dictionary)
static bool captureEvent(Control *self, const SDL_Event *event)
static Checkbox * initWithFrame(Checkbox *self, const SDL_Rect *frame)
static void dealloc(Object *self)
static void initialize(Class *clazz)
Checkboxes are toggle Controls that respond to click events.
@ ControlStateHighlighted
static Image * initWithBytes(Image *self, const uint8_t *bytes, size_t length)
static void addSubview(View *self, View *subview)
@ ViewEventChange
A Control's input value has changed.
#define MakeInlets(...)
Creates a null-termianted array of Inlets.
#define MakeInlet(name, type, dest, data)
Creates an Inlet with the specified parameters.
static bool didReceiveEvent(const View *self, const SDL_Event *event)
static void emitViewEvent(View *self, ViewEvent code, ident data)
@ ViewAlignmentMiddleCenter
Checkboxes are toggle Controls that respond to click events.
ImageView * check
The check.
Controls are Views which capture and respond to events.
unsigned int state
The bit mask of ControlState.
ImageViews render an Image in the context of a View hierarchy.
Inlets enable inbound data binding of View attributes through JSON.
Views are the fundamental building blocks of ObjectivelyMVC user interfaces.
ViewAlignment alignment
The alignment.
int autoresizingMask
The ViewAutoresizing bitmask.
void awakeWithDictionary(View *, const Dictionary *)
Wakes this View with the specified Dictionary.
View * initWithFrame(View *self, const SDL_Rect *frame)
Initializes this View with the specified frame.