00001
00002
00003
00004
00005
00006
00007
00008
00009
00011
00012 #ifndef _WX_SCROLLINGDIALOG_H_
00013 #define _WX_SCROLLINGDIALOG_H_
00014
00015 #include "wx/dialog.h"
00016 #include "wx/propdlg.h"
00017 #include "wx/scrolwin.h"
00018
00026 class wxScrollingDialog;
00027 class wxDialogHelper;
00028
00029
00030
00031
00032 #define wxDIALOG_ADAPTATION_NONE 0
00033
00034
00035 #define wxDIALOG_ADAPTATION_STANDARD_SIZER 1
00036
00037
00038 #define wxDIALOG_ADAPTATION_ANY_SIZER 2
00039
00040
00041 #define wxDIALOG_ADAPTATION_LOOSE_BUTTONS 3
00042
00043
00044 enum wxDialogLayoutAdaptationMode
00045 {
00046 wxDIALOG_ADAPTATION_MODE_DEFAULT = 0,
00047 wxDIALOG_ADAPTATION_MODE_ENABLED = 1,
00048 wxDIALOG_ADAPTATION_MODE_DISABLED = 2
00049 };
00050
00051 class wxDialogLayoutAdapter: public wxObject
00052 {
00053 DECLARE_CLASS(wxDialogLayoutAdapter)
00054 public:
00055 wxDialogLayoutAdapter() {}
00056
00058 virtual bool CanDoLayoutAdaptation(wxDialogHelper* dialog) = 0;
00059
00061 virtual bool DoLayoutAdaptation(wxDialogHelper* dialog) = 0;
00062 };
00063
00069 class wxStandardDialogLayoutAdapter: public wxDialogLayoutAdapter
00070 {
00071 DECLARE_CLASS(wxStandardDialogLayoutAdapter)
00072 public:
00073 wxStandardDialogLayoutAdapter() {}
00074
00075
00076
00078 virtual bool CanDoLayoutAdaptation(wxDialogHelper* dialog);
00079
00081 virtual bool DoLayoutAdaptation(wxDialogHelper* dialog);
00082
00083
00084
00086 virtual wxScrolledWindow* CreateScrolledWindow(wxWindow* parent);
00087
00089 virtual wxSizer* FindButtonSizer(bool stdButtonSizer, wxDialogHelper* dialog, wxSizer* sizer, int& retBorder, int accumlatedBorder = 0);
00090
00092 virtual bool IsOrdinaryButtonSizer(wxDialogHelper* dialog, wxBoxSizer* sizer);
00093
00095 virtual bool IsStandardButton(wxDialogHelper* dialog, wxButton* button);
00096
00098 virtual bool FindLooseButtons(wxDialogHelper* dialog, wxStdDialogButtonSizer* buttonSizer, wxSizer* sizer, int& count);
00099
00101 virtual void ReparentControls(wxWindow* parent, wxWindow* reparentTo, wxSizer* buttonSizer = NULL);
00102 static void DoReparentControls(wxWindow* parent, wxWindow* reparentTo, wxSizer* buttonSizer = NULL);
00103
00106 virtual bool FitWithScrolling(wxDialog* dialog, wxScrolledWindow* scrolledWindow);
00107 virtual bool FitWithScrolling(wxDialog* dialog, wxWindowList& windows);
00108 static bool DoFitWithScrolling(wxDialog* dialog, wxScrolledWindow* scrolledWindow);
00109 static bool DoFitWithScrolling(wxDialog* dialog, wxWindowList& windows);
00110
00112 virtual int MustScroll(wxDialog* dialog, wxSize& windowSize, wxSize& displaySize);
00113 static int DoMustScroll(wxDialog* dialog, wxSize& windowSize, wxSize& displaySize);
00114 };
00115
00121 class wxDialogHelper
00122 {
00123 public:
00124
00125 wxDialogHelper(wxDialog* dialog = NULL) { Init(); m_dialog = dialog; }
00126 virtual ~wxDialogHelper() {}
00127
00128 void Init();
00129
00130 void SetDialog(wxDialog* dialog) { m_dialog = dialog; }
00131 wxDialog* GetDialog() const { return m_dialog; }
00132
00134 virtual bool DoLayoutAdaptation();
00135
00137 virtual bool CanDoLayoutAdaptation();
00138
00140 virtual wxWindow* GetContentWindow() const { return NULL; }
00141
00143 void AddMainButtonId(wxWindowID id) { m_mainButtonIds.Add((int) id); }
00144 wxArrayInt& GetMainButtonIds() { return m_mainButtonIds; }
00145
00147 bool IsMainButtonId(wxWindowID id) const { return (m_mainButtonIds.Index((int) id) != wxNOT_FOUND); }
00148
00149
00150
00155 void SetLayoutAdaptationLevel(int level) { m_layoutAdaptationLevel = level; }
00156
00158 int GetLayoutAdaptationLevel() const { return m_layoutAdaptationLevel; }
00159
00161 void SetLayoutAdaptationMode(wxDialogLayoutAdaptationMode mode) { m_layoutAdaptationMode = mode; }
00162 wxDialogLayoutAdaptationMode GetLayoutAdaptationMode() const { return m_layoutAdaptationMode; }
00163
00165 void SetLayoutAdaptationDone(bool adaptationDone) { m_layoutAdaptationDone = adaptationDone; }
00166 bool GetLayoutAdaptationDone() const { return m_layoutAdaptationDone; }
00167
00169 static wxDialogLayoutAdapter* SetLayoutAdapter(wxDialogLayoutAdapter* adapter);
00170 static wxDialogLayoutAdapter* GetLayoutAdapter() { return sm_layoutAdapter; }
00171
00173 static bool IsLayoutAdaptationEnabled() { return sm_layoutAdaptation; }
00174 static void EnableLayoutAdaptation(bool enable) { sm_layoutAdaptation = enable; }
00175
00176 protected:
00177
00178 wxDialog* m_dialog;
00179 bool m_layoutAdaptationDone;
00180 wxArrayInt m_mainButtonIds;
00181 int m_layoutAdaptationLevel;
00182 wxDialogLayoutAdaptationMode m_layoutAdaptationMode;
00183 static wxDialogLayoutAdapter* sm_layoutAdapter;
00184 static bool sm_layoutAdaptation;
00185 };
00186
00191 class wxScrollingDialog: public wxDialog, public wxDialogHelper
00192 {
00193 DECLARE_CLASS(wxScrollingDialog)
00194 public:
00195
00196 wxScrollingDialog() { Init(); }
00197 wxScrollingDialog(wxWindow *parent,
00198 int id = wxID_ANY,
00199 const wxString& title = wxEmptyString,
00200 const wxPoint& pos = wxDefaultPosition,
00201 const wxSize& size = wxDefaultSize,
00202 long style = wxDEFAULT_DIALOG_STYLE)
00203 {
00204 Init();
00205 Create(parent, id, title, pos, size, style);
00206 }
00207 bool Create(wxWindow *parent,
00208 int id = wxID_ANY,
00209 const wxString& title = wxEmptyString,
00210 const wxPoint& pos = wxDefaultPosition,
00211 const wxSize& size = wxDefaultSize,
00212 long style = wxDEFAULT_DIALOG_STYLE);
00213
00214 void Init();
00215
00217 virtual bool Show(bool show = true);
00218
00220 virtual int ShowModal();
00221 };
00222
00227 class wxScrollingPropertySheetDialog : public wxPropertySheetDialog, public wxDialogHelper
00228 {
00229 public:
00230 wxScrollingPropertySheetDialog() : wxPropertySheetDialog() { Init(); }
00231
00232 wxScrollingPropertySheetDialog(wxWindow* parent, wxWindowID id,
00233 const wxString& title,
00234 const wxPoint& pos = wxDefaultPosition,
00235 const wxSize& sz = wxDefaultSize,
00236 long style = wxDEFAULT_DIALOG_STYLE,
00237 const wxString& name = wxDialogNameStr)
00238 {
00239 Init();
00240 Create(parent, id, title, pos, sz, style, name);
00241 }
00242
00244
00246 virtual wxWindow* GetContentWindow() const;
00247
00249
00251 virtual bool Show(bool show = true);
00252
00254 virtual int ShowModal();
00255
00256 private:
00257 void Init();
00258
00259 protected:
00260
00261 DECLARE_DYNAMIC_CLASS(wxScrollingPropertySheetDialog)
00262 };
00263
00264 #endif
00265
00266