ManaPlus
Public Member Functions | Static Public Member Functions | Static Public Attributes | Private Attributes

#include <label.h>

Inheritance diagram for Label:
Widget WidgetListener ToolTipListener Widget2 MouseListener

Public Member Functions

 Label (const Widget2 *const widget)
 
 Label (const Widget2 *const widget, const std::string &caption)
 
 ~Label ()
 
void init ()
 
void draw (Graphics *const graphics)
 
void safeDraw (Graphics *const graphics)
 
void adjustSize ()
 
void setForegroundColor (const Color &color)
 
void setForegroundColorAll (const Color &color1, const Color &color2)
 
void resizeTo (const int maxSize, const int minSize)
 
const std::string & getCaption () const
 
void setCaption (const std::string &caption)
 
void setAlignment (Graphics::Alignment alignment)
 
Graphics::Alignment getAlignment () const
 
void setParent (Widget *const widget)
 
void setWindow (Widget *const widget)
 
void widgetHidden (const Event &event)
 
- Public Member Functions inherited from Widget
 Widget (const Widget2 *const widget)
 
 ~Widget ()
 
virtual void drawFrame (Graphics *graphics)
 
virtual void safeDrawFrame (Graphics *graphics)
 
void setFrameSize (const unsigned int frameSize)
 
unsigned int getFrameSize () const
 
virtual void logic ()
 
WidgetgetParent () const
 
void setWidth (const int width)
 
int getWidth () const
 
void setHeight (const int height)
 
int getHeight () const
 
void setSize (const int width, const int height)
 
void setX (const int x)
 
int getX () const
 
void setY (const int y)
 
int getY () const
 
void setPosition (const int x, const int y)
 
void setDimension (const Rect &dimension)
 
const RectgetDimension () const
 
void setFocusable (const bool focusable)
 
bool isFocusable () const
 
virtual bool isFocused () const
 
void setEnabled (const bool enabled)
 
bool isEnabled () const
 
void setVisible (Visible visible)
 
bool isVisible () const
 
void setBaseColor (const Color &color)
 
const ColorgetBaseColor () const
 
void setForegroundColor (const Color &color)
 
const ColorgetForegroundColor () const
 
void setBackgroundColor (const Color &color)
 
const ColorgetBackgroundColor () const
 
virtual void requestFocus ()
 
virtual void requestMoveToTop ()
 
virtual void requestMoveToBottom ()
 
virtual void setFocusHandler (FocusHandler *const focusHandler)
 
FocusHandlergetFocusHandler ()
 
void addActionListener (ActionListener *const actionListener)
 
void removeActionListener (ActionListener *const actionListener)
 
void addDeathListener (WidgetDeathListener *const deathListener)
 
void removeDeathListener (WidgetDeathListener *const deathListener)
 
void addMouseListener (MouseListener *const mouseListener)
 
void removeMouseListener (MouseListener *const mouseListener)
 
void addKeyListener (KeyListener *const keyListener)
 
void removeKeyListener (KeyListener *const keyListener)
 
void addFocusListener (FocusListener *const focusListener)
 
void removeFocusListener (FocusListener *const focusListener)
 
void addWidgetListener (WidgetListener *const widgetListener)
 
void removeWidgetListener (WidgetListener *const widgetListener)
 
void setActionEventId (const std::string &actionEventId)
 
const std::string & getActionEventId () const
 
virtual void getAbsolutePosition (int &x, int &y) const
 
FontgetFont () const
 
void setFont (Font *const font)
 
virtual void fontChanged ()
 
bool isTabInEnabled () const
 
void setTabInEnabled (const bool enabled)
 
bool isTabOutEnabled () const
 
void setTabOutEnabled (const bool enabled)
 
void requestModalFocus ()
 
virtual void requestModalMouseInputFocus ()
 
virtual void releaseModalFocus ()
 
virtual void releaseModalMouseInputFocus ()
 
virtual bool isModalFocused () const
 
