X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/655076c7b07c69ea8373098859d9b14adfc8e0a4..5d483828d77426eed11fa19c3f2f318383a118dc:/src/msw/window.cpp diff --git a/src/msw/window.cpp b/src/msw/window.cpp index f58179b4c3..67b1e4d321 100644 --- a/src/msw/window.cpp +++ b/src/msw/window.cpp @@ -46,6 +46,7 @@ #include "wx/listbox.h" #include "wx/button.h" #include "wx/msgdlg.h" + #include "wx/settings.h" #include #endif @@ -107,6 +108,19 @@ #define SIF_TRACKPOS 16 #endif +#if wxUSE_MOUSEWHEEL + #ifndef WM_MOUSEWHEEL + #define WM_MOUSEWHEEL 0x020A + #endif + #ifndef WHEEL_DELTA + #define WHEEL_DELTA 120 + #endif + #ifndef SPI_GETWHEELSCROLLLINES + #define SPI_GETWHEELSCROLLLINES 104 + #endif +#endif + + // --------------------------------------------------------------------------- // global variables // --------------------------------------------------------------------------- @@ -166,7 +180,7 @@ END_EVENT_TABLE() // Find an item given the MS Windows id wxWindow *wxWindow::FindItem(long id) const { - wxControl *item = wxDynamicCast(this, wxControl); + wxControl *item = wxDynamicThisCast(this, wxControl); if ( item ) { // i it we or one of our "internal" children? @@ -342,12 +356,10 @@ bool wxWindow::Create(wxWindow *parent, wxWindowID id, DLGC_WANTTAB | DLGC_WANTMESSAGE; } - MSWCreate(m_windowId, parent, wxCanvasClassName, this, NULL, - pos.x, pos.y, - WidthDefault(size.x), HeightDefault(size.y), - msflags, NULL, exStyle); - - return TRUE; + return MSWCreate(m_windowId, parent, wxCanvasClassName, this, NULL, + pos.x, pos.y, + WidthDefault(size.x), HeightDefault(size.y), + msflags, NULL, exStyle); } // --------------------------------------------------------------------------- @@ -977,7 +989,7 @@ void wxWindow::SetupColours() SetBackgroundColour(GetParent()->GetBackgroundColour()); } -void wxWindow::OnIdle(wxIdleEvent& event) +void wxWindow::OnIdle(wxIdleEvent& WXUNUSED(event)) { // Check if we need to send a LEAVE event if ( m_mouseInWindow ) @@ -1003,7 +1015,7 @@ void wxWindow::OnIdle(wxIdleEvent& event) state |= MK_MBUTTON; if ( GetKeyState( VK_RBUTTON ) ) state |= MK_RBUTTON; - + wxMouseEvent event(wxEVT_LEAVE_WINDOW); InitMouseEvent(event, pt.x, pt.y, state); @@ -1015,7 +1027,7 @@ void wxWindow::OnIdle(wxIdleEvent& event) } // Set this window to be the child of 'parent'. -bool wxWindow::Reparent(wxWindow *parent) +bool wxWindow::Reparent(wxWindowBase *parent) { if ( !wxWindowBase::Reparent(parent) ) return FALSE; @@ -1581,7 +1593,7 @@ bool wxWindow::MSWProcessMessage(WXMSG* pMsg) } else { - wxPanel *panel = wxDynamicCast(this, wxPanel); + wxPanel *panel = wxDynamicThisCast(this, wxPanel); wxButton *btn = NULL; if ( panel ) { @@ -1911,6 +1923,12 @@ long wxWindow::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam) wParam); break; +#if wxUSE_MOUSEWHEEL + case WM_MOUSEWHEEL: + processed = HandleMouseWheel(wParam, lParam); + break; +#endif + case WM_LBUTTONDOWN: // set focus to this window if (AcceptsFocus()) @@ -2229,7 +2247,7 @@ long wxWindow::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam) // Dialog window proc LONG APIENTRY _EXPORT -wxDlgProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) +wxDlgProc(HWND WXUNUSED(hWnd), UINT message, WPARAM WXUNUSED(wParam), LPARAM WXUNUSED(lParam)) { if ( message == WM_INITDIALOG ) { @@ -2334,7 +2352,7 @@ void wxWindow::MSWDetachWindowMenu() bool wxWindow::MSWCreate(int id, wxWindow *parent, const wxChar *wclass, - wxWindow *wx_win, + wxWindow *WXUNUSED(wx_win), const wxChar *title, int x, int y, @@ -2512,6 +2530,8 @@ bool wxWindow::MSWCreate(int id, wxAssociateWinWithHandle((HWND) m_hWnd, this); + SetFont(wxSystemSettings::GetSystemFont(wxSYS_DEFAULT_GUI_FONT)); + return TRUE; } @@ -2618,7 +2638,7 @@ bool wxWindow::HandleEndSession(bool endSession, long logOff) // window creation/destruction // --------------------------------------------------------------------------- -bool wxWindow::HandleCreate(WXLPCREATESTRUCT cs, bool *mayCreate) +bool wxWindow::HandleCreate(WXLPCREATESTRUCT WXUNUSED(cs), bool *mayCreate) { // TODO: should generate this event from WM_NCCREATE wxWindowCreateEvent event(this); @@ -2728,7 +2748,7 @@ bool wxWindow::HandleKillFocus(WXHWND WXUNUSED(hwnd)) // miscellaneous // --------------------------------------------------------------------------- -bool wxWindow::HandleShow(bool show, int status) +bool wxWindow::HandleShow(bool show, int WXUNUSED(status)) { wxShowEvent event(GetId(), show); event.m_eventObject = this; @@ -2779,7 +2799,7 @@ bool wxWindow::HandleDropFiles(WXWPARAM wParam) return rc; } -bool wxWindow::HandleSetCursor(WXHWND hWnd, +bool wxWindow::HandleSetCursor(WXHWND WXUNUSED(hWnd), short nHitTest, int WXUNUSED(mouseMsg)) { @@ -2968,12 +2988,12 @@ bool wxWindow::HandleCtlColor(WXHBRUSH *brush, } // Define for each class of dialog and control -WXHBRUSH wxWindow::OnCtlColor(WXHDC hDC, - WXHWND hWnd, - WXUINT nCtlColor, - WXUINT message, - WXWPARAM wParam, - WXLPARAM lParam) +WXHBRUSH wxWindow::OnCtlColor(WXHDC WXUNUSED(hDC), + WXHWND WXUNUSED(hWnd), + WXUINT WXUNUSED(nCtlColor), + WXUINT WXUNUSED(message), + WXWPARAM WXUNUSED(wParam), + WXLPARAM WXUNUSED(lParam)) { return (WXHBRUSH)0; } @@ -3249,7 +3269,7 @@ bool wxWindow::HandleCommand(WXWORD id, WXWORD cmd, WXHWND control) return FALSE; } -bool wxWindow::HandleSysCommand(WXWPARAM wParam, WXLPARAM lParam) +bool wxWindow::HandleSysCommand(WXWPARAM wParam, WXLPARAM WXUNUSED(lParam)) { // 4 bits are reserved switch ( wParam & 0xFFFFFFF0 ) @@ -3346,6 +3366,46 @@ bool wxWindow::HandleMouseMove(int x, int y, WXUINT flags) return HandleMouseEvent(WM_MOUSEMOVE, x, y, flags); } + +bool wxWindow::HandleMouseWheel(WXWPARAM wParam, WXLPARAM lParam) +{ +#if wxUSE_MOUSEWHEEL + wxMouseEvent event(wxEVT_MOUSEWHEEL); + InitMouseEvent(event, + GET_X_LPARAM(lParam), + GET_Y_LPARAM(lParam), + LOWORD(wParam)); + event.m_wheelRotation = (short)HIWORD(wParam); + event.m_wheelDelta = WHEEL_DELTA; + +#ifdef __WIN32__ + static int s_linesPerRotation = -1; + if ( s_linesPerRotation == -1 ) + { + if ( !::SystemParametersInfo(SPI_GETWHEELSCROLLLINES, 0, + &s_linesPerRotation, 0)) + { + // this is not supposed to happen + wxLogLastError(_T("SystemParametersInfo(GETWHEELSCROLLLINES)")); + + // the default is 3, so use it if SystemParametersInfo() failed + s_linesPerRotation = 3; + } + } +#else // Win16 + // no SystemParametersInfo() under Win16 + static const int s_linesPerRotation = 3; +#endif + + event.m_linesPerAction = s_linesPerRotation; + return GetEventHandler()->ProcessEvent(event); + +#else + return FALSE; +#endif +} + + // --------------------------------------------------------------------------- // keyboard handling // --------------------------------------------------------------------------- @@ -3382,7 +3442,7 @@ wxKeyEvent wxWindow::CreateKeyEvent(wxEventType evType, // isASCII is TRUE only when we're called from WM_CHAR handler and not from // WM_KEYDOWN one -bool wxWindow::HandleChar(WXWORD wParam, WXLPARAM lParam, bool isASCII) +bool wxWindow::HandleChar(WXWPARAM wParam, WXLPARAM lParam, bool isASCII) { bool ctrlDown = FALSE; @@ -3435,7 +3495,7 @@ bool wxWindow::HandleChar(WXWORD wParam, WXLPARAM lParam, bool isASCII) return FALSE; } -bool wxWindow::HandleKeyDown(WXWORD wParam, WXLPARAM lParam) +bool wxWindow::HandleKeyDown(WXWPARAM wParam, WXLPARAM lParam) { int id = wxCharCodeMSWToWX(wParam); @@ -3457,7 +3517,7 @@ bool wxWindow::HandleKeyDown(WXWORD wParam, WXLPARAM lParam) return FALSE; } -bool wxWindow::HandleKeyUp(WXWORD wParam, WXLPARAM lParam) +bool wxWindow::HandleKeyUp(WXWPARAM wParam, WXLPARAM lParam) { int id = wxCharCodeMSWToWX(wParam); @@ -3915,9 +3975,9 @@ void wxSetKeyboardHook(bool doIt) else { UnhookWindowsHookEx(wxTheKeyboardHook); - // avoids mingw warning about statement with no effect (FreeProcInstance - // doesn't do anything under Win32) -#ifndef __GNUC__ + // avoids warning about statement with no effect (FreeProcInstance + // doesn't do anything under Win32) +#if !defined(WIN32) && !defined(_WIN32) && !defined(__WIN32__) && !defined(__NT__) && !defined(__GNUWIN32__) FreeProcInstance(wxTheKeyboardHookProc); #endif } @@ -4097,6 +4157,7 @@ const char *wxGetMessageName(int message) case 0x0207: return "WM_MBUTTONDOWN"; case 0x0208: return "WM_MBUTTONUP"; case 0x0209: return "WM_MBUTTONDBLCLK"; + case 0x020A: return "WM_MOUSEWHEEL"; case 0x0210: return "WM_PARENTNOTIFY"; case 0x0211: return "WM_ENTERMENULOOP"; case 0x0212: return "WM_EXITMENULOOP"; @@ -4438,7 +4499,7 @@ static TEXTMETRIC wxGetTextMetrics(const wxWindow *win) // Find the wxWindow at the current mouse position, returning the mouse // position. -wxWindow* wxFindWindowAtPointer(wxPoint& pt) +wxWindow* wxFindWindowAtPointer(wxPoint& WXUNUSED(pt)) { return wxFindWindowAtPoint(wxGetMousePosition()); }