add support for custom controls in file dialog in wxGTK and generic versions; also allow using generic dialogs in the sample with wxGTK2 (patch 1846837)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@52252 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -229,6 +229,7 @@ All (GUI):
|
||||
- Added wxNotificationMessage class for non-intrusive notifications
|
||||
- Added wxWindow::Show/HideWithEffect()
|
||||
- Added wxWrapSizer
|
||||
- Added custom controls support to wxFileDialog (Diaa Sami and Marcin Wojdyr)
|
||||
- Added wxDC::StretchBlit() for wxMac and wxMSW (Vince Harron).
|
||||
- Added support for drop down toolbar buttons (Tim Kosse).
|
||||
- Added support for labels for toolbar controls (Vince Harron).
|
||||
|
@@ -116,6 +116,15 @@ Destructor.
|
||||
|
||||
Returns the default directory.
|
||||
|
||||
\membersection{wxFileDialog::GetExtraControl}\label{wxfiledialoggetextracontrol}
|
||||
|
||||
\constfunc{wxWindow* }{GetExtraControl}{\void}
|
||||
|
||||
If functions
|
||||
\helpref{SetExtraControlCreator}{wxfiledialogsetextracontrolcreator}
|
||||
and \helpref{ShowModal}{wxfiledialogshowmodal} were called,
|
||||
returns the extra window. Otherwise returns \NULL.
|
||||
|
||||
\membersection{wxFileDialog::GetFilename}\label{wxfiledialoggetfilename}
|
||||
|
||||
\constfunc{wxString}{GetFilename}{\void}
|
||||
@@ -175,6 +184,26 @@ Returns the file dialog wildcard.
|
||||
|
||||
Sets the default directory.
|
||||
|
||||
\membersection{wxFileDialog::SetExtraControlCreator}\label{wxfiledialogsetextracontrolcreator}
|
||||
|
||||
\begin{verbatim}
|
||||
typedef wxWindow* (*ExtraControlCreatorFunction)(wxWindow*);
|
||||
\end{verbatim}
|
||||
\func{bool}{SetExtraControlCreator}{\param{t\_extraControlCreator }{creator}}
|
||||
|
||||
Customize file dialog by adding extra window, which is typically placed
|
||||
below the list of files and above the buttons.
|
||||
|
||||
SetExtraControlCreator can be called only once, before calling
|
||||
\helpref{ShowModal}{wxfiledialogshowmodal}.
|
||||
The {\tt creator} function should take pointer to parent window (file dialog)
|
||||
and should return a window allocated with operator new.
|
||||
|
||||
Supported platforms: wxGTK, wxUniv.
|
||||
|
||||
\wxheading{Return value}
|
||||
{\tt true} if adding extra controls is supported, {\tt false} otherwise.
|
||||
|
||||
\membersection{wxFileDialog::SetFilename}\label{wxfiledialogsetfilename}
|
||||
|
||||
\func{void}{SetFilename}{\param{const wxString\& }{setfilename}}
|
||||
|
@@ -85,6 +85,9 @@ public:
|
||||
Create(parent, message, defaultDir, defaultFile, wildCard, style, pos, sz, name);
|
||||
}
|
||||
|
||||
virtual ~wxFileDialogBase() {}
|
||||
|
||||
|
||||
bool Create(wxWindow *parent,
|
||||
const wxString& message = wxFileSelectorPromptStr,
|
||||
const wxString& defaultDir = wxEmptyString,
|
||||
@@ -113,6 +116,17 @@ public:
|
||||
virtual wxString GetWildcard() const { return m_wildCard; }
|
||||
virtual int GetFilterIndex() const { return m_filterIndex; }
|
||||
|
||||
// this function is called with wxFileDialog as parameter and should
|
||||
// create the window containing the extra controls we want to show in it
|
||||
typedef wxWindow *(*ExtraControlCreatorFunction)(wxWindow*);
|
||||
|
||||
// extra controls are currently supported in GTK and generic versions
|
||||
// only currently
|
||||
virtual bool SupportsExtraControl() const { return false; }
|
||||
|
||||
bool SetExtraControlCreator(ExtraControlCreatorFunction WXUNUSED(c));
|
||||
wxWindow *GetExtraControl() const { return m_extraControl; }
|
||||
|
||||
// Utility functions
|
||||
|
||||
#if WXWIN_COMPATIBILITY_2_6
|
||||
@@ -137,13 +151,20 @@ protected:
|
||||
wxString m_fileName;
|
||||
wxString m_wildCard;
|
||||
int m_filterIndex;
|
||||
wxWindow* m_extraControl;
|
||||
|
||||
// returns true if control is created (if it already exists returns false)
|
||||
bool CreateExtraControl();
|
||||
|
||||
private:
|
||||
ExtraControlCreatorFunction m_extraControlCreator;
|
||||
|
||||
void Init();
|
||||
DECLARE_DYNAMIC_CLASS(wxFileDialogBase)
|
||||
DECLARE_NO_COPY_CLASS(wxFileDialogBase)
|
||||
};
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// wxFileDialog convenience functions
|
||||
//----------------------------------------------------------------------------
|
||||
|
@@ -82,6 +82,7 @@ public:
|
||||
{ return m_filectrl->GetWildcard(); }
|
||||
virtual int GetFilterIndex() const
|
||||
{ return m_filectrl->GetFilterIndex(); }
|
||||
virtual bool SupportsExtraControl() const { return true; }
|
||||
|
||||
// implementation only from now on
|
||||
// -------------------------------
|
||||
@@ -113,6 +114,8 @@ protected:
|
||||
|
||||
private:
|
||||
void Init();
|
||||
wxBitmapButton* AddBitmapButton( wxWindowID winId, const wxArtID& artId,
|
||||
const wxString& tip, wxSizer *sizer );
|
||||
|
||||
DECLARE_DYNAMIC_CLASS(wxGenericFileDialog)
|
||||
DECLARE_EVENT_TABLE()
|
||||
|
@@ -30,8 +30,7 @@ public:
|
||||
const wxPoint& pos = wxDefaultPosition,
|
||||
const wxSize& sz = wxDefaultSize,
|
||||
const wxString& name = wxFileDialogNameStr);
|
||||
|
||||
virtual ~wxFileDialog() {}
|
||||
virtual ~wxFileDialog() { delete m_extraControl; }
|
||||
|
||||
virtual wxString GetPath() const;
|
||||
virtual void GetPaths(wxArrayString& paths) const;
|
||||
@@ -48,8 +47,8 @@ public:
|
||||
virtual void SetFilterIndex(int filterIndex);
|
||||
|
||||
virtual int ShowModal();
|
||||
virtual bool Show( bool show = true );
|
||||
|
||||
virtual bool SupportsExtraControl() const { return true; }
|
||||
|
||||
|
||||
protected:
|
||||
|
@@ -112,6 +112,8 @@ COND_PLATFORM_OS2_1___dialogs___os2_emxbindcmd = $(NM) dialogs$(EXEEXT) | if \
|
||||
@COND_SHARED_0_TOOLKIT_MAC_WXUNIV_0@__GENERIC_DIALOGS_IN_NATIVE_BUILDS_OBJECTS \
|
||||
@COND_SHARED_0_TOOLKIT_MAC_WXUNIV_0@ = dialogs_colrdlgg.o dialogs_dirdlgg.o \
|
||||
@COND_SHARED_0_TOOLKIT_MAC_WXUNIV_0@ dialogs_filedlgg.o
|
||||
@COND_TOOLKIT_GTK_TOOLKIT_VERSION_2@__GENERIC_DIALOGS_IN_NATIVE_BUILDS_OBJECTS \
|
||||
@COND_TOOLKIT_GTK_TOOLKIT_VERSION_2@ = dialogs_filedlgg.o
|
||||
@COND_SHARED_0_TOOLKIT_PM_WXUNIV_0@__GENERIC_DIALOGS_IN_NATIVE_BUILDS_OBJECTS \
|
||||
@COND_SHARED_0_TOOLKIT_PM_WXUNIV_0@ = dialogs_fontdlgg.o dialogs_filedlgg.o
|
||||
COND_MONOLITHIC_0___WXLIB_ADV_p = \
|
||||
@@ -237,6 +239,9 @@ dialogs_dialogs.o: $(srcdir)/dialogs.cpp
|
||||
@COND_SHARED_0_TOOLKIT_MAC_WXUNIV_0@dialogs_filedlgg.o: $(srcdir)/../../src/generic/filedlgg.cpp
|
||||
@COND_SHARED_0_TOOLKIT_MAC_WXUNIV_0@ $(CXXC) -c -o $@ $(DIALOGS_CXXFLAGS) $(srcdir)/../../src/generic/filedlgg.cpp
|
||||
|
||||
@COND_TOOLKIT_GTK_TOOLKIT_VERSION_2@dialogs_filedlgg.o: $(srcdir)/../../src/generic/filedlgg.cpp
|
||||
@COND_TOOLKIT_GTK_TOOLKIT_VERSION_2@ $(CXXC) -c -o $@ $(DIALOGS_CXXFLAGS) $(srcdir)/../../src/generic/filedlgg.cpp
|
||||
|
||||
@COND_SHARED_0_TOOLKIT_PM_WXUNIV_0@dialogs_filedlgg.o: $(srcdir)/../../src/generic/filedlgg.cpp
|
||||
@COND_SHARED_0_TOOLKIT_PM_WXUNIV_0@ $(CXXC) -c -o $@ $(DIALOGS_CXXFLAGS) $(srcdir)/../../src/generic/filedlgg.cpp
|
||||
|
||||
|
@@ -18,6 +18,9 @@
|
||||
$(WXTOPDIR)src/generic/dirdlgg.cpp
|
||||
$(WXTOPDIR)src/generic/filedlgg.cpp
|
||||
</if>
|
||||
<if cond="TOOLKIT=='GTK' and TOOLKIT_VERSION=='2'">
|
||||
$(WXTOPDIR)src/generic/filedlgg.cpp
|
||||
</if>
|
||||
<if cond="TOOLKIT=='PM' and WXUNIV=='0' and SHARED=='0'">
|
||||
$(WXTOPDIR)src/generic/fontdlgg.cpp
|
||||
$(WXTOPDIR)src/generic/filedlgg.cpp
|
||||
|
@@ -799,6 +799,43 @@ void MyFrame::MultiChoice(wxCommandEvent& WXUNUSED(event) )
|
||||
#endif // wxUSE_CHOICEDLG
|
||||
|
||||
#if wxUSE_FILEDLG
|
||||
|
||||
// panel with custom controls for file dialog
|
||||
class MyExtraPanel : public wxPanel
|
||||
{
|
||||
public:
|
||||
MyExtraPanel(wxWindow *parent);
|
||||
void OnCheckBox(wxCommandEvent& event) { m_btn->Enable(event.IsChecked()); }
|
||||
wxString GetInfo() const
|
||||
{
|
||||
return wxString::Format("checkbox value = %d", (int) m_cb->GetValue());
|
||||
}
|
||||
private:
|
||||
wxButton *m_btn;
|
||||
wxCheckBox *m_cb;
|
||||
};
|
||||
|
||||
MyExtraPanel::MyExtraPanel(wxWindow *parent)
|
||||
: wxPanel(parent)
|
||||
{
|
||||
m_btn = new wxButton(this, -1, _T("Custom Button"));
|
||||
m_btn->Enable(false);
|
||||
m_cb = new wxCheckBox(this, -1, _T("Enable Custom Button"));
|
||||
m_cb->Connect(wxID_ANY, wxEVT_COMMAND_CHECKBOX_CLICKED,
|
||||
wxCommandEventHandler(MyExtraPanel::OnCheckBox), NULL, this);
|
||||
wxBoxSizer *sizerTop = new wxBoxSizer(wxHORIZONTAL);
|
||||
sizerTop->Add(m_cb, wxSizerFlags().Centre().Border());
|
||||
sizerTop->AddStretchSpacer();
|
||||
sizerTop->Add(m_btn, wxSizerFlags().Right().Border());
|
||||
SetSizerAndFit(sizerTop);
|
||||
}
|
||||
|
||||
// a static method can be used instead of a function with most of compilers
|
||||
static wxWindow* createMyExtraPanel(wxWindow *parent)
|
||||
{
|
||||
return new MyExtraPanel(parent);
|
||||
}
|
||||
|
||||
void MyFrame::FileOpen(wxCommandEvent& WXUNUSED(event) )
|
||||
{
|
||||
wxFileDialog dialog
|
||||
@@ -814,18 +851,23 @@ void MyFrame::FileOpen(wxCommandEvent& WXUNUSED(event) )
|
||||
#endif
|
||||
);
|
||||
|
||||
dialog.SetExtraControlCreator(&createMyExtraPanel);
|
||||
dialog.CentreOnParent();
|
||||
dialog.SetDirectory(wxGetHomeDir());
|
||||
|
||||
if (dialog.ShowModal() == wxID_OK)
|
||||
{
|
||||
wxString info;
|
||||
MyExtraPanel *extra_panel
|
||||
= static_cast<MyExtraPanel*>(dialog.GetExtraControl());
|
||||
info.Printf(_T("Full file name: %s\n")
|
||||
_T("Path: %s\n")
|
||||
_T("Name: %s"),
|
||||
_T("Name: %s\n")
|
||||
_T("Custom window: %s"),
|
||||
dialog.GetPath().c_str(),
|
||||
dialog.GetDirectory().c_str(),
|
||||
dialog.GetFilename().c_str());
|
||||
dialog.GetFilename().c_str(),
|
||||
extra_panel->GetInfo().c_str());
|
||||
wxMessageDialog dialog2(this, info, _T("Selected file"));
|
||||
dialog2.ShowModal();
|
||||
}
|
||||
@@ -933,6 +975,7 @@ void MyFrame::FileOpenGeneric(wxCommandEvent& WXUNUSED(event) )
|
||||
_T("C++ files (*.cpp;*.h)|*.cpp;*.h")
|
||||
);
|
||||
|
||||
dialog.SetExtraControlCreator(&createMyExtraPanel);
|
||||
dialog.SetDirectory(wxGetHomeDir());
|
||||
|
||||
if (dialog.ShowModal() == wxID_OK)
|
||||
@@ -1264,8 +1307,7 @@ TestDefaultActionDialog::TestDefaultActionDialog( wxWindow *parent ) :
|
||||
if (button_sizer)
|
||||
main_sizer->Add( button_sizer, 0, wxALL|wxGROW, 5 );
|
||||
|
||||
SetSizer( main_sizer );
|
||||
main_sizer->Fit( this );
|
||||
SetSizerAndFit( main_sizer );
|
||||
}
|
||||
|
||||
void TestDefaultActionDialog::OnListBoxDClick(wxCommandEvent& event)
|
||||
@@ -1651,10 +1693,7 @@ MyModelessDialog::MyModelessDialog(wxWindow *parent)
|
||||
sizerTop->Add(btn, 1, wxEXPAND | wxALL, 5);
|
||||
sizerTop->Add(check, 1, wxEXPAND | wxALL, 5);
|
||||
|
||||
SetSizer(sizerTop);
|
||||
|
||||
sizerTop->SetSizeHints(this);
|
||||
sizerTop->Fit(this);
|
||||
SetSizerAndFit(sizerTop);
|
||||
}
|
||||
|
||||
void MyModelessDialog::OnButton(wxCommandEvent& WXUNUSED(event))
|
||||
@@ -1694,10 +1733,7 @@ MyModalDialog::MyModalDialog(wxWindow *parent)
|
||||
sizerTop->Add(m_btnDelete, 0, wxALIGN_CENTER | wxALL, 5);
|
||||
sizerTop->Add(btnOk, 0, wxALIGN_CENTER | wxALL, 5);
|
||||
|
||||
SetSizer(sizerTop);
|
||||
|
||||
sizerTop->SetSizeHints(this);
|
||||
sizerTop->Fit(this);
|
||||
SetSizerAndFit(sizerTop);
|
||||
|
||||
m_btnModal->SetFocus();
|
||||
m_btnModal->SetDefault();
|
||||
@@ -1800,9 +1836,8 @@ StdButtonSizerDialog::StdButtonSizerDialog(wxWindow *parent)
|
||||
|
||||
EnableDisableControls();
|
||||
|
||||
SetSizer(sizerTop);
|
||||
SetSizerAndFit(sizerTop);
|
||||
|
||||
sizerTop->SetSizeHints(this);
|
||||
wxCommandEvent ev;
|
||||
OnEvent(ev);
|
||||
}
|
||||
@@ -2015,8 +2050,7 @@ wxPanel* SettingsDialog::CreateGeneralSettingsPage(wxWindow* parent)
|
||||
|
||||
topSizer->Add( item0, 1, wxGROW|wxALIGN_CENTRE|wxALL, 5 );
|
||||
|
||||
panel->SetSizer(topSizer);
|
||||
topSizer->Fit(panel);
|
||||
panel->SetSizerAndFit(topSizer);
|
||||
|
||||
return panel;
|
||||
}
|
||||
@@ -2074,8 +2108,7 @@ wxPanel* SettingsDialog::CreateAestheticSettingsPage(wxWindow* parent)
|
||||
topSizer->Add( item0, 1, wxGROW|wxALIGN_CENTRE|wxALL, 5 );
|
||||
topSizer->AddSpacer(5);
|
||||
|
||||
panel->SetSizer(topSizer);
|
||||
topSizer->Fit(panel);
|
||||
panel->SetSizerAndFit(topSizer);
|
||||
|
||||
return panel;
|
||||
}
|
||||
|
@@ -77,7 +77,8 @@ of MSW, MAC and OS2
|
||||
#define USE_DIRDLG_GENERIC \
|
||||
((USE_WXMSW || USE_WXMAC) && USE_GENERIC_DIALOGS && wxUSE_DIRDLG)
|
||||
#define USE_FILEDLG_GENERIC \
|
||||
((((USE_WXMSW || USE_WXMAC || USE_WXPM) && USE_GENERIC_DIALOGS) || USE_WXWINCE) && wxUSE_FILEDLG)
|
||||
((((USE_WXMSW || USE_WXMAC || USE_WXPM || USE_WXGTK) \
|
||||
&& USE_GENERIC_DIALOGS) || USE_WXWINCE) && wxUSE_FILEDLG)
|
||||
#define USE_FONTDLG_GENERIC \
|
||||
((USE_WXMSW || USE_WXMACFONTDLG || USE_WXPM) && USE_GENERIC_DIALOGS && wxUSE_FONTDLG)
|
||||
|
||||
|
@@ -35,8 +35,10 @@ IMPLEMENT_DYNAMIC_CLASS(wxFileDialogBase, wxDialog)
|
||||
|
||||
void wxFileDialogBase::Init()
|
||||
{
|
||||
m_filterIndex =
|
||||
m_filterIndex = 0;
|
||||
m_windowStyle = 0;
|
||||
m_extraControl = NULL;
|
||||
m_extraControlCreator = NULL;
|
||||
}
|
||||
|
||||
bool wxFileDialogBase::Create(wxWindow *parent,
|
||||
@@ -149,6 +151,23 @@ wxString wxFileDialogBase::AppendExtension(const wxString &filePath,
|
||||
return filePath + ext;
|
||||
}
|
||||
|
||||
bool wxFileDialogBase::SetExtraControlCreator(ExtraControlCreatorFunction c)
|
||||
{
|
||||
wxCHECK_MSG( !m_extraControlCreator, false,
|
||||
"wxFileDialog::SetExtraControl() called second time" );
|
||||
|
||||
m_extraControlCreator = c;
|
||||
return SupportsExtraControl();
|
||||
}
|
||||
|
||||
bool wxFileDialogBase::CreateExtraControl()
|
||||
{
|
||||
if (!m_extraControlCreator || m_extraControl)
|
||||
return false;
|
||||
m_extraControl = (*m_extraControlCreator)(this);
|
||||
return true;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// wxFileDialog convenience functions
|
||||
//----------------------------------------------------------------------------
|
||||
|
@@ -912,6 +912,7 @@ bool wxGenericFileCtrl::Create( wxWindow *parent,
|
||||
this->m_style = style;
|
||||
m_inSelected = false;
|
||||
m_noSelChgEvent = false;
|
||||
m_check = NULL;
|
||||
|
||||
// check that the styles are not contradictory
|
||||
wxASSERT_MSG( !( ( m_style & wxFC_SAVE ) && ( m_style & wxFC_OPEN ) ),
|
||||
@@ -947,10 +948,11 @@ bool wxGenericFileCtrl::Create( wxWindow *parent,
|
||||
|
||||
wxBoxSizer *staticsizer = new wxBoxSizer( wxHORIZONTAL );
|
||||
if ( is_pda )
|
||||
staticsizer->Add( new wxStaticText( this, wxID_ANY, _( "Current directory:" ) ), 0, wxRIGHT, 10 );
|
||||
staticsizer->Add( new wxStaticText( this, wxID_ANY, _( "Current directory:" ) ),
|
||||
wxSizerFlags().DoubleBorder(wxRIGHT) );
|
||||
m_static = new wxStaticText( this, wxID_ANY, m_dir );
|
||||
staticsizer->Add( m_static, 1 );
|
||||
mainsizer->Add( staticsizer, 0, wxEXPAND | wxLEFT | wxRIGHT | wxBOTTOM, 10 );
|
||||
mainsizer->Add( staticsizer, wxSizerFlags().Expand().Border());
|
||||
|
||||
long style2 = wxLC_LIST;
|
||||
if ( !( m_style & wxFC_MULTIPLE ) )
|
||||
@@ -979,33 +981,25 @@ bool wxGenericFileCtrl::Create( wxWindow *parent,
|
||||
|
||||
wxBoxSizer *textsizer = new wxBoxSizer( wxHORIZONTAL );
|
||||
textsizer->Add( m_text, wxSizerFlags( 1 ).Centre().Border() );
|
||||
textsizer->Add( m_choice, wxSizerFlags( 1 ).Centre().Border() );
|
||||
mainsizer->Add( textsizer, wxSizerFlags().Expand() );
|
||||
|
||||
m_check = NULL;
|
||||
textsizer->Add( m_choice, wxSizerFlags( 1 ).Centre().Border() );
|
||||
}
|
||||
else // !is_pda
|
||||
{
|
||||
mainsizer->Add( m_list, wxSizerFlags( 1 ).Expand().DoubleHorzBorder() );
|
||||
|
||||
wxBoxSizer *textsizer = new wxBoxSizer( wxHORIZONTAL );
|
||||
textsizer->Add( m_text, wxSizerFlags( 1 ).Centre().
|
||||
DoubleBorder( wxLEFT | wxRIGHT | wxTOP ) );
|
||||
mainsizer->Add( textsizer, wxSizerFlags().Expand() );
|
||||
|
||||
wxSizerFlags flagsCentre;
|
||||
flagsCentre.Centre().DoubleBorder();
|
||||
mainsizer->Add( m_list, wxSizerFlags( 1 ).Expand().Border() );
|
||||
mainsizer->Add( m_text, wxSizerFlags().Expand().Border() );
|
||||
|
||||
wxBoxSizer *choicesizer = new wxBoxSizer( wxHORIZONTAL );
|
||||
choicesizer->Add( m_choice, wxSizerFlags( flagsCentre ).Proportion( 1 ) );
|
||||
choicesizer->Add( m_choice, wxSizerFlags( 1 ).Centre() );
|
||||
|
||||
if ( !( m_style & wxFC_NOSHOWHIDDEN ) )
|
||||
{
|
||||
m_check = new wxCheckBox( this, ID_CHECK, _( "Show &hidden files" ) );
|
||||
choicesizer->Add( m_check, flagsCentre );
|
||||
choicesizer->Add( m_check, wxSizerFlags().Centre().DoubleBorder(wxLEFT) );
|
||||
}
|
||||
|
||||
mainsizer->Add( choicesizer, wxSizerFlags().Expand() );
|
||||
mainsizer->Add( choicesizer, wxSizerFlags().Expand().Border() );
|
||||
}
|
||||
|
||||
SetWildcard( wildCard );
|
||||
|
@@ -103,7 +103,7 @@
|
||||
#define ID_LIST_MODE (wxID_FILEDLGG )
|
||||
#define ID_REPORT_MODE (wxID_FILEDLGG + 1)
|
||||
#define ID_UP_DIR (wxID_FILEDLGG + 2)
|
||||
#define ID_PARENT_DIR (wxID_FILEDLGG + 3)
|
||||
#define ID_HOME_DIR (wxID_FILEDLGG + 3)
|
||||
#define ID_NEW_DIR (wxID_FILEDLGG + 4)
|
||||
#define ID_FILE_CTRL (wxID_FILEDLGG + 5)
|
||||
|
||||
@@ -113,7 +113,7 @@ BEGIN_EVENT_TABLE(wxGenericFileDialog,wxDialog)
|
||||
EVT_BUTTON(ID_LIST_MODE, wxGenericFileDialog::OnList)
|
||||
EVT_BUTTON(ID_REPORT_MODE, wxGenericFileDialog::OnReport)
|
||||
EVT_BUTTON(ID_UP_DIR, wxGenericFileDialog::OnUp)
|
||||
EVT_BUTTON(ID_PARENT_DIR, wxGenericFileDialog::OnHome)
|
||||
EVT_BUTTON(ID_HOME_DIR, wxGenericFileDialog::OnHome)
|
||||
EVT_BUTTON(ID_NEW_DIR, wxGenericFileDialog::OnNew)
|
||||
EVT_BUTTON(wxID_OK, wxGenericFileDialog::OnOk)
|
||||
EVT_FILECTRL_FILEACTIVATED(ID_FILE_CTRL, wxGenericFileDialog::OnFileActivated)
|
||||
@@ -212,54 +212,28 @@ bool wxGenericFileDialog::Create( wxWindow *parent,
|
||||
wxBoxSizer *mainsizer = new wxBoxSizer( wxVERTICAL );
|
||||
|
||||
wxBoxSizer *buttonsizer = new wxBoxSizer( wxHORIZONTAL );
|
||||
|
||||
wxBitmapButton *but;
|
||||
|
||||
but = new wxBitmapButton(this, ID_LIST_MODE,
|
||||
wxArtProvider::GetBitmap(wxART_LIST_VIEW, wxART_BUTTON));
|
||||
#if wxUSE_TOOLTIPS
|
||||
but->SetToolTip( _("View files as a list view") );
|
||||
#endif
|
||||
buttonsizer->Add( but, 0, wxALL, 5 );
|
||||
|
||||
but = new wxBitmapButton(this, ID_REPORT_MODE,
|
||||
wxArtProvider::GetBitmap(wxART_REPORT_VIEW, wxART_BUTTON));
|
||||
#if wxUSE_TOOLTIPS
|
||||
but->SetToolTip( _("View files as a detailed view") );
|
||||
#endif
|
||||
buttonsizer->Add( but, 0, wxALL, 5 );
|
||||
|
||||
AddBitmapButton( ID_LIST_MODE, wxART_LIST_VIEW,
|
||||
_("View files as a list view"), buttonsizer );
|
||||
AddBitmapButton( ID_REPORT_MODE, wxART_REPORT_VIEW,
|
||||
_("View files as a detailed view"), buttonsizer );
|
||||
buttonsizer->Add( 30, 5, 1 );
|
||||
|
||||
m_upDirButton = new wxBitmapButton(this, ID_UP_DIR,
|
||||
wxArtProvider::GetBitmap(wxART_GO_DIR_UP, wxART_BUTTON));
|
||||
#if wxUSE_TOOLTIPS
|
||||
m_upDirButton->SetToolTip( _("Go to parent directory") );
|
||||
#endif
|
||||
buttonsizer->Add( m_upDirButton, 0, wxALL, 5 );
|
||||
m_upDirButton = AddBitmapButton( ID_UP_DIR, wxART_GO_DIR_UP,
|
||||
_("Go to parent directory"), buttonsizer );
|
||||
|
||||
#ifndef __DOS__ // VS: Home directory is meaningless in MS-DOS...
|
||||
but = new wxBitmapButton(this, ID_PARENT_DIR,
|
||||
wxArtProvider::GetBitmap(wxART_GO_HOME, wxART_BUTTON));
|
||||
#if wxUSE_TOOLTIPS
|
||||
but->SetToolTip( _("Go to home directory") );
|
||||
#endif
|
||||
buttonsizer->Add( but, 0, wxALL, 5);
|
||||
|
||||
AddBitmapButton( ID_HOME_DIR, wxART_GO_HOME,
|
||||
_("Go to home directory"), buttonsizer );
|
||||
buttonsizer->Add( 20, 20 );
|
||||
#endif //!__DOS__
|
||||
|
||||
m_newDirButton = new wxBitmapButton(this, ID_NEW_DIR,
|
||||
wxArtProvider::GetBitmap(wxART_NEW_DIR, wxART_BUTTON));
|
||||
#if wxUSE_TOOLTIPS
|
||||
m_newDirButton->SetToolTip( _("Create new directory") );
|
||||
#endif
|
||||
buttonsizer->Add( m_newDirButton, 0, wxALL, 5 );
|
||||
m_newDirButton = AddBitmapButton( ID_NEW_DIR, wxART_NEW_DIR,
|
||||
_("Create new directory"), buttonsizer );
|
||||
|
||||
if (is_pda)
|
||||
mainsizer->Add( buttonsizer, 0, wxALL | wxEXPAND, 0 );
|
||||
mainsizer->Add( buttonsizer, wxSizerFlags().Expand() );
|
||||
else
|
||||
mainsizer->Add( buttonsizer, 0, wxALL | wxEXPAND, 5 );
|
||||
mainsizer->Add( buttonsizer, wxSizerFlags().Expand()
|
||||
.Border( wxLEFT | wxRIGHT | wxTOP ) );
|
||||
|
||||
long style2 = 0;
|
||||
if ( HasFdFlag(wxFD_MULTIPLE) )
|
||||
@@ -283,31 +257,21 @@ bool wxGenericFileDialog::Create( wxWindow *parent,
|
||||
m_filectrl->ChangeToReportMode();
|
||||
}
|
||||
|
||||
if (is_pda)
|
||||
{
|
||||
// PDAs have a different screen layout
|
||||
mainsizer->Add(m_filectrl, wxSizerFlags(1).Expand().HorzBorder());
|
||||
|
||||
wxSizer *bsizer = CreateButtonSizer(wxOK | wxCANCEL);
|
||||
if ( bsizer )
|
||||
mainsizer->Add(bsizer, wxSizerFlags().Expand().Border());
|
||||
}
|
||||
else // !is_pda
|
||||
{
|
||||
mainsizer->Add(m_filectrl, wxSizerFlags(1).Expand().DoubleHorzBorder());
|
||||
|
||||
wxBoxSizer *okcancelsizer = new wxBoxSizer( wxHORIZONTAL );
|
||||
okcancelsizer->Add(new wxButton(this, wxID_OK), wxSizerFlags().DoubleBorder().Centre());
|
||||
okcancelsizer->Add(new wxButton(this, wxID_CANCEL), wxSizerFlags().DoubleBorder().Centre());
|
||||
mainsizer->Add(okcancelsizer, wxSizerFlags().Center());
|
||||
if (is_pda)
|
||||
mainsizer->Add(bsizer, wxSizerFlags().Expand().Border());
|
||||
else
|
||||
mainsizer->Add(bsizer, wxSizerFlags().Expand().DoubleBorder());
|
||||
}
|
||||
|
||||
SetAutoLayout( true );
|
||||
SetSizer( mainsizer );
|
||||
|
||||
if (!is_pda)
|
||||
{
|
||||
mainsizer->Fit( this );
|
||||
mainsizer->SetSizeHints( this );
|
||||
|
||||
Centre( wxBOTH );
|
||||
@@ -332,8 +296,28 @@ wxGenericFileDialog::~wxGenericFileDialog()
|
||||
}
|
||||
}
|
||||
|
||||
wxBitmapButton* wxGenericFileDialog::AddBitmapButton( wxWindowID winId,
|
||||
const wxArtID& artId,
|
||||
const wxString& tip,
|
||||
wxSizer *sizer)
|
||||
{
|
||||
wxBitmapButton *but = new wxBitmapButton(this, winId,
|
||||
wxArtProvider::GetBitmap(artId, wxART_BUTTON));
|
||||
but->SetToolTip(tip);
|
||||
sizer->Add(but, wxSizerFlags().Border());
|
||||
return but;
|
||||
}
|
||||
|
||||
int wxGenericFileDialog::ShowModal()
|
||||
{
|
||||
if (CreateExtraControl())
|
||||
{
|
||||
wxSizer *sizer = GetSizer();
|
||||
sizer->Insert(2 /* after m_filectrl */, m_extraControl,
|
||||
wxSizerFlags().Expand().HorzBorder());
|
||||
sizer->Fit(this);
|
||||
}
|
||||
|
||||
m_filectrl->SetDirectory(m_dir);
|
||||
|
||||
return wxDialog::ShowModal();
|
||||
|
@@ -131,6 +131,11 @@ static void gtk_filedialog_update_preview_callback(GtkFileChooser *chooser,
|
||||
|
||||
} // extern "C"
|
||||
|
||||
static void wxInsertChildInFileDialog(wxWindow* WXUNUSED(parent),
|
||||
wxWindow* WXUNUSED(child))
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// wxFileDialog
|
||||
@@ -151,6 +156,7 @@ wxFileDialog::wxFileDialog(wxWindow *parent, const wxString& message,
|
||||
const wxString& name)
|
||||
: wxFileDialogBase()
|
||||
{
|
||||
m_insertCallback = wxInsertChildInFileDialog;
|
||||
parent = GetParentForModalDialog(parent);
|
||||
|
||||
if (!wxFileDialogBase::Create(parent, message, defaultDir, defaultFileName,
|
||||
@@ -276,6 +282,7 @@ wxFileDialog::wxFileDialog(wxWindow *parent, const wxString& message,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void wxFileDialog::OnFakeOk(wxCommandEvent& WXUNUSED(event))
|
||||
{
|
||||
EndDialog(wxID_OK);
|
||||
@@ -283,12 +290,19 @@ void wxFileDialog::OnFakeOk(wxCommandEvent& WXUNUSED(event))
|
||||
|
||||
int wxFileDialog::ShowModal()
|
||||
{
|
||||
return wxDialog::ShowModal();
|
||||
if (CreateExtraControl())
|
||||
{
|
||||
GtkWidget *control = m_extraControl->m_widget;
|
||||
|
||||
// see wxNotebook::InsertPage() for explaination
|
||||
// why gtk_widget_unparent() is not used here
|
||||
control->parent = NULL;
|
||||
|
||||
gtk_widget_show(control);
|
||||
gtk_file_chooser_set_extra_widget(GTK_FILE_CHOOSER(m_widget), control);
|
||||
}
|
||||
|
||||
bool wxFileDialog::Show( bool show )
|
||||
{
|
||||
return wxDialog::Show( show );
|
||||
return wxDialog::ShowModal();
|
||||
}
|
||||
|
||||
void wxFileDialog::DoSetSize(int WXUNUSED(x), int WXUNUSED(y),
|
||||
|
Reference in New Issue
Block a user