]>
git.saurik.com Git - wxWidgets.git/blob - interface/wx/bannerwindow.h
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: interface/wx/bannerwindow.h
3 // Purpose: wxBannerWindow class documentation
4 // Author: Vadim Zeitlin
6 // Copyright: (c) 2011 Vadim Zeitlin <vadim@wxwidgets.org>
7 // Licence: wxWindows licence
8 ///////////////////////////////////////////////////////////////////////////////
11 A simple banner window showing either a bitmap or text.
13 Banner windows can be used to present some overview of the current window
14 contents to the user in an aesthetically pleasant way. They are typically
15 positioned along the left or top edge of the window (although this class
16 also supports right- and bottom-aligned banners) and show either a bitmap
17 with a logo or a few lines of text on a gradient-filled background.
19 Using this class is very simple, e.g.:
23 ... create the frame itself ...
25 // Create and initialize the banner.
26 wxBannerWindow* banner = new wxBannerWindow(this, wxTOP);
27 banner->SetText("Welcome to my wonderful program",
28 " Before doing anything else, you need to connect to "
29 "the online server.\n"
30 " Please enter your credentials in the controls below.");
32 // And position it along the left edge of the window.
33 wxSizer* sizer = new wxBoxSizer(wxVERTICAL);
34 sizer->Add(banner, wxSizerFlags().Expand());
36 ... add the rest of the window contents to the same sizer ...
38 SetSizerAndFit(sizer);
42 This class is currently implemented generically and so looks the same under
47 @genericAppearance{bannerwindow}
51 class wxBannerWindow
: public wxWindow
55 Default constructor, use Create() later.
57 This constructor is only used for two-step creation, if possible,
58 prefer using the constructor below directly instead of using this one
59 and calling Create() later.
64 Convenient constructor that should be used in the majority of cases.
66 The only really important arguments of the full constructor below are
67 @a parent and @a dir so this class provides a convenient constructor
70 The banner orientation changes how the text in it is displayed and also
71 defines where is the bitmap truncated if it's too big to fit but doesn't
72 do anything for the banner position, this is supposed to be taken care
73 of in the usual way, e.g. using sizers.
75 wxBannerWindow(wxWindow
* parent
, wxDirection dir
= wxLEFT
);
78 Full constructor provided for consistency with the other classes only.
80 Prefer to use the shorter constructor documented above. You should
81 rarely, if ever, need to use non-default values for any other
82 parameters: as the banner window doesn't generate any events, its
83 identifier is not particularly useful; its position and size will be
84 almost always managed by the containing sizer and it doesn't have any
85 specific styles. So only the parent and the banner direction need to be
88 wxBannerWindow(wxWindow
* parent
,
90 wxDirection dir
= wxLEFT
,
91 const wxPoint
& pos
= wxDefaultPosition
,
92 const wxSize
& size
= wxDefaultSize
,
94 const wxString
& name
= wxBannerWindowNameStr
);
97 Really create the banner window for the objects created using the
100 It's an error to call Create() for the objects created using
101 non-default constructor.
103 bool Create(wxWindow
* parent
,
105 wxDirection dir
= wxLEFT
,
106 const wxPoint
& pos
= wxDefaultPosition
,
107 const wxSize
& size
= wxDefaultSize
,
109 const wxString
& name
= wxBannerWindowNameStr
);
113 Provide the bitmap to use as background.
115 Notice that ideally the bitmap should be big enough to always cover the
116 entire banner, e.g. for a horizontal banner with wxTOP style its width
117 should be bigger than any reasonable window size. Otherwise the bitmap
118 is extended to cover the entire window area with a solid colour taken
119 from the bitmap pixel on the edge in which direction the extension
120 occurs so all bitmap pixels on this edge (top for wxLEFT, right for
121 wxTOP and wxBOTTOM and bottom for wxRIGHT) should have the same colour
122 to avoid jarring discontinuity.
124 If, on the other hand, the bitmap is bigger than the window size, then
125 it is truncated. For wxLEFT orientation the bitmap is truncated from
126 the top, for wxTOP and wxBOTTOM -- from the right and for wxRIGHT --
127 from the bottom, so put the most important part of the bitmap
128 information in the opposite direction where it will never be truncated.
130 If no valid background bitmap is specified, the banner draws gradient
131 background but if a valid bitmap is given here, the gradient is not
132 draw and the start and end colours specified for it are ignored.
134 @param bmp Bitmap to use as background. May be invalid to indicate
135 that no background bitmap should be used.
137 void SetBitmap(const wxBitmap
& bmp
);
140 Set the text to display.
142 This is mutually exclusive with SetBitmap().
144 Title is rendered in bold and should be single line, message can have
145 multiple lines but is not wrapped automatically, include explicit line
146 breaks in the string if you want to have multiple lines.
148 void SetText(const wxString
& title
, const wxString
& message
);
151 Set the colours between which the gradient runs.
153 The gradient colours are ignored if SetBitmap() is used.
155 void SetGradient(const wxColour
& start
, const wxColour
& end
);