virtual bool isModalMouseInputFocused () const
 
virtual WidgetgetWidgetAt (int x, int y)
 
const std::list< MouseListener * > & getMouseListeners () const A_CONST
 
const std::list< KeyListener * > & getKeyListeners () const A_CONST
 
const std::list< FocusListener * > & getFocusListeners () const A_CONST
 
virtual Rect getChildrenArea ()
 
virtual FocusHandlergetInternalFocusHandler ()
 
void setInternalFocusHandler (FocusHandler *const internalFocusHandler)
 
virtual void moveToTop (Widget *widget)
 
virtual void moveToBottom (Widget *widget)
 
virtual void focusNext ()
 
virtual void focusPrevious ()
 
virtual void showWidgetPart (Widget *const widget, const Rect &area)
 
void setId (const std::string &id)
 
const std::string & getId () const
 
virtual void showPart (const Rect &rectangle)
 
bool isAllowLogic () const
 
void setMouseConsume (const bool b)
 
bool isMouseConsume () const
 
void setRedraw (const bool b)
 
virtual bool isSelectable () const
 
void setSelectable (const bool selectable)
 
void windowResized ()
 
virtual void postInit ()
 
- Public Member Functions inherited from Widget2
virtual ~Widget2 ()
 
const ColorgetThemeColor (const ThemeColorIdT type, const unsigned int alpha) const A_INLINE
 
const ColorgetThemeCharColor (const signed char c, bool &valid) const A_INLINE
 
virtual void setWidget2 (const Widget2 *const widget)
 
void setPalette (int palette)
 
void checkPalette ()
 
void setForegroundColor2 (const Color &color)
 
WidgetgetWindow () const
 
- Public Member Functions inherited from WidgetListener
virtual ~WidgetListener ()
 
virtual void widgetResized (const Event &event)
 
virtual void widgetMoved (const Event &event)
 
virtual void widgetShown (const Event &event)
 
- Public Member Functions inherited from ToolTipListener
 ToolTipListener ()
 
void setToolTip (const std::string &str)
 
std::string getToolTip () const
 
void mouseMoved (MouseEvent &event)
 
void mouseExited (MouseEvent &event)
 
- Public Member Functions inherited from MouseListener
virtual ~MouseListener ()
 
virtual void mouseEntered (MouseEvent &event)
 
virtual void mousePressed (MouseEvent &event)
 
virtual void mouseReleased (MouseEvent &event)
 
virtual void mouseClicked (MouseEvent &event)
 
virtual void mouseWheelMovedUp (MouseEvent &event)
 
virtual void mouseWheelMovedDown (MouseEvent &event)
 
virtual void mouseDragged (MouseEvent &event)
 

Static Public Member Functions

static void finalCleanup ()
 
- Static Public Member Functions inherited from Widget
static void setGlobalFont (Font *const font)
 
static FontgetGloablFont ()
 
static void cleanGlobalFont ()
 
static bool widgetExists (const Widget *const widget)
 
static void distributeWindowResizeEvent ()
 
static WidgetcallPostInit (Widget *const widget)
 

Static Public Attributes

static SkinmSkin = 0
 
static int mInstances = 0
 

Private Attributes

std::string mCaption
 
TextChunk mTextChunk
 
Graphics::Alignment mAlignment
 
int mPadding
 
bool mTextChanged
 

Additional Inherited Members

- Data Fields inherited from Widget
Visible mVisible
 
- Protected Types inherited from Widget
typedef std::list< MouseListener * > MouseListenerList
 
typedef MouseListenerList::iterator MouseListenerIterator
 
typedef std::list< KeyListener * > KeyListenerList
 
typedef KeyListenerList::iterator KeyListenerIterator
 
typedef std::list< ActionListener * > ActionListenerList
 
typedef ActionListenerList::iterator ActionListenerIterator
 
typedef std::list< WidgetDeathListener * > WidgetDeathListenerList
 
typedef WidgetDeathListenerList::iterator WidgetDeathListenerIterator
 
