#include <pgbutton.h>
Inheritance diagram for PG_Button:

Public Types | |
| enum | { OK = 0x80000001, YES = 0x80000002, NO = 0x80000003, APPLY = 0x80000004, CANCEL = 0x80000005, CLOSE = 0x80000006, HELP = 0x80000007 } |
| Standard button IDs. More... | |
| enum | STATE { PRESSED, UNPRESSED, HIGHLITED } |
| Button states. More... | |
| enum | BEHAVIOUR { MSGCAPTURE = 0x00000001, SIGNALONCLICK = 0x00000002, SIGNALONRELEASE = 0x00000004 } |
| Behaviour of the button. More... | |
Public Member Functions | |
| PG_Button (PG_Widget *parent, const PG_Rect &r=PG_Rect::null, const std::string &text=PG_NULLSTR, int id=-1, const std::string &style="Button") | |
| Constructor for the PG_Button class. | |
| virtual | ~PG_Button () |
| void | LoadThemeStyle (const std::string &widgettype) |
| Load a style from the theme definition. | |
| void | LoadThemeStyle (const std::string &widgettype, const std::string &objectname) |
| Load a style from the theme definition. | |
| void | SetGradient (STATE state, const PG_Gradient &gradient) |
| Set the gradient. | |
| void | SetBackground (STATE state, SDL_Surface *background, PG_Draw::BkMode mode=PG_Draw::TILE) |
| Set the background. | |
| void | SetBorderColor (int b, const PG_Color &color) |
| Set the color of the border. | |
| bool | SetIcon (const std::string &filenameup=PG_NULLSTR, const std::string &filenamedown=PG_NULLSTR, const std::string &filenameover=PG_NULLSTR) |
| Set icons for the button. | |
| bool | SetIcon (const std::string &filenameup, const std::string &filenamedown, const std::string &filenameover, const PG_Color &colorkey) |
| Set icons for the button. | |
| bool | SetIcon (SDL_Surface *icon_up, SDL_Surface *icon_down=NULL, SDL_Surface *icon_over=NULL, bool freeSurfaces=false) |
| Set icons for the buttons. | |
| SDL_Surface * | GetIcon (STATE num) |
| Returns an image for a given button state. | |
| void | SetIconIndent (Uint16 indent) |
| Set the distance between the left border of the button and the icon. | |
| void | SetBorderSize (int norm, int pressed, int high) |
| Set the bordersize of the button. | |
| void | SetToggle (bool bToggle) |
| Make the button a toggle button. | |
| void | SetPressed (bool pressed) |
| If the button is a toggle button you can modify the status of the button with this function. | |
| void | SetTransparency (Uint8 t, bool bRecursive=false) |
| Set the transparency of the button. | |
| void | SetTransparency (Uint8 norm, Uint8 pressed, Uint8 high) |
| Set the transparency for the single button states. | |
| void | SetShift (int pixelshift) |
| Set the moving distance of the image when we press on it. | |
| bool | GetPressed () |
| Determine whether a given button is pressed. | |
| void | SetBlendLevel (STATE mode, Uint8 blend) |
| Set the blend-level of gradient and background image. | |
| Uint8 | GetBlendLevel (STATE mode) |
| Get the current blend level. | |
| void | SetSizeByText (int Width=0, int Height=0, const std::string &Text=PG_NULLSTR) |
| Resizes the button so that a specified text fits on it. | |
| void | SetBehaviour (int behaviour) |
| Set the behaviour of the button. | |
| void | SetText (const std::string &text) |
| Sets text. | |
Public Attributes | |
| SignalButtonClick | sigClick |
Static Public Attributes | |
| static SignalButtonClick | sigGlobalClick |
Protected Member Functions | |
| virtual void | eventButtonSurface (SDL_Surface **surface, STATE newstate, Uint16 w, Uint16 h) |
| void | eventBlit (SDL_Surface *surface, const PG_Rect &src, const PG_Rect &dst) |
| overridable eventhandler to blit the widget contents to the screen | |
| void | eventSizeWidget (Uint16 w, Uint16 h) |
| Callback for the SizeWidget event. | |
| void | eventMouseLeave () |
| eventhandler for mouse movements. | |
| void | eventMouseEnter () |
| eventhandler for mouse movements. | |
| bool | eventMouseButtonUp (const SDL_MouseButtonEvent *button) |
| Overridable Eventhandler for a SDL_MouseButtonEvent message. | |
| bool | eventMouseButtonDown (const SDL_MouseButtonEvent *button) |
| Overridable Eventhandler for a SDL_MouseButtonEvent message. | |
| bool | eventKeyDown (const SDL_KeyboardEvent *key) |
| Overridable Eventhandler for a SDL_KeyboardEvent message. | |
Classes | |
| class | SignalButtonClick |
| Signal type declaration. More... | |
button screenshot
Several predefined button IDs exist. All of them are associated with default icons used automatically when the given ID is assigned to a button:
PG_Button::OK
PG_Button::YES
PG_Button::NO
PG_Button::APPLY
PG_Button::CANCEL
PG_Button::CLOSE
PG_Button::HELP
widget type: Button (default)
object name: Button
PG_Widget theme
<widget> <type value="Button"/> <object> <name value="Button"/> <filename name="background0" value="default/button_unpressed.png"/> <filename name="background1" value="default/button_pressed.png"/> <filename name="background2" value="default/button_highlighted.png"/> <color name="textcolor" value="0x00ff9807"/> <property name="backmode0" value="TILE"/> <property name="backmode1" value="TILE"/> <property name="backmode2" value="TILE"/> <gradient name="gradient0" color0="0x000000FF" color1="0x000000FF" color2="0x000000FF" color3="0x000000FF"/> <gradient name="gradient1" color0="0x000000FF" color1="0x000000FF" color2="0x000000FF" color3="0x000000FF"/> <gradient name="gradient2" color0="0x000000FF" color1="0x000000FF" color2="0x000000FF" color3="0x000000FF"/> <property name="blend0" value="0"/> <property name="blend1" value="0"/> <property name="blend2" value="0"/> <property name="bordersize0" value="0"/> <property name="bordersize1" value="0"/> <property name="bordersize2" value="0"/> <property name="transparency0" value="0"/> <property name="transparency1" value="0"/> <property name="transparency2" value="0"/> <filename name="iconup" value="none"/> <filename name="icondown" value="none"/> </object> </widget>
Definition at line 125 of file pgbutton.h.
|
|
Standard button IDs.
Definition at line 131 of file pgbutton.h. |
|
|
Behaviour of the button. The default button captures the messages and fires on mouse button release. This can be changed with these flags. Definition at line 154 of file pgbutton.h. |
|
|
Button states.
Definition at line 144 of file pgbutton.h. |
|
||||||||||||||||||||||||
|
Constructor for the PG_Button class.
Definition at line 72 of file pgbutton.cpp. References LoadThemeStyle(), PG_Widget::SetDirtyUpdate(), PG_Widget::SetID(), and SetText(). |
|
|
Definition at line 83 of file pgbutton.cpp. |
|
||||||||||||||||
|
overridable eventhandler to blit the widget contents to the screen
Reimplemented from PG_Widget. Definition at line 510 of file pgbutton.cpp. References PG_Draw::BlitSurface(), PG_Widget::DrawBorder(), PG_Widget::DrawText(), eventButtonSurface(), PG_Widget::GetClipRects(), PG_Application::GetScreen(), PG_Widget::GetTextSize(), PG_Rect::Height(), HIGHLITED, PG_ButtonDataInternal::iconindent, PG_ButtonDataInternal::isPressed, PG_Rect::my_height, PG_Widget::my_text, PG_Rect::my_width, PG_Rect::my_xpos, PG_Rect::my_ypos, PG_Rect::PG_Rect(), PRESSED, PG_ButtonDataInternal::pressShift, PG_ButtonDataInternal::state, PG_ButtonDataInternal::togglemode, UNPRESSED, and PG_Rect::Width(). |
|
||||||||||||||||||||
|
Definition at line 468 of file pgbutton.cpp. References PG_ThemeWidget::CreateThemedSurface(), and PG_ThemeWidget::DeleteThemedSurface(). Referenced by eventBlit(). |
|
|
Overridable Eventhandler for a SDL_KeyboardEvent message. This handler is called when a key changed it's state from unpressed to pressed. The default implementation returns 'false' which indicates that this message is not processed by this object.
Reimplemented from PG_MessageObject. Definition at line 673 of file pgbutton.cpp. References PG_Widget::checkForHotkey(), and sigClick. |
|
|
Overridable Eventhandler for a SDL_MouseButtonEvent message. This handler is called when a mouse button is pressed. The default implementation returns 'false' which indicates that this message is not processed by this object.
Reimplemented from PG_MessageObject. Reimplemented in PG_ScrollBar::ScrollButton. Definition at line 266 of file pgbutton.cpp. References PG_ButtonDataInternal::behaviour, MSGCAPTURE, PRESSED, PG_MessageObject::SetCapture(), sigClick, sigGlobalClick, SIGNALONCLICK, PG_ButtonDataInternal::state, and PG_Widget::Update(). Referenced by PG_ScrollBar::ScrollButton::eventMouseButtonDown(). |
|
|
Overridable Eventhandler for a SDL_MouseButtonEvent message. This handler is called when a mouse button is released. The default implementation returns 'false' which indicates that this message is not processed by this object.
Reimplemented from PG_MessageObject. Reimplemented in PG_ScrollBar::ScrollButton. Definition at line 291 of file pgbutton.cpp. References PG_ButtonDataInternal::behaviour, HIGHLITED, PG_Widget::IsMouseInside(), PG_ButtonDataInternal::isPressed, MSGCAPTURE, PRESSED, PG_MessageObject::ReleaseCapture(), sigClick, sigGlobalClick, SIGNALONRELEASE, PG_ButtonDataInternal::state, PG_ButtonDataInternal::togglemode, UNPRESSED, and PG_Widget::Update(). Referenced by PG_ScrollBar::ScrollButton::eventMouseButtonUp(). |
|
|
eventhandler for mouse movements. This overrideable handler is called everytime the mouse cursor is entering the widget area. Reimplemented from PG_Widget. Reimplemented in GuiButton, and SmallGuiButton. Definition at line 245 of file pgbutton.cpp. References PG_Widget::eventMouseEnter(), HIGHLITED, PG_ButtonDataInternal::isPressed, PG_ButtonDataInternal::state, PG_ButtonDataInternal::togglemode, and PG_Widget::Update(). Referenced by SmallGuiButton::eventMouseEnter(), and GuiButton::eventMouseEnter(). |
|
|
eventhandler for mouse movements. This overrideable handler is called everytime the mouse cursor is leaving the widget area. Reimplemented from PG_Widget. Reimplemented in GuiButton, and SmallGuiButton. Definition at line 255 of file pgbutton.cpp. References PG_ButtonDataInternal::behaviour, PG_Widget::eventMouseLeave(), HIGHLITED, PG_ButtonDataInternal::isPressed, MSGCAPTURE, PRESSED, PG_ButtonDataInternal::state, PG_ButtonDataInternal::togglemode, UNPRESSED, and PG_Widget::Update(). Referenced by SmallGuiButton::eventMouseLeave(), and GuiButton::eventMouseLeave(). |
|
||||||||||||
|
Callback for the SizeWidget event.
Reimplemented from PG_Widget. Definition at line 204 of file pgbutton.cpp. Referenced by SetSizeByText(). |
|
|
Get the current blend level.
Definition at line 625 of file pgbutton.cpp. |
|
|
Returns an image for a given button state.
Definition at line 398 of file pgbutton.cpp. Referenced by SmallGuiButton::updateIcon(). |
|
|
Determine whether a given button is pressed. This can either mean that the user is clicking the button in the case of a push button, or that the button is toggled in the case of a toggle button.
Definition at line 502 of file pgbutton.cpp. References PG_ButtonDataInternal::isPressed, PRESSED, PG_ButtonDataInternal::state, and PG_ButtonDataInternal::togglemode. Referenced by PG_ScrollBar::ScrollButton::eventMouseMotion(), and PG_ScrollBar::SetPosition(). |
|
||||||||||||
|
|
Load a style from the theme definition.
Reimplemented from PG_Widget. Definition at line 90 of file pgbutton.cpp. References PG_PropStr::Button. Referenced by PG_Window::LoadThemeStyle(), PG_ScrollBar::LoadThemeStyle(), PG_RadioButton::LoadThemeStyle(), PG_MessageBox::LoadThemeStyle(), PG_DropDown::LoadThemeStyle(), MessageDialog::LoadThemeStyle(), PG_Button(), PG_CheckButton::PG_CheckButton(), and PG_SpinnerBox::PG_SpinnerBox(). |
|
||||||||||||||||
|
Set the background.
Definition at line 491 of file pgbutton.cpp. Referenced by GuiButton::GuiButton(), LoadThemeStyle(), SmallGuiButton::SmallGuiButton(), and SubWinButton::SubWinButton(). |
|
|
Set the behaviour of the button.
Definition at line 462 of file pgbutton.cpp. References PG_ButtonDataInternal::behaviour. Referenced by PG_MenuBar::Add(), and SmallGuiButton::SmallGuiButton(). |
|
||||||||||||
|
Set the blend-level of gradient and background image.
Definition at line 621 of file pgbutton.cpp. |
|
||||||||||||
|
Set the color of the border.
Definition at line 199 of file pgbutton.cpp. References PG_Widget::my_colorBorder. |
|
||||||||||||||||
|
Set the bordersize of the button.
Definition at line 403 of file pgbutton.cpp. References HIGHLITED, PRESSED, and UNPRESSED. Referenced by GuiButton::GuiButton(), SetUserButtonAtts(), SmallGuiButton::SmallGuiButton(), and SubWinButton::SubWinButton(). |
|
||||||||||||
|
Set the gradient.
Definition at line 487 of file pgbutton.cpp. Referenced by SetButtonAtts(). |
|
||||||||||||||||||||
|
Set icons for the buttons.
Definition at line 381 of file pgbutton.cpp. References PG_ButtonDataInternal::free_icons, HIGHLITED, PRESSED, and UNPRESSED. |
|
||||||||||||||||||||
|
Set icons for the button.
Definition at line 339 of file pgbutton.cpp. |
|
||||||||||||||||
|
Set icons for the button.
Definition at line 359 of file pgbutton.cpp. References PG_ButtonDataInternal::free_icons, HIGHLITED, PG_FileArchive::LoadSurface(), PRESSED, UNPRESSED, and PG_Widget::Update(). Referenced by LoadThemeStyle(), GuiButton::registerFunc(), SetIcon(), SetUserButtonAtts(), SubWinButton::SubWinButton(), TechWidget::TechWidget(), GuiButton::unregisterFunc(), SmallGuiButton::updateIcon(), VehicleTypeBaseWidget::VehicleTypeBaseWidget(), and VehicleTypeCountLocateWidget::VehicleTypeCountLocateWidget(). |
|
|
Set the distance between the left border of the button and the icon.
Definition at line 662 of file pgbutton.cpp. References PG_ButtonDataInternal::iconindent. |
|
|
If the button is a toggle button you can modify the status of the button with this function.
Definition at line 424 of file pgbutton.cpp. References PG_ButtonDataInternal::isPressed, PRESSED, PG_ButtonDataInternal::state, PG_ButtonDataInternal::togglemode, UNPRESSED, and PG_Widget::Update(). Referenced by SmallGuiButton::press(), PG_RadioButton::ReleaseButton(), NewGuiHost::setNewButtonPressed(), PG_RadioButton::SetPressed(), PG_CheckButton::SetUnpressed(), and SetUserButtonAtts(). |
|
|
Set the moving distance of the image when we press on it.
Definition at line 457 of file pgbutton.cpp. References PG_ButtonDataInternal::pressShift. Referenced by SetUserButtonAtts(). |
|
||||||||||||||||
|
Resizes the button so that a specified text fits on it.
Reimplemented from PG_Widget. Definition at line 629 of file pgbutton.cpp. References eventSizeWidget(), PG_Widget::GetFont(), PG_FontEngine::GetTextSize(), PG_Rect::my_height, PG_Widget::my_text, PG_Rect::my_width, PG_MAX, PG_String, PG_ButtonDataInternal::pressShift, PG_Widget::SetSizeByText(), and UNPRESSED. Referenced by PG_RadioButton::SetSizeByText(). |
|
|
Sets text.
Reimplemented from PG_Widget. Definition at line 666 of file pgbutton.cpp. References PG_Widget::extractAndStoreHotkey(), and PG_Widget::SetText(). Referenced by LoadThemeStyle(), ASCGUI_Window::parsePanelASCTXT(), PG_Button(), and PG_PropertyField_Button::PG_PropertyField_Button(). |
|
|
Make the button a toggle button. A normal (push) button will return to an unpressed state when the user stops clicking it (releases the mouse button). A toggle button will stay pressed once it is pressed. The user must click the button a second time in order to unpress it. Definition at line 419 of file pgbutton.cpp. References PG_ButtonDataInternal::togglemode. Referenced by PG_RadioButton::PG_RadioButton(), NetControlWindow::registerChilds(), NewGuiHost::setNewButtonPressed(), SetUserButtonAtts(), and SubWinButton::SubWinButton(). |
|
||||||||||||||||
|
Set the transparency for the single button states.
Definition at line 448 of file pgbutton.cpp. |
|
||||||||||||
|
Set the transparency of the button.
Reimplemented from PG_Widget. Definition at line 433 of file pgbutton.cpp. References PG_Widget::GetChildList(), HIGHLITED, PG_Rect::next(), PRESSED, PG_Widget::SetTransparency(), and UNPRESSED. Referenced by SetUserButtonAtts(). |
|
|
Definition at line 347 of file pgbutton.h. Referenced by PG_MenuBar::Add(), AdminGameWindow::AdminGameWindow(), AllianceSetupWindow::AllianceSetupWindow(), AmmoTransferWindow::AmmoTransferWindow(), AuthenticationDialog::AuthenticationDialog(), BitMapEditor::BitMapEditor(), CargoEditor::CargoEditor(), ChangePasswordDialog::ChangePasswordDialog(), CopyMap::CopyMap(), EditGameOptions::EditGameOptions(), EditMapParameters::EditMapParameters(), EventAreasDialog::EventAreasDialog(), eventKeyDown(), EventList::EventList(), eventMouseButtonDown(), eventMouseButtonUp(), EventWindChangesDialog::EventWindChangesDialog(), GameParameterEditorWidget::GameParameterEditorWidget(), GuiButton::GuiButton(), IngameMessageViewer::IngameMessageViewer(), InternalAmmoTransferWindow::InternalAmmoTransferWindow(), MailOptionsDialog::MailOptionsDialog(), Maped_MainScreenWidget::Maped_MainScreenWidget(), MapInfoPanel::MapInfoPanel(), MessageDialog::MessageDialog(), NewMap::NewMap(), NewMessage::NewMessage(), NewStringChooser::NewStringChooser(), NextCampaignMap::NextCampaignMap(), PG_DropDown::PG_DropDown(), PG_MessageBox::PG_MessageBox(), PG_PropertyField_Button::PG_PropertyField_Button(), PG_RadioButton::PG_RadioButton(), PG_ScrollBar::PG_ScrollBar(), PG_SpinnerBox::PG_SpinnerBox(), PG_Window::PG_Window(), PlayerSetupWindow::PlayerSetupWindow(), ProductionEditorWindow::ProductionEditorWindow(), NetControlWindow::registerChilds(), SaveGameBaseDialog::SaveGameBaseDialog(), SelectFromMap::SelectFromMap(), SmallGuiButton::SmallGuiButton(), SoundSettings::SoundSettings(), StartMultiplayerGame::StartMultiplayerGame(), TechWidget::TechWidget(), CargoDialog::userHandler(), VehicleProduction_SelectionWindow::VehicleProduction_SelectionWindow(), VehicleTypeBaseWidget::VehicleTypeBaseWidget(), VehicleTypeCountLocateWidget::VehicleTypeCountLocateWidget(), ViewTextQuery::ViewTextQuery(), Weathercast::Weathercast(), WeatherDialog::WeatherDialog(), and WeatherPanel::WeatherPanel(). |
|
|
Definition at line 38 of file pgbutton.cpp. Referenced by eventMouseButtonDown(), and eventMouseButtonUp(). |
1.4.2