|
|
| version 1.16, 2005/02/07 14:46:14 | version 1.17, 2005/02/09 20:11:35 |
|---|---|
| Line 48 enum { | Line 48 enum { |
| }; | }; |
| typedef struct { | typedef struct { |
| char main[MAX_PATH]; | OEMCHAR main[MAX_PATH]; |
| char font[64]; | OEMCHAR font[64]; |
| SINT32 fontsize; | SINT32 fontsize; |
| UINT32 color1; | UINT32 color1; |
| UINT32 color2; | UINT32 color2; |
| } TOOLSKIN; | } TOOLSKIN; |
| typedef struct { | typedef struct { |
| UINT tctl; | UINT tctl; |
| const char *text; | const OEMCHAR *text; |
| short posx; | short posx; |
| short posy; | short posy; |
| short width; | short width; |
| short height; | short height; |
| short extend; | short extend; |
| short padding; | short padding; |
| } SUBITEM; | } SUBITEM; |
| typedef struct { | typedef struct { |
| Line 102 static TOOLWIN toolwin; | Line 102 static TOOLWIN toolwin; |
| typedef struct { | typedef struct { |
| WORD idc; | UINT16 idc; |
| UINT8 *counter; | UINT8 *counter; |
| } DISKACC; | } DISKACC; |
| Line 117 static const DISKACC diskacc[3] = { | Line 117 static const DISKACC diskacc[3] = { |
| // ---- | // ---- |
| static HBITMAP skinload(const char *path) { | static HBITMAP skinload(const OEMCHAR *path) { |
| char fname[MAX_PATH]; | OEMCHAR fname[MAX_PATH]; |
| UINT i; | UINT i; |
| HBITMAP ret; | HBITMAP ret; |
| ZeroMemory(&toolskin, sizeof(toolskin)); | ZeroMemory(&toolskin, sizeof(toolskin)); |
| toolskin.fontsize = 12; | toolskin.fontsize = 12; |
| milstr_ncpy(toolskin.font, str_deffont, sizeof(toolskin.font)); | milstr_ncpy(toolskin.font, str_deffont, NELEMENTS(toolskin.font)); |
| toolskin.color1 = 0x600000; | toolskin.color1 = 0x600000; |
| toolskin.color2 = 0xff0000; | toolskin.color2 = 0xff0000; |
| if (path) { | if (path) { |
| Line 145 static HBITMAP skinload(const char *path | Line 145 static HBITMAP skinload(const char *path |
| ini_read(path, skintitle, skinini2, NELEMENTS(skinini2)); | ini_read(path, skintitle, skinini2, NELEMENTS(skinini2)); |
| } | } |
| if (toolskin.main[0]) { | if (toolskin.main[0]) { |
| milstr_ncpy(fname, path, sizeof(fname)); | milstr_ncpy(fname, path, NELEMENTS(fname)); |
| file_cutname(fname); | file_cutname(fname); |
| file_catname(fname, toolskin.main, sizeof(fname)); | file_catname(fname, toolskin.main, NELEMENTS(fname)); |
| ret = (HBITMAP)LoadImage(hInst, fname, IMAGE_BITMAP, | ret = (HBITMAP)LoadImage(hInst, fname, IMAGE_BITMAP, |
| 0, 0, LR_LOADFROMFILE); | 0, 0, LR_LOADFROMFILE); |
| if (ret != NULL) { | if (ret != NULL) { |
| return(ret); | return(ret); |
| } | } |
| } | } |
| return(LoadBitmap(hInst, "NP2TOOL")); | return(LoadBitmap(hInst, OEMTEXT("NP2TOOL"))); |
| } | } |
| // ---- | // ---- |
| static void calctextsize(char *path, int leng, const char *p, int width) { | static void calctextsize(OEMCHAR *path, int leng, const OEMCHAR *p, int width) { |
| HDC hdc; | HDC hdc; |
| SIZE cur; | SIZE cur; |
| char work[MAX_PATH]; | OEMCHAR work[MAX_PATH]; |
| int l; | int l; |
| SIZE tail; | SIZE tail; |
| int pos; | int pos; |
| Line 172 static void calctextsize(char *path, int | Line 172 static void calctextsize(char *path, int |
| milstr_ncpy(path, p, leng); | milstr_ncpy(path, p, leng); |
| hdc = toolwin.hdcfont; | hdc = toolwin.hdcfont; |
| GetTextExtentPoint32(hdc, p, strlen(p), &cur); | GetTextExtentPoint32(hdc, p, OEMSTRLEN(p), &cur); |
| if (cur.cx < width) { | if (cur.cx < width) { |
| return; | return; |
| } | } |
| Line 181 static void calctextsize(char *path, int | Line 181 static void calctextsize(char *path, int |
| file_cutseparator(path); | file_cutseparator(path); |
| file_cutname(path); | file_cutname(path); |
| file_cutseparator(path); | file_cutseparator(path); |
| l = strlen(path); | l = OEMSTRLEN(path); |
| work[0] = '\0'; | work[0] = '\0'; |
| if (l) { | if (l) { |
| milstr_ncpy(work, str_browse, sizeof(work)); | milstr_ncpy(work, str_browse, NELEMENTS(work)); |
| } | } |
| milstr_ncat(work, p + l, sizeof(work)); | milstr_ncat(work, p + l, NELEMENTS(work)); |
| GetTextExtentPoint32(hdc, work, strlen(work), &tail); | GetTextExtentPoint32(hdc, work, OEMSTRLEN(work), &tail); |
| pos = 0; | pos = 0; |
| while(pos < l) { | while(pos < l) { |
| step = ((((p[pos] ^ 0x20) - 0xa1) & 0xff) < 0x3c)?2:1; | step = ((((p[pos] ^ 0x20) - 0xa1) & 0xff) < 0x3c)?2:1; |
| Line 205 static void calctextsize(char *path, int | Line 205 static void calctextsize(char *path, int |
| static void setlist(HWND hwnd, const TOOLFDD *fdd, UINT sel) { | static void setlist(HWND hwnd, const TOOLFDD *fdd, UINT sel) { |
| RECT rc; | RECT rc; |
| int width; | int width; |
| char basedir[MAX_PATH]; | OEMCHAR basedir[MAX_PATH]; |
| UINT i; | UINT i; |
| const char *p; | const OEMCHAR *p; |
| char dir[MAX_PATH]; | OEMCHAR dir[MAX_PATH]; |
| const char *q; | const OEMCHAR *q; |
| SendMessage(hwnd, CB_RESETCONTENT, (WPARAM)0, (LPARAM)0); | SendMessage(hwnd, CB_RESETCONTENT, (WPARAM)0, (LPARAM)0); |
| GetClientRect(hwnd, &rc); | GetClientRect(hwnd, &rc); |
| width = rc.right - rc.left - 6; // border size? | width = rc.right - rc.left - 6; // border size? |
| basedir[0] = '\0'; | basedir[0] = '\0'; |
| if (sel < fdd->cnt) { | if (sel < fdd->cnt) { |
| milstr_ncpy(basedir, fdd->name[fdd->pos[sel]], sizeof(basedir)); | milstr_ncpy(basedir, fdd->name[fdd->pos[sel]], NELEMENTS(basedir)); |
| file_cutname(basedir); | file_cutname(basedir); |
| } | } |
| for (i=0; i<fdd->cnt; i++) { | for (i=0; i<fdd->cnt; i++) { |
| p = fdd->name[fdd->pos[i]]; | p = fdd->name[fdd->pos[i]]; |
| milstr_ncpy(dir, p, sizeof(dir)); | milstr_ncpy(dir, p, NELEMENTS(dir)); |
| file_cutname(dir); | file_cutname(dir); |
| if (!file_cmpname(basedir, dir)) { | if (!file_cmpname(basedir, dir)) { |
| q = file_getname((char *)p); | q = file_getname(p); |
| } | } |
| else { | else { |
| calctextsize(dir, sizeof(dir), p, width); | calctextsize(dir, NELEMENTS(dir), p, width); |
| q = dir; | q = dir; |
| } | } |
| SendMessage(hwnd, CB_INSERTSTRING, (WPARAM)i, (LPARAM)q); | SendMessage(hwnd, CB_INSERTSTRING, (WPARAM)i, (LPARAM)q); |
| p += sizeof(fdd->name[0]); | p += NELEMENTS(fdd->name[0]); |
| } | } |
| if (sel < fdd->cnt) { | if (sel < fdd->cnt) { |
| SendMessage(hwnd, CB_SETCURSEL, (WPARAM)sel, (LPARAM)0); | SendMessage(hwnd, CB_SETCURSEL, (WPARAM)sel, (LPARAM)0); |
| Line 261 static void sellist(UINT drv) { | Line 261 static void sellist(UINT drv) { |
| static void remakefddlist(HWND hwnd, TOOLFDD *fdd) { | static void remakefddlist(HWND hwnd, TOOLFDD *fdd) { |
| char *p; | OEMCHAR *p; |
| UINT cnt; | UINT cnt; |
| char *q; | OEMCHAR *q; |
| char *fname[FDDLIST_MAX]; | OEMCHAR *fname[FDDLIST_MAX]; |
| UINT i; | UINT i; |
| UINT j; | UINT j; |
| UINT sel; | UINT sel; |
| Line 285 static void remakefddlist(HWND hwnd, TOO | Line 285 static void remakefddlist(HWND hwnd, TOO |
| fdd->pos[j] = fdd->pos[j-1]; | fdd->pos[j] = fdd->pos[j-1]; |
| } | } |
| fdd->pos[i] = cnt; | fdd->pos[i] = cnt; |
| p += sizeof(fdd->name[0]); | p += NELEMENTS(fdd->name[0]); |
| } | } |
| fdd->cnt = cnt; | fdd->cnt = cnt; |
| sel = (UINT)-1; | sel = (UINT)-1; |
| Line 321 static LRESULT CALLBACK twsub(HWND hWnd, | Line 321 static LRESULT CALLBACK twsub(HWND hWnd, |
| int dir; | int dir; |
| UINT newidc; | UINT newidc; |
| int files; | int files; |
| char fname[MAX_PATH]; | OEMCHAR fname[MAX_PATH]; |
| idc = GetWindowLong(hWnd, GWL_ID) - IDC_BASE; | idc = GetWindowLong(hWnd, GWL_ID) - IDC_BASE; |
| if (idc >= IDC_MAXITEMS) { | if (idc >= IDC_MAXITEMS) { |
| Line 353 static LRESULT CALLBACK twsub(HWND hWnd, | Line 353 static LRESULT CALLBACK twsub(HWND hWnd, |
| else if (msg == WM_DROPFILES) { | else if (msg == WM_DROPFILES) { |
| files = DragQueryFile((HDROP)wp, (UINT)-1, NULL, 0); | files = DragQueryFile((HDROP)wp, (UINT)-1, NULL, 0); |
| if (files == 1) { | if (files == 1) { |
| DragQueryFile((HDROP)wp, 0, fname, sizeof(fname)); | DragQueryFile((HDROP)wp, 0, fname, NELEMENTS(fname)); |
| if (idc == IDC_TOOLFDD1LIST) { | if (idc == IDC_TOOLFDD1LIST) { |
| diskdrv_setfdd(0, fname, 0); | diskdrv_setfdd(0, fname, 0); |
| toolwin_setfdd(0, fname); | toolwin_setfdd(0, fname); |
| Line 392 static void toolwincreate(HWND hWnd) { | Line 392 static void toolwincreate(HWND hWnd) { |
| const SUBITEM *p; | const SUBITEM *p; |
| UINT i; | UINT i; |
| HWND sub; | HWND sub; |
| const char *cls; | const OEMCHAR *cls; |
| DWORD style; | DWORD style; |
| toolwin.hfont = CreateFont(toolskin.fontsize, 0, 0, 0, 0, 0, 0, 0, | toolwin.hfont = CreateFont(toolskin.fontsize, 0, 0, 0, 0, 0, 0, 0, |
| Line 541 static void tooldrawbutton(HWND hWnd, UI | Line 541 static void tooldrawbutton(HWND hWnd, UI |
| static HMENU createskinmenu(void) { | static HMENU createskinmenu(void) { |
| HMENU ret; | HMENU ret; |
| UINT cnt; | UINT cnt; |
| const char *base; | const OEMCHAR *base; |
| UINT flag; | UINT flag; |
| char *p; | OEMCHAR *p; |
| UINT i; | UINT i; |
| UINT j; | UINT j; |
| UINT id[SKINMRU_MAX]; | UINT id[SKINMRU_MAX]; |
| const char *file[SKINMRU_MAX]; | const OEMCHAR *file[SKINMRU_MAX]; |
| ret = CreatePopupMenu(); | ret = CreatePopupMenu(); |
| AppendMenu(ret, MF_STRING, IDM_SKINSEL, str_skinsel); | AppendMenu(ret, MF_STRING, IDM_SKINSEL, str_skinsel); |
| Line 585 const char *file[SKINMRU_MAX]; | Line 585 const char *file[SKINMRU_MAX]; |
| static void skinchange(HWND hWnd) { | static void skinchange(HWND hWnd) { |
| const char *p; | const OEMCHAR *p; |
| UINT i; | UINT i; |
| HBITMAP hbmp; | HBITMAP hbmp; |
| BITMAP bmp; | BITMAP bmp; |
| Line 603 const char *p; | Line 603 const char *p; |
| sizeof(np2tool.skinmru[0])); | sizeof(np2tool.skinmru[0])); |
| i--; | i--; |
| } | } |
| file_cpyname(np2tool.skinmru[0], p, sizeof(np2tool.skinmru[0])); | file_cpyname(np2tool.skinmru[0], p, NELEMENTS(np2tool.skinmru[0])); |
| } | } |
| ModifyMenu(np2class_gethmenu(hWnd), 0, MF_BYPOSITION | MF_POPUP, | ModifyMenu(np2class_gethmenu(hWnd), 0, MF_BYPOSITION | MF_POPUP, |
| (UINT)createskinmenu(), str_toolskin); | (UINT)createskinmenu(), str_toolskin); |
| Line 740 static LRESULT CALLBACK twproc(HWND hWnd | Line 740 static LRESULT CALLBACK twproc(HWND hWnd |
| case IDM_SKINSEL: | case IDM_SKINSEL: |
| soundmng_disable(SNDPROC_TOOL); | soundmng_disable(SNDPROC_TOOL); |
| r = dlgs_selectfile(hWnd, &skinui, np2tool.skin, | r = dlgs_selectfile(hWnd, &skinui, np2tool.skin, |
| sizeof(np2tool.skin), NULL); | NELEMENTS(np2tool.skin), NULL); |
| soundmng_enable(SNDPROC_TOOL); | soundmng_enable(SNDPROC_TOOL); |
| if (r) { | if (r) { |
| skinchange(hWnd); | skinchange(hWnd); |
| Line 758 static LRESULT CALLBACK twproc(HWND hWnd | Line 758 static LRESULT CALLBACK twproc(HWND hWnd |
| case IDM_SKINMRU + 3: | case IDM_SKINMRU + 3: |
| file_cpyname(np2tool.skin, | file_cpyname(np2tool.skin, |
| np2tool.skinmru[LOWORD(wp) - IDM_SKINMRU], | np2tool.skinmru[LOWORD(wp) - IDM_SKINMRU], |
| sizeof(np2tool.skin)); | NELEMENTS(np2tool.skin)); |
| skinchange(hWnd); | skinchange(hWnd); |
| break; | break; |
| Line 940 HWND toolwin_gethwnd(void) { | Line 940 HWND toolwin_gethwnd(void) { |
| return(toolwin.hwnd); | return(toolwin.hwnd); |
| } | } |
| void toolwin_setfdd(UINT8 drv, const char *name) { | void toolwin_setfdd(UINT8 drv, const OEMCHAR *name) { |
| TOOLFDD *fdd; | TOOLFDD *fdd; |
| char *q; | OEMCHAR *q; |
| char *p; | OEMCHAR *p; |
| UINT i; | UINT i; |
| HWND sub; | HWND sub; |
| Line 962 void toolwin_setfdd(UINT8 drv, const cha | Line 962 void toolwin_setfdd(UINT8 drv, const cha |
| if (!file_cmpname(q, name)) { | if (!file_cmpname(q, name)) { |
| break; | break; |
| } | } |
| q += sizeof(fdd->name[0]); | q += NELEMENTS(fdd->name[0]); |
| } | } |
| p = q - sizeof(fdd->name[0]); | p = q - NELEMENTS(fdd->name[0]); |
| while(i > 0) { | while(i > 0) { |
| i--; | i--; |
| CopyMemory(q, p, sizeof(fdd->name[0])); | CopyMemory(q, p, sizeof(fdd->name[0])); |
| p -= sizeof(fdd->name[0]); | p -= NELEMENTS(fdd->name[0]); |
| q -= sizeof(fdd->name[0]); | q -= NELEMENTS(fdd->name[0]); |
| } | } |
| file_cpyname(fdd->name[0], name, sizeof(fdd->name[0])); | file_cpyname(fdd->name[0], name, NELEMENTS(fdd->name[0])); |
| } | } |
| sysmng_update(SYS_UPDATEOSCFG); | sysmng_update(SYS_UPDATEOSCFG); |
| if (toolwin.hwnd != NULL) { | if (toolwin.hwnd != NULL) { |
| Line 1052 const DISKACC *accterm; | Line 1052 const DISKACC *accterm; |
| // ---- | // ---- |
| static const char ini_title[] = "NP2 tool"; | static const OEMCHAR ini_title[] = OEMTEXT("NP2 tool"); |
| static const INITBL iniitem[] = { | static const INITBL iniitem[] = { |
| {"WindposX", INITYPE_SINT32, &np2tool.posx, 0}, | {"WindposX", INITYPE_SINT32, &np2tool.posx, 0}, |
| Line 1082 static const INITBL iniitem[] = { | Line 1082 static const INITBL iniitem[] = { |
| void toolwin_readini(void) { | void toolwin_readini(void) { |
| char path[MAX_PATH]; | OEMCHAR path[MAX_PATH]; |
| ZeroMemory(&np2tool, sizeof(np2tool)); | ZeroMemory(&np2tool, sizeof(np2tool)); |
| np2tool.posx = CW_USEDEFAULT; | np2tool.posx = CW_USEDEFAULT; |
| np2tool.posy = CW_USEDEFAULT; | np2tool.posy = CW_USEDEFAULT; |
| np2tool.type = 1; | np2tool.type = 1; |
| initgetfile(path, sizeof(path)); | initgetfile(path, NELEMENTS(path)); |
| ini_read(path, ini_title, iniitem, NELEMENTS(iniitem)); | ini_read(path, ini_title, iniitem, NELEMENTS(iniitem)); |
| } | } |
| void toolwin_writeini(void) { | void toolwin_writeini(void) { |
| char path[MAX_PATH]; | OEMCHAR path[MAX_PATH]; |
| initgetfile(path, sizeof(path)); | initgetfile(path, NELEMENTS(path)); |
| ini_write(path, ini_title, iniitem, NELEMENTS(iniitem)); | ini_write(path, ini_title, iniitem, NELEMENTS(iniitem)); |
| } | } |