typedef std::list< FocusListener * > FocusListenerList
 
typedef FocusListenerList::iterator FocusListenerIterator
 
typedef std::list< WidgetListener * > WidgetListenerList
 
typedef WidgetListenerList::iterator WidgetListenerIterator
 
- Protected Member Functions inherited from Widget
void distributeActionEvent ()
 
void distributeResizedEvent ()
 
void distributeMovedEvent ()
 
void distributeHiddenEvent ()
 
void distributeShownEvent ()
 
- Protected Member Functions inherited from Widget2
 Widget2 (const Widget2 *const widget)
 
- Protected Member Functions inherited from WidgetListener
 WidgetListener ()
 
- Protected Member Functions inherited from MouseListener
 MouseListener ()
 
- Protected Attributes inherited from Widget
MouseListenerList mMouseListeners
 
KeyListenerList mKeyListeners
 
ActionListenerList mActionListeners
 
WidgetDeathListenerList mDeathListeners
 
FocusListenerList mFocusListeners
 
WidgetListenerList mWidgetListeners
 
Color mForegroundColor
 
Color mBackgroundColor
 
Color mBaseColor
 
Rect mDimension
 
std::string mActionEventId
 
std::string mId
 
FocusHandlermFocusHandler
 
FocusHandlermInternalFocusHandler
 
WidgetmParent
 
FontmCurrentFont
 
unsigned int mFrameSize
 
bool mFocusable
 
bool mTabIn
 
bool mTabOut
 
bool mEnabled
 
bool mAllowLogic
 
bool mMouseConsume
 
bool mRedraw
 
bool mSelectable
 
- Protected Attributes inherited from Widget2
int mPaletteOffset
 
WidgetmWindow
 
Color mForegroundColor2
 
- Protected Attributes inherited from ToolTipListener
std::string mToolTip
 
- Static Protected Attributes inherited from Widget
static FontmGlobalFont = 0
 

Detailed Description

Label widget. Same as the Guichan label but modified to use the palette system.

Definition at line 87 of file label.h.

Constructor & Destructor Documentation

◆ Label() [1/2]

Label::Label ( const Widget2 *const  widget)
explicit

Constructor.

Definition at line 77 of file label.cpp.

References init().

77  :
78  Widget(widget),
81  mCaption(),
82  mTextChunk(),
84  mPadding(0),
85  mTextChanged(true)
86 {
87  init();
88 }
TextChunk mTextChunk
Definition: label.h:183
std::string mCaption
Definition: label.h:181
void init()
Definition: label.cpp:125
bool mTextChanged
Definition: label.h:192
int mPadding
Definition: label.h:190
Widget(const Widget2 *const widget)
Definition: widget.cpp:84
Graphics::Alignment mAlignment
Definition: label.h:188

◆ Label() [2/2]

Label::Label ( const Widget2 *const  widget,
const std::string &  caption 
)

Constructor. This version of the constructor sets the label with an inintialization string.

Definition at line 90 of file label.cpp.

References ServerCommandType::font, Widget::getFont(), Font::getHeight(), Font::getWidth(), init(), Widget::setHeight(), and Widget::setWidth().

91  :
92  Widget(widget),
95  mCaption(caption),
96  mTextChunk(),
98  mPadding(0),
99  mTextChanged(true)
100 {
101  const Font *const font = getFont();
102  setWidth(font->getWidth(caption));
103  setHeight(font->getHeight());
104  init();
105 }
Font * getFont() const
Definition: widget.cpp:330
void setWidth(const int width)
Definition: widget.cpp:132
Definition: font.h:88
TextChunk mTextChunk
Definition: label.h:183
std::string mCaption
Definition: label.h:181
void init()
Definition: label.cpp:125
bool mTextChanged
Definition: label.h:192
int mPadding
Definition: label.h:190
Widget(const Widget2 *const widget)
Definition: widget.cpp:84
void setHeight(const int height)
Definition: widget.cpp:139
Graphics::Alignment mAlignment
Definition: label.h:188
int getWidth(const std::string &text) const
Definition: font.cpp:333
int getHeight() const
Definition: font.cpp:361

