Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

PG_Label Class Reference

Text label. More...

#include <pglabel.h>

Inheritance diagram for PG_Label:

Inheritance graph
[legend]
List of all members.

Public Types

enum  TextAlign { LEFT, CENTER, RIGHT }

Public Member Functions

 PG_Label (PG_Widget *parent, const PG_Rect &r=PG_Rect::null, const std::string &text=PG_NULLSTR, const std::string &style="Label")
 Only constructor.
 ~PG_Label ()
 Only destructor.
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 SetAlignment (TextAlign a)
 Sets text alignment.
SDL_Surface * SetIcon (const std::string &filename)
SDL_Surface * SetIcon (SDL_Surface *icon)
SDL_Surface * GetIcon ()
void SetIndent (Uint16 indent)
 Set the text indentation.
Uint16 GetIndent ()
 Returns the text indentation.
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()).

Protected Member Functions

void eventDraw (SDL_Surface *surface, const PG_Rect &rect)
 Draw event handler.
void eventBlit (SDL_Surface *surface, const PG_Rect &src, const PG_Rect &dst)
 overridable eventhandler to blit the widget contents to the screen

Protected Attributes

SDL_Surface * my_srfIcon

Detailed Description

Text label.

Author:
Alexander Pipelka
A text label (unmodifiable by end user). Has attributes for font style, alignment, etc.

Definition at line 47 of file pglabel.h.


Member Enumeration Documentation

enum PG_Label::TextAlign
 

Enumeration values:
LEFT 
CENTER 
RIGHT 

Definition at line 51 of file pglabel.h.


Constructor & Destructor Documentation

PG_Label::PG_Label PG_Widget parent,
const PG_Rect r = PG_Rect::null,
const std::string &  text = PG_NULLSTR,
const std::string &  style = "Label"
 

Only constructor.

Parameters:
parent Parent widget.
r Rectangle to draw in, relative to parent.
text Text displayed by label.
style initial widget style (from xml theme)

Definition at line 37 of file pglabel.cpp.

References LEFT, LoadThemeStyle(), my_srfIcon, and PG_Widget::SetText().

Referenced by ListBoxImageItem< SelectionType >::ListBoxImageItem().

PG_Label::~PG_Label  ) 
 

Only destructor.

Definition at line 49 of file pglabel.cpp.

References my_srfIcon, and PG_FileArchive::UnloadSurface().


Member Function Documentation

void PG_Label::eventBlit SDL_Surface *  surface,
const PG_Rect src,
const PG_Rect dst
[protected, virtual]
 

overridable eventhandler to blit the widget contents to the screen

Parameters:
surface pointer to SDL_Surface to be blitted
src source rectangle (client coordinates)
dst destination rectangle (screen coordinates) Override this eventhandler to perform custom blitting behaviour (without drawing onto the widget surface).

Reimplemented from PG_Widget.

Reimplemented in PG_ColumnItem, and PG_ListBoxItem.

Definition at line 76 of file pglabel.cpp.

References CENTER, PG_Widget::DrawText(), PG_Widget::eventBlit(), PG_Widget::GetClipRects(), PG_Widget::GetTextSize(), LEFT, PG_Rect::my_height, my_srfIcon, PG_Widget::my_text, PG_Rect::my_width, PG_Rect::my_xpos, PG_Rect::my_ypos, and RIGHT.

Referenced by PG_ListBoxItem::eventBlit().

void PG_Label::eventDraw SDL_Surface *  surface,
const PG_Rect rect
[protected, virtual]
 

Draw event handler.

Parameters:
surface Surface to draw to.
rect Rectangle to draw in, relative to surface.

Reimplemented from PG_Widget.

Definition at line 124 of file pglabel.cpp.

SDL_Surface * PG_Label::GetIcon  ) 
 

Definition at line 156 of file pglabel.cpp.

References my_srfIcon.

Referenced by PG_Window::GetIcon(), and SetSizeByText().

Uint16 PG_Label::GetIndent  ) 
 

Returns the text indentation.

Definition at line 164 of file pglabel.cpp.

Referenced by PG_ListBoxBaseItem::PG_ListBoxBaseItem().

void PG_Label::LoadThemeStyle const std::string &  widgettype,
const std::string &  objectname
[virtual]
 

Load a style from the theme definition.

