]> git.saurik.com Git - wxWidgets.git/blob - include/wx/msw/notebook.h
Fix for assert after left click on tree in generic dir dialog in native MSW build...
[wxWidgets.git] / include / wx / msw / notebook.h
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 virtual ~wxNotebook();
76
77 // accessors
78 // ---------
79 // get number of pages in the dialog
80 virtual size_t GetPageCount() const;
81
82 // set the currently selected page, return the index of the previously
83 // selected one (or -1 on error)
84 // NB: this function will _not_ generate wxEVT_NOTEBOOK_PAGE_xxx events
85 int SetSelection(size_t nPage);
86 // get the currently selected page
87 int GetSelection() const { return m_nSelection; }
88
89 // set/get the title of a page
90 bool SetPageText(size_t nPage, const wxString& strText);
91 wxString GetPageText(size_t nPage) const;
92
93 // image list stuff: each page may have an image associated with it. All
94 // the images belong to an image list, so you have to
95 // 1) create an image list
96 // 2) associate it with the notebook
97 // 3) set for each page it's image
98 // associate image list with a control
99 void SetImageList(wxImageList* imageList);
100
101 // sets/returns item's image index in the current image list
102 int GetPageImage(size_t nPage) const;
103 bool SetPageImage(size_t nPage, int nImage);
104
105 // currently it's always 1 because wxGTK doesn't support multi-row
106 // tab controls
107 int GetRowCount() const;
108
109 // control the appearance of the notebook pages
110 // set the size (the same for all pages)
111 void SetPageSize(const wxSize& size);
112 // set the padding between tabs (in pixels)
113 void SetPadding(const wxSize& padding);
114
115 // operations
116 // ----------
117 // remove all pages
118 bool DeleteAllPages();
119
120 // inserts a new page to the notebook (it will be deleted ny the notebook,
121 // don't delete it yourself). If bSelect, this page becomes active.
122 bool InsertPage(size_t nPage,
123 wxNotebookPage *pPage,
124 const wxString& strText,
125 bool bSelect = false,
126 int imageId = -1);
127
128 void AddPageInfo( wxNotebookPageInfo* info ) { AddPage( info->GetPage() , info->GetText() , info->GetSelected() , info->GetImageId() ) ; }
129 const wxNotebookPageInfoList& GetPageInfos() const ;
130
131 // Windows-only at present. Also, you must use the wxNB_FIXEDWIDTH
132 // style.
133 void SetTabSize(const wxSize& sz);
134
135 // hit test
136 virtual int HitTest(const wxPoint& pt, long *flags = NULL) const;
137
138 // calculate the size of the notebook from the size of its page
139 virtual wxSize CalcSizeFromPage(const wxSize& sizePage) const;
140
141 // callbacks
142 // ---------
143 void OnSize(wxSizeEvent& event);
144 void OnSelChange(wxNotebookEvent& event);
145 void OnNavigationKey(wxNavigationKeyEvent& event);
146
147 // base class virtuals
148 // -------------------
149
150 virtual bool MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result);
151 virtual bool MSWOnScroll(int orientation, WXWORD nSBCode,
152 WXWORD pos, WXHWND control);
153 virtual bool MSWTranslateMessage(WXMSG *wxmsg);
154
155 #if wxUSE_CONSTRAINTS
156 virtual void SetConstraintSizes(bool recurse = true);
157 virtual bool DoPhase(int nPhase);
158 #endif // wxUSE_CONSTRAINTS
159
160
161 // implementation only
162 // -------------------
163
164 #if wxUSE_UXTHEME
165 // handler for child pages erase background event
166 void DoEraseBackground(wxEraseEvent& event);
167
168 // real implementation of the above method
169 void DoEraseBackground(wxWindow *win, WXHDC hDC);
170
171 // get the brush to be used for painting the background for the controls
172 // which need it in their MSWControlColor()
173 //
174 // the brush will be adjusted for use with the given window on this DC
175 WXHBRUSH GetThemeBackgroundBrush(WXHDC hDC, wxWindow *win) const;
176 #endif // wxUSE_UXTHEME
177
178 protected:
179 // common part of all ctors
180 void Init();
181
182 // translate wxWin styles to the Windows ones
183 virtual WXDWORD MSWGetStyle(long flags, WXDWORD *exstyle = NULL) const;
184
185 // remove one page from the notebook, without deleting
186 virtual wxNotebookPage *DoRemovePage(size_t nPage);
187
188 // set the size of the given page to fit in the notebook
189 void AdjustPageSize(wxNotebookPage *page);
190
191 #if wxUSE_UXTHEME
192 // creates the brush to be used for drawing the tab control background
193 void UpdateBgBrush();
194 #endif // wxUSE_UXTHEME
195
196 // the current selection (-1 if none)
197 int m_nSelection;
198
199 wxNotebookPageInfoList m_pageInfos;
200
201 #if wxUSE_UXTHEME
202 // background brush used to paint the tab control
203 WXHBRUSH m_hbrBackground;
204 #endif // wxUSE_UXTHEME
205
206
207 DECLARE_DYNAMIC_CLASS_NO_COPY(wxNotebook)
208 DECLARE_EVENT_TABLE()
209 };
210
211 #endif // wxUSE_NOTEBOOK
212
213 #endif // _NOTEBOOK_H