use align for text align and caption for text in menus.ccl
This commit is contained in:
parent
05ee7c9ca5
commit
a5f8b81292
3 changed files with 46 additions and 38 deletions
src
|
@ -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_;
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Add table
Reference in a new issue