notebook.h 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. /////////////////////////////////////////////////////////////////////////////
  2. // Name: wx/generic/notebook.h
  3. // Purpose: wxNotebook class (a.k.a. property sheet, tabbed dialog)
  4. // Author: Julian Smart
  5. // Modified by:
  6. // Copyright: (c) Julian Smart
  7. // Licence: wxWindows licence
  8. /////////////////////////////////////////////////////////////////////////////
  9. #ifndef _WX_NOTEBOOK_H_
  10. #define _WX_NOTEBOOK_H_
  11. // ----------------------------------------------------------------------------
  12. // headers
  13. // ----------------------------------------------------------------------------
  14. #include "wx/event.h"
  15. #include "wx/control.h"
  16. // ----------------------------------------------------------------------------
  17. // types
  18. // ----------------------------------------------------------------------------
  19. // fwd declarations
  20. class WXDLLIMPEXP_FWD_CORE wxImageList;
  21. class WXDLLIMPEXP_FWD_CORE wxWindow;
  22. class WXDLLIMPEXP_FWD_CORE wxTabView;
  23. // ----------------------------------------------------------------------------
  24. // wxNotebook
  25. // ----------------------------------------------------------------------------
  26. class WXDLLIMPEXP_CORE wxNotebook : public wxNotebookBase
  27. {
  28. public:
  29. // ctors
  30. // -----
  31. // default for dynamic class
  32. wxNotebook();
  33. // the same arguments as for wxControl (@@@ any special styles?)
  34. wxNotebook(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. // Create() function
  41. bool Create(wxWindow *parent,
  42. wxWindowID id,
  43. const wxPoint& pos = wxDefaultPosition,
  44. const wxSize& size = wxDefaultSize,
  45. long style = 0,
  46. const wxString& name = wxNotebookNameStr);
  47. // dtor
  48. virtual ~wxNotebook();
  49. // accessors
  50. // ---------
  51. // Find the position of the wxNotebookPage, wxNOT_FOUND if not found.
  52. int FindPagePosition(wxNotebookPage* page) const;
  53. // set the currently selected page, return the index of the previously
  54. // selected one (or wxNOT_FOUND on error)
  55. // NB: this function will _not_ generate wxEVT_NOTEBOOK_PAGE_xxx events
  56. int SetSelection(size_t nPage);
  57. // cycle thru the tabs
  58. // void AdvanceSelection(bool bForward = true);
  59. // changes selected page without sending events
  60. int ChangeSelection(size_t nPage);
  61. // set/get the title of a page
  62. bool SetPageText(size_t nPage, const wxString& strText);
  63. wxString GetPageText(size_t nPage) const;
  64. // get the number of rows for a control with wxNB_MULTILINE style (not all
  65. // versions support it - they will always return 1 then)
  66. virtual int GetRowCount() const ;
  67. // sets/returns item's image index in the current image list
  68. int GetPageImage(size_t nPage) const;
  69. bool SetPageImage(size_t nPage, int nImage);
  70. // control the appearance of the notebook pages
  71. // set the size (the same for all pages)
  72. void SetPageSize(const wxSize& size);
  73. // set the padding between tabs (in pixels)
  74. void SetPadding(const wxSize& padding);
  75. // Sets the size of the tabs (assumes all tabs are the same size)
  76. void SetTabSize(const wxSize& sz);
  77. // operations
  78. // ----------
  79. // remove one page from the notebook, and delete the page.
  80. bool DeletePage(size_t nPage);
  81. bool DeletePage(wxNotebookPage* page);
  82. // remove one page from the notebook, without deleting the page.
  83. bool RemovePage(size_t nPage);
  84. bool RemovePage(wxNotebookPage* page);
  85. virtual wxWindow* DoRemovePage(size_t nPage);
  86. // remove all pages
  87. bool DeleteAllPages();
  88. // the same as AddPage(), but adds it at the specified position
  89. bool InsertPage(size_t nPage,
  90. wxNotebookPage *pPage,
  91. const wxString& strText,
  92. bool bSelect = false,
  93. int imageId = NO_IMAGE);
  94. // callbacks
  95. // ---------
  96. void OnSize(wxSizeEvent& event);
  97. void OnInternalIdle();
  98. void OnSelChange(wxBookCtrlEvent& event);
  99. void OnSetFocus(wxFocusEvent& event);
  100. void OnNavigationKey(wxNavigationKeyEvent& event);
  101. // base class virtuals
  102. // -------------------
  103. virtual void Command(wxCommandEvent& event);
  104. virtual void SetConstraintSizes(bool recurse = true);
  105. virtual bool DoPhase(int nPhase);
  106. virtual wxSize CalcSizeFromPage(const wxSize& sizePage) const;
  107. // Implementation
  108. // wxNotebook on Motif uses a generic wxTabView to implement itself.
  109. wxTabView *GetTabView() const { return m_tabView; }
  110. void SetTabView(wxTabView *v) { m_tabView = v; }
  111. void OnMouseEvent(wxMouseEvent& event);
  112. void OnPaint(wxPaintEvent& event);
  113. virtual wxRect GetAvailableClientSize();
  114. // Implementation: calculate the layout of the view rect
  115. // and resize the children if required
  116. bool RefreshLayout(bool force = true);
  117. protected:
  118. // common part of all ctors
  119. void Init();
  120. // helper functions
  121. void ChangePage(int nOldSel, int nSel); // change pages
  122. wxTabView* m_tabView;
  123. DECLARE_DYNAMIC_CLASS(wxNotebook)
  124. DECLARE_EVENT_TABLE()
  125. };
  126. #endif // _WX_NOTEBOOK_H_