| version 1.4, 2004/03/26 06:47:11 | version 1.17, 2007/12/28 20:36:40 | 
| Line 10 | Line 10 | 
 | #include        "subwind.h" | #include        "subwind.h" | 
 | #include        "np2class.h" | #include        "np2class.h" | 
 | #include        "keydisp.h" | #include        "keydisp.h" | 
 |  | #include        "memdbg32.h" | 
 | #include        "softkbd.h" | #include        "softkbd.h" | 
 |  |  | 
 |  |  | 
| Line 19  static void wintypechange(HWND hWnd, UIN | Line 20  static void wintypechange(HWND hWnd, UIN | 
 |  |  | 
 | WINLOCEX        wlex; | WINLOCEX        wlex; | 
 |  |  | 
| wlex = np2_winlocexallwin(hWndMain); | wlex = np2_winlocexallwin(g_hWndMain); | 
 | winlocex_setholdwnd(wlex, hWnd); | winlocex_setholdwnd(wlex, hWnd); | 
 | np2class_windowtype(hWnd, type); | np2class_windowtype(hWnd, type); | 
 | winlocex_move(wlex); | winlocex_move(wlex); | 
| Line 35  enum { | Line 36  enum { | 
 | KDISPCFG_MIDI   = 0x80 | KDISPCFG_MIDI   = 0x80 | 
 | }; | }; | 
 |  |  | 
 | enum { |  | 
 | IDM_KDCLOSE             = 3000 |  | 
 | }; |  | 
 |  |  | 
 | typedef struct { | typedef struct { | 
 | HWND            hwnd; | HWND            hwnd; | 
 | WINLOCEX        wlex; | WINLOCEX        wlex; | 
 | DD2HDL          dd2hdl; | DD2HDL          dd2hdl; | 
| } KDWIN; | } KDISPWIN; | 
 |  |  | 
 | typedef struct { | typedef struct { | 
 | int             posx; | int             posx; | 
 | int             posy; | int             posy; | 
| BYTE    mode; | UINT8   mode; | 
| BYTE    type; | UINT8   type; | 
 | } KDISPCFG; | } KDISPCFG; | 
 |  |  | 
| static  KDWIN           kdwin; | static  KDISPWIN        kdispwin; | 
 | static  KDISPCFG        kdispcfg; | static  KDISPCFG        kdispcfg; | 
 |  |  | 
| static const char np2kdcaption[] = "Key Display"; | static const TCHAR kdispclass[] = _T("NP2-KeyDispWin"); | 
| static const char np2kdclass[] = "NP2-KeyDispWin"; |  | 
| static const char str_kdclose[] = "&Close"; |  | 
 |  |  | 
| static const UINT32 kdwinpal[KEYDISP_PALS] = | static const UINT32 kdisppal[KEYDISP_PALS] = | 
 | {0x00000000, 0xffffffff, 0xf9ff0000}; | {0x00000000, 0xffffffff, 0xf9ff0000}; | 
 |  |  | 
| static const char np2kdapp[] = "NP2 keydisp"; | static const OEMCHAR kdispapp[] = OEMTEXT("Key Display"); | 
|  | static const PFTBL kdispini[] = { | 
|  | PFVAL("WindposX", PFTYPE_SINT32,        &kdispcfg.posx), | 
|  | PFVAL("WindposY", PFTYPE_SINT32,        &kdispcfg.posy), | 
|  | PFVAL("keydmode", PFTYPE_UINT8,         &kdispcfg.mode), | 
|  | PFVAL("windtype", PFTYPE_BOOL,          &kdispcfg.type)}; | 
 |  |  | 
 | static const INITBL np2kdini[] = { |  | 
 | {"WindposX", INITYPE_SINT32,    &kdispcfg.posx,                 0}, |  | 
 | {"WindposY", INITYPE_SINT32,    &kdispcfg.posy,                 0}, |  | 
 | {"keydmode", INITYPE_UINT8,             &kdispcfg.mode,                 0}, |  | 
 | {"windtype", INITYPE_BOOL,              &kdispcfg.type,                 0}}; |  | 
 |  |  | 
|  | static UINT8 kdgetpal8(CMNPALFN *self, UINT num) { | 
| static BYTE kdgetpal8(CMNPALFN *self, UINT num) { |  | 
 |  |  | 
 | if (num < KEYDISP_PALS) { | if (num < KEYDISP_PALS) { | 
| return(kdwinpal[num] >> 24); | return(kdisppal[num] >> 24); | 
 | } | } | 
 | return(0); | return(0); | 
 | } | } | 
| Line 82  static BYTE kdgetpal8(CMNPALFN *self, UI | Line 76  static BYTE kdgetpal8(CMNPALFN *self, UI | 
 | static UINT32 kdgetpal32(CMNPALFN *self, UINT num) { | static UINT32 kdgetpal32(CMNPALFN *self, UINT num) { | 
 |  |  | 
 | if (num < KEYDISP_PALS) { | if (num < KEYDISP_PALS) { | 
| return(kdwinpal[num] & 0xffffff); | return(kdisppal[num] & 0xffffff); | 
 | } | } | 
 | return(0); | return(0); | 
 | } | } | 
| Line 106  static void kddrawkeys(HWND hWnd, BOOL r | Line 100  static void kddrawkeys(HWND hWnd, BOOL r | 
 | if ((draw.right <= 0) || (draw.bottom <= 0)) { | if ((draw.right <= 0) || (draw.bottom <= 0)) { | 
 | return; | return; | 
 | } | } | 
| vram = dd2_bsurflock(kdwin.dd2hdl); | vram = dd2_bsurflock(kdispwin.dd2hdl); | 
 | if (vram) { | if (vram) { | 
 | keydisp_paint(vram, redraw); | keydisp_paint(vram, redraw); | 
| dd2_bsurfunlock(kdwin.dd2hdl); | dd2_bsurfunlock(kdispwin.dd2hdl); | 
| dd2_blt(kdwin.dd2hdl, NULL, &draw); | dd2_blt(kdispwin.dd2hdl, NULL, &draw); | 
 | } | } | 
 | } | } | 
 |  |  | 
| Line 120  static void kdsetwinsize(void) { | Line 114  static void kdsetwinsize(void) { | 
 | int                     height; | int                     height; | 
 | WINLOCEX        wlex; | WINLOCEX        wlex; | 
 |  |  | 
| wlex = np2_winlocexallwin(hWndMain); | wlex = np2_winlocexallwin(g_hWndMain); | 
| winlocex_setholdwnd(wlex, kdwin.hwnd); | winlocex_setholdwnd(wlex, kdispwin.hwnd); | 
 | keydisp_getsize(&width, &height); | keydisp_getsize(&width, &height); | 
| winloc_setclientsize(kdwin.hwnd, width, height); | winloc_setclientsize(kdispwin.hwnd, width, height); | 
 | winlocex_move(wlex); | winlocex_move(wlex); | 
 | winlocex_destroy(wlex); | winlocex_destroy(wlex); | 
 | } | } | 
 |  |  | 
| static void kdsetdispmode(BYTE mode) { | static void kdsetdispmode(UINT8 mode) { | 
 |  |  | 
 | HMENU   hmenu; | HMENU   hmenu; | 
 |  |  | 
 | keydisp_setmode(mode); | keydisp_setmode(mode); | 
| hmenu = np2class_gethmenu(kdwin.hwnd); | hmenu = np2class_gethmenu(kdispwin.hwnd); | 
 | CheckMenuItem(hmenu, IDM_KDISPFM, | CheckMenuItem(hmenu, IDM_KDISPFM, | 
 | ((mode == KEYDISP_MODEFM)?MF_CHECKED:MF_UNCHECKED)); | ((mode == KEYDISP_MODEFM)?MF_CHECKED:MF_UNCHECKED)); | 
 | CheckMenuItem(hmenu, IDM_KDISPMIDI, | CheckMenuItem(hmenu, IDM_KDISPMIDI, | 
| Line 156  static void kdopenpopup(HWND hWnd, LPARA | Line 150  static void kdopenpopup(HWND hWnd, LPARA | 
 | POINT   pt; | POINT   pt; | 
 |  |  | 
 | hMenu = CreatePopupMenu(); | hMenu = CreatePopupMenu(); | 
| menu_addmenubar(hMenu, np2class_gethmenu(hWnd)); | menu_addmenu(hMenu, 0, np2class_gethmenu(hWnd), FALSE); | 
| AppendMenu(hMenu, MF_SEPARATOR, 0, NULL); | menu_addmenures(hMenu, -1, IDR_CLOSE, TRUE); | 
| AppendMenu(hMenu, MF_STRING, IDM_KDCLOSE, str_kdclose); |  | 
 | pt.x = LOWORD(lp); | pt.x = LOWORD(lp); | 
 | pt.y = HIWORD(lp); | pt.y = HIWORD(lp); | 
 | ClientToScreen(hWnd, &pt); | ClientToScreen(hWnd, &pt); | 
| Line 188  static LRESULT CALLBACK kdproc(HWND hWnd | Line 181  static LRESULT CALLBACK kdproc(HWND hWnd | 
 | kdsetdispmode(KEYDISP_MODEMIDI); | kdsetdispmode(KEYDISP_MODEMIDI); | 
 | break; | break; | 
 |  |  | 
| case IDM_KDCLOSE: | case IDM_CLOSE: | 
 | return(SendMessage(hWnd, WM_CLOSE, 0, 0)); | return(SendMessage(hWnd, WM_CLOSE, 0, 0)); | 
 | } | } | 
 | break; | break; | 
| Line 222  static LRESULT CALLBACK kdproc(HWND hWnd | Line 215  static LRESULT CALLBACK kdproc(HWND hWnd | 
 |  |  | 
 | case WM_KEYDOWN: | case WM_KEYDOWN: | 
 | case WM_KEYUP: | case WM_KEYUP: | 
| SendMessage(hWndMain, msg, wp, lp); | SendMessage(g_hWndMain, msg, wp, lp); | 
 | break; | break; | 
 |  |  | 
 | case WM_ENTERMENULOOP: | case WM_ENTERMENULOOP: | 
| Line 235  static LRESULT CALLBACK kdproc(HWND hWnd | Line 228  static LRESULT CALLBACK kdproc(HWND hWnd | 
 |  |  | 
 | case WM_ENTERSIZEMOVE: | case WM_ENTERSIZEMOVE: | 
 | soundmng_disable(SNDPROC_SUBWIND); | soundmng_disable(SNDPROC_SUBWIND); | 
| winlocex_destroy(kdwin.wlex); | winlocex_destroy(kdispwin.wlex); | 
| kdwin.wlex = np2_winlocexallwin(hWnd); | kdispwin.wlex = np2_winlocexallwin(hWnd); | 
 | break; | break; | 
 |  |  | 
 | case WM_MOVING: | case WM_MOVING: | 
| winlocex_moving(kdwin.wlex, (RECT *)lp); | winlocex_moving(kdispwin.wlex, (RECT *)lp); | 
 | break; | break; | 
 |  |  | 
 | case WM_EXITSIZEMOVE: | case WM_EXITSIZEMOVE: | 
| winlocex_destroy(kdwin.wlex); | winlocex_destroy(kdispwin.wlex); | 
| kdwin.wlex = NULL; | kdispwin.wlex = NULL; | 
 | soundmng_enable(SNDPROC_SUBWIND); | soundmng_enable(SNDPROC_SUBWIND); | 
 | break; | break; | 
 |  |  | 
| Line 268  static LRESULT CALLBACK kdproc(HWND hWnd | Line 261  static LRESULT CALLBACK kdproc(HWND hWnd | 
 |  |  | 
 | case WM_DESTROY: | case WM_DESTROY: | 
 | np2class_wmdestroy(hWnd); | np2class_wmdestroy(hWnd); | 
| dd2_release(kdwin.dd2hdl); | dd2_release(kdispwin.dd2hdl); | 
| kdwin.hwnd = NULL; | kdispwin.hwnd = NULL; | 
 | kdsetdispmode(KEYDISP_MODENONE); | kdsetdispmode(KEYDISP_MODENONE); | 
 | break; | break; | 
 |  |  | 
| Line 279  static LRESULT CALLBACK kdproc(HWND hWnd | Line 272  static LRESULT CALLBACK kdproc(HWND hWnd | 
 | return(0L); | return(0L); | 
 | } | } | 
 |  |  | 
|  | BOOL kdispwin_initialize(HINSTANCE hInstance) { | 
| // ---- |  | 
|  |  | 
| BOOL kdispwin_initialize(HINSTANCE hPreInst) { |  | 
 |  |  | 
 | WNDCLASS        wc; | WNDCLASS        wc; | 
 |  |  | 
| if (!hPreInst) { | ZeroMemory(&wc, sizeof(wc)); | 
| ZeroMemory(&wc, sizeof(wc)); | wc.style = CS_BYTEALIGNCLIENT | CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS; | 
| wc.style = CS_BYTEALIGNCLIENT | CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS; | wc.lpfnWndProc = kdproc; | 
| wc.lpfnWndProc = kdproc; | wc.cbClsExtra = 0; | 
| wc.cbClsExtra = 0; | wc.cbWndExtra = NP2GWLP_SIZE; | 
| wc.cbWndExtra = NP2GWL_SIZE; | wc.hInstance = hInstance; | 
| wc.hInstance = hInst; | wc.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_ICON2)); | 
| wc.hIcon = LoadIcon(hInst, MAKEINTRESOURCE(IDI_ICON2)); | wc.hCursor = LoadCursor(NULL, IDC_ARROW); | 
| wc.hCursor = LoadCursor(NULL, IDC_ARROW); | wc.hbrBackground = (HBRUSH)GetStockObject(NULL_BRUSH); | 
| wc.hbrBackground = (HBRUSH)GetStockObject(NULL_BRUSH); | wc.lpszMenuName = MAKEINTRESOURCE(IDR_KEYDISP); | 
| wc.lpszMenuName = MAKEINTRESOURCE(IDR_KEYDISP); | wc.lpszClassName = kdispclass; | 
| wc.lpszClassName = np2kdclass; | if (!RegisterClass(&wc)) { | 
| if (!RegisterClass(&wc)) { | return(FAILURE); | 
| return(FAILURE); |  | 
| } |  | 
 | } | } | 
 | keydisp_initialize(); | keydisp_initialize(); | 
 | return(SUCCESS); | return(SUCCESS); | 
 | } | } | 
 |  |  | 
| void kdispwin_create(void) { | void kdispwin_create(HINSTANCE hInstance) { | 
 |  |  | 
 |  | TCHAR           szCaption[128]; | 
 | HWND            hwnd; | HWND            hwnd; | 
| BYTE            mode; | UINT8           mode; | 
 | CMNPALFN        palfn; | CMNPALFN        palfn; | 
 |  |  | 
| if (kdwin.hwnd != NULL) { | if (kdispwin.hwnd != NULL) { | 
 | return; | return; | 
 | } | } | 
| ZeroMemory(&kdwin, sizeof(kdwin)); | ZeroMemory(&kdispwin, sizeof(kdispwin)); | 
| hwnd = CreateWindow(np2kdclass, np2kdcaption, |  | 
|  | loadstringresource(LOWORD(IDS_CAPTION_KEYDISP), | 
|  | szCaption, NELEMENTS(szCaption)); | 
|  | hwnd = CreateWindow(kdispclass, szCaption, | 
 | WS_OVERLAPPED | WS_SYSMENU | WS_CAPTION | | WS_OVERLAPPED | WS_SYSMENU | WS_CAPTION | | 
 | WS_MINIMIZEBOX, | WS_MINIMIZEBOX, | 
 | kdispcfg.posx, kdispcfg.posy, | kdispcfg.posx, kdispcfg.posy, | 
| CW_USEDEFAULT, CW_USEDEFAULT, | KEYDISP_WIDTH, KEYDISP_HEIGHT, | 
| NULL, NULL, hInst, NULL); | NULL, NULL, hInstance, NULL); | 
| kdwin.hwnd = hwnd; | kdispwin.hwnd = hwnd; | 
 | if (hwnd == NULL) { | if (hwnd == NULL) { | 
 | goto kdcre_err1; | goto kdcre_err1; | 
 | } | } | 
| Line 339  void kdispwin_create(void) { | Line 331  void kdispwin_create(void) { | 
 | kdsetdispmode(mode); | kdsetdispmode(mode); | 
 | ShowWindow(hwnd, SW_SHOWNOACTIVATE); | ShowWindow(hwnd, SW_SHOWNOACTIVATE); | 
 | UpdateWindow(hwnd); | UpdateWindow(hwnd); | 
| kdwin.dd2hdl = dd2_create(hwnd, KEYDISP_WIDTH, KEYDISP_HEIGHT); | kdispwin.dd2hdl = dd2_create(hwnd, KEYDISP_WIDTH, KEYDISP_HEIGHT); | 
| if (kdwin.dd2hdl == NULL) { | if (kdispwin.dd2hdl == NULL) { | 
 | goto kdcre_err2; | goto kdcre_err2; | 
 | } | } | 
 | palfn.get8 = kdgetpal8; | palfn.get8 = kdgetpal8; | 
 | palfn.get32 = kdgetpal32; | palfn.get32 = kdgetpal32; | 
 | palfn.cnv16 = kdcnvpal16; | palfn.cnv16 = kdcnvpal16; | 
| palfn.userdata = (long)kdwin.dd2hdl; | palfn.userdata = (long)kdispwin.dd2hdl; | 
 | keydisp_setpal(&palfn); | keydisp_setpal(&palfn); | 
 | kdispwin_draw(0); | kdispwin_draw(0); | 
| SetForegroundWindow(hWndMain); | SetForegroundWindow(g_hWndMain); | 
 | return; | return; | 
 |  |  | 
 | kdcre_err2: | kdcre_err2: | 
| Line 362  kdcre_err1: | Line 354  kdcre_err1: | 
 |  |  | 
 | void kdispwin_destroy(void) { | void kdispwin_destroy(void) { | 
 |  |  | 
| if (kdwin.hwnd != NULL) { | if (kdispwin.hwnd != NULL) { | 
| DestroyWindow(kdwin.hwnd); | DestroyWindow(kdispwin.hwnd); | 
 | } | } | 
 | } | } | 
 |  |  | 
 | HWND kdispwin_gethwnd(void) { | HWND kdispwin_gethwnd(void) { | 
 |  |  | 
| return(kdwin.hwnd); | return(kdispwin.hwnd); | 
 | } | } | 
 |  |  | 
| void kdispwin_draw(BYTE cnt) { | void kdispwin_draw(UINT8 cnt) { | 
 |  |  | 
| BYTE    flag; | UINT8   flag; | 
 |  |  | 
| if (kdwin.hwnd) { | if (kdispwin.hwnd) { | 
 | if (!cnt) { | if (!cnt) { | 
 | cnt = 1; | cnt = 1; | 
 | } | } | 
| Line 384  void kdispwin_draw(BYTE cnt) { | Line 376  void kdispwin_draw(BYTE cnt) { | 
 | if (flag & KEYDISP_FLAGSIZING) { | if (flag & KEYDISP_FLAGSIZING) { | 
 | kdsetwinsize(); | kdsetwinsize(); | 
 | } | } | 
| kddrawkeys(kdwin.hwnd, FALSE); | kddrawkeys(kdispwin.hwnd, FALSE); | 
 | } | } | 
 | } | } | 
 |  |  | 
 | void kdispwin_readini(void) { | void kdispwin_readini(void) { | 
 |  |  | 
| char    path[MAX_PATH]; | OEMCHAR path[MAX_PATH]; | 
 |  |  | 
 | ZeroMemory(&kdispcfg, sizeof(kdispcfg)); | ZeroMemory(&kdispcfg, sizeof(kdispcfg)); | 
 | kdispcfg.posx = CW_USEDEFAULT; | kdispcfg.posx = CW_USEDEFAULT; | 
 | kdispcfg.posy = CW_USEDEFAULT; | kdispcfg.posy = CW_USEDEFAULT; | 
| initgetfile(path, sizeof(path)); | initgetfile(path, NELEMENTS(path)); | 
| ini_read(path, np2kdapp, np2kdini, sizeof(np2kdini)/sizeof(INITBL)); | ini_read(path, kdispapp, kdispini, NELEMENTS(kdispini)); | 
 | } | } | 
 |  |  | 
 | void kdispwin_writeini(void) { | void kdispwin_writeini(void) { | 
 |  |  | 
| char    path[MAX_PATH]; | OEMCHAR path[MAX_PATH]; | 
 |  |  | 
| initgetfile(path, sizeof(path)); | initgetfile(path, NELEMENTS(path)); | 
| ini_write(path, np2kdapp, np2kdini, sizeof(np2kdini)/sizeof(INITBL)); | ini_write(path, kdispapp, kdispini, NELEMENTS(kdispini)); | 
|  | } | 
|  | #endif | 
|  |  | 
|  |  | 
|  | // ---- memdbg | 
|  |  | 
|  | #if defined(CPUCORE_IA32) && defined(SUPPORT_MEMDBG32) | 
|  |  | 
|  | typedef struct { | 
|  | HWND            hwnd; | 
|  | WINLOCEX        wlex; | 
|  | DD2HDL          dd2hdl; | 
|  | int                     width; | 
|  | int                     height; | 
|  | } MDBGWIN; | 
|  |  | 
|  | typedef struct { | 
|  | int             posx; | 
|  | int             posy; | 
|  | UINT8   type; | 
|  | } MDBGCFG; | 
|  |  | 
|  | static  MDBGWIN         mdbgwin; | 
|  | static  MDBGCFG         mdbgcfg; | 
|  |  | 
|  | static const TCHAR mdbgtitle[] = _T("Memory Map"); | 
|  | static const TCHAR mdbgclass[] = _T("NP2-MemDbgWin"); | 
|  |  | 
|  | #if defined(OSLANG_UTF8) | 
|  | static const OEMCHAR mdbgapp[] = OEMTEXT("Memory Map"); | 
|  | #else | 
|  | #define mdbgapp         mdbgtitle | 
|  | #endif | 
|  | static const PFTBL mdbgini[] = { | 
|  | PFVAL("WindposX", PFTYPE_SINT32,        &mdbgcfg.posx), | 
|  | PFVAL("WindposY", PFTYPE_SINT32,        &mdbgcfg.posy), | 
|  | PFVAL("windtype", PFTYPE_BOOL,          &mdbgcfg.type)}; | 
|  |  | 
|  |  | 
|  | static void mdpalcnv(CMNPAL *dst, const RGB32 *src, UINT pals, UINT bpp) { | 
|  |  | 
|  | UINT    i; | 
|  |  | 
|  | switch(bpp) { | 
|  | #if defined(SUPPORT_16BPP) | 
|  | case 16: | 
|  | for (i=0; i<pals; i++) { | 
|  | dst[i].pal16 = dd2_get16pal(mdbgwin.dd2hdl, src[i]); | 
|  | } | 
|  | break; | 
|  | #endif | 
|  | #if defined(SUPPORT_24BPP) | 
|  | case 24: | 
|  | #endif | 
|  | #if defined(SUPPORT_32BPP) | 
|  | case 32: | 
|  | #endif | 
|  | #if defined(SUPPORT_24BPP) || defined(SUPPORT_32BPP) | 
|  | for (i=0; i<pals; i++) { | 
|  | dst[i].pal32.d = src[i].d; | 
|  | } | 
|  | break; | 
|  | #endif | 
|  | } | 
|  | } | 
|  |  | 
|  | static void mdwincreate(HWND hWnd) { | 
|  |  | 
|  | int                     width; | 
|  | int                     height; | 
|  |  | 
|  | memdbg32_getsize(&width, &height); | 
|  | } | 
|  |  | 
|  | static void mddrawwin(HWND hWnd, BOOL redraw) { | 
|  |  | 
|  | RECT            rect; | 
|  | RECT            draw; | 
|  | CMNVRAM         *vram; | 
|  |  | 
|  | GetClientRect(hWnd, &rect); | 
|  | draw.left = 0; | 
|  | draw.top = 0; | 
|  | draw.right = min(mdbgwin.width, rect.right - rect.left); | 
|  | draw.bottom = min(mdbgwin.height, rect.bottom - rect.top); | 
|  | vram = dd2_bsurflock(mdbgwin.dd2hdl); | 
|  | if (vram) { | 
|  | memdbg32_paint(vram, mdpalcnv, redraw); | 
|  | dd2_bsurfunlock(mdbgwin.dd2hdl); | 
|  | dd2_blt(mdbgwin.dd2hdl, NULL, &draw); | 
|  | } | 
|  | } | 
|  |  | 
|  | static void mdpaintmsg(HWND hWnd) { | 
|  |  | 
|  | HDC                     hdc; | 
|  | PAINTSTRUCT     ps; | 
|  |  | 
|  | hdc = BeginPaint(hWnd, &ps); | 
|  | mddrawwin(hWnd, TRUE); | 
|  | EndPaint(hWnd, &ps); | 
|  | } | 
|  |  | 
|  | static LRESULT CALLBACK mdproc(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp) { | 
|  |  | 
|  | switch(msg) { | 
|  | case WM_CREATE: | 
|  | np2class_wmcreate(hWnd); | 
|  | winloc_setclientsize(hWnd, mdbgwin.width, mdbgwin.height); | 
|  | np2class_windowtype(hWnd, (mdbgcfg.type & 1) + 1); | 
|  | break; | 
|  |  | 
|  | case WM_PAINT: | 
|  | mdpaintmsg(hWnd); | 
|  | break; | 
|  |  | 
|  | case WM_LBUTTONDOWN: | 
|  | if (mdbgcfg.type & 1) { | 
|  | return(SendMessage(hWnd, WM_NCLBUTTONDOWN, HTCAPTION, 0L)); | 
|  | } | 
|  | break; | 
|  |  | 
|  | case WM_LBUTTONDBLCLK: | 
|  | mdbgcfg.type ^= 1; | 
|  | wintypechange(hWnd, (mdbgcfg.type & 1) + 1); | 
|  | sysmng_update(SYS_UPDATEOSCFG); | 
|  | break; | 
|  |  | 
|  | case WM_KEYDOWN: | 
|  | case WM_KEYUP: | 
|  | SendMessage(g_hWndMain, msg, wp, lp); | 
|  | break; | 
|  |  | 
|  | case WM_ENTERMENULOOP: | 
|  | soundmng_disable(SNDPROC_SUBWIND); | 
|  | break; | 
|  |  | 
|  | case WM_EXITMENULOOP: | 
|  | soundmng_enable(SNDPROC_SUBWIND); | 
|  | break; | 
|  |  | 
|  | case WM_ENTERSIZEMOVE: | 
|  | soundmng_disable(SNDPROC_SUBWIND); | 
|  | winlocex_destroy(mdbgwin.wlex); | 
|  | mdbgwin.wlex = np2_winlocexallwin(hWnd); | 
|  | break; | 
|  |  | 
|  | case WM_MOVING: | 
|  | winlocex_moving(mdbgwin.wlex, (RECT *)lp); | 
|  | break; | 
|  |  | 
|  | case WM_EXITSIZEMOVE: | 
|  | winlocex_destroy(mdbgwin.wlex); | 
|  | mdbgwin.wlex = NULL; | 
|  | soundmng_enable(SNDPROC_SUBWIND); | 
|  | break; | 
|  |  | 
|  | case WM_MOVE: | 
|  | if (!(GetWindowLong(hWnd, GWL_STYLE) & | 
|  | (WS_MAXIMIZE | WS_MINIMIZE))) { | 
|  | RECT rc; | 
|  | GetWindowRect(hWnd, &rc); | 
|  | mdbgcfg.posx = rc.left; | 
|  | mdbgcfg.posy = rc.top; | 
|  | sysmng_update(SYS_UPDATEOSCFG); | 
|  | } | 
|  | break; | 
|  |  | 
|  | case WM_CLOSE: | 
|  | DestroyWindow(hWnd); | 
|  | break; | 
|  |  | 
|  | case WM_DESTROY: | 
|  | np2class_wmdestroy(hWnd); | 
|  | dd2_release(mdbgwin.dd2hdl); | 
|  | mdbgwin.hwnd = NULL; | 
|  | break; | 
|  |  | 
|  | default: | 
|  | return(DefWindowProc(hWnd, msg, wp, lp)); | 
|  | } | 
|  | return(0); | 
|  | } | 
|  |  | 
|  | BOOL mdbgwin_initialize(HINSTANCE hInstance) { | 
|  |  | 
|  | WNDCLASS        wc; | 
|  |  | 
|  | wc.style = CS_BYTEALIGNCLIENT | CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS; | 
|  | wc.lpfnWndProc = mdproc; | 
|  | wc.cbClsExtra = 0; | 
|  | wc.cbWndExtra = 0; | 
|  | wc.hInstance = hInstance; | 
|  | wc.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_ICON2)); | 
|  | wc.hCursor = LoadCursor(NULL, IDC_ARROW); | 
|  | wc.hbrBackground = (HBRUSH)GetStockObject(NULL_BRUSH); | 
|  | wc.lpszMenuName = NULL; | 
|  | wc.lpszClassName = mdbgclass; | 
|  | if (!RegisterClass(&wc)) { | 
|  | return(FAILURE); | 
|  | } | 
|  | memdbg32_initialize(); | 
|  | return(SUCCESS); | 
|  | } | 
|  |  | 
|  | void mdbgwin_create(HINSTANCE hInstance) { | 
|  |  | 
|  | HWND    hWnd; | 
|  |  | 
|  | if (mdbgwin.hwnd != NULL) { | 
|  | return; | 
|  | } | 
|  | ZeroMemory(&mdbgwin, sizeof(mdbgwin)); | 
|  | memdbg32_getsize(&mdbgwin.width, &mdbgwin.height); | 
|  | hWnd = CreateWindow(mdbgclass, mdbgtitle, | 
|  | WS_OVERLAPPED | WS_SYSMENU | WS_CAPTION | | 
|  | WS_MINIMIZEBOX, | 
|  | mdbgcfg.posx, mdbgcfg.posy, | 
|  | mdbgwin.width, mdbgwin.height, | 
|  | NULL, NULL, hInstance, NULL); | 
|  | mdbgwin.hwnd = hWnd; | 
|  | if (hWnd == NULL) { | 
|  | goto mdcre_err1; | 
|  | } | 
|  | ShowWindow(hWnd, SW_SHOWNOACTIVATE); | 
|  | UpdateWindow(hWnd); | 
|  | mdbgwin.dd2hdl = dd2_create(hWnd, mdbgwin.width, mdbgwin.height); | 
|  | if (mdbgwin.dd2hdl == NULL) { | 
|  | goto mdcre_err2; | 
|  | } | 
|  | InvalidateRect(hWnd, NULL, TRUE); | 
|  | SetForegroundWindow(g_hWndMain); | 
|  | return; | 
|  |  | 
|  | mdcre_err2: | 
|  | DestroyWindow(hWnd); | 
|  |  | 
|  | mdcre_err1: | 
|  | return; | 
|  | } | 
|  |  | 
|  | void mdbgwin_destroy(void) { | 
|  |  | 
|  | if (mdbgwin.hwnd) { | 
|  | DestroyWindow(mdbgwin.hwnd); | 
|  | } | 
|  | } | 
|  |  | 
|  | void mdbgwin_process(void) { | 
|  |  | 
|  | if ((mdbgwin.hwnd) && (memdbg32_process())) { | 
|  | mddrawwin(mdbgwin.hwnd, FALSE); | 
|  | } | 
|  | } | 
|  |  | 
|  | HWND mdbgwin_gethwnd(void) { | 
|  |  | 
|  | return(mdbgwin.hwnd); | 
|  | } | 
|  |  | 
|  | void mdbgwin_readini(void) { | 
|  |  | 
|  | OEMCHAR path[MAX_PATH]; | 
|  |  | 
|  | mdbgcfg.posx = CW_USEDEFAULT; | 
|  | mdbgcfg.posy = CW_USEDEFAULT; | 
|  | initgetfile(path, NELEMENTS(path)); | 
|  | ini_read(path, mdbgapp, mdbgini, NELEMENTS(mdbgini)); | 
|  | } | 
|  |  | 
|  | void mdbgwin_writeini(void) { | 
|  |  | 
|  | OEMCHAR path[MAX_PATH]; | 
|  |  | 
|  | initgetfile(path, NELEMENTS(path)); | 
|  | ini_write(path, mdbgapp, mdbgini, NELEMENTS(mdbgini)); | 
 | } | } | 
 | #endif | #endif | 
 |  |  | 
| Line 429  typedef struct { | Line 697  typedef struct { | 
 | static  SKBDWIN         skbdwin; | static  SKBDWIN         skbdwin; | 
 | static  SKBDCFG         skbdcfg; | static  SKBDCFG         skbdcfg; | 
 |  |  | 
| static const char np2skcaption[] = "Soft Keyboard"; | static const TCHAR skbdclass[] = _T("NP2-SoftKBDWin"); | 
| static const char np2skclass[] = "NP2-SoftKBDWin"; |  | 
| static const char np2skapp[] = "NP2 softbkd"; |  | 
| static const INITBL np2skini[] = { |  | 
| {"WindposX", INITYPE_SINT32,    &skbdcfg.posx,                  0}, |  | 
| {"WindposY", INITYPE_SINT32,    &skbdcfg.posy,                  0}, |  | 
| {"windtype", INITYPE_BOOL,              &skbdcfg.type,                  0}}; |  | 
 |  |  | 
| static void skpalcnv(CMNPAL *dst, RGB32 *src, UINT pals, UINT bpp) { | static const OEMCHAR skbdapp[] = OEMTEXT("Soft Keyboard"); | 
|  | static const PFTBL skbdini[] = { | 
|  | PFVAL("WindposX", PFTYPE_SINT32,        &skbdcfg.posx), | 
|  | PFVAL("WindposY", PFTYPE_SINT32,        &skbdcfg.posy), | 
|  | PFVAL("windtype", PFTYPE_BOOL,          &skbdcfg.type)}; | 
|  |  | 
|  | static void skpalcnv(CMNPAL *dst, const RGB32 *src, UINT pals, UINT bpp) { | 
 |  |  | 
 | UINT    i; | UINT    i; | 
 |  |  | 
 | switch(bpp) { | switch(bpp) { | 
 | #if defined(SUPPORT_8BPP) |  | 
 | case 8: |  | 
 | break; |  | 
 | #endif |  | 
 | #if defined(SUPPORT_16BPP) | #if defined(SUPPORT_16BPP) | 
 | case 16: | case 16: | 
 | for (i=0; i<pals; i++) { | for (i=0; i<pals; i++) { | 
| Line 468  static void skpalcnv(CMNPAL *dst, RGB32 | Line 732  static void skpalcnv(CMNPAL *dst, RGB32 | 
 | } | } | 
 | } | } | 
 |  |  | 
| static void skpaintmsg(HWND hWnd) { | static void skdrawkeys(HWND hWnd, BOOL redraw) { | 
 |  |  | 
 | HDC                     hdc; |  | 
 | PAINTSTRUCT     ps; |  | 
 | RECT            rect; | RECT            rect; | 
 | RECT            draw; | RECT            draw; | 
 | CMNVRAM         *vram; | CMNVRAM         *vram; | 
 |  |  | 
 | TRACEOUT(("skpaintmsg")); |  | 
 | GetClientRect(hWnd, &rect); | GetClientRect(hWnd, &rect); | 
 | draw.left = 0; | draw.left = 0; | 
 | draw.top = 0; | draw.top = 0; | 
 | draw.right = min(skbdwin.width, rect.right - rect.left); | draw.right = min(skbdwin.width, rect.right - rect.left); | 
 | draw.bottom = min(skbdwin.height, rect.bottom - rect.top); | draw.bottom = min(skbdwin.height, rect.bottom - rect.top); | 
 | hdc = BeginPaint(hWnd, &ps); |  | 
 | vram = dd2_bsurflock(skbdwin.dd2hdl); | vram = dd2_bsurflock(skbdwin.dd2hdl); | 
 | if (vram) { | if (vram) { | 
| softkbd_paint(vram, skpalcnv); | softkbd_paint(vram, skpalcnv, redraw); | 
 | dd2_bsurfunlock(skbdwin.dd2hdl); | dd2_bsurfunlock(skbdwin.dd2hdl); | 
 | dd2_blt(skbdwin.dd2hdl, NULL, &draw); | dd2_blt(skbdwin.dd2hdl, NULL, &draw); | 
 | } | } | 
 |  | } | 
 |  |  | 
 |  | static void skpaintmsg(HWND hWnd) { | 
 |  |  | 
 |  | HDC                     hdc; | 
 |  | PAINTSTRUCT     ps; | 
 |  |  | 
 |  | hdc = BeginPaint(hWnd, &ps); | 
 |  | skdrawkeys(hWnd, TRUE); | 
 | EndPaint(hWnd, &ps); | EndPaint(hWnd, &ps); | 
 | } | } | 
 |  |  | 
| Line 526  static LRESULT CALLBACK skproc(HWND hWnd | Line 795  static LRESULT CALLBACK skproc(HWND hWnd | 
 |  |  | 
 | case WM_KEYDOWN: | case WM_KEYDOWN: | 
 | case WM_KEYUP: | case WM_KEYUP: | 
| SendMessage(hWndMain, msg, wp, lp); | SendMessage(g_hWndMain, msg, wp, lp); | 
 | break; | break; | 
 |  |  | 
 | case WM_ENTERMENULOOP: | case WM_ENTERMENULOOP: | 
| Line 580  static LRESULT CALLBACK skproc(HWND hWnd | Line 849  static LRESULT CALLBACK skproc(HWND hWnd | 
 | return(0L); | return(0L); | 
 | } | } | 
 |  |  | 
|  | BOOL skbdwin_initialize(HINSTANCE hInstance) { | 
| // ---- |  | 
|  |  | 
| BOOL skbdwin_initialize(HINSTANCE hPreInst) { |  | 
 |  |  | 
 | WNDCLASS        wc; | WNDCLASS        wc; | 
 |  |  | 
| if (!hPreInst) { | ZeroMemory(&wc, sizeof(wc)); | 
| ZeroMemory(&wc, sizeof(wc)); | wc.style = CS_BYTEALIGNCLIENT | CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS; | 
| wc.style = CS_BYTEALIGNCLIENT | CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS; | wc.lpfnWndProc = skproc; | 
| wc.lpfnWndProc = skproc; | wc.cbClsExtra = 0; | 
| wc.cbClsExtra = 0; | wc.cbWndExtra = NP2GWLP_SIZE; | 
| wc.cbWndExtra = NP2GWL_SIZE; | wc.hInstance = hInstance; | 
| wc.hInstance = hInst; | wc.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_ICON2)); | 
| wc.hIcon = LoadIcon(hInst, MAKEINTRESOURCE(IDI_ICON2)); | wc.hCursor = LoadCursor(NULL, IDC_ARROW); | 
| wc.hCursor = LoadCursor(NULL, IDC_ARROW); | wc.hbrBackground = (HBRUSH)GetStockObject(NULL_BRUSH); | 
| wc.hbrBackground = (HBRUSH)GetStockObject(NULL_BRUSH); | wc.lpszMenuName = NULL; | 
| wc.lpszMenuName = NULL; | wc.lpszClassName = skbdclass; | 
| wc.lpszClassName = np2skclass; | if (!RegisterClass(&wc)) { | 
| if (!RegisterClass(&wc)) { | return(FAILURE); | 
| return(FAILURE); |  | 
| } |  | 
 | } | } | 
 | softkbd_initialize(); | softkbd_initialize(); | 
 | return(SUCCESS); | return(SUCCESS); | 
| Line 612  void skbdwin_deinitialize(void) { | Line 876  void skbdwin_deinitialize(void) { | 
 | softkbd_deinitialize(); | softkbd_deinitialize(); | 
 | } | } | 
 |  |  | 
| void skbdwin_create(void) { | void skbdwin_create(HINSTANCE hInstance) { | 
 |  |  | 
 |  | TCHAR   szCaption[128]; | 
 | HWND    hwnd; | HWND    hwnd; | 
 |  |  | 
 | if (skbdwin.hwnd != NULL) { | if (skbdwin.hwnd != NULL) { | 
| Line 623  void skbdwin_create(void) { | Line 888  void skbdwin_create(void) { | 
 | if (softkbd_getsize(&skbdwin.width, &skbdwin.height) != SUCCESS) { | if (softkbd_getsize(&skbdwin.width, &skbdwin.height) != SUCCESS) { | 
 | return; | return; | 
 | } | } | 
| hwnd = CreateWindow(np2skclass, np2skcaption, |  | 
|  | loadstringresource(LOWORD(IDS_CAPTION_SOFTKEY), | 
|  | szCaption, NELEMENTS(szCaption)); | 
|  | hwnd = CreateWindow(skbdclass, szCaption, | 
 | WS_OVERLAPPED | WS_SYSMENU | WS_CAPTION | | WS_OVERLAPPED | WS_SYSMENU | WS_CAPTION | | 
 | WS_MINIMIZEBOX, | WS_MINIMIZEBOX, | 
 | skbdcfg.posx, skbdcfg.posy, | skbdcfg.posx, skbdcfg.posy, | 
 | skbdwin.width, skbdwin.height, | skbdwin.width, skbdwin.height, | 
| NULL, NULL, hInst, NULL); | NULL, NULL, hInstance, NULL); | 
 | skbdwin.hwnd = hwnd; | skbdwin.hwnd = hwnd; | 
 | if (hwnd == NULL) { | if (hwnd == NULL) { | 
 | goto skcre_err1; | goto skcre_err1; | 
| Line 640  void skbdwin_create(void) { | Line 908  void skbdwin_create(void) { | 
 | goto skcre_err2; | goto skcre_err2; | 
 | } | } | 
 | InvalidateRect(hwnd, NULL, TRUE); | InvalidateRect(hwnd, NULL, TRUE); | 
| SetForegroundWindow(hWndMain); | SetForegroundWindow(g_hWndMain); | 
 | return; | return; | 
 |  |  | 
 | skcre_err2: | skcre_err2: | 
| Line 662  HWND skbdwin_gethwnd(void) { | Line 930  HWND skbdwin_gethwnd(void) { | 
 | return(skbdwin.hwnd); | return(skbdwin.hwnd); | 
 | } | } | 
 |  |  | 
 |  | void skbdwin_process(void) { | 
 |  |  | 
 |  | if ((skbdwin.hwnd) && (softkbd_process())) { | 
 |  | skdrawkeys(skbdwin.hwnd, FALSE); | 
 |  | } | 
 |  | } | 
 |  |  | 
 | void skbdwin_readini(void) { | void skbdwin_readini(void) { | 
 |  |  | 
| char    path[MAX_PATH]; | OEMCHAR path[MAX_PATH]; | 
 |  |  | 
 | skbdcfg.posx = CW_USEDEFAULT; | skbdcfg.posx = CW_USEDEFAULT; | 
 | skbdcfg.posy = CW_USEDEFAULT; | skbdcfg.posy = CW_USEDEFAULT; | 
| initgetfile(path, sizeof(path)); | initgetfile(path, NELEMENTS(path)); | 
| ini_read(path, np2skapp, np2skini, sizeof(np2skini)/sizeof(INITBL)); | ini_read(path, skbdapp, skbdini, NELEMENTS(skbdini)); | 
 | } | } | 
 |  |  | 
 | void skbdwin_writeini(void) { | void skbdwin_writeini(void) { | 
 |  |  | 
| char    path[MAX_PATH]; | OEMCHAR path[MAX_PATH]; | 
 |  |  | 
| initgetfile(path, sizeof(path)); | initgetfile(path, NELEMENTS(path)); | 
| ini_write(path, np2skapp, np2skini, sizeof(np2skini)/sizeof(INITBL)); | ini_write(path, skbdapp, skbdini, NELEMENTS(skbdini)); | 
 | } | } | 
 | #endif | #endif | 
 |  |  |