srchctrl.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. /////////////////////////////////////////////////////////////////////////////
  2. // Name: wx/srchctrl.h
  3. // Purpose: wxSearchCtrlBase class
  4. // Author: Vince Harron
  5. // Created: 2006-02-18
  6. // Copyright: (c) Vince Harron
  7. // Licence: wxWindows licence
  8. /////////////////////////////////////////////////////////////////////////////
  9. #ifndef _WX_SEARCHCTRL_H_BASE_
  10. #define _WX_SEARCHCTRL_H_BASE_
  11. #include "wx/defs.h"
  12. #if wxUSE_SEARCHCTRL
  13. #include "wx/textctrl.h"
  14. #if !defined(__WXUNIVERSAL__) && defined(__WXMAC__)
  15. // search control was introduced in Mac OS X 10.3 Panther
  16. #define wxUSE_NATIVE_SEARCH_CONTROL 1
  17. #define wxSearchCtrlBaseBaseClass wxTextCtrl
  18. #else
  19. // no native version, use the generic one
  20. #define wxUSE_NATIVE_SEARCH_CONTROL 0
  21. #include "wx/compositewin.h"
  22. #include "wx/containr.h"
  23. class WXDLLIMPEXP_CORE wxSearchCtrlBaseBaseClass
  24. : public wxCompositeWindow< wxNavigationEnabled<wxControl> >,
  25. public wxTextCtrlIface
  26. {
  27. };
  28. #endif
  29. // ----------------------------------------------------------------------------
  30. // constants
  31. // ----------------------------------------------------------------------------
  32. extern WXDLLIMPEXP_DATA_CORE(const char) wxSearchCtrlNameStr[];
  33. wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_SEARCHCTRL_CANCEL_BTN, wxCommandEvent);
  34. wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_SEARCHCTRL_SEARCH_BTN, wxCommandEvent);
  35. // ----------------------------------------------------------------------------
  36. // a search ctrl is a text control with a search button and a cancel button
  37. // it is based on the MacOSX 10.3 control HISearchFieldCreate
  38. // ----------------------------------------------------------------------------
  39. class WXDLLIMPEXP_CORE wxSearchCtrlBase : public wxSearchCtrlBaseBaseClass
  40. {
  41. public:
  42. wxSearchCtrlBase() { }
  43. virtual ~wxSearchCtrlBase() { }
  44. // search control
  45. #if wxUSE_MENUS
  46. virtual void SetMenu(wxMenu *menu) = 0;
  47. virtual wxMenu *GetMenu() = 0;
  48. #endif // wxUSE_MENUS
  49. // get/set options
  50. virtual void ShowSearchButton( bool show ) = 0;
  51. virtual bool IsSearchButtonVisible() const = 0;
  52. virtual void ShowCancelButton( bool show ) = 0;
  53. virtual bool IsCancelButtonVisible() const = 0;
  54. private:
  55. // implement wxTextEntry pure virtual method
  56. virtual wxWindow *GetEditableWindow() { return this; }
  57. };
  58. // include the platform-dependent class implementation
  59. #if wxUSE_NATIVE_SEARCH_CONTROL
  60. #if defined(__WXMAC__)
  61. #include "wx/osx/srchctrl.h"
  62. #endif
  63. #else
  64. #include "wx/generic/srchctlg.h"
  65. #endif
  66. // ----------------------------------------------------------------------------
  67. // macros for handling search events
  68. // ----------------------------------------------------------------------------
  69. #define EVT_SEARCHCTRL_CANCEL_BTN(id, fn) \
  70. wx__DECLARE_EVT1(wxEVT_SEARCHCTRL_CANCEL_BTN, id, wxCommandEventHandler(fn))
  71. #define EVT_SEARCHCTRL_SEARCH_BTN(id, fn) \
  72. wx__DECLARE_EVT1(wxEVT_SEARCHCTRL_SEARCH_BTN, id, wxCommandEventHandler(fn))
  73. // old wxEVT_COMMAND_* constants
  74. #define wxEVT_COMMAND_SEARCHCTRL_CANCEL_BTN wxEVT_SEARCHCTRL_CANCEL_BTN
  75. #define wxEVT_COMMAND_SEARCHCTRL_SEARCH_BTN wxEVT_SEARCHCTRL_SEARCH_BTN
  76. #endif // wxUSE_SEARCHCTRL
  77. #endif // _WX_SEARCHCTRL_H_BASE_