]>
Commit | Line | Data |
---|---|---|
1 | ///////////////////////////////////////////////////////////////////////////// | |
2 | // Name: msw/notebook.h | |
3 | // Purpose: MSW/GTK compatible notebook (a.k.a. property sheet) | |
4 | // Author: Robert Roebling | |
5 | // Modified by: Vadim Zeitlin for Windows version | |
6 | // RCS-ID: $Id$ | |
7 | // Copyright: (c) Julian Smart | |
8 | // Licence: wxWindows licence | |
9 | ///////////////////////////////////////////////////////////////////////////// | |
10 | ||
11 | #ifndef _NOTEBOOK_H | |
12 | #define _NOTEBOOK_H | |
13 | ||
14 | #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) | |
15 | #pragma interface "notebook.h" | |
16 | #endif | |
17 | ||
18 | #if wxUSE_NOTEBOOK | |
19 | ||
20 | // ---------------------------------------------------------------------------- | |
21 | // headers | |
22 | // ---------------------------------------------------------------------------- | |
23 | ||
24 | #include "wx/control.h" | |
25 | ||
26 | // ---------------------------------------------------------------------------- | |
27 | // wxNotebook | |
28 | // ---------------------------------------------------------------------------- | |
29 | ||
30 | class WXDLLEXPORT wxNotebookPageInfo : public wxObject | |
31 | { | |
32 | public : | |
33 | wxNotebookPageInfo() { m_page = NULL ; m_imageId = -1 ; m_selected = false ; } | |
34 | virtual ~wxNotebookPageInfo() { } | |
35 | ||
36 | void Create( wxNotebookPage *page , const wxString &text , bool selected , int imageId ) | |
37 | { m_page = page ; m_text = text ; m_selected = selected ; m_imageId = imageId ; } | |
38 | wxNotebookPage* GetPage() const { return m_page ; } | |
39 | wxString GetText() const { return m_text ; } | |
40 | bool GetSelected() const { return m_selected ; } | |
41 | int GetImageId() const { return m_imageId; } | |
42 | private : | |
43 | wxNotebookPage *m_page ; | |
44 | wxString m_text ; | |
45 | bool m_selected ; | |
46 | int m_imageId ; | |
47 | ||
48 | DECLARE_DYNAMIC_CLASS(wxNotebookPageInfo) ; | |
49 | } ; | |
50 | ||
51 | ||
52 | WX_DECLARE_EXPORTED_LIST(wxNotebookPageInfo, wxNotebookPageInfoList ); | |
53 | ||
54 | class WXDLLEXPORT wxNotebook : public wxNotebookBase | |
55 | { | |
56 | public: | |
57 | // ctors | |
58 | // ----- | |
59 | // default for dynamic class | |
60 | wxNotebook(); | |
61 | // the same arguments as for wxControl (@@@ any special styles?) | |
62 | wxNotebook(wxWindow *parent, | |
63 | wxWindowID id, | |
64 | const wxPoint& pos = wxDefaultPosition, | |
65 | const wxSize& size = wxDefaultSize, | |
66 | long style = 0, | |
67 | const wxString& name = wxNOTEBOOK_NAME); | |
68 | // Create() function | |
69 | bool Create(wxWindow *parent, | |
70 | wxWindowID id, | |
71 | const wxPoint& pos = wxDefaultPosition, | |
72 | const wxSize& size = wxDefaultSize, | |
73 | long style = 0, | |
74 | const wxString& name = wxNOTEBOOK_NAME); | |
75 | ||
76 | // accessors | |
77 | // --------- | |
78 | // get number of pages in the dialog | |
79 | virtual size_t GetPageCount() const; | |
80 | ||
81 | // set the currently selected page, return the index of the previously | |
82 | // selected one (or -1 on error) | |
83 | // NB: this function will _not_ generate wxEVT_NOTEBOOK_PAGE_xxx events | |
84 | int SetSelection(size_t nPage); | |
85 | // get the currently selected page | |
86 | int GetSelection() const { return m_nSelection; } | |
87 | ||
88 | // set/get the title of a page | |
89 | bool SetPageText(size_t nPage, const wxString& strText); | |
90 | wxString GetPageText(size_t nPage) const; | |
91 | ||
92 | // image list stuff: each page may have an image associated with it. All | |
93 | // the images belong to an image list, so you have to | |
94 | // 1) create an image list | |
95 | // 2) associate it with the notebook | |
96 | // 3) set for each page it's image | |
97 | // associate image list with a control | |
98 | void SetImageList(wxImageList* imageList); | |
99 | ||
100 | // sets/returns item's image index in the current image list | |
101 | int GetPageImage(size_t nPage) const; | |
102 | bool SetPageImage(size_t nPage, int nImage); | |
103 | ||
104 | // currently it's always 1 because wxGTK doesn't support multi-row | |
105 | // tab controls | |
106 | int GetRowCount() const; | |
107 | ||
108 | // control the appearance of the notebook pages | |
109 | // set the size (the same for all pages) | |
110 | void SetPageSize(const wxSize& size); | |
111 | // set the padding between tabs (in pixels) | |
112 | void SetPadding(const wxSize& padding); | |
113 | ||
114 | // Windows only: attempts to get colour for UX theme page background | |
115 | wxColour GetThemeBackgroundColour(); | |
116 | ||
117 | // operations | |
118 | // ---------- | |
119 | // remove all pages | |
120 | bool DeleteAllPages(); | |
121 | ||
122 | // inserts a new page to the notebook (it will be deleted ny the notebook, | |
123 | // don't delete it yourself). If bSelect, this page becomes active. | |
124 | bool InsertPage(size_t nPage, | |
125 | wxNotebookPage *pPage, | |
126 | const wxString& strText, | |
127 | bool bSelect = FALSE, | |
128 | int imageId = -1); | |
129 | ||
130 | void AddPageInfo( wxNotebookPageInfo* info ) { AddPage( info->GetPage() , info->GetText() , info->GetSelected() , info->GetImageId() ) ; } | |
131 | const wxNotebookPageInfoList& GetPageInfos() const ; | |
132 | ||
133 | // Windows-only at present. Also, you must use the wxNB_FIXEDWIDTH | |
134 | // style. | |
135 | void SetTabSize(const wxSize& sz); | |
136 | ||
137 | // Windows only: attempts to apply the UX theme page background to this page | |
138 | void ApplyThemeBackground(wxWindow* window, const wxColour& colour); | |
139 | ||
140 | // hit test | |
141 | virtual int HitTest(const wxPoint& pt, long *flags = NULL) const; | |
142 | ||
143 | // calculate the size of the notebook from the size of its page | |
144 | virtual wxSize CalcSizeFromPage(const wxSize& sizePage) const; | |
145 | ||
146 | // callbacks | |
147 | // --------- | |
148 | void OnSize(wxSizeEvent& event); | |
149 | void OnSelChange(wxNotebookEvent& event); | |
150 | void OnNavigationKey(wxNavigationKeyEvent& event); | |
151 | ||
152 | // base class virtuals | |
153 | // ------------------- | |
154 | ||
155 | virtual bool MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result); | |
156 | virtual bool MSWOnScroll(int orientation, WXWORD nSBCode, | |
157 | WXWORD pos, WXHWND control); | |
158 | virtual bool MSWTranslateMessage(WXMSG *wxmsg); | |
159 | ||
160 | #if wxUSE_CONSTRAINTS | |
161 | virtual void SetConstraintSizes(bool recurse = TRUE); | |
162 | virtual bool DoPhase(int nPhase); | |
163 | #endif // wxUSE_CONSTRAINTS | |
164 | ||
165 | protected: | |
166 | // common part of all ctors | |
167 | void Init(); | |
168 | ||
169 | // translate wxWin styles to the Windows ones | |
170 | virtual WXDWORD MSWGetStyle(long flags, WXDWORD *exstyle = NULL) const; | |
171 | ||
172 | // remove one page from the notebook, without deleting | |
173 | virtual wxNotebookPage *DoRemovePage(size_t nPage); | |
174 | ||
175 | // set the size of the given page to fit in the notebook | |
176 | void AdjustPageSize(wxNotebookPage *page); | |
177 | ||
178 | // override WndProc. | |
179 | #if wxUSE_UXTHEME | |
180 | virtual WXLRESULT MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam); | |
181 | #endif | |
182 | ||
183 | // the current selection (-1 if none) | |
184 | int m_nSelection; | |
185 | ||
186 | wxNotebookPageInfoList m_pageInfos ; | |
187 | ||
188 | ||
189 | DECLARE_DYNAMIC_CLASS_NO_COPY(wxNotebook) | |
190 | DECLARE_EVENT_TABLE() | |
191 | }; | |
192 | ||
193 | #endif // wxUSE_NOTEBOOK | |
194 | ||
195 | #endif // _NOTEBOOK_H |