]>
Commit | Line | Data |
---|---|---|
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 | |
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); | |
42 | ||
43 | virtual void Dismiss(); | |
44 | ||
45 | virtual void AddButton(wxWindowID btnid, const wxString& label = wxString()); | |
46 | ||
47 | virtual void RemoveButton(wxWindowID btnid); | |
48 | ||
49 | // methods specific to this version | |
50 | // -------------------------------- | |
51 | ||
52 | // set the effect(s) to use when showing/hiding the bar, may be | |
53 | // wxSHOW_EFFECT_NONE to disable any effects entirely | |
54 | // | |
55 | // by default, slide to bottom/top is used when it's positioned on the top | |
56 | // of the window for showing/hiding it and top/bottom when it's positioned | |
57 | // at the bottom | |
58 | void SetShowHideEffects(wxShowEffect showEffect, wxShowEffect hideEffect) | |
59 | { | |
60 | m_showEffect = showEffect; | |
61 | m_hideEffect = hideEffect; | |
62 | } | |
63 | ||
64 | // get effect used when showing/hiding the window | |
65 | wxShowEffect GetShowEffect() const; | |
66 | wxShowEffect GetHideEffect() const; | |
67 | ||
68 | // set the duration of animation used when showing/hiding the bar, in ms | |
69 | void SetEffectDuration(int duration) { m_effectDuration = duration; } | |
70 | ||
71 | // get the currently used effect animation duration | |
72 | int GetEffectDuration() const { return m_effectDuration; } | |
73 | ||
74 | ||
75 | // overridden base class methods | |
76 | // ----------------------------- | |
77 | ||
78 | // setting the font of this window sets it for the text control inside it | |
79 | // (default font is a larger and bold version of the normal one) | |
80 | virtual bool SetFont(const wxFont& font); | |
81 | ||
82 | protected: | |
83 | // info bar shouldn't have any border by default, the colour difference | |
84 | // between it and the main window separates it well enough | |
85 | virtual wxBorder GetDefaultBorder() const { return wxBORDER_NONE; } | |
86 | ||
87 | ||
88 | // update the parent to take our new or changed size into account (notably | |
89 | // should be called when we're shown or hidden) | |
90 | void UpdateParent(); | |
91 | ||
92 | private: | |
93 | // common part of all ctors | |
94 | void Init(); | |
95 | ||
96 | // handler for the close button | |
97 | void OnButton(wxCommandEvent& event); | |
98 | ||
99 | // show/hide the bar | |
100 | void DoShow(); | |
101 | void DoHide(); | |
102 | ||
103 | // determine the placement of the bar from its position in the containing | |
104 | // sizer | |
105 | enum BarPlacement | |
106 | { | |
107 | BarPlacement_Top, | |
108 | BarPlacement_Bottom, | |
109 | BarPlacement_Unknown | |
110 | }; | |
111 | ||
112 | BarPlacement GetBarPlacement() const; | |
113 | ||
114 | ||
115 | // different controls making up the bar | |
116 | wxStaticBitmap *m_icon; | |
117 | wxStaticText *m_text; | |
118 | wxBitmapButton *m_button; | |
119 | ||
120 | // the effects to use when showing/hiding and duration for them: by default | |
121 | // the effect is determined by the info bar automatically depending on its | |
122 | // position and the default duration is used | |
123 | wxShowEffect m_showEffect, | |
124 | m_hideEffect; | |
125 | int m_effectDuration; | |
126 | ||
127 | DECLARE_EVENT_TABLE() | |
128 | wxDECLARE_NO_COPY_CLASS(wxInfoBarGeneric); | |
129 | }; | |
130 | ||
131 | #endif // _WX_GENERIC_INFOBAR_H_ | |
132 |