radiobox.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. /////////////////////////////////////////////////////////////////////////////
  2. // Name: wx/motif/radiobox.h
  3. // Purpose: wxRadioBox class
  4. // Author: Julian Smart
  5. // Modified by:
  6. // Created: 17/09/98
  7. // Copyright: (c) Julian Smart
  8. // Licence: wxWindows licence
  9. /////////////////////////////////////////////////////////////////////////////
  10. #ifndef _WX_MOTIF_RADIOBOX_H_
  11. #define _WX_MOTIF_RADIOBOX_H_
  12. #ifndef wxWIDGET_ARRAY_DEFINED
  13. #define wxWIDGET_ARRAY_DEFINED
  14. #include "wx/dynarray.h"
  15. WX_DEFINE_ARRAY_PTR(WXWidget, wxWidgetArray);
  16. #endif // wxWIDGET_ARRAY_DEFINED
  17. #include "wx/arrstr.h"
  18. class WXDLLIMPEXP_CORE wxRadioBox : public wxControl, public wxRadioBoxBase
  19. {
  20. public:
  21. wxRadioBox() { Init(); }
  22. wxRadioBox(wxWindow *parent, wxWindowID id, const wxString& title,
  23. const wxPoint& pos = wxDefaultPosition,
  24. const wxSize& size = wxDefaultSize,
  25. int n = 0, const wxString choices[] = NULL,
  26. int majorDim = 0, long style = wxRA_SPECIFY_COLS,
  27. const wxValidator& val = wxDefaultValidator,
  28. const wxString& name = wxRadioBoxNameStr)
  29. {
  30. Init();
  31. Create(parent, id, title, pos, size, n, choices,
  32. majorDim, style, val, name);
  33. }
  34. wxRadioBox(wxWindow *parent, wxWindowID id, const wxString& title,
  35. const wxPoint& pos,
  36. const wxSize& size,
  37. const wxArrayString& choices,
  38. int majorDim = 0, long style = wxRA_SPECIFY_COLS,
  39. const wxValidator& val = wxDefaultValidator,
  40. const wxString& name = wxRadioBoxNameStr)
  41. {
  42. Init();
  43. Create(parent, id, title, pos, size, choices,
  44. majorDim, style, val, name);
  45. }
  46. virtual ~wxRadioBox();
  47. bool Create(wxWindow *parent, wxWindowID id, const wxString& title,
  48. const wxPoint& pos = wxDefaultPosition,
  49. const wxSize& size = wxDefaultSize,
  50. int n = 0, const wxString choices[] = NULL,
  51. int majorDim = 0, long style = wxRA_SPECIFY_COLS,
  52. const wxValidator& val = wxDefaultValidator,
  53. const wxString& name = wxRadioBoxNameStr);
  54. bool Create(wxWindow *parent, wxWindowID id, const wxString& title,
  55. const wxPoint& pos,
  56. const wxSize& size,
  57. const wxArrayString& choices,
  58. int majorDim = 0, long style = wxRA_SPECIFY_COLS,
  59. const wxValidator& val = wxDefaultValidator,
  60. const wxString& name = wxRadioBoxNameStr);
  61. // Enabling
  62. virtual bool Enable(bool enable = true);
  63. virtual bool Enable(unsigned int item, bool enable = true);
  64. virtual bool IsItemEnabled(unsigned int WXUNUSED(n)) const
  65. {
  66. /* TODO */
  67. return true;
  68. }
  69. // Showing
  70. virtual bool Show(bool show = true);
  71. virtual bool Show(unsigned int item, bool show = true);
  72. virtual bool IsItemShown(unsigned int WXUNUSED(n)) const
  73. {
  74. /* TODO */
  75. return true;
  76. }
  77. virtual void SetSelection(int n);
  78. int GetSelection() const;
  79. virtual void SetString(unsigned int item, const wxString& label);
  80. virtual wxString GetString(unsigned int item) const;
  81. virtual wxString GetStringSelection() const;
  82. virtual bool SetStringSelection(const wxString& s);
  83. virtual unsigned int GetCount() const { return m_noItems; } ;
  84. void Command(wxCommandEvent& event);
  85. int GetNumberOfRowsOrCols() const { return m_noRowsOrCols; }
  86. void SetNumberOfRowsOrCols(int n) { m_noRowsOrCols = n; }
  87. // Implementation
  88. virtual void ChangeFont(bool keepOriginalSize = true);
  89. virtual void ChangeBackgroundColour();
  90. virtual void ChangeForegroundColour();
  91. const wxWidgetArray& GetRadioButtons() const { return m_radioButtons; }
  92. void SetSel(int i) { m_selectedButton = i; }
  93. virtual WXWidget GetLabelWidget() const { return m_labelWidget; }
  94. protected:
  95. virtual wxBorder GetDefaultBorder() const { return wxBORDER_NONE; }
  96. virtual void DoSetSize(int x, int y,
  97. int width, int height,
  98. int sizeFlags = wxSIZE_AUTO);
  99. unsigned int m_noItems;
  100. int m_noRowsOrCols;
  101. int m_selectedButton;
  102. wxWidgetArray m_radioButtons;
  103. WXWidget m_labelWidget;
  104. wxArrayString m_radioButtonLabels;
  105. private:
  106. void Init();
  107. DECLARE_DYNAMIC_CLASS(wxRadioBox)
  108. };
  109. #endif // _WX_MOTIF_RADIOBOX_H_