ManaPlus
Public Member Functions | Static Public Member Functions | Data Fields | Protected Types | Protected Member Functions | Protected Attributes | Static Protected Attributes | Static Private Attributes | Friends
Widget Class Referenceabstract

#include <widget.h>

Inheritance diagram for Widget:
Widget2 BasicContainer BrowserBox Button CheckBox EmotePage GuiTable Icon ItemContainer Label ListBox PlayerBox ProgressBar ProgressIndicator RadioButton ShortcutContainer SkillRectangleListBox Slider StaticBrowserBox TextBox TextField TextPreview

Public Member Functions

 Widget (const Widget2 *const widget)
 
 ~Widget ()
 
virtual void draw (Graphics *const graphics)=0
 
virtual void safeDraw (Graphics *const graphics)=0
 
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
 
virtual void setParent (Widget *parent)
 
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
 
virtual void setWindow (Widget *const window)
 

Static Public Member Functions

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)
 

Data Fields

Visible mVisible
 

Protected Types

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

void distributeActionEvent ()
 
void distributeResizedEvent ()
 
void distributeMovedEvent ()
 
void distributeHiddenEvent ()
 
void distributeShownEvent ()
 
- Protected Member Functions inherited from Widget2
 Widget2 (const Widget2 *const widget)
 

Protected Attributes

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
 

Static Protected Attributes

static FontmGlobalFont = 0
 

Static Private Attributes

static std::list< Widget * > mAllWidgets
 
static std::set< Widget * > mAllWidgetsSet
 

Friends

class BasicContainer
 

Detailed Description

Abstract class for widgets of Guichan. It contains basic functions every widget should have.

NOTE: Functions begining with underscore "_" should not be overloaded unless you know what you are doing

Author
Olof Naessén
Per Larsson.

Definition at line 98 of file widget.h.

Member Typedef Documentation

◆ ActionListenerIterator

typedef ActionListenerList::iterator Widget::ActionListenerIterator
protected

Typdef.

Definition at line 1039 of file widget.h.

◆ ActionListenerList

typedef std::list<ActionListener*> Widget::ActionListenerList
protected

Typdef.

Definition at line 1029 of file widget.h.

◆ FocusListenerIterator

typedef FocusListenerList::iterator Widget::FocusListenerIterator
protected

Typdef.

Definition at line 1069 of file widget.h.

◆ FocusListenerList

typedef std::list<FocusListener*> Widget::FocusListenerList
protected

Typdef.

Definition at line 1059 of file widget.h.

◆ KeyListenerIterator

typedef KeyListenerList::iterator Widget::KeyListenerIterator
protected

Typdef.

Definition at line 1024 of file widget.h.

◆ KeyListenerList

typedef std::list<KeyListener*> Widget::KeyListenerList
protected

Typdef.

Definition at line 1014 of file widget.h.

◆ MouseListenerIterator

typedef MouseListenerList::iterator Widget::MouseListenerIterator
protected

Typdef.

Definition at line 1004 of file widget.h.

◆ MouseListenerList

typedef std::list<MouseListener*> Widget::MouseListenerList
protected

Typdef.

Definition at line 999 of file widget.h.

◆ WidgetDeathListenerIterator

typedef WidgetDeathListenerList::iterator Widget::WidgetDeathListenerIterator
protected

Typdef.

Definition at line 1054 of file widget.h.

◆ WidgetDeathListenerList

Typdef.

Definition at line 1044 of file widget.h.

◆ WidgetListenerIterator

typedef WidgetListenerList::iterator Widget::WidgetListenerIterator
protected

Typdef.

Definition at line 1081 of file widget.h.

◆ WidgetListenerList

typedef std::list<WidgetListener*> Widget::WidgetListenerList
protected

Definition at line 1071 of file widget.h.

Constructor & Destructor Documentation

◆ Widget()

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

Constructor. Resets member variables. Noteable, a widget is not focusable as default, therefore, widgets that are supposed to be focusable should overide this default in their own constructor.

Definition at line 85 of file widget.cpp.

85  :
86  Widget2(widget),
89  mKeyListeners(),
94  mForegroundColor(0x000000),
95  mBackgroundColor(0xffffff),
96  mBaseColor(0x808090),
97  mDimension(),
99  mId(),
100  mFocusHandler(nullptr),
101  mInternalFocusHandler(nullptr),
102  mParent(nullptr),
103  mCurrentFont(nullptr),
104  mFrameSize(0),
105  mFocusable(false),
106  mTabIn(true),
107  mTabOut(true),
108  mEnabled(true),
109  mAllowLogic(true),
110  mMouseConsume(true),
111  mRedraw(true),
112  mSelectable(true)
113 {
114  mAllWidgets.push_back(this);
115  mAllWidgetsSet.insert(this);
116 }
Widget2(const Widget2 *const widget)
Definition: widget2.h:103
bool mFocusable
Definition: widget.h:1143
static std::set< Widget * > mAllWidgetsSet
Definition: widget.h:1179
Color mForegroundColor
Definition: widget.h:1086
static std::list< Widget * > mAllWidgets
Definition: widget.h:1177
Widget * mParent
Definition: widget.h:1128
Rect mDimension
Definition: widget.h:1101
unsigned int mFrameSize
Definition: widget.h:1138
Color mBackgroundColor
Definition: widget.h:1091
Font * mCurrentFont
Definition: widget.h:1133
bool mAllowLogic
Definition: widget.h:1160
FocusHandler * mFocusHandler
Definition: widget.h:1116
bool mTabIn
Definition: widget.h:1148
ActionListenerList mActionListeners
Definition: widget.h:1034
bool mSelectable
Definition: widget.h:1166
KeyListenerList mKeyListeners
Definition: widget.h:1019
bool mEnabled
Definition: widget.h:1158
FocusListenerList mFocusListeners
Definition: widget.h:1064
bool mRedraw
Definition: widget.h:1164
MouseListenerList mMouseListeners
Definition: widget.h:1009
std::string mId
Definition: widget.h:1111
Color mBaseColor
Definition: widget.h:1096
Visible mVisible
Definition: widget.h:963
FocusHandler * mInternalFocusHandler
Definition: widget.h:1122
std::string mActionEventId
Definition: widget.h:1106
WidgetListenerList mWidgetListeners
Definition: widget.h:1076
bool mMouseConsume
Definition: widget.h:1162
bool mTabOut
Definition: widget.h:1153
WidgetDeathListenerList mDeathListeners
Definition: widget.h:1049
const bool Visible_true
Definition: visible.h:30

References mAllWidgets, and mAllWidgetsSet.

◆ ~Widget()

Widget::~Widget ( )

Default destructor.

Definition at line 118 of file widget.cpp.

119 {
121  {
122  Event event(this);
123  (*iter)->death(event);
124  }
125 
126  // +++ call to virtual member
127  setFocusHandler(nullptr);
128 
129  mAllWidgets.remove(this);
130  mAllWidgetsSet.erase(this);
131 }
Definition: event.h:79
virtual void setFocusHandler(FocusHandler *const focusHandler)
Definition: widget.cpp:238
WidgetDeathListenerList::iterator WidgetDeathListenerIterator
Definition: widget.h:1054
#define FOR_EACH(type, iter, array)
Definition: foreach.h:25

References FOR_EACH, mAllWidgets, mAllWidgetsSet, mDeathListeners, and setFocusHandler().

Member Function Documentation

◆ addActionListener()

void Widget::addActionListener ( ActionListener *const  actionListener)

Adds an action listener to the widget. When an action event is fired by the widget the action listeners of the widget will get notified.

Parameters
actionListenerThe action listener to add.
See also
removeActionListener

Definition at line 252 of file widget.cpp.

253 {
254  mActionListeners.push_back(actionListener);
255 }

References mActionListeners.

Referenced by SetupItemTextField::action(), SetupItemIntTextField::action(), Setup_Video::action(), ChangeEmailDialog::action(), ChangePasswordDialog::action(), CharSelectDialog::action(), EditServerDialog::action(), LoginDialog::action(), RegisterDialog::action(), ShopWindow::action(), WidgetGroup::addButton(), SkillDialog::addDefaultTab(), EmoteWindow::addListeners(), TabbedArea::addTab(), CharSelectDialog::askPasswordForDeletion(), DialogsManager::attributeChanged(), Button::Button(), GameModifiers::changeAwayMode(), PincodeManager::changePincode(), CharacterDisplay::CharacterDisplay(), CharCreateDialog::CharCreateDialog(), ChatWindow::ChatWindow(), CheckBox::CheckBox(), InventoryWindow::combineItems(), SetupItemCheckBox::createControls(), SetupItemTextField::createControls(), SetupItemIntTextField::createControls(), SetupItemLabel::createControls(), SetupItemDropDown::createControls(), SetupItemDropDownStr::createControls(), SetupItemSlider::createControls(), SetupItemSlider2::createControls(), SetupItemSliderList::createControls(), SetupQuickItem::createControls(), SetupActionDropDown::createControls(), NpcDialog::createSkinControls(), DropDown::DropDown(), EditServerDialog::EditServerDialog(), EquipmentWindow::EquipmentWindow(), ItemLinkHandler::handleCommandLink(), ItemLinkHandler::handleHttpLink(), PopupMenu::handleLink(), BuyDialog::init(), InventoryWindow::InventoryWindow(), SocialGuildTab::invite(), SocialPartyTab::invite(), ItemAmountWindow::ItemAmountWindow(), SocialGuildTab::leave(), SocialPartyTab::leave(), SkillDialog::loadXmlFile(), LoginDialog::LoginDialog(), NpcDialog::NpcDialog(), InputActionReplayListener::openDialog(), OutfitWindow::OutfitWindow(), PincodeDialog::PincodeDialog(), DialogsManager::playerDeath(), SellDialog::postInit(), EquipmentWindow::postInit(), TextSelectDialog::postInit(), SliderList::postInit2(), EAthena::FamilyRecv::processAskForChild(), ShopWindow::processRequest(), EAthena::SkillRecv::processSkillWarpPoint(), EAthena::SkillRecv::processSkillWarpPoint2(), Ea::TradeRecv::processTradeRequestContinue(), QuestsWindow::QuestsWindow(), RegisterDialog::RegisterDialog(), NpcSellDialog::sellAction(), PincodeManager::setNewPincode(), Setup_Colors::Setup_Colors(), Setup_Input::Setup_Input(), Setup_Joystick::Setup_Joystick(), Setup_Relations::Setup_Relations(), Setup_Theme::Setup_Theme(), Setup_Video::Setup_Video(), ShopWindow::ShopWindow(), SocialWindow::showGuildInvite(), SocialWindow::showPartyInvite(), Game::slowLogic(), TextCommandEditor::TextCommandEditor(), TextField::TextField(), PincodeManager::updateState(), SkillDialog::useSkillDefault(), SkillDialog::useSkillPosition(), and SkillDialog::useSkillTarget().

◆ addDeathListener()

void Widget::addDeathListener ( WidgetDeathListener *const  deathListener)

Adds a death listener to the widget. When a death event is fired by the widget the death listeners of the widget will get notified.

Parameters
deathListenerThe death listener to add.
See also
removeDeathListener

Definition at line 262 of file widget.cpp.

263 {
264  mDeathListeners.push_back(deathListener);
265 }

References mDeathListeners.

◆ addFocusListener()

void Widget::addFocusListener ( FocusListener *const  focusListener)

Adds a focus listener to the widget. When a focus event is fired by the widget the key listeners of the widget will get notified.

