Improve widgets sample UI consistency.

Ensure that the various attributes (colours, font, border, ...) are preserved
when a widget is recreated or the current page is changed. This is more
convenient and also avoids discrepancies between the state of the menu items
and the actual state of the widget.

Closes #16576.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@78332 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2015-01-02 14:26:53 +00:00
parent 55da8a0f86
commit 5662e86b61
17 changed files with 141 additions and 107 deletions

View File

@@ -89,6 +89,36 @@ typedef wxVector<wxControl *> Widgets;
// WidgetsPage: a book page demonstrating some widget
// ----------------------------------------------------------------------------
// struct to store common widget attributes
struct WidgetAttributes
{
WidgetAttributes()
{
#if wxUSE_TOOLTIPS
m_tooltip = "This is a tooltip";
#endif // wxUSE_TOOLTIPS
m_enabled = true;
m_dir = wxLayout_LeftToRight;
m_cursor = *wxSTANDARD_CURSOR;
m_defaultFlags = wxBORDER_DEFAULT;
}
#if wxUSE_TOOLTIPS
wxString m_tooltip;
#endif // wxUSE_TOOLTIPS
#if wxUSE_FONTDLG
wxFont m_font;
#endif // wxUSE_FONTDLG
wxColour m_colFg;
wxColour m_colBg;
wxColour m_colPageBg;
bool m_enabled;
wxLayoutDirection m_dir;
wxCursor m_cursor;
// the default flags, currently only contains border flags
int m_defaultFlags;
};
class WidgetsPage : public wxPanel
{
public:
@@ -119,8 +149,11 @@ public:
// this is currently used only to take into account the border flags
virtual void RecreateWidget() = 0;
// the default flags for the widget, currently only contains border flags
static int ms_defaultFlags;
// apply current atrributes to the widget(s)
void SetUpWidget();
// the default attributes for the widget
static WidgetAttributes& GetAttrs();
protected:
// several helper functions for page creation