choice.h 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. /////////////////////////////////////////////////////////////////////////////
  2. // Name: wx/choice.h
  3. // Purpose: wxChoice class interface
  4. // Author: Vadim Zeitlin
  5. // Modified by:
  6. // Created: 26.07.99
  7. // Copyright: (c) wxWidgets team
  8. // Licence: wxWindows licence
  9. /////////////////////////////////////////////////////////////////////////////
  10. #ifndef _WX_CHOICE_H_BASE_
  11. #define _WX_CHOICE_H_BASE_
  12. // ----------------------------------------------------------------------------
  13. // headers
  14. // ----------------------------------------------------------------------------
  15. #include "wx/defs.h"
  16. #if wxUSE_CHOICE
  17. #include "wx/ctrlsub.h" // the base class
  18. // ----------------------------------------------------------------------------
  19. // global data
  20. // ----------------------------------------------------------------------------
  21. extern WXDLLIMPEXP_DATA_CORE(const char) wxChoiceNameStr[];
  22. // ----------------------------------------------------------------------------
  23. // wxChoice allows to select one of a non-modifiable list of strings
  24. // ----------------------------------------------------------------------------
  25. class WXDLLIMPEXP_CORE wxChoiceBase : public wxControlWithItems
  26. {
  27. public:
  28. wxChoiceBase() { }
  29. virtual ~wxChoiceBase();
  30. // all generic methods are in wxControlWithItems
  31. // get the current selection: this can only be different from the normal
  32. // selection if the popup items list is currently opened and the user
  33. // selected some item in it but didn't close the list yet; otherwise (and
  34. // currently always on platforms other than MSW) this is the same as
  35. // GetSelection()
  36. virtual int GetCurrentSelection() const { return GetSelection(); }
  37. // set/get the number of columns in the control (as they're not supported on
  38. // most platforms, they do nothing by default)
  39. virtual void SetColumns(int WXUNUSED(n) = 1 ) { }
  40. virtual int GetColumns() const { return 1 ; }
  41. // emulate selecting the item event.GetInt()
  42. void Command(wxCommandEvent& event);
  43. // override wxItemContainer::IsSorted
  44. virtual bool IsSorted() const { return HasFlag(wxCB_SORT); }
  45. protected:
  46. // The generic implementation doesn't determine the height correctly and
  47. // doesn't account for the width of the arrow but does take into account
  48. // the string widths, so the derived classes should override it and set the
  49. // height and add the arrow width to the size returned by this version.
  50. virtual wxSize DoGetBestSize() const;
  51. private:
  52. wxDECLARE_NO_COPY_CLASS(wxChoiceBase);
  53. };
  54. // ----------------------------------------------------------------------------
  55. // include the platform-dependent class definition
  56. // ----------------------------------------------------------------------------
  57. #if defined(__WXUNIVERSAL__)
  58. #include "wx/univ/choice.h"
  59. #elif defined(__SMARTPHONE__) && defined(__WXWINCE__)
  60. #include "wx/msw/wince/choicece.h"
  61. #elif defined(__WXMSW__)
  62. #include "wx/msw/choice.h"
  63. #elif defined(__WXMOTIF__)
  64. #include "wx/motif/choice.h"
  65. #elif defined(__WXGTK20__)
  66. #include "wx/gtk/choice.h"
  67. #elif defined(__WXGTK__)
  68. #include "wx/gtk1/choice.h"
  69. #elif defined(__WXMAC__)
  70. #include "wx/osx/choice.h"
  71. #elif defined(__WXCOCOA__)
  72. #include "wx/cocoa/choice.h"
  73. #elif defined(__WXPM__)
  74. #include "wx/os2/choice.h"
  75. #endif
  76. #endif // wxUSE_CHOICE
  77. #endif // _WX_CHOICE_H_BASE_