combo.h 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. /////////////////////////////////////////////////////////////////////////////
  2. // Name: wx/generic/combo.h
  3. // Purpose: Generic wxComboCtrl
  4. // Author: Jaakko Salli
  5. // Modified by:
  6. // Created: Apr-30-2006
  7. // Copyright: (c) Jaakko Salli
  8. // Licence: wxWindows licence
  9. /////////////////////////////////////////////////////////////////////////////
  10. #ifndef _WX_GENERIC_COMBOCTRL_H_
  11. #define _WX_GENERIC_COMBOCTRL_H_
  12. #if wxUSE_COMBOCTRL
  13. // Only define generic if native doesn't have all the features
  14. #if !defined(wxCOMBOCONTROL_FULLY_FEATURED)
  15. // ----------------------------------------------------------------------------
  16. // Generic wxComboCtrl
  17. // ----------------------------------------------------------------------------
  18. #if defined(__WXUNIVERSAL__)
  19. // all actions of single line text controls are supported
  20. // popup/dismiss the choice window
  21. #define wxACTION_COMBOBOX_POPUP wxT("popup")
  22. #define wxACTION_COMBOBOX_DISMISS wxT("dismiss")
  23. #endif
  24. #include "wx/dcbuffer.h"
  25. extern WXDLLIMPEXP_DATA_CORE(const char) wxComboBoxNameStr[];
  26. class WXDLLIMPEXP_CORE wxGenericComboCtrl : public wxComboCtrlBase
  27. {
  28. public:
  29. // ctors and such
  30. wxGenericComboCtrl() : wxComboCtrlBase() { Init(); }
  31. wxGenericComboCtrl(wxWindow *parent,
  32. wxWindowID id = wxID_ANY,
  33. const wxString& value = wxEmptyString,
  34. const wxPoint& pos = wxDefaultPosition,
  35. const wxSize& size = wxDefaultSize,
  36. long style = 0,
  37. const wxValidator& validator = wxDefaultValidator,
  38. const wxString& name = wxComboBoxNameStr)
  39. : wxComboCtrlBase()
  40. {
  41. Init();
  42. (void)Create(parent, id, value, pos, size, style, validator, name);
  43. }
  44. bool Create(wxWindow *parent,
  45. wxWindowID id = wxID_ANY,
  46. const wxString& value = wxEmptyString,
  47. const wxPoint& pos = wxDefaultPosition,
  48. const wxSize& size = wxDefaultSize,
  49. long style = 0,
  50. const wxValidator& validator = wxDefaultValidator,
  51. const wxString& name = wxComboBoxNameStr);
  52. virtual ~wxGenericComboCtrl();
  53. void SetCustomPaintWidth( int width );
  54. virtual bool IsKeyPopupToggle(const wxKeyEvent& event) const;
  55. static int GetFeatures() { return wxComboCtrlFeatures::All; }
  56. #if defined(__WXUNIVERSAL__)
  57. // we have our own input handler and our own actions
  58. virtual bool PerformAction(const wxControlAction& action,
  59. long numArg = 0l,
  60. const wxString& strArg = wxEmptyString);
  61. #endif
  62. protected:
  63. // Dummies for platform-specific wxTextEntry implementations
  64. #if defined(__WXUNIVERSAL__)
  65. // Looks like there's nothing we need to override here
  66. #elif defined(__WXMOTIF__)
  67. virtual WXWidget GetTextWidget() const { return NULL; }
  68. #elif defined(__WXGTK__)
  69. #if defined(__WXGTK20__)
  70. virtual GtkEditable *GetEditable() const { return NULL; }
  71. virtual GtkEntry *GetEntry() const { return NULL; }
  72. #endif
  73. #elif defined(__WXMAC__)
  74. // Looks like there's nothing we need to override here
  75. #elif defined(__WXPM__)
  76. virtual WXHWND GetEditHWND() const { return NULL; }
  77. #endif
  78. // For better transparent background rendering
  79. virtual bool HasTransparentBackground()
  80. {
  81. #if wxALWAYS_NATIVE_DOUBLE_BUFFER
  82. #ifdef __WXGTK__
  83. // Sanity check for GTK+
  84. return IsDoubleBuffered();
  85. #else
  86. return true;
  87. #endif
  88. #else
  89. return false;
  90. #endif
  91. }
  92. // Mandatory virtuals
  93. virtual void OnResize();
  94. // Event handlers
  95. void OnPaintEvent( wxPaintEvent& event );
  96. void OnMouseEvent( wxMouseEvent& event );
  97. private:
  98. void Init();
  99. DECLARE_EVENT_TABLE()
  100. DECLARE_DYNAMIC_CLASS(wxGenericComboCtrl)
  101. };
  102. #ifndef _WX_COMBOCONTROL_H_
  103. // If native wxComboCtrl was not defined, then prepare a simple
  104. // front-end so that wxRTTI works as expected.
  105. class WXDLLIMPEXP_CORE wxComboCtrl : public wxGenericComboCtrl
  106. {
  107. public:
  108. wxComboCtrl() : wxGenericComboCtrl() {}
  109. wxComboCtrl(wxWindow *parent,
  110. wxWindowID id = wxID_ANY,
  111. const wxString& value = wxEmptyString,
  112. const wxPoint& pos = wxDefaultPosition,
  113. const wxSize& size = wxDefaultSize,
  114. long style = 0,
  115. const wxValidator& validator = wxDefaultValidator,
  116. const wxString& name = wxComboBoxNameStr)
  117. : wxGenericComboCtrl()
  118. {
  119. (void)Create(parent, id, value, pos, size, style, validator, name);
  120. }
  121. virtual ~wxComboCtrl() {}
  122. protected:
  123. private:
  124. DECLARE_DYNAMIC_CLASS(wxComboCtrl)
  125. };
  126. #endif // _WX_COMBOCONTROL_H_
  127. #else
  128. #define wxGenericComboCtrl wxComboCtrl
  129. #endif // !defined(wxCOMBOCONTROL_FULLY_FEATURED)
  130. #endif // wxUSE_COMBOCTRL
  131. #endif
  132. // _WX_GENERIC_COMBOCTRL_H_