#ifndef WX_PRECOMP
#include "wx/msw/wrapwin.h"
+ #include "wx/msw/wrapcctl.h" // include <commctrl.h> "properly"
+ #include "wx/msw/missing.h"
#include "wx/accel.h"
#include "wx/menu.h"
#include "wx/dc.h"
#include "wx/log.h"
#include "wx/textctrl.h"
#include "wx/menuitem.h"
+ #include "wx/module.h"
#endif
#if wxUSE_OWNER_DRAWN && !defined(__WXUNIVERSAL__)
#endif
#include "wx/evtloop.h"
-#include "wx/module.h"
#include "wx/power.h"
#include "wx/sysopt.h"
#include <windowsx.h>
#endif
-// include <commctrl.h> "properly"
-#include "wx/msw/wrapcctl.h"
-
-#ifndef __WXWINCE__
+#if !defined __WXWINCE__ && !defined NEED_PBT_H
#include <pbt.h>
#endif
-#include "wx/msw/missing.h"
-
#if defined(__WXWINCE__)
#include "wx/msw/wince/missing.h"
#ifdef __POCKETPC__
if ( s_needToUpdate == -1 )
{
int verMaj, verMin;
- s_needToUpdate = wxGetOsVersion(&verMaj, &verMin) == wxWINDOWS_NT &&
+ s_needToUpdate = wxGetOsVersion(&verMaj, &verMin) == wxOS_WINDOWS_NT &&
verMaj >= 5;
}
down ? pages : -pages);
}
+// ----------------------------------------------------------------------------
+// RTL support
+// ----------------------------------------------------------------------------
+
+void wxWindowMSW::SetLayoutDirection(wxLayoutDirection dir)
+{
+#ifdef __WXWINCE__
+ wxUnusedVar(dir);
+#else
+ const HWND hwnd = GetHwnd();
+ wxCHECK_RET( hwnd, _T("layout direction must be set after window creation") );
+
+ LONG styleOld = ::GetWindowLong(hwnd, GWL_EXSTYLE);
+
+ LONG styleNew = styleOld;
+ switch ( dir )
+ {
+ case wxLayout_LeftToRight:
+ styleNew &= ~WS_EX_LAYOUTRTL;
+ break;
+
+ case wxLayout_RightToLeft:
+ styleNew |= WS_EX_LAYOUTRTL;
+ break;
+
+ default:
+ wxFAIL_MSG(_T("unsupported layout direction"));
+ break;
+ }
+
+ if ( styleNew != styleOld )
+ {
+ ::SetWindowLong(hwnd, GWL_EXSTYLE, styleNew);
+ }
+#endif
+}
+
+wxLayoutDirection wxWindowMSW::GetLayoutDirection() const
+{
+#ifdef __WXWINCE__
+ return wxLayout_Default;
+#else
+ const HWND hwnd = GetHwnd();
+ wxCHECK_MSG( hwnd, wxLayout_Default, _T("invalid window") );
+
+ return ::GetWindowLong(hwnd, GWL_EXSTYLE) & WS_EX_LAYOUTRTL
+ ? wxLayout_RightToLeft
+ : wxLayout_LeftToRight;
+#endif
+}
+
+wxCoord
+wxWindowMSW::AdjustForLayoutDirection(wxCoord x,
+ wxCoord WXUNUSED(width),
+ wxCoord WXUNUSED(widthTotal)) const
+{
+ // Win32 mirrors the coordinates of RTL windows automatically, so don't
+ // redo it ourselves
+ return x;
+}
+
// ---------------------------------------------------------------------------
// subclassing
// ---------------------------------------------------------------------------
if ( (lDlgCode & DLGC_WANTMESSAGE) && !bCtrlDown )
{
// control wants to process Enter itself, don't
- // call IsDialogMessage() which would interpret
- // it
+ // call IsDialogMessage() which would consume it
return false;
}
+#if wxUSE_BUTTON
// currently active button should get enter press even
- // if there is a default button elsewhere
+ // if there is a default button elsewhere so check if
+ // this window is a button first
+ wxWindow *btn = NULL;
if ( lDlgCode & DLGC_DEFPUSHBUTTON )
{
// let IsDialogMessage() handle this for all
if ( (style & BS_OWNERDRAW) == BS_OWNERDRAW )
{
// emulate the button click
- wxWindow *
- btn = wxFindWinFromHandle((WXHWND)msg->hwnd);
- if ( btn )
- btn->MSWCommand(BN_CLICKED, 0 /* unused */);
+ btn = wxFindWinFromHandle((WXHWND)msg->hwnd);
}
bProcess = false;
}
- else // not a button itself
+ else // not a button itself, do we have default button?
{
-#if wxUSE_BUTTON
- wxTopLevelWindow *tlw = wxDynamicCast(wxGetTopLevelParent(this), wxTopLevelWindow);
+ wxTopLevelWindow *
+ tlw = wxDynamicCast(wxGetTopLevelParent(this),
+ wxTopLevelWindow);
if ( tlw )
{
- wxButton *btn = wxDynamicCast(tlw->GetDefaultItem(), wxButton);
- if ( btn && btn->IsEnabled() )
- {
- // if we do have a default button, do press it
- btn->MSWCommand(BN_CLICKED, 0 /* unused */);
-
- return true;
- }
+ btn = wxDynamicCast(tlw->GetDefaultItem(),
+ wxButton);
}
- else // no default button
+ }
+
+ if ( btn && btn->IsEnabled() )
+ {
+ btn->MSWCommand(BN_CLICKED, 0 /* unused */);
+ return true;
+ }
+
#endif // wxUSE_BUTTON
- {
+
#ifdef __WXWINCE__
- wxJoystickEvent event(wxEVT_JOY_BUTTON_DOWN);
- event.SetEventObject(this);
- if(GetEventHandler()->ProcessEvent(event))
- return true;
-#endif
- // this is a quick and dirty test for a text
- // control
- if ( !(lDlgCode & DLGC_HASSETSEL) )
- {
- // don't process Enter, the control might
- // need it for itself and don't let
- // ::IsDialogMessage() have it as it can
- // eat the Enter events sometimes
- return false;
- }
- else if (!IsTopLevel())
- {
- // if not a top level window, let parent
- // handle it
- return false;
- }
- //else: treat Enter as TAB: pass to the next
- // control as this is the best thing to do
- // if the text doesn't handle Enter itself
- }
- }
+ // map Enter presses into button presses on PDAs
+ wxJoystickEvent event(wxEVT_JOY_BUTTON_DOWN);
+ event.SetEventObject(this);
+ if ( GetEventHandler()->ProcessEvent(event) )
+ return true;
+#endif // __WXWINCE__
}
break;
bool wxWindowMSW::HandleCaptureChanged(WXHWND hWndGainedCapture)
{
- wxWindow *win = wxFindWinFromHandle(hWndGainedCapture);
-
// notify windows on the capture stack about lost capture
// (see http://sourceforge.net/tracker/index.php?func=detail&aid=1153662&group_id=9863&atid=109863):
- wxWindowBase::NotifyCaptureLost(win);
+ wxWindowBase::NotifyCaptureLost();
+ wxWindow *win = wxFindWinFromHandle(hWndGainedCapture);
wxMouseCaptureChangedEvent event(GetId(), win);
event.SetEventObject(this);
return GetEventHandler()->ProcessEvent(event);