|
|
| version 1.1, 2003/11/21 06:51:10 | version 1.2, 2003/11/21 09:28:02 |
|---|---|
| Line 1 | Line 1 |
| #include "compiler.h" | #include "compiler.h" |
| #include "strres.h" | |
| #include "fontmng.h" | #include "fontmng.h" |
| #include "vramhdl.h" | #include "vramhdl.h" |
| #include "vrammix.h" | #include "vrammix.h" |
| Line 8 | Line 9 |
| typedef struct _dprm { | typedef struct _dprm { |
| struct _dprm *next; | struct _dprm *next; |
| int width; | UINT16 width; |
| UINT16 num; | |
| VRAMHDL icon; | VRAMHDL icon; |
| char str[128]; | char str[96]; |
| } _DLGPRM, *DLGPRM; | } _DLGPRM, *DLGPRM; |
| #define PRMNEXT_EMPTY ((DLGPRM)-1) | #define PRMNEXT_EMPTY ((DLGPRM)-1) |
| Line 115 static DLGPRM resappend(MENUDLG dlg, con | Line 117 static DLGPRM resappend(MENUDLG dlg, con |
| } | } |
| if (prm) { | if (prm) { |
| prm->next = NULL; | prm->next = NULL; |
| prm->icon = NULL; | |
| prm->width = 0; | prm->width = 0; |
| prm->num = 0; | |
| prm->icon = NULL; | |
| prm->str[0] = '\0'; | prm->str[0] = '\0'; |
| if (str) { | if (str) { |
| milstr_ncpy(prm->str, str, sizeof(prm->str)); | milstr_ncpy(prm->str, str, sizeof(prm->str)); |
| Line 130 static void resattachicon(MENUDLG dlg, D | Line 133 static void resattachicon(MENUDLG dlg, D |
| if (prm) { | if (prm) { |
| menuicon_unlock(prm->icon); | menuicon_unlock(prm->icon); |
| prm->num = icon; | |
| prm->icon = menuicon_lock(icon, width, height, dlg->vram->bpp); | prm->icon = menuicon_lock(icon, width, height, dlg->vram->bpp); |
| } | } |
| } | } |
| Line 166 static DLGHDL dlghdlsea(MENUDLG dlg, MEN | Line 170 static DLGHDL dlghdlsea(MENUDLG dlg, MEN |
| return((DLGHDL)listarray_enum(dlg->dlg, dsbyid, (void *)(long)id)); | return((DLGHDL)listarray_enum(dlg->dlg, dsbyid, (void *)(long)id)); |
| } | } |
| static BOOL gettextsz(DLGHDL hdl, POINT_T *sz) { | |
| DLGPRM prm; | |
| prm = hdl->prm; | |
| if (prm == NULL) { | |
| goto gts_err; | |
| } | |
| *sz = hdl->c.dt.pt; | |
| if (prm->icon) { | |
| if (sz->x) { | |
| #if defined(SIZE_QVGA) | |
| sz->x += 1; | |
| #else | |
| sz->x += 2; | |
| #endif | |
| } | |
| sz->x += sz->y; | |
| } | |
| return(SUCCESS); | |
| gts_err: | |
| return(FAILURE); | |
| } | |
| static void getleft(POINT_T *pt, const RECT_T *rect, const POINT_T *sz) { | static void getleft(POINT_T *pt, const RECT_T *rect, const POINT_T *sz) { |
| Line 174 static void getleft(POINT_T *pt, const R | Line 202 static void getleft(POINT_T *pt, const R |
| (void)sz; | (void)sz; |
| } | } |
| static void getcenter(POINT_T *pt, const RECT_T *rect, const POINT_T *sz) { | static void getcenter(POINT_T *pt, const RECT_T *rect, const POINT_T *sz) { |
| pt->x = rect->left; | pt->x = rect->left; |
| Line 188 static void getright(POINT_T *pt, const | Line 215 static void getright(POINT_T *pt, const |
| pt->y = rect->top; | pt->y = rect->top; |
| } | } |
| static void getmid(POINT_T *pt, const RECT_T *rect, const POINT_T *sz) { | static void getmid(POINT_T *pt, const RECT_T *rect, const POINT_T *sz) { |
| pt->x = rect->left; | pt->x = rect->left; |
| Line 200 static void getmid(POINT_T *pt, const RE | Line 226 static void getmid(POINT_T *pt, const RE |
| static BOOL _cre_settext(MENUDLG dlg, DLGHDL hdl, const void *arg) { | static BOOL _cre_settext(MENUDLG dlg, DLGHDL hdl, const void *arg) { |
| hdl->prm = resappend(dlg, (char *)arg); | const char *str; |
| str = (char *)arg; | |
| if (str == NULL) { | |
| str = str_null; | |
| } | |
| hdl->prm = resappend(dlg, str); | |
| hdl->c.dt.font = dlg->font; | hdl->c.dt.font = dlg->font; |
| fontmng_getsize(dlg->font, (char *)arg, &hdl->c.dt.pt); | fontmng_getsize(dlg->font, str, &hdl->c.dt.pt); |
| return(SUCCESS); | return(SUCCESS); |
| } | } |
| static void dlg_text(MENUDLG dlg, DLGHDL hdl, | static void dlg_text(MENUDLG dlg, DLGHDL hdl, |
| const POINT_T *pt, const RECT_T *rect) { | const POINT_T *pt, const RECT_T *rect) { |
| VRAMHDL icon; | |
| const char *string; | const char *string; |
| int color; | int color; |
| POINT_T fp; | |
| POINT_T p; | POINT_T p; |
| if (hdl->prm == NULL) { | if (hdl->prm == NULL) { |
| goto dgtx_exit; | return; |
| } | |
| string = hdl->prm->str; | |
| if (string == NULL) { | |
| goto dgtx_exit; | |
| } | } |
| if (!(hdl->flag & MENU_GRAY)) { | fp = *pt; |
| color = MVC_TEXT; | icon = hdl->prm->icon; |
| if (icon) { | |
| if (icon->alpha) { | |
| vramcpy_cpyex(dlg->vram, &fp, icon, NULL); | |
| } | |
| else { | |
| vramcpy_cpy(dlg->vram, &fp, icon, NULL); | |
| } | |
| fp.x += icon->width; | |
| #if defined(SIZE_QVGA) | |
| fp.x += 1; | |
| #else | |
| fp.x += 2; | |
| #endif | |
| } | } |
| else { | string = hdl->prm->str; |
| p.x = pt->x + MENU_DSTEXT; | if (string) { |
| p.y = pt->y + MENU_DSTEXT; | if (!(hdl->flag & MENU_GRAY)) { |
| vrammix_text(dlg->vram, hdl->c.dt.font, string, | color = MVC_TEXT; |
| } | |
| else { | |
| p.x = fp.x + MENU_DSTEXT; | |
| p.y = fp.y + MENU_DSTEXT; | |
| vrammix_text(dlg->vram, hdl->c.dt.font, string, | |
| menucolor[MVC_GRAYTEXT2], &p, rect); | menucolor[MVC_GRAYTEXT2], &p, rect); |
| color = MVC_GRAYTEXT1; | color = MVC_GRAYTEXT1; |
| } | |
| vrammix_text(dlg->vram, hdl->c.dt.font, string, | |
| menucolor[color], &fp, rect); | |
| } | } |
| p.x = pt->x; | |
| p.y = pt->y; | |
| vrammix_text(dlg->vram, hdl->c.dt.font, string, | |
| menucolor[color], &p, rect); | |
| dgtx_exit: | |
| return; | |
| } | } |
| Line 352 static void dlgclose_rel(MENUDLG dlg, DL | Line 395 static void dlgclose_rel(MENUDLG dlg, DL |
| static void dlgbtn_paint(MENUDLG dlg, DLGHDL hdl) { | static void dlgbtn_paint(MENUDLG dlg, DLGHDL hdl) { |
| POINT_T sz; | |
| POINT_T pt; | POINT_T pt; |
| UINT c; | UINT c; |
| Line 364 static void dlgbtn_paint(MENUDLG dlg, DL | Line 408 static void dlgbtn_paint(MENUDLG dlg, DL |
| } | } |
| menuvram_box2(dlg->vram, &hdl->rect, c); | menuvram_box2(dlg->vram, &hdl->rect, c); |
| if (hdl->prm) { | if (gettextsz(hdl, &sz) == SUCCESS) { |
| getmid(&pt, &hdl->rect, &hdl->c.dt.pt); | getmid(&pt, &hdl->rect, &sz); |
| if (hdl->val) { | if (hdl->val) { |
| pt.x += MENU_DSTEXT; | pt.x += MENU_DSTEXT; |
| pt.y += MENU_DSTEXT; | pt.y += MENU_DSTEXT; |
| Line 493 static void dlglist_drawitem(DLGHDL hdl, | Line 537 static void dlglist_drawitem(DLGHDL hdl, |
| vramcpy_cpy(hdl->vram, &fp, icon, NULL); | vramcpy_cpy(hdl->vram, &fp, icon, NULL); |
| } | } |
| fp.x += icon->width; | fp.x += icon->width; |
| } | |
| #if defined(SIZE_QVGA) | #if defined(SIZE_QVGA) |
| fp.x += 1; | fp.x += 1; |
| #else | #else |
| fp.x += 2; | fp.x += 2; |
| #endif | #endif |
| } | |
| vrammix_text(hdl->vram, hdl->c.dl.font, prm->str, | vrammix_text(hdl->vram, hdl->c.dl.font, prm->str, |
| menucolor[focus?MVC_CURTEXT:MVC_TEXT], &fp, rct); | menucolor[focus?MVC_CURTEXT:MVC_TEXT], &fp, rct); |
| } | } |
| Line 1482 static void dlgcheck_onclick(MENUDLG dlg | Line 1526 static void dlgcheck_onclick(MENUDLG dlg |
| static void dlgtext_paint(MENUDLG dlg, DLGHDL hdl) { | static void dlgtext_paint(MENUDLG dlg, DLGHDL hdl) { |
| POINT_T sz; | |
| POINT_T pt; | POINT_T pt; |
| void (*getpt)(POINT_T *pt, const RECT_T *rect, const POINT_T *sz); | void (*getpt)(POINT_T *pt, const RECT_T *rect, const POINT_T *sz); |
| vram_filldat(dlg->vram, &hdl->rect, menucolor[MVC_STATIC]); | vram_filldat(dlg->vram, &hdl->rect, menucolor[MVC_STATIC]); |
| if (hdl->prm) { | if (gettextsz(hdl, &sz) == SUCCESS) { |
| switch(hdl->flag & MST_POSMASK) { | switch(hdl->flag & MST_POSMASK) { |
| case MST_LEFT: | case MST_LEFT: |
| default: | default: |
| Line 1501 static void dlgtext_paint(MENUDLG dlg, D | Line 1546 static void dlgtext_paint(MENUDLG dlg, D |
| getpt = getright; | getpt = getright; |
| break; | break; |
| } | } |
| getpt(&pt, &hdl->rect, &hdl->c.dt.pt); | getpt(&pt, &hdl->rect, &sz); |
| dlg_text(dlg, hdl, &pt, &hdl->rect); | dlg_text(dlg, hdl, &pt, &hdl->rect); |
| } | } |
| } | } |
| static void dlgtext_itemset(MENUDLG dlg, DLGHDL hdl, const void *arg) { | |
| static void dlgtext_itemset(MENUDLG dlg, DLGHDL hdl, const void *str) { | const void *str; |
| if (hdl->prm) { | if (hdl->prm) { |
| if (str) { | str = (char *)arg; |
| milstr_ncpy(hdl->prm->str, (char *)str, sizeof(hdl->prm->str)); | if (str == NULL) { |
| fontmng_getsize(hdl->c.dt.font, (char *)str, &hdl->c.dt.pt); | str = str_null; |
| } | |
| else { | |
| hdl->prm->str[0] = '\0'; | |
| hdl->c.dt.pt.x = 0; | |
| } | } |
| milstr_ncpy(hdl->prm->str, str, sizeof(hdl->prm->str)); | |
| fontmng_getsize(hdl->c.dt.font, str, &hdl->c.dt.pt); | |
| } | |
| (void)dlg; | |
| } | |
| static void dlgtext_iconset(MENUDLG dlg, DLGHDL hdl, const void *arg) { | |
| if (hdl->prm) { | |
| resattachicon(dlg, hdl->prm, (UINT16)(long)arg, | |
| hdl->c.dt.pt.y, hdl->c.dt.pt.y); | |
| } | } |
| (void)dlg; | (void)dlg; |
| } | } |
| Line 2180 void *menudlg_msg(int ctrl, MENUID id, v | Line 2233 void *menudlg_msg(int ctrl, MENUID id, v |
| case DMSG_SETTEXT: | case DMSG_SETTEXT: |
| switch(hdl->type) { | switch(hdl->type) { |
| case DLGTYPE_BUTTON: | |
| case DLGTYPE_RADIO: | case DLGTYPE_RADIO: |
| case DLGTYPE_CHECK: | case DLGTYPE_CHECK: |
| case DLGTYPE_EDIT: | case DLGTYPE_EDIT: |
| Line 2190 void *menudlg_msg(int ctrl, MENUID id, v | Line 2244 void *menudlg_msg(int ctrl, MENUID id, v |
| } | } |
| break; | break; |
| case DMSG_SETICON: | |
| switch(hdl->type) { | |
| case DLGTYPE_BUTTON: | |
| case DLGTYPE_RADIO: | |
| case DLGTYPE_CHECK: | |
| case DLGTYPE_EDIT: | |
| case DLGTYPE_TEXT: | |
| dlgtext_iconset(dlg, hdl, arg); | |
| drawctrls(dlg, hdl); | |
| break; | |
| } | |
| break; | |
| case DMSG_ITEMAPPEND: | case DMSG_ITEMAPPEND: |
| switch(hdl->type) { | switch(hdl->type) { |
| case DLGTYPE_LIST: | case DLGTYPE_LIST: |