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:
@@ -422,7 +422,7 @@ void BitmapComboBoxWidgetsPage::Reset()
|
|||||||
|
|
||||||
void BitmapComboBoxWidgetsPage::CreateCombo()
|
void BitmapComboBoxWidgetsPage::CreateCombo()
|
||||||
{
|
{
|
||||||
int flags = ms_defaultFlags;
|
int flags = GetAttrs().m_defaultFlags;
|
||||||
|
|
||||||
if ( m_chkSort->GetValue() )
|
if ( m_chkSort->GetValue() )
|
||||||
flags |= wxCB_SORT;
|
flags |= wxCB_SORT;
|
||||||
|
@@ -408,7 +408,7 @@ void ButtonWidgetsPage::CreateButton()
|
|||||||
label = m_textLabel->GetValue();
|
label = m_textLabel->GetValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
int flags = ms_defaultFlags;
|
int flags = GetAttrs().m_defaultFlags;
|
||||||
switch ( m_radioHAlign->GetSelection() )
|
switch ( m_radioHAlign->GetSelection() )
|
||||||
{
|
{
|
||||||
case ButtonHAlign_Left:
|
case ButtonHAlign_Left:
|
||||||
|
@@ -252,7 +252,7 @@ void CheckBoxWidgetsPage::CreateCheckbox()
|
|||||||
|
|
||||||
delete m_checkbox;
|
delete m_checkbox;
|
||||||
|
|
||||||
int flags = ms_defaultFlags;
|
int flags = GetAttrs().m_defaultFlags;
|
||||||
if ( m_chkRight->IsChecked() )
|
if ( m_chkRight->IsChecked() )
|
||||||
flags |= wxALIGN_RIGHT;
|
flags |= wxALIGN_RIGHT;
|
||||||
|
|
||||||
|
@@ -297,7 +297,7 @@ void ChoiceWidgetsPage::Reset()
|
|||||||
|
|
||||||
void ChoiceWidgetsPage::CreateChoice()
|
void ChoiceWidgetsPage::CreateChoice()
|
||||||
{
|
{
|
||||||
int flags = ms_defaultFlags;
|
int flags = GetAttrs().m_defaultFlags;
|
||||||
|
|
||||||
if ( m_chkSort->GetValue() )
|
if ( m_chkSort->GetValue() )
|
||||||
flags |= wxCB_SORT;
|
flags |= wxCB_SORT;
|
||||||
|
@@ -407,7 +407,7 @@ void ComboboxWidgetsPage::Reset()
|
|||||||
|
|
||||||
void ComboboxWidgetsPage::CreateCombo()
|
void ComboboxWidgetsPage::CreateCombo()
|
||||||
{
|
{
|
||||||
int flags = ms_defaultFlags;
|
int flags = GetAttrs().m_defaultFlags;
|
||||||
|
|
||||||
if ( m_chkSort->GetValue() )
|
if ( m_chkSort->GetValue() )
|
||||||
flags |= wxCB_SORT;
|
flags |= wxCB_SORT;
|
||||||
|
@@ -283,7 +283,7 @@ void GaugeWidgetsPage::Reset()
|
|||||||
|
|
||||||
void GaugeWidgetsPage::CreateGauge()
|
void GaugeWidgetsPage::CreateGauge()
|
||||||
{
|
{
|
||||||
int flags = ms_defaultFlags;
|
int flags = GetAttrs().m_defaultFlags;
|
||||||
|
|
||||||
if ( m_chkVert->GetValue() )
|
if ( m_chkVert->GetValue() )
|
||||||
flags |= wxGA_VERTICAL;
|
flags |= wxGA_VERTICAL;
|
||||||
|
@@ -378,7 +378,7 @@ void ListboxWidgetsPage::Reset()
|
|||||||
|
|
||||||
void ListboxWidgetsPage::CreateLbox()
|
void ListboxWidgetsPage::CreateLbox()
|
||||||
{
|
{
|
||||||
int flags = ms_defaultFlags;
|
int flags = GetAttrs().m_defaultFlags;
|
||||||
switch ( m_radioSelMode->GetSelection() )
|
switch ( m_radioSelMode->GetSelection() )
|
||||||
{
|
{
|
||||||
default:
|
default:
|
||||||
|
@@ -349,7 +349,7 @@ void BookWidgetsPage::RecreateBook()
|
|||||||
if(!m_radioOrient)
|
if(!m_radioOrient)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
int flags = ms_defaultFlags;
|
int flags = GetAttrs().m_defaultFlags;
|
||||||
|
|
||||||
switch ( m_radioOrient->GetSelection() )
|
switch ( m_radioOrient->GetSelection() )
|
||||||
{
|
{
|
||||||
|
@@ -495,7 +495,7 @@ void ODComboboxWidgetsPage::Reset()
|
|||||||
|
|
||||||
void ODComboboxWidgetsPage::CreateCombo()
|
void ODComboboxWidgetsPage::CreateCombo()
|
||||||
{
|
{
|
||||||
int flags = ms_defaultFlags;
|
int flags = GetAttrs().m_defaultFlags;
|
||||||
|
|
||||||
if ( m_chkSort->GetValue() )
|
if ( m_chkSort->GetValue() )
|
||||||
flags |= wxCB_SORT;
|
flags |= wxCB_SORT;
|
||||||
|
@@ -370,7 +370,7 @@ void RadioWidgetsPage::CreateRadio()
|
|||||||
int flags = m_chkSpecifyRows->GetValue() ? wxRA_SPECIFY_ROWS
|
int flags = m_chkSpecifyRows->GetValue() ? wxRA_SPECIFY_ROWS
|
||||||
: wxRA_SPECIFY_COLS;
|
: wxRA_SPECIFY_COLS;
|
||||||
|
|
||||||
flags |= ms_defaultFlags;
|
flags |= GetAttrs().m_defaultFlags;
|
||||||
|
|
||||||
#ifdef wxRA_LEFTTORIGHT
|
#ifdef wxRA_LEFTTORIGHT
|
||||||
switch ( m_radioDir->GetSelection() )
|
switch ( m_radioDir->GetSelection() )
|
||||||
|
@@ -383,7 +383,7 @@ void SliderWidgetsPage::Reset()
|
|||||||
|
|
||||||
void SliderWidgetsPage::CreateSlider()
|
void SliderWidgetsPage::CreateSlider()
|
||||||
{
|
{
|
||||||
int flags = ms_defaultFlags;
|
int flags = GetAttrs().m_defaultFlags;
|
||||||
|
|
||||||
if ( m_chkInverse->GetValue() )
|
if ( m_chkInverse->GetValue() )
|
||||||
{
|
{
|
||||||
|
@@ -347,7 +347,7 @@ void SpinBtnWidgetsPage::Reset()
|
|||||||
|
|
||||||
void SpinBtnWidgetsPage::CreateSpin()
|
void SpinBtnWidgetsPage::CreateSpin()
|
||||||
{
|
{
|
||||||
int flags = ms_defaultFlags;
|
int flags = GetAttrs().m_defaultFlags;
|
||||||
|
|
||||||
bool isVert = m_chkVert->GetValue();
|
bool isVert = m_chkVert->GetValue();
|
||||||
if ( isVert )
|
if ( isVert )
|
||||||
|
@@ -395,8 +395,8 @@ void StaticWidgetsPage::CreateStatic()
|
|||||||
}
|
}
|
||||||
|
|
||||||
int flagsBox = 0,
|
int flagsBox = 0,
|
||||||
flagsText = ms_defaultFlags,
|
flagsText = GetAttrs().m_defaultFlags,
|
||||||
flagsDummyText = ms_defaultFlags;
|
flagsDummyText = GetAttrs().m_defaultFlags;
|
||||||
|
|
||||||
if ( !m_chkAutoResize->GetValue() )
|
if ( !m_chkAutoResize->GetValue() )
|
||||||
{
|
{
|
||||||
|
@@ -631,7 +631,7 @@ void TextWidgetsPage::Reset()
|
|||||||
|
|
||||||
void TextWidgetsPage::CreateText()
|
void TextWidgetsPage::CreateText()
|
||||||
{
|
{
|
||||||
int flags = ms_defaultFlags;
|
int flags = GetAttrs().m_defaultFlags;
|
||||||
switch ( m_radioTextLines->GetSelection() )
|
switch ( m_radioTextLines->GetSelection() )
|
||||||
{
|
{
|
||||||
default:
|
default:
|
||||||
|
@@ -370,7 +370,7 @@ void ToggleWidgetsPage::CreateToggle()
|
|||||||
label = m_textLabel->GetValue();
|
label = m_textLabel->GetValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
int flags = ms_defaultFlags;
|
int flags = GetAttrs().m_defaultFlags;
|
||||||
#ifdef wxHAS_BITMAPTOGGLEBUTTON
|
#ifdef wxHAS_BITMAPTOGGLEBUTTON
|
||||||
switch ( m_radioHAlign->GetSelection() )
|
switch ( m_radioHAlign->GetSelection() )
|
||||||
{
|
{
|
||||||
|
@@ -210,13 +210,6 @@ private:
|
|||||||
// the book containing the test pages
|
// the book containing the test pages
|
||||||
WidgetsBookCtrl *m_book;
|
WidgetsBookCtrl *m_book;
|
||||||
|
|
||||||
#if wxUSE_MENUS
|
|
||||||
// last chosen fg/bg colours and font
|
|
||||||
wxColour m_colFg,
|
|
||||||
m_colBg;
|
|
||||||
wxFont m_font;
|
|
||||||
#endif // wxUSE_MENUS
|
|
||||||
|
|
||||||
// any class wishing to process wxWidgets events must use this macro
|
// any class wishing to process wxWidgets events must use this macro
|
||||||
wxDECLARE_EVENT_TABLE();
|
wxDECLARE_EVENT_TABLE();
|
||||||
};
|
};
|
||||||
@@ -736,6 +729,8 @@ void WidgetsFrame::OnPageChanged(WidgetsBookCtrlEvent& event)
|
|||||||
}
|
}
|
||||||
page->SetSize(size);
|
page->SetSize(size);
|
||||||
}
|
}
|
||||||
|
// re-apply the attributes to the widget(s)
|
||||||
|
page->SetUpWidget();
|
||||||
|
|
||||||
event.Skip();
|
event.Skip();
|
||||||
}
|
}
|
||||||
@@ -755,31 +750,21 @@ void WidgetsFrame::OnGoToPage(wxCommandEvent& event)
|
|||||||
|
|
||||||
void WidgetsFrame::OnSetTooltip(wxCommandEvent& WXUNUSED(event))
|
void WidgetsFrame::OnSetTooltip(wxCommandEvent& WXUNUSED(event))
|
||||||
{
|
{
|
||||||
static wxString s_tip = wxT("This is a tooltip");
|
|
||||||
|
|
||||||
wxTextEntryDialog dialog
|
wxTextEntryDialog dialog
|
||||||
(
|
(
|
||||||
this,
|
this,
|
||||||
wxT("Tooltip text (may use \\n, leave empty to remove): "),
|
wxT("Tooltip text (may use \\n, leave empty to remove): "),
|
||||||
wxT("Widgets sample"),
|
wxT("Widgets sample"),
|
||||||
s_tip
|
WidgetsPage::GetAttrs().m_tooltip
|
||||||
);
|
);
|
||||||
|
|
||||||
if ( dialog.ShowModal() != wxID_OK )
|
if ( dialog.ShowModal() != wxID_OK )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
s_tip = dialog.GetValue();
|
WidgetsPage::GetAttrs().m_tooltip = dialog.GetValue();
|
||||||
s_tip.Replace(wxT("\\n"), wxT("\n"));
|
WidgetsPage::GetAttrs().m_tooltip.Replace(wxT("\\n"), wxT("\n"));
|
||||||
|
|
||||||
WidgetsPage *page = CurrentPage();
|
CurrentPage()->SetUpWidget();
|
||||||
|
|
||||||
const Widgets widgets = page->GetWidgets();
|
|
||||||
for ( Widgets::const_iterator it = widgets.begin();
|
|
||||||
it != widgets.end();
|
|
||||||
++it )
|
|
||||||
{
|
|
||||||
(*it)->SetToolTip(s_tip);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // wxUSE_TOOLTIPS
|
#endif // wxUSE_TOOLTIPS
|
||||||
@@ -809,46 +794,32 @@ void WidgetsFrame::OnSetFgCol(wxCommandEvent& WXUNUSED(event))
|
|||||||
// allow for debugging the default colour the first time this is called
|
// allow for debugging the default colour the first time this is called
|
||||||
WidgetsPage *page = CurrentPage();
|
WidgetsPage *page = CurrentPage();
|
||||||
|
|
||||||
if (!m_colFg.IsOk())
|
if (!WidgetsPage::GetAttrs().m_colFg.IsOk())
|
||||||
m_colFg = page->GetForegroundColour();
|
WidgetsPage::GetAttrs().m_colFg = page->GetForegroundColour();
|
||||||
|
|
||||||
wxColour col = GetColourFromUser(this, m_colFg);
|
wxColour col = GetColourFromUser(this, WidgetsPage::GetAttrs().m_colFg);
|
||||||
if ( !col.IsOk() )
|
if ( !col.IsOk() )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
m_colFg = col;
|
WidgetsPage::GetAttrs().m_colFg = col;
|
||||||
|
|
||||||
const Widgets widgets = page->GetWidgets();
|
page->SetUpWidget();
|
||||||
for ( Widgets::const_iterator it = widgets.begin();
|
|
||||||
it != widgets.end();
|
|
||||||
++it )
|
|
||||||
{
|
|
||||||
(*it)->SetForegroundColour(m_colFg);
|
|
||||||
(*it)->Refresh();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void WidgetsFrame::OnSetBgCol(wxCommandEvent& WXUNUSED(event))
|
void WidgetsFrame::OnSetBgCol(wxCommandEvent& WXUNUSED(event))
|
||||||
{
|
{
|
||||||
WidgetsPage *page = CurrentPage();
|
WidgetsPage *page = CurrentPage();
|
||||||
|
|
||||||
if ( !m_colBg.IsOk() )
|
if ( !WidgetsPage::GetAttrs().m_colBg.IsOk() )
|
||||||
m_colBg = page->GetBackgroundColour();
|
WidgetsPage::GetAttrs().m_colBg = page->GetBackgroundColour();
|
||||||
|
|
||||||
wxColour col = GetColourFromUser(this, m_colBg);
|
wxColour col = GetColourFromUser(this, WidgetsPage::GetAttrs().m_colBg);
|
||||||
if ( !col.IsOk() )
|
if ( !col.IsOk() )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
m_colBg = col;
|
WidgetsPage::GetAttrs().m_colBg = col;
|
||||||
|
|
||||||
const Widgets widgets = page->GetWidgets();
|
page->SetUpWidget();
|
||||||
for ( Widgets::const_iterator it = widgets.begin();
|
|
||||||
it != widgets.end();
|
|
||||||
++it )
|
|
||||||
{
|
|
||||||
(*it)->SetBackgroundColour(m_colBg);
|
|
||||||
(*it)->Refresh();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void WidgetsFrame::OnSetPageBg(wxCommandEvent& WXUNUSED(event))
|
void WidgetsFrame::OnSetPageBg(wxCommandEvent& WXUNUSED(event))
|
||||||
@@ -857,8 +828,9 @@ void WidgetsFrame::OnSetPageBg(wxCommandEvent& WXUNUSED(event))
|
|||||||
if ( !col.IsOk() )
|
if ( !col.IsOk() )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
CurrentPage()->SetBackgroundColour(col);
|
WidgetsPage::GetAttrs().m_colPageBg = col;
|
||||||
CurrentPage()->Refresh();
|
|
||||||
|
CurrentPage()->SetUpWidget();
|
||||||
}
|
}
|
||||||
|
|
||||||
void WidgetsFrame::OnSetFont(wxCommandEvent& WXUNUSED(event))
|
void WidgetsFrame::OnSetFont(wxCommandEvent& WXUNUSED(event))
|
||||||
@@ -866,24 +838,16 @@ void WidgetsFrame::OnSetFont(wxCommandEvent& WXUNUSED(event))
|
|||||||
#if wxUSE_FONTDLG
|
#if wxUSE_FONTDLG
|
||||||
WidgetsPage *page = CurrentPage();
|
WidgetsPage *page = CurrentPage();
|
||||||
|
|
||||||
if (!m_font.IsOk())
|
if (!WidgetsPage::GetAttrs().m_font.IsOk())
|
||||||
m_font = page->GetFont();
|
WidgetsPage::GetAttrs().m_font = page->GetFont();
|
||||||
|
|
||||||
wxFont font = wxGetFontFromUser(this, m_font);
|
wxFont font = wxGetFontFromUser(this, WidgetsPage::GetAttrs().m_font);
|
||||||
if ( !font.IsOk() )
|
if ( !font.IsOk() )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
m_font = font;
|
WidgetsPage::GetAttrs().m_font = font;
|
||||||
|
|
||||||
const Widgets widgets = page->GetWidgets();
|
|
||||||
for ( Widgets::const_iterator it = widgets.begin();
|
|
||||||
it != widgets.end();
|
|
||||||
++it )
|
|
||||||
{
|
|
||||||
(*it)->SetFont(m_font);
|
|
||||||
(*it)->Refresh();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
page->SetUpWidget();
|
||||||
// The best size of the widget could have changed after changing its font,
|
// The best size of the widget could have changed after changing its font,
|
||||||
// so re-layout to show it correctly.
|
// so re-layout to show it correctly.
|
||||||
page->Layout();
|
page->Layout();
|
||||||
@@ -894,13 +858,9 @@ void WidgetsFrame::OnSetFont(wxCommandEvent& WXUNUSED(event))
|
|||||||
|
|
||||||
void WidgetsFrame::OnEnable(wxCommandEvent& event)
|
void WidgetsFrame::OnEnable(wxCommandEvent& event)
|
||||||
{
|
{
|
||||||
const Widgets widgets = CurrentPage()->GetWidgets();
|
WidgetsPage::GetAttrs().m_enabled = event.IsChecked();
|
||||||
for ( Widgets::const_iterator it = widgets.begin();
|
|
||||||
it != widgets.end();
|
CurrentPage()->SetUpWidget();
|
||||||
++it )
|
|
||||||
{
|
|
||||||
(*it)->Enable(event.IsChecked());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void WidgetsFrame::OnSetBorder(wxCommandEvent& event)
|
void WidgetsFrame::OnSetBorder(wxCommandEvent& event)
|
||||||
@@ -922,27 +882,22 @@ void WidgetsFrame::OnSetBorder(wxCommandEvent& event)
|
|||||||
case Widgets_BorderDefault: border = wxBORDER_DEFAULT; break;
|
case Widgets_BorderDefault: border = wxBORDER_DEFAULT; break;
|
||||||
}
|
}
|
||||||
|
|
||||||
WidgetsPage::ms_defaultFlags &= ~wxBORDER_MASK;
|
WidgetsPage::GetAttrs().m_defaultFlags &= ~wxBORDER_MASK;
|
||||||
WidgetsPage::ms_defaultFlags |= border;
|
WidgetsPage::GetAttrs().m_defaultFlags |= border;
|
||||||
|
|
||||||
WidgetsPage *page = CurrentPage();
|
WidgetsPage *page = CurrentPage();
|
||||||
|
|
||||||
page->RecreateWidget();
|
page->RecreateWidget();
|
||||||
|
// re-apply the attributes to the widget(s)
|
||||||
|
page->SetUpWidget();
|
||||||
}
|
}
|
||||||
|
|
||||||
void WidgetsFrame::OnToggleLayoutDirection(wxCommandEvent& event)
|
void WidgetsFrame::OnToggleLayoutDirection(wxCommandEvent& event)
|
||||||
{
|
{
|
||||||
wxLayoutDirection dir = event.IsChecked() ? wxLayout_RightToLeft
|
WidgetsPage::GetAttrs().m_dir = event.IsChecked() ? wxLayout_RightToLeft
|
||||||
: wxLayout_LeftToRight;
|
: wxLayout_LeftToRight;
|
||||||
|
|
||||||
const Widgets widgets = CurrentPage()->GetWidgets();
|
CurrentPage()->SetUpWidget();
|
||||||
for ( Widgets::const_iterator it = widgets.begin();
|
|
||||||
it != widgets.end();
|
|
||||||
++it )
|
|
||||||
{
|
|
||||||
(*it)->SetLayoutDirection(dir);
|
|
||||||
(*it)->Refresh();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void WidgetsFrame::OnToggleGlobalBusyCursor(wxCommandEvent& event)
|
void WidgetsFrame::OnToggleGlobalBusyCursor(wxCommandEvent& event)
|
||||||
@@ -955,16 +910,10 @@ void WidgetsFrame::OnToggleGlobalBusyCursor(wxCommandEvent& event)
|
|||||||
|
|
||||||
void WidgetsFrame::OnToggleBusyCursor(wxCommandEvent& event)
|
void WidgetsFrame::OnToggleBusyCursor(wxCommandEvent& event)
|
||||||
{
|
{
|
||||||
wxCursor cursor(*(event.IsChecked() ? wxHOURGLASS_CURSOR
|
WidgetsPage::GetAttrs().m_cursor = *(event.IsChecked() ? wxHOURGLASS_CURSOR
|
||||||
: wxSTANDARD_CURSOR));
|
: wxSTANDARD_CURSOR);
|
||||||
|
|
||||||
const Widgets widgets = CurrentPage()->GetWidgets();
|
CurrentPage()->SetUpWidget();
|
||||||
for ( Widgets::const_iterator it = widgets.begin();
|
|
||||||
it != widgets.end();
|
|
||||||
++it )
|
|
||||||
{
|
|
||||||
(*it)->SetCursor(cursor);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void WidgetsFrame::OnDisableAutoComplete(wxCommandEvent& WXUNUSED(event))
|
void WidgetsFrame::OnDisableAutoComplete(wxCommandEvent& WXUNUSED(event))
|
||||||
@@ -1230,7 +1179,6 @@ WidgetsPageInfo::WidgetsPageInfo(Constructor ctor, const wxChar *label, int cate
|
|||||||
// WidgetsPage
|
// WidgetsPage
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
int WidgetsPage::ms_defaultFlags = wxBORDER_DEFAULT;
|
|
||||||
WidgetsPageInfo *WidgetsPage::ms_widgetPages = NULL;
|
WidgetsPageInfo *WidgetsPage::ms_widgetPages = NULL;
|
||||||
|
|
||||||
WidgetsPage::WidgetsPage(WidgetsBookCtrl *book,
|
WidgetsPage::WidgetsPage(WidgetsBookCtrl *book,
|
||||||
@@ -1250,6 +1198,59 @@ WidgetsPage::WidgetsPage(WidgetsBookCtrl *book,
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* static */
|
||||||
|
WidgetAttributes& WidgetsPage::GetAttrs()
|
||||||
|
{
|
||||||
|
static WidgetAttributes s_attrs;
|
||||||
|
|
||||||
|
return s_attrs;
|
||||||
|
}
|
||||||
|
|
||||||
|
void WidgetsPage::SetUpWidget()
|
||||||
|
{
|
||||||
|
const Widgets widgets = GetWidgets();
|
||||||
|
|
||||||
|
for ( Widgets::const_iterator it = widgets.begin();
|
||||||
|
it != widgets.end();
|
||||||
|
++it )
|
||||||
|
{
|
||||||
|
#if wxUSE_TOOLTIPS
|
||||||
|
(*it)->SetToolTip(GetAttrs().m_tooltip);
|
||||||
|
#endif // wxUSE_TOOLTIPS
|
||||||
|
#if wxUSE_FONTDLG
|
||||||
|
if ( GetAttrs().m_font.IsOk() )
|
||||||
|
{
|
||||||
|
(*it)->SetFont(GetAttrs().m_font);
|
||||||
|
}
|
||||||
|
#endif // wxUSE_FONTDLG
|
||||||
|
if ( GetAttrs().m_colFg.IsOk() )
|
||||||
|
{
|
||||||
|
(*it)->SetForegroundColour(GetAttrs().m_colFg);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( GetAttrs().m_colBg.IsOk() )
|
||||||
|
{
|
||||||
|
(*it)->SetBackgroundColour(GetAttrs().m_colBg);
|
||||||
|
}
|
||||||
|
|
||||||
|
(*it)->SetLayoutDirection(GetAttrs().m_dir);
|
||||||
|
(*it)->Enable(GetAttrs().m_enabled);
|
||||||
|
|
||||||
|
if ( GetAttrs().m_cursor.IsOk() )
|
||||||
|
{
|
||||||
|
(*it)->SetCursor(GetAttrs().m_cursor);
|
||||||
|
}
|
||||||
|
|
||||||
|
(*it)->Refresh();
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( GetAttrs().m_colPageBg.IsOk() )
|
||||||
|
{
|
||||||
|
SetBackgroundColour(GetAttrs().m_colPageBg);
|
||||||
|
Refresh();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
wxSizer *WidgetsPage::CreateSizerWithText(wxControl *control,
|
wxSizer *WidgetsPage::CreateSizerWithText(wxControl *control,
|
||||||
wxWindowID id,
|
wxWindowID id,
|
||||||
wxTextCtrl **ppText)
|
wxTextCtrl **ppText)
|
||||||
|
@@ -89,6 +89,36 @@ typedef wxVector<wxControl *> Widgets;
|
|||||||
// WidgetsPage: a book page demonstrating some widget
|
// 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
|
class WidgetsPage : public wxPanel
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -119,8 +149,11 @@ public:
|
|||||||
// this is currently used only to take into account the border flags
|
// this is currently used only to take into account the border flags
|
||||||
virtual void RecreateWidget() = 0;
|
virtual void RecreateWidget() = 0;
|
||||||
|
|
||||||
// the default flags for the widget, currently only contains border flags
|
// apply current atrributes to the widget(s)
|
||||||
static int ms_defaultFlags;
|
void SetUpWidget();
|
||||||
|
|
||||||
|
// the default attributes for the widget
|
||||||
|
static WidgetAttributes& GetAttrs();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// several helper functions for page creation
|
// several helper functions for page creation
|
||||||
|
Reference in New Issue
Block a user