Static Controls
Static controls do not take any input and are used to display information or to enhance the application's aesthetics.
wxGauge
This is a horizontal or vertical bar that shows a quantity (often time) from zero to the specified range. No command events are generated for the gauge. Here's a simple example of creating a gauge:
Under Windows, this is displayed as shown in Figure 4-28.
#include "wx/gauge.h"
wxGauge* gauge = new wxGauge(panel, ID_GAUGE,
200, wxDefaultPosition, wxDefaultSize, wxGA_HORIZONTAL);
gauge->SetValue(50);
Figure 4-28. A wxGauge

wxGauge Styles
Table 4-42 lists the specific window styles for wxGauge.
wxGA_HORIZONTAL | Creates a horizontal gauge. |
wxGA_VERTICAL | Creates a vertical gauge. |
wxGA_SMOOTH | Creates a smooth progress bar with no spaces between steps. This is only supported on Windows. |
wxGauge Events
Because it only displays information, wxGauge does not generate events.
wxGauge Member Functions
These are the major wxGauge functions.GeTRange and SetRange are accessors for the gauge range (the maximum integer value).GetValue and SetValue get and set the integer value of the gauge.IsVertical returns TRue if the gauge is vertical, and false if horizontal.
wxStaticText
A static text control displays one or more lines of read-only text.To create a wxStaticText control, pass a parent window, identifier, label, position, size, and style. For example:
Under Windows, this creates the control shown in Figure 4-29.
#include "wx/stattext.h"
wxStaticText* staticText = new wxStaticText(panel, wxID_STATIC,
wxT("This is my &static label"),
wxDefaultPosition, wxDefaultSize, wxALIGN_LEFT);
Figure 4-29. A wxStaticText

wxStaticText Styles
Table 4-43 lists the specific window styles for wxStaticText.
wxALIGN_LEFT | Aligns the text to the left. |
wxALIGN_RIGHT | Aligns the text to the right. |
wxALIGN_CENTRE | Centers the text horizontally. wxALIGN_CENTER |
wxST_NO_AUTORESIZE | By default, the control will adjust its size to exactly fit the size of the text when SetLabel is called. If this style is given, the control will not change its size. This style is especially useful with controls that also have wxALIGN_RIGHT or wxALIGN_CENTER because otherwise they won't make sense any longer after a call to SetLabel. |
wxStaticText Member Functions
GetLabel and SetLabel are accessors for the text label.
wxStaticBitmap
A static bitmap control displays an image.To create a wxStaticBitmap control, pass a parent window, identifier, bitmap, position, size and style. For example:
This produces a simple image on the panel or dialog as shown in Figure 4-30.
#include "wx/statbmp.h"
#include "print.xpm"
wxBitmap bitmap(print_xpm);
wxStaticBitmap* staticBitmap = new wxStaticBitmap(panel, wxID_STATIC,
bitmap);
Figure 4-30. A wxStaticBitmap

wxStaticBitmap Styles
There are no special styles for wxStaticBitmap.
wxStaticBitmap Member Functions
GetBitmap and SetBitmap are accessors for the bitmap label.
wxStaticLine
This control displays a horizontal or vertical line, to be used as a separator in dialogs.Here's an example of creating a wxStaticLine control:
Figure 4-31 shows what a horizontal static line looks like under Windows.
#include "wx/statline.h"
wxStaticLine* staticLine = new wxStaticLine(panel, wxID_STATIC,
wxDefaultPosition, wxSize(150, -1), wxLI_HORIZONTAL);
Figure 4-31. A wxStaticLine

wxStaticLine Styles
Table 4-44 lists the specific window styles for wxStaticLine.
wxLI_HORIZONTAL | Creates a horizontal line. |
wxLI_VERTICAL | Creates a vertical line. |
wxStaticLine Member Functions
IsVertical returns true if the line is vertical, false otherwise.
wxStaticBox
This control is a rectangle drawn around other controls to denote a logical grouping of items, with an optional text label. At present, the control should not be used as a parent for further controls; the controls that it surrounds are actually siblings of the box and should be created after it but with the same parent as the box. Future versions of wxWidgets may allow contained controls to be either siblings or children.Here's an example of creating a wxStaticBox control:
This will look like the control in Figure 4-32 under Windows.
#include "wx/statbox.h"
wxStaticBox* staticBox = new wxStaticBox(panel, wxID_STATIC,
wxT("&Static box"), wxDefaultPosition, wxSize(100, 100));
Figure 4-32. A wxStaticBox

wxStaticBox Styles
There are no special styles for wxStaticBox.
wxStaticBox Member Functions
Use GetLabel and SetLabel to get and set the static box text.
