combobox.h 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. /////////////////////////////////////////////////////////////////////////////
  2. // Name: wx/motif/combobox.h
  3. // Purpose: wxComboBox 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_COMBOBOX_H_
  11. #define _WX_COMBOBOX_H_
  12. #include "wx/choice.h"
  13. #include "wx/textentry.h"
  14. // Combobox item
  15. class WXDLLIMPEXP_CORE wxComboBox : public wxChoice,
  16. public wxTextEntry
  17. {
  18. public:
  19. wxComboBox() { m_inSetSelection = false; }
  20. virtual ~wxComboBox();
  21. inline wxComboBox(wxWindow *parent, wxWindowID id,
  22. const wxString& value = wxEmptyString,
  23. const wxPoint& pos = wxDefaultPosition,
  24. const wxSize& size = wxDefaultSize,
  25. int n = 0, const wxString choices[] = NULL,
  26. long style = 0,
  27. const wxValidator& validator = wxDefaultValidator,
  28. const wxString& name = wxComboBoxNameStr)
  29. {
  30. m_inSetSelection = false;
  31. Create(parent, id, value, pos, size, n, choices,
  32. style, validator, name);
  33. }
  34. inline wxComboBox(wxWindow *parent, wxWindowID id,
  35. const wxString& value,
  36. const wxPoint& pos,
  37. const wxSize& size,
  38. const wxArrayString& choices,
  39. long style = 0,
  40. const wxValidator& validator = wxDefaultValidator,
  41. const wxString& name = wxComboBoxNameStr)
  42. {
  43. m_inSetSelection = false;
  44. Create(parent, id, value, pos, size, choices,
  45. style, validator, name);
  46. }
  47. bool Create(wxWindow *parent, wxWindowID id,
  48. const wxString& value = wxEmptyString,
  49. const wxPoint& pos = wxDefaultPosition,
  50. const wxSize& size = wxDefaultSize,
  51. int n = 0, const wxString choices[] = NULL,
  52. long style = 0,
  53. const wxValidator& validator = wxDefaultValidator,
  54. const wxString& name = wxComboBoxNameStr);
  55. bool Create(wxWindow *parent, wxWindowID id,
  56. const wxString& value,
  57. const wxPoint& pos,
  58. const wxSize& size,
  59. const wxArrayString& choices,
  60. long style = 0,
  61. const wxValidator& validator = wxDefaultValidator,
  62. const wxString& name = wxComboBoxNameStr);
  63. // See wxComboBoxBase discussion of IsEmpty().
  64. bool IsListEmpty() const { return wxItemContainer::IsEmpty(); }
  65. bool IsTextEmpty() const { return wxTextEntry::IsEmpty(); }
  66. // resolve ambiguities among virtual functions inherited from both base
  67. // classes
  68. virtual void Clear();
  69. virtual wxString GetValue() const { return wxTextEntry::GetValue(); }
  70. virtual void SetValue(const wxString& value);
  71. virtual wxString GetStringSelection() const
  72. { return wxChoice::GetStringSelection(); }
  73. virtual void SetSelection(long from, long to)
  74. { wxTextEntry::SetSelection(from, to); }
  75. virtual void GetSelection(long *from, long *to) const
  76. { wxTextEntry::GetSelection(from, to); }
  77. // implementation of wxControlWithItems
  78. virtual int DoInsertItems(const wxArrayStringsAdapter& items,
  79. unsigned int pos,
  80. void **clientData, wxClientDataType type);
  81. virtual void DoDeleteOneItem(unsigned int n);
  82. virtual int GetSelection() const ;
  83. virtual void SetSelection(int n);
  84. virtual int FindString(const wxString& s, bool bCase = false) const;
  85. virtual wxString GetString(unsigned int n) const ;
  86. virtual void SetString(unsigned int n, const wxString& s);
  87. // Implementation
  88. virtual void ChangeFont(bool keepOriginalSize = true);
  89. virtual void ChangeBackgroundColour();
  90. virtual void ChangeForegroundColour();
  91. WXWidget GetTopWidget() const { return m_mainWidget; }
  92. WXWidget GetMainWidget() const { return m_mainWidget; }
  93. //Copied from wxComboBoxBase because for wxMOTIF wxComboBox does not inherit from it.
  94. virtual void Popup() { wxFAIL_MSG( wxT("Not implemented") ); }
  95. virtual void Dismiss() { wxFAIL_MSG( wxT("Not implemented") ); }
  96. protected:
  97. virtual wxSize DoGetBestSize() const;
  98. virtual void DoSetSize(int x, int y,
  99. int width, int height,
  100. int sizeFlags = wxSIZE_AUTO);
  101. // implement wxTextEntry pure virtual methods
  102. virtual wxWindow *GetEditableWindow() { return this; }
  103. virtual WXWidget GetTextWidget() const;
  104. private:
  105. // only implemented for native combo box
  106. void AdjustDropDownListSize();
  107. // implementation detail, should really be private
  108. public:
  109. bool m_inSetSelection;
  110. DECLARE_DYNAMIC_CLASS(wxComboBox)
  111. };
  112. #endif // _WX_COMBOBOX_H_