#include "wx/msw/wrapwin.h"
#include "wx/window.h"
#include "wx/accel.h"
- #include "wx/setup.h"
#include "wx/menu.h"
#include "wx/dc.h"
#include "wx/dcclient.h"
// resizing complicated window hierarchies, but this can in theory result in
// different behaviour than the old code so we keep the possibility to use it
// by setting this to 0 (in the future this should be removed completely)
+#ifdef __WXWINCE__
+#define USE_DEFERRED_SIZING 0
+#else
#define USE_DEFERRED_SIZING 1
+#endif
// set this to 1 to filter out duplicate mouse events, e.g. mouse move events
// when mouse position didnd't change
// We have to set the variables here to make them valid in events
// triggered by ::SetScrollInfo()
*(orient == wxHORIZONTAL ? &m_xThumbSize : &m_yThumbSize) = pageSize;
-
+
::SetScrollInfo(hWnd, orient == wxHORIZONTAL ? SB_HORZ : SB_VERT,
&info, refresh);
}
bool wxCheckWindowWndProc(WXHWND hWnd,
- WXFARPROC WXUNUSED_IN_WINCE(wndProc))
+ WXFARPROC WXUNUSED(wndProc))
{
- // Unicows note: the code below works, but only because WNDCLASS contains
- // original window handler rather that the unicows fake one. This may not
- // be on purpose, though; if it stops working with future versions of
- // unicows.dll, we can override unicows hooks by setting
- // Unicows_{Set,Get}WindowLong and Unicows_RegisterClass to our own
- // versions that keep track of fake<->real wnd proc mapping.
+// TODO: This list of window class names should be factored out so they can be
+// managed in one place and then accessed from here and other places, such as
+// wxApp::RegisterWindowClasses() and wxApp::UnregisterWindowClasses()
- // On WinCE (at least), the wndproc comparison doesn't work,
- // so have to use something like this.
#ifdef __WXWINCE__
extern wxChar *wxCanvasClassName;
extern wxChar *wxCanvasClassNameNR;
+#else
+ extern const wxChar *wxCanvasClassName;
+ extern const wxChar *wxCanvasClassNameNR;
+#endif
extern const wxChar *wxMDIFrameClassName;
extern const wxChar *wxMDIFrameClassNameNoRedraw;
extern const wxChar *wxMDIChildFrameClassName;
wxString str(wxGetWindowClass(hWnd));
if (str == wxCanvasClassName ||
str == wxCanvasClassNameNR ||
+#if wxUSE_GLCANVAS
+ str == _T("wxGLCanvasClass") ||
+ str == _T("wxGLCanvasClassNR") ||
+#endif // wxUSE_GLCANVAS
str == wxMDIFrameClassName ||
str == wxMDIFrameClassNameNoRedraw ||
str == wxMDIChildFrameClassName ||
str == wxMDIChildFrameClassNameNoRedraw ||
str == _T("wxTLWHiddenParent"))
return true; // Effectively means don't subclass
-
- return false;
-#else
- WNDCLASS cls;
- if ( !::GetClassInfo(wxGetInstance(), wxGetWindowClass(hWnd), &cls) )
- {
- wxLogLastError(_T("GetClassInfo"));
-
+ else
return false;
- }
-
- return wndProc == (WXFARPROC)cls.lpfnWndProc;
-#endif
}
// ----------------------------------------------------------------------------
// Get size *available for subwindows* i.e. excluding menu bar etc.
void wxWindowMSW::DoGetClientSize(int *x, int *y) const
{
+#if USE_DEFERRED_SIZING
if ( IsTopLevel() || m_pendingSize == wxDefaultSize )
- {
- // top level windows resizing is never deferred, so we can safely use
+#endif
+ { // top level windows resizing is never deferred, so we can safely use
// the current size here
RECT rect = wxGetClientRect(GetHwnd());
if ( y )
*y = rect.bottom;
}
- else // non top level
+#if USE_DEFERRED_SIZING
+ else // non top level and using deferred sizing
{
- // size is the same as client size for non top level windows, so
- // forward to GetSize() to take into account deferred sizing (which
- // wxGetClientRect() doesn't)
- DoGetSize(x, y);
+ // we need to calculate the *pending* client size here
+ RECT rect;
+ rect.left = m_pendingPosition.x;
+ rect.top = m_pendingPosition.y;
+ rect.right = rect.left + m_pendingSize.x;
+ rect.bottom = rect.top + m_pendingSize.y;
+
+ ::SendMessage(GetHwnd(), WM_NCCALCSIZE, FALSE, (LPARAM)&rect);
+
+ if ( x )
+ *x = rect.right - rect.left;
+ if ( y )
+ *y = rect.bottom - rect.top;
}
+#endif
}
void wxWindowMSW::DoGetPosition(int *x, int *y) const
{
// setting the client size is less obvious than it could have been
// because in the result of changing the total size the window scrollbar
- // may [dis]appear and/or its menubar may [un]wrap and so the client size
- // will not be correct as the difference between the total and client size
- // changes - so we keep changing it until we get it right
+ // may [dis]appear and/or its menubar may [un]wrap (and AdjustWindowRect()
+ // doesn't take neither into account) and so the client size will not be
+ // correct as the difference between the total and client size changes --
+ // so we keep changing it until we get it right
//
// normally this loop shouldn't take more than 3 iterations (usually 1 but
// if scrollbars [dis]appear as the result of the first call, then 2 and it
}
// don't call DoMoveWindow() because we want to move window immediately
- // and not defer it here
+ // and not defer it here as otherwise the value returned by
+ // GetClient/WindowRect() wouldn't change as the window wouldn't be
+ // really resized
if ( !::MoveWindow(GetHwnd(),
rectWin.left,
rectWin.top,
dc.SetHDC(hdc);
dc.SetWindow((wxWindow *)this);
- dc.BeginDrawing();
wxEraseEvent event(m_windowId, &dc);
event.SetEventObject(this);
bool rc = GetEventHandler()->ProcessEvent(event);
- dc.EndDrawing();
-
// must be called manually as ~wxDC doesn't do anything for wxDCTemp
dc.SelectOldObjects(hdc);
// the_font.ReleaseResource();
}
+// use the "extended" bit (24) of lParam to distinguish extended keys
+// from normal keys as the same key is sent
+static inline int ChooseNormalOrExtended(int lParam, int keyNormal, int keyExtended)
+{
+ return lParam & (1 << 24) ? keyExtended : keyNormal;
+}
+
// Returns 0 if was a normal ASCII value, not a special key. This indicates that
// the key should be ignored by WM_KEYDOWN and processed by WM_CHAR instead.
int wxCharCodeMSWToWX(int keySym, WXLPARAM lParam)
case VK_APPS: id = WXK_WINDOWS_MENU; break;
#endif // VK_APPS defined
- // use the "extended" bit (24) of lParam to distinguish extended keys
- // from normal keys as the same key is sent
+ // handle extended keys
case VK_PRIOR:
- id = lParam & (1 << 24) ? WXK_PRIOR : WXK_NUMPAD_PRIOR;
+ id = ChooseNormalOrExtended(lParam, WXK_NUMPAD_PRIOR, WXK_PRIOR);
break;
case VK_NEXT:
- id = lParam & (1 << 24) ? WXK_NEXT : WXK_NUMPAD_NEXT;
+ id = ChooseNormalOrExtended(lParam, WXK_NUMPAD_NEXT, WXK_NEXT);
break;
case VK_END:
- id = lParam & (1 << 24) ? WXK_END : WXK_NUMPAD_END;
+ id = ChooseNormalOrExtended(lParam, WXK_NUMPAD_END, WXK_END);
break;
case VK_HOME:
- id = lParam & (1 << 24) ? WXK_HOME : WXK_NUMPAD_HOME;
+ id = ChooseNormalOrExtended(lParam, WXK_NUMPAD_HOME, WXK_HOME);
break;
case VK_LEFT:
- id = lParam & (1 << 24) ? WXK_LEFT : WXK_NUMPAD_LEFT;
+ id = ChooseNormalOrExtended(lParam, WXK_NUMPAD_LEFT, WXK_LEFT);
break;
case VK_UP:
- id = lParam & (1 << 24) ? WXK_UP : WXK_NUMPAD_UP;
+ id = ChooseNormalOrExtended(lParam, WXK_NUMPAD_UP, WXK_UP);
break;
case VK_RIGHT:
- id = lParam & (1 << 24) ? WXK_RIGHT : WXK_NUMPAD_RIGHT;
+ id = ChooseNormalOrExtended(lParam, WXK_NUMPAD_RIGHT, WXK_RIGHT);
break;
case VK_DOWN:
- id = lParam & (1 << 24) ? WXK_DOWN : WXK_NUMPAD_DOWN;
+ id = ChooseNormalOrExtended(lParam, WXK_NUMPAD_DOWN, WXK_DOWN);
break;
case VK_INSERT:
- id = lParam & (1 << 24) ? WXK_INSERT : WXK_NUMPAD_INSERT;
+ id = ChooseNormalOrExtended(lParam, WXK_NUMPAD_INSERT, WXK_INSERT);
break;
case VK_DELETE:
- id = lParam & (1 << 24) ? WXK_DELETE : WXK_NUMPAD_DELETE;
+ id = ChooseNormalOrExtended(lParam, WXK_NUMPAD_DELETE, WXK_DELETE);
break;
// this order is correct as the numpad enter is the extended key
case VK_RETURN:
- id = lParam & (1 << 24) ? WXK_NUMPAD_ENTER : WXK_RETURN;
+ id = ChooseNormalOrExtended(lParam, WXK_RETURN, WXK_NUMPAD_ENTER);
break;
default: