From 7527fdaac83401f3dc5bb849b9be3b2d5d44efd4 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sat, 13 Jul 2013 23:23:01 +0000 Subject: [PATCH] Add a possibility to change the layout direction in the widgets sample. This allows to test whether a widget is drawn correctly in RTL variant as well as the default LTR one easily. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@74504 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- samples/widgets/widgets.cpp | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/samples/widgets/widgets.cpp b/samples/widgets/widgets.cpp index 9d08c992c3..19759aabb6 100644 --- a/samples/widgets/widgets.cpp +++ b/samples/widgets/widgets.cpp @@ -88,6 +88,8 @@ enum Widgets_BorderDouble, Widgets_BorderDefault, + Widgets_LayoutDirection, + Widgets_GlobalBusyCursor, Widgets_BusyCursor, @@ -168,6 +170,8 @@ protected: void OnEnable(wxCommandEvent& event); void OnSetBorder(wxCommandEvent& event); + void OnToggleLayoutDirection(wxCommandEvent& event); + void OnToggleGlobalBusyCursor(wxCommandEvent& event); void OnToggleBusyCursor(wxCommandEvent& event); @@ -299,6 +303,8 @@ BEGIN_EVENT_TABLE(WidgetsFrame, wxFrame) EVT_MENU_RANGE(Widgets_BorderNone, Widgets_BorderDefault, WidgetsFrame::OnSetBorder) + EVT_MENU(Widgets_LayoutDirection, WidgetsFrame::OnToggleLayoutDirection) + EVT_MENU(Widgets_GlobalBusyCursor, WidgetsFrame::OnToggleGlobalBusyCursor) EVT_MENU(Widgets_BusyCursor, WidgetsFrame::OnToggleBusyCursor) @@ -400,6 +406,10 @@ WidgetsFrame::WidgetsFrame(const wxString& title) menuBorders->AppendRadioItem(Widgets_BorderSunken, wxT("S&unken\tCtrl-Shift-5")); menuWidget->AppendSubMenu(menuBorders, wxT("Set &border")); + menuWidget->AppendSeparator(); + menuWidget->AppendCheckItem(Widgets_LayoutDirection, + "Toggle &layout direction\tCtrl-L"); + menuWidget->AppendSeparator(); menuWidget->AppendCheckItem(Widgets_GlobalBusyCursor, wxT("Toggle &global busy cursor\tCtrl-Shift-U")); @@ -922,6 +932,21 @@ void WidgetsFrame::OnSetBorder(wxCommandEvent& event) page->RecreateWidget(); } +void WidgetsFrame::OnToggleLayoutDirection(wxCommandEvent& event) +{ + wxLayoutDirection dir = event.IsChecked() ? wxLayout_RightToLeft + : wxLayout_LeftToRight; + + const Widgets widgets = CurrentPage()->GetWidgets(); + for ( Widgets::const_iterator it = widgets.begin(); + it != widgets.end(); + ++it ) + { + (*it)->SetLayoutDirection(dir); + (*it)->Refresh(); + } +} + void WidgetsFrame::OnToggleGlobalBusyCursor(wxCommandEvent& event) { if ( event.IsChecked() ) -- 2.47.2