#include "wx/sizer.h"
#include "wx/intl.h"
#include "wx/log.h"
+ #include "wx/textctrl.h"
#endif
#if wxUSE_OWNER_DRAWN && !defined(__WXUNIVERSAL__)
#include "wx/evtloop.h"
#include "wx/module.h"
+#include "wx/power.h"
#include "wx/sysopt.h"
#if wxUSE_DRAG_AND_DROP
#include "wx/spinctrl.h"
#endif // wxUSE_SPINCTRL
-#include "wx/textctrl.h"
#include "wx/notebook.h"
#include "wx/listctrl.h"
#include <windowsx.h>
#endif
-#include <commctrl.h>
+// include <commctrl.h> "properly"
+#include "wx/msw/wrapcctl.h"
+
+#ifndef __WXWINCE__
+ #include <pbt.h>
+#endif
#include "wx/msw/missing.h"
// update the internal variable
wxWindowBase::SetWindowStyleFlag(flags);
+ // and the real window flags
+ MSWUpdateStyle(flagsOld, GetExtraStyle());
+}
+
+void wxWindowMSW::SetExtraStyle(long exflags)
+{
+ long exflagsOld = GetExtraStyle();
+ if ( exflags == exflagsOld )
+ return;
+
+ // update the internal variable
+ wxWindowBase::SetExtraStyle(exflags);
+
+ // and the real window flags
+ MSWUpdateStyle(GetWindowStyleFlag(), exflagsOld);
+}
+
+void wxWindowMSW::MSWUpdateStyle(long flagsOld, long exflagsOld)
+{
// now update the Windows style as well if needed - and if the window had
// been already created
if ( !GetHwnd() )
// we may need to call SetWindowPos() when we change some styles
bool callSWP = false;
- WXDWORD exstyle, exstyleOld;
- long style = MSWGetStyle(flags, &exstyle),
- styleOld = MSWGetStyle(flagsOld, &exstyleOld);
+ WXDWORD exstyle;
+ long style = MSWGetStyle(GetWindowStyleFlag(), &exstyle);
+
+ // this is quite a horrible hack but we need it because MSWGetStyle()
+ // doesn't take exflags as parameter but uses GetExtraStyle() internally
+ // and so we have to modify the window exflags temporarily to get the
+ // correct exstyleOld
+ long exflagsNew = GetExtraStyle();
+ wxWindowBase::SetExtraStyle(exflagsOld);
+
+ WXDWORD exstyleOld;
+ long styleOld = MSWGetStyle(flagsOld, &exstyleOld);
+
+ wxWindowBase::SetExtraStyle(exflagsNew);
+
if ( style != styleOld )
{
::SetWindowLong(GetHwnd(), GWL_STYLE, styleReal);
- // If any of the style changes changed any of the frame styles:
- // MSDN: SetWindowLong:
- // Certain window data is cached, so changes you make using
- // SetWindowLong will not take effect until you call the
- // SetWindowPos function. Specifically, if you change any of
- // the frame styles, you must call SetWindowPos with the
- // SWP_FRAMECHANGED flag for the cache to be updated properly.
-
+ // we need to call SetWindowPos() if any of the styles affecting the
+ // frame appearance have changed
callSWP = ((styleOld ^ style ) & (WS_BORDER |
WS_THICKFRAME |
WS_CAPTION |
#if defined(WM_HELP)
case WM_HELP:
{
- // HELPINFO doesn't seem to be supported on WinCE.
+ // by default, WM_HELP is propagated by DefWindowProc() upwards
+ // to the window parent but as we do it ourselves already
+ // (wxHelpEvent is derived from wxCommandEvent), we don't want
+ // to get the other events if we process this message at all
+ processed = true;
+
+ // WM_HELP doesn't use lParam under CE
#ifndef __WXWINCE__
HELPINFO* info = (HELPINFO*) lParam;
- // Don't yet process menu help events, just windows
- if (info->iContextType == HELPINFO_WINDOW)
+ if ( info->iContextType == HELPINFO_WINDOW )
{
-#endif
- wxWindowMSW* subjectOfHelp = this;
- bool eventProcessed = false;
- while (subjectOfHelp && !eventProcessed)
- {
- wxHelpEvent helpEvent(wxEVT_HELP,
- subjectOfHelp->GetId(),
+#endif // !__WXWINCE__
+ wxHelpEvent helpEvent
+ (
+ wxEVT_HELP,
+ GetId(),
#ifdef __WXWINCE__
- wxPoint(0,0)
+ wxGetMousePosition() // what else?
#else
- wxPoint(info->MousePos.x, info->MousePos.y)
+ wxPoint(info->MousePos.x, info->MousePos.y)
#endif
- );
+ );
- helpEvent.SetEventObject(this);
- eventProcessed =
- GetEventHandler()->ProcessEvent(helpEvent);
-
- // Go up the window hierarchy until the event is
- // handled (or not)
- subjectOfHelp = subjectOfHelp->GetParent();
- }
-
- processed = eventProcessed;
+ helpEvent.SetEventObject(this);
+ GetEventHandler()->ProcessEvent(helpEvent);
#ifndef __WXWINCE__
}
- else if (info->iContextType == HELPINFO_MENUITEM)
+ else if ( info->iContextType == HELPINFO_MENUITEM )
{
wxHelpEvent helpEvent(wxEVT_HELP, info->iCtrlId);
helpEvent.SetEventObject(this);
- processed = GetEventHandler()->ProcessEvent(helpEvent);
+ GetEventHandler()->ProcessEvent(helpEvent);
}
- //else: processed is already false
-#endif
+ else // unknown help event?
+ {
+ processed = false;
+ }
+#endif // !__WXWINCE__
}
break;
-#endif
+#endif // WM_HELP
#if !defined(__WXWINCE__)
case WM_CONTEXTMENU:
}
}
break;
+
+#ifndef __WXWINCE__
+ case WM_POWERBROADCAST:
+ {
+ bool vetoed;
+ processed = HandlePower(wParam, lParam, &vetoed);
+ rc.result = processed && vetoed ? BROADCAST_QUERY_DENY : TRUE;
+ }
+ break;
+#endif // __WXWINCE__
}
if ( !processed )
// Truncate tooltip length if needed as otherwise we might not have
// enough space for it in the buffer and MultiByteToWideChar() would
// return an error
- size_t tipLength = wxMin(ttip.Len(), WXSIZEOF(buf) - 1);
+ size_t tipLength = wxMin(ttip.length(), WXSIZEOF(buf) - 1);
// Convert to WideChar without adding the NULL character. The NULL
// character is added afterwards (this is more efficient).
return false;
}
+bool wxWindowMSW::HandlePower(WXWPARAM WXUNUSED_IN_WINCE(wParam),
+ WXLPARAM WXUNUSED(lParam),
+ bool *WXUNUSED_IN_WINCE(vetoed))
+{
+#ifdef __WXWINCE__
+ // FIXME
+ return false;
+#else
+ wxEventType evtType;
+ switch ( wParam )
+ {
+ case PBT_APMQUERYSUSPEND:
+ evtType = wxEVT_POWER_SUSPENDING;
+ break;
+
+ case PBT_APMQUERYSUSPENDFAILED:
+ evtType = wxEVT_POWER_SUSPEND_CANCEL;
+ break;
+
+ case PBT_APMSUSPEND:
+ evtType = wxEVT_POWER_SUSPENDED;
+ break;
+
+ case PBT_APMRESUMESUSPEND:
+#ifdef PBT_APMRESUMEAUTOMATIC
+ case PBT_APMRESUMEAUTOMATIC:
+#endif
+ evtType = wxEVT_POWER_RESUME;
+ break;
+
+ default:
+ wxLogDebug(_T("Unknown WM_POWERBROADCAST(%d) event"), wParam);
+ // fall through
+
+ // these messages are currently not mapped to wx events
+ case PBT_APMQUERYSTANDBY:
+ case PBT_APMQUERYSTANDBYFAILED:
+ case PBT_APMSTANDBY:
+ case PBT_APMRESUMESTANDBY:
+ case PBT_APMBATTERYLOW:
+ case PBT_APMPOWERSTATUSCHANGE:
+ case PBT_APMOEMEVENT:
+ case PBT_APMRESUMECRITICAL:
+ evtType = wxEVT_NULL;
+ break;
+ }
+
+ // don't handle unknown messages
+ if ( evtType == wxEVT_NULL )
+ return false;
+
+ // TODO: notify about PBTF_APMRESUMEFROMFAILURE in case of resume events?
+
+ wxPowerEvent event(evtType);
+ if ( !GetEventHandler()->ProcessEvent(event) )
+ return false;
+
+ *vetoed = event.IsVetoed();
+
+ return true;
+#endif
+}
+
// ---------------------------------------------------------------------------
// owner drawn stuff
// ---------------------------------------------------------------------------
return wxNOT_FOUND;
}
+bool wxWindowMSW::HandleClipboardEvent( WXUINT nMsg )
+{
+ const wxEventType type = ( nMsg == WM_CUT ) ? wxEVT_COMMAND_TEXT_CUT :
+ ( nMsg == WM_COPY ) ? wxEVT_COMMAND_TEXT_COPY :
+ /*( nMsg == WM_PASTE ) ? */ wxEVT_COMMAND_TEXT_PASTE;
+ wxClipboardTextEvent evt(type, GetId());
+
+ evt.SetEventObject(this);
+
+ return GetEventHandler()->ProcessEvent(evt);
+}
+
// ---------------------------------------------------------------------------
// joystick
// ---------------------------------------------------------------------------
POINT pt2;
pt2.x = pt.x;
pt2.y = pt.y;
- HWND hWndHit = ::WindowFromPoint(pt2);
- wxWindow* win = wxFindWinFromHandle((WXHWND) hWndHit) ;
- HWND hWnd = hWndHit;
+ HWND hWnd = ::WindowFromPoint(pt2);
- // Try to find a window with a wxWindow associated with it
- while (!win && (hWnd != 0))
- {
- hWnd = ::GetParent(hWnd);
- win = wxFindWinFromHandle((WXHWND) hWnd) ;
- }
- return win;
+ return wxGetWindowFromHWND((WXHWND)hWnd);
}
// Get the current mouse position.