1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222
|
///////////////////////////////////////////////////////////////////////////////
// Name: wx/filedlgcustomize.h
// Purpose: Classes for wxFileDialog customization.
// Author: Vadim Zeitlin
// Created: 2022-05-26
// Copyright: (c) 2022 Vadim Zeitlin <vadim@wxwidgets.org>
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_FILEDLGCUSTOMIZE_H_
#define _WX_FILEDLGCUSTOMIZE_H_
#include "wx/vector.h"
class wxFileDialogCustomControlImpl;
class wxFileDialogButtonImpl;
class wxFileDialogCheckBoxImpl;
class wxFileDialogRadioButtonImpl;
class wxFileDialogChoiceImpl;
class wxFileDialogTextCtrlImpl;
class wxFileDialogStaticTextImpl;
class wxFileDialogCustomizeImpl;
// ----------------------------------------------------------------------------
// wxFileDialog custom controls
// ----------------------------------------------------------------------------
// All these controls support a very limited set of functions, but use the same
// names for the things that they do support as the corresponding "normal" wx
// classes and also generate some (but not all) of the same events.
// The base class for all wxFileDialog custom controls.
class WXDLLIMPEXP_CORE wxFileDialogCustomControl : public wxEvtHandler
{
public:
void Show(bool show = true);
void Hide() { Show(false); }
void Enable(bool enable = true);
void Disable() { Enable(false); }
~wxFileDialogCustomControl();
protected:
explicit wxFileDialogCustomControl(wxFileDialogCustomControlImpl* impl)
: m_impl(impl)
{
}
// By default custom controls don't generate any events, but some of them
// override this function to allow connecting to the selected events.
virtual bool OnDynamicBind(wxDynamicEventTableEntry& entry) wxOVERRIDE;
wxFileDialogCustomControlImpl* const m_impl;
wxDECLARE_NO_COPY_CLASS(wxFileDialogCustomControl);
};
// A class representing a custom button.
class WXDLLIMPEXP_CORE wxFileDialogButton : public wxFileDialogCustomControl
{
public:
// Ctor is only used by wxWidgets itself.
explicit wxFileDialogButton(wxFileDialogButtonImpl* impl);
protected:
virtual bool OnDynamicBind(wxDynamicEventTableEntry& entry) wxOVERRIDE;
private:
wxFileDialogButtonImpl* GetImpl() const;
wxDECLARE_NO_COPY_CLASS(wxFileDialogButton);
};
// A class representing a custom checkbox.
class WXDLLIMPEXP_CORE wxFileDialogCheckBox : public wxFileDialogCustomControl
{
public:
bool GetValue() const;
void SetValue(bool value);
// Ctor is only used by wxWidgets itself.
explicit wxFileDialogCheckBox(wxFileDialogCheckBoxImpl* impl);
protected:
virtual bool OnDynamicBind(wxDynamicEventTableEntry& entry) wxOVERRIDE;
private:
wxFileDialogCheckBoxImpl* GetImpl() const;
wxDECLARE_NO_COPY_CLASS(wxFileDialogCheckBox);
};
// A class representing a custom radio button.
class WXDLLIMPEXP_CORE wxFileDialogRadioButton : public wxFileDialogCustomControl
{
public:
bool GetValue() const;
void SetValue(bool value);
// Ctor is only used by wxWidgets itself.
explicit wxFileDialogRadioButton(wxFileDialogRadioButtonImpl* impl);
protected:
virtual bool OnDynamicBind(wxDynamicEventTableEntry& entry) wxOVERRIDE;
private:
wxFileDialogRadioButtonImpl* GetImpl() const;
wxDECLARE_NO_COPY_CLASS(wxFileDialogRadioButton);
};
// A class representing a custom combobox button.
class WXDLLIMPEXP_CORE wxFileDialogChoice : public wxFileDialogCustomControl
{
public:
int GetSelection() const;
void SetSelection(int n);
// Ctor is only used by wxWidgets itself.
explicit wxFileDialogChoice(wxFileDialogChoiceImpl* impl);
protected:
virtual bool OnDynamicBind(wxDynamicEventTableEntry& entry) wxOVERRIDE;
private:
wxFileDialogChoiceImpl* GetImpl() const;
wxDECLARE_NO_COPY_CLASS(wxFileDialogChoice);
};
// A class representing a custom text control.
class WXDLLIMPEXP_CORE wxFileDialogTextCtrl : public wxFileDialogCustomControl
{
public:
wxString GetValue() const;
void SetValue(const wxString& text);
// Ctor is only used by wxWidgets itself.
explicit wxFileDialogTextCtrl(wxFileDialogTextCtrlImpl* impl);
private:
wxFileDialogTextCtrlImpl* GetImpl() const;
wxDECLARE_NO_COPY_CLASS(wxFileDialogTextCtrl);
};
// A class representing a custom static text.
class WXDLLIMPEXP_CORE wxFileDialogStaticText : public wxFileDialogCustomControl
{
public:
void SetLabelText(const wxString& text);
// Ctor is only used by wxWidgets itself.
explicit wxFileDialogStaticText(wxFileDialogStaticTextImpl* impl);
private:
wxFileDialogStaticTextImpl* GetImpl() const;
wxDECLARE_NO_COPY_CLASS(wxFileDialogStaticText);
};
// ----------------------------------------------------------------------------
// wxFileDialogCustomizer is used by wxFileDialogCustomizeHook
// ----------------------------------------------------------------------------
class WXDLLIMPEXP_CORE wxFileDialogCustomize
{
public:
wxFileDialogButton* AddButton(const wxString& label);
wxFileDialogCheckBox* AddCheckBox(const wxString& label);
wxFileDialogRadioButton* AddRadioButton(const wxString& label);
wxFileDialogChoice* AddChoice(size_t n, const wxString* strings);
wxFileDialogTextCtrl* AddTextCtrl(const wxString& label = wxString());
wxFileDialogStaticText* AddStaticText(const wxString& label);
~wxFileDialogCustomize();
protected:
// Ctor is only used by wxWidgets itself.
//
// Note that we don't take ownership of the implementation pointer here,
// see the comment in the dtor for more details.
explicit wxFileDialogCustomize(wxFileDialogCustomizeImpl* impl)
: m_impl(impl)
{
}
wxVector<wxFileDialogCustomControl*> m_controls;
private:
template <typename T> T* StoreAndReturn(T* control);
wxFileDialogCustomizeImpl* const m_impl;
wxDECLARE_NO_COPY_CLASS(wxFileDialogCustomize);
};
// ----------------------------------------------------------------------------
// wxFileDialogCustomizeHook: used by wxFileDialog itself
// ----------------------------------------------------------------------------
class WXDLLIMPEXP_CORE wxFileDialogCustomizeHook
{
public:
// This method must be overridden to add custom controls to the dialog
// using the provided customizer object.
virtual void AddCustomControls(wxFileDialogCustomize& customizer) = 0;
// This method may be overridden to update the custom controls whenever
// something changes in the dialog.
virtual void UpdateCustomControls() { }
// This method should typically be overridden to save the values of the
// custom controls when the dialog is accepted.
virtual void TransferDataFromCustomControls() { }
virtual ~wxFileDialogCustomizeHook();
};
#endif // _WX_FILEDLGCUSTOMIZE_H_
|