From 9a4457e4fff086007ffe5e0f274ec0baf4fe8335 Mon Sep 17 00:00:00 2001 From: luigi__ Date: Wed, 23 Dec 2009 00:11:50 +0000 Subject: [PATCH] Add some rotate buttons to the toolbar, fix the black/random line under the toolbar and remove useless code. --- desmume/src/windows/CWindow.cpp | 54 ++----- desmume/src/windows/CWindow.h | 23 +-- .../src/windows/bitmaps/IDB_FRAMEADVANCE.bmp | Bin 822 -> 822 bytes desmume/src/windows/bitmaps/IDB_ROTATECCW.bmp | Bin 0 -> 822 bytes desmume/src/windows/bitmaps/IDB_ROTATECW.bmp | Bin 0 -> 822 bytes desmume/src/windows/main.cpp | 148 +++++++++++++----- desmume/src/windows/resource.h | 6 +- desmume/src/windows/resources.rc | Bin 891018 -> 891328 bytes 8 files changed, 130 insertions(+), 101 deletions(-) create mode 100644 desmume/src/windows/bitmaps/IDB_ROTATECCW.bmp create mode 100644 desmume/src/windows/bitmaps/IDB_ROTATECW.bmp diff --git a/desmume/src/windows/CWindow.cpp b/desmume/src/windows/CWindow.cpp index 906ccf108..226e4f4c3 100644 --- a/desmume/src/windows/CWindow.cpp +++ b/desmume/src/windows/CWindow.cpp @@ -326,33 +326,6 @@ void RefreshAllToolWindows() } } -//----------------------------------------------------------------------------- -// The Toolkit - Tooltip API wrapper -//----------------------------------------------------------------------------- - -CToolTip::CToolTip(HWND hParent) -{ - hWnd = CreateWindow(TOOLTIPS_CLASS, NULL, WS_POPUP | TTS_NOPREFIX, - CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, - hParent, NULL, hAppInst, NULL); -} - -void CToolTip::AddToolTip(HWND hCtl, int uID, CRect rcRect, char* text) -{ - TOOLINFO ti; - - memset(&ti, 0, sizeof(TOOLINFO)); - ti.cbSize = sizeof(TOOLINFO); - ti.uFlags = TTF_SUBCLASS; - ti.hwnd = hCtl; - ti.uId = uID; - ti.rect = rcRect.ToMSRect(); - printf("%i %i %i %i\n", rcRect.ToMSRect().top, ti.rect.left, ti.rect.bottom, ti.rect.right); - ti.lpszText = text; - - SendMessage(hWnd, TTM_ADDTOOL, 0, (LPARAM)&ti); -} - //----------------------------------------------------------------------------- // The Toolkit - Toolbar API wrapper //----------------------------------------------------------------------------- @@ -362,9 +335,9 @@ CToolBar::CToolBar(HWND hParent) { // Create the toolbar // Note: dropdown buttons look like crap without TBSTYLE_FLAT - hWnd = CreateWindowEx(0, TOOLBARCLASSNAME, - NULL, WS_CHILD | WS_VISIBLE | WS_BORDER | TBSTYLE_FLAT, 0, 0, 0, 0, - hParent, NULL, hAppInst, NULL); + hWnd = CreateWindowEx(0, TOOLBARCLASSNAME, NULL, + WS_CHILD | WS_VISIBLE | WS_BORDER | TBSTYLE_FLAT | TBSTYLE_TOOLTIPS, + 0, 0, 0, 0, hParent, NULL, hAppInst, NULL); // Send it a few messages to finish setting it up SendMessage(hWnd, TB_BUTTONSTRUCTSIZE, sizeof(TBBUTTON), 0); @@ -403,6 +376,12 @@ void CToolBar::Show(bool bShow) void CToolBar::OnSize() { + // Not-fully-working wraparound handling code + // the toolbar behaves weirdly when it comes to separators + // TODO: figure out why. + // Note: right now this code is useless, but it may be useful + // if we use more toolbars +#if 0 RECT rc; int parentwidth; @@ -419,31 +398,32 @@ void CToolBar::OnSize() SendMessage(hWnd, TB_GETITEMRECT, i, (LPARAM)&rc); curwidth += (rc.right - rc.left); - if (i > 0) + if (i > 1) { TBBUTTON btn; TBBUTTONINFO btninfo; + int cmdid; - // Retrieve the command ID of the button just behind the current one - // if it's a separator, then try the button behind it SendMessage(hWnd, TB_GETBUTTON, i-1, (LPARAM)&btn); if (btn.idCommand == -1) SendMessage(hWnd, TB_GETBUTTON, i-2, (LPARAM)&btn); + cmdid = btn.idCommand; + // Add/remove the TBSTATE_WRAP style if needed btninfo.cbSize = sizeof(TBBUTTONINFO); btninfo.dwMask = TBIF_STATE; - SendMessage(hWnd, TB_GETBUTTONINFO, btn.idCommand, (LPARAM)&btninfo); + SendMessage(hWnd, TB_GETBUTTONINFO, cmdid, (LPARAM)&btninfo); btninfo.dwMask = TBIF_STATE; if (curwidth > parentwidth) btninfo.fsState |= TBSTATE_WRAP; else btninfo.fsState &= ~TBSTATE_WRAP; - SendMessage(hWnd, TB_SETBUTTONINFO, btn.idCommand, (LPARAM)&btninfo); + SendMessage(hWnd, TB_SETBUTTONINFO, cmdid, (LPARAM)&btninfo); if (curwidth > parentwidth) curwidth = 0; } } - +#endif SetWindowPos(hWnd, NULL, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, SWP_NOZORDER | SWP_NOMOVE); @@ -551,7 +531,7 @@ int CToolBar::GetHeight() if (hidden) return 0; RECT rc; GetWindowRect(hWnd, &rc); - return rc.bottom - rc.top; + return rc.bottom - rc.top - 1; } diff --git a/desmume/src/windows/CWindow.h b/desmume/src/windows/CWindow.h index 1167510bb..a2e4da1b6 100644 --- a/desmume/src/windows/CWindow.h +++ b/desmume/src/windows/CWindow.h @@ -173,24 +173,6 @@ void CloseAllToolWindows(); // Called once per frame when the emu is running. void RefreshAllToolWindows(); -//----------------------------------------------------------------------------- -// The Toolkit - Tooltip API wrapper -//----------------------------------------------------------------------------- - -class CToolTip -{ -public: - CToolTip(HWND hParent); - ~CToolTip() {} - - HWND GetHWnd() { return hWnd; } - - void AddToolTip(HWND hCtl, int uID, CRect rcRect, char* text); - -private: - HWND hWnd; -}; - //----------------------------------------------------------------------------- // The Toolkit - Toolbar API wrapper //----------------------------------------------------------------------------- @@ -217,10 +199,9 @@ public: SendMessage(hWnd, TB_CHECKBUTTON, uID, bCheck ? TRUE:FALSE); } void ChangeButtonBitmap(int uID, int uBitmapID); - void EnableButtonDropdown(int uID, bool bDropdown); - - void SetToolTip(CToolTip tt); + void ChangeButtonID(int uIndex, int uNewID) { + SendMessage(hWnd, TB_SETCMDID, uIndex, MAKELPARAM(uNewID, 0)); } int GetHeight(); diff --git a/desmume/src/windows/bitmaps/IDB_FRAMEADVANCE.bmp b/desmume/src/windows/bitmaps/IDB_FRAMEADVANCE.bmp index 9d71446872d75b63517ebfdda0da9fb78a1ac9c5..983bf834a92f040b5f153c34053772f8a1130f74 100644 GIT binary patch delta 146 zcmdnSwvBBR{S|NefKpGI@YZ*p%Y9w>o}DVbsJxG4WvS?fF4)+klKi Ptyz~>%miBK3ep1rmrX>m delta 162 zcmdnSwvBBT2cqvE-t4Z3I5VsL_xEoT8&&u}J$tw%N$*IV>z16rS69zZ z+>*xp{^9M(vWzB7|Nc!5W;9^_0OYnY_A-Bc{d}?*lRESLL)#}iFljM=dHHm5E|Z7N z$0zqUr8w@bj^9xj_2JQ7h&9OM%3$s7`9bd=+<^%G{Pg}%Yu4ozGynenHTffxD*&07 BUu^&Y diff --git a/desmume/src/windows/bitmaps/IDB_ROTATECCW.bmp b/desmume/src/windows/bitmaps/IDB_ROTATECCW.bmp new file mode 100644 index 0000000000000000000000000000000000000000..3d2cd593dd9381c883784186ffcc9d104426b25d GIT binary patch literal 822 zcmZ?rHDhJ~12Z700mK4O%*Y@C7H0s;AK`;whyVk_e}?~*qZKPw%%49WV$QMSJA5Bip_0C$W)l9Z(sWeIBQonrp@;P(nKx9K3T@AJv+3d4W>r{lR-?L{AP{EQVOBO9! zv~JzH%*@Q>H~ ztY5z#C}NvyW_#Sz{amo_bOX40AY=K?MR8NYAtD<$Z(O!w8HDZFZsU3(((h`5?ramd z`q~whMr$10@2AoGiMGi^EI1Q?T@-z9dW$oIvYu2s-iU7%-J9om>YfaGey_(>DDaNJ~>i&(JH!fYi6rvz*YWV!kv*3z> z4C@|i-#eLs*V1hc2M0{@TYh43L0?W*N9xKGOKlo0TyG|uZgweLkPFu`eft#a{UMRh zt3vJ;dfv>m-WzPQFUV$pkmU}4`xDW@PfEjIRRI+gEiQy>iJlYddL<+NeS7Tl#+X;l zF|VO0>P17?owD#-rAfbf^;X!!)dLw>OL8qX`T5-~347iU22}Q>(IEnableButton(IDC_ROTATE90, true); + MainWindowToolbar->EnableButton(IDC_ROTATE270, true); + if (video.layout_old == 1) { newwidth = oldwidth / 2; newheight = oldheight * 2; } + else if (video.layout_old == 2) + { + newwidth = oldwidth; + newheight = oldheight * 2; + } else - if (video.layout_old == 2) - { - newwidth = oldwidth; - newheight = oldheight * 2; - } - else - { - newwidth = oldwidth; - newheight = oldheight; - } + { + newwidth = oldwidth; + newheight = oldheight; + } MainWindow->checkMenu(ID_LCDS_VERTICAL, true); MainWindow->checkMenu(ID_LCDS_HORIZONTAL, false); MainWindow->checkMenu(ID_LCDS_ONE, false); @@ -1170,6 +1172,11 @@ void doLCDsLayout() DesEnableMenuItem(mainMenu, IDM_SCREENSEP_COLORGRAY, false); DesEnableMenuItem(mainMenu, IDM_SCREENSEP_COLORBLACK, false); + // As rotation was reset to 0, the button IDs were reset to + // IDC_ROTATE90 and IDC_ROTATE270. + MainWindowToolbar->EnableButton(IDC_ROTATE90, false); + MainWindowToolbar->EnableButton(IDC_ROTATE270, false); + if (video.layout == 1) { if (video.layout_old == 0) @@ -1177,46 +1184,43 @@ void doLCDsLayout() newwidth = oldwidth * 2; newheight = oldheight / 2; } + else if (video.layout_old == 2) + { + newwidth = oldwidth * 2; + newheight = oldheight; + } else - if (video.layout_old == 2) - { - newwidth = oldwidth * 2; - newheight = oldheight; - } - else - { - newwidth = oldwidth; - newheight = oldheight; - } + { + newwidth = oldwidth; + newheight = oldheight; + } MainWindow->checkMenu(ID_LCDS_HORIZONTAL, false); MainWindow->checkMenu(ID_LCDS_VERTICAL, true); MainWindow->checkMenu(ID_LCDS_ONE, false); } - else - if (video.layout == 2) + else if (video.layout == 2) + { + if (video.layout_old == 0) { - if (video.layout_old == 0) - { - newwidth = oldwidth; - newheight = oldheight / 2; - } - else - if (video.layout_old == 1) - { - newwidth = oldwidth / 2; - newheight = oldheight; - } - else - { - newwidth = oldwidth; - newheight = oldheight; - } - MainWindow->checkMenu(ID_LCDS_HORIZONTAL, false); - MainWindow->checkMenu(ID_LCDS_VERTICAL, false); - MainWindow->checkMenu(ID_LCDS_ONE, true); + newwidth = oldwidth; + newheight = oldheight / 2; + } + else if (video.layout_old == 1) + { + newwidth = oldwidth / 2; + newheight = oldheight; } else - return; + { + newwidth = oldwidth; + newheight = oldheight; + } + MainWindow->checkMenu(ID_LCDS_HORIZONTAL, false); + MainWindow->checkMenu(ID_LCDS_VERTICAL, false); + MainWindow->checkMenu(ID_LCDS_ONE, true); + } + else + return; } video.layout_old = video.layout; @@ -2986,6 +2990,18 @@ void SetRotate(HWND hwnd, int rot, bool user) MainWindow->setClientSize(newwidth, newheight); + int cwid, ccwid; + switch (rot) + { + case 0: cwid = IDC_ROTATE90; ccwid = IDC_ROTATE270; break; + case 90: cwid = IDC_ROTATE180; ccwid = IDC_ROTATE0; break; + case 180: cwid = IDC_ROTATE270; ccwid = IDC_ROTATE90; break; + case 270: cwid = IDC_ROTATE0; ccwid = IDC_ROTATE180; break; + } + + MainWindowToolbar->ChangeButtonID(6, cwid); + MainWindowToolbar->ChangeButtonID(7, ccwid); + /* Recreate the DirectDraw back buffer */ if (lpBackSurface!=NULL) { @@ -3786,6 +3802,20 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM MainWindowToolbar->AppendButton(IDM_PAUSE, IDB_PLAY, 0, false); MainWindowToolbar->AppendButton(IDM_CLOSEROM, IDB_STOP, 0, false); MainWindowToolbar->AppendButton(IDM_RESET, IDB_RESET, 0, false); + MainWindowToolbar->AppendSeparator(); + + int cwid, ccwid; + DWORD rotstate = (video.layout == 0) ? TBSTATE_ENABLED : 0; + switch (video.rotation) + { + case 0: cwid = IDC_ROTATE90; ccwid = IDC_ROTATE270; break; + case 90: cwid = IDC_ROTATE180; ccwid = IDC_ROTATE0; break; + case 180: cwid = IDC_ROTATE270; ccwid = IDC_ROTATE90; break; + case 270: cwid = IDC_ROTATE0; ccwid = IDC_ROTATE180; break; + } + + MainWindowToolbar->AppendButton(cwid, IDB_ROTATECW, rotstate, false); + MainWindowToolbar->AppendButton(ccwid, IDB_ROTATECCW, rotstate, false); bool showtb = GetPrivateProfileBool("Display", "Show Toolbar", true, IniName); MainWindowToolbar->Show(showtb); @@ -5283,6 +5313,40 @@ DOKEYDOWN: } } return 0; + + case TTN_NEEDTEXT: + { + TOOLTIPTEXT* ttt = (TOOLTIPTEXT*)lParam; + ttt->hinst = hAppInst; + + switch (ttt->hdr.idFrom) + { + case IDM_OPEN: + if (RecentRoms.empty()) ttt->lpszText = "Open a ROM"; + else ttt->lpszText = "Open a ROM\nClick the arrow to open a recent ROM"; break; + + case IDM_PAUSE: + if (paused) ttt->lpszText = "Resume emulation"; + else ttt->lpszText = "Pause emulation"; break; + + case IDM_CLOSEROM: ttt->lpszText = "Stop emulation"; break; + case IDM_RESET: ttt->lpszText = "Reset emulation"; break; + + case IDC_ROTATE0: + if (video.rotation == 90) ttt->lpszText = "Rotate CCW"; + else if (video.rotation == 270) ttt->lpszText = "Rotate CW"; break; + case IDC_ROTATE90: + if (video.rotation == 180) ttt->lpszText = "Rotate CCW"; + else if (video.rotation == 0) ttt->lpszText = "Rotate CW"; break; + case IDC_ROTATE180: + if (video.rotation == 270) ttt->lpszText = "Rotate CCW"; + else if (video.rotation == 90) ttt->lpszText = "Rotate CW"; break; + case IDC_ROTATE270: + if (video.rotation == 0) ttt->lpszText = "Rotate CCW"; + else if (video.rotation == 180) ttt->lpszText = "Rotate CW"; break; + } + } + return 0; } } return 0; diff --git a/desmume/src/windows/resource.h b/desmume/src/windows/resource.h index 611caf41f..69624539b 100644 --- a/desmume/src/windows/resource.h +++ b/desmume/src/windows/resource.h @@ -34,7 +34,10 @@ #define IDM_PAL 117 #define IDM_TILE 118 #define IDM_MAP 119 +#define IDB_ROTATECCW 119 #define IDM_MBG0 120 +#define IDB_BITMAP2 120 +#define IDB_ROTATECW 120 #define IDM_MBG1 121 #define IDM_MBG2 122 #define IDM_MBG3 123 @@ -756,6 +759,7 @@ #define IDC_LUASCRIPT_RESERVE_END 58099 #define IDD_LUARECENT_RESERVE_START 58100 #define IDD_LUARECENT_RESERVE_END 58199 +#define IDC_FRAMEADVANCE 58200 #define IDC_LABEL_HK1 60001 #define IDC_LABEL_HK2 60002 #define IDC_LABEL_HK3 60003 @@ -807,7 +811,7 @@ // #ifdef APSTUDIO_INVOKED #ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_NEXT_RESOURCE_VALUE 118 +#define _APS_NEXT_RESOURCE_VALUE 121 #define _APS_NEXT_COMMAND_VALUE 40073 #define _APS_NEXT_CONTROL_VALUE 1022 #define _APS_NEXT_SYMED_VALUE 101 diff --git a/desmume/src/windows/resources.rc b/desmume/src/windows/resources.rc index 47403fc5ca39875fb2ca8f509b23d6fde7926670..9b03cee36bc32bc70b0f1742a18987e8d9c7044b 100644 GIT binary patch delta 152 zcmeC$Xm((;SwjnB3sVbo3rh=Y3tJ0&3r7p*7Os>_)9o&Daq;^zgfKV)u`7c!5Qa}z zyv!&*{mun0AHg67bUFQtT#~%Vg5lFI`Y}m@l}n;34`Up2*H2-(Gi# O3y8V5*InY_IR*f(87ZRx delta 43 ycmX@G*{o}$SwjnB3sVbo3rh=Y3tJ0&3r7p*7Os>_?Xxa(0WtUXS(ka#jsXB}i4l1K