]> git.saurik.com Git - wxWidgets.git/blame - include/wx/generic/propdlg.h
prevent crash if panel/kicker is killed, bug 1872724
[wxWidgets.git] / include / wx / generic / propdlg.h
CommitLineData
3c9287bb
JS
1/////////////////////////////////////////////////////////////////////////////
2// Name: wx/generic/propdlg.h
3// Purpose: wxPropertySheetDialog
4// Author: Julian Smart
5// Modified by:
6// Created: 2005-03-12
7// RCS-ID: $Id$
8// Copyright: (c) Julian Smart
9// Licence: wxWindows licence
10/////////////////////////////////////////////////////////////////////////////
11
12#ifndef _WX_PROPDLG_H_
13#define _WX_PROPDLG_H_
14
532d575b
WS
15#include "wx/defs.h"
16
17#if wxUSE_BOOKCTRL
18
38b13085
PC
19#include "wx/dialog.h"
20
b5dbe15d 21class WXDLLIMPEXP_FWD_CORE wxBookCtrlBase;
3c9287bb
JS
22
23//-----------------------------------------------------------------------------
24// wxPropertySheetDialog
25// A platform-independent properties dialog.
26//
27// * on PocketPC, a flat-look 'property sheet' notebook will be used, with
28// no OK/Cancel/Help buttons
29// * on other platforms, a normal notebook will be used, with standard buttons
30//
31// To use this class, call Create from your derived class.
32// Then create pages and add to the book control. Finally call CreateButtons and
33// LayoutDialog.
34//
35// For example:
36//
37// MyPropertySheetDialog::Create(...)
38// {
39// wxPropertySheetDialog::Create(...);
40//
41// // Add page
42// wxPanel* panel = new wxPanel(GetBookCtrl(), ...);
43// GetBookCtrl()->AddPage(panel, wxT("General"));
44//
45// CreateButtons();
46// LayoutDialog();
47// }
48//
49// Override CreateBookCtrl and AddBookCtrl to create and add a different
50// kind of book control.
51//-----------------------------------------------------------------------------
52
3e8ec954
FM
53enum wxPropertySheetDialogFlags
54{
55 // Use the platform default
56 wxPROPSHEET_DEFAULT = 0x0001,
cc8bc5aa 57
3e8ec954
FM
58 // Use a notebook
59 wxPROPSHEET_NOTEBOOK = 0x0002,
cc8bc5aa 60
3e8ec954
FM
61 // Use a toolbook
62 wxPROPSHEET_TOOLBOOK = 0x0004,
cc8bc5aa 63
3e8ec954
FM
64 // Use a choicebook
65 wxPROPSHEET_CHOICEBOOK = 0x0008,
cc8bc5aa 66
3e8ec954
FM
67 // Use a listbook
68 wxPROPSHEET_LISTBOOK = 0x0010,
cc8bc5aa 69
3e8ec954
FM
70 // Use a wxButtonToolBar toolbook
71 wxPROPSHEET_BUTTONTOOLBOOK = 0x0020,
6334d903 72
3e8ec954
FM
73 // Use a treebook
74 wxPROPSHEET_TREEBOOK = 0x0040,
6334d903 75
3e8ec954
FM
76 // Shrink dialog to fit current page
77 wxPROPSHEET_SHRINKTOFIT = 0x0100,
78};
64d3ed17 79
c27bcbd5 80class WXDLLIMPEXP_ADV wxPropertySheetDialog : public wxDialog
3c9287bb
JS
81{
82public:
83 wxPropertySheetDialog() : wxDialog() { Init(); }
84
85 wxPropertySheetDialog(wxWindow* parent, wxWindowID id,
86 const wxString& title,
87 const wxPoint& pos = wxDefaultPosition,
88 const wxSize& sz = wxDefaultSize,
89 long style = wxDEFAULT_DIALOG_STYLE,
90 const wxString& name = wxDialogNameStr)
91 {
92 Init();
93 Create(parent, id, title, pos, sz, style, name);
94 }
95
96 bool Create(wxWindow* parent, wxWindowID id,
97 const wxString& title,
98 const wxPoint& pos = wxDefaultPosition,
99 const wxSize& sz = wxDefaultSize,
100 long style = wxDEFAULT_DIALOG_STYLE,
101 const wxString& name = wxDialogNameStr);
102
3c9287bb
JS
103//// Accessors
104
105 // Set and get the notebook
106 void SetBookCtrl(wxBookCtrlBase* book) { m_bookCtrl = book; }
107 wxBookCtrlBase* GetBookCtrl() const { return m_bookCtrl; }
108
3aa8e4ea
JS
109 // Override function in base
110 virtual wxWindow* GetContentWindow() const;
111
3c9287bb
JS
112 // Set and get the inner sizer
113 void SetInnerSize(wxSizer* sizer) { m_innerSizer = sizer; }
114 wxSizer* GetInnerSizer() const { return m_innerSizer ; }
115
cc8bc5aa
JS
116 // Set and get the book style
117 void SetSheetStyle(long sheetStyle) { m_sheetStyle = sheetStyle; }
118 long GetSheetStyle() const { return m_sheetStyle ; }
119
1a1190b2
JS
120 // Set and get the border around the whole dialog
121 void SetSheetOuterBorder(int border) { m_sheetOuterBorder = border; }
122 int GetSheetOuterBorder() const { return m_sheetOuterBorder ; }
123
124 // Set and get the border around the book control only
125 void SetSheetInnerBorder(int border) { m_sheetInnerBorder = border; }
126 int GetSheetInnerBorder() const { return m_sheetInnerBorder ; }
127
3c9287bb
JS
128/// Operations
129
130 // Creates the buttons (none on PocketPC)
131 virtual void CreateButtons(int flags = wxOK|wxCANCEL);
132
133 // Lay out the dialog, to be called after pages have been created
cc8bc5aa 134 virtual void LayoutDialog(int centreFlags = wxBOTH);
3c9287bb
JS
135
136/// Implementation
137
138 // Creates the book control. If you want to use a different kind of
139 // control, override.
140 virtual wxBookCtrlBase* CreateBookCtrl();
141
142 // Adds the book control to the inner sizer.
143 virtual void AddBookCtrl(wxSizer* sizer);
144
c9ab63f4
JS
145 // Set the focus
146 void OnActivate(wxActivateEvent& event);
147
cc8bc5aa
JS
148 // Resize dialog if necessary
149 void OnIdle(wxIdleEvent& event);
150
c9ab63f4
JS
151private:
152 void Init();
153
3c9287bb
JS
154protected:
155 wxBookCtrlBase* m_bookCtrl;
156 wxSizer* m_innerSizer; // sizer for extra space
cc8bc5aa 157 long m_sheetStyle;
1a1190b2
JS
158 int m_sheetOuterBorder;
159 int m_sheetInnerBorder;
cc8bc5aa 160 int m_selectedPage;
3c9287bb
JS
161
162 DECLARE_DYNAMIC_CLASS(wxPropertySheetDialog)
c9ab63f4 163 DECLARE_EVENT_TABLE()
3c9287bb
JS
164};
165
532d575b
WS
166#endif // wxUSE_BOOKCTRL
167
3c9287bb
JS
168#endif // _WX_PROPDLG_H_
169