summaryrefslogtreecommitdiff
path: root/src/ui
diff options
context:
space:
mode:
Diffstat (limited to 'src/ui')
-rw-r--r--src/ui/widget.c15
-rw-r--r--src/ui/widget.h2
2 files changed, 15 insertions, 2 deletions
diff --git a/src/ui/widget.c b/src/ui/widget.c
index 69509e33..e83532d4 100644
--- a/src/ui/widget.c
+++ b/src/ui/widget.c
@@ -45,6 +45,7 @@ void init_Widget(iWidget *d) {
45 d->flags = 0; 45 d->flags = 0;
46 d->rect = zero_Rect(); 46 d->rect = zero_Rect();
47 d->bgColor = none_ColorId; 47 d->bgColor = none_ColorId;
48 d->frameColor = none_ColorId;
48 d->children = NULL; 49 d->children = NULL;
49 d->parent = NULL; 50 d->parent = NULL;
50 d->commandHandler = NULL; 51 d->commandHandler = NULL;
@@ -114,6 +115,10 @@ void setBackgroundColor_Widget(iWidget *d, int bgColor) {
114 d->bgColor = bgColor; 115 d->bgColor = bgColor;
115} 116}
116 117
118void setFrameColor_Widget(iWidget *d, int frameColor) {
119 d->frameColor = frameColor;
120}
121
117void setCommandHandler_Widget(iWidget *d, iBool (*handler)(iWidget *, const char *)) { 122void setCommandHandler_Widget(iWidget *d, iBool (*handler)(iWidget *, const char *)) {
118 d->commandHandler = handler; 123 d->commandHandler = handler;
119} 124}
@@ -392,10 +397,16 @@ iBool processEvent_Widget(iWidget *d, const SDL_Event *ev) {
392 397
393void draw_Widget(const iWidget *d) { 398void draw_Widget(const iWidget *d) {
394 if (d->flags & hidden_WidgetFlag) return; 399 if (d->flags & hidden_WidgetFlag) return;
395 if (d->bgColor >= 0) { 400 if (d->bgColor >= 0 || d->frameColor >= 0) {
401 const iRect rect = bounds_Widget(d);
396 iPaint p; 402 iPaint p;
397 init_Paint(&p); 403 init_Paint(&p);
398 fillRect_Paint(&p, bounds_Widget(d), d->bgColor); 404 if (d->bgColor >= 0) {
405 fillRect_Paint(&p, rect, d->bgColor);
406 }
407 if (d->frameColor >= 0) {
408 drawRect_Paint(&p, rect, d->frameColor);
409 }
399 } 410 }
400 iConstForEach(ObjectList, i, d->children) { 411 iConstForEach(ObjectList, i, d->children) {
401 const iWidget *child = constAs_Widget(i.object); 412 const iWidget *child = constAs_Widget(i.object);
diff --git a/src/ui/widget.h b/src/ui/widget.h
index af3934e6..3155d6df 100644
--- a/src/ui/widget.h
+++ b/src/ui/widget.h
@@ -65,6 +65,7 @@ struct Impl_Widget {
65 int flags; 65 int flags;
66 iRect rect; 66 iRect rect;
67 int bgColor; 67 int bgColor;
68 int frameColor;
68 iObjectList *children; 69 iObjectList *children;
69 iWidget * parent; 70 iWidget * parent;
70 iBool (*commandHandler)(iWidget *, const char *); 71 iBool (*commandHandler)(iWidget *, const char *);
@@ -113,6 +114,7 @@ void setFlags_Widget (iWidget *, int flags, iBool set);
113void setPos_Widget (iWidget *, iInt2 pos); 114void setPos_Widget (iWidget *, iInt2 pos);
114void setSize_Widget (iWidget *, iInt2 size); 115void setSize_Widget (iWidget *, iInt2 size);
115void setBackgroundColor_Widget (iWidget *, int bgColor); 116void setBackgroundColor_Widget (iWidget *, int bgColor);
117void setFrameColor_Widget (iWidget *, int frameColor);
116void setCommandHandler_Widget (iWidget *, iBool (*handler)(iWidget *, const char *)); 118void setCommandHandler_Widget (iWidget *, iBool (*handler)(iWidget *, const char *));
117iAny * addChild_Widget (iWidget *, iAnyObject *child); /* holds a ref */ 119iAny * addChild_Widget (iWidget *, iAnyObject *child); /* holds a ref */
118iAny * addChildPos_Widget (iWidget *, iAnyObject *child, enum iWidgetAddPos addPos); 120iAny * addChildPos_Widget (iWidget *, iAnyObject *child, enum iWidgetAddPos addPos);