notebook.h 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  1. ///////////////////////////////////////////////////////////////////////////////
  2. // Name: wx/notebook.h
  3. // Purpose: wxNotebook interface
  4. // Author: Vadim Zeitlin
  5. // Modified by:
  6. // Created: 01.02.01
  7. // Copyright: (c) 1996-2000 Vadim Zeitlin
  8. // Licence: wxWindows licence
  9. ///////////////////////////////////////////////////////////////////////////////
  10. #ifndef _WX_NOTEBOOK_H_BASE_
  11. #define _WX_NOTEBOOK_H_BASE_
  12. // ----------------------------------------------------------------------------
  13. // headers
  14. // ----------------------------------------------------------------------------
  15. #include "wx/defs.h"
  16. #if wxUSE_NOTEBOOK
  17. #include "wx/bookctrl.h"
  18. // ----------------------------------------------------------------------------
  19. // constants
  20. // ----------------------------------------------------------------------------
  21. // wxNotebook hit results, use wxBK_HITTEST so other book controls can share them
  22. // if wxUSE_NOTEBOOK is disabled
  23. enum
  24. {
  25. wxNB_HITTEST_NOWHERE = wxBK_HITTEST_NOWHERE,
  26. wxNB_HITTEST_ONICON = wxBK_HITTEST_ONICON,
  27. wxNB_HITTEST_ONLABEL = wxBK_HITTEST_ONLABEL,
  28. wxNB_HITTEST_ONITEM = wxBK_HITTEST_ONITEM,
  29. wxNB_HITTEST_ONPAGE = wxBK_HITTEST_ONPAGE
  30. };
  31. // wxNotebook flags
  32. // use common book wxBK_* flags for describing alignment
  33. #define wxNB_DEFAULT wxBK_DEFAULT
  34. #define wxNB_TOP wxBK_TOP
  35. #define wxNB_BOTTOM wxBK_BOTTOM
  36. #define wxNB_LEFT wxBK_LEFT
  37. #define wxNB_RIGHT wxBK_RIGHT
  38. #define wxNB_FIXEDWIDTH 0x0100
  39. #define wxNB_MULTILINE 0x0200
  40. #define wxNB_NOPAGETHEME 0x0400
  41. #define wxNB_FLAT 0x0800
  42. typedef wxWindow wxNotebookPage; // so far, any window can be a page
  43. extern WXDLLIMPEXP_DATA_CORE(const char) wxNotebookNameStr[];
  44. #if wxUSE_EXTENDED_RTTI
  45. // ----------------------------------------------------------------------------
  46. // XTI accessor
  47. // ----------------------------------------------------------------------------
  48. class WXDLLEXPORT wxNotebookPageInfo : public wxObject
  49. {
  50. public:
  51. wxNotebookPageInfo() { m_page = NULL; m_imageId = -1; m_selected = false; }
  52. virtual ~wxNotebookPageInfo() { }
  53. bool Create(wxNotebookPage *page,
  54. const wxString& text,
  55. bool selected,
  56. int imageId)
  57. {
  58. m_page = page;
  59. m_text = text;
  60. m_selected = selected;
  61. m_imageId = imageId;
  62. return true;
  63. }
  64. wxNotebookPage* GetPage() const { return m_page; }
  65. wxString GetText() const { return m_text; }
  66. bool GetSelected() const { return m_selected; }
  67. int GetImageId() const { return m_imageId; }
  68. private:
  69. wxNotebookPage *m_page;
  70. wxString m_text;
  71. bool m_selected;
  72. int m_imageId;
  73. DECLARE_DYNAMIC_CLASS(wxNotebookPageInfo)
  74. };
  75. WX_DECLARE_EXPORTED_LIST(wxNotebookPageInfo, wxNotebookPageInfoList );
  76. #endif
  77. // ----------------------------------------------------------------------------
  78. // wxNotebookBase: define wxNotebook interface
  79. // ----------------------------------------------------------------------------
  80. class WXDLLIMPEXP_CORE wxNotebookBase : public wxBookCtrlBase
  81. {
  82. public:
  83. // ctors
  84. // -----
  85. wxNotebookBase() { }
  86. // wxNotebook-specific additions to wxBookCtrlBase interface
  87. // ---------------------------------------------------------
  88. // get the number of rows for a control with wxNB_MULTILINE style (not all
  89. // versions support it - they will always return 1 then)
  90. virtual int GetRowCount() const { return 1; }
  91. // set the padding between tabs (in pixels)
  92. virtual void SetPadding(const wxSize& padding) = 0;
  93. // set the size of the tabs for wxNB_FIXEDWIDTH controls
  94. virtual void SetTabSize(const wxSize& sz) = 0;
  95. // implement some base class functions
  96. virtual wxSize CalcSizeFromPage(const wxSize& sizePage) const;
  97. // On platforms that support it, get the theme page background colour, else invalid colour
  98. virtual wxColour GetThemeBackgroundColour() const { return wxNullColour; }
  99. // send wxEVT_NOTEBOOK_PAGE_CHANGING/ED events
  100. // returns false if the change to nPage is vetoed by the program
  101. bool SendPageChangingEvent(int nPage);
  102. // sends the event about page change from old to new (or GetSelection() if
  103. // new is wxNOT_FOUND)
  104. void SendPageChangedEvent(int nPageOld, int nPageNew = wxNOT_FOUND);
  105. // wxBookCtrlBase overrides this method to return false but we do need
  106. // focus because we have tabs
  107. virtual bool AcceptsFocus() const { return wxControl::AcceptsFocus(); }
  108. #if wxUSE_EXTENDED_RTTI
  109. // XTI accessors
  110. virtual void AddPageInfo( wxNotebookPageInfo* info );
  111. virtual const wxNotebookPageInfoList& GetPageInfos() const;
  112. #endif
  113. protected:
  114. #if wxUSE_EXTENDED_RTTI
  115. wxNotebookPageInfoList m_pageInfos;
  116. #endif
  117. wxDECLARE_NO_COPY_CLASS(wxNotebookBase);
  118. };
  119. // ----------------------------------------------------------------------------
  120. // notebook event class and related stuff
  121. // ----------------------------------------------------------------------------
  122. // wxNotebookEvent is obsolete and defined for compatibility only (notice that
  123. // we use #define and not typedef to also keep compatibility with the existing
  124. // code which forward declares it)
  125. #define wxNotebookEvent wxBookCtrlEvent
  126. typedef wxBookCtrlEventFunction wxNotebookEventFunction;
  127. #define wxNotebookEventHandler(func) wxBookCtrlEventHandler(func)
  128. wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_NOTEBOOK_PAGE_CHANGED, wxBookCtrlEvent );
  129. wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_NOTEBOOK_PAGE_CHANGING, wxBookCtrlEvent );
  130. #define EVT_NOTEBOOK_PAGE_CHANGED(winid, fn) \
  131. wx__DECLARE_EVT1(wxEVT_NOTEBOOK_PAGE_CHANGED, winid, wxBookCtrlEventHandler(fn))
  132. #define EVT_NOTEBOOK_PAGE_CHANGING(winid, fn) \
  133. wx__DECLARE_EVT1(wxEVT_NOTEBOOK_PAGE_CHANGING, winid, wxBookCtrlEventHandler(fn))
  134. // ----------------------------------------------------------------------------
  135. // wxNotebook class itself
  136. // ----------------------------------------------------------------------------
  137. #if defined(__WXUNIVERSAL__)
  138. #include "wx/univ/notebook.h"
  139. #elif defined(__WXMSW__)
  140. #include "wx/msw/notebook.h"
  141. #elif defined(__WXMOTIF__)
  142. #include "wx/generic/notebook.h"
  143. #elif defined(__WXGTK20__)
  144. #include "wx/gtk/notebook.h"
  145. #elif defined(__WXGTK__)
  146. #include "wx/gtk1/notebook.h"
  147. #elif defined(__WXMAC__)
  148. #include "wx/osx/notebook.h"
  149. #elif defined(__WXCOCOA__)
  150. #include "wx/cocoa/notebook.h"
  151. #elif defined(__WXPM__)
  152. #include "wx/os2/notebook.h"
  153. #endif
  154. // old wxEVT_COMMAND_* constants
  155. #define wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED wxEVT_NOTEBOOK_PAGE_CHANGED
  156. #define wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING wxEVT_NOTEBOOK_PAGE_CHANGING
  157. #endif // wxUSE_NOTEBOOK
  158. #endif
  159. // _WX_NOTEBOOK_H_BASE_