popupwin.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. /////////////////////////////////////////////////////////////////////////////
  2. // Name: popupwin.h
  3. // Purpose: interface of wxPopupWindow
  4. // Author: wxWidgets team
  5. // Licence: wxWindows licence
  6. /////////////////////////////////////////////////////////////////////////////
  7. /**
  8. @class wxPopupWindow
  9. A special kind of top level window used for popup menus,
  10. combobox popups and such.
  11. @library{wxcore}
  12. @category{managedwnd}
  13. @see wxDialog, wxFrame
  14. */
  15. class wxPopupWindow: public wxNonOwnedWindow
  16. {
  17. public:
  18. /**
  19. Default constructor
  20. */
  21. wxPopupWindow();
  22. /**
  23. Constructor
  24. */
  25. wxPopupWindow(wxWindow *parent, int flags = wxBORDER_NONE);
  26. /**
  27. Create method for two-step creation
  28. */
  29. bool Create(wxWindow *parent, int flags = wxBORDER_NONE);
  30. /**
  31. Move the popup window to the right position, i.e.\ such that it is
  32. entirely visible.
  33. The popup is positioned at ptOrigin + size if it opens below and to the
  34. right (default), at ptOrigin - sizePopup if it opens above and to the
  35. left etc.
  36. @param ptOrigin
  37. Must be given in screen coordinates!
  38. @param sizePopup
  39. The size of the popup window
  40. */
  41. virtual void Position(const wxPoint& ptOrigin,
  42. const wxSize& sizePopup);
  43. };
  44. /**
  45. @class wxPopupTransientWindow
  46. A wxPopupWindow which disappears automatically when the user clicks mouse
  47. outside it or if it loses focus in any other way.
  48. This window can be useful for implementing custom combobox-like controls
  49. for example.
  50. @library{wxcore}
  51. @category{managedwnd}
  52. @see wxPopupWindow
  53. */
  54. class wxPopupTransientWindow : public wxPopupWindow
  55. {
  56. public:
  57. /**
  58. Default constructor.
  59. */
  60. wxPopupTransientWindow();
  61. /**
  62. Constructor.
  63. */
  64. wxPopupTransientWindow(wxWindow *parent, int flags = wxBORDER_NONE);
  65. /**
  66. Popup the window (this will show it too).
  67. If @a winFocus is non-@NULL, it will be kept focused while this window
  68. is shown, otherwise this window itself will receive focus. In any case,
  69. the popup will disappear automatically if it loses focus because of a
  70. user action.
  71. @see Dismiss()
  72. */
  73. virtual void Popup(wxWindow *focus = NULL);
  74. /**
  75. Hide the window.
  76. */
  77. virtual void Dismiss();
  78. /**
  79. Called when a mouse is pressed while the popup is shown.
  80. Return @true from here to prevent its normal processing by the popup
  81. (which consists in dismissing it if the mouse is clicked outside it).
  82. */
  83. virtual bool ProcessLeftDown(wxMouseEvent& event);
  84. protected:
  85. /**
  86. This is called when the popup is disappeared because of anything
  87. else but direct call to Dismiss().
  88. */
  89. virtual void OnDismiss();
  90. };