1 ///////////////////////////////////////////////////////////////////////////// 2 // Name: notebook.h 3 // Purpose: wxNotebook class (a.k.a. property sheet, tabbed dialog) 4 // Author: Julian Smart 5 // Modified by: 6 // RCS-ID: $Id: notebook.h,v 1.1 2006/12/02 15:58:29 scara Exp $ 7 // Copyright: (c) Julian Smart 8 // Licence: wxWindows licence 9 ///////////////////////////////////////////////////////////////////////////// 10 11 #ifndef _WX_NOTEBOOK_H_ 12 #define _WX_NOTEBOOK_H_ 13 14 #if defined(__GNUG__) && !defined(__APPLE__) 15 #pragma interface "notebook.h" 16 #endif 17 18 // ---------------------------------------------------------------------------- 19 // headers 20 // ---------------------------------------------------------------------------- 21 #include "wx/dynarray.h" 22 #include "wx/event.h" 23 #include "wx/control.h" 24 #include "wx/generic/tabg.h" 25 26 // ---------------------------------------------------------------------------- 27 // types 28 // ---------------------------------------------------------------------------- 29 30 // fwd declarations 31 class WXDLLEXPORT wxImageList; 32 class WXDLLEXPORT wxWindow; 33 34 // Already defined in wx/notebook.h 35 #if 0 36 // array of notebook pages 37 typedef wxWindow wxNotebookPage; // so far, any window can be a page 38 WX_DEFINE_ARRAY(wxNotebookPage *, wxArrayPages); 39 #endif 40 41 // ---------------------------------------------------------------------------- 42 // wxNotebook 43 // ---------------------------------------------------------------------------- 44 45 class WXDLLEXPORT wxNotebook; 46 47 // This reuses wxTabView to draw the tabs. 48 class WXDLLEXPORT wxNotebookTabView: public wxTabView 49 { 50 DECLARE_DYNAMIC_CLASS(wxNotebookTabView) 51 public: 52 wxNotebookTabView(wxNotebook* notebook, long style = wxTAB_STYLE_DRAW_BOX | wxTAB_STYLE_COLOUR_INTERIOR); 53 ~wxNotebookTabView(void); 54 55 // Called when a tab is activated 56 virtual void OnTabActivate(int activateId, int deactivateId); 57 // Allows vetoing 58 virtual bool OnTabPreActivate(int activateId, int deactivateId); 59 60 protected: 61 wxNotebook* m_notebook; 62 }; 63 64 class wxNotebook : public wxNotebookBase 65 { 66 public: 67 // ctors 68 // ----- 69 // default for dynamic class 70 wxNotebook(); 71 // the same arguments as for wxControl (@@@ any special styles?) 72 wxNotebook(wxWindow *parent, 73 wxWindowID id, 74 const wxPoint& pos = wxDefaultPosition, 75 const wxSize& size = wxDefaultSize, 76 long style = 0, 77 const wxString& name = "notebook"); 78 // Create() function 79 bool Create(wxWindow *parent, 80 wxWindowID id, 81 const wxPoint& pos = wxDefaultPosition, 82 const wxSize& size = wxDefaultSize, 83 long style = 0, 84 const wxString& name = "notebook"); 85 // dtor 86 ~wxNotebook(); 87 88 // accessors 89 // --------- 90 // Find the position of the wxNotebookPage, -1 if not found. 91 int FindPagePosition(wxNotebookPage* page) const; 92 93 // set the currently selected page, return the index of the previously 94 // selected one (or -1 on error) 95 // NB: this function will _not_ generate wxEVT_NOTEBOOK_PAGE_xxx events 96 int SetSelection(int nPage); 97 // cycle thru the tabs 98 // void AdvanceSelection(bool bForward = TRUE); 99 // get the currently selected page GetSelection()100 int GetSelection() const { return m_nSelection; } 101 102 // set/get the title of a page 103 bool SetPageText(int nPage, const wxString& strText); 104 wxString GetPageText(int nPage) const; 105 106 // get the number of rows for a control with wxNB_MULTILINE style (not all 107 // versions support it - they will always return 1 then) 108 virtual int GetRowCount() const ; 109 110 // sets/returns item's image index in the current image list 111 int GetPageImage(int nPage) const; 112 bool SetPageImage(int nPage, int nImage); 113 114 // control the appearance of the notebook pages 115 // set the size (the same for all pages) 116 void SetPageSize(const wxSize& size); 117 // set the padding between tabs (in pixels) 118 void SetPadding(const wxSize& padding); 119 120 // Sets the size of the tabs (assumes all tabs are the same size) 121 void SetTabSize(const wxSize& sz); 122 123 // operations 124 // ---------- 125 // remove one page from the notebook, and delete the page. 126 bool DeletePage(int nPage); 127 bool DeletePage(wxNotebookPage* page); 128 // remove one page from the notebook, without deleting the page. 129 bool RemovePage(int nPage); 130 bool RemovePage(wxNotebookPage* page); 131 // remove all pages 132 bool DeleteAllPages(); 133 // the same as AddPage(), but adds it at the specified position 134 bool InsertPage(int nPage, 135 wxNotebookPage *pPage, 136 const wxString& strText, 137 bool bSelect = FALSE, 138 int imageId = -1); 139 140 // callbacks 141 // --------- 142 void OnSize(wxSizeEvent& event); 143 void OnIdle(wxIdleEvent& event); 144 void OnSelChange(wxNotebookEvent& event); 145 void OnSetFocus(wxFocusEvent& event); 146 void OnNavigationKey(wxNavigationKeyEvent& event); 147 148 // base class virtuals 149 // ------------------- 150 virtual void Command(wxCommandEvent& event); 151 virtual void SetConstraintSizes(bool recurse = TRUE); 152 virtual bool DoPhase(int nPhase); 153 154 // Implementation 155 156 // wxNotebook on Motif uses a generic wxTabView to implement itself. GetTabView()157 wxTabView *GetTabView() const { return m_tabView; } SetTabView(wxTabView * v)158 void SetTabView(wxTabView *v) { m_tabView = v; } 159 160 void OnMouseEvent(wxMouseEvent& event); 161 void OnPaint(wxPaintEvent& event); 162 163 virtual wxRect GetAvailableClientSize(); 164 165 // Implementation: calculate the layout of the view rect 166 // and resize the children if required 167 bool RefreshLayout(bool force = TRUE); 168 169 protected: 170 // common part of all ctors 171 void Init(); 172 173 // helper functions 174 void ChangePage(int nOldSel, int nSel); // change pages 175 176 #if 0 177 wxImageList *m_pImageList; // we can have an associated image list 178 wxArrayPages m_aPages; // array of pages 179 #endif 180 181 int m_nSelection; // the current selection (-1 if none) 182 183 wxTabView* m_tabView; 184 185 DECLARE_DYNAMIC_CLASS(wxNotebook) 186 DECLARE_EVENT_TABLE() 187 }; 188 189 #endif // _WX_NOTEBOOK_H_ 190