From acab1ec756c10cac4a1ad9171fafa7da6abff048 Mon Sep 17 00:00:00 2001 From: Artur Wieczorek Date: Sun, 21 Nov 2021 20:34:38 +0100 Subject: [PATCH] Add option to change layout direction to render sample --- samples/render/render.cpp | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/samples/render/render.cpp b/samples/render/render.cpp index 6bae34781b..fdf4febaa1 100644 --- a/samples/render/render.cpp +++ b/samples/render/render.cpp @@ -142,6 +142,8 @@ private: void OnLoad(wxCommandEvent& event); void OnUnload(wxCommandEvent& event); #endif // wxUSE_DYNLIB_CLASS + void OnToggleLayoutDirection(wxCommandEvent &evt); + void OnQuit(wxCommandEvent& event); void OnAbout(wxCommandEvent& event); @@ -449,6 +451,7 @@ enum Render_Load, Render_Unload, #endif // wxUSE_DYNLIB_CLASS + Render_LayoutDir, #if wxUSE_GRAPHICS_CONTEXT DC_DC, @@ -502,6 +505,7 @@ wxBEGIN_EVENT_TABLE(MyFrame, wxFrame) EVT_MENU(Render_Load, MyFrame::OnLoad) EVT_MENU(Render_Unload,MyFrame::OnUnload) #endif // wxUSE_DYNLIB_CLASS + EVT_MENU(Render_LayoutDir, MyFrame::OnToggleLayoutDirection) EVT_MENU(Render_Quit, MyFrame::OnQuit) #if wxUSE_GRAPHICS_CONTEXT @@ -602,8 +606,11 @@ MyFrame::MyFrame() #if wxUSE_DYNLIB_CLASS menuFile->Append(Render_Load, "&Load renderer...\tCtrl-L"); menuFile->Append(Render_Unload, "&Unload renderer\tCtrl-U"); - menuFile->AppendSeparator(); #endif // wxUSE_DYNLIB_CLASS + menuFile->AppendSeparator(); + menuFile->AppendCheckItem(Render_LayoutDir, "Toggle &layout direction\tShift-Ctrl-L"); + menuFile->Check(Render_LayoutDir, GetLayoutDirection() == wxLayout_RightToLeft); + menuFile->AppendSeparator(); menuFile->Append(Render_Quit); #if wxUSE_GRAPHICS_CONTEXT @@ -754,6 +761,15 @@ void MyFrame::OnUnload(wxCommandEvent& WXUNUSED(event)) #endif // wxUSE_DYNLIB_CLASS +void MyFrame::OnToggleLayoutDirection(wxCommandEvent& WXUNUSED(evt)) +{ + wxLayoutDirection dir = GetLayoutDirection() == wxLayout_LeftToRight + ? wxLayout_RightToLeft : wxLayout_LeftToRight; + SetLayoutDirection(dir); + GetStatusBar()->SetLayoutDirection(dir); + m_panel->SetLayoutDirection(dir); +} + void MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event)) { // true is to force the frame to close