notebook.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. /////////////////////////////////////////////////////////////////////////////
  2. // Name: wx/gtk/notebook.h
  3. // Purpose: wxNotebook class
  4. // Author: Robert Roebling
  5. // Modified by:
  6. // Copyright: (c) Julian Smart and Robert Roebling
  7. // Licence: wxWindows licence
  8. /////////////////////////////////////////////////////////////////////////////
  9. #ifndef _WX_GTKNOTEBOOK_H_
  10. #define _WX_GTKNOTEBOOK_H_
  11. //-----------------------------------------------------------------------------
  12. // internal class
  13. //-----------------------------------------------------------------------------
  14. class WXDLLIMPEXP_FWD_CORE wxGtkNotebookPage;
  15. #include "wx/list.h"
  16. WX_DECLARE_LIST(wxGtkNotebookPage, wxGtkNotebookPagesList);
  17. //-----------------------------------------------------------------------------
  18. // wxNotebook
  19. //-----------------------------------------------------------------------------
  20. class WXDLLIMPEXP_CORE wxNotebook : public wxNotebookBase
  21. {
  22. public:
  23. // default for dynamic class
  24. wxNotebook();
  25. // the same arguments as for wxControl
  26. wxNotebook(wxWindow *parent,
  27. wxWindowID id,
  28. const wxPoint& pos = wxDefaultPosition,
  29. const wxSize& size = wxDefaultSize,
  30. long style = 0,
  31. const wxString& name = wxNotebookNameStr);
  32. // Create() function
  33. bool Create(wxWindow *parent,
  34. wxWindowID id,
  35. const wxPoint& pos = wxDefaultPosition,
  36. const wxSize& size = wxDefaultSize,
  37. long style = 0,
  38. const wxString& name = wxNotebookNameStr);
  39. // dtor
  40. virtual ~wxNotebook();
  41. // accessors
  42. // ---------
  43. // set the currently selected page, return the index of the previously
  44. // selected one (or wxNOT_FOUND on error)
  45. // NB: this function will _not_ generate wxEVT_NOTEBOOK_PAGE_xxx events
  46. int SetSelection(size_t nPage) { return DoSetSelection(nPage, SetSelection_SendEvent); }
  47. // get the currently selected page
  48. int GetSelection() const;
  49. // changes selected page without sending events
  50. int ChangeSelection(size_t nPage) { return DoSetSelection(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. // sets/returns item's image index in the current image list
  55. int GetPageImage(size_t nPage) const;
  56. bool SetPageImage(size_t nPage, int nImage);
  57. // control the appearance of the notebook pages
  58. // set the padding between tabs (in pixels)
  59. void SetPadding(const wxSize& padding);
  60. // sets the size of the tabs (assumes all tabs are the same size)
  61. void SetTabSize(const wxSize& sz);
  62. // geometry
  63. virtual wxSize CalcSizeFromPage(const wxSize& sizePage) const;
  64. virtual int HitTest(const wxPoint& pt, long *flags = NULL) const;
  65. // operations
  66. // ----------
  67. // remove all pages
  68. bool DeleteAllPages();
  69. // adds a new page to the notebook (it will be deleted by the notebook,
  70. // don't delete it yourself). If bSelect, this page becomes active.
  71. // the same as AddPage(), but adds it at the specified position
  72. bool InsertPage( size_t position,
  73. wxNotebookPage *win,
  74. const wxString& strText,
  75. bool bSelect = false,
  76. int imageId = NO_IMAGE );
  77. // handler for tab navigation
  78. // --------------------------
  79. void OnNavigationKey(wxNavigationKeyEvent& event);
  80. static wxVisualAttributes
  81. GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
  82. // implementation
  83. // --------------
  84. #if wxUSE_CONSTRAINTS
  85. void SetConstraintSizes(bool recurse);
  86. bool DoPhase(int phase);
  87. #endif
  88. // Called by GTK event handler when the current page is definitely changed.
  89. void GTKOnPageChanged();
  90. // helper function
  91. wxGtkNotebookPage* GetNotebookPage(int page) const;
  92. // the additional page data (the pages themselves are in m_pages array)
  93. wxGtkNotebookPagesList m_pagesData;
  94. // we need to store the old selection since there
  95. // is no other way to know about it at the time
  96. // of the change selection event
  97. int m_oldSelection;
  98. protected:
  99. // set all page's attributes
  100. virtual void DoApplyWidgetStyle(GtkRcStyle *style);
  101. virtual GdkWindow *GTKGetWindow(wxArrayGdkWindows& windows) const;
  102. // remove one page from the notebook but do not destroy it
  103. virtual wxNotebookPage *DoRemovePage(size_t nPage);
  104. int DoSetSelection(size_t nPage, int flags = 0);
  105. private:
  106. // the padding set by SetPadding()
  107. int m_padding;
  108. void Init();
  109. virtual void AddChildGTK(wxWindowGTK* child);
  110. DECLARE_DYNAMIC_CLASS(wxNotebook)
  111. DECLARE_EVENT_TABLE()
  112. };
  113. #endif // _WX_GTKNOTEBOOK_H_