Parameters:
widgettype name of the widgettype
objectname name of the object
Loads the defined style of a given widgettype and objectname.

Reimplemented from PG_Widget.

Reimplemented in PG_ListBoxItem.

Definition at line 62 of file pglabel.cpp.

References PG_PropStr::alignment, PG_Theme::FindString(), PG_Theme::GetAlignment(), PG_Application::GetTheme(), PG_PropStr::label, PG_Widget::LoadThemeStyle(), and PG_Widget::SetText().

void PG_Label::LoadThemeStyle const std::string &  widgettype  ) 
 

Load a style from the theme definition.

Parameters:
widgettype name of the widgettype
Loads the defined style for a given widgettype

Reimplemented from PG_Widget.

Definition at line 55 of file pglabel.cpp.

References PG_PropStr::Label.

Referenced by PG_RadioButton::LoadThemeStyle(), PG_Label(), and PG_PropertyEditor::RegisterProperty().

void PG_Label::SetAlignment TextAlign  a  ) 
 

Sets text alignment.

Definition at line 126 of file pglabel.cpp.

References PG_Widget::Update().

Referenced by ASCGUI_Window::WidgetParameters::assign(), BuildingTypeCountWidget::BuildingTypeCountWidget(), BuildingTypeResourceWidget::BuildingTypeResourceWidget(), CopyMap::CopyMap(), InternalAmmoTransferWidget::InternalAmmoTransferWidget(), PG_ListBoxBaseItem::PG_ListBoxBaseItem(), PG_Window::PG_Window(), PG_RadioButton::SetAlignment(), SetLabelAtts(), PG_Window::SetTitle(), StartupScreen::StartupScreen(), TransferWidget::TransferWidget(), VehicleTypeCountWidget::VehicleTypeCountWidget(), and VehicleTypeResourceWidget::VehicleTypeResourceWidget().

SDL_Surface * PG_Label::SetIcon SDL_Surface *  icon  ) 
 

Definition at line 131 of file pglabel.cpp.

References my_srfIcon, PG_FileArchive::UnloadSurface(), and PG_Widget::Update().

SDL_Surface * PG_Label::SetIcon const std::string &  filename  ) 
 

Definition at line 144 of file pglabel.cpp.

References PG_FileArchive::LoadSurface(), my_srfIcon, PG_FileArchive::UnloadSurface(), and PG_Widget::Update().

Referenced by PG_Window::SetIcon(), and SetLabelAtts().

void PG_Label::SetIndent Uint16  indent  ) 
 

Set the text indentation.

Parameters:
indent number of pixels for text indentation

Definition at line 160 of file pglabel.cpp.

Referenced by PG_ListBoxBaseItem::PG_ListBoxBaseItem(), PG_ListBox::SetIndent(), and SetLabelAtts().

void PG_Label::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()).

Parameters:
Width Value witch is added to text width (default = 0)
Height Value witch is added to text height (default = 0)
Text Text to get size from, if NULL my_text is used

Reimplemented from PG_Widget.

Definition at line 168 of file pglabel.cpp.

References PG_Widget::GetFont(), GetIcon(), PG_FontEngine::GetTextSize(), PG_Rect::my_height, PG_Widget::my_text, PG_Rect::my_width, PG_MAX, PG_String, and PG_Widget::SetSizeByText().

Referenced by AddWeatherAreaDialog::AddWeatherAreaDialog(), AddWindChangeDialog::AddWindChangeDialog(), ChanceSettingsDialog::buildUpForm(), ChangePasswordDialog::ChangePasswordDialog(), ResourcePlacementDialog::ResourcePlacementDialog(), SaveGameBaseDialog::SaveGameBaseDialog(), PG_RadioButton::SetSizeByText(), WeatherDialog::WeatherDialog(), and WeatherPanel::WeatherPanel().


Member Data Documentation

SDL_Surface* PG_Label::my_srfIcon [protected]
 

Definition at line 107 of file pglabel.h.

Referenced by eventBlit(), PG_ColumnItem::eventBlit(), GetIcon(), PG_Label(), PG_ListBoxItem::PG_ListBoxItem(), SetIcon(), and ~PG_Label().


The documentation for this class was generated from the following files:
Generated on Tue Jun 24 02:18:56 2008 for Advanced Strategic Command by  doxygen 1.4.2