Parameters
focusListenerThe focus listener to add.
See also
removeFocusListener

Definition at line 282 of file widget.cpp.

283 {
284  mFocusListeners.push_back(focusListener);
285 }

References mFocusListeners.

Referenced by ChatInput::ChatInput(), DropDown::DropDown(), Button::init(), MailEditWindow::MailEditWindow(), and TextField::TextField().

◆ addKeyListener()

void Widget::addKeyListener ( KeyListener *const  keyListener)

◆ addMouseListener()

void Widget::addMouseListener ( MouseListener *const  mouseListener)

◆ addWidgetListener()

void Widget::addWidgetListener ( WidgetListener *const  widgetListener)

◆ callPostInit()

Widget * Widget::callPostInit ( Widget *const  widget)
static

Definition at line 522 of file widget.cpp.

523 {
524  if (widget != nullptr)
525  widget->postInit();
526  return widget;
527 }
virtual void postInit()
Definition: widget.h:957

References postInit().

◆ cleanGlobalFont()

static void Widget::cleanGlobalFont ( )
inlinestatic

Definition at line 650 of file widget.h.

651  { mGlobalFont = nullptr; }
static Font * mGlobalFont
Definition: widget.h:1171

References mGlobalFont.

Referenced by Gui::~Gui().

◆ distributeActionEvent()

void Widget::distributeActionEvent ( )
protected

◆ distributeHiddenEvent()

void Widget::distributeHiddenEvent ( )
protected

Distributes hidden events to all of the widget's listeners.

Author
Olof Naessén

Definition at line 484 of file widget.cpp.

485 {
487  {
488  Event event(this);
489  (*iter)->widgetHidden(event);
490  }
491 }
WidgetListenerList::iterator WidgetListenerIterator
Definition: widget.h:1081

References FOR_EACH, and mWidgetListeners.

Referenced by setVisible().

◆ distributeMovedEvent()

void Widget::distributeMovedEvent ( )
protected

Distributes moved events to all of the widget's listeners.

Definition at line 475 of file widget.cpp.

476 {
478  {
479  Event event(this);
480  (*iter)->widgetMoved(event);
481  }
482 }

References FOR_EACH, and mWidgetListeners.

Referenced by setDimension().

◆ distributeResizedEvent()

void Widget::distributeResizedEvent ( )
protected

Distributes resized events to all of the widget's listeners.

Definition at line 466 of file widget.cpp.

467 {
469  {
470  Event event(this);
471  (*iter)->widgetResized(event);
472  }
473 }

References FOR_EACH, and mWidgetListeners.

Referenced by setDimension(), and CharacterDisplay::update().

◆ distributeShownEvent()

void Widget::distributeShownEvent ( )
protected

Distributes shown events to all of the widget's listeners.

Author
Olof Naessén

Definition at line 502 of file widget.cpp.

503 {
505  {
506  Event event(this);
507  (*iter)->widgetShown(event);
508  }
509 }

References FOR_EACH, and mWidgetListeners.

Referenced by setVisible().

◆ distributeWindowResizeEvent()

void Widget::distributeWindowResizeEvent ( )
static

Definition at line 355 of file widget.cpp.

356 {
357  FOR_EACH (std::list<Widget*>::const_iterator, iter, mAllWidgets)
358  (*iter)->windowResized();
359 }

References FOR_EACH, and mAllWidgets.

Referenced by Gui::videoResized().

◆ draw()

virtual void Widget::draw ( Graphics *const  graphics)
pure virtual

Draws the widget. It is called by the parent widget when it is time for the widget to draw itself. The graphics object is set up so that all drawing is relative to the widget, i.e coordinate (0,0) is the top left corner of the widget. It is not possible to draw outside of a widget's dimension.

Parameters
graphicsaA graphics object to draw with.

Implemented in EmoteShortcutContainer, AvatarListBox, Viewport, Viewport, OutfitWindow, MiniStatusWindow, Minimap, EquipmentWindow, CutInWindow, ConnectionDialog, ChatWindow, Window, VirtShortcutContainer, TextPreview, TextField, TextBox, Tab, TabbedArea, StaticBrowserBox, SpellShortcutContainer, SliderList, Slider, SkillRectangleListBox, SkillListBox, ShopListBox, ServersListBox, ScrollArea, RadioButton, ProgressIndicator, ProgressBar, Popup, PlayerBox, PasswordField, ListBox, Label, ItemShortcutContainer, ItemContainer, GuiTable, ExtendedListBox, EmotePage, DropDown, Desktop, ColorPage, CheckBox, Button, BrowserBox, BasicContainer2, DebugWindow, and Icon.

Referenced by GuiTable::draw().

◆ drawFrame()

virtual void Widget::drawFrame ( Graphics graphics)
inlinevirtual

Called when a widget is given a chance to draw a frame around itself. The frame is not considered a part of the widget, it only allows a frame to be drawn around the widget, thus a frame will never be included when calculating if a widget should receive events from user input. Also a widget's frame will never be included when calculating a widget's position.

The size of the frame is calculated using the widget's frame size. If a widget has a frame size of 10 pixels than the area the drawFrame function can draw to will be the size of the widget with an additional extension of 10 pixels in each direction.

An example when drawFrame is a useful function is if a widget needs a glow around itself.

Parameters
graphicsA graphics object to draw with.
See also
setFrameSize, getFrameSize

Reimplemented in TextField, ScrollArea, PlayerBox, and DropDown.

Definition at line 149 of file widget.h.

150  { }

◆ focusNext()

virtual void Widget::focusNext ( )
inlinevirtual

Focuses the next widget in the widget.

See also
moveToBottom

Reimplemented in BasicContainer.

Definition at line 885 of file widget.h.

886  { }

◆ focusPrevious()

virtual void Widget::focusPrevious ( )
inlinevirtual

Focuses the previous widget in the widget.

See also
moveToBottom

Reimplemented in BasicContainer.

Definition at line 893 of file widget.h.

894  { }

◆ fontChanged()

virtual void Widget::fontChanged ( )
inlinevirtual

Called when the font has changed. If the change is global, this function will only be called if the widget doesn't have a font already set.

Reimplemented in TextField, and TextBox.

Definition at line 667 of file widget.h.

668  { }

Referenced by setFont().

◆ getAbsolutePosition()

void Widget::getAbsolutePosition ( int &  x,
int &  y 
) const
virtual

Gets the absolute position on the screen for the widget.

Parameters
xThe absolute x coordinate will be stored in this parameter.
yThe absolute y coordinate will be stored in this parameter.

Definition at line 312 of file widget.cpp.

313 {
314  if (mParent == nullptr)
315  {
316  x = mDimension.x;
317  y = mDimension.y;
318  return;
319  }
320 
321  int parentX;
322  int parentY;
323 
324  mParent->getAbsolutePosition(parentX, parentY);
325 
326  const Rect &rect = mParent->getChildrenArea();
327  x = parentX + mDimension.x + rect.x;
328  y = parentY + mDimension.y + rect.y;
329 }
Definition: rect.h:74
int y
Definition: rect.h:214
int x
Definition: rect.h:209
virtual Rect getChildrenArea()
Definition: widget.cpp:451
virtual void getAbsolutePosition(int &x, int &y) const
Definition: widget.cpp:312

References getAbsolutePosition(), getChildrenArea(), mDimension, mParent, Rect::x, x, Rect::y, and y.

Referenced by Gui::distributeMouseEvent(), DropDown::dropDown(), getAbsolutePosition(), BrowserBox::getTextAtPos(), StaticBrowserBox::getTextAtPos(), Gui::getWidgetAt(), Gui::handleMouseMoved(), Gui::handleMousePressed(), Gui::handleMouseReleased(), Gui::handleMouseWheelMovedDown(), Gui::handleMouseWheelMovedUp(), Window::setLocationHorisontallyRelativeTo(), Popup::setLocationRelativeTo(), Window::setLocationRelativeTo(), and ChatWindow::updateVisibility().

◆ getActionEventId()

const std::string& Widget::getActionEventId ( ) const
inline

◆ getBackgroundColor()

const Color& Widget::getBackgroundColor ( ) const
inline

Gets the background color.

See also
setBackgroundColor

Definition at line 433 of file widget.h.

434  { return mBackgroundColor; }

References mBackgroundColor.

◆ getBaseColor()

const Color& Widget::getBaseColor ( ) const
inline

Gets the base color.

Returns
The base color.
See also
setBaseColor

Definition at line 399 of file widget.h.

400  { return mBaseColor; }

References mBaseColor.

◆ getChildrenArea()

Rect Widget::getChildrenArea ( )
virtual

Gets the area of the widget occupied by the widget's children. By default this method returns an empty rectangle as not all widgets are containers. If you want to make a container this method should return the area where the children resides. This method is used when drawing children of a widget when computing clip rectangles for the children.

An example of a widget that overloads this method is ScrollArea. A ScrollArea has a view of its contant and that view is the children area. The size of a ScrollArea's children area might vary depending on if the scroll bars of the ScrollArea is shown or not.

Returns
The area of the widget occupied by the widget's children.
See also
BasicContainer
BasicContainer::getChildrenArea
BasicContainer::drawChildren

Reimplemented in MiniStatusWindow, Window, ScrollArea, Popup, GuiTable, DropDown, and BasicContainer.

Definition at line 451 of file widget.cpp.

452 {
453  return Rect(0, 0, 0, 0);
454 }

Referenced by getAbsolutePosition(), and TextBox::keyPressed().

◆ getDimension()

const Rect& Widget::getDimension ( ) const
inline

Gets the dimension of the widget. The dimension is relative to the widget's parent.

Returns
The dimension of the widget.
See also
getDimension, setX, getX, setY, getY, setPosition

Definition at line 317 of file widget.h.

318  { return mDimension; }

References mDimension.

Referenced by Pincode::addButtons(), GuiTable::draw(), GuiTable::getWidgetAt(), Gui::handleMouseMoved(), Window::mouseDragged(), GuiTable::safeDraw(), and TabbedArea::widgetResized().

◆ getFocusHandler()

FocusHandler* Widget::getFocusHandler ( )
inline

Gets the focus handler used.

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

Returns
The focus handler used.
See also
setFocusHandler

Definition at line 474 of file widget.h.

475  { return mFocusHandler; }

References mFocusHandler.

Referenced by GuiTable::installActionListeners().

◆ getFocusListeners()

const std::list< FocusListener * > & Widget::getFocusListeners ( ) const

Gets the focus listeners of the widget.

Returns
The focus listeners of the widget.

Definition at line 446 of file widget.cpp.

447 {
448  return mFocusListeners;
449 }

References mFocusListeners.

Referenced by FocusHandler::distributeFocusGainedEvent(), and FocusHandler::distributeFocusLostEvent().

◆ getFont()

Font * Widget::getFont ( ) const

Gets the font set for the widget. If no font has been set, the global font will be returned. If no global font has been set, the default font will be returend.

Returns
The font set for the widget.
See also
setFont, setGlobalFont

Definition at line 331 of file widget.cpp.

332 {
333  if (mCurrentFont == nullptr)
334  return mGlobalFont;
335  return mCurrentFont;
336 }

References mCurrentFont, and mGlobalFont.

