Add an example of customizing "Save" file dialog too
Show doing it in the sample and also add a missing line to the example in the documentation.
This commit is contained in:
parent
88bade66ac
commit
475c2ca201
@ -331,6 +331,7 @@ public:
|
||||
// This object may be destroyed before the dialog, but must remain
|
||||
// alive until ShowModal() returns.
|
||||
EncryptHook customizeHook;
|
||||
dialog.SetCustomizeHook(customHook);
|
||||
|
||||
if ( dialog.ShowModal() == wxID_OK )
|
||||
{
|
||||
|
@ -2009,10 +2009,42 @@ void MyFrame::FileSave(wxCommandEvent& WXUNUSED(event) )
|
||||
|
||||
dialog.SetFilterIndex(1);
|
||||
|
||||
// This tests the (even more simplified) example from the docs.
|
||||
class EncryptHook : public wxFileDialogCustomizeHook
|
||||
{
|
||||
public:
|
||||
EncryptHook()
|
||||
: m_encrypt(false)
|
||||
{
|
||||
}
|
||||
|
||||
void AddCustomControls(wxFileDialogCustomize& customizer) wxOVERRIDE
|
||||
{
|
||||
m_checkbox = customizer.AddCheckBox("Encrypt");
|
||||
}
|
||||
|
||||
void TransferDataFromCustomControls() wxOVERRIDE
|
||||
{
|
||||
m_encrypt = m_checkbox->GetValue();
|
||||
}
|
||||
|
||||
bool Encrypt() const { return m_encrypt; }
|
||||
|
||||
private:
|
||||
wxFileDialogCheckBox* m_checkbox;
|
||||
|
||||
bool m_encrypt;
|
||||
};
|
||||
|
||||
EncryptHook customHook;
|
||||
dialog.SetCustomizeHook(customHook);
|
||||
|
||||
if (dialog.ShowModal() == wxID_OK)
|
||||
{
|
||||
wxLogMessage("%s, filter %d",
|
||||
dialog.GetPath(), dialog.GetFilterIndex());
|
||||
wxLogMessage("%s, filter %d%s",
|
||||
dialog.GetPath(),
|
||||
dialog.GetFilterIndex(),
|
||||
customHook.Encrypt() ? ", encrypt" : "");
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user