]> git.saurik.com Git - wxWidgets.git/blob - include/wx/bannerwindow.h
wxRTC: fixed guidelines overwriting adjacent cell borders; corrected capitalisation...
[wxWidgets.git] / include / wx / bannerwindow.h
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: wx/bannerwindow.h
3 // Purpose: wxBannerWindow class declaration
4 // Author: Vadim Zeitlin
5 // Created: 2011-08-16
6 // Copyright: (c) 2011 Vadim Zeitlin <vadim@wxwidgets.org>
7 // Licence: wxWindows licence
8 ///////////////////////////////////////////////////////////////////////////////
9
10 #ifndef _WX_BANNERWINDOW_H_
11 #define _WX_BANNERWINDOW_H_
12
13 #include "wx/defs.h"
14
15 #if wxUSE_BANNERWINDOW
16
17 #include "wx/bitmap.h"
18 #include "wx/event.h"
19 #include "wx/window.h"
20
21 class WXDLLIMPEXP_FWD_CORE wxBitmap;
22 class WXDLLIMPEXP_FWD_CORE wxColour;
23 class WXDLLIMPEXP_FWD_CORE wxDC;
24
25 extern WXDLLIMPEXP_DATA_ADV(const char) wxBannerWindowNameStr[];
26
27 // ----------------------------------------------------------------------------
28 // A simple banner window showing either a bitmap or text.
29 // ----------------------------------------------------------------------------
30
31 class WXDLLIMPEXP_ADV wxBannerWindow : public wxWindow
32 {
33 public:
34 // Default constructor, use Create() later.
35 wxBannerWindow() { Init(); }
36
37 // Convenient constructor that should be used in the majority of cases.
38 //
39 // The banner orientation changes how the text in it is displayed and also
40 // defines where is the bitmap truncated if it's too big to fit but doesn't
41 // do anything for the banner position, this is supposed to be taken care
42 // of in the usual way, e.g. using sizers.
43 wxBannerWindow(wxWindow* parent, wxDirection dir = wxLEFT)
44 {
45 Init();
46
47 Create(parent, wxID_ANY, dir);
48 }
49
50 // Full constructor provided for consistency with the other classes only.
51 wxBannerWindow(wxWindow* parent,
52 wxWindowID winid,
53 wxDirection dir = wxLEFT,
54 const wxPoint& pos = wxDefaultPosition,
55 const wxSize& size = wxDefaultSize,
56 long style = 0,
57 const wxString& name = wxBannerWindowNameStr)
58 {
59 Init();
60
61 Create(parent, winid, dir, pos, size, style, name);
62 }
63
64 // Can be only called on objects created with the default constructor.
65 bool Create(wxWindow* parent,
66 wxWindowID winid,
67 wxDirection dir = wxLEFT,
68 const wxPoint& pos = wxDefaultPosition,
69 const wxSize& size = wxDefaultSize,
70 long style = 0,
71 const wxString& name = wxBannerWindowNameStr);
72
73
74 // Provide an existing bitmap to show. For wxLEFT orientation the bitmap is
75 // truncated from the top, for wxTOP and wxBOTTOM -- from the right and for
76 // wxRIGHT -- from the bottom, so put the most important part of the bitmap
77 // information in the opposite direction.
78 void SetBitmap(const wxBitmap& bmp);
79
80 // Set the text to display. This is mutually exclusive with SetBitmap().
81 // Title is rendered in bold and should be single line, message can have
82 // multiple lines but is not wrapped automatically.
83 void SetText(const wxString& title, const wxString& message);
84
85 // Set the colours between which the gradient runs. This can be combined
86 // with SetText() but not SetBitmap().
87 void SetGradient(const wxColour& start, const wxColour& end);
88
89 protected:
90 virtual wxSize DoGetBestClientSize() const;
91
92 private:
93 // Common part of all constructors.
94 void Init();
95
96 // Fully invalidates the window.
97 void OnSize(wxSizeEvent& event);
98
99 // Redraws the window using either m_bitmap or m_title/m_message.
100 void OnPaint(wxPaintEvent& event);
101
102 // Helper of OnPaint(): draw the bitmap at the correct position depending
103 // on our orientation.
104 void DrawBitmapBackground(wxDC& dc);
105
106 // Helper of OnPaint(): draw the text in the appropriate direction.
107 void DrawBannerTextLine(wxDC& dc, const wxString& str, const wxPoint& pos);
108
109 // Return the font to use for the title. Currently this is hardcoded as a
110 // larger bold version of the standard window font but could be made
111 // configurable in the future.
112 wxFont GetTitleFont() const;
113
114 // Return the colour to use for extending the bitmap. Non-const as it
115 // updates m_colBitmapBg if needed.
116 wxColour GetBitmapBg();
117
118
119 // The window side along which the banner is laid out.
120 wxDirection m_direction;
121
122 // If valid, this bitmap is drawn as is.
123 wxBitmap m_bitmap;
124
125 // If bitmap is valid, this is the colour we use to extend it if the bitmap
126 // is smaller than this window. It is computed on demand by GetBitmapBg().
127 wxColour m_colBitmapBg;
128
129 // The title and main message to draw, used if m_bitmap is invalid.
130 wxString m_title,
131 m_message;
132
133 // Start and stop gradient colours, only used when drawing text.
134 wxColour m_colStart,
135 m_colEnd;
136
137 wxDECLARE_EVENT_TABLE();
138
139 wxDECLARE_NO_COPY_CLASS(wxBannerWindow);
140 };
141
142 #endif // wxUSE_BANNERWINDOW
143
144 #endif // _WX_BANNERWINDOW_H_