Referenced by BrowserBox::addRow(), StaticBrowserBox::addRow(), DropDown::adjustHeight(), TextField::adjustHeight(), Button::adjustSize(), CheckBox::adjustSize(), Label::adjustSize(), RadioButton::adjustSize(), TextBox::adjustSize(), TextField::adjustSize(), TextPreview::adjustSize(), BrowserBox::calcHeight(), ColorPage::ColorPage(), BrowserBox::draw(), Button::draw(), CheckBox::draw(), ColorPage::draw(), DropDown::draw(), ExtendedListBox::draw(), ItemContainer::draw(), ItemShortcutContainer::draw(), Label::draw(), ListBox::draw(), RadioButton::draw(), ServersListBox::draw(), ShopListBox::draw(), SkillListBox::draw(), SkillRectangleListBox::draw(), SpellShortcutContainer::draw(), StaticBrowserBox::draw(), TextBox::draw(), TextField::draw(), VirtShortcutContainer::draw(), EquipmentWindow::draw(), AvatarListBox::draw(), TextBox::drawCaret(), Viewport::drawPath(), TextField::fixScroll(), SliderList::getMaxLabelWidth(), ServersListBox::getRowHeight(), InventoryWindow::InventoryWindow(), ItemPopup::ItemPopup(), TextBox::keyPressed(), Label::Label(), ListBox::ListBox(), AvatarListBox::mousePressed(), SkillRectangleListBox::mousePressed(), TextBox::mousePressed(), TextField::mousePressed(), NpcDialog::NpcDialog(), OkDialog::OkDialog(), PincodeDialog::PincodeDialog(), StatusPopup::postInit(), TextBoxPopup::postInit(), TextPopup::postInit(), ConfirmDialog::postInit(), ProgressBar::ProgressBar(), Label::resizeTo(), Button::safeDraw(), ItemContainer::safeDraw(), ItemShortcutContainer::safeDraw(), SpellShortcutContainer::safeDraw(), VirtShortcutContainer::safeDraw(), EquipmentWindow::safeDraw(), AvatarListBox::safeDraw(), TextBox::scrollToCaret(), ItemPopup::setItem(), SpeechBubble::setText(), TextBox::setTextWrapped(), Setup_Colors::Setup_Colors(), ShopListBox::ShopListBox(), BeingPopup::show(), TextPopup::show(), SkillPopup::show(), SkillListBox::SkillListBox(), SkillPopup::SkillPopup(), SkillRectangleListBox::SkillRectangleListBox(), TextDialog::TextDialog(), TradeWindow::TradeWindow(), and StaticBrowserBox::updateHeight().

◆ getForegroundColor()

const Color& Widget::getForegroundColor ( ) const
inline

Gets the foreground color.

See also
setForegroundColor

Definition at line 416 of file widget.h.

417  { return mForegroundColor; }

References mForegroundColor.

◆ getFrameSize()

unsigned int Widget::getFrameSize ( ) const
inline

Gets the size of the widget's frame. The frame is not considered a part of the widget, it only allows a frame to be drawn around the widget, thus a frame will never be included when calculating if a widget should receive events from user input. Also a widget's frame will never be included when calculating a widget's position.

A frame size of 0 means that the widget has no frame. The default frame size is 0.

Returns
The size of the widget's frame.
See also
setFrameSize, drawFrame

Definition at line 184 of file widget.h.

185  { return mFrameSize; }

References mFrameSize.

Referenced by TabbedArea::adjustSize(), ChatWindow::adjustTabSize(), DropDown::drawFrame(), DropDown::dropDown(), ScrollArea::getHorizontalMaxScroll(), ScrollArea::getVerticalMaxScroll(), ScrollArea::logic(), DropDown::safeDrawFrame(), ScrollArea::showWidgetPart(), and TabbedArea::widgetResized().

◆ getGloablFont()

static Font* Widget::getGloablFont ( )
inlinestatic

Definition at line 647 of file widget.h.

648  { return mGlobalFont; }

References mGlobalFont.

◆ getHeight()

int Widget::getHeight ( ) const
inline

Gets the height of the widget.

Returns
The height of the widget.
See also
setHeight, setWidth, getWidth, setSize, setDimension, getDimension

Definition at line 240 of file widget.h.

241  { return mDimension.height; }
int height
Definition: rect.h:224

References Rect::height, and mDimension.

Referenced by VertContainer::add2(), WindowMenu::addButton(), TabbedArea::addTab(), DropDown::adjustHeight(), TextField::adjustHeight(), CheckBox::adjustSize(), TabbedArea::adjustSize(), Tab::adjustSize(), TextPreview::adjustSize(), TabbedArea::adjustTabPositions(), ChatWindow::adjustTabSize(), TabbedArea::adjustWidget(), BeingPopup::BeingPopup(), ChangeEmailDialog::ChangeEmailDialog(), CharCreateDialog::CharCreateDialog(), ScrollArea::checkPolicies(), GuiTable::draw(), Slider::draw(), TextBox::draw(), Viewport::draw(), CheckBox::drawBox(), RadioButton::drawBox(), TextBox::drawCaret(), DropDown::dropDown(), EditServerDialog::EditServerDialog(), EquipmentWindow::EquipmentWindow(), ScrollArea::getChildrenArea(), TabbedArea::getContainerHeight(), ScrollArea::getVerticalMarkerDimension(), ScrollArea::getVerticalMaxScroll(), Gui::handleMouseMoved(), BuySellDialog::init(), Window::loadWindowState(), Window::mouseDragged(), ChatWindow::mouseDragged(), ShortcutWindow::mouseDragged(), OkDialog::OkDialog(), LayoutArray::place(), ConfirmDialog::postInit(), EditDialog::postInit(), EquipmentWindow::postInit(), SetupWindow::postInit(), ProgressBar::ProgressBar(), EquipmentWindow::recalcSize(), CharacterViewNormal::resize(), CharacterViewSmall::resize(), Window::resizeToContent(), GuiTable::safeDraw(), Slider::safeDraw(), ChatTab::scroll(), ServerDialog::ServerDialog(), StaticTableModel::set(), CharCreateDialog::setAttributes(), Desktop::setBestFittingWallpaper(), CharCreateDialog::setButtonsPosition(), SpellPopup::setItem(), Popup::setLocationRelativeTo(), Window::setLocationRelativeTo(), SpeechBubble::setText(), ShopListBox::ShopListBox(), TextBoxPopup::show(), TextPopup::show(), PopupList::show(), PopupMenu::showPopup(), StatusWindow::StatusWindow(), StatusPopup::update(), MiniStatusWindow::updateBars(), WindowMenu::updateButtons(), StatsClanTab::updateClan(), RelationClanTab::updateClan(), SliderList::updateLabel(), ChatWindow::updateVisibility(), StatusPopup::view(), Desktop::widgetResized(), FlowContainer::widgetResized(), StatsPage::widgetResized(), StatsPageBasic::widgetResized(), TabbedArea::widgetResized(), SetupTabScroll::widgetResized(), EmoteWindow::widgetResized(), and SetupWindow::widgetResized().

◆ getId()

const std::string& Widget::getId ( ) const
inline

Definition at line 919 of file widget.h.

920  { return mId; }

References mId.

Referenced by RequestTradeListener::action(), MiniStatusWindow::mouseMoved(), and PopupMenu::showPopup().

◆ getInternalFocusHandler()

FocusHandler * Widget::getInternalFocusHandler ( )
virtual

Gets the internal focus handler used.

Returns
the internalFocusHandler used. If no internal focus handler is used, NULL will be returned.
See also
setInternalFocusHandler

Definition at line 456 of file widget.cpp.

457 {
458  return mInternalFocusHandler;
459 }

References mInternalFocusHandler.

Referenced by Gui::getKeyEventSource().

◆ getKeyListeners()

const std::list< KeyListener * > & Widget::getKeyListeners ( ) const

Gets the key listeners of the widget.

Returns
The key listeners of the widget.

Definition at line 441 of file widget.cpp.

442 {
443  return mKeyListeners;
444 }

References mKeyListeners.

Referenced by Gui::distributeKeyEvent().

◆ getMouseListeners()

const std::list< MouseListener * > & Widget::getMouseListeners ( ) const

Gets the mouse listeners of the widget.

Returns
The mouse listeners of the widget.

Definition at line 436 of file widget.cpp.

437 {
438  return mMouseListeners;
439 }

References mMouseListeners.

Referenced by Gui::distributeMouseEvent().

◆ getParent()

Widget* Widget::getParent ( ) const
inline

◆ getWidgetAt()

virtual Widget* Widget::getWidgetAt ( int  x,
int  y 
)
inlinevirtual

Gets a widget from a certain position in the widget. This function is used to decide which gets mouse input, thus it can be overloaded to change that behaviour.

NOTE: This always returns NULL if the widget is not a container.

Parameters
xThe x coordinate of the widget to get.
yThe y coordinate of the widget to get.
Returns
The widget at the specified coodinate, NULL if no widget is found.

Reimplemented in ScrollArea, GuiTable, and BasicContainer.

Definition at line 792 of file widget.h.

794  { return nullptr; }

Referenced by Gui::getWidgetAt().

◆ getWidth()

int Widget::getWidth ( ) const
inline

Gets the width of the widget.

Returns
The width of the widget.
See also
setWidth, setHeight, getHeight, setSize, setDimension, getDimension

Definition at line 221 of file widget.h.

222  { return mDimension.width; }
int width
Definition: rect.h:219

References mDimension, and Rect::width.

Referenced by HorizontContainer::add(), VertContainer::add2(), WindowMenu::addButton(), BrowserBox::addRow(), StaticBrowserBox::addRow(), TabbedArea::addTab(), WidgetGroup::addWidget(), CheckBox::adjustSize(), TabbedArea::adjustSize(), Tab::adjustSize(), TextField::adjustSize(), TabbedArea::adjustTabPositions(), ChatWindow::adjustTabSize(), TabbedArea::adjustWidget(), ChangeEmailDialog::ChangeEmailDialog(), CharacterViewNormal::CharacterViewNormal(), CharCreateDialog::CharCreateDialog(), CharSelectDialog::CharSelectDialog(), ChatWindow::ChatWindow(), ScrollArea::checkPolicies(), GuiTable::draw(), ServersListBox::draw(), SkillListBox::draw(), Slider::draw(), TextBox::draw(), Viewport::draw(), AvatarListBox::draw(), EditServerDialog::EditServerDialog(), SetupItem::fixFirstItemSize(), ScrollArea::getChildrenArea(), ScrollArea::getHorizontalMarkerDimension(), ScrollArea::getHorizontalMaxScroll(), Gui::handleMouseMoved(), Slider::init(), BuyDialog::init(), BuySellDialog::init(), InventoryWindow::InventoryWindow(), ItemAmountWindow::ItemAmountWindow(), Window::loadWindowState(), NpcDialog::logic(), ChatWindow::mouseDragged(), ShortcutWindow::mouseDragged(), SkillListBox::mousePressed(), Client::moveButtons(), OkDialog::OkDialog(), PincodeDialog::PincodeDialog(), LayoutArray::place(), SellDialog::postInit(), ConfirmDialog::postInit(), EditDialog::postInit(), EquipmentWindow::postInit(), SetupWindow::postInit(), CharacterViewNormal::resize(), CharacterViewSmall::resize(), SliderList::resize(), Window::resizeToContent(), GuiTable::safeDraw(), Slider::safeDraw(), AvatarListBox::safeDraw(), ServerDialog::ServerDialog(), StaticTableModel::set(), Desktop::setBestFittingWallpaper(), CharCreateDialog::setButtonsPosition(), ItemPopup::setItem(), SpellPopup::setItem(), Window::setLocationHorisontallyRelativeTo(), Popup::setLocationRelativeTo(), Window::setLocationRelativeTo(), SpeechBubble::setText(), Setup_Colors::Setup_Colors(), BeingPopup::show(), TextBoxPopup::show(), TextPopup::show(), SkillPopup::show(), PopupList::show(), PopupMenu::showPopup(), SkillDialog::SkillDialog(), StatusWindow::StatusWindow(), TextDialog::TextDialog(), StatusPopup::update(), CharacterDisplay::update(), TabbedArea::updateArrowEnableState(), MiniStatusWindow::updateBars(), WindowMenu::updateButtons(), SliderList::updateLabel(), ChatWindow::updateTabsMargin(), TabbedArea::updateTabsWidth(), ChatWindow::updateVisibility(), TabbedArea::updateVisibleTabsWidth(), Game::videoResized(), SpellPopup::view(), StatusPopup::view(), Desktop::widgetResized(), FlowContainer::widgetResized(), StatsPage::widgetResized(), StatsPageBasic::widgetResized(), TabbedArea::widgetResized(), SetupTabScroll::widgetResized(), VertContainer::widgetResized(), EmoteWindow::widgetResized(), InventoryWindow::widgetResized(), and SetupWindow::widgetResized().

