Added wxFLP_SMALL and wxDIRP_SMALL styles for wx{File,Dir}PickerCtrl.
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
This commit is contained in:
parent
ea7ff9ad2a
commit
75bc8b3454
@ -465,6 +465,7 @@ All (GUI):
|
||||
- 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.
|
||||
|
||||
OSX:
|
||||
|
||||
|
@ -109,12 +109,14 @@ protected:
|
||||
#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
|
||||
#define wxDIRP_SMALL wxPB_SMALL
|
||||
|
||||
|
||||
// map platform-dependent controls which implement the wxFileDirPickerWidgetBase
|
||||
@ -300,8 +302,13 @@ protected:
|
||||
// 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);
|
||||
}
|
||||
|
||||
private:
|
||||
@ -396,7 +403,12 @@ protected:
|
||||
|
||||
// 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)
|
||||
|
@ -31,6 +31,7 @@ extern WXDLLIMPEXP_DATA_CORE(const char) wxButtonNameStr[];
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#define wxPB_USE_TEXTCTRL 0x0002
|
||||
#define wxPB_SMALL 0x8000
|
||||
|
||||
class WXDLLIMPEXP_CORE wxPickerBase : public wxNavigationEnabled<wxControl>
|
||||
{
|
||||
|
@ -37,6 +37,9 @@
|
||||
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.
|
||||
@endStyleTable
|
||||
|
||||
|
||||
@ -161,6 +164,9 @@ public:
|
||||
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}
|
||||
|
@ -100,7 +100,8 @@ protected:
|
||||
|
||||
wxCheckBox *m_chkDirTextCtrl,
|
||||
*m_chkDirChangeDir,
|
||||
*m_chkDirMustExist;
|
||||
*m_chkDirMustExist,
|
||||
*m_chkSmall;
|
||||
wxBoxSizer *m_sizer;
|
||||
|
||||
private:
|
||||
@ -148,6 +149,7 @@ void DirPickerWidgetsPage::CreateContent()
|
||||
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")),
|
||||
@ -196,6 +198,9 @@ long DirPickerWidgetsPage::GetPickerStyle()
|
||||
if ( m_chkDirChangeDir->GetValue() )
|
||||
style |= wxDIRP_CHANGE_DIR;
|
||||
|
||||
if ( m_chkSmall->GetValue() )
|
||||
style |= wxDIRP_SMALL;
|
||||
|
||||
return style;
|
||||
}
|
||||
|
||||
@ -213,6 +218,7 @@ void DirPickerWidgetsPage::Reset()
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
@ -236,7 +242,8 @@ void DirPickerWidgetsPage::OnCheckBox(wxCommandEvent &event)
|
||||
{
|
||||
if (event.GetEventObject() == m_chkDirTextCtrl ||
|
||||
event.GetEventObject() == m_chkDirChangeDir ||
|
||||
event.GetEventObject() == m_chkDirMustExist)
|
||||
event.GetEventObject() == m_chkDirMustExist ||
|
||||
event.GetEventObject() == m_chkSmall)
|
||||
RecreatePicker();
|
||||
}
|
||||
|
||||
|
@ -111,7 +111,8 @@ protected:
|
||||
wxCheckBox *m_chkFileTextCtrl,
|
||||
*m_chkFileOverwritePrompt,
|
||||
*m_chkFileMustExist,
|
||||
*m_chkFileChangeDir;
|
||||
*m_chkFileChangeDir,
|
||||
*m_chkSmall;
|
||||
wxRadioBox *m_radioFilePickerMode;
|
||||
|
||||
wxBoxSizer *m_sizer;
|
||||
@ -169,6 +170,8 @@ void FilePickerWidgetsPage::CreateContent()
|
||||
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")),
|
||||
@ -222,6 +225,9 @@ long FilePickerWidgetsPage::GetPickerStyle()
|
||||
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
|
||||
@ -247,6 +253,7 @@ void FilePickerWidgetsPage::Reset()
|
||||
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();
|
||||
}
|
||||
@ -291,7 +298,8 @@ void FilePickerWidgetsPage::OnCheckBox(wxCommandEvent &event)
|
||||
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)
|
||||
|
@ -117,14 +117,19 @@ void wxPickerBase::PostCreation()
|
||||
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);
|
||||
}
|
||||
|
||||
SetSizer(m_sizer);
|
||||
|
||||
|
@ -54,8 +54,24 @@ bool wxGenericFileDirButton::Create(wxWindow *parent,
|
||||
{
|
||||
m_pickerStyle = style;
|
||||
|
||||
// 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;
|
||||
}
|
||||
|
||||
// create this button
|
||||
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;
|
||||
|
@ -27,6 +27,7 @@ wxDirPickerCtrlXmlHandler::wxDirPickerCtrlXmlHandler() : wxXmlResourceHandler()
|
||||
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();
|
||||
}
|
||||
|
@ -29,6 +29,7 @@ wxFilePickerCtrlXmlHandler::wxFilePickerCtrlXmlHandler() : wxXmlResourceHandler(
|
||||
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();
|
||||
|
Loading…
Reference in New Issue
Block a user