X-Git-Url: https://codewiz.org/gitweb?a=blobdiff_plain;f=gui%2Fmenu.c;h=f02324ecf2c2b02e4738cb500dcc5f8b18a73fdd;hb=07382ad480794063a2d5be63547eb288034d9832;hp=289b9b6c92f792cbc1d5683d49053cca5f741125;hpb=04e64923302910207dfa44340d21ec27aef67ef1;p=bertos.git diff --git a/gui/menu.c b/gui/menu.c old mode 100755 new mode 100644 index 289b9b6c..f02324ec --- a/gui/menu.c +++ b/gui/menu.c @@ -1,9 +1,34 @@ -/*! +/** * \file * * * \version $Id$ @@ -16,6 +41,15 @@ /*#* *#* $Log$ + *#* Revision 1.8 2006/09/13 13:58:32 bernie + *#* Add RenderHook support. + *#* + *#* Revision 1.7 2006/08/01 12:22:46 bernie + *#* Mention DevLib license. + *#* + *#* Revision 1.6 2006/07/19 12:56:27 bernie + *#* Convert to new Doxygen style. + *#* *#* Revision 1.5 2006/06/03 13:58:01 bernie *#* Fix recursive timeout and add exit status information. *#* @@ -51,6 +85,7 @@ *#*/ #include "menu.h" + #include #include #include @@ -82,6 +117,7 @@ #define PTRMSG(x) ((const char *)x) #endif + /* Temporary fake defines for ABORT stuff... */ #define abort_top 0 #define PUSH_ABORT false @@ -153,6 +189,39 @@ static void menu_update_menubar( #endif /* CONFIG_MENU_MENUBAR */ +static void menu_defaultRenderHook(struct Bitmap *bm, int ypos, bool selected, const struct MenuItem *item) +{ + if (item->flags & MIF_CHECKIT) + { + gfx_rectClear(bm, 0, ypos, + bm->font->height, ypos + bm->font->height); + + if (item->flags & MIF_TOGGLE) + gfx_rectDraw(bm, 2, ypos + 2, + bm->font->height - 2, ypos + bm->font->height - 2); + if (item->flags & MIF_CHECKED) + { + gfx_line(bm, + 3, ypos + 3, + bm->font->height - 3, ypos + bm->font->height - 3); + gfx_line(bm, + bm->font->height - 3, ypos + 3, + 3, ypos + bm->font->height - 3); + } + } + +#if CPU_HARVARD + ((item->flags & MIF_RAMLABEL) ? text_xyprintf : text_xyprintf_P) +#else + text_xyprintf +#endif + ( + bm, (item->flags & MIF_CHECKIT) ? bm->font->height : 0, ypos, + selected ? (STYLEF_INVERT | TEXT_FILL) : TEXT_FILL, + PTRMSG(item->label) + ); +} + /** * Show a menu on the display. */ @@ -248,35 +317,11 @@ static void menu_layout( /* Only print visible items */ if (!(item->flags & MIF_HIDDEN)) { - if (item->flags & MIF_CHECKIT) - { - gfx_rectClear(bm, 0, ypos, - bm->font->height, ypos + bm->font->height); + /* Check if a special render function is supplied, otherwise use defaults */ + RenderHook renderhook = (item->flags & MIF_RENDERHOOK) ? (RenderHook)item->label : menu_defaultRenderHook; - if (item->flags & MIF_TOGGLE) - gfx_rectDraw(bm, 2, ypos + 2, - bm->font->height - 2, ypos + bm->font->height - 2); - if (item->flags & MIF_CHECKED) - { - gfx_line(bm, - 3, ypos + 3, - bm->font->height - 3, ypos + bm->font->height - 3); - gfx_line(bm, - bm->font->height - 3, ypos + 3, - 3, ypos + bm->font->height - 3); - } - } - -#if CPU_HARVARD - ((item->flags & MIF_RAMLABEL) ? text_xyprintf : text_xyprintf_P) -#else - text_xyprintf -#endif - ( - bm, (item->flags & MIF_CHECKIT) ? bm->font->height : 0, ypos, - (i == selected) ? (STYLEF_INVERT | TEXT_FILL) : TEXT_FILL, - PTRMSG(item->label) - ); + /* Render menuitem */ + renderhook(menu->bitmap, ypos++, (i == selected), item); ypos += bm->font->height; } @@ -541,7 +586,7 @@ iptr_t menu_handle(const struct Menu *menu) } -/*! +/** * Set flags on a menuitem. * * \param menu Menu owner of the item to change. @@ -561,7 +606,7 @@ int menu_setFlags(struct Menu *menu, int idx, int flags) } -/*! +/** * Clear flags on a menuitem. * * \param menu Menu owner of the item to change.