◆ ~Label()

Label::~Label ( )

Definition at line 107 of file label.cpp.

References TextChunk::deleteImage(), gui, mInstances, mSkin, mTextChunk, Widget2::mWindow, Gui::removeDragged(), Widget::removeMouseListener(), Widget::removeWidgetListener(), theme, and Theme::unload().

108 {
109  if (mWindow != nullptr)
111 
112  if (gui != nullptr)
113  gui->removeDragged(this);
114 
115  mInstances --;
116  if (mInstances == 0)
117  {
118  if (theme != nullptr)
119  theme->unload(mSkin);
120  }
121  removeMouseListener(this);
123 }
void unload(Skin *const skin)
Definition: theme.cpp:249
Gui * gui
Definition: gui.cpp:110
static int mInstances
Definition: label.h:173
TextChunk mTextChunk
Definition: label.h:183
void removeMouseListener(MouseListener *const mouseListener)
Definition: widget.cpp:296
Widget * mWindow
Definition: widget2.h:111
Theme * theme
Definition: theme.cpp:61
void removeDragged(const Widget *const widget)
Definition: gui.cpp:1161
void removeWidgetListener(WidgetListener *const widgetListener)
Definition: widget.cpp:306
void deleteImage()
Definition: textchunk.cpp:192
static Skin * mSkin
Definition: label.h:171

Member Function Documentation

◆ adjustSize()

void Label::adjustSize ( )

Definition at line 197 of file label.cpp.

References ServerCommandType::font, Widget::getFont(), Font::getHeight(), Font::getWidth(), mCaption, mPadding, Widget::setHeight(), and Widget::setWidth().

Referenced by StatsPageBasic::attributeChanged(), StatusWindow::attributeChanged(), BankWindow::BankWindow(), CharacterDisplay::CharacterDisplay(), CharacterViewSmall::CharacterViewSmall(), SetupQuickItem::createControls(), BuyDialog::init(), TargetDebugTab::logic(), MapDebugTab::logic(), UpdaterWindow::logic(), LoginDialog::LoginDialog(), SpeechBubble::setCaption(), Tab::setCaption(), SpellPopup::setItem(), ItemPopup::setItem(), Tab::setLabelFont(), StatusPopup::setLabelText(), TradeWindow::setMoney(), CharacterViewSmall::show(), BeingPopup::show(), SkillPopup::show(), TextPopup::show(), StatDebugTab::StatDebugTab(), StatsPageBasic::StatsPageBasic(), StatusWindow::StatusWindow(), SetupQuickItem::toWidget(), KillStats::update(), SkillDialog::update(), StatsClanTab::updateClan(), RelationClanTab::updateClan(), SocialWindow::updateCounter(), SliderList::updateLabel(), StatusWindow::updateLevelLabel(), and CharCreateDialog::updateSliders().

198 {
199  const Font *const font = getFont();
200  const int pad2 = 2 * mPadding;
201  setWidth(font->getWidth(mCaption) + pad2);
202  setHeight(font->getHeight() + pad2);
203 }
Font * getFont() const
Definition: widget.cpp:330
void setWidth(const int width)
Definition: widget.cpp:132
Definition: font.h:88
std::string mCaption
Definition: label.h:181
int mPadding
Definition: label.h:190
void setHeight(const int height)
Definition: widget.cpp:139
int getWidth(const std::string &text) const
Definition: font.cpp:333
int getHeight() const
Definition: font.cpp:361

◆ draw()

void Label::draw ( Graphics *const  graphics)
virtual

Draws the label.

Implements Widget.

Definition at line 150 of file label.cpp.

