|
|
| version 1.3, 2003/10/29 10:09:37 | version 1.4, 2003/10/29 14:02:35 |
|---|---|
| Line 20 | Line 20 |
| #endif | #endif |
| NP2TOOL np2tool; | |
| static const char np2toolclass[] = "np2-toolwin"; | |
| static const char np2tooltitle[] = "NP2 tool"; | |
| static const char str_deffont[] = "£Í£Ó £Ð¥´¥·¥Ã¥¯"; | |
| static const char str_static[] = "STATIC"; | |
| static const char str_combobox[] = "COMBOBOX"; | |
| static const char str_button[] = "BUTTON"; | |
| static const char str_browse[] = "..."; | |
| static const char str_eject[] = "Eject"; | |
| enum { | enum { |
| IDC_TOOLHDDACC = 0, | IDC_TOOLHDDACC = 0, |
| IDC_TOOLFDD1ACC, | IDC_TOOLFDD1ACC, |
| Line 48 enum { | Line 36 enum { |
| }; | }; |
| typedef struct { | typedef struct { |
| char main[MAX_PATH]; | |
| char font[64]; | |
| SINT32 fontsize; | |
| UINT32 color1; | |
| UINT32 color2; | |
| } TOOLSKIN; | |
| typedef struct { | |
| const char *cname; | const char *cname; |
| const char *text; | const char *text; |
| DWORD style; | DWORD style; |
| DWORD exstyle; | |
| short posx; | short posx; |
| short posy; | short posy; |
| short width; | short width; |
| short height; | short height; |
| BOOL tabstop; | |
| } SUBITEM; | } SUBITEM; |
| static const BYTE fddlist[FDDLIST_DRV] = { | |
| IDC_TOOLFDD1LIST, IDC_TOOLFDD2LIST}; | |
| static const SUBITEM subitem[IDC_MAXITEMS] = { | |
| {str_static, NULL, WS_VISIBLE, 0, 49, 44, 8, 3}, | |
| {str_static, NULL, WS_VISIBLE, 0, 93, 19, 8, 3}, | |
| {str_combobox, NULL, | |
| WS_VISIBLE | CBS_DROPDOWNLIST | WS_VSCROLL, 0, 104, 6, 248, 160}, | |
| {str_button, str_browse, | |
| WS_VISIBLE | BS_PUSHBUTTON, 0, 352, 7, 18, 17}, | |
| {str_button, str_eject, | |
| WS_VISIBLE | BS_PUSHBUTTON, 0, 370, 7, 34, 17}, | |
| {str_static, NULL, WS_VISIBLE, 0, 93, 41, 8, 3}, | |
| {str_combobox, NULL, | |
| WS_VISIBLE | CBS_DROPDOWNLIST | WS_VSCROLL, 0, 104, 28, 248, 160}, | |
| {str_button, str_browse, | |
| WS_VISIBLE | BS_PUSHBUTTON, 0, 352, 29, 18, 17}, | |
| {str_button, str_eject, | |
| WS_VISIBLE | BS_PUSHBUTTON, 0, 370, 29, 34, 17}, | |
| }; | |
| // static const DWORD mvccol[MVC_MAXCOLOR] = { | |
| // 0xc0e8f8, 0xd8ecf4, 0x48a8c8, 0x000000}; | |
| typedef struct { | typedef struct { |
| HWND hwnd; | HWND hwnd; |
| HBITMAP hbmp; | |
| BYTE fddaccess[2]; | BYTE fddaccess[2]; |
| BYTE hddaccess; | BYTE hddaccess; |
| BYTE _padding; | BYTE _padding; |
| Line 102 typedef struct { | Line 75 typedef struct { |
| SCPROC subproc[IDC_MAXITEMS]; | SCPROC subproc[IDC_MAXITEMS]; |
| } TOOLWIN; | } TOOLWIN; |
| NP2TOOL np2tool; | |
| static TOOLSKIN toolskin; | |
| static SUBITEM subitem[IDC_MAXITEMS]; | |
| static TOOLWIN toolwin; | static TOOLWIN toolwin; |
| #include "toolwin.res" | |
| typedef struct { | typedef struct { |
| WORD idc; | WORD idc; |
| BYTE *counter; | BYTE *counter; |
| } DISKACC; | } DISKACC; |
| static const BYTE fddlist[FDDLIST_DRV] = { | |
| IDC_TOOLFDD1LIST, IDC_TOOLFDD2LIST}; | |
| static const DISKACC diskacc[3] = { | static const DISKACC diskacc[3] = { |
| {IDC_TOOLFDD1ACC, &toolwin.fddaccess[0]}, | {IDC_TOOLFDD1ACC, &toolwin.fddaccess[0]}, |
| {IDC_TOOLFDD2ACC, &toolwin.fddaccess[1]}, | {IDC_TOOLFDD2ACC, &toolwin.fddaccess[1]}, |
| {IDC_TOOLHDDACC, &toolwin.hddaccess}}; | {IDC_TOOLHDDACC, &toolwin.hddaccess}}; |
| // ---- | |
| static void skinsetdef(void) { | |
| ZeroMemory(&toolskin, sizeof(toolskin)); | |
| toolskin.fontsize = 12; | |
| milstr_ncpy(toolskin.font, str_deffont, sizeof(toolskin.font)); | |
| toolskin.color1 = 0x600000; | |
| toolskin.color2 = 0xff0000; | |
| CopyMemory(subitem, defsubitem, sizeof(defsubitem)); | |
| } | |
| static HBITMAP skinload(const char *path) { | |
| char fname[MAX_PATH]; | |
| if (path) { | |
| ini_read(path, skintitle, skinini, sizeof(skinini)/sizeof(INITBL)); | |
| } | |
| if ((path) && (toolskin.main[0])) { | |
| milstr_ncpy(fname, path, sizeof(fname)); | |
| file_cutname(fname); | |
| file_catname(fname, toolskin.main, sizeof(fname)); | |
| return((HBITMAP)LoadImage(hInst, fname, IMAGE_BITMAP, | |
| 0, 0, LR_LOADFROMFILE)); | |
| } | |
| else { | |
| return(LoadBitmap(hInst, "NP2TOOL")); | |
| } | |
| } | |
| // ---- | |
| static void calctextsize(char *path, int leng, const char *p, int width) { | static void calctextsize(char *path, int leng, const char *p, int width) { |
| Line 246 static void accdraw(HWND hWnd, BYTE coun | Line 263 static void accdraw(HWND hWnd, BYTE coun |
| static LRESULT CALLBACK twsub(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp) { | static LRESULT CALLBACK twsub(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp) { |
| UINT idc; | UINT idc; |
| int dir; | |
| UINT newidc; | |
| int files; | int files; |
| char fname[MAX_PATH]; | char fname[MAX_PATH]; |
| Line 257 static LRESULT CALLBACK twsub(HWND hWnd, | Line 276 static LRESULT CALLBACK twsub(HWND hWnd, |
| if (idc >= IDC_MAXITEMS) { | if (idc >= IDC_MAXITEMS) { |
| return(0); | return(0); |
| } | } |
| if (msg == WM_DROPFILES) { | if (msg == WM_KEYDOWN) { |
| if ((TCHAR)wp == VK_TAB) { | |
| dir = (GetKeyState(VK_SHIFT) >= 0)?1:-1; | |
| newidc = idc; | |
| do { | |
| newidc += dir; | |
| if (newidc >= IDC_MAXITEMS) { | |
| newidc = (dir >= 0)?0:(IDC_MAXITEMS - 1); | |
| } | |
| if (subitem[newidc].tabstop) { | |
| SetFocus(toolwin.sub[newidc]); | |
| break; | |
| } | |
| } while(idc != newidc); | |
| } | |
| else if ((TCHAR)wp == VK_RETURN) { | |
| if (subitem[idc].cname == str_button) { | |
| return(CallWindowProc(toolwin.subproc[idc], | |
| hWnd, WM_KEYDOWN, VK_SPACE, 0)); | |
| } | |
| } | |
| } | |
| 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, sizeof(fname)); |
| Line 298 const SUBITEM *p; | Line 339 const SUBITEM *p; |
| UINT i; | UINT i; |
| HWND sub; | HWND sub; |
| toolwin.hfont = CreateFont(12, 0, 0, 0, 0, 0, 0, 0, | toolwin.hfont = CreateFont(toolskin.fontsize, 0, 0, 0, 0, 0, 0, 0, |
| SHIFTJIS_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, | SHIFTJIS_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, |
| DEFAULT_QUALITY, FIXED_PITCH, str_deffont); | DEFAULT_QUALITY, FIXED_PITCH, toolskin.font); |
| hdc = GetDC(NULL); | hdc = GetDC(NULL); |
| toolwin.hdcfont = CreateCompatibleDC(hdc); | toolwin.hdcfont = CreateCompatibleDC(hdc); |
| ReleaseDC(NULL, hdc); | ReleaseDC(NULL, hdc); |
| Line 312 const SUBITEM *p; | Line 353 const SUBITEM *p; |
| hinstance = ((LPCREATESTRUCT)lp)->hInstance; | hinstance = ((LPCREATESTRUCT)lp)->hInstance; |
| p = subitem; | p = subitem; |
| for (i=0; i<IDC_MAXITEMS; i++) { | for (i=0; i<IDC_MAXITEMS; i++) { |
| sub = CreateWindowEx(p->exstyle, p->cname, p->text, | sub = CreateWindow(p->cname, p->text, |
| WS_CHILD | p->style, p->posx, p->posy, p->width, p->height, | WS_CHILD | p->style, p->posx, p->posy, p->width, p->height, |
| hWnd, (HMENU)(i + IDC_BASE), hinstance, NULL); | hWnd, (HMENU)(i + IDC_BASE), hinstance, NULL); |
| toolwin.sub[i] = sub; | toolwin.sub[i] = sub; |
| Line 339 static void toolwindestroy(void) { | Line 380 static void toolwindestroy(void) { |
| DeleteObject(toolwin.access[1]); | DeleteObject(toolwin.access[1]); |
| DeleteObject(toolwin.hdcfont); | DeleteObject(toolwin.hdcfont); |
| DeleteObject(toolwin.hfont); | DeleteObject(toolwin.hfont); |
| DeleteObject(toolwin.hbmp); | |
| } | } |
| static void toolwinpaint(HWND hWnd) { | static void toolwinpaint(HWND hWnd) { |
| Line 346 static void toolwinpaint(HWND hWnd) { | Line 388 static void toolwinpaint(HWND hWnd) { |
| HDC hdc; | HDC hdc; |
| PAINTSTRUCT ps; | PAINTSTRUCT ps; |
| HINSTANCE hinst; | HINSTANCE hinst; |
| HBITMAP hbmp; | |
| BITMAP bmp; | BITMAP bmp; |
| HDC hmdc; | HDC hmdc; |
| hdc = BeginPaint(hWnd, &ps); | hdc = BeginPaint(hWnd, &ps); |
| hinst = (HINSTANCE)GetWindowLong(hWnd, GWL_HINSTANCE); | hinst = (HINSTANCE)GetWindowLong(hWnd, GWL_HINSTANCE); |
| hbmp = LoadBitmap(hinst, "NP2TOOL"); | GetObject(toolwin.hbmp, sizeof(BITMAP), &bmp); |
| GetObject(hbmp, sizeof(BITMAP), &bmp); | |
| hmdc = CreateCompatibleDC(hdc); | hmdc = CreateCompatibleDC(hdc); |
| SelectObject(hmdc, hbmp); | SelectObject(hmdc, toolwin.hbmp); |
| BitBlt(hdc, 0, 0, bmp.bmWidth, bmp.bmHeight, hmdc, 0, 0, SRCCOPY); | BitBlt(hdc, 0, 0, bmp.bmWidth, bmp.bmHeight, hmdc, 0, 0, SRCCOPY); |
| DeleteDC(hmdc); | DeleteDC(hmdc); |
| DeleteObject(hbmp); | |
| EndPaint(hWnd, &ps); | EndPaint(hWnd, &ps); |
| } | } |
| Line 381 static void movingproc(RECT *rect) { | Line 420 static void movingproc(RECT *rect) { |
| RECT workrc; | RECT workrc; |
| RECT mainrc; | RECT mainrc; |
| int winlx, winly; | int winlx; |
| int winly; | |
| BOOL changes; | |
| BOOL connectx; | BOOL connectx; |
| BOOL connecty; | BOOL connecty; |
| int d; | int d; |
| Line 396 static void movingproc(RECT *rect) { | Line 437 static void movingproc(RECT *rect) { |
| return; | return; |
| } | } |
| connectx = ((rect->right >= mainrc.left) && (rect->left <= mainrc.right)); | changes = FALSE; |
| connecty = ((rect->bottom >= mainrc.top) && (rect->top <= mainrc.bottom)); | do { |
| if ((toolwin.winflg & 3) && (!connectx) && (!connecty)) { | if (toolwin.winflg & 1) { |
| toolwin.winflg &= ~3; | toolwin.wingx += rect->left - toolwin.wintx; |
| rect->left += toolwin.wingx; | rect->left = toolwin.wintx; |
| rect->top += toolwin.wingy; | } |
| toolwin.wingx = 0; | else { |
| toolwin.wingy = 0; | d = SNAPDOTPULL; |
| } | do { |
| connecty = ((rect->bottom >= mainrc.top) && | |
| if (toolwin.winflg & 1) { | (rect->top <= mainrc.bottom)); |
| toolwin.wingx += rect->left - toolwin.wintx; | if (connecty) { |
| rect->left = toolwin.wintx; | d = rect->left - mainrc.right; |
| } | |
| else { | |
| d = SNAPDOTPULL; | |
| do { | |
| if (connecty) { | |
| d = rect->right - mainrc.left; | |
| if ((d < SNAPDOTPULL) && (d > -SNAPDOTPULL)) { | |
| break; | |
| } | |
| d = rect->left - mainrc.right; | |
| if ((d < SNAPDOTPULL) && (d > -SNAPDOTPULL)) { | |
| break; | |
| } | |
| if ((rect->bottom == mainrc.top) || | |
| (rect->top == mainrc.bottom)) { | |
| d = rect->left - mainrc.left; | |
| if ((d < SNAPDOTPULL) && (d > -SNAPDOTPULL)) { | if ((d < SNAPDOTPULL) && (d > -SNAPDOTPULL)) { |
| break; | break; |
| } | } |
| d = rect->right - mainrc.right; | d = rect->right - mainrc.left; |
| if ((d < SNAPDOTPULL) && (d > -SNAPDOTPULL)) { | if ((d < SNAPDOTPULL) && (d > -SNAPDOTPULL)) { |
| break; | break; |
| } | } |
| if ((rect->bottom == mainrc.top) || | |
| (rect->top == mainrc.bottom)) { | |
| d = rect->left - mainrc.left; | |
| if ((d < SNAPDOTPULL) && (d > -SNAPDOTPULL)) { | |
| break; | |
| } | |
| d = rect->right - mainrc.right; | |
| if ((d < SNAPDOTPULL) && (d > -SNAPDOTPULL)) { | |
| break; | |
| } | |
| } | |
| } | } |
| } | d = rect->left - workrc.left; |
| d = rect->left - workrc.left; | |
| if ((d < SNAPDOTPULL) && (d > -SNAPDOTPULL)) { | |
| break; | |
| } | |
| d = rect->right - workrc.right; | |
| if ((d < SNAPDOTPULL) && (d > -SNAPDOTPULL)) { | |
| break; | |
| } | |
| } while(0); | |
| if ((d < SNAPDOTPULL) && (d > -SNAPDOTPULL)) { | |
| toolwin.winflg |= 1; | |
| rect->left -= d; | |
| toolwin.wingx = d; | |
| toolwin.wintx = rect->left; | |
| } | |
| } | |
| if ((toolwin.wingx >= SNAPDOTREL) || (toolwin.wingx <= -SNAPDOTREL)) { | |
| toolwin.winflg &= ~1; | |
| rect->left += toolwin.wingx; | |
| toolwin.wingx = 0; | |
| } | |
| if (toolwin.winflg & 2) { | |
| toolwin.wingy += rect->top - toolwin.winty; | |
| rect->top = toolwin.winty; | |
| } | |
| else { | |
| d = SNAPDOTPULL; | |
| do { | |
| if (connectx) { | |
| d = rect->bottom - mainrc.top; | |
| if ((d < SNAPDOTPULL) && (d > -SNAPDOTPULL)) { | if ((d < SNAPDOTPULL) && (d > -SNAPDOTPULL)) { |
| break; | break; |
| } | } |
| d = rect->top - mainrc.bottom; | d = rect->right - workrc.right; |
| if ((d < SNAPDOTPULL) && (d > -SNAPDOTPULL)) { | if ((d < SNAPDOTPULL) && (d > -SNAPDOTPULL)) { |
| break; | break; |
| } | } |
| if ((rect->right == mainrc.left) || | } while(0); |
| (rect->left == mainrc.right)) { | if ((d < SNAPDOTPULL) && (d > -SNAPDOTPULL)) { |
| d = rect->top - mainrc.top; | toolwin.winflg |= 1; |
| rect->left -= d; | |
| toolwin.wingx = d; | |
| toolwin.wintx = rect->left; | |
| } | |
| } | |
| if ((toolwin.wingx >= SNAPDOTREL) || (toolwin.wingx <= -SNAPDOTREL)) { | |
| toolwin.winflg &= ~1; | |
| rect->left += toolwin.wingx; | |
| toolwin.wingx = 0; | |
| } | |
| rect->right = rect->left + winlx; | |
| if (changes) { | |
| break; | |
| } | |
| if (toolwin.winflg & 2) { | |
| toolwin.wingy += rect->top - toolwin.winty; | |
| rect->top = toolwin.winty; | |
| } | |
| else { | |
| d = SNAPDOTPULL; | |
| do { | |
| connectx = ((rect->right >= mainrc.left) && | |
| (rect->left <= mainrc.right)); | |
| if (connectx) { | |
| d = rect->top - mainrc.bottom; | |
| if ((d < SNAPDOTPULL) && (d > -SNAPDOTPULL)) { | if ((d < SNAPDOTPULL) && (d > -SNAPDOTPULL)) { |
| break; | break; |
| } | } |
| d = rect->bottom - mainrc.bottom; | d = rect->bottom - mainrc.top; |
| if ((d < SNAPDOTPULL) && (d > -SNAPDOTPULL)) { | if ((d < SNAPDOTPULL) && (d > -SNAPDOTPULL)) { |
| break; | break; |
| } | } |
| if ((rect->right == mainrc.left) || | |
| (rect->left == mainrc.right)) { | |
| d = rect->top - mainrc.top; | |
| if ((d < SNAPDOTPULL) && (d > -SNAPDOTPULL)) { | |
| break; | |
| } | |
| d = rect->bottom - mainrc.bottom; | |
| if ((d < SNAPDOTPULL) && (d > -SNAPDOTPULL)) { | |
| break; | |
| } | |
| } | |
| } | } |
| } | d = rect->top - workrc.top; |
| d = rect->top - workrc.top; | if ((d < SNAPDOTPULL) && (d > -SNAPDOTPULL)) { |
| if ((d < SNAPDOTPULL) && (d > -SNAPDOTPULL)) { | break; |
| break; | } |
| } | d = rect->bottom - workrc.bottom; |
| d = rect->bottom - workrc.bottom; | if ((d < SNAPDOTPULL) && (d > -SNAPDOTPULL)) { |
| break; | |
| } | |
| } while(0); | |
| if ((d < SNAPDOTPULL) && (d > -SNAPDOTPULL)) { | if ((d < SNAPDOTPULL) && (d > -SNAPDOTPULL)) { |
| break; | toolwin.winflg |= 2; |
| rect->top -= d; | |
| toolwin.wingy = d; | |
| toolwin.winty = rect->top; | |
| changes = TRUE; | |
| } | } |
| } while(0); | |
| if ((d < SNAPDOTPULL) && (d > -SNAPDOTPULL)) { | |
| toolwin.winflg |= 2; | |
| rect->top -= d; | |
| toolwin.wingy = d; | |
| toolwin.winty = rect->top; | |
| } | } |
| } | if ((toolwin.wingy >= SNAPDOTREL) || (toolwin.wingy <= -SNAPDOTREL)) { |
| if ((toolwin.wingy >= SNAPDOTREL) || (toolwin.wingy <= -SNAPDOTREL)) { | toolwin.winflg &= ~2; |
| toolwin.winflg &= ~2; | rect->top += toolwin.wingy; |
| toolwin.wingy = 0; | |
| changes = TRUE; | |
| } | |
| rect->bottom = rect->top + winly; | |
| } while(changes); | |
| connectx = ((rect->right >= mainrc.left) && (rect->left <= mainrc.right)); | |
| connecty = ((rect->bottom >= mainrc.top) && (rect->top <= mainrc.bottom)); | |
| if ((toolwin.winflg & 3) && ((!connectx) || (!connecty))) { | |
| toolwin.winflg &= ~3; | |
| rect->left += toolwin.wingx; | |
| rect->top += toolwin.wingy; | rect->top += toolwin.wingy; |
| rect->right = rect->left + winlx; | |
| rect->bottom = rect->top + winly; | |
| toolwin.wingx = 0; | |
| toolwin.wingy = 0; | toolwin.wingy = 0; |
| } | } |
| rect->right = rect->left + winlx; | |
| rect->bottom = rect->top + winly; | |
| } | } |
| Line 600 static LRESULT CALLBACK twproc(HWND hWnd | Line 655 static LRESULT CALLBACK twproc(HWND hWnd |
| case WM_CLOSE: | case WM_CLOSE: |
| xmenu_settoolwin(0); | xmenu_settoolwin(0); |
| sysmng_update(SYS_UPDATEOSCFG); | |
| DestroyWindow(hWnd); | DestroyWindow(hWnd); |
| break; | break; |
| Line 637 BOOL toolwin_initapp(HINSTANCE hInstance | Line 693 BOOL toolwin_initapp(HINSTANCE hInstance |
| void toolwin_open(void) { | void toolwin_open(void) { |
| char path[MAX_PATH]; | |
| HBITMAP hbmp; | |
| BITMAP bmp; | |
| HWND hWnd; | HWND hWnd; |
| if (toolwin.hwnd) { | if (toolwin.hwnd) { |
| return; | return; |
| } | } |
| ZeroMemory(&toolwin, sizeof(toolwin)); | ZeroMemory(&toolwin, sizeof(toolwin)); |
| skinsetdef(); | |
| milstr_ncpy(path, modulefile, sizeof(path)); | |
| file_cutname(path); | |
| file_catname(path, np2skin, sizeof(path)); | |
| hbmp = skinload(path); | |
| if (hbmp == NULL) { | |
| goto twope_err1; | |
| } | |
| GetObject(hbmp, sizeof(BITMAP), &bmp); | |
| toolwin.hbmp = hbmp; | |
| hWnd = CreateWindowEx(0, np2toolclass, np2tooltitle, WS_SYSMENU, | hWnd = CreateWindowEx(0, np2toolclass, np2tooltitle, WS_SYSMENU, |
| np2tool.posx, np2tool.posy, 410, 52, | np2tool.posx, np2tool.posy, |
| bmp.bmWidth, bmp.bmHeight, | |
| NULL, NULL, hInst, NULL); | NULL, NULL, hInst, NULL); |
| toolwin.hwnd = hWnd; | toolwin.hwnd = hWnd; |
| if (hWnd == NULL) { | if (hWnd == NULL) { |
| return; | goto twope_err2; |
| } | } |
| UpdateWindow(hWnd); | UpdateWindow(hWnd); |
| ShowWindow(hWnd, SW_SHOW); | ShowWindow(hWnd, SW_SHOW); |
| return; | |
| twope_err2: | |
| DeleteObject(hbmp); | |
| twope_err1: | |
| xmenu_settoolwin(0); | |
| sysmng_update(SYS_UPDATEOSCFG); | |
| return; | |
| } | } |
| void toolwin_close(void) { | void toolwin_close(void) { |