◆ getX()

int Widget::getX ( ) const
inline

◆ getY()

int Widget::getY ( ) const
inline

◆ isAllowLogic()

bool Widget::isAllowLogic ( ) const
inline

Definition at line 933 of file widget.h.

934  { return mAllowLogic; }

References mAllowLogic.

◆ isEnabled()

bool Widget::isEnabled ( ) const

Checks if the widget is enabled. A disabled widget will never recieve mouse or key events.

Returns
True if widget is enabled, false otherwise.
See also
setEnabled

Definition at line 375 of file widget.cpp.

376 {
377  return mEnabled && isVisible();
378 }
bool isVisible() const
Definition: widget.h:378

References isVisible(), and mEnabled.

Referenced by Setup_Video::action(), Gui::distributeKeyEvent(), Gui::distributeMouseEvent(), Button::draw(), isFocusable(), and Button::safeDraw().

◆ isFocusable()

bool Widget::isFocusable ( ) const

Checks if a widget is focsable.

Returns
True if the widget should be focusable, false otherwise.
See also
setFocusable

Definition at line 199 of file widget.cpp.

200 {
201  return mFocusable && isVisible() && isEnabled();
202 }
bool isEnabled() const
Definition: widget.cpp:375

References isEnabled(), isVisible(), and mFocusable.

Referenced by GuiTable::getWidgetAt(), Gui::handleKeyInput(), ListBox::refocus(), requestFocus(), FocusHandler::tabNext(), and FocusHandler::tabPrevious().

◆ isFocused()

bool Widget::isFocused ( ) const
virtual

◆ isModalFocused()

bool Widget::isModalFocused ( ) const
virtual

Checks if the widget or it's parent has modal focus.

Returns
True if the widget has modal focus, false otherwise.
See also
requestModalFocus, releaseModalFocus

Definition at line 408 of file widget.cpp.

409 {
410  if (mFocusHandler == nullptr)
411  return false;
412 
413  if (mParent != nullptr)
414  {
415  return (mFocusHandler->getModalFocused() == this)
416  || mParent->isModalFocused();
417  }
418 
419  return mFocusHandler->getModalFocused() == this;
420 }
Widget * getModalFocused() const
virtual bool isModalFocused() const
Definition: widget.cpp:408

References FocusHandler::getModalFocused(), isModalFocused(), mFocusHandler, and mParent.

Referenced by Gui::distributeKeyEvent(), Gui::distributeMouseEvent(), Gui::handleMousePressed(), isModalFocused(), FocusHandler::requestModalFocus(), FocusHandler::tabNext(), and FocusHandler::tabPrevious().

◆ isModalMouseInputFocused()

bool Widget::isModalMouseInputFocused ( ) const
virtual

Checks if the widget or it's parent has modal mouse input focus.

Returns
True if the widget has modal mouse input focus, false otherwise.
See also
requestModalMouseInputFocus, releaseModalMouseInputFocus

Definition at line 422 of file widget.cpp.

423 {
424  if (mFocusHandler == nullptr)
425  return false;
426 
427  if (mParent != nullptr)
428  {
429  return (mFocusHandler->getModalMouseInputFocused() == this)
431  }
432 
433  return mFocusHandler->getModalMouseInputFocused() == this;
434 }
Widget * getModalMouseInputFocused() const
virtual bool isModalMouseInputFocused() const
Definition: widget.cpp:422

References FocusHandler::getModalMouseInputFocused(), isModalMouseInputFocused(), mFocusHandler, and mParent.

Referenced by Gui::distributeKeyEvent(), Gui::distributeMouseEvent(), Gui::getMouseEventSource(), and isModalMouseInputFocused().

◆ isMouseConsume()

bool Widget::isMouseConsume ( ) const
inline

Definition at line 939 of file widget.h.

940  { return mMouseConsume; }

References mMouseConsume.

◆ isSelectable()

virtual bool Widget::isSelectable ( ) const
inlinevirtual

Reimplemented in ScrollArea.

Definition at line 945 of file widget.h.

946  { return mSelectable; }

References mSelectable.

Referenced by Gui::getWidgetAt(), and ScrollArea::isSelectable().

◆ isTabInEnabled()

bool Widget::isTabInEnabled ( ) const
inline

Checks if tab in is enabled. Tab in means that you can set focus to this widget by pressing the tab button. If tab in is disabled then the focus handler will skip this widget and focus the next in its focus order.

Returns
True if tab in is enabled, false otherwise.
See also
setTabInEnabled

Definition at line 688 of file widget.h.

689  { return mTabIn; }

References mTabIn.

Referenced by FocusHandler::tabNext(), and FocusHandler::tabPrevious().

◆ isTabOutEnabled()

bool Widget::isTabOutEnabled ( ) const
inline

Checks if tab out is enabled. Tab out means that you can lose focus to this widget by pressing the tab button. If tab out is disabled then the FocusHandler ignores tabbing and focus will stay with this widget.

Returns
True if tab out is enabled, false otherwise.
See also
setTabOutEnabled

Definition at line 712 of file widget.h.

713  { return mTabOut; }

References mTabOut.

Referenced by FocusHandler::tabNext(), and FocusHandler::tabPrevious().

◆ isVisible()

bool Widget::isVisible ( ) const
inline

Checks if the widget is visible.

Returns
True if widget is be visible, false otherwise.
See also
setVisible

Definition at line 378 of file widget.h.

379  {
380  return mVisible == Visible_true &&
381  ((mParent == nullptr) || mParent->isVisible());
382  }

References isVisible(), mParent, mVisible, and Visible_true.

Referenced by Gui::handleMouseMoved(), isEnabled(), isFocusable(), isVisible(), ScrollArea::logic(), ChatInput::processVisible(), ChatWindow::requestChatFocus(), ChatWindow::toggleChatFocus(), and ChatWindow::updateVisibility().

◆ logic()

virtual void Widget::logic ( )
inlinevirtual

Called for all widgets in the gui each time Gui::logic is called. You can do logic stuff here like playing an animation.

See also
Gui::logic

Reimplemented in Viewport, Viewport, WhoIsOnline, UpdaterWindow, ServerDialog, NpcDialog, MiniStatusWindow, CutInWindow, CharCreateDialog, TargetDebugTab, StatDebugTab, NetDebugTab, MapDebugTab, DebugTab, TabbedArea, ScrollArea, ProgressIndicator, ProgressBar, ListBox, ItemContainer, and BasicContainer.

Definition at line 193 of file widget.h.

194  { }

Referenced by ChatWindow::adjustTabSize(), Gui::logic(), ItemContainer::logic(), ScrollArea::logic(), and TextBox::setTextWrapped().

◆ moveToBottom()

virtual void Widget::moveToBottom ( Widget widget)
inlinevirtual

Moves a widget in this widget to the bottom of this widget. The moved widget will be drawn below all other widgets in this widget.

Parameters
widgetThe widget to move to the bottom.
See also
moveToTop

Reimplemented in GuiTable, and BasicContainer.

Definition at line 877 of file widget.h.

878  { }

Referenced by GuiTable::moveToBottom(), and requestMoveToBottom().

◆ moveToTop()

virtual void Widget::moveToTop ( Widget widget)
inlinevirtual

Moves a widget to the top of this widget. The moved widget will be drawn above all other widgets in this widget.

Parameters
widgetThe widget to move to the top.
See also
moveToBottom

Reimplemented in GuiTable, and BasicContainer.

Definition at line 867 of file widget.h.

868  { }

Referenced by Window::mousePressed(), GuiTable::moveToTop(), ConfirmDialog::postInit(), PincodeDialog::postInit(), TextDialog::postInit(), and requestMoveToTop().

◆ postInit()

virtual void Widget::postInit ( )
inlinevirtual

◆ releaseModalFocus()

void Widget::releaseModalFocus ( )
virtual

Releases modal focus. Modal focus will only be released if the widget has modal focus.

See also
requestModalFocus, isModalFocused

Definition at line 394 of file widget.cpp.

395 {
396  if (mFocusHandler == nullptr)
397  return;
399 }
void releaseModalFocus(Widget *const widget)

References mFocusHandler, and FocusHandler::releaseModalFocus().

Referenced by PopupList::focusGained(), PopupList::mouseReleased(), setFocusHandler(), and Window::setModal().

◆ releaseModalMouseInputFocus()

void Widget::releaseModalMouseInputFocus ( )
virtual

Releases modal mouse input focus. Modal mouse input focus will only be released if the widget has modal mouse input focus.

See also
requestModalMouseInputFocus, isModalMouseInputFocused

Definition at line 401 of file widget.cpp.

402 {
403  if (mFocusHandler == nullptr)
404  return;
406 }
void releaseModalMouseInputFocus(const Widget *const widget)

References mFocusHandler, and FocusHandler::releaseModalMouseInputFocus().

◆ removeActionListener()

void Widget::removeActionListener ( ActionListener *const  actionListener)

Removes an added action listener from the widget.

Parameters
actionListenerThe action listener to remove.
See also
addActionListener

Definition at line 257 of file widget.cpp.

258 {
259  mActionListeners.remove(actionListener);
260 }

References mActionListeners.

Referenced by GuiTableActionListener::~GuiTableActionListener().

◆ removeDeathListener()

void Widget::removeDeathListener ( WidgetDeathListener *const  deathListener)

Removes an added death listener from the widget.

Parameters
deathListenerThe death listener to remove.
See also
addDeathListener

Definition at line 267 of file widget.cpp.

268 {
269  mDeathListeners.remove(deathListener);
270 }

References mDeathListeners.

◆ removeFocusListener()

void Widget::removeFocusListener ( FocusListener *const  focusListener)

Removes an added focus listener from the widget.

Parameters
focusListenerThe focus listener to remove.
See also
addFocusListener

Definition at line 287 of file widget.cpp.

288 {
289  mFocusListeners.remove(focusListener);
290 }

References mFocusListeners.

Referenced by PopupList::~PopupList().

◆ removeKeyListener()

void Widget::removeKeyListener ( KeyListener *const  keyListener)

Removes an added key listener from the widget.

Parameters
keyListenerThe key listener to remove.
See also
addKeyListener

Definition at line 277 of file widget.cpp.

