collpane.h 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. /////////////////////////////////////////////////////////////////////////////
  2. // Name: collpane.h
  3. // Purpose: interface of wxCollapsiblePane
  4. // Author: wxWidgets team
  5. // Licence: wxWindows licence
  6. /////////////////////////////////////////////////////////////////////////////
  7. #define wxCP_DEFAULT_STYLE (wxTAB_TRAVERSAL | wxNO_BORDER)
  8. #define wxCP_NO_TLW_RESIZE (0x0002)
  9. /**
  10. @class wxCollapsiblePaneEvent
  11. This event class is used for the events generated by wxCollapsiblePane.
  12. @beginEventTable{wxCollapsiblePaneEvent}
  13. @event{EVT_COLLAPSIBLEPANE_CHANGED(id, func)}
  14. The user expanded or collapsed the collapsible pane.
  15. @endEventTable
  16. @library{wxcore}
  17. @category{events}
  18. @see wxCollapsiblePane
  19. */
  20. class wxCollapsiblePaneEvent : public wxCommandEvent
  21. {
  22. public:
  23. /**
  24. The constructor is not normally used by the user code.
  25. */
  26. wxCollapsiblePaneEvent(wxObject* generator, int id, bool collapsed);
  27. /**
  28. Returns @true if the pane has been collapsed.
  29. */
  30. bool GetCollapsed() const;
  31. /**
  32. Sets this as a collapsed pane event (if @a collapsed is @true) or as an
  33. expanded pane event (if @a collapsed is @false).
  34. */
  35. void SetCollapsed(bool collapsed);
  36. };
  37. wxEventType wxEVT_COLLAPSIBLEPANE_CHANGED;
  38. /**
  39. @class wxCollapsiblePane
  40. A collapsible pane is a container with an embedded button-like control
  41. which can be used by the user to collapse or expand the pane's contents.
  42. Once constructed you should use the GetPane() function to access the pane
  43. and add your controls inside it (i.e. use the returned pointer from
  44. GetPane() as parent for the controls which must go in the pane, @b not the
  45. wxCollapsiblePane itself!).
  46. Note that because of its nature of control which can dynamically (and
  47. drastically) change its size at run-time under user-input, when putting
  48. wxCollapsiblePane inside a wxSizer you should be careful to add it with a
  49. proportion value of zero; this is because otherwise all other windows with
  50. non-null proportion values will automatically resize each time the user
  51. expands or collapse the pane window usually resulting in a weird,
  52. flickering effect.
  53. Usage sample:
  54. @code
  55. wxCollapsiblePane *collpane = new wxCollapsiblePane(this, wxID_ANY, "Details:");
  56. // add the pane with a zero proportion value to the 'sz' sizer which contains it
  57. sz->Add(collpane, 0, wxGROW|wxALL, 5);
  58. // now add a test label in the collapsible pane using a sizer to layout it:
  59. wxWindow *win = collpane->GetPane();
  60. wxSizer *paneSz = new wxBoxSizer(wxVERTICAL);
  61. paneSz->Add(new wxStaticText(win, wxID_ANY, "test!"), 1, wxGROW|wxALL, 2);
  62. win->SetSizer(paneSz);
  63. paneSz->SetSizeHints(win);
  64. @endcode
  65. It is only available if @c wxUSE_COLLPANE is set to 1 (the default).
  66. @beginStyleTable
  67. @style{wxCP_DEFAULT_STYLE}
  68. The default style. It includes wxTAB_TRAVERSAL and wxBORDER_NONE.
  69. @style{wxCP_NO_TLW_RESIZE}
  70. By default wxCollapsiblePane resizes the top level window containing it
  71. when its own size changes. This allows to easily implement dialogs
  72. containing an optionally shown part, for example, and so is the default
  73. behaviour but can be inconvenient in some specific cases -- use this
  74. flag to disable this automatic parent resizing then.
  75. @endStyleTable
  76. @beginEventEmissionTable{wxCollapsiblePaneEvent,wxNavigationKeyEvent}
  77. @event{EVT_COLLAPSIBLEPANE_CHANGED(id, func)}
  78. The user expanded or collapsed the collapsible pane.
  79. @event{EVT_NAVIGATION_KEY(func)}
  80. Process a navigation key event.
  81. @endEventTable
  82. @library{wxcore}
  83. @category{ctrl}
  84. @appearance{collapsiblepane}
  85. @see wxPanel, wxCollapsiblePaneEvent
  86. */
  87. class wxCollapsiblePane : public wxControl
  88. {
  89. public:
  90. /**
  91. Default constructor.
  92. */
  93. wxCollapsiblePane();
  94. /**
  95. Initializes the object and calls Create() with all the parameters.
  96. */
  97. wxCollapsiblePane(wxWindow* parent, wxWindowID id,
  98. const wxString& label,
  99. const wxPoint& pos = wxDefaultPosition,
  100. const wxSize& size = wxDefaultSize,
  101. long style = wxCP_DEFAULT_STYLE,
  102. const wxValidator& validator = wxDefaultValidator,
  103. const wxString& name = wxCollapsiblePaneNameStr);
  104. /**
  105. @param parent
  106. Parent window, must not be non-@NULL.
  107. @param id
  108. The identifier for the control.
  109. @param label
  110. The initial label shown in the button which allows the user to
  111. expand or collapse the pane window.
  112. @param pos
  113. Initial position.
  114. @param size
  115. Initial size.
  116. @param style
  117. The window style, see wxCP_* flags.
  118. @param validator
  119. Validator which can be used for additional date checks.
  120. @param name
  121. Control name.
  122. @return @true if the control was successfully created or @false if
  123. creation failed.
  124. */
  125. bool Create(wxWindow* parent, wxWindowID id,
  126. const wxString& label,
  127. const wxPoint& pos = wxDefaultPosition,
  128. const wxSize& size = wxDefaultSize,
  129. long style = wxCP_DEFAULT_STYLE,
  130. const wxValidator& validator = wxDefaultValidator,
  131. const wxString& name = wxCollapsiblePaneNameStr);
  132. /**
  133. Collapses or expands the pane window.
  134. */
  135. virtual void Collapse(bool collapse = true);
  136. /**
  137. Same as calling Collapse(@false).
  138. */
  139. void Expand();
  140. /**
  141. Returns a pointer to the pane window. Add controls to the returned
  142. wxWindow to make them collapsible.
  143. */
  144. virtual wxWindow* GetPane() const;
  145. /**
  146. Returns @true if the pane window is currently hidden.
  147. */
  148. virtual bool IsCollapsed() const;
  149. /**
  150. Returns @true if the pane window is currently shown.
  151. */
  152. bool IsExpanded() const;
  153. };