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
7 // Copyright: (c) Julian Smart
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
14 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
15 #pragma interface "notebook.h"
20 // ----------------------------------------------------------------------------
22 // ----------------------------------------------------------------------------
24 #include "wx/control.h"
26 // ----------------------------------------------------------------------------
28 // ----------------------------------------------------------------------------
30 class WXDLLEXPORT wxNotebookPageInfo
: public wxObject
33 wxNotebookPageInfo() { m_page
= NULL
; m_imageId
= -1 ; m_selected
= false ; }
34 virtual ~wxNotebookPageInfo() { }
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
; }
43 wxNotebookPage
*m_page
;
48 DECLARE_DYNAMIC_CLASS(wxNotebookPageInfo
) ;
52 WX_DECLARE_LIST(wxNotebookPageInfo
, wxNotebookPageInfoList
);
53 // WX_DECLARE_EXPORTED_LIST(wxNotebookPageInfo, wxNotebookPageInfoList );
54 // WX_DECLARE_LIST_3(wxNotebookPageInfo, wxNotebookPageInfo, wxNotebookPageInfoList, wxNotebookPageInfoListNode, class WXDLLEXPORT);
56 class WXDLLEXPORT wxNotebook
: public wxNotebookBase
61 // default for dynamic class
63 // the same arguments as for wxControl (@@@ any special styles?)
64 wxNotebook(wxWindow
*parent
,
66 const wxPoint
& pos
= wxDefaultPosition
,
67 const wxSize
& size
= wxDefaultSize
,
69 const wxString
& name
= wxNOTEBOOK_NAME
);
71 bool Create(wxWindow
*parent
,
73 const wxPoint
& pos
= wxDefaultPosition
,
74 const wxSize
& size
= wxDefaultSize
,
76 const wxString
& name
= wxNOTEBOOK_NAME
);
80 // get number of pages in the dialog
81 virtual size_t GetPageCount() const;
83 // set the currently selected page, return the index of the previously
84 // selected one (or -1 on error)
85 // NB: this function will _not_ generate wxEVT_NOTEBOOK_PAGE_xxx events
86 int SetSelection(size_t nPage
);
87 // get the currently selected page
88 int GetSelection() const { return m_nSelection
; }
90 // set/get the title of a page
91 bool SetPageText(size_t nPage
, const wxString
& strText
);
92 wxString
GetPageText(size_t nPage
) const;
94 // image list stuff: each page may have an image associated with it. All
95 // the images belong to an image list, so you have to
96 // 1) create an image list
97 // 2) associate it with the notebook
98 // 3) set for each page it's image
99 // associate image list with a control
100 void SetImageList(wxImageList
* imageList
);
102 // sets/returns item's image index in the current image list
103 int GetPageImage(size_t nPage
) const;
104 bool SetPageImage(size_t nPage
, int nImage
);
106 // currently it's always 1 because wxGTK doesn't support multi-row
108 int GetRowCount() const;
110 // control the appearance of the notebook pages
111 // set the size (the same for all pages)
112 void SetPageSize(const wxSize
& size
);
113 // set the padding between tabs (in pixels)
114 void SetPadding(const wxSize
& padding
);
116 // Windows only: attempts to get colour for UX theme page background
117 wxColour
GetThemeBackgroundColour();
122 bool DeleteAllPages();
124 // inserts a new page to the notebook (it will be deleted ny the notebook,
125 // don't delete it yourself). If bSelect, this page becomes active.
126 bool InsertPage(size_t nPage
,
127 wxNotebookPage
*pPage
,
128 const wxString
& strText
,
129 bool bSelect
= FALSE
,
132 void AddPageInfo( wxNotebookPageInfo
* info
) { AddPage( info
->GetPage() , info
->GetText() , info
->GetSelected() , info
->GetImageId() ) ; }
133 const wxNotebookPageInfoList
& GetPageInfos() const ;
135 // Windows-only at present. Also, you must use the wxNB_FIXEDWIDTH
137 void SetTabSize(const wxSize
& sz
);
139 // Windows only: attempts to apply the UX theme page background to this page
140 void ApplyThemeBackground(wxWindow
* window
, const wxColour
& colour
);
143 virtual int HitTest(const wxPoint
& pt
, long *flags
= NULL
) const;
145 // calculate the size of the notebook from the size of its page
146 virtual wxSize
CalcSizeFromPage(const wxSize
& sizePage
) const;
150 void OnSize(wxSizeEvent
& event
);
151 void OnSelChange(wxNotebookEvent
& event
);
152 void OnSetFocus(wxFocusEvent
& event
);
153 void OnNavigationKey(wxNavigationKeyEvent
& event
);
155 // base class virtuals
156 // -------------------
158 virtual bool MSWOnNotify(int idCtrl
, WXLPARAM lParam
, WXLPARAM
*result
);
159 virtual bool MSWOnScroll(int orientation
, WXWORD nSBCode
,
160 WXWORD pos
, WXHWND control
);
162 #if wxUSE_CONSTRAINTS
163 virtual void SetConstraintSizes(bool recurse
= TRUE
);
164 virtual bool DoPhase(int nPhase
);
165 #endif // wxUSE_CONSTRAINTS
168 // common part of all ctors
171 // translate wxWin styles to the Windows ones
172 virtual WXDWORD
MSWGetStyle(long flags
, WXDWORD
*exstyle
= NULL
) const;
174 // remove one page from the notebook, without deleting
175 virtual wxNotebookPage
*DoRemovePage(size_t nPage
);
177 // set the size of the given page to fit in the notebook
178 void AdjustPageSize(wxNotebookPage
*page
);
181 virtual long MSWWindowProc(WXUINT nMsg
, WXWPARAM wParam
, WXLPARAM lParam
);
183 // the current selection (-1 if none)
186 wxNotebookPageInfoList m_pageInfos
;
189 DECLARE_DYNAMIC_CLASS_NO_COPY(wxNotebook
)
190 DECLARE_EVENT_TABLE()
193 #endif // wxUSE_NOTEBOOK
195 #endif // _NOTEBOOK_H