278 {
279  mKeyListeners.remove(keyListener);
280 }

References mKeyListeners.

Referenced by CharacterViewNormal::~CharacterViewNormal(), CharacterViewSmall::~CharacterViewSmall(), and PopupList::~PopupList().

◆ removeMouseListener()

void Widget::removeMouseListener ( MouseListener *const  mouseListener)

Removes an added mouse listener from the widget.

Parameters
mouseListenerThe mouse listener to remove.
See also
addMouseListener

Definition at line 297 of file widget.cpp.

298 {
299  mMouseListeners.remove(mouseListener);
300 }

References mMouseListeners.

Referenced by Label::~Label().

◆ removeWidgetListener()

void Widget::removeWidgetListener ( WidgetListener *const  widgetListener)

Removes an added widget listener from the widget.

Parameters
widgetListenerThe widget listener to remove.
See also
addWidgetListener

Definition at line 307 of file widget.cpp.

308 {
309  mWidgetListeners.remove(widgetListener);
310 }

References mWidgetListeners.

Referenced by Button::setWindow(), CheckBox::setWindow(), Label::setWindow(), RadioButton::setWindow(), TextField::setWindow(), Button::~Button(), CheckBox::~CheckBox(), Label::~Label(), LayoutHelper::~LayoutHelper(), Pincode::~Pincode(), RadioButton::~RadioButton(), TextField::~TextField(), and Window::~Window().

◆ requestFocus()

void Widget::requestFocus ( )
virtual

Requests focus for the widget. A widget will only recieve focus if it is focusable.

Reimplemented in GuiTable, and CharacterDisplay.

Definition at line 204 of file widget.cpp.

205 {
206  if (mFocusHandler == nullptr)
207  return;
208 
209  if (isFocusable())
211 }
void requestFocus(const Widget *const widget)
bool isFocusable() const
Definition: widget.cpp:199

References isFocusable(), mFocusHandler, and FocusHandler::requestFocus().

Referenced by EditServerDialog::action(), WrongDataNoticeListener::action(), ChangeEmailDialog::ChangeEmailDialog(), ChangePasswordDialog::ChangePasswordDialog(), PincodeManager::changePincode(), CharCreateDialog::CharCreateDialog(), DropDown::dropDown(), UpdaterWindow::enable(), ChatInput::focusLost(), Client::focusWindow(), Gui::handleMousePressed(), BuySellDialog::init(), TabbedArea::mousePressed(), OkDialog::OkDialog(), NpcDialog::parseListItems(), CharSelectDialog::postInit(), ConfirmDialog::postInit(), EditDialog::postInit(), EditServerDialog::postInit(), LoginDialog::postInit(), NpcDialog::postInit(), PincodeDialog::postInit(), QuitDialog::postInit(), RegisterDialog::postInit(), ServerDialog::postInit(), TextDialog::postInit(), UpdaterWindow::postInit(), WorldSelectDialog::postInit(), ChatWindow::requestChatFocus(), GuiTable::requestFocus(), PincodeManager::setNewPincode(), SellDialog::setVisible(), BuyDialog::setVisible(), BuySellDialog::setVisible(), TextSelectDialog::setVisible(), and PincodeManager::updateState().

◆ requestModalFocus()

void Widget::requestModalFocus ( )

Requests modal focus. When a widget has modal focus, only that widget and it's children may recieve input.

Exceptions
Exceptionif another widget already has modal focus.
See also
releaseModalFocus, isModalFocused

Definition at line 380 of file widget.cpp.

381 {
382  if (mFocusHandler == nullptr)
383  return;
385 }
void requestModalFocus(Widget *const widget)

References mFocusHandler, and FocusHandler::requestModalFocus().

Referenced by PincodeDialog::postInit(), QuitDialog::postInit(), TextDialog::postInit(), Window::setModal(), PopupList::show(), and Window::Window().

◆ requestModalMouseInputFocus()

void Widget::requestModalMouseInputFocus ( )
virtual

Requests modal mouse input focus. When a widget has modal input focus that widget will be the only widget receiving input even if the input occurs outside of the widget and no matter what the input is.

Exceptions
Exceptionif another widget already has modal focus.
See also
releaseModalMouseInputFocus, isModalMouseInputFocused

Definition at line 387 of file widget.cpp.

388 {
389  if (mFocusHandler == nullptr)
390  return;
392 }
void requestModalMouseInputFocus(Widget *const widget)

References mFocusHandler, and FocusHandler::requestModalMouseInputFocus().

◆ requestMoveToBottom()

void Widget::requestMoveToBottom ( )
virtual

Requests a move to the bottom in the parent widget.

Definition at line 219 of file widget.cpp.

220 {
221  if (mParent != nullptr)
222  mParent->moveToBottom(this);
223 }
virtual void moveToBottom(Widget *widget)
Definition: widget.h:877

References moveToBottom(), and mParent.

Referenced by Game::Game().

◆ requestMoveToTop()

void Widget::requestMoveToTop ( )
virtual

◆ safeDraw()

virtual void Widget::safeDraw ( Graphics *const  graphics)
pure virtual

◆ safeDrawFrame()

virtual void Widget::safeDrawFrame ( Graphics graphics)
inlinevirtual

Reimplemented in TextField, ScrollArea, PlayerBox, and DropDown.

Definition at line 152 of file widget.h.

153  { }

◆ setActionEventId()

void Widget::setActionEventId ( const std::string &  actionEventId)
inline

Sets the action event identifier of the widget. The identifier is used to be able to identify which action has occured.

NOTE: An action event identifier should not be used to identify a certain widget but rather a certain event in your application. Several widgets can have the same action event identifer.

Parameters
actionEventIdThe action event identifier.
See also
getActionEventId

Definition at line 596 of file widget.h.

597  { mActionEventId = actionEventId; }

References mActionEventId.

Referenced by Setup_Video::action(), ConfirmDialog::action(), OkDialog::action(), PincodeDialog::action(), TextDialog::action(), WidgetGroup::addButton(), SkillDialog::addDefaultTab(), CharSelectDialog::askPasswordForDeletion(), Button::Button(), ChangeEmailDialog::ChangeEmailDialog(), ChangePasswordDialog::ChangePasswordDialog(), PincodeManager::changePincode(), CharacterDisplay::CharacterDisplay(), CharCreateDialog::CharCreateDialog(), ChatWindow::ChatWindow(), CheckBox::CheckBox(), MiniStatusWindow::createBar(), SetupItemIntTextField::createControls(), SetupItemDropDown::createControls(), SetupItemDropDownStr::createControls(), SetupItemSlider::createControls(), SetupItemSlider2::createControls(), SetupActionDropDown::createControls(), NpcDialog::createSkinControls(), DropDown::DropDown(), EquipmentWindow::EquipmentWindow(), PopupMenu::handleLink(), BuyDialog::init(), InventoryWindow::InventoryWindow(), SocialGuildTab::invite(), SocialPartyTab::invite(), ItemAmountWindow::ItemAmountWindow(), SkillDialog::loadXmlFile(), LoginDialog::LoginDialog(), NpcDialog::NpcDialog(), OutfitWindow::OutfitWindow(), PincodeDialog::PincodeDialog(), SellDialog::postInit(), EmoteWindow::postInit(), EquipmentWindow::postInit(), TextSelectDialog::postInit(), SliderList::postInit2(), QuestsWindow::QuestsWindow(), RegisterDialog::RegisterDialog(), PincodeManager::setNewPincode(), TradeWindow::setStatus(), Setup_Colors::Setup_Colors(), Setup_Input::Setup_Input(), Setup_Joystick::Setup_Joystick(), Setup_Relations::Setup_Relations(), Setup_Theme::Setup_Theme(), Setup_Video::Setup_Video(), ShopWindow::ShopWindow(), TextCommandEditor::TextCommandEditor(), TextField::TextField(), SocialWindow::updateMenu(), PincodeManager::updateState(), SkillDialog::useSkillDefault(), SkillDialog::useSkillPosition(), and SkillDialog::useSkillTarget().

◆ setBackgroundColor()

void Widget::setBackgroundColor ( const Color color)
inline

Sets the background color.

Parameters
colorThe background Color.
See also
setBackgroundColor

Definition at line 425 of file widget.h.

426  { mBackgroundColor = color; }

References mBackgroundColor.

Referenced by Setup_Relations::Setup_Relations().

◆ setBaseColor()

void Widget::setBaseColor ( const Color color)
inline

Sets the base color of the widget.

Parameters
colorThe baseground color.
See also
getBaseColor

Definition at line 390 of file widget.h.

391  { mBaseColor = color; }

References mBaseColor.

◆ setDimension()

void Widget::setDimension ( const Rect dimension)

Sets the dimension of the widget. The dimension is relative to the widget's parent.

Parameters
dimensionThe dimension of the widget.
See also
getDimension, setX, getX, setY, getY, setPosition

Definition at line 169 of file widget.cpp.

170 {
171  const Rect oldDimension = mDimension;
172  mDimension = dimension;
173 
174  if (mDimension.width != oldDimension.width
175  || mDimension.height != oldDimension.height)
176  {
178  }
179 
180  if (mDimension.x != oldDimension.x || mDimension.y != oldDimension.y)
182 }
void distributeMovedEvent()
Definition: widget.cpp:475
void distributeResizedEvent()
Definition: widget.cpp:466

References distributeMovedEvent(), distributeResizedEvent(), Rect::height, mDimension, Rect::width, Rect::x, and Rect::y.

Referenced by CharCreateDialog::CharCreateDialog(), ClanWindow::ClanWindow(), GuiTable::draw(), EquipmentWindow::EquipmentWindow(), InfoClanTab::InfoClanTab(), MapDebugTab::MapDebugTab(), Window::mouseDragged(), NetDebugTab::NetDebugTab(), WhoIsOnline::postInit(), LayoutCell::reflow(), DebugTab::resize(), GuiTable::safeDraw(), ScrollArea::setDimension(), TabbedArea::setDimension(), setHeight(), setPosition(), setSize(), Setup_Audio::Setup_Audio(), Setup_Chat::Setup_Chat(), Setup_Colors::Setup_Colors(), Setup_Input::Setup_Input(), Setup_Joystick::Setup_Joystick(), Setup_Misc::Setup_Misc(), Setup_Mods::Setup_Mods(), Setup_Perfomance::Setup_Perfomance(), Setup_Players::Setup_Players(), Setup_Quick::Setup_Quick(), Setup_Relations::Setup_Relations(), Setup_Theme::Setup_Theme(), Setup_Touch::Setup_Touch(), Setup_Video::Setup_Video(), Setup_Visual::Setup_Visual(), setWidth(), setX(), setY(), StatDebugTab::StatDebugTab(), TargetDebugTab::TargetDebugTab(), WindowMenu::updateButtons(), EquipmentWindow::updatePage(), and WindowMenu::WindowMenu().

◆ setEnabled()

void Widget::setEnabled ( const bool  enabled)
inline

Sets the widget to enabled, or not. A disabled widget will never recieve mouse or key events.

Parameters
enabledTrue if widget should be enabled, false otherwise.
See also
isEnabled

Definition at line 352 of file widget.h.

353  { mEnabled = enabled; }

References mEnabled.

