The wxWidgets programming tutorial (7. Wigets part 1)

Jan Bodnar, “ The wxWidgets programming tutorial (7. Wigets part 1)”, public translation into Turkish from English More about this translation.

Another translations: into Russian. Translate into another language.

Participants

attila8 points
Join Translated.by to translate! If you already have a Translated.by account, please sign in.
If you do not want to register an account, you can sign in with OpenID.
Pages: ← previous Ctrl next next untranslated
1 2 3 4

The wxWidgets programming tutorial (7. Wigets part 1)

The wxWidgets programming tutorial (7. Wigets part 1)

History of edits (Latest: attila 5 months, 2 weeks ago) §

Widgets

In this chapter, we will show small examples of several widgets, available in wxWidgets. Widgets are builing blocks of our applications. wxWidgets consists of a large amout of useful widgets. Widget is a basic GUI object by definition. A widget gave wxWidgets toolkit a name. This term is used on UNIX systems. On windows, a widget is usually called a control.

wxCheckBox

wxCheckBox is a widget that has two states. On and Off. It is a box with a label. The label can be set to the right or to the left of the box. If the checkbox is checked, it is represented by a tick in a box. A checkbox can be used to show/hide splashscreen at startup, toggle visibility of a toolbar etc.

In our example, we display one checkbox on the window. We toggle the titlel of the window by clicking on the checkbox.

m_cb = new wxCheckBox(panel, ID_CHECKBOX, wxT("Show title"),

wxPoint(20, 20));

m_cb->SetValue(true);

We create a checkbox. By default, the title is visible. So we check the checkbox by calling the method SetValue().

Connect(ID_CHECKBOX, wxEVT_COMMAND_CHECKBOX_CLICKED,

wxCommandEventHandler(CheckBox::OnToggle));

If we click on the checkbox, a wxEVT_COMMAND_CHECKBOX_CLICKED event is generated. We connect this event to the user defined OnToggle() method.

if (m_cb->GetValue()) {

this->SetTitle(wxT("CheckBox"));

} else {

this->SetTitle(wxT(" "));

}

Inside the OnToggle() method, we check the state of the checkbox. If it is checked, we display "CheckBox" string in the titlebar, otherwise we clear the title.

wxBitmapButton

A bitmap button is a button, that displays a bitmap. A bitmap button can have three other states. Selected, focused and displayed. We can set a specific bitmap for those states.

In our example, we have a slider and a bitmap button. We simulate a volume control. By dragging the handle of a slider, we change a bitmap on the button.

wxImage::AddHandler( new wxPNGHandler );

We will use PNG images, so we must initialize a PNG image handler.

Pages: ← previous Ctrl next next untranslated
1 2 3 4