+ // if orientation doesn't match dock, fix it
+ wxAuiManager* manager = wxAuiManager::GetManager(this);
+ if (manager)
+ {
+ wxAuiPaneInfo& pane = manager->GetPane(this);
+ // pane state member is public, so it might have been changed
+ // without going through wxPaneInfo::SetFlag() check
+ bool ok = pane.IsOk();
+ wxCHECK2_MSG(!ok || IsPaneValid(m_style, pane), ok = false,
+ "window settings and pane settings are incompatible");
+ if (ok)
+ {
+ wxOrientation newOrientation = m_orientation;
+ if (pane.IsDocked())
+ {
+ switch (pane.dock_direction)
+ {
+ case wxAUI_DOCK_TOP:
+ case wxAUI_DOCK_BOTTOM:
+ newOrientation = wxHORIZONTAL;
+ break;
+ case wxAUI_DOCK_LEFT:
+ case wxAUI_DOCK_RIGHT:
+ newOrientation = wxVERTICAL;
+ break;
+ default:
+ wxFAIL_MSG("invalid dock location value");
+ }
+ }
+ else if (pane.IsResizable() &&
+ GetOrientation(m_style) == wxBOTH)
+ {
+ // changing orientation in OnSize causes havoc
+ int x, y;
+ GetClientSize(&x, &y);
+
+ if (x > y)
+ {
+ newOrientation = wxHORIZONTAL;
+ }
+ else
+ {
+ newOrientation = wxVERTICAL;
+ }
+ }
+ if (newOrientation != m_orientation)
+ {
+ SetOrientation(newOrientation);
+ Realize();
+ if (newOrientation == wxHORIZONTAL)
+ {
+ pane.best_size = GetHintSize(wxAUI_DOCK_TOP);
+ }
+ else
+ {
+ pane.best_size = GetHintSize(wxAUI_DOCK_LEFT);
+ }
+ if (pane.IsDocked())
+ {
+ pane.floating_size = wxDefaultSize;
+ }
+ else
+ {
+ SetSize(GetParent()->GetClientSize());
+ }
+ manager->Update();
+ }
+ }
+ }
+