Referenced by Setup_Input::action(), Setup_Video::action(), BuyDialog::action(), ChangeEmailDialog::action(), ChangePasswordDialog::action(), CharCreateDialog::action(), EditServerDialog::action(), RegisterDialog::action(), SkillDialog::action(), TradeWindow::action(), WhoIsOnline::action(), WorldSelectDialog::action(), ShopWindow::announce(), Setup_Video::apply(), Setup_Video::cancel(), ServerDialog::connectToSelectedServer(), UpdaterWindow::enable(), MailEditWindow::focusLost(), BuyDialog::init(), IntTextField::IntTextField(), LoginDialog::keyPressed(), RegisterDialog::keyPressed(), MailEditWindow::MailEditWindow(), Setup_Input::newKeyCallback(), PincodeDialog::PincodeDialog(), SellDialog::postInit(), EquipmentWindow::postInit(), LoginDialog::postInit(), RegisterDialog::postInit(), TextSelectDialog::postInit(), WhoIsOnline::postInit(), LoginDialog::prepareUpdate(), MailWindow::refreshMails(), TradeWindow::reset(), NpcSellDialog::sellManyItems(), SetupWindow::setInGame(), MailWindow::setLastPage(), CharSelectDialog::setLocked(), EquipmentWindow::setSelected(), TradeWindow::setStatus(), Setup_Joystick::setTempEnabled(), MailEditWindow::setTo(), Setup_Colors::Setup_Colors(), Setup_Input::Setup_Input(), Setup_Joystick::Setup_Joystick(), Setup_Video::Setup_Video(), SkillDialog::SkillDialog(), WhoIsOnline::slowLogic(), CharCreateDialog::unlock(), ChangeDisplay::update(), TabbedArea::updateArrowEnableState(), PincodeDialog::updateButtons(), InventoryWindow::updateButtons(), SellDialog::updateButtonsAndLabels(), BuyDialog::updateButtonsAndLabels(), ShopWindow::updateButtonsAndLabels(), TextSelectDialog::updateButtonsAndLabels(), Setup_Colors::updateGradType(), Setup_Theme::updateInfo(), UpdaterWindow::UpdaterWindow(), CharCreateDialog::updateSliders(), CharSelectDialog::updateState(), SkillDialog::updateTabSelection(), ShopWindow::updateTimes(), MailEditWindow::validatedTo(), Setup_Colors::valueChanged(), ServerDialog::valueChanged(), and WorldSelectDialog::WorldSelectDialog().

◆ setFocusable()

void Widget::setFocusable ( const bool  focusable)

◆ setFocusHandler()

void Widget::setFocusHandler ( FocusHandler *const  focusHandler)
virtual

Sets the focus handler to be used.

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

Parameters
focusHandlerThe focus handler to use.
See also
getFocusHandler

Reimplemented in GuiTable, and BasicContainer.

Definition at line 238 of file widget.cpp.

239 {
240  if (mFocusHandler != nullptr)
241  {
243  mFocusHandler->remove(this);
244  }
245 
246  if (focusHandler != nullptr)
247  focusHandler->add(this);
248 
249  mFocusHandler = focusHandler;
250 }
void add(Widget *const widget)
void remove(Widget *const widget)
virtual void releaseModalFocus()
Definition: widget.cpp:394

References FocusHandler::add(), mFocusHandler, releaseModalFocus(), and FocusHandler::remove().

Referenced by BasicContainer::setFocusHandler(), GuiTable::setFocusHandler(), Gui::setTop(), and ~Widget().

◆ setFont()

void Widget::setFont ( Font *const  font)

Sets the font for the widget. If NULL is passed, the global font will be used.

Parameters
fontThe font to set for the widget.
See also
getFont

Definition at line 349 of file widget.cpp.

350 {
351  mCurrentFont = font;
352  fontChanged();
353 }
virtual void fontChanged()
Definition: widget.h:667

References fontChanged(), and mCurrentFont.

Referenced by BeingPopup::BeingPopup(), NpcDialog::createSkinControls(), DidYouKnowWindow::DidYouKnowWindow(), HelpWindow::HelpWindow(), ItemPopup::ItemPopup(), NpcDialog::NpcDialog(), ServerInfoWindow::ServerInfoWindow(), Tab::setLabelFont(), Setup_Input::Setup_Input(), BeingPopup::show(), SkillPopup::SkillPopup(), SpeechBubble::SpeechBubble(), and SpellPopup::SpellPopup().

◆ setForegroundColor()

void Widget::setForegroundColor ( const Color color)
inline

Sets the foreground color.

Parameters
colorThe foreground color.
See also
getForegroundColor

Definition at line 408 of file widget.h.

409  { mForegroundColor = color; }

References mForegroundColor.

◆ setFrameSize()

void Widget::setFrameSize ( const unsigned int  frameSize)
inline

Sets the size of the widget's frame. The frame is not considered a part of the widget, it only allows a frame to be drawn around the widget, thus a frame will never be included when calculating if a widget should receive events from user input. Also a widget's frame will never be included when calculating a widget's position.

A frame size of 0 means that the widget has no frame. The default frame size is 0.

Parameters
frameSizeThe size of the widget's frame.
See also
getFrameSize, drawFrame

Definition at line 168 of file widget.h.

169  { mFrameSize = frameSize; }

References mFrameSize.

Referenced by Button::init(), Slider::init(), Tab::init(), PlayerBox::init(), ScrollArea::setOpaque(), TextBox::TextBox(), TextField::TextField(), and Window::Window().

◆ setGlobalFont()

void Widget::setGlobalFont ( Font *const  font)
static

Sets the global font to be used by default for all widgets.

Parameters
fontThe global font.
See also
getGlobalFont

Definition at line 338 of file widget.cpp.

339 {
340  mGlobalFont = font;
341 
342  FOR_EACH (std::list<Widget*>::const_iterator, iter, mAllWidgets)
343  {
344  if ((*iter)->mCurrentFont == nullptr)
345  (*iter)->fontChanged();
346  }
347 }

References FOR_EACH, mAllWidgets, and mGlobalFont.

Referenced by Gui::postInit().

◆ setHeight()

void Widget::setHeight ( const int  height)

Sets the height of the widget.

Parameters
heightThe height of the widget.
See also
getHeight, setWidth, getWidth, setSize, setDimension, getDimension

Definition at line 140 of file widget.cpp.

141 {
142  Rect newDimension = mDimension;
143  newDimension.height = height;
144  setDimension(newDimension);
145 }
void setDimension(const Rect &dimension)
Definition: widget.cpp:169

References Rect::height, mDimension, and setDimension().

Referenced by VertContainer::add2(), BrowserBox::addRow(), DropDown::adjustHeight(), ItemContainer::adjustHeight(), TextField::adjustHeight(), Button::adjustSize(), CheckBox::adjustSize(), ColorPage::adjustSize(), ExtendedListBox::adjustSize(), Label::adjustSize(), ListBox::adjustSize(), RadioButton::adjustSize(), ShopListBox::adjustSize(), TextBox::adjustSize(), TextPreview::adjustSize(), CharacterDisplay::CharacterDisplay(), CharacterViewNormal::CharacterViewNormal(), CharacterViewSmall::CharacterViewSmall(), CharCreateDialog::CharCreateDialog(), BrowserBox::clearRows(), StaticBrowserBox::clearRows(), ColorPage::ColorPage(), SetupItemSlider::createControls(), SetupItemSlider2::createControls(), NpcDialog::createSkinControls(), BrowserBox::draw(), SkillRectangleListBox::draw(), DropDown::DropDown(), HorizontContainer::HorizontContainer(), ItemAmountWindow::ItemAmountWindow(), Label::Label(), ScrollArea::logic(), NpcDialog::logic(), NpcDialog::NpcDialog(), EmoteWindow::postInit(), ProgressBar::ProgressBar(), GuiTable::recomputeDimensions(), Label::resizeTo(), Window::saveWindowState(), ScrollArea::setHeight(), TabbedArea::setHeight(), Minimap::setMap(), TextPopup::show(), NpcDialog::showAvatar(), SkillRectangleListBox::SkillRectangleListBox(), SliderList::SliderList(), TextCommandEditor::TextCommandEditor(), StatusPopup::update(), BrowserBox::updateHeight(), WidgetGroup::WidgetGroup(), FlowContainer::widgetResized(), and ShortcutContainer::widgetResized().

◆ setId()

void Widget::setId ( const std::string &  id)
inline

Sets an id of a widget. An id can be useful if a widget needs to be identified in a container. For example, if widgets are created by an XML document, a certain widget can be retrieved given that the widget has an id.

Parameters
idThe id to set to the widget.
See also
getId

Definition at line 916 of file widget.h.

917  { mId = id; }

References mId.

Referenced by MiniStatusWindow::createBar().

◆ setInternalFocusHandler()

void Widget::setInternalFocusHandler ( FocusHandler *const  internalFocusHandler)

Sets the internal focus handler. An internal focus handler is needed if both a widget in the widget and the widget itself should be foucsed at the same time.

Parameters
focusHandlerThe internal focus handler to be used.
See also
getInternalFocusHandler

Definition at line 461 of file widget.cpp.

462 {
463  mInternalFocusHandler = focusHandler;
464 }

References mInternalFocusHandler.

Referenced by BasicContainer::setInternalFocusHandler().

◆ setMouseConsume()

void Widget::setMouseConsume ( const bool  b)
inline

Definition at line 936 of file widget.h.

937  { mMouseConsume = b; }

References mMouseConsume.

Referenced by PopupList::PopupList().

◆ setParent()

virtual void Widget::setParent ( Widget parent)
inlinevirtual

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 in TextField, RadioButton, CheckBox, Button, and Label.

Definition at line 626 of file widget.h.

627  { mParent = parent; }

References mParent.

Referenced by Label::setParent(), Button::setParent(), CheckBox::setParent(), RadioButton::setParent(), TextField::setParent(), and GuiTableActionListener::~GuiTableActionListener().

◆ setPosition()

void Widget::setPosition ( const int  x,
const int  y 
)

Sets position of the widget. The position is relative to the widget's parent.

Parameters
xThe x coordinate of the widget.
yThe y coordinate of the widget.
See also
setX, getX, setY, getY, setDimension, getDimension

Definition at line 161 of file widget.cpp.

162 {
163  Rect newDimension = mDimension;
164  newDimension.x = x;
165  newDimension.y = y;
166  setDimension(newDimension);
167 }

References mDimension, setDimension(), Rect::x, x, Rect::y, and y.

Referenced by HorizontContainer::add(), VertContainer::add2(), WindowMenu::addButton(), Pincode::addButtons(), BeingPopup::addLabels(), ShortcutWindow::addTab(), WidgetGroup::addWidget(), BasicContainer2::addXY(), TabbedArea::adjustSize(), TabbedArea::adjustTabPositions(), ChatWindow::adjustTabSize(), BeingPopup::BeingPopup(), ChangeEmailDialog::ChangeEmailDialog(), CharCreateDialog::CharCreateDialog(), ChatWindow::ChatWindow(), NpcDialog::createSkinControls(), Tab::init(), BuySellDialog::init(), ItemPopup::ItemPopup(), Window::loadWindowState(), ScrollArea::logic(), Window::mouseDragged(), ChatWindow::mouseDragged(), ShortcutWindow::mouseDragged(), Client::moveButtons(), OkDialog::OkDialog(), PopupList::PopupList(), Popup::position(), TextPopup::postInit(), ConfirmDialog::postInit(), EditDialog::postInit(), EmoteWindow::postInit(), EquipmentWindow::postInit(), SetupWindow::postInit(), Window::resetToDefaultSize(), CharacterViewSmall::resize(), SliderList::resize(), CharCreateDialog::setButtonsPosition(), ScrollArea::setContent(), ItemPopup::setItem(), SpellPopup::setItem(), Window::setLocationHorisontallyRelativeTo(), Popup::setLocationRelativeTo(), Window::setLocationRelativeTo(), SpeechBubble::setText(), ShortcutWindow::ShortcutWindow(), TextBoxPopup::show(), TextPopup::show(), SkillPopup::show(), CutInWindow::show(), PopupList::show(), PopupMenu::showPopup(), SkillPopup::SkillPopup(), MiniStatusWindow::updateBars(), WindowMenu::updateButtons(), StatsClanTab::updateClan(), RelationClanTab::updateClan(), SliderList::updateLabel(), Game::videoResized(), SpellPopup::view(), StatusPopup::view(), TabbedArea::widgetResized(), and SetupWindow::widgetResized().

