48#define _Class _Control
100 $(self, bind, inlets, (Dictionary *) style->
attributes);
117 $(self, bind, inlets, dictionary);
149 assert(simpleSelector);
153 switch (simpleSelector->
type) {
155 if (strcmp(
"highlighted", simpleSelector->
pattern) == 0) {
157 }
else if (strcmp(
"disabled", simpleSelector->
pattern) == 0) {
159 }
else if (strcmp(
"selected", simpleSelector->
pattern) == 0) {
161 }
else if (strcmp(
"focused", simpleSelector->
pattern) == 0) {
163 }
else if (strcmp(
"single", simpleSelector->
pattern) == 0) {
165 }
else if (strcmp(
"multiple", simpleSelector->
pattern) == 0) {
191 points[0].x = frame.x;
192 points[0].y = frame.y + frame.h;
194 points[1].x = frame.x + frame.w;
195 points[1].y = frame.y + frame.h;
197 points[2].x = frame.x + frame.w;
198 points[2].y = frame.y;
202 points[0].x = frame.x;
203 points[0].y = frame.y + frame.h;
205 points[1].x = frame.x;
206 points[1].y = frame.y;
208 points[2].x = frame.x + frame.w;
209 points[2].y = frame.y;
217 points[0].x = frame.x;
218 points[0].y = frame.y + frame.h;
220 points[1].x = frame.x + frame.w;
221 points[1].y = frame.y + frame.h;
223 points[2].x = frame.x + frame.w;
224 points[2].y = frame.y;
228 points[0].x = frame.x;
229 points[0].y = frame.y + frame.h;
231 points[1].x = frame.x;
232 points[1].y = frame.y;
234 points[2].x = frame.x + frame.w;
235 points[2].y = frame.y;
254 this->state &= ~ControlStateHighlighted;
255 this->state &= ~ControlStateFocused;
273 if (this->state != state) {
283#pragma mark - Control
355 this->needsLayout =
true;
358#pragma mark - Class lifecycle
365 ((ObjectInterface *) clazz->interface)->dealloc =
dealloc;
369 ((ViewInterface *) clazz->interface)->applyStyle =
applyStyle;
372 ((ViewInterface *) clazz->interface)->init =
init;
374 ((ViewInterface *) clazz->interface)->render =
render;
376 ((ViewInterface *) clazz->interface)->respondToEvent =
respondToEvent;
378 ((ControlInterface *) clazz->interface)->captureEvent =
captureEvent;
379 ((ControlInterface *) clazz->interface)->initWithFrame =
initWithFrame;
381 ((ControlInterface *) clazz->interface)->isFocused =
isFocused;
382 ((ControlInterface *) clazz->interface)->isHighlighted =
isHighlighted;
383 ((ControlInterface *) clazz->interface)->isSelected =
isSelected;
384 ((ControlInterface *) clazz->interface)->stateDidChange =
stateDidChange;
396 clazz = _initialize(&(
const ClassDef) {
398 .superclass =
_View(),
399 .instanceSize =
sizeof(
Control),
400 .interfaceOffset = offsetof(
Control, interface),
401 .interfaceSize =
sizeof(ControlInterface),
const EnumName ControlBevelNames[]
const EnumName ControlSelectionNames[]
static void becomeKeyResponder(View *self)
static void stateDidChange(Control *self)
static bool acceptsKeyResponder(const View *self)
static View * init(View *self)
static void awakeWithDictionary(View *self, const Dictionary *dictionary)
static Control * initWithFrame(Control *self, const SDL_Rect *frame)
const EnumName ControlStateNames[]
static void respondToEvent(View *self, const SDL_Event *event)
static void applyStyle(View *self, const Style *style)
static bool matchesSelector(const View *self, const SimpleSelector *simpleSelector)
static bool captureEvent(Control *self, const SDL_Event *event)
static bool isHighlighted(const Control *self)
static void render(View *self, Renderer *renderer)
static void dealloc(Object *self)
static void resignKeyResponder(View *self)
static bool isDisabled(const Control *self)
static void initialize(Class *clazz)
static bool acceptsTouchResponder(const View *self)
static bool isFocused(const Control *self)
static bool isSelected(const Control *self)
Controls are Views which capture and respond to events.
@ ControlSelectionMultiple
ControlState
Control states, which are bit-masked.
@ ControlStateHighlighted
static void drawLines(const Renderer *self, const SDL_Point *points, size_t count, const SDL_Color *color)
static void drawRect(const Renderer *self, const SDL_Rect *rect, const SDL_Color *color)
@ SimpleSelectorTypePseudo
@ ViewEventFocus
A Control's state has focus.
@ ViewEventBlur
A Control has lost focus.
#define MakeInlets(...)
Creates a null-termianted array of Inlets.
#define MakeInlet(name, type, dest, data)
Creates an Inlet with the specified parameters.
static void invalidateStyle(View *self)
static SDL_Rect renderFrame(const View *self)
static void emitViewEvent(View *self, ViewEvent code, ident data)
Controls are Views which capture and respond to events.
unsigned int state
The bit mask of ControlState.
bool isDisabled(const Control *self)
Inlets enable inbound data binding of View attributes through JSON.
Renderer extends Object with ObjectivelyMVC's UI rendering layer.
SimpleSelectorType type
The SimpleSelectorType.
char * pattern
The pattern, as provided by the user.
Views are the fundamental building blocks of ObjectivelyMVC user interfaces.
bool matchesSelector(const View *self, const SimpleSelector *simpleSelector)