OpenCPN Partial API docs
Loading...
Searching...
No Matches
scrollingdialog.h
1
2// Name: scrollingdialog.h
3// Purpose: wxScrollingDialog
4// Author: Julian Smart
5// Modified by:
6// Created: 2007-12-11
7// Copyright: (c) Julian Smart
8// Licence: wxWindows licence
10
11#ifndef _WX_SCROLLINGDIALOG_H_
12#define _WX_SCROLLINGDIALOG_H_
13
14#include "wx/dialog.h"
15#include "wx/propdlg.h"
16#include <vector>
17
26class wxDialogHelper;
27
28class wxDialogLayoutAdapter : public wxObject {
29 DECLARE_CLASS(wxDialogLayoutAdapter)
30public:
32
34 virtual bool CanDoLayoutAdaptation(wxDialogHelper* dialog) = 0;
35
37 virtual bool DoLayoutAdaptation(wxDialogHelper* dialog) = 0;
38};
39
47public:
49
50 // Overrides
51
53 virtual bool CanDoLayoutAdaptation(wxDialogHelper* dialog);
54
56 virtual bool DoLayoutAdaptation(wxDialogHelper* dialog);
57
58 // Implementation
59
61 virtual wxSizer* FindButtonSizer(bool stdButtonSizer, wxDialogHelper* dialog,
62 wxSizer* sizer, int& retBorder,
63 int accumlatedBorder = 0);
64
67 virtual bool IsOrdinaryButtonSizer(wxDialogHelper* dialog, wxBoxSizer* sizer);
68
70 virtual bool IsStandardButton(wxDialogHelper* dialog, wxButton* button);
71
74 virtual bool FindLooseButtons(wxDialogHelper* dialog,
75 wxStdDialogButtonSizer* buttonSizer,
76 wxSizer* sizer, int& count);
77
79 virtual void ReparentControls(wxWindow* parent, wxWindow* reparentTo,
80 wxSizer* buttonSizer = NULL);
81
85 virtual bool FitWithScrolling(wxDialog* dialog,
86 wxScrolledWindow* scrolledWindow);
87 virtual bool FitWithScrolling(wxDialog* dialog, wxWindowList& windows);
88
91 virtual int MustScroll(wxDialog* dialog, wxSize& windowSize,
92 wxSize& displaySize);
93};
94
102public:
103 wxDialogHelper(wxDialog* dialog = NULL) {
104 Init();
105 m_dialog = dialog;
106 }
107 virtual ~wxDialogHelper() {}
108
109 void Init();
110
111 void SetDialog(wxDialog* dialog) { m_dialog = dialog; }
112 wxDialog* GetDialog() const { return m_dialog; }
113
115 virtual bool DoLayoutAdaptation();
116
118 virtual bool CanDoLayoutAdaptation();
119
121 virtual wxWindow* GetContentWindow() const { return NULL; }
122
125 void AddButtonId(wxWindowID id) { m_buttonIds.Add((int)id); }
126 std::vector<int>& GetButtonIds() { return m_buttonIds; }
127
129 bool IsUserButtonId(wxWindowID id) {
130 return (m_buttonIds.Index((int)id) != wxNOT_FOUND);
131 }
132
133 // ACCESSORS
134
139 void SetLayoutAdaptationLevel(int level) { m_layoutAdaptationLevel = level; }
140
142 int GetLayoutAdaptationLevel() const { return m_layoutAdaptationLevel; }
143
145 void SetLayoutAdaptationDone(bool adaptationDone) {
146 m_layoutLayoutAdaptationDone = adaptationDone;
147 }
148 bool GetLayoutAdaptationDone() const { return m_layoutLayoutAdaptationDone; }
149
152 wxDialogLayoutAdapter* adapter);
153 static wxDialogLayoutAdapter* GetLayoutAdapter() { return sm_layoutAdapter; }
154
156 static bool GetLayoutAdaptation() { return sm_layoutAdaptation; }
157 static void SetLayoutAdaptation(bool enable) { sm_layoutAdaptation = enable; }
158
159protected:
160 wxDialog* m_dialog;
161 bool m_layoutLayoutAdaptationDone;
162 std::vector<int> m_buttonIds;
163 int m_layoutAdaptationLevel;
165 static bool sm_layoutAdaptation;
166};
167
172class wxScrollingDialog : public wxDialog, public wxDialogHelper {
173 DECLARE_CLASS(wxScrollingDialog)
174public:
175 wxScrollingDialog() { Init(); }
176 wxScrollingDialog(wxWindow* parent, int id = wxID_ANY,
177 const wxString& title = wxEmptyString,
178 const wxPoint& pos = wxDefaultPosition,
179 const wxSize& size = wxDefaultSize,
180 long style = wxDEFAULT_DIALOG_STYLE) {
181 Init();
182 Create(parent, id, title, pos, size, style);
183 }
184 bool Create(wxWindow* parent, int id = wxID_ANY,
185 const wxString& title = wxEmptyString,
186 const wxPoint& pos = wxDefaultPosition,
187 const wxSize& size = wxDefaultSize,
188 long style = wxDEFAULT_DIALOG_STYLE);
189
190 void Init();
191
193 virtual bool Show(bool show = true);
194
196 virtual int ShowModal();
197};
198
203class wxScrollingPropertySheetDialog : public wxPropertySheetDialog,
204 public wxDialogHelper {
205public:
206 wxScrollingPropertySheetDialog() : wxPropertySheetDialog() { Init(); }
207
208 wxScrollingPropertySheetDialog(wxWindow* parent, wxWindowID id,
209 const wxString& title,
210 const wxPoint& pos = wxDefaultPosition,
211 const wxSize& sz = wxDefaultSize,
212 long style = wxDEFAULT_DIALOG_STYLE,
213 const wxString& name = wxDialogNameStr) {
214 Init();
215 Create(parent, id, title, pos, sz, style, name);
216 }
217
219
221 virtual wxWindow* GetContentWindow() const;
222
224
226 virtual bool Show(bool show = true);
227
229 virtual int ShowModal();
230
231private:
232 void Init();
233
234protected:
235 DECLARE_DYNAMIC_CLASS(wxScrollingPropertySheetDialog)
236};
237
238#endif
239// _WX_SCROLLINGDIALOG_H_
int GetLayoutAdaptationLevel() const
Get level of adaptation.
virtual wxWindow * GetContentWindow() const
Returns a content window if there is one.
void AddButtonId(wxWindowID id)
Add an id to the list of custom button identifiers that should be in the button sizer.
void SetLayoutAdaptationDone(bool adaptationDone)
Returns true if the adaptation has been done.
static bool GetLayoutAdaptation()
Global switch for layout adaptation.
static wxDialogLayoutAdapter * sm_layoutAdapter
static wxDialogLayoutAdapter * SetLayoutAdapter(wxDialogLayoutAdapter *adapter)
Set layout adapter class, returning old adapter.
bool IsUserButtonId(wxWindowID id)
Is this id in the custom button id array?
virtual bool DoLayoutAdaptation()
Do the adaptation.
void SetLayoutAdaptationLevel(int level)
Level of adaptation, from none (Level 0) to full (Level 3).
virtual bool CanDoLayoutAdaptation()
Can we do the adaptation?
virtual bool DoLayoutAdaptation(wxDialogHelper *dialog)=0
Override this function to do the adaptation.
virtual bool CanDoLayoutAdaptation(wxDialogHelper *dialog)=0
Override this function to indicate that adaptation should be done.
virtual bool Show(bool show=true)
Override Show to rejig the control and sizer hierarchy if necessary.
virtual int ShowModal()
Override ShowModal to rejig the control and sizer hierarchy if necessary.
virtual bool Show(bool show=true)
Operations.
virtual int ShowModal()
Override ShowModal to rejig the control and sizer hierarchy if necessary.
virtual wxWindow * GetContentWindow() const
Returns the content window.
virtual bool FitWithScrolling(wxDialog *dialog, wxScrolledWindow *scrolledWindow)
A function to fit the dialog around its contents, and then adjust for screen size.
virtual bool IsOrdinaryButtonSizer(wxDialogHelper *dialog, wxBoxSizer *sizer)
Check if this sizer contains standard buttons, and so can be repositioned in the dialog.
virtual bool FindLooseButtons(wxDialogHelper *dialog, wxStdDialogButtonSizer *buttonSizer, wxSizer *sizer, int &count)
Find 'loose' main buttons in the existing layout and add them to the standard dialog sizer.
virtual bool DoLayoutAdaptation(wxDialogHelper *dialog)
Do layout adaptation.
virtual void ReparentControls(wxWindow *parent, wxWindow *reparentTo, wxSizer *buttonSizer=NULL)
Reparent the controls to the scrolled window, except those in buttonSizer.
virtual bool IsStandardButton(wxDialogHelper *dialog, wxButton *button)
Check if this is a standard button.
virtual bool CanDoLayoutAdaptation(wxDialogHelper *dialog)
Indicate that adaptation should be done.
virtual int MustScroll(wxDialog *dialog, wxSize &windowSize, wxSize &displaySize)
Find whether scrolling will be necessary for the dialog, returning wxVERTICAL, wxHORIZONTAL or both.
virtual wxSizer * FindButtonSizer(bool stdButtonSizer, wxDialogHelper *dialog, wxSizer *sizer, int &retBorder, int accumlatedBorder=0)
Find a standard or horizontal box sizer.