00001
00002
00003
00004
00005
00007
00008
00009
00010
00011
00012
00013
00014
00016
00017 #ifndef _WXXTRA_TREEBOOK_H_
00018 #define _WXXTRA_TREEBOOK_H_
00019
00020 #include <wx/defs.h>
00021
00022 #if wxUSE_TREEBOOK
00023 #define wxXTRA_TREEBOOK 0
00024 #else
00025 #define wxXTRA_TREEBOOK 1
00026
00027 #include <wx/bookctrl.h>
00028 #include <wx/treectrl.h>
00029
00030 #define wxBK_TOP wxBC_TOP
00031 #define wxBK_BOTTOM wxBC_BOTTOM
00032 #define wxBK_LEFT wxBC_LEFT
00033 #define wxBK_RIGHT wxBC_RIGHT
00034 #define wxBK_DEFAULT wxBC_DEFAULT
00035 #define wxBK_ALIGN_MASK (wxBK_LEFT | wxBK_RIGHT | wxBK_TOP | wxBK_BOTTOM)
00036
00037 class wxTreeCtrl;
00038 typedef wxWindow wxTreebookPage;
00039
00040 class WXDLLEXPORT wxTreeEvent;
00041
00042
00043
00044
00045
00046 class WXDLLEXPORT wxTreebook : public wxBookCtrlBase
00047 {
00048 public:
00049
00050
00051
00052
00053 wxTreebook()
00054 {
00055 Init();
00056 }
00057
00058
00059 wxTreebook(wxWindow *parent,
00060 wxWindowID id,
00061 const wxPoint& pos = wxDefaultPosition,
00062 const wxSize& size = wxDefaultSize,
00063 long style = wxBK_DEFAULT,
00064 const wxString& name = wxEmptyString)
00065 {
00066 Init();
00067
00068 (void)Create(parent, id, pos, size, style, name);
00069 }
00070
00071
00072 bool Create(wxWindow *parent,
00073 wxWindowID id,
00074 const wxPoint& pos = wxDefaultPosition,
00075 const wxSize& size = wxDefaultSize,
00076 long style = wxBK_DEFAULT,
00077 const wxString& name = wxEmptyString);
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089 virtual bool InsertPage(size_t pos,
00090 wxWindow *page,
00091 const wxString& text,
00092 bool bSelect = false,
00093 int imageId = wxNOT_FOUND);
00094
00095
00096 virtual bool InsertSubPage(size_t pos,
00097 wxWindow *page,
00098 const wxString& text,
00099 bool bSelect = false,
00100 int imageId = wxNOT_FOUND);
00101
00102
00103 virtual bool AddPage(wxWindow *page,
00104 const wxString& text,
00105 bool bSelect = false,
00106 int imageId = wxNOT_FOUND);
00107
00108
00109
00110 virtual bool AddSubPage(wxWindow *page,
00111 const wxString& text,
00112 bool bSelect = false,
00113 int imageId = wxNOT_FOUND);
00114
00115
00116
00117
00118 virtual bool DeletePage(size_t pos);
00119
00120
00121
00122
00123
00124
00125 virtual bool IsNodeExpanded(size_t pos) const;
00126
00127
00128
00129
00130 virtual bool ExpandNode(size_t pos, bool expand = true);
00131
00132
00133 bool CollapseNode(size_t pos) { return ExpandNode(pos, false); }
00134
00135
00136 int GetPageParent(size_t pos) const;
00137
00138
00139 wxTreeCtrl* GetTreeCtrl() const { return (wxTreeCtrl*)m_bookctrl; }
00140
00141
00142
00143
00144
00145 virtual int GetSelection() const;
00146 virtual bool SetPageText(size_t n, const wxString& strText);
00147 virtual wxString GetPageText(size_t n) const;
00148 virtual int GetPageImage(size_t n) const;
00149 virtual bool SetPageImage(size_t n, int imageId);
00150 virtual wxSize CalcSizeFromPage(const wxSize& sizePage) const;
00151 virtual int SetSelection(size_t n);
00152 virtual void SetImageList(wxImageList *imageList);
00153 virtual void AssignImageList(wxImageList *imageList);
00154 virtual bool DeleteAllPages();
00155
00156 protected:
00157
00158 wxTreebookPage *DoRemovePage(size_t pos);
00159
00160
00161 virtual bool AllowNullPage() const { return true; }
00162
00163
00164 void OnTreeSelectionChange(wxTreeEvent& event);
00165 void OnTreeNodeExpandedCollapsed(wxTreeEvent& event);
00166
00167
00168 wxArrayTreeItemIds m_treeIds;
00169
00170
00171 int m_selection;
00172
00173
00174
00175 int m_actualSelection;
00176
00177
00178 wxSize GetControllerSize() const;
00179 virtual void DoSize();
00180 void OnSize(wxSizeEvent& event);
00181 wxRect GetPageRect() const;
00182
00183 inline unsigned int GetInternalBorder() const
00184 {
00185 return m_internalBorder;
00186 }
00187 void SetInternalBorder(unsigned int internalBorder)
00188 {
00189 m_internalBorder = internalBorder;
00190 }
00191
00192 unsigned int m_internalBorder;
00193
00194 private:
00195
00196 void Init();
00197
00198
00199
00200
00201
00202
00203
00204 bool DoInsertPage(size_t pos,
00205 wxWindow *page,
00206 const wxString& text,
00207 bool bSelect = false,
00208 int imageId = wxNOT_FOUND);
00209 bool DoInsertSubPage(size_t pos,
00210 wxWindow *page,
00211 const wxString& text,
00212 bool bSelect = false,
00213 int imageId = wxNOT_FOUND);
00214 bool DoAddSubPage(wxWindow *page,
00215 const wxString& text,
00216 bool bSelect = false,
00217 int imageId = wxNOT_FOUND);
00218
00219
00220 int DoSetSelection(size_t pos);
00221
00222
00223
00224 wxTreebookPage *DoGetCurrentPage();
00225
00226
00227
00228 void DoUpdateSelection(bool bSelect, int page);
00229
00230
00231
00232
00233
00234
00235 wxTreeItemId DoInternalGetPage(size_t pos) const;
00236
00237
00238
00239
00240 int DoInternalFindPageById(wxTreeItemId page) const;
00241
00242
00243 void DoInternalAddPage(size_t newPos, wxWindow *page, wxTreeItemId pageId);
00244
00245
00246 void DoInternalRemovePage(size_t pos)
00247 { DoInternalRemovePageRange(pos, 0); }
00248
00249
00250
00251 void DoInternalRemovePageRange(size_t pos, size_t subCount);
00252
00253
00254
00255 size_t DoInternalGetPageCount() const { return m_treeIds.Count(); }
00256
00257
00258 DECLARE_EVENT_TABLE()
00259 DECLARE_DYNAMIC_CLASS_NO_COPY(wxTreebook)
00260
00261 wxTreeCtrl * m_bookctrl;
00262 };
00263
00264
00265
00266
00267
00268
00269 class WXDLLEXPORT wxTreebookEvent : public wxBookCtrlBaseEvent
00270 {
00271 public:
00272 wxTreebookEvent(wxEventType commandType = wxEVT_NULL, int id = 0,
00273 int nSel = wxNOT_FOUND, int nOldSel = wxNOT_FOUND)
00274 : wxBookCtrlBaseEvent(commandType, id, nSel, nOldSel)
00275 {
00276 }
00277
00278 wxTreebookEvent(const wxTreebookEvent& event)
00279 : wxBookCtrlBaseEvent(event)
00280 {
00281 }
00282
00283 virtual wxEvent *Clone() const { return new wxTreebookEvent(*this); }
00284
00285 private:
00286 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxTreebookEvent)
00287 };
00288
00289 extern WXDLLIMPEXP_CORE const wxEventType wxEVT_COMMAND_TREEBOOK_PAGE_CHANGED;
00290 extern WXDLLIMPEXP_CORE const wxEventType wxEVT_COMMAND_TREEBOOK_PAGE_CHANGING;
00291 extern WXDLLIMPEXP_CORE const wxEventType wxEVT_COMMAND_TREEBOOK_NODE_COLLAPSED;
00292 extern WXDLLIMPEXP_CORE const wxEventType wxEVT_COMMAND_TREEBOOK_NODE_EXPANDED;
00293
00294 typedef void (wxEvtHandler::*wxTreebookEventFunction)(wxTreebookEvent&);
00295
00296 #define wxTreebookEventHandler(func) \
00297 (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxTreebookEventFunction, &func)
00298
00299 #define EVT_TREEBOOK_PAGE_CHANGED(winid, fn) \
00300 wx__DECLARE_EVT1(wxEVT_COMMAND_TREEBOOK_PAGE_CHANGED, winid, wxTreebookEventHandler(fn))
00301
00302 #define EVT_TREEBOOK_PAGE_CHANGING(winid, fn) \
00303 wx__DECLARE_EVT1(wxEVT_COMMAND_TREEBOOK_PAGE_CHANGING, winid, wxTreebookEventHandler(fn))
00304
00305 #define EVT_TREEBOOK_NODE_COLLAPSED(winid, fn) \
00306 wx__DECLARE_EVT1(wxEVT_COMMAND_TREEBOOK_NODE_COLLAPSED, winid, wxTreebookEventHandler(fn))
00307
00308 #define EVT_TREEBOOK_NODE_EXPANDED(winid, fn) \
00309 wx__DECLARE_EVT1(wxEVT_COMMAND_TREEBOOK_NODE_EXPANDED, winid, wxTreebookEventHandler(fn))
00310
00311
00312 #endif // wxUSE_TREEBOOK
00313
00314 #endif // _WX_TREEBOOK_H_