Use border style consistently in the widgets sample
Use GetAttrs().m_defaultFlags everywhere when creating the widgets, it was done for some but not all of them before, without any apparent reason. This should make setting various border styles work (for the widgets supporting them).
This commit is contained in:
parent
0acb119ccb
commit
7e8fb1e294
@ -81,9 +81,6 @@ protected:
|
||||
// restore the checkboxes state to the initial values
|
||||
void Reset();
|
||||
|
||||
// get the initial style for the picker of the given kind
|
||||
long GetPickerStyle();
|
||||
|
||||
|
||||
void OnColourChange(wxColourPickerEvent &ev);
|
||||
void OnCheckBox(wxCommandEvent &ev);
|
||||
@ -175,14 +172,7 @@ void ColourPickerWidgetsPage::CreatePicker()
|
||||
{
|
||||
delete m_clrPicker;
|
||||
|
||||
m_clrPicker = new wxColourPickerCtrl(this, PickerPage_Colour, *wxRED,
|
||||
wxDefaultPosition, wxDefaultSize,
|
||||
GetPickerStyle());
|
||||
}
|
||||
|
||||
long ColourPickerWidgetsPage::GetPickerStyle()
|
||||
{
|
||||
long style = 0;
|
||||
long style = GetAttrs().m_defaultFlags;
|
||||
|
||||
if ( m_chkColourTextCtrl->GetValue() )
|
||||
style |= wxCLRP_USE_TEXTCTRL;
|
||||
@ -193,7 +183,9 @@ long ColourPickerWidgetsPage::GetPickerStyle()
|
||||
if ( m_chkColourShowAlpha->GetValue() )
|
||||
style |= wxCLRP_SHOW_ALPHA;
|
||||
|
||||
return style;
|
||||
m_clrPicker = new wxColourPickerCtrl(this, PickerPage_Colour, *wxRED,
|
||||
wxDefaultPosition, wxDefaultSize,
|
||||
style);
|
||||
}
|
||||
|
||||
void ColourPickerWidgetsPage::RecreatePicker()
|
||||
|
@ -243,7 +243,7 @@ void DatePickerWidgetsPage::CreateDatePicker()
|
||||
|
||||
delete m_datePicker;
|
||||
|
||||
long style = 0;
|
||||
long style = GetAttrs().m_defaultFlags;
|
||||
switch ( m_radioKind->GetSelection() )
|
||||
{
|
||||
case 0:
|
||||
|
@ -246,18 +246,27 @@ void DirCtrlWidgetsPage::CreateDirCtrl()
|
||||
{
|
||||
wxWindowUpdateLocker noUpdates(this);
|
||||
|
||||
long style = GetAttrs().m_defaultFlags;
|
||||
if ( m_chkDirOnly->IsChecked() )
|
||||
style |= wxDIRCTRL_DIR_ONLY;
|
||||
if ( m_chk3D->IsChecked() )
|
||||
style |= wxDIRCTRL_3D_INTERNAL;
|
||||
if ( m_chkFirst->IsChecked() )
|
||||
style |= wxDIRCTRL_SELECT_FIRST;
|
||||
if ( m_chkFilters->IsChecked() )
|
||||
style |= wxDIRCTRL_SHOW_FILTERS;
|
||||
if ( m_chkLabels->IsChecked() )
|
||||
style |= wxDIRCTRL_EDIT_LABELS;
|
||||
if ( m_chkMulti->IsChecked() )
|
||||
style |= wxDIRCTRL_MULTIPLE;
|
||||
|
||||
wxGenericDirCtrl *dirCtrl = new wxGenericDirCtrl(
|
||||
this,
|
||||
DirCtrlPage_Ctrl,
|
||||
wxDirDialogDefaultFolderStr,
|
||||
wxDefaultPosition,
|
||||
wxDefaultSize,
|
||||
( m_chkDirOnly->IsChecked() ? wxDIRCTRL_DIR_ONLY : 0 ) |
|
||||
( m_chk3D->IsChecked() ? wxDIRCTRL_3D_INTERNAL : 0 ) |
|
||||
( m_chkFirst->IsChecked() ? wxDIRCTRL_SELECT_FIRST : 0 ) |
|
||||
( m_chkFilters->IsChecked() ? wxDIRCTRL_SHOW_FILTERS : 0 ) |
|
||||
( m_chkLabels->IsChecked() ? wxDIRCTRL_EDIT_LABELS : 0 ) |
|
||||
( m_chkMulti->IsChecked() ? wxDIRCTRL_MULTIPLE : 0)
|
||||
style
|
||||
);
|
||||
|
||||
wxString filter;
|
||||
|
@ -83,9 +83,6 @@ protected:
|
||||
// restore the checkboxes state to the initial values
|
||||
void Reset();
|
||||
|
||||
// get the initial style for the picker of the given kind
|
||||
long GetPickerStyle();
|
||||
|
||||
|
||||
void OnDirChange(wxFileDirPickerEvent &ev);
|
||||
void OnCheckBox(wxCommandEvent &ev);
|
||||
@ -194,15 +191,7 @@ void DirPickerWidgetsPage::CreatePicker()
|
||||
{
|
||||
delete m_dirPicker;
|
||||
|
||||
m_dirPicker = new wxDirPickerCtrl(this, PickerPage_Dir,
|
||||
wxGetHomeDir(), wxT("Hello!"),
|
||||
wxDefaultPosition, wxDefaultSize,
|
||||
GetPickerStyle());
|
||||
}
|
||||
|
||||
long DirPickerWidgetsPage::GetPickerStyle()
|
||||
{
|
||||
long style = 0;
|
||||
long style = GetAttrs().m_defaultFlags;
|
||||
|
||||
if ( m_chkDirTextCtrl->GetValue() )
|
||||
style |= wxDIRP_USE_TEXTCTRL;
|
||||
@ -216,7 +205,10 @@ long DirPickerWidgetsPage::GetPickerStyle()
|
||||
if ( m_chkSmall->GetValue() )
|
||||
style |= wxDIRP_SMALL;
|
||||
|
||||
return style;
|
||||
m_dirPicker = new wxDirPickerCtrl(this, PickerPage_Dir,
|
||||
wxGetHomeDir(), wxT("Hello!"),
|
||||
wxDefaultPosition, wxDefaultSize,
|
||||
style);
|
||||
}
|
||||
|
||||
void DirPickerWidgetsPage::RecreatePicker()
|
||||
|
@ -178,7 +178,7 @@ void EditableListboxWidgetsPage::Reset()
|
||||
|
||||
void EditableListboxWidgetsPage::CreateLbox()
|
||||
{
|
||||
int flags = 0;
|
||||
long flags = GetAttrs().m_defaultFlags;
|
||||
|
||||
if ( m_chkAllowNew->GetValue() )
|
||||
flags |= wxEL_ALLOW_NEW;
|
||||
|
@ -227,11 +227,14 @@ void FileCtrlWidgetsPage::CreateFileCtrl()
|
||||
{
|
||||
wxWindowUpdateLocker noUpdates( this );
|
||||
|
||||
const int style =
|
||||
( m_radioFileCtrlMode->GetSelection() == FileCtrlMode_Open ?
|
||||
wxFC_OPEN : wxFC_SAVE ) |
|
||||
( m_chkMultiple->IsChecked() ? wxFC_MULTIPLE : 0 ) |
|
||||
( m_chkNoShowHidden->IsChecked() ? wxFC_NOSHOWHIDDEN : 0 );
|
||||
long style = GetAttrs().m_defaultFlags;
|
||||
style |= m_radioFileCtrlMode->GetSelection() == FileCtrlMode_Open
|
||||
? wxFC_OPEN
|
||||
: wxFC_SAVE;
|
||||
if ( m_chkMultiple->IsChecked() )
|
||||
style |= wxFC_MULTIPLE;
|
||||
if ( m_chkNoShowHidden->IsChecked() )
|
||||
style |= wxFC_NOSHOWHIDDEN;
|
||||
|
||||
wxFileCtrl *fileCtrl = new wxFileCtrl(
|
||||
this,
|
||||
|
@ -90,9 +90,6 @@ protected:
|
||||
// restore the checkboxes state to the initial values
|
||||
void Reset();
|
||||
|
||||
// get the initial style for the picker of the given kind
|
||||
long GetPickerStyle();
|
||||
|
||||
// update filepicker radiobox
|
||||
void UpdateFilePickerMode();
|
||||
|
||||
@ -223,17 +220,7 @@ void FilePickerWidgetsPage::CreatePicker()
|
||||
{
|
||||
delete m_filePicker;
|
||||
|
||||
// pass an empty string as initial file
|
||||
m_filePicker = new wxFilePickerCtrl(this, PickerPage_File,
|
||||
wxEmptyString,
|
||||
wxT("Hello!"), wxT("*"),
|
||||
wxDefaultPosition, wxDefaultSize,
|
||||
GetPickerStyle());
|
||||
}
|
||||
|
||||
long FilePickerWidgetsPage::GetPickerStyle()
|
||||
{
|
||||
long style = 0;
|
||||
long style = GetAttrs().m_defaultFlags;
|
||||
|
||||
if ( m_chkFileTextCtrl->GetValue() )
|
||||
style |= wxFLP_USE_TEXTCTRL;
|
||||
@ -255,7 +242,12 @@ long FilePickerWidgetsPage::GetPickerStyle()
|
||||
else
|
||||
style |= wxFLP_SAVE;
|
||||
|
||||
return style;
|
||||
// pass an empty string as initial file
|
||||
m_filePicker = new wxFilePickerCtrl(this, PickerPage_File,
|
||||
wxEmptyString,
|
||||
wxT("Hello!"), wxT("*"),
|
||||
wxDefaultPosition, wxDefaultSize,
|
||||
style);
|
||||
}
|
||||
|
||||
void FilePickerWidgetsPage::RecreatePicker()
|
||||
|
@ -81,9 +81,6 @@ protected:
|
||||
// restore the checkboxes state to the initial values
|
||||
void Reset();
|
||||
|
||||
// get the initial style for the picker of the given kind
|
||||
long GetPickerStyle();
|
||||
|
||||
|
||||
void OnFontChange(wxFontPickerEvent &ev);
|
||||
void OnCheckBox(wxCommandEvent &ev);
|
||||
@ -175,15 +172,7 @@ void FontPickerWidgetsPage::CreatePicker()
|
||||
{
|
||||
delete m_fontPicker;
|
||||
|
||||
m_fontPicker = new wxFontPickerCtrl(this, PickerPage_Font,
|
||||
*wxSWISS_FONT,
|
||||
wxDefaultPosition, wxDefaultSize,
|
||||
GetPickerStyle());
|
||||
}
|
||||
|
||||
long FontPickerWidgetsPage::GetPickerStyle()
|
||||
{
|
||||
long style = 0;
|
||||
long style = GetAttrs().m_defaultFlags;
|
||||
|
||||
if ( m_chkFontTextCtrl->GetValue() )
|
||||
style |= wxFNTP_USE_TEXTCTRL;
|
||||
@ -192,9 +181,12 @@ long FontPickerWidgetsPage::GetPickerStyle()
|
||||
style |= wxFNTP_USEFONT_FOR_LABEL;
|
||||
|
||||
if ( m_chkFontDescAsLabel->GetValue() )
|
||||
style |= wxFNTP_FONTDESC_AS_LABEL;
|
||||
style |= wxFNTP_FONTDESC_AS_LABEL;
|
||||
|
||||
return style;
|
||||
m_fontPicker = new wxFontPickerCtrl(this, PickerPage_Font,
|
||||
*wxSWISS_FONT,
|
||||
wxDefaultPosition, wxDefaultSize,
|
||||
style);
|
||||
}
|
||||
|
||||
void FontPickerWidgetsPage::RecreatePicker()
|
||||
|
@ -99,7 +99,7 @@ protected:
|
||||
|
||||
// (re)create the hyperctrl
|
||||
void CreateHyperlink();
|
||||
void CreateHyperlinkLong(long);
|
||||
void CreateHyperlinkLong(long align);
|
||||
|
||||
// the controls
|
||||
// ------------
|
||||
@ -259,6 +259,9 @@ void HyperlinkWidgetsPage::CreateHyperlink()
|
||||
{
|
||||
const wxString label = m_hyperlink->GetLabel();
|
||||
const wxString url = m_hyperlink->GetURL();
|
||||
long style = GetAttrs().m_defaultFlags;
|
||||
|
||||
style |= wxHL_DEFAULT_STYLE & ~wxBORDER_MASK;
|
||||
|
||||
wxGenericHyperlinkCtrl *hyp;
|
||||
if (m_checkGeneric->IsChecked())
|
||||
@ -266,14 +269,20 @@ void HyperlinkWidgetsPage::CreateHyperlink()
|
||||
hyp = new wxGenericHyperlinkCtrl(this,
|
||||
HyperlinkPage_Ctrl,
|
||||
label,
|
||||
url);
|
||||
url,
|
||||
wxDefaultPosition,
|
||||
wxDefaultSize,
|
||||
style);
|
||||
}
|
||||
else
|
||||
{
|
||||
hyp = new wxHyperlinkCtrl(this,
|
||||
HyperlinkPage_Ctrl,
|
||||
label,
|
||||
url);
|
||||
url,
|
||||
wxDefaultPosition,
|
||||
wxDefaultSize,
|
||||
style);
|
||||
}
|
||||
|
||||
// update sizer's child window
|
||||
@ -287,9 +296,11 @@ void HyperlinkWidgetsPage::CreateHyperlink()
|
||||
GetSizer()->Layout();
|
||||
}
|
||||
|
||||
void HyperlinkWidgetsPage::CreateHyperlinkLong(long style)
|
||||
void HyperlinkWidgetsPage::CreateHyperlinkLong(long align)
|
||||
{
|
||||
style = (wxHL_DEFAULT_STYLE & ~wxHL_ALIGN_CENTRE)|style;
|
||||
long style = GetAttrs().m_defaultFlags;
|
||||
style |= align;
|
||||
style |= wxHL_DEFAULT_STYLE & ~(wxHL_ALIGN_CENTRE | wxBORDER_MASK);
|
||||
|
||||
wxGenericHyperlinkCtrl *hyp;
|
||||
if (m_checkGeneric->IsChecked())
|
||||
|
@ -68,7 +68,6 @@ class SearchCtrlWidgetsPage : public WidgetsPage
|
||||
{
|
||||
public:
|
||||
SearchCtrlWidgetsPage(WidgetsBookCtrl *book, wxImageList *imaglist);
|
||||
virtual ~SearchCtrlWidgetsPage(){};
|
||||
|
||||
virtual wxWindow *GetWidget() const wxOVERRIDE { return m_srchCtrl; }
|
||||
virtual wxTextEntryBase *GetTextEntry() const wxOVERRIDE { return m_srchCtrl; }
|
||||
@ -176,7 +175,7 @@ void SearchCtrlWidgetsPage::CreateControl()
|
||||
if (m_srchCtrl)
|
||||
m_srchCtrl->Destroy();
|
||||
|
||||
int style = 0;
|
||||
long style = GetAttrs().m_defaultFlags;
|
||||
|
||||
m_srchCtrl = new wxSearchCtrl(this, -1, wxEmptyString, wxDefaultPosition,
|
||||
wxSize(150, -1), style);
|
||||
|
@ -132,10 +132,21 @@ void StatBmpWidgetsPage::RecreateWidget()
|
||||
wxLogMessage("Reading image from file '%s' failed.", filepath.c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
long style = GetAttrs().m_defaultFlags;
|
||||
|
||||
if (m_radio->GetSelection() == 0)
|
||||
m_statbmp = new wxStaticBitmap(this, wxID_ANY, wxBitmap(image));
|
||||
{
|
||||
m_statbmp = new wxStaticBitmap(this, wxID_ANY, wxBitmap(image),
|
||||
wxDefaultPosition, wxDefaultSize,
|
||||
style);
|
||||
}
|
||||
else
|
||||
m_statbmp = new wxGenericStaticBitmap(this, wxID_ANY, wxBitmap(image));
|
||||
{
|
||||
m_statbmp = new wxGenericStaticBitmap(this, wxID_ANY, wxBitmap(image),
|
||||
wxDefaultPosition, wxDefaultSize,
|
||||
style);
|
||||
}
|
||||
|
||||
wxStaticBitmapBase::ScaleMode scaleMode = (wxStaticBitmapBase::ScaleMode) m_scaleRadio->GetSelection();
|
||||
m_statbmp->SetScaleMode(scaleMode);
|
||||
|
@ -195,7 +195,11 @@ void TimePickerWidgetsPage::CreateTimePicker()
|
||||
|
||||
delete m_timePicker;
|
||||
|
||||
m_timePicker = new wxTimePickerCtrl(this, TimePickerPage_Picker, value);
|
||||
long style = GetAttrs().m_defaultFlags;
|
||||
|
||||
m_timePicker = new wxTimePickerCtrl(this, TimePickerPage_Picker, value,
|
||||
wxDefaultPosition, wxDefaultSize,
|
||||
style);
|
||||
|
||||
m_sizerTimePicker->Add(0, 0, 1, wxCENTRE);
|
||||
m_sizerTimePicker->Add(m_timePicker, 1, wxCENTRE);
|
||||
|
@ -115,7 +115,7 @@ struct WidgetAttributes
|
||||
wxWindowVariant m_variant;
|
||||
wxCursor m_cursor;
|
||||
// the default flags, currently only contains border flags
|
||||
int m_defaultFlags;
|
||||
long m_defaultFlags;
|
||||
};
|
||||
|
||||
class WidgetsPage : public wxPanel
|
||||
|
Loading…
Reference in New Issue
Block a user