◆ setRedraw()

void Widget::setRedraw ( const bool  b)
inline

Definition at line 942 of file widget.h.

943  { mRedraw = b; }

References mRedraw.

Referenced by ShortcutWindow::widgetMoved().

◆ setSelectable()

void Widget::setSelectable ( const bool  selectable)
inline

◆ setSize()

void Widget::setSize ( const int  width,
const int  height 
)

◆ setTabInEnabled()

void Widget::setTabInEnabled ( const bool  enabled)
inline

Sets tab in enabled, or not. Tab in means that you can set focus to this widget by pressing the tab button. If tab in is disabled then the FocusHandler will skip this widget and focus the next in its focus order.

Parameters
enabledTrue if tab in should be enabled, false otherwise.
See also
isTabInEnabled

Definition at line 700 of file widget.h.

701  { mTabIn = enabled; }

References mTabIn.

◆ setTabOutEnabled()

void Widget::setTabOutEnabled ( const bool  enabled)
inline

Sets tab out enabled. Tab out means that you can lose focus to this widget by pressing the tab button. If tab out is disabled then the FocusHandler ignores tabbing and focus will stay with this widget.

Parameters
enabledTrue if tab out should be enabled, false otherwise.
See also
isTabOutEnabled

Definition at line 724 of file widget.h.

725  { mTabOut = enabled; }

References mTabOut.

◆ setVisible()

void Widget::setVisible ( Visible  visible)

Sets the widget to be visible, or not.

Parameters
visibleTrue if widget should be visible, false otherwise.
See also
isVisible

Definition at line 225 of file widget.cpp.

226 {
227  if (visible == Visible_false && isFocused() && (mFocusHandler != nullptr))
229 
230  if (visible == Visible_true)
232  else
234 
235  mVisible = visible;
236 }
void distributeHiddenEvent()
Definition: widget.cpp:484
void distributeShownEvent()
Definition: widget.cpp:502
const bool Visible_false
Definition: visible.h:30

References distributeHiddenEvent(), distributeShownEvent(), FocusHandler::focusNone(), isFocused(), mFocusHandler, mVisible, Visible_false, and Visible_true.

Referenced by ChatWindow::action(), LoginDialog::action(), SkillDialog::addDefaultTab(), SkillDialog::addSkill(), ChatWindow::adjustTabSize(), CharacterViewNormal::CharacterViewNormal(), CharacterViewSmall::CharacterViewSmall(), CharCreateDialog::CharCreateDialog(), CharSelectDialog::CharSelectDialog(), ChatWindow::ChatWindow(), PopupList::focusGained(), ItemLinkHandler::handleItemLink(), PopupMenu::handleLink(), Popup::hide(), PopupManager::hideBeingPopup(), DropDown::hideDrop(), PopupManager::hidePopupMenu(), PopupManager::hideTextPopup(), MiniStatusWindow::loadBars(), WindowMenu::loadButtons(), SkillDialog::loadXmlFile(), LoginDialog::LoginDialog(), CharacterDisplay::mouseExited(), EmoteShortcutContainer::mouseExited(), ItemContainer::mouseExited(), ItemShortcutContainer::mouseExited(), SpellShortcutContainer::mouseExited(), VirtShortcutContainer::mouseExited(), EquipmentWindow::mouseExited(), ItemAmountWindow::mouseExited(), ItemPopup::mouseMoved(), SkillPopup::mouseMoved(), SpellPopup::mouseMoved(), TextBoxPopup::mouseMoved(), TextPopup::mouseMoved(), CharacterDisplay::mouseMoved(), EmoteShortcutContainer::mouseMoved(), ItemContainer::mouseMoved(), ItemShortcutContainer::mouseMoved(), ShopListBox::mouseMoved(), SpellShortcutContainer::mouseMoved(), VirtShortcutContainer::mouseMoved(), EquipmentWindow::mouseMoved(), EquipmentWindow::mousePressed(), PopupList::mouseReleased(), NpcDialog::NpcDialog(), Popup::Popup(), Popup::position(), MailViewWindow::removeMoney(), CharCreateDialog::setAttributes(), EquipmentWindow::setSelected(), Window::setVisible(), ChatInput::setVisible(), CharacterViewSmall::show(), BeingPopup::show(), TextBoxPopup::show(), TextPopup::show(), PopupList::show(), MiniStatusWindow::showBar(), PopupMenu::showChangePos(), TextCommandEditor::showControls(), PopupMenu::showPopup(), TabbedArea::updateArrowEnableState(), MailViewWindow::updateAttachButton(), EquipmentWindow::updatePage(), Setup_Colors::valueChanged(), SpellPopup::view(), StatusPopup::view(), CharacterDisplay::widgetHidden(), EmoteShortcutContainer::widgetHidden(), ItemShortcutContainer::widgetHidden(), SpellShortcutContainer::widgetHidden(), VirtShortcutContainer::widgetHidden(), InventoryWindow::widgetHidden(), InventoryWindow::widgetResized(), and WindowMenu::WindowMenu().

◆ setWidth()

void Widget::setWidth ( const int  width)

Sets the width of the widget.

Parameters
widthThe width of the widget.
See also
getWidth, setHeight, getHeight, setSize, setDimension, getDimensi

Definition at line 133 of file widget.cpp.

134 {
135  Rect newDimension = mDimension;
136  newDimension.width = width;
137  setDimension(newDimension);
138 }

References mDimension, setDimension(), and Rect::width.

Referenced by StaticBrowserBox::addRow(), Button::adjustSize(), CheckBox::adjustSize(), Label::adjustSize(), PopupList::adjustSize(), RadioButton::adjustSize(), SliderList::adjustSize(), TextBox::adjustSize(), TextField::adjustSize(), ChatWindow::adjustTabSize(), AvatarListBox::AvatarListBox(), BrowserBox::calcHeight(), ChangeEmailDialog::ChangeEmailDialog(), CharacterDisplay::CharacterDisplay(), CharacterViewNormal::CharacterViewNormal(), CharCreateDialog::CharCreateDialog(), CharSelectDialog::CharSelectDialog(), BrowserBox::clearRows(), StaticBrowserBox::clearRows(), SetupItemTextField::createControls(), SetupItemIntTextField::createControls(), SetupItemDropDown::createControls(), SetupItemDropDownStr::createControls(), SetupItemSlider::createControls(), SetupItemSlider2::createControls(), SetupActionDropDown::createControls(), NpcDialog::createSkinControls(), SkillRectangleListBox::draw(), AvatarListBox::draw(), DropDown::dropDown(), DropDown::DropDown(), SetupItem::fixFirstItemSize(), BuyDialog::init(), IntTextField::IntTextField(), ItemAmountWindow::ItemAmountWindow(), Label::Label(), ListBox::ListBox(), ScrollArea::logic(), NpcDialog::logic(), MailEditWindow::MailEditWindow(), NpcDialog::NpcDialog(), SellDialog::postInit(), EditDialog::postInit(), EmoteWindow::postInit(), QuestsWindow::QuestsWindow(), EquipmentWindow::recalcSize(), GuiTable::recomputeDimensions(), SliderList::resize(), Label::resizeTo(), AvatarListBox::safeDraw(), Window::saveWindowState(), ItemPopup::setItem(), Minimap::setMap(), Setup_Colors::Setup_Colors(), Setup_Video::Setup_Video(), ScrollArea::setWidth(), TabbedArea::setWidth(), TextPopup::show(), NpcDialog::showAvatar(), PopupMenu::showPopup(), SkillRectangleListBox::SkillRectangleListBox(), TextCommandEditor::TextCommandEditor(), TradeWindow::TradeWindow(), StatusPopup::update(), WhoIsOnline::updateSize(), and FlowContainer::widgetResized().

◆ setX()

void Widget::setX ( const int  x)

Sets the x coordinate of the widget. The coordinate is relateive to the widget's parent.

Parameters
xThe x coordinate of the widget.
See also
getX, setY, getY, setPosition, setDimension, getDimension

Definition at line 147 of file widget.cpp.

148 {
149  Rect newDimension = mDimension;
150  newDimension.x = x;
151  setDimension(newDimension);
152 }

References mDimension, setDimension(), Rect::x, and x.

◆ setY()

void Widget::setY ( const int  y)

Sets the y coordinate of the widget. The coordinate is relative to the widget's parent.

Parameters
yThe y coordinate of the widget.
See also
setY, setX, getX, setPosition, setDimension, getDimension

Definition at line 154 of file widget.cpp.

155 {
156  Rect newDimension = mDimension;
157  newDimension.y = y;
158  setDimension(newDimension);
159 }

References mDimension, setDimension(), Rect::y, and y.

◆ showPart()

void Widget::showPart ( const Rect rectangle)
virtual

Shows a certain part of a widget in the widget's parent. Used when widgets want a specific part to be visible in its parent. An example is a TextArea that wants a specific part of its text to be visible when a TextArea is a child of a ScrollArea.

Parameters
rectangleThe rectangle to be shown.

Definition at line 511 of file widget.cpp.

512 {
513  if (mParent != nullptr)
514  mParent->showWidgetPart(this, rectangle);
515 }
virtual void showWidgetPart(Widget *const widget, const Rect &area)
Definition: widget.h:903

References mParent, and showWidgetPart().

Referenced by ChatTab::scroll(), TextBox::scrollToCaret(), NpcSellDialog::sellOneItem(), and ListBox::setSelected().

◆ showWidgetPart()

virtual void Widget::showWidgetPart ( Widget *const  widget,
const Rect area 
)
inlinevirtual

Tries to show a specific part of a widget by moving it. Used if the widget should act as a container.

Parameters
widgetThe target widget.
areaThe area to show.

Reimplemented in ScrollArea, and BasicContainer.

Definition at line 903 of file widget.h.

905  { }

Referenced by showPart().

◆ widgetExists()

bool Widget::widgetExists ( const Widget *const  widget)
static

Checks if a widget exists or not, that is if it still exists an instance of the object.

Parameters
widgetThe widget to check.
Returns
True if an instance of the widget exists, false otherwise.

Definition at line 361 of file widget.cpp.

362 {
363  return mAllWidgetsSet.find(const_cast<Widget*>(widget))
364  != mAllWidgetsSet.end();
365 }
Definition: widget.h:99

References mAllWidgetsSet.

Referenced by Gui::distributeKeyEvent(), Gui::distributeMouseEvent(), PopupMenu::handleLink(), Gui::handleModalFocusGained(), Gui::handleModalFocusReleased(), Gui::handleMouseMoved(), and Gui::~Gui().

◆ windowResized()

void Widget::windowResized ( )

Definition at line 517 of file widget.cpp.

