notebook.h 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  1. /////////////////////////////////////////////////////////////////////////////
  2. // Name: notebook.h
  3. // Purpose: interface of wxNotebook
  4. // Author: wxWidgets team
  5. // Licence: wxWindows licence
  6. /////////////////////////////////////////////////////////////////////////////
  7. enum
  8. {
  9. wxNB_HITTEST_NOWHERE = wxBK_HITTEST_NOWHERE,
  10. wxNB_HITTEST_ONICON = wxBK_HITTEST_ONICON,
  11. wxNB_HITTEST_ONLABEL = wxBK_HITTEST_ONLABEL,
  12. wxNB_HITTEST_ONITEM = wxBK_HITTEST_ONITEM,
  13. wxNB_HITTEST_ONPAGE = wxBK_HITTEST_ONPAGE
  14. };
  15. #define wxNB_DEFAULT wxBK_DEFAULT
  16. #define wxNB_TOP wxBK_TOP
  17. #define wxNB_BOTTOM wxBK_BOTTOM
  18. #define wxNB_LEFT wxBK_LEFT
  19. #define wxNB_RIGHT wxBK_RIGHT
  20. #define wxNB_FIXEDWIDTH 0x0100
  21. #define wxNB_MULTILINE 0x0200
  22. #define wxNB_NOPAGETHEME 0x0400
  23. #define wxNB_FLAT 0x0800
  24. wxEventType wxEVT_NOTEBOOK_PAGE_CHANGED;
  25. wxEventType wxEVT_NOTEBOOK_PAGE_CHANGING;
  26. /**
  27. @class wxNotebook
  28. This class represents a notebook control, which manages multiple windows with
  29. associated tabs.
  30. To use the class, create a wxNotebook object and call wxNotebook::AddPage
  31. or wxNotebook::InsertPage, passing a window to be used as the page.
  32. Do not explicitly delete the window for a page that is currently managed by
  33. wxNotebook.
  34. @b wxNotebookPage is a typedef for wxWindow.
  35. @beginStyleTable
  36. @style{wxNB_TOP}
  37. Place tabs on the top side.
  38. @style{wxNB_LEFT}
  39. Place tabs on the left side.
  40. @style{wxNB_RIGHT}
  41. Place tabs on the right side.
  42. @style{wxNB_BOTTOM}
  43. Place tabs under instead of above the notebook pages.
  44. @style{wxNB_FIXEDWIDTH}
  45. (Windows only) All tabs will have same width.
  46. @style{wxNB_MULTILINE}
  47. (Windows only) There can be several rows of tabs.
  48. @style{wxNB_NOPAGETHEME}
  49. (Windows only) Display a solid colour on notebook pages, and not a
  50. gradient, which can reduce performance.
  51. @style{wxNB_FLAT}
  52. (Windows CE only) Show tabs in a flat style.
  53. @endStyleTable
  54. The styles wxNB_LEFT, RIGHT and BOTTOM are not supported under
  55. Microsoft Windows XP when using visual themes.
  56. @beginEventEmissionTable{wxBookCtrlEvent}
  57. @event{EVT_NOTEBOOK_PAGE_CHANGED(id, func)}
  58. The page selection was changed.
  59. Processes a @c wxEVT_NOTEBOOK_PAGE_CHANGED event.
  60. @event{EVT_NOTEBOOK_PAGE_CHANGING(id, func)}
  61. The page selection is about to be changed.
  62. Processes a @c wxEVT_NOTEBOOK_PAGE_CHANGING event.
  63. This event can be vetoed.
  64. @endEventTable
  65. @section notebook_bg Page backgrounds
  66. On Windows XP, the default theme paints a gradient on the notebook's pages.
  67. If you wish to suppress this theme, for aesthetic or performance reasons,
  68. there are three ways of doing it.
  69. You can use @c wxNB_NOPAGETHEME to disable themed drawing for a particular
  70. notebook, you can call wxSystemOptions::SetOption to disable it for the
  71. whole application, or you can disable it for individual pages by using
  72. SetBackgroundColour().
  73. To disable themed pages globally:
  74. @code
  75. wxSystemOptions::SetOption("msw.notebook.themed-background", 0);
  76. @endcode
  77. Set the value to 1 to enable it again.
  78. To give a single page a solid background that more or less fits in with the
  79. overall theme, use:
  80. @code
  81. wxColour col = notebook->GetThemeBackgroundColour();
  82. if (col.IsOk())
  83. {
  84. page->SetBackgroundColour(col);
  85. }
  86. @endcode
  87. On platforms other than Windows, or if the application is not using Windows
  88. themes, GetThemeBackgroundColour() will return an uninitialised colour object,
  89. and the above code will therefore work on all platforms.
  90. @library{wxcore}
  91. @category{bookctrl}
  92. @appearance{notebook}
  93. @see wxBookCtrl, wxBookCtrlEvent, wxImageList, @ref page_samples_notebook
  94. */
  95. class wxNotebook : public wxBookCtrlBase
  96. {
  97. public:
  98. /**
  99. Constructs a notebook control.
  100. */
  101. wxNotebook();
  102. /**
  103. Constructs a notebook control.
  104. Note that sometimes you can reduce flicker by passing the wxCLIP_CHILDREN
  105. window style.
  106. @param parent
  107. The parent window. Must be non-@NULL.
  108. @param id
  109. The window identifier.
  110. @param pos
  111. The window position.
  112. @param size
  113. The window size.
  114. @param style
  115. The window style. See wxNotebook.
  116. @param name
  117. The name of the control.
  118. */
  119. wxNotebook(wxWindow* parent, wxWindowID id,
  120. const wxPoint& pos = wxDefaultPosition,
  121. const wxSize& size = wxDefaultSize,
  122. long style = 0,
  123. const wxString& name = wxNotebookNameStr);
  124. /**
  125. Destroys the wxNotebook object.
  126. */
  127. virtual ~wxNotebook();
  128. /**
  129. Creates a notebook control.
  130. See wxNotebook() for a description of the parameters.
  131. */
  132. bool Create(wxWindow* parent, wxWindowID id,
  133. const wxPoint& pos = wxDefaultPosition,
  134. const wxSize& size = wxDefaultSize,
  135. long style = 0,
  136. const wxString& name = wxNotebookNameStr);
  137. /**
  138. Returns the number of rows in the notebook control.
  139. */
  140. virtual int GetRowCount() const;
  141. /**
  142. If running under Windows and themes are enabled for the application, this
  143. function returns a suitable colour for painting the background of a notebook
  144. page, and can be passed to SetBackgroundColour().
  145. Otherwise, an uninitialised colour will be returned.
  146. */
  147. virtual wxColour GetThemeBackgroundColour() const;
  148. /**
  149. An event handler function, called when the page selection is changed.
  150. @see wxBookCtrlEvent
  151. */
  152. void OnSelChange(wxBookCtrlEvent& event);
  153. /**
  154. Sets the amount of space around each page's icon and label, in pixels.
  155. @note The vertical padding cannot be changed in wxGTK.
  156. */
  157. virtual void SetPadding(const wxSize& padding);
  158. // implementations of pure virtuals
  159. virtual int GetPageImage(size_t nPage) const;
  160. virtual bool SetPageImage(size_t page, int image);
  161. virtual wxString GetPageText(size_t nPage) const;
  162. virtual bool SetPageText(size_t page, const wxString& text);
  163. virtual int GetSelection() const;
  164. virtual int SetSelection(size_t page);
  165. virtual int ChangeSelection(size_t page);
  166. virtual bool InsertPage(size_t index, wxWindow * page, const wxString & text,
  167. bool select = false, int imageId = NO_IMAGE);
  168. };