From bd48847366cc3e9947abd36216fabc08e0ea9202 Mon Sep 17 00:00:00 2001 From: yui Date: Wed, 30 Dec 2015 15:05:01 +0000 Subject: [PATCH] win9x: adds resizer refs #94 svn merge -r 342:343 https://amethyst.yui.ne.jp/svn-dev/x1/xmil/branches/yui/WORK_01 --- win9x/dialog/d_cfg.cpp | 10 +++ win9x/dialog/extclass.cpp | 70 +++++++++++++++++++ win9x/dialog/extclass.h | 3 +- win9x/ini.cpp | 1 + win9x/resource.h | 1 + win9x/scrnmng.cpp | 138 ++++++++++++++++++++++++++++++++++++-- win9x/scrnmng.h | 13 +++- win9x/xmil.cpp | 36 +++++++--- win9x/xmil.h | 1 + win9x/xmil.rc | 4 +- 10 files changed, 257 insertions(+), 20 deletions(-) diff --git a/win9x/dialog/d_cfg.cpp b/win9x/dialog/d_cfg.cpp index 7068256..88d70d2 100644 --- a/win9x/dialog/d_cfg.cpp +++ b/win9x/dialog/d_cfg.cpp @@ -7,6 +7,7 @@ #include "d_cfg.h" #include "resource.h" #include +#include "xmil.h" #include "soundmng.h" #include "sysmng.h" #include "pccore.h" @@ -51,6 +52,8 @@ BOOL CConfigDlg::OnInitDialog() } #endif // !defined(DISABLE_SOUND) + CheckDlgButton(IDC_ALLOWRESIZE, (xmiloscfg.thickframe) ? BST_CHECKED : BST_UNCHECKED); + return TRUE; } @@ -91,6 +94,13 @@ void CConfigDlg::OnOK() } #endif // !defined(DISABLE_SOUND) + const UINT8 bAllowResize = (IsDlgButtonChecked(IDC_ALLOWRESIZE) != BST_UNCHECKED) ? 1 : 0; + if (xmiloscfg.thickframe != bAllowResize) + { + xmiloscfg.thickframe = bAllowResize; + nUpdateFlags |= SYS_UPDATEOSCFG; + } + ::sysmng_update(nUpdateFlags); CDlgProc::OnOK(); diff --git a/win9x/dialog/extclass.cpp b/win9x/dialog/extclass.cpp index 18aae73..ce6e323 100644 --- a/win9x/dialog/extclass.cpp +++ b/win9x/dialog/extclass.cpp @@ -110,6 +110,26 @@ void extclass_enablemenu(HWND hWnd, BOOL enable) { } } +void extclass_frametype(HWND hWnd, UINT8 thick) { + + RECT rect; + DWORD style; + + GetClientRect(hWnd, &rect); + style = GetWindowLong(hWnd, GWL_STYLE); + if (thick) { + style |= WS_THICKFRAME; + } + else { + style &= ~WS_THICKFRAME; + } + SetWindowLong(hWnd, GWL_STYLE, style); + SetWindowPos(hWnd, 0, 0, 0, 0, 0, + SWP_FRAMECHANGED | SWP_DRAWFRAME | + SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER); + extclass_setclientsize(hWnd, rect.right - rect.left, rect.bottom - rect.top); +} + HMENU extclass_gethmenu(HWND hWnd) { HMENU ret; @@ -121,3 +141,53 @@ HMENU extclass_gethmenu(HWND hWnd) { return(ret); } +void extclass_setclientsize(HWND hwnd, int width, int height) { + + RECT rectDisktop; + int scx; + int scy; + UINT cnt; + RECT rectWindow; + RECT rectClient; + int x, y, w, h; + + SystemParametersInfo(SPI_GETWORKAREA, 0, &rectDisktop, 0); + scx = GetSystemMetrics(SM_CXSCREEN); + scy = GetSystemMetrics(SM_CYSCREEN); + + cnt = 2; + do { + GetWindowRect(hwnd, &rectWindow); + GetClientRect(hwnd, &rectClient); + w = width + (rectWindow.right - rectWindow.left) + - (rectClient.right - rectClient.left); + h = height + (rectWindow.bottom - rectWindow.top) + - (rectClient.bottom - rectClient.top); + + x = rectWindow.left; + y = rectWindow.top; + if (scx < w) { + x = (scx - w) / 2; + } + else { + if ((x + w) > rectDisktop.right) { + x = rectDisktop.right - w; + } + if (x < rectDisktop.left) { + x = rectDisktop.left; + } + } + if (scy < h) { + y = (scy - h) / 2; + } + else { + if ((y + h) > rectDisktop.bottom) { + y = rectDisktop.bottom - h; + } + if (y < rectDisktop.top) { + y = rectDisktop.top; + } + } + MoveWindow(hwnd, x, y, w, h, TRUE); + } while(--cnt); +} diff --git a/win9x/dialog/extclass.h b/win9x/dialog/extclass.h index 75dae92..b71f8a6 100644 --- a/win9x/dialog/extclass.h +++ b/win9x/dialog/extclass.h @@ -22,5 +22,6 @@ enum { void extclass_wmcreate(HWND hWnd); void extclass_wmdestroy(HWND hWnd); void extclass_enablemenu(HWND hWnd, BOOL enable); +void extclass_frametype(HWND hWnd, UINT8 thick); HMENU extclass_gethmenu(HWND hWnd); - +void extclass_setclientsize(HWND hwnd, int width, int height); diff --git a/win9x/ini.cpp b/win9x/ini.cpp index 84ded13..61afec1 100644 --- a/win9x/ini.cpp +++ b/win9x/ini.cpp @@ -363,6 +363,7 @@ static const PFTBL s_IniItems[] = PFAND("clock_dn", PFRO_HEX32, &xmiloscfg.clockcolor2, 0xffffff), #endif /* defined(SUPPORT_DCLOCK) */ + PFVAL("thickfrm", PFTYPE_BOOL, &xmiloscfg.thickframe), PFVAL("fscrnbpp", PFRO_UINT8, &xmiloscfg.fscrnbpp), PFVAL("fscrnmod", PFTYPE_HEX8, &xmiloscfg.fscrnmod), }; diff --git a/win9x/resource.h b/win9x/resource.h index a06aa04..21c9e97 100644 --- a/win9x/resource.h +++ b/win9x/resource.h @@ -29,6 +29,7 @@ #define IDC_MAKE2D 1008 #define IDC_MAKE2HD 1009 #define IDC_XMILVER 1010 +#define IDC_ALLOWRESIZE 1011 #define IDC_FULLSCREEN_SAMEBPP 1101 #define IDC_FULLSCREEN_SAMERES 1102 #define IDC_FULLSCREEN_ZOOM 1103 diff --git a/win9x/scrnmng.cpp b/win9x/scrnmng.cpp index c17f136..6cd5efa 100644 --- a/win9x/scrnmng.cpp +++ b/win9x/scrnmng.cpp @@ -63,7 +63,7 @@ typedef struct { int width; int height; // int extend; -// int multiple; + int multiple; } SCRNSTAT; static DDRAW ddraw; @@ -208,7 +208,7 @@ static void renewalclientsize(BOOL winloc) { } } else { - multiple = 8; + multiple = scrnstat.multiple; scrnwidth = (width * multiple) >> 3; scrnheight = (height * multiple) >> 3; ddraw.rect.right = width; @@ -387,7 +387,7 @@ void scrnmng_initialize(void) { scrnstat.width = 640; scrnstat.height = 400; // scrnstat.extend = 1; -// scrnstat.multiple = 8; + scrnstat.multiple = 8; setwindowsize(hWndMain, 640, 400); } @@ -407,7 +407,7 @@ BRESULT scrnmng_create(UINT8 scrnmode) { winstyleex = GetWindowLong(hWndMain, GWL_EXSTYLE); if (scrnmode & SCRNMODE_FULLSCREEN) { scrnmng.flag = SCRNFLAG_FULLSCREEN; - winstyle &= ~(WS_CAPTION | WS_OVERLAPPED | WS_SYSMENU); + winstyle &= ~(WS_CAPTION | WS_SYSMENU | WS_THICKFRAME); winstyle |= WS_POPUP; winstyleex |= WS_EX_TOPMOST; ddraw.menudisp = FALSE; @@ -417,6 +417,9 @@ BRESULT scrnmng_create(UINT8 scrnmode) { else { // scrnmng.flag = 0; winstyle |= WS_SYSMENU; + if (xmiloscfg.thickframe) { + winstyle |= WS_THICKFRAME; + } winstyle |= WS_CAPTION; winstyle &= ~WS_POPUP; winstyleex &= ~WS_EX_TOPMOST; @@ -798,6 +801,23 @@ void scrnmng_update(void) { } +// ---- + +void scrnmng_setmultiple(int multiple) +{ + if (scrnstat.multiple != multiple) + { + scrnstat.multiple = multiple; + renewalclientsize(TRUE); + } +} + +int scrnmng_getmultiple(void) +{ + return scrnstat.multiple; +} + + // ---- #if defined(SUPPORT_DCLOCK) @@ -840,3 +860,113 @@ void scrnmng_dispclock(void) } #endif // defined(SUPPORT_DCLOCK) + +// ---- + +typedef struct { + int bx; + int by; + int cx; + int cy; + int mul; +} SCRNSIZING; + +static SCRNSIZING scrnsizing; + +enum { + SIZING_ADJUST = 12 +}; + +void scrnmng_entersizing(void) { + + RECT rectwindow; + RECT rectclient; + int cx; + int cy; + + GetWindowRect(hWndMain, &rectwindow); + GetClientRect(hWndMain, &rectclient); + scrnsizing.bx = (rectwindow.right - rectwindow.left) - + (rectclient.right - rectclient.left); + scrnsizing.by = (rectwindow.bottom - rectwindow.top) - + (rectclient.bottom - rectclient.top); + cx = min(scrnstat.width, ddraw.width); + cx = (cx + 7) >> 3; + cy = min(scrnstat.height, ddraw.height); + cy = (cy + 7) >> 3; + scrnsizing.cx = cx; + scrnsizing.cy = cy; + scrnsizing.mul = scrnstat.multiple; +} + +void scrnmng_sizing(UINT side, RECT *rect) { + + int width; + int height; + int mul; + + if ((side != WMSZ_TOP) && (side != WMSZ_BOTTOM)) { + width = rect->right - rect->left - scrnsizing.bx + SIZING_ADJUST; + width /= scrnsizing.cx; + } + else { + width = 16; + } + if ((side != WMSZ_LEFT) && (side != WMSZ_RIGHT)) { + height = rect->bottom - rect->top - scrnsizing.by + SIZING_ADJUST; + height /= scrnsizing.cy; + } + else { + height = 16; + } + mul = min(width, height); + if (mul <= 0) { + mul = 1; + } + else if (mul > 16) { + mul = 16; + } + width = scrnsizing.bx + (scrnsizing.cx * mul); + height = scrnsizing.by + (scrnsizing.cy * mul); + switch(side) { + case WMSZ_LEFT: + case WMSZ_TOPLEFT: + case WMSZ_BOTTOMLEFT: + rect->left = rect->right - width; + break; + + case WMSZ_RIGHT: + case WMSZ_TOP: + case WMSZ_TOPRIGHT: + case WMSZ_BOTTOM: + case WMSZ_BOTTOMRIGHT: + default: + rect->right = rect->left + width; + break; + } + + switch(side) { + case WMSZ_TOP: + case WMSZ_TOPLEFT: + case WMSZ_TOPRIGHT: + rect->top = rect->bottom - height; + break; + + case WMSZ_LEFT: + case WMSZ_RIGHT: + case WMSZ_BOTTOM: + case WMSZ_BOTTOMLEFT: + case WMSZ_BOTTOMRIGHT: + default: + rect->bottom = rect->top + height; + break; + } + scrnsizing.mul = mul; +} + +void scrnmng_exitsizing(void) +{ + scrnmng_setmultiple(scrnsizing.mul); + InvalidateRect(hWndMain, NULL, TRUE); // ugh +} + diff --git a/win9x/scrnmng.h b/win9x/scrnmng.h index 3b0ad25..fe4f2a1 100644 --- a/win9x/scrnmng.h +++ b/win9x/scrnmng.h @@ -76,15 +76,22 @@ RGB16 scrnmng_makepal16(RGB32 pal32); // pal_get16pal // ---- for windows +void scrnmng_setmultiple(int multiple); +int scrnmng_getmultiple(void); + void scrnmng_initialize(void); // ddraws_initwindowsize BRESULT scrnmng_create(UINT8 scrnmode); // ddraws_InitDirectDraw void scrnmng_destroy(void); // ddraws_TermDirectDraw -#if defined(SUPPORT_DCLOCK) -void scrnmng_dispclock(void); // ddraws_dispclock -#endif // defined(SUPPORT_DCLOCK) void scrnmng_querypalette(void); // ddraws_palette void scrnmng_fullscrnmenu(int y); void scrnmng_topwinui(void); // ddraws_topwinui void scrnmng_clearwinui(void); // ddraws_clearwinui +void scrnmng_entersizing(void); +void scrnmng_sizing(UINT side, RECT *rect); +void scrnmng_exitsizing(void); + +#if defined(SUPPORT_DCLOCK) +void scrnmng_dispclock(void); +#endif // defined(SUPPORT_DCLOCK) diff --git a/win9x/xmil.cpp b/win9x/xmil.cpp index 0bcc456..e3f09c4 100644 --- a/win9x/xmil.cpp +++ b/win9x/xmil.cpp @@ -57,7 +57,7 @@ static const OEMCHAR szClassName[] = OEMTEXT("Xmil-MainWindow"); #if defined(SUPPORT_DCLOCK) 0, 0, 0xffffff, 0xffbf6a, #endif // defined(SUPPORT_DCLOCK) - 0, + 0, 0, FSCRNMOD_SAMEBPP | FSCRNMOD_SAMERES | FSCRNMOD_ASPECTFIX8 }; @@ -272,6 +272,13 @@ static void xmilcmd(HWND hWnd, UINT cmd) { case IDM_CONFIG: winuienter(); CConfigDlg::Config(hWnd); + if (!scrnmng_isfullscreen()) { + UINT8 thick; + thick = (GetWindowLong(hWnd, GWL_STYLE) & WS_THICKFRAME) ? 1 : 0; + if (thick != xmiloscfg.thickframe) { + extclass_frametype(hWnd, xmiloscfg.thickframe); + } + } winuileave(); break; @@ -714,11 +721,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) { soundmng_disable(SNDPROC_MAIN); mousemng_disable(MOUSEPROC_WINUI); s_wndloc.Start(); - break; - - case WM_EXITSIZEMOVE: - mousemng_enable(MOUSEPROC_WINUI); - soundmng_enable(SNDPROC_MAIN); + scrnmng_entersizing(); break; case WM_MOVING: @@ -728,6 +731,16 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) { } break; + case WM_SIZING: + scrnmng_sizing((UINT)wParam, (RECT *)lParam); + break; + + case WM_EXITSIZEMOVE: + scrnmng_exitsizing(); + mousemng_enable(MOUSEPROC_WINUI); + soundmng_enable(SNDPROC_MAIN); + break; + case WM_KEYDOWN: if (wParam == VK_F12) { mousemng_toggle(MOUSEPROC_SYSTEM); @@ -971,12 +984,13 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInst, mousemng_initialize(); + DWORD style = WS_OVERLAPPED | WS_SYSMENU | WS_CAPTION | WS_MINIMIZEBOX; + if (xmiloscfg.thickframe) { + style |= WS_THICKFRAME; + } hWnd = CreateWindowEx(0, - szClassName, szProgName, - WS_OVERLAPPED | WS_SYSMENU | WS_CAPTION | - WS_MINIMIZEBOX, - xmiloscfg.winx, xmiloscfg.winy, - SURFACE_WIDTH, SURFACE_HEIGHT, + szClassName, szProgName, style, + xmiloscfg.winx, xmiloscfg.winy, SURFACE_WIDTH, SURFACE_HEIGHT, NULL, NULL, hInstance, NULL); hWndMain = hWnd; scrnmng_initialize(); diff --git a/win9x/xmil.h b/win9x/xmil.h index c715c8a..d716269 100644 --- a/win9x/xmil.h +++ b/win9x/xmil.h @@ -29,6 +29,7 @@ typedef struct { UINT32 clockcolor2; #endif // defined(SUPPORT_DCLOCK) + UINT8 thickframe; UINT8 fscrnbpp; UINT8 fscrnmod; } XMILOSCFG; diff --git a/win9x/xmil.rc b/win9x/xmil.rc index ca2116f..fd30e7e 100644 --- a/win9x/xmil.rc +++ b/win9x/xmil.rc @@ -225,7 +225,7 @@ END // Dialog // -IDD_CONFIG DIALOG DISCARDABLE 0, 0, 194, 80 +IDD_CONFIG DIALOG DISCARDABLE 0, 0, 194, 100 STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU CAPTION "Configure" FONT 9, "‚l‚r ‚oƒSƒVƒbƒN" @@ -240,6 +240,8 @@ BEGIN LTEXT "ms",IDC_STATIC,116,37,10,8 LTEXT "Seek Volume",IDC_STATIC,16,52,38,8 EDITTEXT IDC_SEEKVOL,80,50,20,12 + CONTROL "Allow resize",IDC_ALLOWRESIZE,"Button",BS_AUTOCHECKBOX | + WS_TABSTOP,8,80,162,10 DEFPUSHBUTTON "&OK",IDOK,144,12,44,14 PUSHBUTTON "Cancel",IDCANCEL,144,30,44,14 END