Kirix Support Forums

Updating on theme change

Please post any wxAUI patches or modifications you've created here. Thanks!

Updating on theme change

Postby astigsen on Mon Mar 13, 2006 9:17 am

On windows XP (and possibly other platforms) the user can change the theme while the app i running, so the look of the app should update as well.

This patch re-inits wxDockArt when it recieves a SysColourChangedEvent, which usually indicates a theme change.

Code: Select all
--- wxaui-0.9.1/include/manager.h   2006-01-10 18:37:04.000000000 +0100
+++ manager.h (themed)   2006-03-13 14:56:57.796875000 +0100
@@ -447,6 +447,7 @@
     void OnPaneButton(wxFrameManagerEvent& event);
     void OnChildFocus(wxChildFocusEvent& event);
     void OnHintFadeTimer(wxTimerEvent& event);
+    void OnSysColourChanged(wxSysColourChangedEvent& event);

private:

@@ -532,6 +533,7 @@
     wxDockArt() { }
     virtual ~wxDockArt() { }

+    virtual void Init() = 0;
     virtual int GetMetric(int id) = 0;
     virtual void SetMetric(int id, int new_val) = 0;
     virtual void SetFont(int id, const wxFont& font) = 0;


Code: Select all
--- wxaui-0.9.1/src/manager.cpp   2006-01-10 18:37:06.000000000 +0100
+++ manager.cpp   2006-03-13 14:53:48.218750000 +0100
@@ -110,6 +110,11 @@

wxDefaultDockArt::wxDefaultDockArt()
{
+    wxDefaultDockArt::Init();
+}
+
+wxDefaultDockArt::Init()
+{
     wxColor base_color = wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE);
     wxColor darker1_color = StepColour(base_color, 85);
     wxColor darker2_color = StepColour(base_color, 70);
@@ -959,6 +964,7 @@
     EVT_LEAVE_WINDOW(wxFrameManager::OnLeaveWindow)
     EVT_CHILD_FOCUS(wxFrameManager::OnChildFocus)
     EVT_TIMER(101, wxFrameManager::OnHintFadeTimer)
+    EVT_SYS_COLOUR_CHANGED(wxFrameManager::OnSysColourChanged)
END_EVENT_TABLE()


@@ -3403,6 +3409,19 @@
{
}

+void wxFrameManager::OnSysColourChanged(wxSysColourChangedEvent& WXUNUSED(event))
+{
+    // this event is probably triggered by a theme change
+    // so we have to re-init the art provider.
+    if (m_art) m_art->Init();
+
+    if (m_frame)
+    {
+        DoFrameLayout();
+        Repaint();
+    }
+}
+
void wxFrameManager::OnSize(wxSizeEvent& event)
{
     if (m_frame)
astigsen
Registered User
 
Posts: 8
Joined: Thu Jan 26, 2006 9:06 am

Return to wxAUI Patches & Modifications