infobar.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. ///////////////////////////////////////////////////////////////////////////////
  2. // Name: wx/generic/infobar.h
  3. // Purpose: generic wxInfoBar class declaration
  4. // Author: Vadim Zeitlin
  5. // Created: 2009-07-28
  6. // Copyright: (c) 2009 Vadim Zeitlin <vadim@wxwidgets.org>
  7. // Licence: wxWindows licence
  8. ///////////////////////////////////////////////////////////////////////////////
  9. #ifndef _WX_GENERIC_INFOBAR_H_
  10. #define _WX_GENERIC_INFOBAR_H_
  11. class WXDLLIMPEXP_FWD_CORE wxBitmapButton;
  12. class WXDLLIMPEXP_FWD_CORE wxStaticBitmap;
  13. class WXDLLIMPEXP_FWD_CORE wxStaticText;
  14. // ----------------------------------------------------------------------------
  15. // wxInfoBar
  16. // ----------------------------------------------------------------------------
  17. class WXDLLIMPEXP_CORE wxInfoBarGeneric : public wxInfoBarBase
  18. {
  19. public:
  20. // the usual ctors and Create() but remember that info bar is created
  21. // hidden
  22. wxInfoBarGeneric() { Init(); }
  23. wxInfoBarGeneric(wxWindow *parent, wxWindowID winid = wxID_ANY)
  24. {
  25. Init();
  26. Create(parent, winid);
  27. }
  28. bool Create(wxWindow *parent, wxWindowID winid = wxID_ANY);
  29. // implement base class methods
  30. // ----------------------------
  31. virtual void ShowMessage(const wxString& msg,
  32. int flags = wxICON_INFORMATION);
  33. virtual void Dismiss();
  34. virtual void AddButton(wxWindowID btnid, const wxString& label = wxString());
  35. virtual void RemoveButton(wxWindowID btnid);
  36. // methods specific to this version
  37. // --------------------------------
  38. // set the effect(s) to use when showing/hiding the bar, may be
  39. // wxSHOW_EFFECT_NONE to disable any effects entirely
  40. //
  41. // by default, slide to bottom/top is used when it's positioned on the top
  42. // of the window for showing/hiding it and top/bottom when it's positioned
  43. // at the bottom
  44. void SetShowHideEffects(wxShowEffect showEffect, wxShowEffect hideEffect)
  45. {
  46. m_showEffect = showEffect;
  47. m_hideEffect = hideEffect;
  48. }
  49. // get effect used when showing/hiding the window
  50. wxShowEffect GetShowEffect() const;
  51. wxShowEffect GetHideEffect() const;
  52. // set the duration of animation used when showing/hiding the bar, in ms
  53. void SetEffectDuration(int duration) { m_effectDuration = duration; }
  54. // get the currently used effect animation duration
  55. int GetEffectDuration() const { return m_effectDuration; }
  56. // overridden base class methods
  57. // -----------------------------
  58. // setting the font of this window sets it for the text control inside it
  59. // (default font is a larger and bold version of the normal one)
  60. virtual bool SetFont(const wxFont& font);
  61. #if wxABI_VERSION >= 30001
  62. // same thing with the colour: this affects the text colour
  63. virtual bool SetForegroundColour(const wxColor& colour);
  64. #endif // 3.0.1+
  65. protected:
  66. // info bar shouldn't have any border by default, the colour difference
  67. // between it and the main window separates it well enough
  68. virtual wxBorder GetDefaultBorder() const { return wxBORDER_NONE; }
  69. // update the parent to take our new or changed size into account (notably
  70. // should be called when we're shown or hidden)
  71. void UpdateParent();
  72. private:
  73. // common part of all ctors
  74. void Init();
  75. // handler for the close button
  76. void OnButton(wxCommandEvent& event);
  77. // show/hide the bar
  78. void DoShow();
  79. void DoHide();
  80. // determine the placement of the bar from its position in the containing
  81. // sizer
  82. enum BarPlacement
  83. {
  84. BarPlacement_Top,
  85. BarPlacement_Bottom,
  86. BarPlacement_Unknown
  87. };
  88. BarPlacement GetBarPlacement() const;
  89. // different controls making up the bar
  90. wxStaticBitmap *m_icon;
  91. wxStaticText *m_text;
  92. wxBitmapButton *m_button;
  93. // the effects to use when showing/hiding and duration for them: by default
  94. // the effect is determined by the info bar automatically depending on its
  95. // position and the default duration is used
  96. wxShowEffect m_showEffect,
  97. m_hideEffect;
  98. int m_effectDuration;
  99. DECLARE_EVENT_TABLE()
  100. wxDECLARE_NO_COPY_CLASS(wxInfoBarGeneric);
  101. };
  102. #endif // _WX_GENERIC_INFOBAR_H_