SubStyle * subStyleFind(SubStyle *s, char *name, int *idx) { SubStyle *found = NULL; assert(s); if(s->styles && name) { int i; /* Check each state */ for(i = 0; i < s->styles->ndata; i++) { SubStyle *style = STYLE(s->styles->data[i]); /* Compare state name */ if(0 == strcmp(name, style->name)) { found = style; if(idx) *idx = i; break; } } } return found; } /* }}} */
static void Draw(void *obj) { AG_Separator *sep = obj; if (!sep->visible) return; switch (sep->type) { case AG_SEPARATOR_HORIZ: STYLE(sep)->SeparatorHoriz(sep); break; case AG_SEPARATOR_VERT: STYLE(sep)->SeparatorVert(sep); break; } }
SubStyle * subStyleNew(void) { SubStyle *s = NULL; /* Create new style */ s = STYLE(subSharedMemoryAlloc(1, sizeof(SubStyle))); s->flags |= SUB_TYPE_STYLE; /* Init style values */ subStyleReset(s, -1); subSharedLogDebugSubtle("new=style\n"); return s; } /* }}} */
static void Draw(void *p) { AG_Textbox *tb = p; STYLE(tb)->TextboxBackground(tb, tb->r, (tb->flags & AG_TEXTBOX_COMBO)); if (tb->lbl != NULL) AG_WidgetDraw(tb->lbl); AG_PushClipRect(tb, tb->r); if (tb->flags & AG_TEXTBOX_MULTILINE) { int d; if (tb->vBar != NULL && AG_ScrollbarVisible(tb->vBar)) { d = WIDTH(tb->vBar); AG_DrawBox(tb, AG_RECT(WIDTH(tb)-d, HEIGHT(tb)-d, d, d), -1, agColors[TEXTBOX_COLOR]); } else if (tb->hBar != NULL && AG_ScrollbarVisible(tb->hBar)) { d = HEIGHT(tb->hBar); AG_DrawBox(tb, AG_RECT(WIDTH(tb)-d, HEIGHT(tb)-d, d, d), -1, agColors[TEXTBOX_COLOR]); } AG_WidgetUpdate(tb); } /* Render the Editable widget, inheriting our Font. */ tb->ed->font = tb->font; AG_WidgetDraw(tb->ed); if (tb->hBar != NULL) AG_WidgetDraw(tb->hBar); if (tb->vBar != NULL) AG_WidgetDraw(tb->vBar); AG_PopClipRect(tb); }
/* StyleInherit {{{ */ static void StyleInherit(SubStyle *s1, SubStyle *s2, int sanitize) { assert(s1 && s2); /* Inherit nset colors */ if(-1 == s1->fg) s1->fg = s2->fg; if(-1 == s1->bg) s1->bg = s2->bg; if(-1 == s1->icon) s1->icon = s2->icon; if(-1 == s1->top) s1->top = s2->top; if(-1 == s1->right) s1->right = s2->right; if(-1 == s1->bottom) s1->bottom = s2->bottom; if(-1 == s1->left) s1->left = s2->left; /* Sanitize icon */ if(sanitize && -1 == s1->icon) s1->icon = s1->fg; /* Inherit unset border, padding and margin */ StyleInheritSides(&s1->border, &s2->border); StyleInheritSides(&s1->padding, &s2->padding); StyleInheritSides(&s1->margin, &s2->margin); /* Check styles */ if(s1->styles) { int i; /* Inherit unset values from parent style */ for(i = 0; i < s1->styles->ndata; i++) { SubStyle *style = STYLE(s1->styles->data[i]); StyleInherit(style, s1, True); } } } /* }}} */
void shoes_app_reset_styles(shoes_app *app) { app->styles = rb_hash_new(); STYLE(cBanner, size, 48); STYLE(cTitle, size, 34); STYLE(cSubtitle, size, 26); STYLE(cTagline, size, 18); STYLE(cCaption, size, 14); STYLE(cPara, size, 12); STYLE(cInscription, size, 10); STYLE(cCode, family, monospace); STYLE(cDel, strikethrough, single); STYLE(cEm, emphasis, italic); STYLE(cIns, underline, single); STYLE(cLink, underline, single); STYLE(cLink, stroke, #06E); STYLE(cLinkHover, underline, single); STYLE(cLinkHover, stroke, #039); STYLE(cLinkHover, fill, #EEE); STYLE(cStrong, weight, bold); STYLE(cSup, rise, 10); STYLE(cSup, size, x-small); STYLE(cSub, rise, -10); STYLE(cSub, size, x-small); }