References BLOCK_END, BLOCK_START, Graphics::CENTER, TextChunk::color, TextChunk::color2, TextChunk::deleteImage(), Graphics::drawImage(), ServerCommandType::font, Font::generate(), Widget::getFont(), Font::getHeight(), Font::getWidth(), Rect::height, TextChunk::img, Graphics::LEFT, mAlignment, mCaption, Widget::mDimension, Widget::mForegroundColor, Widget2::mForegroundColor2, mPadding, mTextChanged, mTextChunk, Graphics::RIGHT, TextChunk::text, TextChunk::textFont, and Rect::width.

Referenced by safeDraw().

151 {
152  BLOCK_START("Label::draw")
153  int textX;
154  const Rect &rect = mDimension;
155  const int textY = rect.height / 2 - getFont()->getHeight() / 2;
156  Font *const font = getFont();
157 
158  switch (mAlignment)
159  {
160  case Graphics::LEFT:
161  default:
162  textX = mPadding;
163  break;
164  case Graphics::CENTER:
165  textX = (rect.width - font->getWidth(mCaption)) / 2;
166  break;
167  case Graphics::RIGHT:
168  if (rect.width > mPadding)
169  textX = rect.width - mPadding - font->getWidth(mCaption);
170  else
171  textX = 0;
172  break;
173  }
174 
175  if (mTextChanged)
176  {
182  font->generate(mTextChunk);
183  mTextChanged = false;
184  }
185 
186  const Image *const image = mTextChunk.img;
187  if (image != nullptr)
188  graphics->drawImage(image, textX, textY);
189  BLOCK_END("Label::draw")
190 }
Font * getFont() const
Definition: widget.cpp:330
std::string text
Definition: textchunk.h:64
Definition: font.h:88
TextChunk mTextChunk
Definition: label.h:183
Definition: rect.h:72
#define BLOCK_START(name)
Definition: perfomance.h:78
#define BLOCK_END(name)
Definition: perfomance.h:79
Color mForegroundColor
Definition: widget.h:1085
std::string mCaption
Definition: label.h:181
Font * textFont
Definition: textchunk.h:63
bool mTextChanged
Definition: label.h:192
int mPadding
Definition: label.h:190
Graphics::Alignment mAlignment
Definition: label.h:188
Color mForegroundColor2
Definition: widget2.h:112
Image * img
Definition: textchunk.h:62
virtual void drawImage(const Image *const image, int dstX, int dstY)=0
Definition: image.h:61
int getHeight() const
Definition: widget.h:239
Color color
Definition: textchunk.h:65
void deleteImage()
Definition: textchunk.cpp:192
Color color2
Definition: textchunk.h:66
Rect mDimension
Definition: widget.h:1100

◆ finalCleanup()

void Label::finalCleanup ( )
static

Definition at line 294 of file label.cpp.

References mSkin.

Referenced by Gui::~Gui().

295 {
296  mSkin = nullptr;
297 }
static Skin * mSkin
Definition: label.h:171

◆ getAlignment()

Graphics::Alignment Label::getAlignment ( ) const
inline

Gets the alignment of the caption. The alignment is relative to the center of the label.

Returns
The alignment of caption of the label.
See also
setAlignmentm Graphics

Definition at line 162 of file label.h.

References mAlignment, setParent(), setWindow(), and widgetHidden().

163  { return mAlignment; }
Graphics::Alignment mAlignment
Definition: label.h:188

◆ getCaption()

const std::string& Label::getCaption ( ) const
inline

Gets the caption of the label.

Returns
The caption of the label.
See also
setCaption

Definition at line 132 of file label.h.

References mCaption, and setCaption().

Referenced by Tab::getCaption(), AttrDisplay::getValue(), UpdaterWindow::logic(), CharacterDisplay::mouseMoved(), SpellPopup::setItem(), and BeingPopup::show().

133  { return mCaption; }
std::string mCaption
Definition: label.h:181

◆ init()

void Label::init ( )

Definition at line 125 of file label.cpp.

