#include <pgwidget.h>
Inheritance diagram for PG_Widget:

Public Types | |
| enum | KeyAction { ACT_ACTIVATE, ACT_DEACTIVATE, ACT_OK, ACT_CANCEL, ACT_LEFT, ACT_RIGHT, ACT_UP, ACT_DOWN } |
| Keyevent actions. More... | |
Public Member Functions | |
| PG_Widget (PG_Widget *parent, const PG_Rect &rect=PG_Rect::null, bool bObjectSurface=false) | |
| Creates a PG_Widget with an internal object surface. | |
| virtual | ~PG_Widget () |
| Destroys a PG_Widget. | |
| void | LoadThemeStyle (const std::string &widgettype) |
| Load a style from the theme definition. | |
| virtual void | LoadThemeStyle (const std::string &widgettype, const std::string &objectname) |
| Load a style from the theme definition. | |
| void | StartWidgetDrag () |
| Start to drag a widget. | |
| void | WidgetDrag (int x, int y) |
| Drag the widget to a given position (in screen coordinates). | |
| void | EndWidgetDrag (int x, int y) |
| Finishes a drag operation. | |
| bool | MoveWidget (int x, int y, bool update=true) |
| Move a widget. | |
| bool | MoveWidget (const PG_Rect &r, bool update=true) |
| Move and resize widget. | |
| virtual bool | SizeWidget (Uint16 w, Uint16 h, bool update=true) |
| Resize a widget. | |
| PG_Point | ClientToScreen (int x, int y) |
| Convert a client (widget) coordinate to a screen position. | |
| PG_Point | ScreenToClient (int x, int y) |
| Convert a screen position to a client (widget) coordinate. | |
| SDL_Surface * | GetWidgetSurface () |
| Return the pointer to the widget's drawing surface. | |
| bool | IsVisible () |
| Check if the object is visible. | |
| PG_Widget * | GetParent () |
| Get the parentwidget of a widget. | |
| virtual void | AddChild (PG_Widget *child) |
| Add a clientwidget (which will be embedded into this widget). | |
| virtual bool | ProcessEvent (const SDL_Event *event, bool bModal=false) |
| Process a native PG_ event. | |
| void | SetID (int id) |
| Set the widgetid. | |
| int | GetID () |
| Return the widgetid. | |
| PG_Widget * | FindChild (int id, bool recursive=false) |
| Find a child that is identified by the given ID. | |
| PG_Widget * | FindChild (const std::string &name, bool recursive=false) |
| Find a child that is identified by the given name. | |
| bool | IsMouseInside () |
| Check if the mousepointer is currently inside the widget. | |
| bool | Redraw (bool update=true) |
| Redraw the widget and all embedded child widgets. | |
| virtual void | Blit (bool recursive=true, bool restore=true) |
| Blit the widget to the screen. | |
| void | Update (bool doBlit=true) |
| Update the widget's screen area. | |
| virtual void | Show (bool fade=false) |
| Make a widget visible (if you want a widget to show up the first time, use this method). | |
| virtual void | Hide (bool fade=false) |
| Hide a widget. | |
| bool | IsInFrontOf (PG_Widget *) |
| Check if the widget is in front of another one. | |
| void | SendToBack () |
| Send the widget back to the end of the list. | |
| void | BringToFront () |
| Reorder the widget in front of all others. | |
| PG_Widget * | GetToplevelWidget () |
| Get the toplevel widget. | |
| void | RecalcClipRect () |
| virtual bool | RestoreBackground (PG_Rect *clip=NULL, bool force=false) |
| Restore the background (all widgets behind this one). | |
| void | SetVisible (bool visible) |
| Set the visiblility of a widget with updating the screen contents. | |
| void | SetFadeSteps (int steps) |
| Set the number of steps for fading in/out widgets. | |
| void | SetChildTransparency (Uint8 t) |
| Set the transparency of all child widgets. | |
| PG_RectList * | GetChildList () |
| Get a list of child widgets. | |
| int | GetChildCount () |
| Get the number of childwidgets. | |
| void | MoveRect (int x, int y) |
| virtual bool | Action (KeyAction action) |
| void | SetName (const std::string &name) |
| Set the name for the widget. | |
| const std::string & | GetName () |
| Get the name for the widget. | |
| bool | LoadLayout (const std::string &name) |
| Load layout from the XML file to the current widget. | |
| bool | LoadLayout (const std::string &name, void(*WorkCallback)(int now, int max)) |
| Load layout from the XML file to the current widget. | |
| bool | LoadLayout (const std::string &name, void(*WorkCallback)(int now, int max), void *UserSpace) |
| Load layout from the XML file to the current widget. | |
| void | RemoveAllChilds () |
| Removes all childs. | |
| void | SetUserData (void *userdata, int size) |
| Sets user data to the widget (malloc inside). | |
| virtual int | GetUserDataSize () |
| Sets user data to the widget (malloc inside). | |
| virtual void | GetUserData (void *userdata) |
| Gets user data from the widget. | |
| void | ReleaseUserData () |
| Releases user data. | |
| virtual bool | RemoveChild (PG_Widget *child) |
| virtual void | SetText (const std::string &text) |
| Sets text. | |
| void | AddText (const std::string &text, bool update=false) |
| Adds text. | |
| virtual void | SetTextFormat (const char *text,...) |
| Sets formated text. | |
| virtual const PG_String & | GetText () |
| Returns text. | |
| void | GetTextSize (Uint16 &w, Uint16 &h, const std::string &text=PG_NULLSTR) |
| int | GetTextWidth () |
| int | GetTextHeight () |
| int | GetFontAscender () |
| int | GetFontHeight () |
| PG_Color | GetFontColor () |
| Return the current text color. | |
| PG_Color | GetFontHighlightColor () |
| void | SetFontColor (const PG_Color &Color, bool bRecursive=false) |
| Set font color. | |
| void | SetFontHighlightColor (const PG_Color &Color, bool bRecursive=false) |
| void | SetFontAlpha (int Alpha, bool bRecursive=false) |
| Set font transparency (!!!). | |
| void | SetFontStyle (PG_Font::Style Style, bool bRecursive=false) |
| Set font style. | |
| void | SetFontSize (int Size, bool bRecursive=false) |
| Set font size. | |
| void | SetFontIndex (int Index, bool bRecursive=false) |
| Set font index. | |
| void | SetFontName (const std::string &Name, bool bRecursive=false) |
| Set font name. | |
| void | SetSizeByText (int Width=0, int Height=0, const std::string &Text=PG_NULLSTR) |
| Set widget size by size of text (should be used before Show() or AddWidget()). | |
| int | GetFontSize () |
| Get the size of the font. | |
| PG_Font * | GetFont () |
| Get the current font parameters. | |
| void | SetFont (PG_Font *font) |
| Set the current font parameters. | |
| void | DrawText (const PG_Rect &rect, const PG_String &text) |
| Render text inside the widget. | |
| void | DrawText (int x, int y, const PG_String &text) |
| Render text inside the widget. | |
| void | DrawText (int x, int y, const PG_String &text, const PG_Rect &cliprect) |
| Render text inside the widget and clip to a given clipping rectangle. | |
| void | DrawText (const PG_Rect &rect, const PG_String &text, const PG_Color &c) |
| Render text inside the widget and set the font color. | |
| void | DrawText (int x, int y, const PG_String &text, const PG_Color &c) |
| Render text inside the widget and set the font color. | |
| void | DrawBorder (const PG_Rect &r, int size, bool up=true) |
| virtual void | SetTransparency (Uint8 t, bool bRecursive=false) |
| Set the transparency of the drawing object. | |
| Uint8 | GetTransparency () |
| Get the transparency of the drawing object. | |
| void | SetClipRect (const PG_Rect &r) |
| Set the clipping rectangle for the object. | |
| PG_Rect * | GetClipRect () |
| Get the current clipping rectangle. | |
| bool | IsClippingEnabled () |
| Check if there is a clipping rectangle assigned to the object. | |
| void | GetClipRects (PG_Rect &src, PG_Rect &dst) |
| void | GetClipRects (PG_Rect &src, PG_Rect &dst, const PG_Rect &displayrect) |
| void | SetPixel (int x, int y, const PG_Color &c) |
| void | DrawHLine (int x, int y, int w, const PG_Color &c) |
| void | DrawVLine (int x, int y, int h, const PG_Color &c) |
| void | DrawRectWH (int x, int y, int w, int h, const PG_Color &c) |
| void | DrawLine (Uint32 x0, Uint32 y0, Uint32 x1, Uint32 y1, const PG_Color &color, Uint8 width=1) |
| virtual int | RunModal () |
| Enter modal mode. | |
| bool | QuitModal () |
| Quit modal mode. | |
| bool | WillQuitModal () |
| void | StopQuitModal () |
| void | SetDirtyUpdate (bool bDirtyUpdate) |
| Set the dirty update mode. | |
| void | UpdateOverlappingSiblings (bool enable, bool recursive=true) |
| Set the sibling update mode. | |
| bool | GetDirtyUpdate () |
| return if the dirty update mode is enabled | |
| virtual void | eventMouseLeave () |
| eventhandler for mouse movements. | |
| virtual void | eventMouseEnter () |
| eventhandler for mouse movements. | |
| void | SetHidden (bool hidden) |
| bool | IsHidden () |
| void | SetModalStatus (int status) |
| Set the return status of the modal eventloop. | |
| void | EnableReceiver (bool enable, bool bRecursive=false) |
| void | SetParent (PG_Widget *parent) |
| change the parent of the widget. | |
| void | SetBorderSize (int b) |
| Set the bordersize of the widget. | |
| int | GetBorderSize () |
| Get the bordersize of the widget. | |
| void | activateHotkey (int keymodifier) |
| enables hotkey listening for the widget. Keymodifier is a bitmap of SDLMod values that must be pressed for the hotkey | |
| int | getHotkeyModifier () |
Static Public Member Functions | |
| static void | UpdateRect (const PG_Rect &r) |
| Update a screen area. | |
| static void | UpdateScreen () |
| Update (render) the whole application screen. | |
| static void | HideAll () |
| Hide all widgets of an application. | |
| static PG_Widget * | FindWidgetFromPos (int x, int y) |
| static void | BulkBlit () |
| static PG_RectList * | GetWidgetList () |
| Get a list of all toplevel widgets. | |
| static void | GetTextSize (Uint16 &w, Uint16 &h, const PG_String &text, PG_Font *font) |
Public Attributes | |
| SignalMouseEnter | sigMouseEnter |
| SignalMouseLeave | sigMouseLeave |
Protected Member Functions | |
| virtual void | eventMoveWidget (int x, int y) |
| Callback for the MoveWidget event. | |
| virtual void | eventSizeWidget (Uint16 w, Uint16 h) |
| Callback for the SizeWidget event. | |
| virtual void | eventDraw (SDL_Surface *surface, const PG_Rect &rect) |
| overridable eventhandler to draw the object surface | |
| virtual void | eventBlit (SDL_Surface *surface, const PG_Rect &src, const PG_Rect &dst) |
| overridable eventhandler to blit the widget contents to the screen | |
| virtual void | eventShow () |
| overridable eventhandler called whenever the widget gets shown. | |
| virtual void | eventHide () |
| overridable eventhandler called whenever the widget gets hidden. | |
| virtual bool | eventQuitModal (int id, PG_MessageObject *widget, unsigned long data) |
| overridable eventhandler called when leaving a modal eventloop | |
| void | FadeOut () |
| void | FadeIn () |
| bool | AcceptEvent (const SDL_Event *event) |
| Check if we can accept the event. | |
| void | RemoveFromWidgetList () |
| void | AddToWidgetList () |
| PG_Char | extractHotkey (const std::string &s) |
| bool | extractAndStoreHotkey (const std::string &s) |
| bool | checkForHotkey (const SDL_KeyboardEvent *key) |
Static Protected Member Functions | |
| static bool | RenderText (SDL_Surface *Surface, const PG_Rect &ClipRect, int BaseLineX, int BaseLineY, const PG_String &Text, PG_Font *ParamIn) |
Protected Attributes | |
| SDL_Surface * | my_srfObject |
| pointer to the widgets drawing surface or NULL | |
| PG_String | my_text |
| text attached to the widget | |
| PG_Color | my_colorBorder [2][2] |
| array of border colors | |
| int | my_bordersize |
Classes | |
| class | SignalMouseEnter |
| class | SignalMouseLeave |
This class provides themeing capabilities only for subclassed widgets.
widget type: none (managed through subclass)
object name: none (managed through subclass)
<widget>
<type value="xxx"/>
<object>
<name value="xxx"/>
<property color="textcolor" value="0x00FFFFFF"/>
<property color="bordercolor0" value="0x00202020"/>
<property color="bordercolor1" value="0x00E0E0E0"/>
<property color="bordercolor0i" value="0x00202020"/>
<property color="bordercolor1i" value="0x00E0E0E0"/>
</object>
</widget>
Definition at line 81 of file pgwidget.h.
|
|
Keyevent actions.
Definition at line 86 of file pgwidget.h. |
|
||||||||||||||||
|
Creates a PG_Widget with an internal object surface.
Definition at line 89 of file pgwidget.cpp. References AddChild(), AddToWidgetList(), PG_Draw::CreateRGBSurface(), PG_Application::DefaultFont, PG_WidgetDataInternal::font, GetName(), PG_WidgetDataInternal::havesurface, my_colorBorder, my_srfObject, PG_WidgetDataInternal::name, and PG_LogWRN(). Referenced by TextRenderer::addAbsPosition(), TextRenderer::addIndentation(), and TextRenderer::layout(). |
|
|
Destroys a PG_Widget. This is the destructor for the PG_Widget class Definition at line 159 of file pgwidget.cpp. References PG_WidgetDataInternal::childList, PG_WidgetDataInternal::font, GetParent(), PG_WidgetDataInternal::havesurface, Hide(), PG_WidgetDataInternal::inDestruct, my_srfObject, PG_LogWRN(), RemoveAllChilds(), RemoveFromWidgetList(), PG_FileArchive::UnloadSurface(), and PG_WidgetDataInternal::userdata. |
|
|
Check if we can accept the event.
Reimplemented from PG_MessageObject. Definition at line 210 of file pgwidget.cpp. References eventMouseEnter(), eventMouseLeave(), IsHidden(), IsVisible(), PG_WidgetDataInternal::mouseInside, PG_Rect::my_height, PG_Rect::my_width, PG_Rect::my_xpos, PG_Rect::my_ypos, and PG_WidgetDataInternal::rectClip. |
|
|
Reimplemented in PG_LineEdit. Definition at line 996 of file pgwidget.cpp. References ACT_ACTIVATE, ACT_DEACTIVATE, ACT_OK, PG_MessageObject::eventMouseButtonDown(), PG_MessageObject::eventMouseButtonUp(), eventMouseEnter(), eventMouseLeave(), PG_Rect::my_height, PG_Rect::my_width, PG_Rect::my_xpos, and PG_Rect::my_ypos. Referenced by PG_Navigator::Action(), and PG_LineEdit::Action(). |
|
|
enables hotkey listening for the widget. Keymodifier is a bitmap of SDLMod values that must be pressed for the hotkey
Definition at line 1930 of file pgwidget.cpp. References PG_MessageObject::eventKeyDown(), PG_Application::GetApp(), and PG_WidgetDataInternal::hotkeyModifier. Referenced by Menu::Menu(), MessageDialog::MessageDialog(), and ViewTextQuery::ViewTextQuery(). |
|
|
Add a clientwidget (which will be embedded into this widget).
Reimplemented in PG_DropDown, PG_ListBox, PG_RichEdit, PG_ScrollArea, PG_ScrollWidget, and PG_WidgetList. Definition at line 291 of file pgwidget.cpp. References _mid, PG_RectList::Add(), PG_WidgetDataInternal::childList, GetParent(), MoveRect(), PG_Rect::my_xpos, PG_Rect::my_ypos, RemoveFromWidgetList(), and PG_WidgetDataInternal::widgetParent. Referenced by PG_WidgetList::AddChild(), PG_ScrollWidget::AddChild(), PG_ScrollArea::AddChild(), PG_DropDown::AddChild(), and PG_Widget(). |
|
||||||||||||
|
Adds text.
Definition at line 1216 of file pgwidget.cpp. References GetText(), PG_WidgetDataInternal::heightText, my_text, SetText(), TXT_HEIGHT_UNDEF, and PG_WidgetDataInternal::widthText. Referenced by XMLTextDoc(). |
|
|
Definition at line 202 of file pgwidget.cpp. References PG_RectList::Add(), and GetParent(). Referenced by PG_Widget(). |
|
||||||||||||
|
Blit the widget to the screen.
Definition at line 704 of file pgwidget.cpp. References PG_RectList::Blit(), PG_WidgetDataInternal::childList, eventBlit(), PG_WidgetDataInternal::hidden, my_srfObject, PG_Rect::my_xpos, PG_Rect::my_ypos, RecalcClipRect(), PG_WidgetDataInternal::rectClip, RestoreBackground(), PG_Rect::SetRect(), and PG_WidgetDataInternal::visible. Referenced by PG_RectList::Blit(), FadeIn(), and FadeOut(). |
|
|
Reorder the widget in front of all others.
Definition at line 1148 of file pgwidget.cpp. References PG_RectList::BringToFront(), GetParent(), and Update(). Referenced by ConfigurableWindow::ConfigurableWindow(), UnitInfoPanel::onClick(), Panel::Panel(), SelectFromMap::Show(), and NewGuiHost::showSmallIcons(). |
|
|
Definition at line 872 of file pgwidget.cpp. References PG_RectList::Blit(), and PG_Application::DrawCursor(). |
|
|
Definition at line 1946 of file pgwidget.cpp. References PG_WidgetDataInternal::hotkey, and PG_WidgetDataInternal::hotkeyModifier. Referenced by PG_Button::eventKeyDown(). |
|
||||||||||||
|
Convert a client (widget) coordinate to a screen position.
Definition at line 283 of file pgwidget.cpp. References PG_Rect::my_xpos, and PG_Rect::my_ypos. Referenced by MapDisplayPG::eventBlit(), GraphWidget::eventBlit(), Weathercast::painter(), Weathercast::paintWeatherArea(), and MapDisplayPG::widget2screen(). |
|
||||||||||||||||
|
Definition at line 1584 of file pgwidget.cpp. References DrawHLine(), DrawVLine(), IsVisible(), and my_colorBorder. Referenced by PG_Window::eventBlit(), PG_ThemeWidget::eventBlit(), PG_Button::eventBlit(), and PG_ThemeWidget::eventDraw(). |
|
||||||||||||||||||||
|
Definition at line 1663 of file pgwidget.cpp. References PG_Application::GetScreen(), PG_Application::ScreenLocker::lock(), PG_Color::MapRGB(), my_srfObject, PG_Rect::my_xpos, PG_Rect::my_ypos, PG_MAX, PG_MIN, PG_WidgetDataInternal::rectClip, and PG_Rect::SetRect(). Referenced by DrawBorder(), DrawRectWH(), and PG_ColorSelector::PG_ColorBox::eventBlit(). |
|
||||||||||||||||||||||||||||
|
Definition at line 1749 of file pgwidget.cpp. References PG_Draw::DrawLine(), PG_Application::GetScreen(), my_srfObject, PG_Rect::my_xpos, and PG_Rect::my_ypos. |
|
||||||||||||||||||||||||
|
Definition at line 1740 of file pgwidget.cpp. References DrawHLine(), and DrawVLine(). |
|
||||||||||||||||||||
|
Render text inside the widget and set the font color.
Definition at line 1506 of file pgwidget.cpp. References DrawText(), and PG_Rect::PG_Rect(). |
|
||||||||||||||||
|
Render text inside the widget and set the font color.
Definition at line 1501 of file pgwidget.cpp. References DrawText(), and SetFontColor(). |
|
||||||||||||||||||||
|
Render text inside the widget and clip to a given clipping rectangle.
Definition at line 1488 of file pgwidget.cpp. References PG_WidgetDataInternal::font, GetFontAscender(), PG_Application::GetScreen(), my_srfObject, PG_Rect::my_xpos, PG_Rect::my_ypos, and PG_FontEngine::RenderText(). |
|
||||||||||||||||
|
Render text inside the widget.
Definition at line 1484 of file pgwidget.cpp. References DrawText(), and PG_Rect::PG_Rect(). |
|
||||||||||||
|
Render text inside the widget.
Definition at line 1476 of file pgwidget.cpp. References PG_WidgetDataInternal::font, GetFontAscender(), PG_Application::GetScreen(), PG_Rect::Height(), my_srfObject, PG_Rect::my_xpos, PG_Rect::my_ypos, PG_Rect::PG_Rect(), PG_WidgetDataInternal::rectClip, RenderText(), and PG_Rect::Width(). Referenced by DrawText(), PG_ProgressBar::eventBlit(), PG_PopupMenu::eventBlit(), PG_Label::eventBlit(), PG_ColumnItem::eventBlit(), and PG_Button::eventBlit(). |
|
||||||||||||||||||||
|
Definition at line 1702 of file pgwidget.cpp. References PG_Application::GetScreen(), PG_Application::ScreenLocker::lock(), PG_Color::MapRGB(), my_srfObject, PG_Rect::my_xpos, PG_Rect::my_ypos, PG_MAX, PG_MIN, PG_WidgetDataInternal::rectClip, and PG_Rect::SetRect(). Referenced by DrawBorder(), DrawRectWH(), and PG_ColorSelector::PG_ColorBox::eventBlit(). |
|
||||||||||||
|
Definition at line 1910 of file pgwidget.cpp. References EnableReceiver(), PG_MessageObject::EnableReceiver(), GetChildList(), and PG_Rect::next(). Referenced by EnableReceiver(), PG_RadioButton::PG_RadioButton(), and PG_Window::PG_Window(). |
|
||||||||||||
|
Finishes a drag operation.
Definition at line 848 of file pgwidget.cpp. References PG_WidgetDataInternal::ptDragStart, WidgetDrag(), PG_Point::x, and PG_Point::y. |
|
||||||||||||||||
|
||||||||||||
|
overridable eventhandler to draw the object surface
Reimplemented in ExperienceOverview, DiplomaticModeChooser< SelectionType >, PG_Image, PG_Label, PG_ThemeWidget, and SelectionItemWidget. Definition at line 1763 of file pgwidget.cpp. Referenced by Redraw(). |
|
|
overridable eventhandler called whenever the widget gets hidden.
Reimplemented in PG_DropDown, PG_LineEdit, PG_ListBoxBaseItem, PG_PopupMenu, and LayoutablePanel. Definition at line 280 of file pgwidget.cpp. Referenced by LayoutablePanel::eventHide(), PG_PopupMenu::eventHide(), Hide(), and SetVisible(). |
|
|
eventhandler for mouse movements. This overrideable handler is called everytime the mouse cursor is entering the widget area. Reimplemented in WeaponInfoLine, GuiButton, SmallGuiButton, PG_Button, PG_ListBoxBaseItem, PG_PopupMenu, and PG_RadioButton. Definition at line 257 of file pgwidget.cpp. References sigMouseEnter. Referenced by AcceptEvent(), Action(), PG_RadioButton::eventMouseEnter(), PG_PopupMenu::eventMouseEnter(), PG_Button::eventMouseEnter(), and Show(). |
|
|
eventhandler for mouse movements. This overrideable handler is called everytime the mouse cursor is leaving the widget area. Reimplemented in WeaponInfoLine, GuiButton, SmallGuiButton, PG_Button, PG_ListBoxBaseItem, PG_PopupMenu, and PG_RadioButton. Definition at line 263 of file pgwidget.cpp. References GetParent(), PG_WidgetDataInternal::mouseInside, and sigMouseLeave. Referenced by AcceptEvent(), Action(), PG_RadioButton::eventMouseLeave(), PG_PopupMenu::eventMouseLeave(), PG_ListBoxBaseItem::eventMouseLeave(), PG_Button::eventMouseLeave(), and Hide(). |
|
||||||||||||
|
Callback for the MoveWidget event.
Reimplemented in PG_DropDown, PG_PopupMenu, and LayoutablePanel. Definition at line 1765 of file pgwidget.cpp. Referenced by LayoutablePanel::eventMoveWidget(), PG_PopupMenu::eventMoveWidget(), and MoveRect(). |
|
||||||||||||||||
|
overridable eventhandler called when leaving a modal eventloop
Reimplemented from PG_MessageObject. Definition at line 1550 of file pgwidget.cpp. References PG_WidgetDataInternal::quitModalLoop. Referenced by QuitModal(). |
|