--- np2/win9x/dialog/d_screen.cpp 2005/02/09 20:11:36 1.9 +++ np2/win9x/dialog/d_screen.cpp 2011/03/07 09:54:11 1.18 @@ -1,26 +1,35 @@ -#include "compiler.h" -#include -#include -#include "strres.h" -#include "resource.h" -#include "np2.h" -#include "scrnmng.h" -#include "sysmng.h" -#include "np2class.h" -#include "dialog.h" -#include "dialogs.h" -#include "pccore.h" -#include "iocore.h" -#include "scrndraw.h" -#include "palettes.h" - - -static const OEMCHAR str_scropt[] = OEMTEXT("Screen option"); - +/** + * @file d_screen.cpp + * @brief Screen configure dialog procedure + * + * @author $Author: yui $ + * @date $Date: 2011/03/07 09:54:11 $ + */ + +#include "compiler.h" +#include +#include +#include "strres.h" +#include "resource.h" +#include "np2.h" +#include "oemtext.h" +#include "scrnmng.h" +#include "sysmng.h" +#include "np2class.h" +#include "dialog.h" +#include "dialogs.h" +#include "pccore.h" +#include "iocore.h" +#include "scrndraw.h" +#include "palettes.h" + +#if !defined(__GNUC__) +#pragma comment(lib, "comctl32.lib") +#endif // !defined(__GNUC__) static LRESULT CALLBACK Scropt1DlgProc(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp) { - OEMCHAR work[32]; + TCHAR work[32]; UINT16 ret; UINT8 b; int renewal; @@ -36,7 +45,7 @@ static LRESULT CALLBACK Scropt1DlgProc(H MAKELONG(0, 255)); SendDlgItemMessage(hWnd, IDC_SKIPLIGHT, TBM_SETPOS, TRUE, np2cfg.skiplight); - OEMSPRINTF(work, str_d, np2cfg.skiplight); + wsprintf(work, tchar_u, np2cfg.skiplight); SetDlgItemText(hWnd, IDC_LIGHTSTR, work); return(TRUE); @@ -54,7 +63,7 @@ static LRESULT CALLBACK Scropt1DlgProc(H case IDC_SKIPLIGHT: ret = (UINT16)SendDlgItemMessage(hWnd, IDC_SKIPLIGHT, TBM_GETPOS, 0, 0); - OEMSPRINTF(work, str_d, ret); + wsprintf(work, tchar_u, ret); SetDlgItemText(hWnd, IDC_LIGHTSTR, work); break; } @@ -63,13 +72,14 @@ static LRESULT CALLBACK Scropt1DlgProc(H case WM_NOTIFY: if ((((NMHDR *)lp)->code) == (UINT)PSN_APPLY) { renewal = 0; - b = GetDlgItemCheck(hWnd, IDC_SKIPLINE); + b = (UINT8)GetDlgItemCheck(hWnd, IDC_SKIPLINE); if (np2cfg.skipline != b) { np2cfg.skipline = b; renewal = 1; } - if ((ret = (UINT16)SendDlgItemMessage(hWnd, IDC_SKIPLIGHT, - TBM_GETPOS, 0, 0)) > 255) { + ret = (UINT16)SendDlgItemMessage(hWnd, IDC_SKIPLIGHT, + TBM_GETPOS, 0, 0); + if (ret > 255) { ret = 255; } if (np2cfg.skiplight != ret) { @@ -79,8 +89,8 @@ static LRESULT CALLBACK Scropt1DlgProc(H if (renewal) { pal_makeskiptable(); } - b = GetDlgItemCheck(hWnd, IDC_LCD) | - (GetDlgItemCheck(hWnd, IDC_LCDX) << 1); + b = (GetDlgItemCheck(hWnd, IDC_LCD)?0x01:0x00) | + (GetDlgItemCheck(hWnd, IDC_LCDX)?0x02:0x00); if (np2cfg.LCD_MODE != b) { np2cfg.LCD_MODE = b; pal_makelcdpal(); @@ -128,7 +138,7 @@ static LRESULT CALLBACK Scropt2DlgProc(H case WM_NOTIFY: if ((((NMHDR *)lp)->code) == (UINT)PSN_APPLY) { update = 0; - b = GetDlgItemCheck(hWnd, IDC_GDC72020); + b = (UINT8)GetDlgItemCheck(hWnd, IDC_GDC72020); if (np2cfg.uPD72020 != b) { np2cfg.uPD72020 = b; update |= SYS_UPDATECFG; @@ -141,7 +151,7 @@ static LRESULT CALLBACK Scropt2DlgProc(H update |= SYS_UPDATECFG; gdcs.grphdisp |= GDCSCRN_ALLDRAW2; } - b = GetDlgItemCheck(hWnd, IDC_PC980124); + b = (UINT8)GetDlgItemCheck(hWnd, IDC_PC980124); if (np2cfg.color16 != b) { np2cfg.color16 = b; update |= SYS_UPDATECFG; @@ -157,7 +167,7 @@ static LRESULT CALLBACK Scropt2DlgProc(H static LRESULT CALLBACK Scropt3DlgProc(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp) { - OEMCHAR work[32]; + TCHAR work[32]; UINT8 value[6]; UINT8 b; UINT update; @@ -168,26 +178,26 @@ static LRESULT CALLBACK Scropt3DlgProc(H MAKELONG(0, 32)); SendDlgItemMessage(hWnd, IDC_TRAMWAIT, TBM_SETPOS, TRUE, np2cfg.wait[0]); - OEMSPRINTF(work, str_u, np2cfg.wait[0]); + wsprintf(work, tchar_u, np2cfg.wait[0]); SetDlgItemText(hWnd, IDC_TRAMSTR, work); SendDlgItemMessage(hWnd, IDC_VRAMWAIT, TBM_SETRANGE, TRUE, MAKELONG(0, 32)); SendDlgItemMessage(hWnd, IDC_VRAMWAIT, TBM_SETPOS, TRUE, np2cfg.wait[2]); - OEMSPRINTF(work, str_u, np2cfg.wait[2]); + wsprintf(work, tchar_u, np2cfg.wait[2]); SetDlgItemText(hWnd, IDC_VRAMSTR, work); SendDlgItemMessage(hWnd, IDC_GRCGWAIT, TBM_SETRANGE, TRUE, MAKELONG(0, 32)); SendDlgItemMessage(hWnd, IDC_GRCGWAIT, TBM_SETPOS, TRUE, np2cfg.wait[4]); - OEMSPRINTF(work, str_u, np2cfg.wait[4]); + wsprintf(work, tchar_u, np2cfg.wait[4]); SetDlgItemText(hWnd, IDC_GRCGSTR, work); SendDlgItemMessage(hWnd, IDC_REALPAL, TBM_SETRANGE, TRUE, MAKELONG(0, 64)); SendDlgItemMessage(hWnd, IDC_REALPAL, TBM_SETPOS, TRUE, np2cfg.realpal); - OEMSPRINTF(work, str_d, (int)np2cfg.realpal - 32); + wsprintf(work, tchar_d, (int)np2cfg.realpal - 32); SetDlgItemText(hWnd, IDC_REALPALSTR, work); return(TRUE); @@ -197,25 +207,28 @@ static LRESULT CALLBACK Scropt3DlgProc(H case IDC_TRAMWAIT: b = (UINT8)SendDlgItemMessage(hWnd, IDC_TRAMWAIT, TBM_GETPOS, 0, 0); - OEMSPRINTF(work, str_u, b); + wsprintf(work, tchar_u, b); SetDlgItemText(hWnd, IDC_TRAMSTR, work); break; + case IDC_VRAMWAIT: b = (UINT8)SendDlgItemMessage(hWnd, IDC_VRAMWAIT, TBM_GETPOS, 0, 0); - OEMSPRINTF(work, str_u, b); + wsprintf(work, tchar_u, b); SetDlgItemText(hWnd, IDC_VRAMSTR, work); break; + case IDC_GRCGWAIT: b = (UINT8)SendDlgItemMessage(hWnd, IDC_GRCGWAIT, TBM_GETPOS, 0, 0); - OEMSPRINTF(work, str_u, b); + wsprintf(work, tchar_u, b); SetDlgItemText(hWnd, IDC_GRCGSTR, work); break; + case IDC_REALPAL: b = (UINT8)SendDlgItemMessage(hWnd, IDC_REALPAL, TBM_GETPOS, 0, 0); - OEMSPRINTF(work, str_d, (int)b - 32); + wsprintf(work, tchar_d, (int)b - 32); SetDlgItemText(hWnd, IDC_REALPALSTR, work); } break; @@ -259,19 +272,83 @@ static LRESULT CALLBACK Scropt3DlgProc(H return(FALSE); } -void dialog_scropt(HWND hWnd) { +static const CBPARAM cpZoom[] = +{ + {MAKEINTRESOURCE(IDS_ZOOM_NONE), 0}, + {MAKEINTRESOURCE(IDS_ZOOM_FIXEDASPECT), 1}, + {MAKEINTRESOURCE(IDS_ZOOM_ADJUSTASPECT), 2}, + {MAKEINTRESOURCE(IDS_ZOOM_FULL), 3}, +}; + +static LRESULT CALLBACK ScroptFullScreenDlgProc(HWND hWnd, UINT uMsg, + WPARAM wParam, LPARAM lParam) +{ + UINT8 c; + + switch(uMsg) + { + case WM_INITDIALOG: + c = np2oscfg.fscrnmod; + SetDlgItemCheck(hWnd, IDC_FULLSCREEN_SAMEBPP, + (c & FSCRNMOD_SAMEBPP)); + SetDlgItemCheck(hWnd, IDC_FULLSCREEN_SAMERES, + (c & FSCRNMOD_SAMERES)); + dlgs_setcbitem(hWnd, IDC_FULLSCREEN_ZOOM, + cpZoom, NELEMENTS(cpZoom)); + dlgs_setcbcur(hWnd, IDC_FULLSCREEN_ZOOM, (c & 3)); + EnableWindow(GetDlgItem(hWnd, IDC_FULLSCREEN_ZOOM), + (c & FSCRNMOD_SAMERES) != 0); + return(TRUE); + + case WM_COMMAND: + switch(LOWORD(wParam)) + { + case IDC_FULLSCREEN_SAMERES: + dlgs_enablebyautocheck(hWnd, IDC_FULLSCREEN_ZOOM, + IDC_FULLSCREEN_SAMERES); + break; + } + break; + + case WM_NOTIFY: + if ((((NMHDR *)lParam)->code) == (UINT)PSN_APPLY) + { + c = 0; + if (GetDlgItemCheck(hWnd, IDC_FULLSCREEN_SAMEBPP)) + { + c |= FSCRNMOD_SAMEBPP; + } + if (GetDlgItemCheck(hWnd, IDC_FULLSCREEN_SAMERES)) + { + c |= FSCRNMOD_SAMERES; + } + c |= dlgs_getcbcur(hWnd, IDC_FULLSCREEN_ZOOM, 0); + if (np2oscfg.fscrnmod != c) + { + np2oscfg.fscrnmod = c; + sysmng_update(SYS_UPDATEOSCFG); + } + return(TRUE); + } + break; + } + return(FALSE); +} - HINSTANCE hinst; +void dialog_scropt(HWND hWnd) +{ + HINSTANCE hInstance; PROPSHEETPAGE psp; PROPSHEETHEADER psh; - HPROPSHEETPAGE hpsp[3]; + HPROPSHEETPAGE hpsp[4]; + TCHAR szTitle[128]; - hinst = (HINSTANCE)GetWindowLong(hWnd, GWL_HINSTANCE); + hInstance = (HINSTANCE)GetWindowLongPtr(hWnd, GWLP_HINSTANCE); ZeroMemory(&psp, sizeof(psp)); psp.dwSize = sizeof(PROPSHEETPAGE); psp.dwFlags = PSP_DEFAULT; - psp.hInstance = hinst; + psp.hInstance = hInstance; psp.pszTemplate = MAKEINTRESOURCE(IDD_SCROPT1); psp.pfnDlgProc = (DLGPROC)Scropt1DlgProc; @@ -285,17 +362,23 @@ void dialog_scropt(HWND hWnd) { psp.pfnDlgProc = (DLGPROC)Scropt3DlgProc; hpsp[2] = CreatePropertySheetPage(&psp); + psp.pszTemplate = MAKEINTRESOURCE(IDD_SCROPT_FULLSCREEN); + psp.pfnDlgProc = (DLGPROC)ScroptFullScreenDlgProc; + hpsp[3] = CreatePropertySheetPage(&psp); + + loadstringresource(IDS_SCREENOPTION, szTitle, NELEMENTS(szTitle)); + ZeroMemory(&psh, sizeof(psh)); psh.dwSize = sizeof(PROPSHEETHEADER); psh.dwFlags = PSH_NOAPPLYNOW | PSH_USEHICON | PSH_USECALLBACK; psh.hwndParent = hWnd; - psh.hInstance = hinst; - psh.hIcon = LoadIcon(hinst, MAKEINTRESOURCE(IDI_ICON2)); - psh.nPages = 3; + psh.hInstance = hInstance; + psh.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_ICON2)); + psh.nPages = 4; psh.phpage = hpsp; - psh.pszCaption = str_scropt; + psh.pszCaption = szTitle; psh.pfnCallback = np2class_propetysheet; PropertySheet(&psh); - InvalidateRect(hWndMain, NULL, TRUE); + InvalidateRect(hWnd, NULL, TRUE); }