]> git.saurik.com Git - wxWidgets.git/commitdiff
Commit pickers-fixes.patch added to 1472329 (Francesco Montorsi)
authorMichael Wetherell <mike.wetherell@ntlworld.com>
Fri, 2 Jun 2006 12:00:30 +0000 (12:00 +0000)
committerMichael Wetherell <mike.wetherell@ntlworld.com>
Fri, 2 Jun 2006 12:00:30 +0000 (12:00 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@39528 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

14 files changed:
include/wx/clrpicker.h
include/wx/filepicker.h
include/wx/fontpicker.h
include/wx/generic/clrpickerg.h
include/wx/generic/filepickerg.h
include/wx/gtk/filepicker.h
samples/widgets/picker.cpp
src/common/filepickercmn.cpp
src/common/fldlgcmn.cpp
src/generic/filepickerg.cpp
src/gtk/filepicker.cpp
src/gtk/window.cpp
src/msw/filedlg.cpp
src/os2/filedlg.cpp

index fdd10bd80e94c114bd9750fe8ca4f5788160690a..e36b8cca944dd3ce8d42ab0200c3e55e71801c86 100644 (file)
@@ -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
index eb015b8ed6b8e66de4ac3c2131630fe7d61e55da..0564cf0e8e547dbddf1b82ea3109dbe32e4a5a9d 100644 (file)
@@ -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
index 88a29d4b55a8f77dcb9d98f5813e7d9dbb015230..e559e8d780a7fcad4718e70da2b4c0d2ffac5ab1 100644 (file)
@@ -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
index 16fe8413d5cb439636351ee99cd65759c5e58122..dfb67c8fa9d914321088855cab85b5669ddb2069 100644 (file)
@@ -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,
index 4485a30e195e4be0bbae0aa30cd8174e53380935..51a019b8df483118f7f0fbf0071055a07d6f2918 100644 (file)
@@ -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; }
 
index f9dab6e24798c1c49140eb0167579d2152add8d3..5e04b4f88aaff1a61f227a295d4f4b0182abaddc 100644 (file)
 // 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_
 
index 6512e9e91ee20ddeda0775f47188a680737a8860..74eab9c1c8a5a525394fbc3f6ca8bdef8599d0ac 100644 (file)
@@ -30,6 +30,7 @@
 #ifndef WX_PRECOMP
     #include "wx/app.h"
     #include "wx/log.h"
+    #include "wx/radiobox.h"
 #endif
 
 #include "wx/artprov.h"
 // 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
index ddd28f6c941e17575f247a7853c3345d0e51d2a6..3d09ab700b0ead5f590e8db07aa4fcafc13bff8b 100644 (file)
@@ -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;
index 115881214a2aace947819510a76fa38bc2bd1a14..1365b0fde43555f69317b2a55a4f46e31db5ed27 100644 (file)
@@ -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") );
index 32f76b8633b9c3beecd6fbcf08e469e18bea950f..f5f128d50d67b00472854bda41910742be6a13e7 100644 (file)
@@ -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
index a32f2cc185d8f816a670085ef240af2173323026..f6dc7254df429f83351c6e43412655cf55ab4a75 100644 (file)
@@ -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':
index 1f6fb8ba13857ae1fe08a3bfefb4d7c81e813441..5ebf62893df1f5649ea98234e84c50b38c278e83 100644 (file)
@@ -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
index 063377993f1f11078cebb3a11f1a022b8c34e3b8..3c09287d94802dac3ea891bff28fc51691069063 100644 (file)
@@ -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;
 
index 5f14190ee69654047768143869d7219838f29c46..4a968e951a5ac087a4921ddb20e95b13db59e56f 100644 (file)
@@ -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