panel.h 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. /////////////////////////////////////////////////////////////////////////////
  2. // Name: panel.h
  3. // Purpose: interface of wxPanel
  4. // Author: wxWidgets team
  5. // Licence: wxWindows licence
  6. /////////////////////////////////////////////////////////////////////////////
  7. /**
  8. @class wxPanel
  9. A panel is a window on which controls are placed. It is usually placed within
  10. a frame. Its main feature over its parent class wxWindow is code for handling
  11. child windows and TAB traversal. Since wxWidgets 2.9, there is support both
  12. for TAB traversal implemented by wxWidgets itself as well as native TAB
  13. traversal (such as for GTK 2.0).
  14. @note Tab traversal is implemented through an otherwise undocumented
  15. intermediate wxControlContainer class from which any class can derive
  16. in addition to the normal wxWindow base class. Please see @c wx/containr.h
  17. and @c wx/panel.h to find out how this is achieved.
  18. @note if not all characters are being intercepted by your OnKeyDown or
  19. OnChar handler, it may be because you are using the @c wxTAB_TRAVERSAL style,
  20. which grabs some keypresses for use by child controls.
  21. @remarks By default, a panel has the same colouring as a dialog.
  22. @beginEventEmissionTable{wxNavigationKeyEvent}
  23. @event{EVT_NAVIGATION_KEY(func)}
  24. Process a navigation key event.
  25. @endEventTable
  26. @library{wxcore}
  27. @category{miscwnd}
  28. @see wxDialog
  29. */
  30. class wxPanel : public wxWindow
  31. {
  32. public:
  33. /**
  34. Default constructor.
  35. */
  36. wxPanel();
  37. /**
  38. Constructor.
  39. @param parent
  40. The parent window.
  41. @param id
  42. An identifier for the panel. @c wxID_ANY is taken to mean a default.
  43. @param pos
  44. The panel position. The value ::wxDefaultPosition indicates a default position,
  45. chosen by either the windowing system or wxWidgets, depending on platform.
  46. @param size
  47. The panel size. The value ::wxDefaultSize indicates a default size, chosen by
  48. either the windowing system or wxWidgets, depending on platform.
  49. @param style
  50. The window style. See wxPanel.
  51. @param name
  52. Window name.
  53. @see Create()
  54. */
  55. wxPanel(wxWindow* parent, wxWindowID id = wxID_ANY,
  56. const wxPoint& pos = wxDefaultPosition,
  57. const wxSize& size = wxDefaultSize,
  58. long style = wxTAB_TRAVERSAL,
  59. const wxString& name = wxPanelNameStr);
  60. /**
  61. Destructor. Deletes any child windows before deleting the physical window.
  62. */
  63. virtual ~wxPanel();
  64. /**
  65. This method is overridden from wxWindow::AcceptsFocus()
  66. and returns @true only if there is no child window in the panel which
  67. can accept the focus. This is reevaluated each time a child
  68. window is added or removed from the panel.
  69. */
  70. bool AcceptsFocus() const;
  71. /**
  72. Used for two-step panel construction. See wxPanel() for details.
  73. */
  74. bool Create(wxWindow* parent, wxWindowID id = wxID_ANY,
  75. const wxPoint& pos = wxDefaultPosition,
  76. const wxSize& size = wxDefaultSize,
  77. long style = wxTAB_TRAVERSAL,
  78. const wxString& name = wxPanelNameStr);
  79. /**
  80. Sends a wxInitDialogEvent, which in turn transfers data to the dialog via
  81. validators.
  82. @see wxInitDialogEvent
  83. */
  84. virtual void InitDialog();
  85. /**
  86. See wxWindow::SetAutoLayout(): when auto layout is on, this function gets
  87. called automatically when the window is resized.
  88. */
  89. virtual bool Layout();
  90. /**
  91. The default handler for @c wxEVT_SYS_COLOUR_CHANGED.
  92. @param event
  93. The colour change event.
  94. @remarks Changes the panel's colour to conform to the current settings
  95. (Windows only). Add an event table entry for your panel
  96. class if you wish the behaviour to be different (such
  97. as keeping a user-defined background colour). If you do
  98. override this function, call wxEvent::Skip() to propagate
  99. the notification to child windows and controls.
  100. @see wxSysColourChangedEvent
  101. */
  102. void OnSysColourChanged(wxSysColourChangedEvent& event);
  103. /**
  104. Overrides wxWindow::SetFocus().
  105. This method uses the (undocumented) mix-in class wxControlContainer which manages
  106. the focus and TAB logic for controls which usually have child controls.
  107. In practice, if you call this method and the control has at least
  108. one child window, the focus will be given to the child window.
  109. @see wxFocusEvent, wxWindow::SetFocus()
  110. */
  111. virtual void SetFocus();
  112. /**
  113. In contrast to SetFocus() (see above) this will set the focus to the panel
  114. even if there are child windows in the panel. This is only rarely needed.
  115. */
  116. void SetFocusIgnoringChildren();
  117. };