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 10 #ifndef _WX_GENERIC_INFOBAR_H_ 11 #define _WX_GENERIC_INFOBAR_H_ 12 13 class WXDLLIMPEXP_FWD_CORE wxBitmapButton; 14 class WXDLLIMPEXP_FWD_CORE wxStaticBitmap; 15 class WXDLLIMPEXP_FWD_CORE wxStaticText; 16 17 // ---------------------------------------------------------------------------- 18 // wxInfoBar 19 // ---------------------------------------------------------------------------- 20 21 class WXDLLIMPEXP_CORE wxInfoBarGeneric : public wxInfoBarBase 22 { 23 public: 24 // the usual ctors and Create() but remember that info bar is created 25 // hidden wxInfoBarGeneric()26 wxInfoBarGeneric() { Init(); } 27 28 wxInfoBarGeneric(wxWindow *parent, wxWindowID winid = wxID_ANY) 29 { 30 Init(); 31 Create(parent, winid); 32 } 33 34 bool Create(wxWindow *parent, wxWindowID winid = wxID_ANY); 35 36 37 // implement base class methods 38 // ---------------------------- 39 40 virtual void ShowMessage(const wxString& msg, 41 int flags = wxICON_INFORMATION) wxOVERRIDE; 42 43 virtual void Dismiss() wxOVERRIDE; 44 45 virtual void AddButton(wxWindowID btnid, const wxString& label = wxString()) wxOVERRIDE; 46 47 virtual void RemoveButton(wxWindowID btnid) wxOVERRIDE; 48 49 virtual size_t GetButtonCount() const wxOVERRIDE; 50 virtual wxWindowID GetButtonId(size_t idx) const wxOVERRIDE; 51 virtual bool HasButtonId(wxWindowID btnid) const wxOVERRIDE; 52 53 // methods specific to this version 54 // -------------------------------- 55 56 // set the effect(s) to use when showing/hiding the bar, may be 57 // wxSHOW_EFFECT_NONE to disable any effects entirely 58 // 59 // by default, slide to bottom/top is used when it's positioned on the top 60 // of the window for showing/hiding it and top/bottom when it's positioned 61 // at the bottom SetShowHideEffects(wxShowEffect showEffect,wxShowEffect hideEffect)62 void SetShowHideEffects(wxShowEffect showEffect, wxShowEffect hideEffect) 63 { 64 m_showEffect = showEffect; 65 m_hideEffect = hideEffect; 66 } 67 68 // get effect used when showing/hiding the window 69 wxShowEffect GetShowEffect() const; 70 wxShowEffect GetHideEffect() const; 71 72 // set the duration of animation used when showing/hiding the bar, in ms SetEffectDuration(int duration)73 void SetEffectDuration(int duration) { m_effectDuration = duration; } 74 75 // get the currently used effect animation duration GetEffectDuration()76 int GetEffectDuration() const { return m_effectDuration; } 77 78 79 // overridden base class methods 80 // ----------------------------- 81 82 // setting the font of this window sets it for the text control inside it 83 // (default font is a larger and bold version of the normal one) 84 virtual bool SetFont(const wxFont& font) wxOVERRIDE; 85 86 // same thing with the colour: this affects the text colour 87 virtual bool SetForegroundColour(const wxColor& colour) wxOVERRIDE; 88 89 protected: 90 // info bar shouldn't have any border by default, the colour difference 91 // between it and the main window separates it well enough GetDefaultBorder()92 virtual wxBorder GetDefaultBorder() const wxOVERRIDE { return wxBORDER_NONE; } 93 94 95 // update the parent to take our new or changed size into account (notably 96 // should be called when we're shown or hidden) 97 void UpdateParent(); 98 99 private: 100 // common part of all ctors 101 void Init(); 102 103 // handler for the close button 104 void OnButton(wxCommandEvent& event); 105 106 // show/hide the bar 107 void DoShow(); 108 void DoHide(); 109 110 // determine the placement of the bar from its position in the containing 111 // sizer 112 enum BarPlacement 113 { 114 BarPlacement_Top, 115 BarPlacement_Bottom, 116 BarPlacement_Unknown 117 }; 118 119 BarPlacement GetBarPlacement() const; 120 121 122 // different controls making up the bar 123 wxStaticBitmap *m_icon; 124 wxStaticText *m_text; 125 wxBitmapButton *m_button; 126 127 // the effects to use when showing/hiding and duration for them: by default 128 // the effect is determined by the info bar automatically depending on its 129 // position and the default duration is used 130 wxShowEffect m_showEffect, 131 m_hideEffect; 132 int m_effectDuration; 133 134 wxDECLARE_EVENT_TABLE(); 135 wxDECLARE_NO_COPY_CLASS(wxInfoBarGeneric); 136 }; 137 138 #endif // _WX_GENERIC_INFOBAR_H_ 139 140