Commit pickers-fixes.patch added to 1472329 (Francesco Montorsi)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@39528 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
7ba03e3cd2
commit
556151f5ff
@ -85,7 +85,7 @@ protected:
|
||||
// used, a textctrl next to it.
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#define wxCLRP_USE_TEXTCTRL wxPB_USE_TEXTCTRL
|
||||
#define wxCLRP_USE_TEXTCTRL (wxPB_USE_TEXTCTRL)
|
||||
#define wxCLRP_DEFAULT_STYLE 0
|
||||
|
||||
class WXDLLIMPEXP_CORE wxColourPickerCtrl : public wxPickerBase
|
||||
|
@ -48,11 +48,11 @@ public:
|
||||
virtual ~wxFileDirPickerWidgetBase() { }
|
||||
|
||||
wxString GetPath() const { return m_path; }
|
||||
void SetPath(const wxString &str) { m_path=str; UpdateDialogPath(); }
|
||||
virtual void SetPath(const wxString &str) { m_path=str; }
|
||||
|
||||
protected:
|
||||
virtual void UpdateDialogPath() = 0;
|
||||
virtual void UpdatePathFromDialog() = 0;
|
||||
virtual void UpdateDialogPath(wxDialog *) = 0;
|
||||
virtual void UpdatePathFromDialog(wxDialog *) = 0;
|
||||
|
||||
wxString m_path;
|
||||
};
|
||||
@ -159,13 +159,13 @@ protected:
|
||||
// used, a textctrl next to it.
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#define wxFLP_USE_TEXTCTRL wxPB_USE_TEXTCTRL
|
||||
#define wxFLP_USE_TEXTCTRL (wxPB_USE_TEXTCTRL)
|
||||
|
||||
#ifdef __WXGTK__
|
||||
// GTK apps usually don't have a textctrl next to the picker
|
||||
#define wxFLP_DEFAULT_STYLE wxFLP_OPEN
|
||||
#define wxFLP_DEFAULT_STYLE (wxFLP_OPEN)
|
||||
#else
|
||||
#define wxFLP_DEFAULT_STYLE wxFLP_USE_TEXTCTRL|wxFLP_OPEN
|
||||
#define wxFLP_DEFAULT_STYLE (wxFLP_USE_TEXTCTRL|wxFLP_OPEN)
|
||||
#endif
|
||||
|
||||
class WXDLLIMPEXP_CORE wxFilePickerCtrl : public wxFileDirPickerCtrlBase
|
||||
@ -253,13 +253,13 @@ private:
|
||||
// (see wxDIRP_USE_TEXTCTRL) next to it.
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#define wxDIRP_USE_TEXTCTRL wxPB_USE_TEXTCTRL
|
||||
#define wxDIRP_USE_TEXTCTRL (wxPB_USE_TEXTCTRL)
|
||||
|
||||
#ifdef __WXGTK__
|
||||
// GTK apps usually don't have a textctrl next to the picker
|
||||
#define wxDIRP_DEFAULT_STYLE 0
|
||||
#else
|
||||
#define wxDIRP_DEFAULT_STYLE wxDIRP_USE_TEXTCTRL
|
||||
#define wxDIRP_DEFAULT_STYLE (wxDIRP_USE_TEXTCTRL)
|
||||
#endif
|
||||
|
||||
class WXDLLIMPEXP_CORE wxDirPickerCtrl : public wxFileDirPickerCtrlBase
|
||||
|
@ -80,8 +80,8 @@ protected:
|
||||
// wxFontPickerCtrl specific flags
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#define wxFNTP_USE_TEXTCTRL wxPB_USE_TEXTCTRL
|
||||
#define wxFNTP_DEFAULT_STYLE wxFNTP_FONTDESC_AS_LABEL|wxFNTP_USEFONT_FOR_LABEL
|
||||
#define wxFNTP_USE_TEXTCTRL (wxPB_USE_TEXTCTRL)
|
||||
#define wxFNTP_DEFAULT_STYLE (wxFNTP_FONTDESC_AS_LABEL|wxFNTP_USEFONT_FOR_LABEL)
|
||||
|
||||
// not a style but rather the default value of the maximum pointsize allowed
|
||||
#define wxFNTP_MAXPOINT_SIZE 100
|
||||
|
@ -23,7 +23,7 @@
|
||||
#define wxCLRBTN_SHOW_LABEL 100
|
||||
|
||||
// the default style
|
||||
#define wxCLRBTN_DEFAULT_STYLE wxCLRBTN_SHOW_LABEL
|
||||
#define wxCLRBTN_DEFAULT_STYLE (wxCLRBTN_SHOW_LABEL)
|
||||
|
||||
|
||||
class WXDLLIMPEXP_CORE wxGenericColourButton : public wxButton,
|
||||
|
@ -30,7 +30,7 @@ class WXDLLIMPEXP_CORE wxGenericFileDirButton : public wxButton,
|
||||
public wxFileDirPickerWidgetBase
|
||||
{
|
||||
public:
|
||||
wxGenericFileDirButton() { m_dialog = NULL; }
|
||||
wxGenericFileDirButton() { }
|
||||
wxGenericFileDirButton(wxWindow *parent,
|
||||
wxWindowID id,
|
||||
const wxString& label = wxFilePickerWidgetLabel,
|
||||
@ -43,7 +43,6 @@ public:
|
||||
const wxValidator& validator = wxDefaultValidator,
|
||||
const wxString& name = wxFilePickerWidgetNameStr)
|
||||
{
|
||||
m_dialog = NULL;
|
||||
Create(parent, id, label, path, message, wildcard,
|
||||
pos, size, style, validator, name);
|
||||
}
|
||||
@ -52,23 +51,15 @@ public:
|
||||
|
||||
public: // overrideable
|
||||
|
||||
virtual bool CreateDialog(const wxString &message,
|
||||
const wxString &wildcard) = 0;
|
||||
virtual wxDialog *CreateDialog() = 0;
|
||||
|
||||
// NULL is because of a problem with destruction order in both generic & GTK code
|
||||
virtual wxWindow *GetDialogParent()
|
||||
{ return NULL; }
|
||||
{ return GetParent(); }
|
||||
|
||||
virtual wxEventType GetEventType() const = 0;
|
||||
|
||||
public:
|
||||
|
||||
bool Destroy()
|
||||
{
|
||||
if (m_dialog) m_dialog->Destroy();
|
||||
return wxButton::Destroy();
|
||||
}
|
||||
|
||||
bool Create(wxWindow *parent, wxWindowID id,
|
||||
const wxString& label = wxFilePickerWidgetLabel,
|
||||
const wxString& path = wxEmptyString,
|
||||
@ -83,7 +74,8 @@ public:
|
||||
// event handler for the click
|
||||
void OnButtonClick(wxCommandEvent &);
|
||||
|
||||
wxDialog *m_dialog;
|
||||
protected:
|
||||
wxString m_message, m_wildcard;
|
||||
};
|
||||
|
||||
|
||||
@ -91,7 +83,7 @@ public:
|
||||
// wxGenericFileButton: a button which brings up a wxFileDialog
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#define wxFILEBTN_DEFAULT_STYLE wxFLP_OPEN
|
||||
#define wxFILEBTN_DEFAULT_STYLE (wxFLP_OPEN)
|
||||
|
||||
class WXDLLIMPEXP_CORE wxGenericFileButton : public wxGenericFileDirButton
|
||||
{
|
||||
@ -133,24 +125,21 @@ public: // overrideable
|
||||
return filedlgstyle;
|
||||
}
|
||||
|
||||
virtual bool CreateDialog(const wxString &message, const wxString &wildcard)
|
||||
virtual wxDialog *CreateDialog()
|
||||
{
|
||||
m_dialog = new wxFileDialog(GetDialogParent(), message,
|
||||
wxFileDialog *p = new wxFileDialog(GetDialogParent(), m_message,
|
||||
wxEmptyString, wxEmptyString,
|
||||
wildcard, GetDialogStyle());
|
||||
m_wildcard, GetDialogStyle());
|
||||
|
||||
// this sets both the default folder and the default file of the dialog
|
||||
GetDialog()->SetPath(m_path);
|
||||
|
||||
return true;
|
||||
p->SetPath(m_path);
|
||||
return p;
|
||||
}
|
||||
|
||||
wxFileDialog *GetDialog()
|
||||
{ return wxStaticCast(m_dialog, wxFileDialog); }
|
||||
void UpdateDialogPath()
|
||||
{ GetDialog()->SetPath(m_path); }
|
||||
void UpdatePathFromDialog()
|
||||
{ m_path = GetDialog()->GetPath(); }
|
||||
void UpdateDialogPath(wxDialog *p)
|
||||
{ wxStaticCast(p, wxFileDialog)->SetPath(m_path); }
|
||||
void UpdatePathFromDialog(wxDialog *p)
|
||||
{ m_path = wxStaticCast(p, wxFileDialog)->GetPath(); }
|
||||
wxEventType GetEventType() const
|
||||
{ return wxEVT_COMMAND_FILEPICKER_CHANGED; }
|
||||
|
||||
@ -198,19 +187,16 @@ public: // overrideable
|
||||
return dirdlgstyle;
|
||||
}
|
||||
|
||||
virtual bool CreateDialog(const wxString &message, const wxString &WXUNUSED(wildcard))
|
||||
virtual wxDialog *CreateDialog()
|
||||
{
|
||||
m_dialog = new wxDirDialog(GetDialogParent(), message, m_path,
|
||||
return new wxDirDialog(GetDialogParent(), m_message, m_path,
|
||||
GetDialogStyle());
|
||||
return true;
|
||||
}
|
||||
|
||||
wxDirDialog *GetDialog()
|
||||
{ return wxStaticCast(m_dialog, wxDirDialog); }
|
||||
void UpdateDialogPath()
|
||||
{ GetDialog()->SetPath(m_path); }
|
||||
void UpdatePathFromDialog()
|
||||
{ m_path = GetDialog()->GetPath(); }
|
||||
void UpdateDialogPath(wxDialog *p)
|
||||
{ wxStaticCast(p, wxDirDialog)->SetPath(m_path); }
|
||||
void UpdatePathFromDialog(wxDialog *p)
|
||||
{ m_path = wxStaticCast(p, wxDirDialog)->GetPath(); }
|
||||
wxEventType GetEventType() const
|
||||
{ return wxEVT_COMMAND_DIRPICKER_CHANGED; }
|
||||
|
||||
|
@ -17,6 +17,37 @@
|
||||
// that GTK+ < 2.4
|
||||
#include "wx/generic/filepickerg.h"
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// wxFileButton and wxDirButton shared code
|
||||
// (cannot be a base class since they need to derive from wxGenericFileButton
|
||||
// and from wxGenericDirButton classes !)
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#define FILEDIRBTN_OVERRIDES \
|
||||
/* NULL is because of a problem with destruction order which happens */ \
|
||||
/* if we pass GetParent(): in fact, this GTK native implementation */ \
|
||||
/* needs to create the dialog in ::Create() and not for each user request */ \
|
||||
/* in response to the user click as the generic implementation does */ \
|
||||
virtual wxWindow *GetDialogParent() \
|
||||
{ \
|
||||
return NULL; \
|
||||
} \
|
||||
\
|
||||
virtual bool Destroy() \
|
||||
{ \
|
||||
m_dialog->Destroy(); \
|
||||
return wxButton::Destroy(); \
|
||||
} \
|
||||
\
|
||||
virtual void SetPath(const wxString &str) \
|
||||
{ \
|
||||
m_path=str; \
|
||||
UpdateDialogPath(m_dialog); \
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// wxFileButton
|
||||
//-----------------------------------------------------------------------------
|
||||
@ -24,7 +55,7 @@
|
||||
class WXDLLIMPEXP_CORE wxFileButton : public wxGenericFileButton
|
||||
{
|
||||
public:
|
||||
wxFileButton() {}
|
||||
wxFileButton() { m_dialog = NULL; }
|
||||
wxFileButton(wxWindow *parent,
|
||||
wxWindowID id,
|
||||
const wxString& label = wxFilePickerWidgetLabel,
|
||||
@ -37,11 +68,12 @@ public:
|
||||
const wxValidator& validator = wxDefaultValidator,
|
||||
const wxString& name = wxFilePickerWidgetNameStr)
|
||||
{
|
||||
m_dialog = NULL;
|
||||
Create(parent, id, label, path, message, wildcard,
|
||||
pos, size, style, validator, name);
|
||||
}
|
||||
|
||||
virtual ~wxFileButton() ;
|
||||
virtual ~wxFileButton();
|
||||
|
||||
|
||||
public: // overrides
|
||||
@ -62,13 +94,22 @@ public: // overrides
|
||||
void OnDialogOK(wxCommandEvent &);
|
||||
|
||||
|
||||
public: // some overrides
|
||||
|
||||
// GtkFileChooserButton does not support GTK_FILE_CHOOSER_ACTION_SAVE
|
||||
// so we replace it with GTK_FILE_CHOOSER_ACTION_OPEN
|
||||
long GetDialogStyle() const
|
||||
// so we replace it with GTK_FILE_CHOOSER_ACTION_OPEN; since wxFD_SAVE
|
||||
// is not supported, wxFD_OVERWRITE_PROMPT isn't too...
|
||||
virtual long GetDialogStyle() const
|
||||
{
|
||||
return (wxGenericFileButton::GetDialogStyle() & ~wxFD_SAVE) | wxFD_OPEN;
|
||||
return (wxGenericFileButton::GetDialogStyle() &
|
||||
~(wxFD_SAVE | wxFD_OVERWRITE_PROMPT)) | wxFD_OPEN;
|
||||
}
|
||||
|
||||
// see macro defined above
|
||||
FILEDIRBTN_OVERRIDES
|
||||
|
||||
protected:
|
||||
wxDialog *m_dialog;
|
||||
|
||||
private:
|
||||
DECLARE_DYNAMIC_CLASS(wxFileButton)
|
||||
@ -82,7 +123,7 @@ private:
|
||||
class WXDLLIMPEXP_CORE wxDirButton : public wxGenericDirButton
|
||||
{
|
||||
public:
|
||||
wxDirButton() {}
|
||||
wxDirButton() { m_dialog = NULL;}
|
||||
wxDirButton(wxWindow *parent,
|
||||
wxWindowID id,
|
||||
const wxString& label = wxFilePickerWidgetLabel,
|
||||
@ -94,6 +135,7 @@ public:
|
||||
const wxValidator& validator = wxDefaultValidator,
|
||||
const wxString& name = wxFilePickerWidgetNameStr)
|
||||
{
|
||||
m_dialog = NULL;
|
||||
Create(parent, id, label, path, message, wxEmptyString,
|
||||
pos, size, style, validator, name);
|
||||
}
|
||||
@ -126,9 +168,17 @@ public: // overrides
|
||||
return (wxGenericDirButton::GetDialogStyle() | wxDD_DIR_MUST_EXIST);
|
||||
}
|
||||
|
||||
// see macro defined above
|
||||
FILEDIRBTN_OVERRIDES
|
||||
|
||||
protected:
|
||||
wxDialog *m_dialog;
|
||||
|
||||
private:
|
||||
DECLARE_DYNAMIC_CLASS(wxDirButton)
|
||||
};
|
||||
|
||||
#undef FILEDIRBTN_OVERRIDES
|
||||
|
||||
#endif // _WX_GTK_FILEPICKER_H_
|
||||
|
||||
|
@ -30,6 +30,7 @@
|
||||
#ifndef WX_PRECOMP
|
||||
#include "wx/app.h"
|
||||
#include "wx/log.h"
|
||||
#include "wx/radiobox.h"
|
||||
#endif
|
||||
|
||||
#include "wx/artprov.h"
|
||||
@ -50,6 +51,12 @@
|
||||
// constants
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
enum
|
||||
{
|
||||
FilePickerMode_Open = 0,
|
||||
FilePickerMode_Save
|
||||
};
|
||||
|
||||
// control ids
|
||||
enum
|
||||
{
|
||||
@ -80,7 +87,7 @@ public:
|
||||
PickerWidgetsPage(WidgetsBookCtrl *book, wxImageList *imaglist);
|
||||
virtual ~PickerWidgetsPage(){};
|
||||
|
||||
virtual wxControl *GetWidget() const { /*return m_fontPicker;*/ return NULL; }
|
||||
virtual wxControl *GetWidget() const { return m_filePicker; }
|
||||
virtual void RecreateWidget() { RecreateAllPickers(); }
|
||||
|
||||
protected:
|
||||
@ -108,6 +115,8 @@ protected:
|
||||
// get the initial style for the picker of the given kind
|
||||
long GetPickerStyle(PickerKind kind);
|
||||
|
||||
// update filepicker radiobox
|
||||
void UpdateFilePickerMode();
|
||||
|
||||
// the pickers and the relative event handlers
|
||||
#if wxUSE_COLOURPICKERCTRL
|
||||
@ -140,6 +149,7 @@ protected:
|
||||
*m_chkFileOverwritePrompt,
|
||||
*m_chkFileMustExist,
|
||||
*m_chkFileChangeDir;
|
||||
wxRadioBox *m_radioFilePickerMode;
|
||||
|
||||
wxCheckBox *m_chkDirTextCtrl,
|
||||
*m_chkDirChangeDir,
|
||||
@ -177,6 +187,7 @@ BEGIN_EVENT_TABLE(PickerWidgetsPage, WidgetsPage)
|
||||
#endif
|
||||
|
||||
EVT_CHECKBOX(wxID_ANY, PickerWidgetsPage::OnCheckBox)
|
||||
EVT_RADIOBOX(wxID_ANY, PickerWidgetsPage::OnCheckBox)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
// ============================================================================
|
||||
@ -208,6 +219,12 @@ PickerWidgetsPage::PickerWidgetsPage(WidgetsBookCtrl *book,
|
||||
#endif // wxUSE_COLOURPICKERCTRL
|
||||
|
||||
#if wxUSE_FILEPICKERCTRL
|
||||
static const wxString mode[] = { _T("open"), _T("save") };
|
||||
m_radioFilePickerMode = new wxRadioBox(this, wxID_ANY, _T("wxFilePicker mode"),
|
||||
wxDefaultPosition, wxDefaultSize,
|
||||
WXSIZEOF(mode), mode);
|
||||
boxleft->Add(m_radioFilePickerMode, 0, wxALL|wxGROW, 5);
|
||||
|
||||
wxStaticBoxSizer *filebox = new wxStaticBoxSizer(wxVERTICAL, this, _T("&FilePicker style"));
|
||||
m_chkFileTextCtrl = CreateCheckBoxAndAddToSizer(filebox, _T("With textctrl"), false);
|
||||
m_chkFileOverwritePrompt = CreateCheckBoxAndAddToSizer(filebox, _T("Overwrite prompt"), false);
|
||||
@ -388,6 +405,11 @@ long PickerWidgetsPage::GetPickerStyle(PickerKind picker)
|
||||
if ( m_chkFileChangeDir->GetValue() )
|
||||
style |= wxFLP_CHANGE_DIR;
|
||||
|
||||
if (m_radioFilePickerMode->GetSelection() == FilePickerMode_Open)
|
||||
style |= wxFLP_OPEN;
|
||||
else
|
||||
style |= wxFLP_SAVE;
|
||||
|
||||
break;
|
||||
#endif // wxUSE_FILEPICKERCTRL
|
||||
|
||||
@ -496,10 +518,14 @@ void PickerWidgetsPage::Reset()
|
||||
#endif
|
||||
|
||||
#if wxUSE_FILEPICKERCTRL
|
||||
m_radioFilePickerMode->SetSelection((wxFLP_DEFAULT_STYLE & wxFLP_OPEN) ?
|
||||
FilePickerMode_Open : FilePickerMode_Save);
|
||||
m_chkFileTextCtrl->SetValue((wxFLP_DEFAULT_STYLE & wxFLP_USE_TEXTCTRL) != 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);
|
||||
|
||||
UpdateFilePickerMode();
|
||||
#endif
|
||||
|
||||
#if wxUSE_DIRPICKERCTRL
|
||||
@ -515,6 +541,23 @@ void PickerWidgetsPage::Reset()
|
||||
#endif
|
||||
}
|
||||
|
||||
void PickerWidgetsPage::UpdateFilePickerMode()
|
||||
{
|
||||
switch (m_radioFilePickerMode->GetSelection())
|
||||
{
|
||||
case FilePickerMode_Open:
|
||||
m_chkFileOverwritePrompt->SetValue(false);
|
||||
m_chkFileOverwritePrompt->Disable();
|
||||
m_chkFileMustExist->Enable();
|
||||
break;
|
||||
case FilePickerMode_Save:
|
||||
m_chkFileMustExist->SetValue(false);
|
||||
m_chkFileMustExist->Disable();
|
||||
m_chkFileOverwritePrompt->Enable();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// event handlers
|
||||
@ -577,6 +620,12 @@ void PickerWidgetsPage::OnCheckBox(wxCommandEvent &event)
|
||||
event.GetEventObject() == m_chkFontDescAsLabel ||
|
||||
event.GetEventObject() == m_chkFontUseFontForLabel)
|
||||
RecreatePicker(Picker_Font);
|
||||
|
||||
if (event.GetEventObject() == m_radioFilePickerMode)
|
||||
{
|
||||
UpdateFilePickerMode();
|
||||
RecreatePicker(Picker_File);
|
||||
}
|
||||
}
|
||||
|
||||
#endif // wxUSE_COLOURPICKERCTRL || wxUSE_FILEPICKERCTRL || wxUSE_DIRPICKERCTRL || wxUSE_FONTPICKERCTRL
|
||||
|
@ -55,6 +55,19 @@ bool wxFileDirPickerCtrlBase::CreateBase( wxWindow *parent, wxWindowID id,
|
||||
style, validator, name))
|
||||
return false;
|
||||
|
||||
if (!HasFlag(wxFLP_OPEN) && !HasFlag(wxFLP_SAVE))
|
||||
m_windowStyle |= wxFLP_OPEN; // wxFD_OPEN is the default
|
||||
|
||||
// check that the styles are not contradictory
|
||||
wxASSERT_MSG( !(HasFlag(wxFLP_SAVE) && HasFlag(wxFLP_OPEN)),
|
||||
_T("can't specify both wxFLP_SAVE and wxFLP_OPEN at once") );
|
||||
|
||||
wxASSERT_MSG( !HasFlag(wxFLP_SAVE) || !HasFlag(wxFLP_FILE_MUST_EXIST),
|
||||
_T("wxFLP_FILE_MUST_EXIST can't be used with wxFLP_SAVE" ) );
|
||||
|
||||
wxASSERT_MSG( !HasFlag(wxFLP_OPEN) || !HasFlag(wxFLP_OVERWRITE_PROMPT),
|
||||
_T("wxFLP_OVERWRITE_PROMPT can't be used with wxFLP_OPEN") );
|
||||
|
||||
// create a wxFilePickerWidget or a wxDirPickerWidget...
|
||||
if (!CreatePicker(this, path, message, wildcard))
|
||||
return false;
|
||||
|
@ -57,6 +57,9 @@ bool wxFileDialogBase::Create(wxWindow *parent,
|
||||
m_windowStyle = style;
|
||||
m_filterIndex = 0;
|
||||
|
||||
if (!HasFlag(wxFD_OPEN) && !HasFlag(wxFD_SAVE))
|
||||
m_windowStyle |= wxFD_OPEN; // wxFD_OPEN is the default
|
||||
|
||||
// check that the styles are not contradictory
|
||||
wxASSERT_MSG( !(HasFlag(wxFD_SAVE) && HasFlag(wxFD_OPEN)),
|
||||
_T("can't specify both wxFD_SAVE and wxFD_OPEN at once") );
|
||||
|
@ -66,20 +66,26 @@ bool wxGenericFileDirButton::Create( wxWindow *parent, wxWindowID id,
|
||||
|
||||
// create the dialog associated with this button
|
||||
m_path = path;
|
||||
return CreateDialog(message, wildcard);
|
||||
m_message = message;
|
||||
m_wildcard = wildcard;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void wxGenericFileDirButton::OnButtonClick(wxCommandEvent& WXUNUSED(ev))
|
||||
{
|
||||
if (m_dialog->ShowModal() == wxID_OK)
|
||||
wxDialog *p = CreateDialog();
|
||||
if (p->ShowModal() == wxID_OK)
|
||||
{
|
||||
// save the path
|
||||
UpdatePathFromDialog();
|
||||
// save updated path in m_path
|
||||
UpdatePathFromDialog(p);
|
||||
|
||||
// fire an event
|
||||
wxFileDirPickerEvent event(GetEventType(), this, GetId(), m_path);
|
||||
GetEventHandler()->ProcessEvent(event);
|
||||
}
|
||||
|
||||
wxDELETE(p);
|
||||
}
|
||||
|
||||
#endif // wxUSE_FILEPICKERCTRL || wxUSE_DIRPICKERCTRL
|
||||
|
@ -66,9 +66,13 @@ bool wxFileButton::Create( wxWindow *parent, wxWindowID id,
|
||||
}
|
||||
|
||||
// create the dialog associated with this button
|
||||
// NB: unlike generic implementation, native GTK implementation needs to create
|
||||
// the filedialog here as it needs to use gtk_file_chooser_button_new_with_dialog()
|
||||
SetWindowStyle(style);
|
||||
m_path = path;
|
||||
if (!CreateDialog(message, wildcard))
|
||||
m_message = message;
|
||||
m_wildcard = wildcard;
|
||||
if ((m_dialog = CreateDialog()) == NULL)
|
||||
return false;
|
||||
|
||||
// little trick used to avoid problems when there are other GTK windows 'grabbed':
|
||||
@ -122,7 +126,7 @@ void wxFileButton::OnDialogOK(wxCommandEvent& ev)
|
||||
if (ev.GetId() == wxID_OK)
|
||||
{
|
||||
// ...update our path
|
||||
UpdatePathFromDialog();
|
||||
UpdatePathFromDialog(m_dialog);
|
||||
|
||||
// ...and fire an event
|
||||
wxFileDirPickerEvent event(wxEVT_COMMAND_FILEPICKER_CHANGED, this, GetId(), m_path);
|
||||
@ -199,8 +203,9 @@ bool wxDirButton::Create( wxWindow *parent, wxWindowID id,
|
||||
|
||||
// create the dialog associated with this button
|
||||
SetWindowStyle(style);
|
||||
m_path = path;
|
||||
if (!CreateDialog(message, wildcard))
|
||||
m_message = message;
|
||||
m_wildcard = wildcard;
|
||||
if ((m_dialog = CreateDialog()) == NULL)
|
||||
return false;
|
||||
|
||||
// little trick used to avoid problems when there are other GTK windows 'grabbed':
|
||||
|
@ -2749,6 +2749,9 @@ void wxWindowGTK::PostCreation()
|
||||
#ifdef GTK_IS_FILE_CHOOSER_BUTTON
|
||||
else if (GTK_IS_FILE_CHOOSER_BUTTON(m_widget))
|
||||
{
|
||||
// If we connect to the "size_request" signal of a GtkFileChooserButton
|
||||
// then that control won't be sized properly when placed inside sizers
|
||||
// (this can be tested removing this elseif and running XRC or WIDGETS samples)
|
||||
// FIXME: what should be done here ?
|
||||
}
|
||||
#endif
|
||||
|
@ -136,8 +136,7 @@ wxFileDialog::wxFileDialog(wxWindow *parent,
|
||||
wildCard, style, pos, sz, name)
|
||||
|
||||
{
|
||||
if ( ( m_windowStyle & wxFD_MULTIPLE ) && ( m_windowStyle & wxFD_SAVE ) )
|
||||
m_windowStyle &= ~wxFD_MULTIPLE;
|
||||
// NB: all style checks are done by wxFileDialogBase::Create
|
||||
|
||||
m_bMovedWindow = false;
|
||||
|
||||
|
@ -78,8 +78,7 @@ wxFileDialog::wxFileDialog (
|
||||
:wxFileDialogBase(pParent, rsMessage, rsDefaultDir, rsDefaultFileName, rsWildCard, lStyle, rPos, sz, name)
|
||||
|
||||
{
|
||||
if ((m_windowStyle & wxFD_MULTIPLE) && (m_windowStyle & wxFD_SAVE))
|
||||
m_windowStyle &= ~wxFD_MULTIPLE;
|
||||
// NB: all style checks are done by wxFileDialogBase::Create
|
||||
|
||||
m_filterIndex = 1;
|
||||
} // end of wxFileDialog::wxFileDialog
|
||||
|
Loading…
Reference in New Issue
Block a user