From a5f8b8129292c2c764a41ddd983884611008ab90 Mon Sep 17 00:00:00 2001 From: nehalmistry <> Date: Tue, 1 Apr 2003 03:14:15 +0000 Subject: [PATCH] use align for text align and caption for text in menus.ccl --- src/include/menus.h | 13 +++++++++ src/ui/menu_proc.cpp | 4 +-- src/ui/script_ui.cpp | 67 ++++++++++++++++++++------------------------ 3 files changed, 46 insertions(+), 38 deletions(-) diff --git a/src/include/menus.h b/src/include/menus.h index 199964fd0..d57a20d7a 100644 --- a/src/include/menus.h +++ b/src/include/menus.h @@ -113,6 +113,9 @@ struct _menuitem_; typedef struct _menuitem_text_ { unsigned char *text; unsigned int tflags; + unsigned char *normalcolor; + unsigned char *reversecolor; + int align; void (*action)(struct _menuitem_ *); } MenuitemText; typedef struct _menuitem_button_ { @@ -120,6 +123,8 @@ typedef struct _menuitem_button_ { int xsize; int ysize; MenuButtonId button; + unsigned char *normalcolor; + unsigned char *reversecolor; void (*handler)(void); unsigned hotkey; } MenuitemButton; @@ -134,6 +139,8 @@ typedef struct _menuitem_pulldown_ { int curopt; int cursel; /* used in popup state */ unsigned int state; + unsigned char *normalcolor; + unsigned char *reversecolor; } MenuitemPulldown; typedef struct _menuitem_listbox_ { void *options; @@ -148,6 +155,8 @@ typedef struct _menuitem_listbox_ { int nlines; int startline; int dohandler; + unsigned char *normalcolor; + unsigned char *reversecolor; void *(*retrieveopt)(struct _menuitem_ *, int); void (*handler)(void); /* for return key */ } MenuitemListbox; @@ -186,6 +195,8 @@ typedef struct _menuitem_input_ { void (*action)(struct _menuitem_ *, int); /* for key */ int nch; int maxch; + unsigned char *normalcolor; + unsigned char *reversecolor; } MenuitemInput; typedef struct _menuitem_gem_ { unsigned char *text; @@ -194,6 +205,8 @@ typedef struct _menuitem_gem_ { int ysize; MenuButtonId button; void (*action)(struct _menuitem_ *); + unsigned char *normalcolor; + unsigned char *reversecolor; } MenuitemGem; struct _menus_; diff --git a/src/ui/menu_proc.cpp b/src/ui/menu_proc.cpp index 511cb7f2a..d3b53b19d 100644 --- a/src/ui/menu_proc.cpp +++ b/src/ui/menu_proc.cpp @@ -947,10 +947,10 @@ global void DrawMenu(Menu *menu) VideoTextHeight(mi->font)+5); SetDefaultTextColors(rc,rc); } - if (mi->d.text.tflags&MI_TFLAGS_CENTERED) + if (mi->d.text.align&MI_TFLAGS_CENTERED) VideoDrawTextCentered(menu->x+mi->xofs,menu->y+mi->yofs, mi->font,mi->d.text.text); - else if (mi->d.text.tflags&MI_TFLAGS_RALIGN) { + else if (mi->d.text.align&MI_TFLAGS_RALIGN) { l = VideoTextLength(mi->font,mi->d.text.text); VideoDrawText(menu->x+mi->xofs-l,menu->y+mi->yofs, mi->font,mi->d.text.text); diff --git a/src/ui/script_ui.cpp b/src/ui/script_ui.cpp index 994f222e1..d4128b1d4 100644 --- a/src/ui/script_ui.cpp +++ b/src/ui/script_ui.cpp @@ -2558,43 +2558,38 @@ local SCM CclDefineMenuItem(SCM list) item->mitype=MI_TYPE_TEXT; item->d.text.text = NULL; - if ( !gh_null_p(gh_car(sublist)) ) { - item->d.text.text=gh_scm2newstr(gh_car(sublist), NULL); - // FIXME: can be removed - if (!strcmp(item->d.text.text, "null")) { - free(item->d.text.text); - item->d.text.text = NULL; - } - } - sublist=gh_cdr(sublist); - value=gh_car(sublist); - if ( gh_eq_p(value,gh_symbol2scm("center")) ) { - item->d.text.tflags=MI_TFLAGS_CENTERED; - } else if ( gh_eq_p(value,gh_symbol2scm("left")) ) { - item->d.text.tflags=MI_TFLAGS_LALIGN; - } else if ( gh_eq_p(value,gh_symbol2scm("right")) ) { - item->d.text.tflags=MI_TFLAGS_RALIGN; - } else if ( gh_eq_p(value,gh_symbol2scm("none")) ) { - item->d.text.tflags=0; - } else { - s1=gh_scm2newstr(gh_car(value),NULL); - fprintf(stderr,"Unknow flag %s\n", s1); - free(s1); - } - - sublist=gh_cdr(sublist); - value=gh_car(sublist); - sublist=gh_cdr(sublist); - if ( gh_eq_p(value, gh_symbol2scm("func")) ) { - s1 = gh_scm2newstr(gh_car(sublist),NULL); - func = (void **)hash_find(MenuFuncHash,s1); - if (func != NULL) { - item->d.text.action=(void *)*func; - } else { - fprintf(stderr,"Can't find function: %s\n", s1); - } - free(s1); + while ( !gh_null_p(sublist) ) { + value=gh_car(sublist); sublist=gh_cdr(sublist); + + if ( gh_eq_p(value,gh_symbol2scm("align")) ) { + value=gh_car(sublist); + if (gh_eq_p(value,gh_symbol2scm("left")) ) { + item->d.text.align=MI_TFLAGS_LALIGN; + } else if (gh_eq_p(value,gh_symbol2scm("right")) ) { + item->d.text.align=MI_TFLAGS_RALIGN; + } else if (gh_eq_p(value,gh_symbol2scm("center")) ) { + item->d.text.align=MI_TFLAGS_CENTERED; + } + } else if ( gh_eq_p(value,gh_symbol2scm("caption")) ) { + if ( !gh_null_p(gh_car(sublist)) ) { + item->d.text.text=gh_scm2newstr(gh_car(sublist), NULL); + } + } else if ( gh_eq_p(value, gh_symbol2scm("func")) ) { + value=gh_car(sublist); + s1 = gh_scm2newstr(value,NULL); + func = (void **)hash_find(MenuFuncHash,s1); + if (func != NULL) { + item->d.text.action=(void *)*func; + } else { + fprintf(stderr,"Can't find function: %s\n", s1); + } + free(s1); + } else { + //s1=gh_scm2newstr(value, NULL); + //fprintf(stderr, "Unsupported property %s\n", s1); + //free(s1); + } } } else if ( gh_eq_p(value,gh_symbol2scm("button")) ) { sublist=gh_car(list);