1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: wx/preferences.h
3 // Purpose: Declaration of wxPreferencesEditor class.
4 // Author: Vaclav Slavik
7 // Copyright: (c) 2013 Vaclav Slavik <vslavik@fastmail.fm>
8 // Licence: wxWindows licence
9 ///////////////////////////////////////////////////////////////////////////////
11 #ifndef _WX_PREFERENCES_H_
12 #define _WX_PREFERENCES_H_
15 #include "wx/bitmap.h"
16 #include "wx/vector.h"
18 class WXDLLIMPEXP_FWD_CORE wxWindow
;
20 class wxPreferencesEditorImpl
;
22 #if defined(__WXOSX_COCOA__)
23 // GetLargeIcon() is used
24 #define wxHAS_PREF_EDITOR_ICONS
25 // Changes should be applied immediately
26 #define wxHAS_PREF_EDITOR_APPLY_IMMEDIATELY
27 #elif defined(__WXGTK__)
28 // Changes should be applied immediately
29 #define wxHAS_PREF_EDITOR_APPLY_IMMEDIATELY
32 // ----------------------------------------------------------------------------
33 // wxPreferencesEditor: Native preferences editing
34 // ----------------------------------------------------------------------------
36 // One page of a preferences window
37 class WXDLLIMPEXP_CORE wxPreferencesPage
40 wxPreferencesPage() {}
41 virtual ~wxPreferencesPage() {}
43 // Name of the page, used e.g. for tabs
44 virtual wxString
GetName() const = 0;
46 // Return 32x32 icon used for the page. Currently only used on OS X, where
47 // implementation is required; unused on other platforms. Because of this,
48 // the method is only pure virtual on platforms that use it.
49 #ifdef wxHAS_PREF_EDITOR_ICONS
50 virtual wxBitmap
GetLargeIcon() const = 0;
52 virtual wxBitmap
GetLargeIcon() const { return wxBitmap(); }
55 // Create a window (usually a wxPanel) for this page. The caller takes
56 // ownership of the returned window.
57 virtual wxWindow
*CreateWindow(wxWindow
*parent
) = 0;
59 wxDECLARE_NO_COPY_CLASS(wxPreferencesPage
);
63 // Helper for implementing some common pages (General, Advanced)
64 class WXDLLIMPEXP_CORE wxStockPreferencesPage
: public wxPreferencesPage
73 wxStockPreferencesPage(Kind kind
) : m_kind(kind
) {}
74 Kind
GetKind() const { return m_kind
; }
76 virtual wxString
GetName() const;
77 #ifdef __WXOSX_COCOA__
78 virtual wxBitmap
GetLargeIcon() const;
86 // Notice that this class does not inherit from wxWindow.
87 class WXDLLIMPEXP_CORE wxPreferencesEditor
90 // Ctor creates an empty editor, use AddPage() to add controls to it.
91 wxPreferencesEditor();
92 ~wxPreferencesEditor();
94 // Add a new page to the editor. The editor takes ownership of the page
95 // and won't delete it until it is destroyed itself.
96 void AddPage(wxPreferencesPage
*page
);
98 // Show the preferences dialog or bring it to the top if it's already
99 // shown. Notice that this method may or may not block depending on the
100 // platform, i.e. depending on whether the dialog is modal or not.
101 void Show(wxWindow
* parent
);
103 // Hide the currently shown dialog, if any. This doesn't do anything on the
104 // platforms using modal preferences dialogs but should be called to
105 // dismiss the dialog if the object whose preferences it is editing was
109 // Whether changes to values in the pages should be applied immediately
110 // (OS X, GTK+) or only when the user clicks OK/Apply (Windows)
111 static bool ShouldApplyChangesImmediately()
113 #ifdef wxHAS_PREF_EDITOR_APPLY_IMMEDIATELY
121 wxPreferencesEditorImpl
* m_impl
;
123 wxDECLARE_NO_COPY_CLASS(wxPreferencesEditor
);
126 #endif // _WX_PREFERENCES_H_