References Widget::addMouseListener(), Skin::getPadding(), Widget2::getThemeColor(), Theme::getThemePath(), ThemeColorId::LABEL, ThemeColorId::LABEL_OUTLINE, Theme::load(), Widget::mAllowLogic, Widget::mForegroundColor, Widget2::mForegroundColor2, mInstances, mPadding, mSkin, Widget::setSelectable(), and theme.

Referenced by Label().

126 {
127  addMouseListener(this);
128  mAllowLogic = false;
131  if (mInstances == 0)
132  {
133  if (theme != nullptr)
134  {
135  mSkin = theme->load("label.xml",
136  "",
137  true,
139  }
140  }
141  mInstances ++;
142 
143  if (mSkin != nullptr)
145  else
146  mPadding = 0;
147  setSelectable(false);
148 }
static int mInstances
Definition: label.h:173
static std::string getThemePath()
Definition: theme.h:66
Skin * load(const std::string &filename, const std::string &filename2, const bool full, const std::string &defaultPath)
Definition: theme.cpp:178
Color mForegroundColor
Definition: widget.h:1085
void setSelectable(const bool selectable)
Definition: widget.h:947
int getPadding() const
Definition: skin.h:99
int mPadding
Definition: label.h:190
bool mAllowLogic
Definition: widget.h:1159
void addMouseListener(MouseListener *const mouseListener)
Definition: widget.cpp:291
Theme * theme
Definition: theme.cpp:61
Color mForegroundColor2
Definition: widget2.h:112
const Color & getThemeColor(const ThemeColorIdT type, const unsigned int alpha) const A_INLINE
Definition: widget2.h:44
static Skin * mSkin
Definition: label.h:171

◆ resizeTo()

void Label::resizeTo ( const int  maxSize,
const int  minSize 
)

Definition at line 224 of file label.cpp.

References ServerCommandType::font, Widget::getFont(), Font::getHeight(), Font::getWidth(), mCaption, mPadding, setCaption(), Widget::setHeight(), and Widget::setWidth().

Referenced by CharacterDisplay::update(), CharCreateDialog::updateHair(), and CharCreateDialog::updateLook().

225 {
226  const Font *const font = getFont();
227  const int pad2 = 2 * mPadding;
228  setHeight(font->getHeight() + pad2);
229 
230  if (font->getWidth(mCaption) + pad2 > maxSize)
231  {
232  const int dots = font->getWidth("...");
233  if (dots > maxSize)
234  {
235  setWidth(maxSize);
236  return;
237  }
238  const size_t szChars = mCaption.size();
239  for (size_t f = 1; f < szChars - 1; f ++)
240  {
241  const std::string text = mCaption.substr(0, szChars - f);
242  const int width = font->getWidth(text) + dots + pad2;
243  if (width <= maxSize)
244  {
245  setCaption(text + "...");
246  setWidth(width);
247  return;
248  }
249  }
250  setWidth(maxSize);
251  }
252  else
253  {
254  int sz = font->getWidth(mCaption) + pad2;
255  if (sz < minSize)
256  sz = minSize;
257  setWidth(sz);
258  }
259 }
Font * getFont() const
Definition: widget.cpp:330
void setWidth(const int width)
Definition: widget.cpp:132
Definition: font.h:88
std::string mCaption
Definition: label.h:181
void setCaption(const std::string &caption)
Definition: label.cpp:261
int mPadding
Definition: label.h:190
void setHeight(const int height)
Definition: widget.cpp:139
int getWidth(const std::string &text) const
Definition: font.cpp:333
int getHeight() const
Definition: font.cpp:361

◆ safeDraw()

void Label::safeDraw ( Graphics *const  graphics)
virtual

Implements Widget.

Definition at line 192 of file label.cpp.

References draw().

193 {
194  Label::draw(graphics);
195 }
void draw(Graphics *const graphics)
Definition: label.cpp:150

◆ setAlignment()

void Label::setAlignment ( Graphics::Alignment  alignment)
inline

Sets the alignment of the caption. The alignment is relative to the center of the label.

Parameters
alignmentThe alignment of the caption of the label.
See also
getAlignment, Graphics

Definition at line 152 of file label.h.

References mAlignment.

Referenced by AttrDisplay::AttrDisplay(), CharacterDisplay::CharacterDisplay(), BuyDialog::init(), OutfitWindow::OutfitWindow(), and SellDialog::postInit().

153  { mAlignment = alignment; }
Graphics::Alignment mAlignment
Definition: label.h:188

◆ setCaption()

void Label::setCaption ( const std::string &  caption)

Sets the caption of the label. It's advisable to call adjustSize after setting of the caption to adjust the label's size to fit the caption.

Parameters
captionThe caption of the label.
See also
getCaption, adjustSize

Definition at line 261 of file label.cpp.

References mCaption, and mTextChanged.

Referenced by Setup_Joystick::action(), KillStats::action(), Setup_Video::action(), StatsPageBasic::attributeChanged(), KillStats::attributeChanged(), StatusWindow::attributeChanged(), BankWindow::bankMoneyChanged(), Setup_Video::cancel(), CharacterViewSmall::CharacterViewSmall(), KillStats::gainXp(), getCaption(), TargetDebugTab::logic(), NetDebugTab::logic(), MapDebugTab::logic(), StatDebugTab::logic(), ServerDialog::logic(), UpdaterWindow::logic(), MailViewWindow::removeMoney(), InfoClanTab::resetClan(), resizeTo(), SpeechBubble::setCaption(), Tab::setCaption(), SpellPopup::setItem(), ItemPopup::setItem(), StatusPopup::setLabelText(), TradeWindow::setMoney(), Setup_Colors::Setup_Colors(), Setup_Video::Setup_Video(), CharacterViewSmall::show(), BeingPopup::show(), SkillPopup::show(), TextPopup::show(), OutfitWindow::showCurrentOutfit(), StatsPageBasic::StatsPageBasic(), StatusWindow::StatusWindow(), SetupQuickItem::toWidget(), ChangeDisplay::update(), AttrDisplay::update(), KillStats::update(), SkillDialog::update(), CharacterDisplay::update(), SellDialog::updateButtonsAndLabels(), BuyDialog::updateButtonsAndLabels(), InfoClanTab::updateClan(), SocialWindow::updateCounter(), Setup_Colors::updateGradType(), CharCreateDialog::updateHair(), SliderList::updateLabel(), SetupItemSlider2::updateLabel(), StatusWindow::updateLevelLabel(), CharCreateDialog::updateLook(), CharCreateDialog::updateSliders(), and Setup_Colors::valueChanged().

262 {
263  if (caption != mCaption)
264  mTextChanged = true;
265  mCaption = caption;
266 }
std::string mCaption
Definition: label.h:181
bool mTextChanged
Definition: label.h:192

◆ setForegroundColor()

void Label::setForegroundColor ( const Color color)

Definition at line 205 of file label.cpp.

References Widget::mForegroundColor, Widget2::mForegroundColor2, and mTextChanged.

206 {
207  if (mForegroundColor != color || mForegroundColor2 != color)
208  mTextChanged = true;
209 // logger->log("Label::setForegroundColor: " + mCaption);
210  mForegroundColor = color;
211  mForegroundColor2 = color;
212 }
Color mForegroundColor
Definition: widget.h:1085
bool mTextChanged
Definition: label.h:192
Color mForegroundColor2
Definition: widget2.h:112

◆ setForegroundColorAll()

void Label::setForegroundColorAll ( const Color color1,
const Color color2 
)

Definition at line 214 of file label.cpp.

References Widget::mForegroundColor, Widget2::mForegroundColor2, and mTextChanged.

Referenced by BeingPopup::addLabels(), TradeWindow::clear(), Tab::draw(), TextPopup::postInit(), TradeWindow::reset(), Tab::safeDraw(), SpeechBubble::setCaption(), ItemPopup::setLabelColor(), TradeWindow::setMoney(), BeingPopup::show(), SkillPopup::SkillPopup(), and SpellPopup::SpellPopup().

216 {
217  if (mForegroundColor != color1 || mForegroundColor2 != color2)
218  mTextChanged = true;
219 // logger->log("Label::setForegroundColorAll: " + mCaption);
220  mForegroundColor = color1;
221  mForegroundColor2 = color2;
222 }
Color mForegroundColor
Definition: widget.h:1085
bool mTextChanged
Definition: label.h:192
Color mForegroundColor2
Definition: widget2.h:112

◆ setParent()

void Label::setParent ( Widget *const  parent)
virtual

Sets the parent of the widget. A parent must be a BasicContainer.

WARNING: This function is used internally and should not be called or overloaded unless you know what you are doing.

Parameters
parentThe parent of the widget.
See also
getParent

Reimplemented from Widget.

Definition at line 268 of file label.cpp.

References Widget::addWidgetListener(), Widget2::mWindow, and Widget::setParent().

Referenced by getAlignment().

269 {
270  if (mWindow != nullptr)
271  mWindow->addWidgetListener(this);
272  Widget::setParent(widget);
273 }
Widget * mWindow
Definition: widget2.h:111
virtual void setParent(Widget *parent)
Definition: widget.h:625
void addWidgetListener(WidgetListener *const widgetListener)
Definition: widget.cpp:301

◆ setWindow()

void Label::setWindow ( Widget *const  widget)
virtual

Reimplemented from Widget2.

Definition at line 275 of file label.cpp.

References Widget2::mWindow, Widget::removeWidgetListener(), and Widget2::setWindow().

Referenced by getAlignment().

276 {
277  if ((widget == nullptr) && (mWindow != nullptr))
278  {
280  mWindow = nullptr;
281  }
282  else
283  {
284  Widget2::setWindow(widget);
285  }
286 }
virtual void setWindow(Widget *const window)
Definition: widget2.h:96
Widget * mWindow
Definition: widget2.h:111
void removeWidgetListener(WidgetListener *const widgetListener)
Definition: widget.cpp:306

◆ widgetHidden()

void Label::widgetHidden ( const Event event)
virtual

Invoked when a widget is hidden, i.e it's set to be not visible.

Parameters
eventDescribes the event.

Reimplemented from WidgetListener.

Definition at line 288 of file label.cpp.

References TextChunk::deleteImage(), mTextChanged, and mTextChunk.

Referenced by getAlignment().

289 {
290  mTextChanged = true;
292 }
TextChunk mTextChunk
Definition: label.h:183
bool mTextChanged
Definition: label.h:192
void deleteImage()
Definition: textchunk.cpp:192

Field Documentation

◆ mAlignment

Graphics::Alignment Label::mAlignment
private

Holds the alignment of the caption.

Definition at line 188 of file label.h.

Referenced by draw(), getAlignment(), and setAlignment().

◆ mCaption

std::string Label::mCaption
private

Holds the caption of the label.

Definition at line 181 of file label.h.

Referenced by adjustSize(), draw(), getCaption(), resizeTo(), and setCaption().

◆ mInstances

int Label::mInstances = 0
static

Definition at line 173 of file label.h.

Referenced by init(), and ~Label().

◆ mPadding

int Label::mPadding
private

Definition at line 190 of file label.h.

Referenced by adjustSize(), draw(), init(), and resizeTo().

◆ mSkin

Skin * Label::mSkin = 0
static

Definition at line 171 of file label.h.

Referenced by finalCleanup(), init(), and ~Label().

◆ mTextChanged

bool Label::mTextChanged
private

Definition at line 192 of file label.h.

Referenced by draw(), setCaption(), setForegroundColor(), setForegroundColorAll(), and widgetHidden().

◆ mTextChunk

TextChunk Label::mTextChunk
private

Definition at line 183 of file label.h.

Referenced by draw(), widgetHidden(), and ~Label().


The documentation for this class was generated from the following files: