choicebk.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. ///////////////////////////////////////////////////////////////////////////////
  2. // Name: wx/choicebk.h
  3. // Purpose: wxChoicebook: wxChoice and wxNotebook combination
  4. // Author: Vadim Zeitlin
  5. // Modified by: Wlodzimierz ABX Skiba from wx/listbook.h
  6. // Created: 15.09.04
  7. // Copyright: (c) Vadim Zeitlin, Wlodzimierz Skiba
  8. // Licence: wxWindows licence
  9. ///////////////////////////////////////////////////////////////////////////////
  10. #ifndef _WX_CHOICEBOOK_H_
  11. #define _WX_CHOICEBOOK_H_
  12. #include "wx/defs.h"
  13. #if wxUSE_CHOICEBOOK
  14. #include "wx/bookctrl.h"
  15. #include "wx/choice.h"
  16. #include "wx/containr.h"
  17. class WXDLLIMPEXP_FWD_CORE wxChoice;
  18. wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_CHOICEBOOK_PAGE_CHANGED, wxBookCtrlEvent );
  19. wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_CHOICEBOOK_PAGE_CHANGING, wxBookCtrlEvent );
  20. // wxChoicebook flags
  21. #define wxCHB_DEFAULT wxBK_DEFAULT
  22. #define wxCHB_TOP wxBK_TOP
  23. #define wxCHB_BOTTOM wxBK_BOTTOM
  24. #define wxCHB_LEFT wxBK_LEFT
  25. #define wxCHB_RIGHT wxBK_RIGHT
  26. #define wxCHB_ALIGN_MASK wxBK_ALIGN_MASK
  27. // ----------------------------------------------------------------------------
  28. // wxChoicebook
  29. // ----------------------------------------------------------------------------
  30. class WXDLLIMPEXP_CORE wxChoicebook : public wxNavigationEnabled<wxBookCtrlBase>
  31. {
  32. public:
  33. wxChoicebook() { }
  34. wxChoicebook(wxWindow *parent,
  35. wxWindowID id,
  36. const wxPoint& pos = wxDefaultPosition,
  37. const wxSize& size = wxDefaultSize,
  38. long style = 0,
  39. const wxString& name = wxEmptyString)
  40. {
  41. (void)Create(parent, id, pos, size, style, name);
  42. }
  43. // quasi ctor
  44. bool Create(wxWindow *parent,
  45. wxWindowID id,
  46. const wxPoint& pos = wxDefaultPosition,
  47. const wxSize& size = wxDefaultSize,
  48. long style = 0,
  49. const wxString& name = wxEmptyString);
  50. virtual bool SetPageText(size_t n, const wxString& strText);
  51. virtual wxString GetPageText(size_t n) const;
  52. virtual int GetPageImage(size_t n) const;
  53. virtual bool SetPageImage(size_t n, int imageId);
  54. virtual bool InsertPage(size_t n,
  55. wxWindow *page,
  56. const wxString& text,
  57. bool bSelect = false,
  58. int imageId = NO_IMAGE);
  59. virtual int SetSelection(size_t n)
  60. { return DoSetSelection(n, SetSelection_SendEvent); }
  61. virtual int ChangeSelection(size_t n) { return DoSetSelection(n); }
  62. virtual void SetImageList(wxImageList *imageList);
  63. virtual bool DeleteAllPages();
  64. // returns the choice control
  65. wxChoice* GetChoiceCtrl() const { return (wxChoice*)m_bookctrl; }
  66. // Override this to return true because the part of parent window
  67. // background between our controlling wxChoice and the page area should
  68. // show through.
  69. virtual bool HasTransparentBackground() { return true; }
  70. protected:
  71. virtual void DoSetWindowVariant(wxWindowVariant variant);
  72. virtual wxWindow *DoRemovePage(size_t page);
  73. void UpdateSelectedPage(size_t newsel)
  74. {
  75. m_selection = static_cast<int>(newsel);
  76. GetChoiceCtrl()->Select(m_selection);
  77. }
  78. wxBookCtrlEvent* CreatePageChangingEvent() const;
  79. void MakeChangedEvent(wxBookCtrlEvent &event);
  80. // event handlers
  81. void OnChoiceSelected(wxCommandEvent& event);
  82. private:
  83. DECLARE_EVENT_TABLE()
  84. DECLARE_DYNAMIC_CLASS_NO_COPY(wxChoicebook)
  85. };
  86. // ----------------------------------------------------------------------------
  87. // choicebook event class and related stuff
  88. // ----------------------------------------------------------------------------
  89. // wxChoicebookEvent is obsolete and defined for compatibility only
  90. #define wxChoicebookEvent wxBookCtrlEvent
  91. typedef wxBookCtrlEventFunction wxChoicebookEventFunction;
  92. #define wxChoicebookEventHandler(func) wxBookCtrlEventHandler(func)
  93. #define EVT_CHOICEBOOK_PAGE_CHANGED(winid, fn) \
  94. wx__DECLARE_EVT1(wxEVT_CHOICEBOOK_PAGE_CHANGED, winid, wxBookCtrlEventHandler(fn))
  95. #define EVT_CHOICEBOOK_PAGE_CHANGING(winid, fn) \
  96. wx__DECLARE_EVT1(wxEVT_CHOICEBOOK_PAGE_CHANGING, winid, wxBookCtrlEventHandler(fn))
  97. // old wxEVT_COMMAND_* constants
  98. #define wxEVT_COMMAND_CHOICEBOOK_PAGE_CHANGED wxEVT_CHOICEBOOK_PAGE_CHANGED
  99. #define wxEVT_COMMAND_CHOICEBOOK_PAGE_CHANGING wxEVT_CHOICEBOOK_PAGE_CHANGING
  100. #endif // wxUSE_CHOICEBOOK
  101. #endif // _WX_CHOICEBOOK_H_