These styles allow to use a smaller browse button as the standard one takes
too much space, often leaving too little of it for the more important text
control part.
Notice that both styles are, in fact, equal to wxPB_SMALL but only file and
directory pickers currently use it as it doesn't make sense for the colour and
font pickers.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@68921
c3d73ce0-8a6f-49c7-b76d-
6d57e0e08775
- Fix stock labels when not using mnemonics for Chinese (cw.ahbong).
- Added wxComboBox::IsListEmpty() and IsTextEmpty().
- Added wxDataViewCtrl::GetSelectedItemsCount() and HasSelection().
- Fix stock labels when not using mnemonics for Chinese (cw.ahbong).
- Added wxComboBox::IsListEmpty() and IsTextEmpty().
- Added wxDataViewCtrl::GetSelectedItemsCount() and HasSelection().
+- Added wxFLP_SMALL and wxDIRP_SMALL styles.
#define wxFLP_OVERWRITE_PROMPT 0x1000
#define wxFLP_FILE_MUST_EXIST 0x2000
#define wxFLP_CHANGE_DIR 0x4000
#define wxFLP_OVERWRITE_PROMPT 0x1000
#define wxFLP_FILE_MUST_EXIST 0x2000
#define wxFLP_CHANGE_DIR 0x4000
+#define wxFLP_SMALL wxPB_SMALL
// NOTE: wxMULTIPLE is not supported !
#define wxDIRP_DIR_MUST_EXIST 0x0008
#define wxDIRP_CHANGE_DIR 0x0010
// NOTE: wxMULTIPLE is not supported !
#define wxDIRP_DIR_MUST_EXIST 0x0008
#define wxDIRP_CHANGE_DIR 0x0010
+#define wxDIRP_SMALL wxPB_SMALL
// map platform-dependent controls which implement the wxFileDirPickerWidgetBase
// map platform-dependent controls which implement the wxFileDirPickerWidgetBase
// extracts the style for our picker from wxFileDirPickerCtrlBase's style
long GetPickerStyle(long style) const
{
// extracts the style for our picker from wxFileDirPickerCtrlBase's style
long GetPickerStyle(long style) const
{
- return (style & (wxFLP_OPEN|wxFLP_SAVE|wxFLP_OVERWRITE_PROMPT|
- wxFLP_FILE_MUST_EXIST|wxFLP_CHANGE_DIR|wxFLP_USE_TEXTCTRL));
+ return style & (wxFLP_OPEN |
+ wxFLP_SAVE |
+ wxFLP_OVERWRITE_PROMPT |
+ wxFLP_FILE_MUST_EXIST |
+ wxFLP_CHANGE_DIR |
+ wxFLP_USE_TEXTCTRL |
+ wxFLP_SMALL);
// extracts the style for our picker from wxFileDirPickerCtrlBase's style
long GetPickerStyle(long style) const
// extracts the style for our picker from wxFileDirPickerCtrlBase's style
long GetPickerStyle(long style) const
- { return (style & (wxDIRP_DIR_MUST_EXIST|wxDIRP_CHANGE_DIR|wxDIRP_USE_TEXTCTRL)); }
+ {
+ return style & (wxDIRP_DIR_MUST_EXIST |
+ wxDIRP_CHANGE_DIR |
+ wxDIRP_USE_TEXTCTRL |
+ wxDIRP_SMALL);
+ }
private:
DECLARE_DYNAMIC_CLASS(wxDirPickerCtrl)
private:
DECLARE_DYNAMIC_CLASS(wxDirPickerCtrl)
// ----------------------------------------------------------------------------
#define wxPB_USE_TEXTCTRL 0x0002
// ----------------------------------------------------------------------------
#define wxPB_USE_TEXTCTRL 0x0002
+#define wxPB_SMALL 0x8000
class WXDLLIMPEXP_CORE wxPickerBase : public wxNavigationEnabled<wxControl>
{
class WXDLLIMPEXP_CORE wxPickerBase : public wxNavigationEnabled<wxControl>
{
existing file.
@style{wxFLP_CHANGE_DIR}
Change current working directory on each user file selection change.
existing file.
@style{wxFLP_CHANGE_DIR}
Change current working directory on each user file selection change.
+ @style{wxFLP_SMALL}
+ Use smaller version of the control with a small "..." button instead
+ of the normal "Browse" one. This flag is new since wxWidgets 2.9.3.
support its absence.
@style{wxDIRP_CHANGE_DIR}
Change current working directory on each user directory selection change.
support its absence.
@style{wxDIRP_CHANGE_DIR}
Change current working directory on each user directory selection change.
+ @style{wxDIRP_SMALL}
+ Use smaller version of the control with a small "..." button instead
+ of the normal "Browse" one. This flag is new since wxWidgets 2.9.3.
@endStyleTable
@beginEventEmissionTable{wxFileDirPickerEvent}
@endStyleTable
@beginEventEmissionTable{wxFileDirPickerEvent}
wxCheckBox *m_chkDirTextCtrl,
*m_chkDirChangeDir,
wxCheckBox *m_chkDirTextCtrl,
*m_chkDirChangeDir,
+ *m_chkDirMustExist,
+ *m_chkSmall;
wxBoxSizer *m_sizer;
private:
wxBoxSizer *m_sizer;
private:
m_chkDirTextCtrl = CreateCheckBoxAndAddToSizer(dirbox, wxT("With textctrl"), false);
m_chkDirMustExist = CreateCheckBoxAndAddToSizer(dirbox, wxT("Dir must exist"), false);
m_chkDirChangeDir = CreateCheckBoxAndAddToSizer(dirbox, wxT("Change working dir"), false);
m_chkDirTextCtrl = CreateCheckBoxAndAddToSizer(dirbox, wxT("With textctrl"), false);
m_chkDirMustExist = CreateCheckBoxAndAddToSizer(dirbox, wxT("Dir must exist"), false);
m_chkDirChangeDir = CreateCheckBoxAndAddToSizer(dirbox, wxT("Change working dir"), false);
+ m_chkSmall = CreateCheckBoxAndAddToSizer(dirbox, "&Small version", false);
boxleft->Add(dirbox, 0, wxALL|wxGROW, 5);
boxleft->Add(new wxButton(this, PickerPage_Reset, wxT("&Reset")),
boxleft->Add(dirbox, 0, wxALL|wxGROW, 5);
boxleft->Add(new wxButton(this, PickerPage_Reset, wxT("&Reset")),
if ( m_chkDirChangeDir->GetValue() )
style |= wxDIRP_CHANGE_DIR;
if ( m_chkDirChangeDir->GetValue() )
style |= wxDIRP_CHANGE_DIR;
+ if ( m_chkSmall->GetValue() )
+ style |= wxDIRP_SMALL;
+
m_chkDirTextCtrl->SetValue((wxDIRP_DEFAULT_STYLE & wxDIRP_USE_TEXTCTRL) != 0);
m_chkDirMustExist->SetValue((wxDIRP_DEFAULT_STYLE & wxDIRP_DIR_MUST_EXIST) != 0);
m_chkDirChangeDir->SetValue((wxDIRP_DEFAULT_STYLE & wxDIRP_CHANGE_DIR) != 0);
m_chkDirTextCtrl->SetValue((wxDIRP_DEFAULT_STYLE & wxDIRP_USE_TEXTCTRL) != 0);
m_chkDirMustExist->SetValue((wxDIRP_DEFAULT_STYLE & wxDIRP_DIR_MUST_EXIST) != 0);
m_chkDirChangeDir->SetValue((wxDIRP_DEFAULT_STYLE & wxDIRP_CHANGE_DIR) != 0);
+ m_chkSmall->SetValue((wxFLP_DEFAULT_STYLE & wxDIRP_SMALL) != 0);
{
if (event.GetEventObject() == m_chkDirTextCtrl ||
event.GetEventObject() == m_chkDirChangeDir ||
{
if (event.GetEventObject() == m_chkDirTextCtrl ||
event.GetEventObject() == m_chkDirChangeDir ||
- event.GetEventObject() == m_chkDirMustExist)
+ event.GetEventObject() == m_chkDirMustExist ||
+ event.GetEventObject() == m_chkSmall)
wxCheckBox *m_chkFileTextCtrl,
*m_chkFileOverwritePrompt,
*m_chkFileMustExist,
wxCheckBox *m_chkFileTextCtrl,
*m_chkFileOverwritePrompt,
*m_chkFileMustExist,
+ *m_chkFileChangeDir,
+ *m_chkSmall;
wxRadioBox *m_radioFilePickerMode;
wxBoxSizer *m_sizer;
wxRadioBox *m_radioFilePickerMode;
wxBoxSizer *m_sizer;
m_chkFileOverwritePrompt = CreateCheckBoxAndAddToSizer(filebox, wxT("Overwrite prompt"), false);
m_chkFileMustExist = CreateCheckBoxAndAddToSizer(filebox, wxT("File must exist"), false);
m_chkFileChangeDir = CreateCheckBoxAndAddToSizer(filebox, wxT("Change working dir"), false);
m_chkFileOverwritePrompt = CreateCheckBoxAndAddToSizer(filebox, wxT("Overwrite prompt"), false);
m_chkFileMustExist = CreateCheckBoxAndAddToSizer(filebox, wxT("File must exist"), false);
m_chkFileChangeDir = CreateCheckBoxAndAddToSizer(filebox, wxT("Change working dir"), false);
+ m_chkSmall = CreateCheckBoxAndAddToSizer(filebox, "&Small version", false);
+
boxleft->Add(filebox, 0, wxALL|wxGROW, 5);
boxleft->Add(new wxButton(this, PickerPage_Reset, wxT("&Reset")),
boxleft->Add(filebox, 0, wxALL|wxGROW, 5);
boxleft->Add(new wxButton(this, PickerPage_Reset, wxT("&Reset")),
if ( m_chkFileChangeDir->GetValue() )
style |= wxFLP_CHANGE_DIR;
if ( m_chkFileChangeDir->GetValue() )
style |= wxFLP_CHANGE_DIR;
+ if ( m_chkSmall->GetValue() )
+ style |= wxFLP_SMALL;
+
if (m_radioFilePickerMode->GetSelection() == FilePickerMode_Open)
style |= wxFLP_OPEN;
else
if (m_radioFilePickerMode->GetSelection() == FilePickerMode_Open)
style |= wxFLP_OPEN;
else
m_chkFileOverwritePrompt->SetValue((wxFLP_DEFAULT_STYLE & wxFLP_OVERWRITE_PROMPT) != 0);
m_chkFileMustExist->SetValue((wxFLP_DEFAULT_STYLE & wxFLP_FILE_MUST_EXIST) != 0);
m_chkFileChangeDir->SetValue((wxFLP_DEFAULT_STYLE & wxFLP_CHANGE_DIR) != 0);
m_chkFileOverwritePrompt->SetValue((wxFLP_DEFAULT_STYLE & wxFLP_OVERWRITE_PROMPT) != 0);
m_chkFileMustExist->SetValue((wxFLP_DEFAULT_STYLE & wxFLP_FILE_MUST_EXIST) != 0);
m_chkFileChangeDir->SetValue((wxFLP_DEFAULT_STYLE & wxFLP_CHANGE_DIR) != 0);
+ m_chkSmall->SetValue((wxFLP_DEFAULT_STYLE & wxFLP_SMALL) != 0);
UpdateFilePickerMode();
}
UpdateFilePickerMode();
}
if (event.GetEventObject() == m_chkFileTextCtrl ||
event.GetEventObject() == m_chkFileOverwritePrompt ||
event.GetEventObject() == m_chkFileMustExist ||
if (event.GetEventObject() == m_chkFileTextCtrl ||
event.GetEventObject() == m_chkFileOverwritePrompt ||
event.GetEventObject() == m_chkFileMustExist ||
- event.GetEventObject() == m_chkFileChangeDir)
+ event.GetEventObject() == m_chkFileChangeDir ||
+ event.GetEventObject() == m_chkSmall)
RecreatePicker();
if (event.GetEventObject() == m_radioFilePickerMode)
RecreatePicker();
if (event.GetEventObject() == m_radioFilePickerMode)
m_sizer->Add(m_picker, HasTextCtrl() ? 0 : 1, GetDefaultPickerCtrlFlag(), 5);
// For aesthetic reasons, make sure the picker is at least as high as the
m_sizer->Add(m_picker, HasTextCtrl() ? 0 : 1, GetDefaultPickerCtrlFlag(), 5);
// For aesthetic reasons, make sure the picker is at least as high as the
- // associated text control and is always at least square.
- const wxSize pickerBestSize(m_picker->GetBestSize());
- const wxSize textBestSize( HasTextCtrl() ? m_text->GetBestSize() : wxSize());
- wxSize pickerMinSize;
- pickerMinSize.y = wxMax(pickerBestSize.y, textBestSize.y);
- pickerMinSize.x = wxMax(pickerBestSize.x, pickerMinSize.y);
- if ( pickerMinSize != pickerBestSize )
- m_picker->SetMinSize(pickerMinSize);
+ // associated text control and is always at least square, unless we are
+ // explicitly using wxPB_SMALL style to force it to take as little space as
+ // possible.
+ if ( !HasFlag(wxPB_SMALL) )
+ {
+ const wxSize pickerBestSize(m_picker->GetBestSize());
+ const wxSize textBestSize( HasTextCtrl() ? m_text->GetBestSize() : wxSize());
+ wxSize pickerMinSize;
+ pickerMinSize.y = wxMax(pickerBestSize.y, textBestSize.y);
+ pickerMinSize.x = wxMax(pickerBestSize.x, pickerMinSize.y);
+ if ( pickerMinSize != pickerBestSize )
+ m_picker->SetMinSize(pickerMinSize);
+ }
+ // If the special wxPB_SMALL flag is used, ignore the provided label and
+ // use the shortest possible label and the smallest possible button fitting
+ // it.
+ long styleButton = 0;
+ wxString labelButton;
+ if ( m_pickerStyle & wxPB_SMALL )
+ {
+ labelButton = _("...");
+ styleButton = wxBU_EXACTFIT;
+ }
+ else
+ {
+ labelButton = label;
+ }
+
- if ( !wxButton::Create(parent, id, label, pos, size, 0, validator, name) )
+ if ( !wxButton::Create(parent, id, labelButton,
+ pos, size, styleButton, validator, name) )
{
wxFAIL_MSG( wxT("wxGenericFileButton creation failed") );
return false;
{
wxFAIL_MSG( wxT("wxGenericFileButton creation failed") );
return false;
XRC_ADD_STYLE(wxDIRP_USE_TEXTCTRL);
XRC_ADD_STYLE(wxDIRP_DIR_MUST_EXIST);
XRC_ADD_STYLE(wxDIRP_CHANGE_DIR);
XRC_ADD_STYLE(wxDIRP_USE_TEXTCTRL);
XRC_ADD_STYLE(wxDIRP_DIR_MUST_EXIST);
XRC_ADD_STYLE(wxDIRP_CHANGE_DIR);
+ XRC_ADD_STYLE(wxDIRP_SMALL);
XRC_ADD_STYLE(wxDIRP_DEFAULT_STYLE);
AddWindowStyles();
}
XRC_ADD_STYLE(wxDIRP_DEFAULT_STYLE);
AddWindowStyles();
}
XRC_ADD_STYLE(wxFLP_OVERWRITE_PROMPT);
XRC_ADD_STYLE(wxFLP_FILE_MUST_EXIST);
XRC_ADD_STYLE(wxFLP_CHANGE_DIR);
XRC_ADD_STYLE(wxFLP_OVERWRITE_PROMPT);
XRC_ADD_STYLE(wxFLP_FILE_MUST_EXIST);
XRC_ADD_STYLE(wxFLP_CHANGE_DIR);
+ XRC_ADD_STYLE(wxFLP_SMALL);
XRC_ADD_STYLE(wxFLP_DEFAULT_STYLE);
XRC_ADD_STYLE(wxFLP_USE_TEXTCTRL);
AddWindowStyles();
XRC_ADD_STYLE(wxFLP_DEFAULT_STYLE);
XRC_ADD_STYLE(wxFLP_USE_TEXTCTRL);
AddWindowStyles();