statbox.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. /////////////////////////////////////////////////////////////////////////////
  2. // Name: statbox.h
  3. // Purpose: interface of wxStaticBox
  4. // Author: wxWidgets team
  5. // Licence: wxWindows licence
  6. /////////////////////////////////////////////////////////////////////////////
  7. /**
  8. @class wxStaticBox
  9. A static box is a rectangle drawn around other windows to denote
  10. a logical grouping of items.
  11. Note that while the previous versions required that windows appearing
  12. inside a static box be created as its siblings (i.e. use the same parent as
  13. the static box itself), since wxWidgets 2.9.1 it is also possible to create
  14. them as children of wxStaticBox itself and you are actually encouraged to
  15. do it like this if compatibility with the previous versions is not
  16. important.
  17. So the new recommended way to create static box is:
  18. @code
  19. void MyFrame::CreateControls()
  20. {
  21. wxPanel *panel = new wxPanel(this);
  22. wxStaticBox *box = new wxStaticBox(panel, wxID_ANY, "StaticBox");
  23. new wxStaticText(box, wxID_ANY "This window is a child of the staticbox");
  24. ...
  25. }
  26. @endcode
  27. While the compatible -- and now deprecated -- way is
  28. @code
  29. wxStaticBox *box = new wxStaticBox(panel, wxID_ANY, "StaticBox");
  30. new wxStaticText(panel, wxID_ANY "This window is a child of the panel");
  31. ...
  32. @endcode
  33. Also note that there is a specialized wxSizer class (wxStaticBoxSizer) which can
  34. be used as an easier way to pack items into a static box.
  35. @library{wxcore}
  36. @category{ctrl}
  37. @appearance{staticbox}
  38. @see wxStaticText, wxStaticBoxSizer
  39. */
  40. class wxStaticBox : public wxControl
  41. {
  42. public:
  43. /**
  44. Default constructor
  45. */
  46. wxStaticBox();
  47. /**
  48. Constructor, creating and showing a static box.
  49. @param parent
  50. Parent window. Must not be @NULL.
  51. @param id
  52. Window identifier. The value wxID_ANY indicates a default value.
  53. @param label
  54. Text to be displayed in the static box, the empty string for no label.
  55. @param pos
  56. Window position.
  57. If ::wxDefaultPosition is specified then a default position is chosen.
  58. @param size
  59. Checkbox size.
  60. If ::wxDefaultSize is specified then a default size is chosen.
  61. @param style
  62. Window style. See wxStaticBox.
  63. @param name
  64. Window name.
  65. @see Create()
  66. */
  67. wxStaticBox(wxWindow* parent, wxWindowID id,
  68. const wxString& label,
  69. const wxPoint& pos = wxDefaultPosition,
  70. const wxSize& size = wxDefaultSize,
  71. long style = 0,
  72. const wxString& name = wxStaticBoxNameStr);
  73. /**
  74. Destructor, destroying the group box.
  75. */
  76. virtual ~wxStaticBox();
  77. /**
  78. Creates the static box for two-step construction.
  79. See wxStaticBox() for further details.
  80. */
  81. bool Create(wxWindow* parent, wxWindowID id, const wxString& label,
  82. const wxPoint& pos = wxDefaultPosition,
  83. const wxSize& size = wxDefaultSize, long style = 0,
  84. const wxString& name = wxStaticBoxNameStr);
  85. };