518 {
519  mRedraw = true;
520 }

References mRedraw.

Friends And Related Function Documentation

◆ BasicContainer

friend class BasicContainer
friend

Definition at line 101 of file widget.h.

Field Documentation

◆ mActionEventId

std::string Widget::mActionEventId
protected

Holds the action event of the widget.

Definition at line 1106 of file widget.h.

Referenced by WidgetGroup::addButton(), distributeActionEvent(), getActionEventId(), PlayerBox::mouseReleased(), and setActionEventId().

◆ mActionListeners

ActionListenerList Widget::mActionListeners
protected

Holds the action listeners of the widget.

Definition at line 1034 of file widget.h.

Referenced by WidgetGroup::action(), EditDialog::action(), addActionListener(), distributeActionEvent(), and removeActionListener().

◆ mAllowLogic

bool Widget::mAllowLogic
protected

◆ mAllWidgets

std::list< Widget * > Widget::mAllWidgets
staticprivate

Holds a list of all instances of widgets.

Definition at line 1177 of file widget.h.

Referenced by distributeWindowResizeEvent(), setGlobalFont(), Widget(), and ~Widget().

◆ mAllWidgetsSet

std::set< Widget * > Widget::mAllWidgetsSet
staticprivate

Definition at line 1179 of file widget.h.

Referenced by Widget(), widgetExists(), and ~Widget().

◆ mBackgroundColor

Color Widget::mBackgroundColor
protected

◆ mBaseColor

Color Widget::mBaseColor
protected

Holds the base color of the widget.

Definition at line 1096 of file widget.h.

Referenced by BasicContainer2::draw(), getBaseColor(), BasicContainer2::safeDraw(), and setBaseColor().

◆ mCurrentFont

Font* Widget::mCurrentFont
protected

Holds the font used by the widget.

Definition at line 1133 of file widget.h.

Referenced by getFont(), and setFont().

◆ mDeathListeners

WidgetDeathListenerList Widget::mDeathListeners
protected

Holds the death listeners of the widget.

Definition at line 1049 of file widget.h.

Referenced by addDeathListener(), removeDeathListener(), and ~Widget().

◆ mDimension

Rect Widget::mDimension
protected

Holds the dimension of the widget.

Definition at line 1101 of file widget.h.

Referenced by VertContainer::add2(), Window::adjustPositionAfterResize(), PopupList::adjustSize(), TabbedArea::adjustSize(), Window::adjustSizeToScreen(), BrowserBox::calcHeight(), ScrollArea::calcHMarker(), ScrollArea::calcVMarker(), ClanWindow::ClanWindow(), DebugWindow::DebugWindow(), Icon::draw(), DebugWindow::draw(), BasicContainer2::draw(), BrowserBox::draw(), Button::draw(), ColorPage::draw(), Desktop::draw(), DropDown::draw(), EmotePage::draw(), ExtendedListBox::draw(), GuiTable::draw(), Label::draw(), ListBox::draw(), PlayerBox::draw(), Popup::draw(), ProgressBar::draw(), ProgressIndicator::draw(), ShopListBox::draw(), Slider::draw(), SliderList::draw(), StaticBrowserBox::draw(), Tab::draw(), TextPreview::draw(), Window::draw(), DropDown::drawButton(), DropDown::drawFrame(), PlayerBox::drawFrame(), ScrollArea::drawFrame(), TextField::drawFrame(), ScrollArea::drawHMarker(), ScrollArea::drawVMarker(), DropDown::dropDown(), Window::ensureOnScreen(), TextField::fixScroll(), getAbsolutePosition(), BasicContainer::getChildrenArea(), DropDown::getChildrenArea(), GuiTable::getChildrenArea(), Popup::getChildrenArea(), Window::getChildrenArea(), MiniStatusWindow::getChildrenArea(), getDimension(), ScrollArea::getDownButtonDimension(), getHeight(), ScrollArea::getHorizontalBarDimension(), ScrollArea::getHorizontalMarkerDimension(), EmotePage::getIndexFromGrid(), ScrollArea::getLeftButtonDimension(), Window::getResizeHandles(), ScrollArea::getRightButtonDimension(), ItemContainer::getSlotByXY(), ItemContainer::getSlotIndex(), ScrollArea::getUpButtonDimension(), ScrollArea::getVerticalBarDimension(), ScrollArea::getVerticalMarkerDimension(), getWidth(), Window::getWindowArea(), getX(), getY(), Window::loadWindowState(), ScrollArea::logic(), Slider::markerPositionToValue(), Slider::mouseDragged(), Window::mouseDragged(), WindowMenu::mouseMoved(), InventoryWindow::mouseMoved(), Minimap::mouseMoved(), MiniStatusWindow::mouseMoved(), Slider::mousePressed(), DropDown::mouseReleased(), Popup::position(), CharacterViewSmall::resize(), Icon::safeDraw(), DebugWindow::safeDraw(), BasicContainer2::safeDraw(), Button::safeDraw(), EmotePage::safeDraw(), GuiTable::safeDraw(), Popup::safeDraw(), ProgressBar::safeDraw(), ProgressIndicator::safeDraw(), Slider::safeDraw(), SliderList::safeDraw(), Tab::safeDraw(), Window::safeDraw(), DropDown::safeDrawFrame(), PlayerBox::safeDrawFrame(), ScrollArea::safeDrawFrame(), TextField::safeDrawFrame(), Window::saveWindowState(), Desktop::setBestFittingWallpaper(), Window::setDefaultSize(), setDimension(), setHeight(), Window::setLocationHorisontallyRelativeTo(), Popup::setLocationRelativeTo(), Window::setLocationRelativeTo(), Minimap::setMap(), setPosition(), Window::setResizable(), setSize(), Window::setVisible(), setWidth(), setX(), setY(), TextBoxPopup::show(), TextPopup::show(), PopupList::show(), TabbedArea::updateArrowEnableState(), BrowserBox::updateHeight(), StaticBrowserBox::updateHeight(), SliderList::updateLabel(), ItemContainer::updateSize(), Slider::valueToMarkerPosition(), SpellPopup::view(), ScrollArea::widgetResized(), ShortcutContainer::widgetResized(), TabbedArea::widgetResized(), Window::widgetResized(), ClanWindow::widgetResized(), DebugWindow::widgetResized(), and EmoteWindow::widgetResized().

◆ mEnabled

bool Widget::mEnabled
protected

True if the widget is enabled, false otherwise.

Definition at line 1158 of file widget.h.

Referenced by CheckBox::drawBox(), RadioButton::drawBox(), isEnabled(), and setEnabled().

◆ mFocusable

bool Widget::mFocusable
protected

True if the widget focusable, false otherwise.

Definition at line 1143 of file widget.h.

Referenced by isFocusable(), and setFocusable().

◆ mFocusHandler

FocusHandler* Widget::mFocusHandler
protected

◆ mFocusListeners

FocusListenerList Widget::mFocusListeners
protected

Holds the focus listeners of the widget.

Definition at line 1064 of file widget.h.

Referenced by addFocusListener(), getFocusListeners(), and removeFocusListener().

◆ mForegroundColor

Color Widget::mForegroundColor
protected

◆ mFrameSize

unsigned int Widget::mFrameSize
protected

◆ mGlobalFont

Font * Widget::mGlobalFont = 0
staticprotected

Holds the global font used by the widget.

Definition at line 1171 of file widget.h.

Referenced by cleanGlobalFont(), getFont(), getGloablFont(), and setGlobalFont().

◆ mId

std::string Widget::mId
protected

Holds the id of the widget.

Definition at line 1111 of file widget.h.

Referenced by getId(), and setId().

◆ mInternalFocusHandler

FocusHandler* Widget::mInternalFocusHandler
protected

Holds the focus handler used by the widget. NULL if no internal focus handler is used.

Definition at line 1122 of file widget.h.

Referenced by getInternalFocusHandler(), and setInternalFocusHandler().

◆ mKeyListeners

KeyListenerList Widget::mKeyListeners
protected

Holds the key listeners of the widget.

Definition at line 1019 of file widget.h.

Referenced by addKeyListener(), getKeyListeners(), and removeKeyListener().

◆ mMouseConsume

bool Widget::mMouseConsume
protected

◆ mMouseListeners

MouseListenerList Widget::mMouseListeners
protected

Holds the mouse listeners of the widget.

Definition at line 1009 of file widget.h.

Referenced by addMouseListener(), getMouseListeners(), and removeMouseListener().

◆ mParent

Widget* Widget::mParent
protected

◆ mRedraw

bool Widget::mRedraw
protected

Definition at line 1164 of file widget.h.

Referenced by Button::draw(), EmotePage::draw(), ItemContainer::draw(), Popup::draw(), ProgressBar::draw(), ScrollArea::draw(), Slider::draw(), Tab::draw(), Window::draw(), ShortcutContainer::drawBackground(), ScrollArea::drawFrame(), Popup::hide(), ProgressBar::logic(), ScrollArea::mouseDragged(), Slider::mouseEntered(), Slider::mouseExited(), Popup::mouseMoved(), ScrollArea::mouseReleased(), Popup::position(), ScrollArea::safeDraw(), ProgressBar::setBackgroundColor(), ItemContainer::setCellBackgroundImage(), Popup::setContentSize(), Tab::setFlash(), Tab::setFlashTabColor(), Tab::setHighlightedTabColor(), Tab::setLabelFont(), Popup::setLocationRelativeTo(), Tab::setPlayerFlashTabColor(), ProgressBar::setProgress(), ProgressBar::setProgressPalette(), setRedraw(), EquipmentWindow::setSelected(), Tab::setSelectedTabColor(), Window::setSticky(), Tab::setTabColor(), Slider::setValue(), ScrollArea::updateCalcFlag(), ItemContainer::updateMatrix(), EquipmentWindow::updatePage(), ItemContainer::updateSize(), Button::widgetHidden(), Window::widgetHidden(), Button::widgetMoved(), EmotePage::widgetMoved(), ItemContainer::widgetMoved(), Popup::widgetMoved(), ProgressBar::widgetMoved(), ScrollArea::widgetMoved(), ShortcutContainer::widgetMoved(), Tab::widgetMoved(), Window::widgetMoved(), Button::widgetResized(), EmotePage::widgetResized(), Popup::widgetResized(), ProgressBar::widgetResized(), ScrollArea::widgetResized(), ShortcutContainer::widgetResized(), Tab::widgetResized(), Window::widgetResized(), and windowResized().

◆ mSelectable

bool Widget::mSelectable
protected

Definition at line 1166 of file widget.h.

Referenced by isSelectable(), TextBox::setEditable(), and setSelectable().

◆ mTabIn

bool Widget::mTabIn
protected

True if the widget has tab in enabled, false otherwise.

Definition at line 1148 of file widget.h.

Referenced by isTabInEnabled(), and setTabInEnabled().

◆ mTabOut

bool Widget::mTabOut
protected

True if the widget has tab in enabled, false otherwise.

Definition at line 1153 of file widget.h.

Referenced by isTabOutEnabled(), and setTabOutEnabled().

◆ mVisible

Visible Widget::mVisible

◆ mWidgetListeners

WidgetListenerList Widget::mWidgetListeners
protected

Holds the widget listeners of the widget.

Definition at line 1076 of file widget.h.

Referenced by addWidgetListener(), distributeHiddenEvent(), distributeMovedEvent(), distributeResizedEvent(), distributeShownEvent(), and removeWidgetListener().


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