notebook.h 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  1. /////////////////////////////////////////////////////////////////////////////
  2. // Name: wx/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
  6. // Copyright: (c) Julian Smart
  7. // Licence: wxWindows licence
  8. /////////////////////////////////////////////////////////////////////////////
  9. #ifndef _NOTEBOOK_H
  10. #define _NOTEBOOK_H
  11. #if wxUSE_NOTEBOOK
  12. // ----------------------------------------------------------------------------
  13. // headers
  14. // ----------------------------------------------------------------------------
  15. #include "wx/control.h"
  16. // ----------------------------------------------------------------------------
  17. // wxNotebook
  18. // ----------------------------------------------------------------------------
  19. class WXDLLIMPEXP_CORE wxNotebook : public wxNotebookBase
  20. {
  21. public:
  22. // ctors
  23. // -----
  24. // default for dynamic class
  25. wxNotebook();
  26. // the same arguments as for wxControl (@@@ any special styles?)
  27. wxNotebook(wxWindow *parent,
  28. wxWindowID id,
  29. const wxPoint& pos = wxDefaultPosition,
  30. const wxSize& size = wxDefaultSize,
  31. long style = 0,
  32. const wxString& name = wxNotebookNameStr);
  33. // Create() function
  34. bool Create(wxWindow *parent,
  35. wxWindowID id,
  36. const wxPoint& pos = wxDefaultPosition,
  37. const wxSize& size = wxDefaultSize,
  38. long style = 0,
  39. const wxString& name = wxNotebookNameStr);
  40. virtual ~wxNotebook();
  41. // accessors
  42. // ---------
  43. // get number of pages in the dialog
  44. virtual size_t GetPageCount() const;
  45. // set the currently selected page, return the index of the previously
  46. // selected one (or wxNOT_FOUND on error)
  47. // NB: this function will _not_ generate wxEVT_NOTEBOOK_PAGE_xxx events
  48. int SetSelection(size_t nPage);
  49. // changes selected page without sending events
  50. int ChangeSelection(size_t nPage);
  51. // set/get the title of a page
  52. bool SetPageText(size_t nPage, const wxString& strText);
  53. wxString GetPageText(size_t nPage) const;
  54. // image list stuff: each page may have an image associated with it. All
  55. // the images belong to an image list, so you have to
  56. // 1) create an image list
  57. // 2) associate it with the notebook
  58. // 3) set for each page it's image
  59. // associate image list with a control
  60. void SetImageList(wxImageList* imageList);
  61. // sets/returns item's image index in the current image list
  62. int GetPageImage(size_t nPage) const;
  63. bool SetPageImage(size_t nPage, int nImage);
  64. // currently it's always 1 because wxGTK doesn't support multi-row
  65. // tab controls
  66. int GetRowCount() const;
  67. // control the appearance of the notebook pages
  68. // set the size (the same for all pages)
  69. void SetPageSize(const wxSize& size);
  70. // set the padding between tabs (in pixels)
  71. void SetPadding(const wxSize& padding);
  72. // operations
  73. // ----------
  74. // remove all pages
  75. bool DeleteAllPages();
  76. // inserts a new page to the notebook (it will be deleted ny the notebook,
  77. // don't delete it yourself). If bSelect, this page becomes active.
  78. bool InsertPage(size_t nPage,
  79. wxNotebookPage *pPage,
  80. const wxString& strText,
  81. bool bSelect = false,
  82. int imageId = NO_IMAGE);
  83. // Windows-only at present. Also, you must use the wxNB_FIXEDWIDTH
  84. // style.
  85. void SetTabSize(const wxSize& sz);
  86. // hit test
  87. virtual int HitTest(const wxPoint& pt, long *flags = NULL) const;
  88. // calculate the size of the notebook from the size of its page
  89. virtual wxSize CalcSizeFromPage(const wxSize& sizePage) const;
  90. // callbacks
  91. // ---------
  92. void OnSize(wxSizeEvent& event);
  93. void OnNavigationKey(wxNavigationKeyEvent& event);
  94. // base class virtuals
  95. // -------------------
  96. virtual bool MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result);
  97. virtual bool MSWOnScroll(int orientation, WXWORD nSBCode,
  98. WXWORD pos, WXHWND control);
  99. #if wxUSE_CONSTRAINTS
  100. virtual void SetConstraintSizes(bool recurse = true);
  101. virtual bool DoPhase(int nPhase);
  102. #endif // wxUSE_CONSTRAINTS
  103. // Attempts to get colour for UX theme page background
  104. wxColour GetThemeBackgroundColour() const;
  105. // implementation only
  106. // -------------------
  107. #if wxUSE_UXTHEME
  108. virtual bool SetBackgroundColour(const wxColour& colour)
  109. {
  110. if ( !wxNotebookBase::SetBackgroundColour(colour) )
  111. return false;
  112. UpdateBgBrush();
  113. return true;
  114. }
  115. // draw child background
  116. virtual bool MSWPrintChild(WXHDC hDC, wxWindow *win);
  117. virtual bool MSWHasInheritableBackground() const { return true; }
  118. #endif // wxUSE_UXTHEME
  119. // translate wxWin styles to the Windows ones
  120. virtual WXDWORD MSWGetStyle(long flags, WXDWORD *exstyle = NULL) const;
  121. protected:
  122. // common part of all ctors
  123. void Init();
  124. // hides the currently shown page and shows the given one (if not -1) and
  125. // updates m_selection accordingly
  126. void UpdateSelection(int selNew);
  127. // remove one page from the notebook, without deleting
  128. virtual wxNotebookPage *DoRemovePage(size_t nPage);
  129. // get the page rectangle for the current notebook size
  130. //
  131. // returns empty rectangle if an error occurs, do test for it
  132. wxRect GetPageSize() const;
  133. // set the size of the given page to fit in the notebook
  134. void AdjustPageSize(wxNotebookPage *page);
  135. #if wxUSE_UXTHEME
  136. // return the themed brush for painting our children
  137. virtual WXHBRUSH MSWGetCustomBgBrush() { return m_hbrBackground; }
  138. // gets the bitmap of notebook background and returns a brush from it
  139. WXHBRUSH QueryBgBitmap();
  140. // creates the brush to be used for drawing the tab control background
  141. void UpdateBgBrush();
  142. // common part of QueryBgBitmap() and MSWPrintChild()
  143. //
  144. // if child == NULL, draw background for the entire notebook itself
  145. bool DoDrawBackground(WXHDC hDC, wxWindow *child = NULL);
  146. #endif // wxUSE_UXTHEME
  147. // these function are only used for reducing flicker on notebook resize and
  148. // we don't need to do this for WinCE
  149. #ifndef __WXWINCE__
  150. void OnEraseBackground(wxEraseEvent& event);
  151. void OnPaint(wxPaintEvent& event);
  152. // true if we have already subclassed our updown control
  153. bool m_hasSubclassedUpdown;
  154. // true if we already refreshed the current page after showing the window
  155. bool m_doneUpdateHack;
  156. #endif // __WXWINCE__
  157. #if wxUSE_UXTHEME
  158. // background brush used to paint the tab control
  159. WXHBRUSH m_hbrBackground;
  160. #endif // wxUSE_UXTHEME
  161. DECLARE_DYNAMIC_CLASS_NO_COPY(wxNotebook)
  162. DECLARE_EVENT_TABLE()
  163. };
  164. #endif // wxUSE_NOTEBOOK
  165. #endif // _NOTEBOOK_H