combo.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. /////////////////////////////////////////////////////////////////////////////
  2. // Name: wx/msw/combo.h
  3. // Purpose: wxComboCtrl class
  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_COMBOCONTROL_H_
  11. #define _WX_COMBOCONTROL_H_
  12. // NB: Definition of _WX_COMBOCONTROL_H_ is used in wx/generic/combo.h to
  13. // determine whether there is native wxComboCtrl, so make sure you
  14. // use it in all native wxComboCtrls.
  15. #if wxUSE_COMBOCTRL
  16. #if !defined(__WXWINCE__) && wxUSE_TIMER
  17. #include "wx/timer.h"
  18. #define wxUSE_COMBOCTRL_POPUP_ANIMATION 1
  19. #else
  20. #define wxUSE_COMBOCTRL_POPUP_ANIMATION 0
  21. #endif
  22. // ----------------------------------------------------------------------------
  23. // Native wxComboCtrl
  24. // ----------------------------------------------------------------------------
  25. // Define this only if native implementation includes all features
  26. #define wxCOMBOCONTROL_FULLY_FEATURED
  27. extern WXDLLIMPEXP_DATA_CORE(const char) wxComboBoxNameStr[];
  28. class WXDLLIMPEXP_CORE wxComboCtrl : public wxComboCtrlBase
  29. {
  30. public:
  31. // ctors and such
  32. wxComboCtrl() : wxComboCtrlBase() { Init(); }
  33. wxComboCtrl(wxWindow *parent,
  34. wxWindowID id = wxID_ANY,
  35. const wxString& value = wxEmptyString,
  36. const wxPoint& pos = wxDefaultPosition,
  37. const wxSize& size = wxDefaultSize,
  38. long style = 0,
  39. const wxValidator& validator = wxDefaultValidator,
  40. const wxString& name = wxComboBoxNameStr)
  41. : wxComboCtrlBase()
  42. {
  43. Init();
  44. (void)Create(parent, id, value, pos, size, style, validator, name);
  45. }
  46. bool Create(wxWindow *parent,
  47. wxWindowID id = wxID_ANY,
  48. const wxString& value = wxEmptyString,
  49. const wxPoint& pos = wxDefaultPosition,
  50. const wxSize& size = wxDefaultSize,
  51. long style = 0,
  52. const wxValidator& validator = wxDefaultValidator,
  53. const wxString& name = wxComboBoxNameStr);
  54. virtual ~wxComboCtrl();
  55. virtual void PrepareBackground( wxDC& dc, const wxRect& rect, int flags ) const;
  56. virtual bool IsKeyPopupToggle(const wxKeyEvent& event) const;
  57. static int GetFeatures() { return wxComboCtrlFeatures::All; }
  58. #if wxUSE_COMBOCTRL_POPUP_ANIMATION
  59. void OnTimerEvent(wxTimerEvent& WXUNUSED(event)) { DoTimerEvent(); }
  60. protected:
  61. void DoTimerEvent();
  62. virtual bool AnimateShow( const wxRect& rect, int flags );
  63. #endif // wxUSE_COMBOCTRL_POPUP_ANIMATION
  64. protected:
  65. // Dummy method - we override all functions that call this
  66. virtual WXHWND GetEditHWND() const { return NULL; }
  67. // customization
  68. virtual void OnResize();
  69. virtual wxCoord GetNativeTextIndent() const;
  70. // event handlers
  71. void OnPaintEvent( wxPaintEvent& event );
  72. void OnMouseEvent( wxMouseEvent& event );
  73. virtual bool HasTransparentBackground() { return IsDoubleBuffered(); }
  74. private:
  75. void Init();
  76. #if wxUSE_COMBOCTRL_POPUP_ANIMATION
  77. // Popup animation related
  78. wxLongLong m_animStart;
  79. wxTimer m_animTimer;
  80. wxRect m_animRect;
  81. int m_animFlags;
  82. #endif
  83. DECLARE_EVENT_TABLE()
  84. DECLARE_DYNAMIC_CLASS(wxComboCtrl)
  85. };
  86. #endif // wxUSE_COMBOCTRL
  87. #endif
  88. // _WX_COMBOCONTROL_H_