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:
@@ -85,7 +85,7 @@ protected:
|
|||||||
// used, a textctrl next to it.
|
// 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
|
#define wxCLRP_DEFAULT_STYLE 0
|
||||||
|
|
||||||
class WXDLLIMPEXP_CORE wxColourPickerCtrl : public wxPickerBase
|
class WXDLLIMPEXP_CORE wxColourPickerCtrl : public wxPickerBase
|
||||||
|
@@ -48,11 +48,11 @@ public:
|
|||||||
virtual ~wxFileDirPickerWidgetBase() { }
|
virtual ~wxFileDirPickerWidgetBase() { }
|
||||||
|
|
||||||
wxString GetPath() const { return m_path; }
|
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:
|
protected:
|
||||||
virtual void UpdateDialogPath() = 0;
|
virtual void UpdateDialogPath(wxDialog *) = 0;
|
||||||
virtual void UpdatePathFromDialog() = 0;
|
virtual void UpdatePathFromDialog(wxDialog *) = 0;
|
||||||
|
|
||||||
wxString m_path;
|
wxString m_path;
|
||||||
};
|
};
|
||||||
@@ -159,13 +159,13 @@ protected:
|
|||||||
// used, a textctrl next to it.
|
// used, a textctrl next to it.
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
#define wxFLP_USE_TEXTCTRL wxPB_USE_TEXTCTRL
|
#define wxFLP_USE_TEXTCTRL (wxPB_USE_TEXTCTRL)
|
||||||
|
|
||||||
#ifdef __WXGTK__
|
#ifdef __WXGTK__
|
||||||
// GTK apps usually don't have a textctrl next to the picker
|
// 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
|
#else
|
||||||
#define wxFLP_DEFAULT_STYLE wxFLP_USE_TEXTCTRL|wxFLP_OPEN
|
#define wxFLP_DEFAULT_STYLE (wxFLP_USE_TEXTCTRL|wxFLP_OPEN)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
class WXDLLIMPEXP_CORE wxFilePickerCtrl : public wxFileDirPickerCtrlBase
|
class WXDLLIMPEXP_CORE wxFilePickerCtrl : public wxFileDirPickerCtrlBase
|
||||||
@@ -253,13 +253,13 @@ private:
|
|||||||
// (see wxDIRP_USE_TEXTCTRL) next to it.
|
// (see wxDIRP_USE_TEXTCTRL) next to it.
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
#define wxDIRP_USE_TEXTCTRL wxPB_USE_TEXTCTRL
|
#define wxDIRP_USE_TEXTCTRL (wxPB_USE_TEXTCTRL)
|
||||||
|
|
||||||
#ifdef __WXGTK__
|
#ifdef __WXGTK__
|
||||||
// GTK apps usually don't have a textctrl next to the picker
|
// GTK apps usually don't have a textctrl next to the picker
|
||||||
#define wxDIRP_DEFAULT_STYLE 0
|
#define wxDIRP_DEFAULT_STYLE 0
|
||||||
#else
|
#else
|
||||||
#define wxDIRP_DEFAULT_STYLE wxDIRP_USE_TEXTCTRL
|
#define wxDIRP_DEFAULT_STYLE (wxDIRP_USE_TEXTCTRL)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
class WXDLLIMPEXP_CORE wxDirPickerCtrl : public wxFileDirPickerCtrlBase
|
class WXDLLIMPEXP_CORE wxDirPickerCtrl : public wxFileDirPickerCtrlBase
|
||||||
|
@@ -80,8 +80,8 @@ protected:
|
|||||||
// wxFontPickerCtrl specific flags
|
// wxFontPickerCtrl specific flags
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
#define wxFNTP_USE_TEXTCTRL wxPB_USE_TEXTCTRL
|
#define wxFNTP_USE_TEXTCTRL (wxPB_USE_TEXTCTRL)
|
||||||
#define wxFNTP_DEFAULT_STYLE wxFNTP_FONTDESC_AS_LABEL|wxFNTP_USEFONT_FOR_LABEL
|
#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
|
// not a style but rather the default value of the maximum pointsize allowed
|
||||||
#define wxFNTP_MAXPOINT_SIZE 100
|
#define wxFNTP_MAXPOINT_SIZE 100
|
||||||
|
@@ -23,7 +23,7 @@
|
|||||||
#define wxCLRBTN_SHOW_LABEL 100
|
#define wxCLRBTN_SHOW_LABEL 100
|
||||||
|
|
||||||
// the default style
|
// the default style
|
||||||
#define wxCLRBTN_DEFAULT_STYLE wxCLRBTN_SHOW_LABEL
|
#define wxCLRBTN_DEFAULT_STYLE (wxCLRBTN_SHOW_LABEL)
|
||||||
|
|
||||||
|
|
||||||
class WXDLLIMPEXP_CORE wxGenericColourButton : public wxButton,
|
class WXDLLIMPEXP_CORE wxGenericColourButton : public wxButton,
|
||||||
|
@@ -30,7 +30,7 @@ class WXDLLIMPEXP_CORE wxGenericFileDirButton : public wxButton,
|
|||||||
public wxFileDirPickerWidgetBase
|
public wxFileDirPickerWidgetBase
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
wxGenericFileDirButton() { m_dialog = NULL; }
|
wxGenericFileDirButton() { }
|
||||||
wxGenericFileDirButton(wxWindow *parent,
|
wxGenericFileDirButton(wxWindow *parent,
|
||||||
wxWindowID id,
|
wxWindowID id,
|
||||||
const wxString& label = wxFilePickerWidgetLabel,
|
const wxString& label = wxFilePickerWidgetLabel,
|
||||||
@@ -43,7 +43,6 @@ public:
|
|||||||
const wxValidator& validator = wxDefaultValidator,
|
const wxValidator& validator = wxDefaultValidator,
|
||||||
const wxString& name = wxFilePickerWidgetNameStr)
|
const wxString& name = wxFilePickerWidgetNameStr)
|
||||||
{
|
{
|
||||||
m_dialog = NULL;
|
|
||||||
Create(parent, id, label, path, message, wildcard,
|
Create(parent, id, label, path, message, wildcard,
|
||||||
pos, size, style, validator, name);
|
pos, size, style, validator, name);
|
||||||
}
|
}
|
||||||
@@ -52,23 +51,15 @@ public:
|
|||||||
|
|
||||||
public: // overrideable
|
public: // overrideable
|
||||||
|
|
||||||
virtual bool CreateDialog(const wxString &message,
|
virtual wxDialog *CreateDialog() = 0;
|
||||||
const wxString &wildcard) = 0;
|
|
||||||
|
|
||||||
// NULL is because of a problem with destruction order in both generic & GTK code
|
|
||||||
virtual wxWindow *GetDialogParent()
|
virtual wxWindow *GetDialogParent()
|
||||||
{ return NULL; }
|
{ return GetParent(); }
|
||||||
|
|
||||||
virtual wxEventType GetEventType() const = 0;
|
virtual wxEventType GetEventType() const = 0;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
bool Destroy()
|
|
||||||
{
|
|
||||||
if (m_dialog) m_dialog->Destroy();
|
|
||||||
return wxButton::Destroy();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Create(wxWindow *parent, wxWindowID id,
|
bool Create(wxWindow *parent, wxWindowID id,
|
||||||
const wxString& label = wxFilePickerWidgetLabel,
|
const wxString& label = wxFilePickerWidgetLabel,
|
||||||
const wxString& path = wxEmptyString,
|
const wxString& path = wxEmptyString,
|
||||||
@@ -83,7 +74,8 @@ public:
|
|||||||
// event handler for the click
|
// event handler for the click
|
||||||
void OnButtonClick(wxCommandEvent &);
|
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
|
// 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
|
class WXDLLIMPEXP_CORE wxGenericFileButton : public wxGenericFileDirButton
|
||||||
{
|
{
|
||||||
@@ -133,24 +125,21 @@ public: // overrideable
|
|||||||
return filedlgstyle;
|
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,
|
wxEmptyString, wxEmptyString,
|
||||||
wildcard, GetDialogStyle());
|
m_wildcard, GetDialogStyle());
|
||||||
|
|
||||||
// this sets both the default folder and the default file of the dialog
|
// this sets both the default folder and the default file of the dialog
|
||||||
GetDialog()->SetPath(m_path);
|
p->SetPath(m_path);
|
||||||
|
return p;
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
wxFileDialog *GetDialog()
|
void UpdateDialogPath(wxDialog *p)
|
||||||
{ return wxStaticCast(m_dialog, wxFileDialog); }
|
{ wxStaticCast(p, wxFileDialog)->SetPath(m_path); }
|
||||||
void UpdateDialogPath()
|
void UpdatePathFromDialog(wxDialog *p)
|
||||||
{ GetDialog()->SetPath(m_path); }
|
{ m_path = wxStaticCast(p, wxFileDialog)->GetPath(); }
|
||||||
void UpdatePathFromDialog()
|
|
||||||
{ m_path = GetDialog()->GetPath(); }
|
|
||||||
wxEventType GetEventType() const
|
wxEventType GetEventType() const
|
||||||
{ return wxEVT_COMMAND_FILEPICKER_CHANGED; }
|
{ return wxEVT_COMMAND_FILEPICKER_CHANGED; }
|
||||||
|
|
||||||
@@ -198,19 +187,16 @@ public: // overrideable
|
|||||||
return dirdlgstyle;
|
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());
|
GetDialogStyle());
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
wxDirDialog *GetDialog()
|
void UpdateDialogPath(wxDialog *p)
|
||||||
{ return wxStaticCast(m_dialog, wxDirDialog); }
|
{ wxStaticCast(p, wxDirDialog)->SetPath(m_path); }
|
||||||
void UpdateDialogPath()
|
void UpdatePathFromDialog(wxDialog *p)
|
||||||
{ GetDialog()->SetPath(m_path); }
|
{ m_path = wxStaticCast(p, wxDirDialog)->GetPath(); }
|
||||||
void UpdatePathFromDialog()
|
|
||||||
{ m_path = GetDialog()->GetPath(); }
|
|
||||||
wxEventType GetEventType() const
|
wxEventType GetEventType() const
|
||||||
{ return wxEVT_COMMAND_DIRPICKER_CHANGED; }
|
{ return wxEVT_COMMAND_DIRPICKER_CHANGED; }
|
||||||
|
|
||||||
|
@@ -17,6 +17,37 @@
|
|||||||
// that GTK+ < 2.4
|
// that GTK+ < 2.4
|
||||||
#include "wx/generic/filepickerg.h"
|
#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
|
// wxFileButton
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
@@ -24,7 +55,7 @@
|
|||||||
class WXDLLIMPEXP_CORE wxFileButton : public wxGenericFileButton
|
class WXDLLIMPEXP_CORE wxFileButton : public wxGenericFileButton
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
wxFileButton() {}
|
wxFileButton() { m_dialog = NULL; }
|
||||||
wxFileButton(wxWindow *parent,
|
wxFileButton(wxWindow *parent,
|
||||||
wxWindowID id,
|
wxWindowID id,
|
||||||
const wxString& label = wxFilePickerWidgetLabel,
|
const wxString& label = wxFilePickerWidgetLabel,
|
||||||
@@ -37,6 +68,7 @@ public:
|
|||||||
const wxValidator& validator = wxDefaultValidator,
|
const wxValidator& validator = wxDefaultValidator,
|
||||||
const wxString& name = wxFilePickerWidgetNameStr)
|
const wxString& name = wxFilePickerWidgetNameStr)
|
||||||
{
|
{
|
||||||
|
m_dialog = NULL;
|
||||||
Create(parent, id, label, path, message, wildcard,
|
Create(parent, id, label, path, message, wildcard,
|
||||||
pos, size, style, validator, name);
|
pos, size, style, validator, name);
|
||||||
}
|
}
|
||||||
@@ -62,13 +94,22 @@ public: // overrides
|
|||||||
void OnDialogOK(wxCommandEvent &);
|
void OnDialogOK(wxCommandEvent &);
|
||||||
|
|
||||||
|
|
||||||
|
public: // some overrides
|
||||||
|
|
||||||
// GtkFileChooserButton does not support GTK_FILE_CHOOSER_ACTION_SAVE
|
// GtkFileChooserButton does not support GTK_FILE_CHOOSER_ACTION_SAVE
|
||||||
// so we replace it with GTK_FILE_CHOOSER_ACTION_OPEN
|
// so we replace it with GTK_FILE_CHOOSER_ACTION_OPEN; since wxFD_SAVE
|
||||||
long GetDialogStyle() const
|
// 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:
|
private:
|
||||||
DECLARE_DYNAMIC_CLASS(wxFileButton)
|
DECLARE_DYNAMIC_CLASS(wxFileButton)
|
||||||
@@ -82,7 +123,7 @@ private:
|
|||||||
class WXDLLIMPEXP_CORE wxDirButton : public wxGenericDirButton
|
class WXDLLIMPEXP_CORE wxDirButton : public wxGenericDirButton
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
wxDirButton() {}
|
wxDirButton() { m_dialog = NULL;}
|
||||||
wxDirButton(wxWindow *parent,
|
wxDirButton(wxWindow *parent,
|
||||||
wxWindowID id,
|
wxWindowID id,
|
||||||
const wxString& label = wxFilePickerWidgetLabel,
|
const wxString& label = wxFilePickerWidgetLabel,
|
||||||
@@ -94,6 +135,7 @@ public:
|
|||||||
const wxValidator& validator = wxDefaultValidator,
|
const wxValidator& validator = wxDefaultValidator,
|
||||||
const wxString& name = wxFilePickerWidgetNameStr)
|
const wxString& name = wxFilePickerWidgetNameStr)
|
||||||
{
|
{
|
||||||
|
m_dialog = NULL;
|
||||||
Create(parent, id, label, path, message, wxEmptyString,
|
Create(parent, id, label, path, message, wxEmptyString,
|
||||||
pos, size, style, validator, name);
|
pos, size, style, validator, name);
|
||||||
}
|
}
|
||||||
@@ -126,9 +168,17 @@ public: // overrides
|
|||||||
return (wxGenericDirButton::GetDialogStyle() | wxDD_DIR_MUST_EXIST);
|
return (wxGenericDirButton::GetDialogStyle() | wxDD_DIR_MUST_EXIST);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// see macro defined above
|
||||||
|
FILEDIRBTN_OVERRIDES
|
||||||
|
|
||||||
|
protected:
|
||||||
|
wxDialog *m_dialog;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
DECLARE_DYNAMIC_CLASS(wxDirButton)
|
DECLARE_DYNAMIC_CLASS(wxDirButton)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#undef FILEDIRBTN_OVERRIDES
|
||||||
|
|
||||||
#endif // _WX_GTK_FILEPICKER_H_
|
#endif // _WX_GTK_FILEPICKER_H_
|
||||||
|
|
||||||
|
@@ -30,6 +30,7 @@
|
|||||||
#ifndef WX_PRECOMP
|
#ifndef WX_PRECOMP
|
||||||
#include "wx/app.h"
|
#include "wx/app.h"
|
||||||
#include "wx/log.h"
|
#include "wx/log.h"
|
||||||
|
#include "wx/radiobox.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "wx/artprov.h"
|
#include "wx/artprov.h"
|
||||||
@@ -50,6 +51,12 @@
|
|||||||
// constants
|
// constants
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
FilePickerMode_Open = 0,
|
||||||
|
FilePickerMode_Save
|
||||||
|
};
|
||||||
|
|
||||||
// control ids
|
// control ids
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
@@ -80,7 +87,7 @@ public:
|
|||||||
PickerWidgetsPage(WidgetsBookCtrl *book, wxImageList *imaglist);
|
PickerWidgetsPage(WidgetsBookCtrl *book, wxImageList *imaglist);
|
||||||
virtual ~PickerWidgetsPage(){};
|
virtual ~PickerWidgetsPage(){};
|
||||||
|
|
||||||
virtual wxControl *GetWidget() const { /*return m_fontPicker;*/ return NULL; }
|
virtual wxControl *GetWidget() const { return m_filePicker; }
|
||||||
virtual void RecreateWidget() { RecreateAllPickers(); }
|
virtual void RecreateWidget() { RecreateAllPickers(); }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
@@ -108,6 +115,8 @@ protected:
|
|||||||
// get the initial style for the picker of the given kind
|
// get the initial style for the picker of the given kind
|
||||||
long GetPickerStyle(PickerKind kind);
|
long GetPickerStyle(PickerKind kind);
|
||||||
|
|
||||||
|
// update filepicker radiobox
|
||||||
|
void UpdateFilePickerMode();
|
||||||
|
|
||||||
// the pickers and the relative event handlers
|
// the pickers and the relative event handlers
|
||||||
#if wxUSE_COLOURPICKERCTRL
|
#if wxUSE_COLOURPICKERCTRL
|
||||||
@@ -140,6 +149,7 @@ protected:
|
|||||||
*m_chkFileOverwritePrompt,
|
*m_chkFileOverwritePrompt,
|
||||||
*m_chkFileMustExist,
|
*m_chkFileMustExist,
|
||||||
*m_chkFileChangeDir;
|
*m_chkFileChangeDir;
|
||||||
|
wxRadioBox *m_radioFilePickerMode;
|
||||||
|
|
||||||
wxCheckBox *m_chkDirTextCtrl,
|
wxCheckBox *m_chkDirTextCtrl,
|
||||||
*m_chkDirChangeDir,
|
*m_chkDirChangeDir,
|
||||||
@@ -177,6 +187,7 @@ BEGIN_EVENT_TABLE(PickerWidgetsPage, WidgetsPage)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
EVT_CHECKBOX(wxID_ANY, PickerWidgetsPage::OnCheckBox)
|
EVT_CHECKBOX(wxID_ANY, PickerWidgetsPage::OnCheckBox)
|
||||||
|
EVT_RADIOBOX(wxID_ANY, PickerWidgetsPage::OnCheckBox)
|
||||||
END_EVENT_TABLE()
|
END_EVENT_TABLE()
|
||||||
|
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
@@ -208,6 +219,12 @@ PickerWidgetsPage::PickerWidgetsPage(WidgetsBookCtrl *book,
|
|||||||
#endif // wxUSE_COLOURPICKERCTRL
|
#endif // wxUSE_COLOURPICKERCTRL
|
||||||
|
|
||||||
#if wxUSE_FILEPICKERCTRL
|
#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"));
|
wxStaticBoxSizer *filebox = new wxStaticBoxSizer(wxVERTICAL, this, _T("&FilePicker style"));
|
||||||
m_chkFileTextCtrl = CreateCheckBoxAndAddToSizer(filebox, _T("With textctrl"), false);
|
m_chkFileTextCtrl = CreateCheckBoxAndAddToSizer(filebox, _T("With textctrl"), false);
|
||||||
m_chkFileOverwritePrompt = CreateCheckBoxAndAddToSizer(filebox, _T("Overwrite prompt"), false);
|
m_chkFileOverwritePrompt = CreateCheckBoxAndAddToSizer(filebox, _T("Overwrite prompt"), false);
|
||||||
@@ -388,6 +405,11 @@ long PickerWidgetsPage::GetPickerStyle(PickerKind picker)
|
|||||||
if ( m_chkFileChangeDir->GetValue() )
|
if ( m_chkFileChangeDir->GetValue() )
|
||||||
style |= wxFLP_CHANGE_DIR;
|
style |= wxFLP_CHANGE_DIR;
|
||||||
|
|
||||||
|
if (m_radioFilePickerMode->GetSelection() == FilePickerMode_Open)
|
||||||
|
style |= wxFLP_OPEN;
|
||||||
|
else
|
||||||
|
style |= wxFLP_SAVE;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
#endif // wxUSE_FILEPICKERCTRL
|
#endif // wxUSE_FILEPICKERCTRL
|
||||||
|
|
||||||
@@ -496,10 +518,14 @@ void PickerWidgetsPage::Reset()
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if wxUSE_FILEPICKERCTRL
|
#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_chkFileTextCtrl->SetValue((wxFLP_DEFAULT_STYLE & wxFLP_USE_TEXTCTRL) != 0);
|
||||||
m_chkFileOverwritePrompt->SetValue((wxFLP_DEFAULT_STYLE & wxFLP_OVERWRITE_PROMPT) != 0);
|
m_chkFileOverwritePrompt->SetValue((wxFLP_DEFAULT_STYLE & wxFLP_OVERWRITE_PROMPT) != 0);
|
||||||
m_chkFileMustExist->SetValue((wxFLP_DEFAULT_STYLE & wxFLP_FILE_MUST_EXIST) != 0);
|
m_chkFileMustExist->SetValue((wxFLP_DEFAULT_STYLE & wxFLP_FILE_MUST_EXIST) != 0);
|
||||||
m_chkFileChangeDir->SetValue((wxFLP_DEFAULT_STYLE & wxFLP_CHANGE_DIR) != 0);
|
m_chkFileChangeDir->SetValue((wxFLP_DEFAULT_STYLE & wxFLP_CHANGE_DIR) != 0);
|
||||||
|
|
||||||
|
UpdateFilePickerMode();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if wxUSE_DIRPICKERCTRL
|
#if wxUSE_DIRPICKERCTRL
|
||||||
@@ -515,6 +541,23 @@ void PickerWidgetsPage::Reset()
|
|||||||
#endif
|
#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
|
// event handlers
|
||||||
@@ -577,6 +620,12 @@ void PickerWidgetsPage::OnCheckBox(wxCommandEvent &event)
|
|||||||
event.GetEventObject() == m_chkFontDescAsLabel ||
|
event.GetEventObject() == m_chkFontDescAsLabel ||
|
||||||
event.GetEventObject() == m_chkFontUseFontForLabel)
|
event.GetEventObject() == m_chkFontUseFontForLabel)
|
||||||
RecreatePicker(Picker_Font);
|
RecreatePicker(Picker_Font);
|
||||||
|
|
||||||
|
if (event.GetEventObject() == m_radioFilePickerMode)
|
||||||
|
{
|
||||||
|
UpdateFilePickerMode();
|
||||||
|
RecreatePicker(Picker_File);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // wxUSE_COLOURPICKERCTRL || wxUSE_FILEPICKERCTRL || wxUSE_DIRPICKERCTRL || wxUSE_FONTPICKERCTRL
|
#endif // wxUSE_COLOURPICKERCTRL || wxUSE_FILEPICKERCTRL || wxUSE_DIRPICKERCTRL || wxUSE_FONTPICKERCTRL
|
||||||
|
@@ -55,6 +55,19 @@ bool wxFileDirPickerCtrlBase::CreateBase( wxWindow *parent, wxWindowID id,
|
|||||||
style, validator, name))
|
style, validator, name))
|
||||||
return false;
|
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...
|
// create a wxFilePickerWidget or a wxDirPickerWidget...
|
||||||
if (!CreatePicker(this, path, message, wildcard))
|
if (!CreatePicker(this, path, message, wildcard))
|
||||||
return false;
|
return false;
|
||||||
|
@@ -57,6 +57,9 @@ bool wxFileDialogBase::Create(wxWindow *parent,
|
|||||||
m_windowStyle = style;
|
m_windowStyle = style;
|
||||||
m_filterIndex = 0;
|
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
|
// check that the styles are not contradictory
|
||||||
wxASSERT_MSG( !(HasFlag(wxFD_SAVE) && HasFlag(wxFD_OPEN)),
|
wxASSERT_MSG( !(HasFlag(wxFD_SAVE) && HasFlag(wxFD_OPEN)),
|
||||||
_T("can't specify both wxFD_SAVE and wxFD_OPEN at once") );
|
_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
|
// create the dialog associated with this button
|
||||||
m_path = path;
|
m_path = path;
|
||||||
return CreateDialog(message, wildcard);
|
m_message = message;
|
||||||
|
m_wildcard = wildcard;
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxGenericFileDirButton::OnButtonClick(wxCommandEvent& WXUNUSED(ev))
|
void wxGenericFileDirButton::OnButtonClick(wxCommandEvent& WXUNUSED(ev))
|
||||||
{
|
{
|
||||||
if (m_dialog->ShowModal() == wxID_OK)
|
wxDialog *p = CreateDialog();
|
||||||
|
if (p->ShowModal() == wxID_OK)
|
||||||
{
|
{
|
||||||
// save the path
|
// save updated path in m_path
|
||||||
UpdatePathFromDialog();
|
UpdatePathFromDialog(p);
|
||||||
|
|
||||||
// fire an event
|
// fire an event
|
||||||
wxFileDirPickerEvent event(GetEventType(), this, GetId(), m_path);
|
wxFileDirPickerEvent event(GetEventType(), this, GetId(), m_path);
|
||||||
GetEventHandler()->ProcessEvent(event);
|
GetEventHandler()->ProcessEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wxDELETE(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // wxUSE_FILEPICKERCTRL || wxUSE_DIRPICKERCTRL
|
#endif // wxUSE_FILEPICKERCTRL || wxUSE_DIRPICKERCTRL
|
||||||
|
@@ -66,9 +66,13 @@ bool wxFileButton::Create( wxWindow *parent, wxWindowID id,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// create the dialog associated with this button
|
// 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);
|
SetWindowStyle(style);
|
||||||
m_path = path;
|
m_path = path;
|
||||||
if (!CreateDialog(message, wildcard))
|
m_message = message;
|
||||||
|
m_wildcard = wildcard;
|
||||||
|
if ((m_dialog = CreateDialog()) == NULL)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// little trick used to avoid problems when there are other GTK windows 'grabbed':
|
// 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)
|
if (ev.GetId() == wxID_OK)
|
||||||
{
|
{
|
||||||
// ...update our path
|
// ...update our path
|
||||||
UpdatePathFromDialog();
|
UpdatePathFromDialog(m_dialog);
|
||||||
|
|
||||||
// ...and fire an event
|
// ...and fire an event
|
||||||
wxFileDirPickerEvent event(wxEVT_COMMAND_FILEPICKER_CHANGED, this, GetId(), m_path);
|
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
|
// create the dialog associated with this button
|
||||||
SetWindowStyle(style);
|
SetWindowStyle(style);
|
||||||
m_path = path;
|
m_message = message;
|
||||||
if (!CreateDialog(message, wildcard))
|
m_wildcard = wildcard;
|
||||||
|
if ((m_dialog = CreateDialog()) == NULL)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// little trick used to avoid problems when there are other GTK windows 'grabbed':
|
// 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
|
#ifdef GTK_IS_FILE_CHOOSER_BUTTON
|
||||||
else if (GTK_IS_FILE_CHOOSER_BUTTON(m_widget))
|
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 ?
|
// FIXME: what should be done here ?
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@@ -136,8 +136,7 @@ wxFileDialog::wxFileDialog(wxWindow *parent,
|
|||||||
wildCard, style, pos, sz, name)
|
wildCard, style, pos, sz, name)
|
||||||
|
|
||||||
{
|
{
|
||||||
if ( ( m_windowStyle & wxFD_MULTIPLE ) && ( m_windowStyle & wxFD_SAVE ) )
|
// NB: all style checks are done by wxFileDialogBase::Create
|
||||||
m_windowStyle &= ~wxFD_MULTIPLE;
|
|
||||||
|
|
||||||
m_bMovedWindow = false;
|
m_bMovedWindow = false;
|
||||||
|
|
||||||
|
@@ -78,8 +78,7 @@ wxFileDialog::wxFileDialog (
|
|||||||
:wxFileDialogBase(pParent, rsMessage, rsDefaultDir, rsDefaultFileName, rsWildCard, lStyle, rPos, sz, name)
|
:wxFileDialogBase(pParent, rsMessage, rsDefaultDir, rsDefaultFileName, rsWildCard, lStyle, rPos, sz, name)
|
||||||
|
|
||||||
{
|
{
|
||||||
if ((m_windowStyle & wxFD_MULTIPLE) && (m_windowStyle & wxFD_SAVE))
|
// NB: all style checks are done by wxFileDialogBase::Create
|
||||||
m_windowStyle &= ~wxFD_MULTIPLE;
|
|
||||||
|
|
||||||
m_filterIndex = 1;
|
m_filterIndex = 1;
|
||||||
} // end of wxFileDialog::wxFileDialog
|
} // end of wxFileDialog::wxFileDialog
|
||||||
|
Reference in New Issue
Block a user