notebook.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. /////////////////////////////////////////////////////////////////////////////
  2. // Name: wx/osx/notebook.h
  3. // Purpose: MSW/GTK compatible notebook (a.k.a. property sheet)
  4. // Author: Stefan Csomor
  5. // Modified by:
  6. // Copyright: (c) Stefan Csomor
  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. // ----------------------------------------------------------------------------
  16. // types
  17. // ----------------------------------------------------------------------------
  18. // fwd declarations
  19. class WXDLLIMPEXP_FWD_CORE wxImageList;
  20. class WXDLLIMPEXP_FWD_CORE wxWindow;
  21. // ----------------------------------------------------------------------------
  22. // wxNotebook
  23. // ----------------------------------------------------------------------------
  24. class WXDLLIMPEXP_CORE wxNotebook : public wxNotebookBase
  25. {
  26. public:
  27. // ctors
  28. // -----
  29. // default for dynamic class
  30. wxNotebook() { }
  31. // the same arguments as for wxControl (@@@ any special styles?)
  32. wxNotebook(wxWindow *parent,
  33. wxWindowID id,
  34. const wxPoint& pos = wxDefaultPosition,
  35. const wxSize& size = wxDefaultSize,
  36. long style = 0,
  37. const wxString& name = wxNotebookNameStr)
  38. { Create( parent, id, pos, size, style, name ); }
  39. // Create() function
  40. bool Create(wxWindow *parent,
  41. wxWindowID id,
  42. const wxPoint& pos = wxDefaultPosition,
  43. const wxSize& size = wxDefaultSize,
  44. long style = 0,
  45. const wxString& name = wxNotebookNameStr);
  46. // dtor
  47. virtual ~wxNotebook();
  48. // accessors
  49. // ---------
  50. // set the currently selected page, return the index of the previously
  51. // selected one (or wxNOT_FOUND on error)
  52. // NB: this function will _not_ generate wxEVT_NOTEBOOK_PAGE_xxx events
  53. int SetSelection(size_t nPage) { return DoSetSelection(nPage, SetSelection_SendEvent); }
  54. // changes selected page without sending events
  55. int ChangeSelection(size_t nPage) { return DoSetSelection(nPage); }
  56. // set/get the title of a page
  57. bool SetPageText(size_t nPage, const wxString& strText);
  58. wxString GetPageText(size_t nPage) const;
  59. // sets/returns item's image index in the current image list
  60. int GetPageImage(size_t nPage) const;
  61. bool SetPageImage(size_t nPage, int nImage);
  62. // control the appearance of the notebook pages
  63. // set the size (the same for all pages)
  64. virtual void SetPageSize(const wxSize& size);
  65. // set the padding between tabs (in pixels)
  66. virtual void SetPadding(const wxSize& padding);
  67. // sets the size of the tabs (assumes all tabs are the same size)
  68. virtual void SetTabSize(const wxSize& sz);
  69. // hit test
  70. virtual int HitTest(const wxPoint& pt, long *flags = NULL) const;
  71. // calculate size for wxNotebookSizer
  72. wxSize CalcSizeFromPage(const wxSize& sizePage) const;
  73. wxRect GetPageRect() const ;
  74. // operations
  75. // ----------
  76. // remove all pages
  77. bool DeleteAllPages();
  78. // the same as AddPage(), but adds it at the specified position
  79. bool InsertPage(size_t nPage,
  80. wxNotebookPage *pPage,
  81. const wxString& strText,
  82. bool bSelect = false,
  83. int imageId = NO_IMAGE);
  84. // callbacks
  85. // ---------
  86. void OnSize(wxSizeEvent& event);
  87. void OnSelChange(wxBookCtrlEvent& event);
  88. void OnSetFocus(wxFocusEvent& event);
  89. void OnNavigationKey(wxNavigationKeyEvent& event);
  90. // implementation
  91. // --------------
  92. #if wxUSE_CONSTRAINTS
  93. virtual void SetConstraintSizes(bool recurse = true);
  94. virtual bool DoPhase(int nPhase);
  95. #endif
  96. // base class virtuals
  97. // -------------------
  98. virtual void Command(wxCommandEvent& event);
  99. // osx specific event handling common for all osx-ports
  100. virtual bool OSXHandleClicked( double timestampsec );
  101. protected:
  102. virtual wxNotebookPage *DoRemovePage(size_t page) ;
  103. // common part of all ctors
  104. void Init();
  105. // helper functions
  106. void ChangePage(int nOldSel, int nSel); // change pages
  107. void MacSetupTabs();
  108. int DoSetSelection(size_t nPage, int flags = 0);
  109. // the icon indices
  110. wxArrayInt m_images;
  111. DECLARE_DYNAMIC_CLASS(wxNotebook)
  112. DECLARE_EVENT_TABLE()
  113. };
  114. #endif // _WX_NOTEBOOK_H_