X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/42e69d6b435a4dd5415caf3750db62cf45b6f373..0b4c331f91428fa71510b2492345ec6d6a999c35:/src/msw/window.cpp diff --git a/src/msw/window.cpp b/src/msw/window.cpp index de806ac65f..8da3bb78c9 100644 --- a/src/msw/window.cpp +++ b/src/msw/window.cpp @@ -29,6 +29,9 @@ #endif #ifndef WX_PRECOMP + #include + #include "wx/msw/winundef.h" + #include "wx/accel.h" #include "wx/setup.h" #include "wx/menu.h" #include "wx/dc.h" @@ -51,20 +54,26 @@ #endif #if wxUSE_DRAG_AND_DROP + #include "wx/dataobj.h" #include "wx/msw/ole/droptgt.h" #endif #include "wx/menuitem.h" #include "wx/log.h" +#include "wx/msw/private.h" + #if wxUSE_TOOLTIPS #include "wx/tooltip.h" #endif +#if wxUSE_CARET + #include "wx/caret.h" +#endif // wxUSE_CARET + #include "wx/intl.h" #include "wx/log.h" -#include "wx/msw/private.h" #include "wx/textctrl.h" @@ -89,16 +98,14 @@ #endif #endif -#include "wx/msw/winundef.h" - // --------------------------------------------------------------------------- // macros // --------------------------------------------------------------------------- // standard macros missing from some compilers headers #ifndef GET_X_LPARAM - #define GET_X_LPARAM(lp) ((int)(short)LOWORD(lp)) - #define GET_Y_LPARAM(lp) ((int)(short)HIWORD(lp)) + #define GET_X_LPARAM(lp) ((int)(short)LOWORD(lp)) + #define GET_Y_LPARAM(lp) ((int)(short)HIWORD(lp)) #endif // GET_X_LPARAM // --------------------------------------------------------------------------- @@ -112,6 +119,17 @@ wxMenu *wxCurrentPopupMenu = NULL; extern wxList WXDLLEXPORT wxPendingDelete; extern char wxCanvasClassName[]; +#ifdef __WXDEBUG__ + // see comments in dcclient.cpp where g_isPainting is defined + extern bool g_isPainting; + + inline static void wxStartPainting() { g_isPainting = TRUE; } + inline static void wxEndPainting() { g_isPainting = FALSE; } +#else // !debug + inline static void wxStartPainting() { } + inline static void wxEndPainting() { } +#endif // debug/!debug + // --------------------------------------------------------------------------- // private functions // --------------------------------------------------------------------------- @@ -231,12 +249,6 @@ void wxWindow::Init() m_doubleClickAllowed = 0; m_winCaptured = FALSE; - // caret stuff: initially there is no caret at all - m_caretWidth = - m_caretHeight = 0; - m_caretEnabled = - m_caretShown = FALSE; - m_isBeingDeleted = FALSE; m_oldWndProc = 0; m_useCtl3D = FALSE; @@ -891,7 +903,7 @@ WXDWORD wxWindow::Determine3DEffects(WXDWORD defaultBorderStyle, bool *want3D) return exStyle; } -#if WXWIN_COMPATIBILITY_2 +#if WXWIN_COMPATIBILITY // If nothing defined for this, try the parent. // E.g. we may be a button loaded from a resource, with no callback function // defined. @@ -1006,7 +1018,7 @@ void wxWindow::Refresh(bool eraseBack, const wxRect *rect) // drag and drop // --------------------------------------------------------------------------- -#if wxUSE_DRAG_AND_DROP +#if wxUSE_DRAG_AND_DROP void wxWindow::SetDropTarget(wxDropTarget *pDropTarget) { @@ -1099,7 +1111,7 @@ void wxWindow::DoGetPosition(int *x, int *y) const *y = point.y; } -void wxWindow::ScreenToClient(int *x, int *y) const +void wxWindow::DoScreenToClient(int *x, int *y) const { POINT pt; if ( x ) @@ -1116,7 +1128,7 @@ void wxWindow::ScreenToClient(int *x, int *y) const *y = pt.y; } -void wxWindow::ClientToScreen(int *x, int *y) const +void wxWindow::DoClientToScreen(int *x, int *y) const { POINT pt; if ( x ) @@ -1260,7 +1272,8 @@ int wxWindow::GetCharWidth() const return lpTextMetric.tmAveCharWidth; } -void wxWindow::GetTextExtent(const wxString& string, int *x, int *y, +void wxWindow::GetTextExtent(const wxString& string, + int *x, int *y, int *descent, int *externalLeading, const wxFont *theFont) const { @@ -1296,51 +1309,47 @@ void wxWindow::GetTextExtent(const wxString& string, int *x, int *y, if ( externalLeading ) *externalLeading = tm.tmExternalLeading; } +#if wxUSE_CARET && WXWIN_COMPATIBILITY // --------------------------------------------------------------------------- // Caret manipulation // --------------------------------------------------------------------------- void wxWindow::CreateCaret(int w, int h) { - m_caretWidth = w; - m_caretHeight = h; - m_caretEnabled = TRUE; + SetCaret(new wxCaret(this, w, h)); } void wxWindow::CreateCaret(const wxBitmap *WXUNUSED(bitmap)) { - // Not implemented + wxFAIL_MSG("not implemented"); } void wxWindow::ShowCaret(bool show) { - if ( m_caretEnabled ) - { - if ( show ) - ::ShowCaret(GetHwnd()); - else - ::HideCaret(GetHwnd()); - m_caretShown = show; - } + wxCHECK_RET( m_caret, "no caret to show" ); + + m_caret->Show(show); } void wxWindow::DestroyCaret() { - m_caretEnabled = FALSE; + SetCaret(NULL); } void wxWindow::SetCaretPos(int x, int y) { - ::SetCaretPos(x, y); + wxCHECK_RET( m_caret, "no caret to move" ); + + m_caret->Move(x, y); } void wxWindow::GetCaretPos(int *x, int *y) const { - POINT point; - ::GetCaretPos(&point); - *x = point.x; - *y = point.y; + wxCHECK_RET( m_caret, "no caret to get position of" ); + + m_caret->GetPosition(x, y); } +#endif // wxUSE_CARET // =========================================================================== // pre/post message processing @@ -1383,7 +1392,7 @@ bool wxWindow::MSWProcessMessage(WXMSG* pMsg) bool bForward = TRUE, bWindowChange = FALSE; - switch ( msg->wParam ) + switch ( msg->wParam ) { case VK_TAB: if ( lDlgCode & DLGC_WANTTAB ) { @@ -1679,7 +1688,9 @@ long wxWindow::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam) break; case WM_PAINT: + wxStartPainting(); processed = HandlePaint(); + wxEndPainting(); break; case WM_CLOSE: @@ -1768,6 +1779,14 @@ long wxWindow::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam) } break; + case WM_GETDLGCODE: + if ( GetWindowStyleFlag() & wxWANTS_CHARS ) + { + rc.result = DLGC_WANTARROWS | DLGC_WANTCHARS | DLGC_WANTTAB; + processed = TRUE; + } + break; + case WM_KEYDOWN: // If this has been processed by an event handler, // return 0 now (we've handled it). @@ -2068,7 +2087,11 @@ bool wxWindow::MSWCreate(int id, if ( width > -1 ) width1 = width; if ( height > -1 ) height1 = height; +#ifdef __WXWINE__ + HWND hParent = (HWND)NULL; +#else HWND hParent = NULL; +#endif if ( parent ) hParent = (HWND) parent->GetHWND(); @@ -2089,7 +2112,22 @@ bool wxWindow::MSWCreate(int id, return FALSE; } - ::MoveWindow(GetHwnd(), x1, y1, width1, height1, FALSE); + // ::SetWindowLong(GWL_EXSTYLE) doesn't work for the dialogs, so try + // to take care of (at least some) extended style flags ourselves + if ( extendedStyle & WS_EX_TOPMOST ) + { + if ( !::SetWindowPos(GetHwnd(), HWND_TOPMOST, 0, 0, 0, 0, + SWP_NOSIZE | SWP_NOMOVE) ) + { + wxLogLastError("SetWindowPos"); + } + } + + // move the dialog to its initial position without forcing repainting + if ( !::MoveWindow(GetHwnd(), x1, y1, width1, height1, FALSE) ) + { + wxLogLastError("MoveWindow"); + } } else { @@ -2277,20 +2315,13 @@ bool wxWindow::HandleActivate(int state, bool wxWindow::HandleSetFocus(WXHWND WXUNUSED(hwnd)) { +#if wxUSE_CARET // Deal with caret - if ( m_caretEnabled && (m_caretWidth > 0) && (m_caretHeight > 0) ) + if ( m_caret ) { - if ( ::CreateCaret(GetHwnd(), NULL, m_caretWidth, m_caretHeight) ) - { - if ( m_caretShown ) - { - if ( !::ShowCaret(GetHwnd()) ) - wxLogLastError("ShowCaret"); - } - } - else - wxLogLastError("CreateCaret"); + m_caret->OnSetFocus(); } +#endif // wxUSE_CARET // panel wants to track the window which was the last to have focus in it wxWindow *parent = GetParent(); @@ -2307,12 +2338,13 @@ bool wxWindow::HandleSetFocus(WXHWND WXUNUSED(hwnd)) bool wxWindow::HandleKillFocus(WXHWND WXUNUSED(hwnd)) { +#if wxUSE_CARET // Deal with caret - if ( m_caretEnabled ) + if ( m_caret ) { - if ( !::DestroyCaret() ) - wxLogLastError("DestroyCaret"); + m_caret->OnKillFocus(); } +#endif // wxUSE_CARET wxFocusEvent event(wxEVT_KILL_FOCUS, m_windowId); event.SetEventObject(this); @@ -3093,7 +3125,7 @@ bool wxWindow::MSWOnScroll(int orientation, WXWORD wParam, return child->MSWOnScroll(orientation, wParam, pos, control); } - wxScrollEvent event; + wxScrollWinEvent event; event.SetPosition(pos); event.SetOrientation(orientation); event.m_eventObject = this; @@ -3101,32 +3133,32 @@ bool wxWindow::MSWOnScroll(int orientation, WXWORD wParam, switch ( wParam ) { case SB_TOP: - event.m_eventType = wxEVT_SCROLL_TOP; + event.m_eventType = wxEVT_SCROLLWIN_TOP; break; case SB_BOTTOM: - event.m_eventType = wxEVT_SCROLL_BOTTOM; + event.m_eventType = wxEVT_SCROLLWIN_BOTTOM; break; case SB_LINEUP: - event.m_eventType = wxEVT_SCROLL_LINEUP; + event.m_eventType = wxEVT_SCROLLWIN_LINEUP; break; case SB_LINEDOWN: - event.m_eventType = wxEVT_SCROLL_LINEDOWN; + event.m_eventType = wxEVT_SCROLLWIN_LINEDOWN; break; case SB_PAGEUP: - event.m_eventType = wxEVT_SCROLL_PAGEUP; + event.m_eventType = wxEVT_SCROLLWIN_PAGEUP; break; case SB_PAGEDOWN: - event.m_eventType = wxEVT_SCROLL_PAGEDOWN; + event.m_eventType = wxEVT_SCROLLWIN_PAGEDOWN; break; case SB_THUMBTRACK: case SB_THUMBPOSITION: - event.m_eventType = wxEVT_SCROLL_THUMBTRACK; + event.m_eventType = wxEVT_SCROLLWIN_THUMBTRACK; break; default: