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_EXPORTED_LIST(wxNotebookPageInfo
, wxNotebookPageInfoList
);
54 class WXDLLEXPORT wxNotebook
: public wxNotebookBase
59 // default for dynamic class
61 // the same arguments as for wxControl (@@@ any special styles?)
62 wxNotebook(wxWindow
*parent
,
64 const wxPoint
& pos
= wxDefaultPosition
,
65 const wxSize
& size
= wxDefaultSize
,
67 const wxString
& name
= wxNOTEBOOK_NAME
);
69 bool Create(wxWindow
*parent
,
71 const wxPoint
& pos
= wxDefaultPosition
,
72 const wxSize
& size
= wxDefaultSize
,
74 const wxString
& name
= wxNOTEBOOK_NAME
);
78 // get number of pages in the dialog
79 virtual size_t GetPageCount() const;
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
; }
88 // set/get the title of a page
89 bool SetPageText(size_t nPage
, const wxString
& strText
);
90 wxString
GetPageText(size_t nPage
) const;
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
);
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
);
104 // currently it's always 1 because wxGTK doesn't support multi-row
106 int GetRowCount() const;
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
);
114 // Windows only: attempts to get colour for UX theme page background
115 wxColour
GetThemeBackgroundColour();
120 bool DeleteAllPages();
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
,
130 void AddPageInfo( wxNotebookPageInfo
* info
) { AddPage( info
->GetPage() , info
->GetText() , info
->GetSelected() , info
->GetImageId() ) ; }
131 const wxNotebookPageInfoList
& GetPageInfos() const ;
133 // Windows-only at present. Also, you must use the wxNB_FIXEDWIDTH
135 void SetTabSize(const wxSize
& sz
);
137 // Windows only: attempts to apply the UX theme page background to this page
138 void ApplyThemeBackground(wxWindow
* window
, const wxColour
& colour
);
141 virtual int HitTest(const wxPoint
& pt
, long *flags
= NULL
) const;
143 // calculate the size of the notebook from the size of its page
144 virtual wxSize
CalcSizeFromPage(const wxSize
& sizePage
) const;
148 void OnSize(wxSizeEvent
& event
);
149 void OnSelChange(wxNotebookEvent
& event
);
150 void OnNavigationKey(wxNavigationKeyEvent
& event
);
152 // base class virtuals
153 // -------------------
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
);
160 #if wxUSE_CONSTRAINTS
161 virtual void SetConstraintSizes(bool recurse
= TRUE
);
162 virtual bool DoPhase(int nPhase
);
163 #endif // wxUSE_CONSTRAINTS
166 // common part of all ctors
169 // translate wxWin styles to the Windows ones
170 virtual WXDWORD
MSWGetStyle(long flags
, WXDWORD
*exstyle
= NULL
) const;
172 // remove one page from the notebook, without deleting
173 virtual wxNotebookPage
*DoRemovePage(size_t nPage
);
175 // set the size of the given page to fit in the notebook
176 void AdjustPageSize(wxNotebookPage
*page
);
180 virtual WXLRESULT
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