combobox.h 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. /////////////////////////////////////////////////////////////////////////////
  2. // Name: wx/gtk/combobox.h
  3. // Purpose:
  4. // Author: Robert Roebling
  5. // Created: 01/02/97
  6. // Copyright: (c) 1998 Robert Roebling
  7. // Licence: wxWindows licence
  8. /////////////////////////////////////////////////////////////////////////////
  9. #ifndef _WX_GTK_COMBOBOX_H_
  10. #define _WX_GTK_COMBOBOX_H_
  11. #include "wx/choice.h"
  12. typedef struct _GtkEntry GtkEntry;
  13. //-----------------------------------------------------------------------------
  14. // wxComboBox
  15. //-----------------------------------------------------------------------------
  16. class WXDLLIMPEXP_CORE wxComboBox : public wxChoice,
  17. public wxTextEntry
  18. {
  19. public:
  20. wxComboBox()
  21. : wxChoice(), wxTextEntry()
  22. {
  23. Init();
  24. }
  25. wxComboBox(wxWindow *parent,
  26. wxWindowID id,
  27. const wxString& value = wxEmptyString,
  28. const wxPoint& pos = wxDefaultPosition,
  29. const wxSize& size = wxDefaultSize,
  30. int n = 0, const wxString choices[] = NULL,
  31. long style = 0,
  32. const wxValidator& validator = wxDefaultValidator,
  33. const wxString& name = wxComboBoxNameStr)
  34. : wxChoice(), wxTextEntry()
  35. {
  36. Init();
  37. Create(parent, id, value, pos, size, n, choices, style, validator, name);
  38. }
  39. wxComboBox(wxWindow *parent, wxWindowID id,
  40. const wxString& value,
  41. const wxPoint& pos,
  42. const wxSize& size,
  43. const wxArrayString& choices,
  44. long style = 0,
  45. const wxValidator& validator = wxDefaultValidator,
  46. const wxString& name = wxComboBoxNameStr)
  47. : wxChoice(), wxTextEntry()
  48. {
  49. Init();
  50. Create(parent, id, value, pos, size, choices, style, validator, name);
  51. }
  52. ~wxComboBox();
  53. bool Create(wxWindow *parent, wxWindowID id,
  54. const wxString& value = wxEmptyString,
  55. const wxPoint& pos = wxDefaultPosition,
  56. const wxSize& size = wxDefaultSize,
  57. int n = 0, const wxString choices[] = (const wxString *) NULL,
  58. long style = 0,
  59. const wxValidator& validator = wxDefaultValidator,
  60. const wxString& name = wxComboBoxNameStr);
  61. bool Create(wxWindow *parent, wxWindowID id,
  62. const wxString& value,
  63. const wxPoint& pos,
  64. const wxSize& size,
  65. const wxArrayString& choices,
  66. long style = 0,
  67. const wxValidator& validator = wxDefaultValidator,
  68. const wxString& name = wxComboBoxNameStr);
  69. // Set/GetSelection() from wxTextEntry and wxChoice
  70. virtual void SetSelection(int n) { wxChoice::SetSelection(n); }
  71. virtual void SetSelection(long from, long to)
  72. { wxTextEntry::SetSelection(from, to); }
  73. virtual int GetSelection() const { return wxChoice::GetSelection(); }
  74. virtual void GetSelection(long *from, long *to) const
  75. { return wxTextEntry::GetSelection(from, to); }
  76. virtual wxString GetStringSelection() const
  77. {
  78. return wxItemContainer::GetStringSelection();
  79. }
  80. virtual void SetString(unsigned int n, const wxString& string);
  81. virtual void Popup();
  82. virtual void Dismiss();
  83. virtual void Clear()
  84. {
  85. wxTextEntry::Clear();
  86. wxItemContainer::Clear();
  87. }
  88. // See wxComboBoxBase discussion of IsEmpty().
  89. bool IsListEmpty() const { return wxItemContainer::IsEmpty(); }
  90. bool IsTextEmpty() const { return wxTextEntry::IsEmpty(); }
  91. void OnChar( wxKeyEvent &event );
  92. virtual void SetValue(const wxString& value);
  93. // Standard event handling
  94. void OnCut(wxCommandEvent& event);
  95. void OnCopy(wxCommandEvent& event);
  96. void OnPaste(wxCommandEvent& event);
  97. void OnUndo(wxCommandEvent& event);
  98. void OnRedo(wxCommandEvent& event);
  99. void OnDelete(wxCommandEvent& event);
  100. void OnSelectAll(wxCommandEvent& event);
  101. void OnUpdateCut(wxUpdateUIEvent& event);
  102. void OnUpdateCopy(wxUpdateUIEvent& event);
  103. void OnUpdatePaste(wxUpdateUIEvent& event);
  104. void OnUpdateUndo(wxUpdateUIEvent& event);
  105. void OnUpdateRedo(wxUpdateUIEvent& event);
  106. void OnUpdateDelete(wxUpdateUIEvent& event);
  107. void OnUpdateSelectAll(wxUpdateUIEvent& event);
  108. virtual void GTKDisableEvents();
  109. virtual void GTKEnableEvents();
  110. GtkWidget* GetConnectWidget();
  111. static wxVisualAttributes
  112. GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
  113. protected:
  114. // From wxWindowGTK:
  115. virtual GdkWindow *GTKGetWindow(wxArrayGdkWindows& windows) const;
  116. // Widgets that use the style->base colour for the BG colour should
  117. // override this and return true.
  118. virtual bool UseGTKStyleBase() const { return true; }
  119. // Override in derived classes to create combo box widgets with
  120. // custom list stores.
  121. virtual void GTKCreateComboBoxWidget();
  122. virtual wxSize DoGetSizeFromTextSize(int xlen, int ylen = -1) const;
  123. virtual GtkEntry *GetEntry() const
  124. { return m_entry; }
  125. GtkEntry* m_entry;
  126. private:
  127. // From wxTextEntry:
  128. virtual wxWindow *GetEditableWindow() { return this; }
  129. virtual GtkEditable *GetEditable() const;
  130. virtual void EnableTextChangedEvents(bool enable);
  131. void Init();
  132. DECLARE_DYNAMIC_CLASS_NO_COPY(wxComboBox)
  133. DECLARE_EVENT_TABLE()
  134. };
  135. #endif // _WX_GTK_COMBOBOX_H_