1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: wx/bannerwindow.h
3 // Purpose: wxBannerWindow class declaration
4 // Author: Vadim Zeitlin
7 // Copyright: (c) 2011 Vadim Zeitlin <vadim@wxwidgets.org>
8 // Licence: wxWindows licence
9 ///////////////////////////////////////////////////////////////////////////////
11 #ifndef _WX_BANNERWINDOW_H_
12 #define _WX_BANNERWINDOW_H_
16 #if wxUSE_BANNERWINDOW
18 #include "wx/bitmap.h"
20 #include "wx/window.h"
22 class WXDLLIMPEXP_FWD_CORE wxBitmap
;
23 class WXDLLIMPEXP_FWD_CORE wxColour
;
24 class WXDLLIMPEXP_FWD_CORE wxDC
;
26 extern WXDLLIMPEXP_DATA_ADV(const char) wxBannerWindowNameStr
[];
28 // ----------------------------------------------------------------------------
29 // A simple banner window showing either a bitmap or text.
30 // ----------------------------------------------------------------------------
32 class WXDLLIMPEXP_ADV wxBannerWindow
: public wxWindow
35 // Default constructor, use Create() later.
36 wxBannerWindow() { Init(); }
38 // Convenient constructor that should be used in the majority of cases.
40 // The banner orientation changes how the text in it is displayed and also
41 // defines where is the bitmap truncated if it's too big to fit but doesn't
42 // do anything for the banner position, this is supposed to be taken care
43 // of in the usual way, e.g. using sizers.
44 wxBannerWindow(wxWindow
* parent
, wxDirection dir
= wxLEFT
)
48 Create(parent
, wxID_ANY
, dir
);
51 // Full constructor provided for consistency with the other classes only.
52 wxBannerWindow(wxWindow
* parent
,
54 wxDirection dir
= wxLEFT
,
55 const wxPoint
& pos
= wxDefaultPosition
,
56 const wxSize
& size
= wxDefaultSize
,
58 const wxString
& name
= wxBannerWindowNameStr
)
62 Create(parent
, winid
, dir
, pos
, size
, style
, name
);
65 // Can be only called on objects created with the default constructor.
66 bool Create(wxWindow
* parent
,
68 wxDirection dir
= wxLEFT
,
69 const wxPoint
& pos
= wxDefaultPosition
,
70 const wxSize
& size
= wxDefaultSize
,
72 const wxString
& name
= wxBannerWindowNameStr
);
75 // Provide an existing bitmap to show. For wxLEFT orientation the bitmap is
76 // truncated from the top, for wxTOP and wxBOTTOM -- from the right and for
77 // wxRIGHT -- from the bottom, so put the most important part of the bitmap
78 // information in the opposite direction.
79 void SetBitmap(const wxBitmap
& bmp
);
81 // Set the text to display. This is mutually exclusive with SetBitmap().
82 // Title is rendered in bold and should be single line, message can have
83 // multiple lines but is not wrapped automatically.
84 void SetText(const wxString
& title
, const wxString
& message
);
86 // Set the colours between which the gradient runs. This can be combined
87 // with SetText() but not SetBitmap().
88 void SetGradient(const wxColour
& start
, const wxColour
& end
);
91 virtual wxSize
DoGetBestClientSize() const;
94 // Common part of all constructors.
97 // Fully invalidates the window.
98 void OnSize(wxSizeEvent
& event
);
100 // Redraws the window using either m_bitmap or m_title/m_message.
101 void OnPaint(wxPaintEvent
& event
);
103 // Helper of OnPaint(): draw the bitmap at the correct position depending
104 // on our orientation.
105 void DrawBitmapBackground(wxDC
& dc
);
107 // Helper of OnPaint(): draw the text in the appropriate direction.
108 void DrawBannerTextLine(wxDC
& dc
, const wxString
& str
, const wxPoint
& pos
);
110 // Return the font to use for the title. Currently this is hardcoded as a
111 // larger bold version of the standard window font but could be made
112 // configurable in the future.
113 wxFont
GetTitleFont() const;
116 // The window side along which the banner is laid out.
117 wxDirection m_direction
;
119 // If valid, this bitmap is drawn as is.
122 // The title and main message to draw, used if m_bitmap is invalid.
126 // Start and stop gradient colours, only used when drawing text.
130 wxDECLARE_EVENT_TABLE();
132 wxDECLARE_NO_COPY_CLASS(wxBannerWindow
);
135 #endif // wxUSE_BANNERWINDOW
137 #endif // _WX_BANNERWINDOW_H_