#include "wx/ownerdrw.h"
#endif
+#include "wx/evtloop.h"
#include "wx/module.h"
#include "wx/sysopt.h"
}
#endif
-// ---------------------------------------------------------------------------
-// wxWindowExtraData
-// ---------------------------------------------------------------------------
-
-#if USE_DEFER_BUG_WORKAROUND
-// This class is used to hold additional data memebers that were added after
-// the stable 2.6.0 release. They should be moved into wxWindow for 2.7 after
-// binary compatibility is no longer being maintained.
-
-class wxWindowExtraData {
-public:
- wxWindowExtraData()
- : m_pendingPosition(wxDefaultPosition),
- m_pendingSize(wxDefaultSize)
- {}
-
- wxPoint m_pendingPosition;
- wxSize m_pendingSize;
-};
-
-#endif
-
// ---------------------------------------------------------------------------
// event tables
// ---------------------------------------------------------------------------
m_lastMouseEvent = -1;
#endif // wxUSE_MOUSEEVENT_HACK
-#if USE_DEFER_BUG_WORKAROUND
- m_extraData = new wxWindowExtraData;
-#endif
+ m_pendingPosition = wxDefaultPosition;
+ m_pendingSize = wxDefaultSize;
}
// Destructor
delete m_childrenDisabled;
-#if USE_DEFER_BUG_WORKAROUND
- delete m_extraData;
-#endif
}
// real construction (Init() must have been called before!)
wOrient,
&scrollInfo) )
{
- // Not neccessarily an error, if there are no scrollbars yet.
+ // Not necessarily an error, if there are no scrollbars yet.
// wxLogLastError(_T("GetScrollInfo"));
}
return scrollInfo.nPos;
}
-bool wxCheckWindowWndProc(WXHWND hWnd, WXFARPROC wndProc)
+bool wxCheckWindowWndProc(WXHWND hWnd,
+ WXFARPROC WXUNUSED_IN_WINCE(wndProc))
{
// Unicows note: the code below works, but only because WNDCLASS contains
// original window handler rather that the unicows fake one. This may not
// On WinCE (at least), the wndproc comparison doesn't work,
// so have to use something like this.
#ifdef __WXWINCE__
- wxUnusedVar(wndProc);
-
extern wxChar *wxCanvasClassName;
extern wxChar *wxCanvasClassNameNR;
extern const wxChar *wxMDIFrameClassName;
pRect = NULL;
}
- // RedrawWindow not available on SmartPhone or eVC++ 3
+ // RedrawWindow not available on SmartPhone or eVC++ 3
#if !defined(__SMARTPHONE__) && !(defined(_WIN32_WCE) && _WIN32_WCE < 400)
UINT flags = RDW_INVALIDATE | RDW_ALLCHILDREN;
if ( eraseBack )
// old style file-manager drag&drop support: we retain the old-style
// DragAcceptFiles in parallel with SetDropTarget.
-void wxWindowMSW::DragAcceptFiles(bool accept)
+void wxWindowMSW::DragAcceptFiles(bool WXUNUSED_IN_WINCE(accept))
{
-#if !defined(__WXWINCE__)
+#ifndef __WXWINCE__
HWND hWnd = GetHwnd();
if ( hWnd )
::DragAcceptFiles(hWnd, (BOOL)accept);
-#else
- wxUnusedVar(accept);
#endif
}
int currentW, currentH;
#if USE_DEFER_BUG_WORKAROUND
- currentX = m_extraData->m_pendingPosition.x;
+ currentX = m_pendingPosition.x;
if (currentX == wxDefaultCoord)
GetPosition(¤tX, NULL);
- currentY = m_extraData->m_pendingPosition.y;
+ currentY = m_pendingPosition.y;
if (currentY == wxDefaultCoord)
GetPosition(NULL, ¤tY);
- currentW = m_extraData->m_pendingSize.x;
+ currentW = m_pendingSize.x;
if (currentW == wxDefaultCoord)
GetSize(¤tW, NULL);
- currentH = m_extraData->m_pendingSize.y;
+ currentH = m_pendingSize.y;
if (currentH == wxDefaultCoord)
GetSize(NULL, ¤tH);
#else
// save the pending dimensions or not. This isn't done in DoMoveWindow
// (where the hdwp is used) because some controls have thier own
// DoMoveWindow so it is easier to catch it here.
- HDWP hdwp = GetParent() && !IsTopLevel() ? (HDWP)GetParent()->m_hDWP : NULL;
+ wxWindowMSW *parent = GetParent();
+ HDWP hdwp = parent && !IsTopLevel() ? (HDWP)parent->m_hDWP : NULL;
if (hdwp)
{
- m_extraData->m_pendingPosition = wxPoint(x, y);
- m_extraData->m_pendingSize = wxSize(width, height);
+ m_pendingPosition = wxPoint(x, y);
+ m_pendingSize = wxSize(width, height);
}
else
{
- m_extraData->m_pendingPosition = wxDefaultPosition;
- m_extraData->m_pendingSize = wxDefaultSize;
+ m_pendingPosition = wxDefaultPosition;
+ m_pendingSize = wxDefaultSize;
}
#endif
RECT rectClient;
::GetClientRect(GetHwnd(), &rectClient);
- // if the size is already ok, stop here (rectClient.left = top = 0)
+ // if the size is already ok, stop here (NB: rectClient.left = top = 0)
if ( (rectClient.right == width || width == wxDefaultCoord) &&
(rectClient.bottom == height || height == wxDefaultCoord) )
{
break;
}
- int widthClient = width,
- heightClient = height;
-
// Find the difference between the entire window (title bar and all)
// and the client area; add this to the new client size to move the
// window
RECT rectWin;
::GetWindowRect(GetHwnd(), &rectWin);
- widthClient += rectWin.right - rectWin.left - rectClient.right;
- heightClient += rectWin.bottom - rectWin.top - rectClient.bottom;
-
- POINT point;
- point.x = rectWin.left;
- point.y = rectWin.top;
+ const int widthWin = rectWin.right - rectWin.left,
+ heightWin = rectWin.bottom - rectWin.top;
// MoveWindow positions the child windows relative to the parent, so
// adjust if necessary
wxWindow *parent = GetParent();
if ( parent )
{
- ::ScreenToClient(GetHwndOf(parent), &point);
+ ::ScreenToClient(GetHwndOf(parent), (POINT *)&rectWin);
}
}
- DoMoveWindow(point.x, point.y, widthClient, heightClient);
+ // don't call DoMoveWindow() because we want to move window immediately
+ // and not defer it here
+ if ( !::MoveWindow(GetHwnd(),
+ rectWin.left,
+ rectWin.top,
+ width + widthWin - rectClient.right,
+ height + heightWin - rectClient.bottom,
+ TRUE) )
+ {
+ wxLogLastError(_T("MoveWindow"));
+ }
}
}
SIZE sizeRect;
TEXTMETRIC tm;
- GetTextExtentPoint(hdc, string, string.length(), &sizeRect);
+ ::GetTextExtentPoint32(hdc, string, string.length(), &sizeRect);
GetTextMetrics(hdc, &tm);
if ( x )
bProcess = false;
break;
- case VK_ESCAPE:
- {
-#if wxUSE_BUTTON
- wxButton *btn = wxDynamicCast(FindWindow(wxID_CANCEL),wxButton);
-
- // our own wxLogDialog should react to Esc
- // without Cancel button but this is a private class
- // so let's try recognize it by content
- #if wxUSE_LOG_DIALOG
- if ( !btn &&
- wxDynamicCast(this,wxDialog) &&
- FindWindow(wxID_MORE) &&
- FindWindow(wxID_OK) &&
- !FindWindow(wxID_CANCEL) &&
- GetTitle().MakeLower().StartsWith(wxTheApp->GetAppName().c_str())
- )
- btn = wxDynamicCast(FindWindow(wxID_OK),wxButton);
- #endif // wxUSE_LOG_DIALOG
- if ( btn && btn->IsEnabled() )
- {
- // if we do have a cancel button, do press it
- btn->MSWCommand(BN_CLICKED, 0 /* unused */);
-
- // we consumed the message
- return true;
- }
-#endif // wxUSE_BUTTON
-
- bProcess = false;
- }
- break;
-
case VK_RETURN:
{
if ( (lDlgCode & DLGC_WANTMESSAGE) && !bCtrlDown )
LRESULT rc;
- if ( wnd )
+ if ( wnd && wxEventLoop::AllowProcessing(wnd) )
rc = wnd->MSWWindowProc(message, wParam, lParam);
else
rc = ::DefWindowProc(hWnd, message, wParam, lParam);
break;
#endif // !__WXWINCE__
+#if !(defined(_WIN32_WCE) && _WIN32_WCE < 400)
case WM_WINDOWPOSCHANGED:
{
WINDOWPOS *lpPos = (WINDOWPOS *)lParam;
AutoHRGN hrgnClient(::CreateRectRgnIndirect(&rc));
AutoHRGN hrgnNew(::CreateRectRgn(lpPos->x, lpPos->y,
lpPos->cx, lpPos->cy));
- AutoHRGN hrgn(::CreateRectRgn(0, 0, 0, 0));
// we need to invalidate any new exposed areas here
// to force them to repaint
- if ( ::CombineRgn(hrgn, hrgnNew, hrgnClient, RGN_DIFF) != NULLREGION )
- ::InvalidateRgn(GetHwnd(), hrgn, TRUE);
- if ( ::CombineRgn(hrgn, hrgnClient, hrgnNew, RGN_DIFF) != NULLREGION )
- ::InvalidateRgn(GetHwnd(), hrgn, TRUE);
-
+ if ( ::CombineRgn(hrgnNew, hrgnNew, hrgnClient, RGN_DIFF) != NULLREGION )
+ ::InvalidateRgn(GetHwnd(), hrgnNew, TRUE);
}
}
break;
-
+#endif
#if !defined(__WXMICROWIN__) && !defined(__WXWINCE__)
case WM_ACTIVATEAPP:
// This implicitly sends a wxEVT_ACTIVATE_APP event
// window creation/destruction
// ---------------------------------------------------------------------------
-bool wxWindowMSW::HandleCreate(WXLPCREATESTRUCT cs, bool *mayCreate)
+bool wxWindowMSW::HandleCreate(WXLPCREATESTRUCT WXUNUSED_IN_WINCE(cs),
+ bool *mayCreate)
{
// VZ: why is this commented out for WinCE? If it doesn't support
// WS_EX_CONTROLPARENT at all it should be somehow handled globally,
#ifndef __WXWINCE__
if ( ((CREATESTRUCT *)cs)->dwExStyle & WS_EX_CONTROLPARENT )
EnsureParentHasControlParentStyle(GetParent());
-#else
- wxUnusedVar(cs);
#endif // !__WXWINCE__
// TODO: should generate this event from WM_NCCREATE
// we want to avoid Windows' "help" and for this we need to have a
// reference bitmap which can tell us what the RGB values change
// to.
+ wxLogNull logNo; // suppress error if we couldn't load the bitmap
wxBitmap stdColourBitmap(_T("wxBITMAP_STD_COLOURS"));
if ( stdColourBitmap.Ok() )
{
//
// also note that in this case lParam == PRF_CLIENT but we're
// clearly expected to paint the background and nothing else!
+
+ if ( IsTopLevel() || InheritsBackgroundColour() )
+ return false;
+
+ // sometimes we don't want the parent to handle it at all, instead
+ // return whatever value this window wants
+ if ( !MSWShouldPropagatePrintChild() )
+ return MSWPrintChild(hDC, (wxWindow *)this);
+
for ( wxWindow *win = GetParent(); win; win = win->GetParent() )
{
if ( win->MSWPrintChild(hDC, (wxWindow *)this) )
node;
node = node->GetNext() )
{
- wxWindow *child = node->GetData();
- child->m_extraData->m_pendingPosition = wxDefaultPosition;
- child->m_extraData->m_pendingSize = wxDefaultSize;
+ wxWindowMSW *child = node->GetData();
+ child->m_pendingPosition = wxDefaultPosition;
+ child->m_pendingSize = wxDefaultSize;
}
#endif
}
return rc;
}
-bool wxWindowMSW::HandleGetMinMaxInfo(void *mmInfo)
+bool wxWindowMSW::HandleGetMinMaxInfo(void *WXUNUSED_IN_WINCE(mmInfo))
{
#ifdef __WXWINCE__
- wxUnusedVar(mmInfo);
return false;
#else
MINMAXINFO *info = (MINMAXINFO *)mmInfo;
bool wxWindowMSW::HandleMouseWheel(WXWPARAM wParam, WXLPARAM lParam)
{
#if wxUSE_MOUSEWHEEL
+ // notice that WM_MOUSEWHEEL position is in screen coords (as it's
+ // forwarded up to the parent by DefWindowProc()) and not in the client
+ // ones as all the other messages, translate them to the client coords for
+ // consistency
+ const wxPoint
+ pt = ScreenToClient(wxPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam)));
wxMouseEvent event(wxEVT_MOUSEWHEEL);
- InitMouseEvent(event,
- GET_X_LPARAM(lParam),
- GET_Y_LPARAM(lParam),
- LOWORD(wParam));
+ InitMouseEvent(event, pt.x, pt.y, LOWORD(wParam));
event.m_wheelRotation = (short)HIWORD(wParam);
event.m_wheelDelta = WHEEL_DELTA;
return false;
}
-int wxWindowMSW::HandleMenuChar(int chAccel, WXLPARAM lParam)
+int wxWindowMSW::HandleMenuChar(int WXUNUSED_IN_WINCE(chAccel),
+ WXLPARAM WXUNUSED_IN_WINCE(lParam))
{
// FIXME: implement GetMenuItemCount for WinCE, possibly
// in terms of GetMenuItemInfo
wxLogLastError(_T("GetMenuItemInfo"));
}
}
-#else
- wxUnusedVar(chAccel);
- wxUnusedVar(lParam);
#endif
return wxNOT_FOUND;
}
: SB_VERT,
&scrollInfo) )
{
- // Not neccessarily an error, if there are no scrollbars yet.
+ // Not necessarily an error, if there are no scrollbars yet.
// wxLogLastError(_T("GetScrollInfo"));
}