ManaPlus
Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes
BasicContainer Class Reference

#include <basiccontainer.h>

Inheritance diagram for BasicContainer:
Widget WidgetDeathListener Widget2 BasicContainer2 DropDown ScrollArea Tab TabbedArea Container Window ChatTab ShortcutTab SkillTab SocialTab AttrDisplay CharacterDisplay CharacterViewBase DebugTab Desktop FlowContainer HorizontContainer Popup SetupTab SliderList StatsPage StatsPageBasic VertContainer WidgetGroup WindowContainer WindowMenu BankWindow BuyDialog BuySellDialog ChangeEmailDialog ChangePasswordDialog CharCreateDialog CharSelectDialog ChatWindow ConfirmDialog ConnectionDialog CutInWindow DebugWindow DidYouKnowWindow EditDialog EditServerDialog EmoteWindow EquipmentWindow HelpWindow InventoryWindow ItemAmountWindow KillStats LoginDialog MailEditWindow MailViewWindow MailWindow Minimap MiniStatusWindow NpcDialog OkDialog OutfitWindow QuestsWindow QuitDialog RegisterDialog SellDialog ServerDialog ServerInfoWindow SetupWindow ShopWindow ShortcutWindow SkillDialog SocialWindow StatusWindow TextCommandEditor TextDialog TextSelectDialog TradeWindow UpdaterWindow WhoIsOnline WorldSelectDialog BattleTab ChannelTab EmulateGuildTab GmTab GuildTab LangTab PartyTab TradeTab WhisperTab SocialAttackTab SocialFriendsTab SocialGuildTab SocialGuildTab2 SocialNavigationTab SocialPartyTab SocialPickupTab SocialPlayersTab

Public Member Functions

 BasicContainer (const Widget2 *const widget)
 
virtual ~BasicContainer ()
 
void showWidgetPart (Widget *const widget, const Rect &area)
 
void moveToTop (Widget *const widget)
 
void moveToBottom (Widget *const widget)
 
Rect getChildrenArea ()
 
void focusNext ()
 
void focusPrevious ()
 
void logic ()
 
void setFocusHandler (FocusHandler *const focusHandler)
 
void setInternalFocusHandler (FocusHandler *const focusHandler)
 
WidgetgetWidgetAt (int x, int y)
 
void death (const Event &event)
 
WidgetfindFirstWidget (const std::set< Widget *> &list)
 
void add (Widget *const widget)
 
virtual void remove (Widget *const widget)
 
virtual void clear ()
 
- Public Member Functions inherited from Widget
 Widget (const Widget2 *const widget)
 
virtual ~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
 
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 ()
 
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
 
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 FocusHandlergetInternalFocusHandler ()
 
void setInternalFocusHandler (FocusHandler *const internalFocusHandler)
 
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=255U) 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)
 
- Public Member Functions inherited from WidgetDeathListener
virtual ~WidgetDeathListener ()
 

Protected Types

typedef std::vector< Widget * > WidgetList
 
typedef WidgetList::iterator WidgetListIterator
 
typedef WidgetList::const_iterator WidgetListConstIterator
 
typedef WidgetList::reverse_iterator WidgetListReverseIterator
 
typedef WidgetList::const_reverse_iterator WidgetListCReverseIterator
 
- 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

virtual void drawChildren (Graphics *const graphics)
 
virtual void safeDrawChildren (Graphics *const graphics)
 
virtual void logicChildren ()
 
- 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 WidgetDeathListener
 WidgetDeathListener ()
 

Protected Attributes

WidgetList mWidgets
 
WidgetList mLogicWidgets
 
- 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
 

Additional Inherited Members

- 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)
 
- Data Fields inherited from Widget
Visible mVisible
 
- Static Protected Attributes inherited from Widget
static FontmGlobalFont = 0
 

Detailed Description

A base class for containers. The class implements the most common things for a container. If you are implementing a container, consider inheriting from this class.

See also
Container

Definition at line 78 of file basiccontainer.h.

Member Typedef Documentation

◆ WidgetList

typedef std::vector<Widget *> BasicContainer::WidgetList
protected

Typedef.

Definition at line 183 of file basiccontainer.h.

◆ WidgetListConstIterator

typedef WidgetList::const_iterator BasicContainer::WidgetListConstIterator
protected

Typedef.

Definition at line 193 of file basiccontainer.h.

◆ WidgetListCReverseIterator

typedef WidgetList::const_reverse_iterator BasicContainer::WidgetListCReverseIterator
protected

Typedef.

Definition at line 203 of file basiccontainer.h.

◆ WidgetListIterator

typedef WidgetList::iterator BasicContainer::WidgetListIterator
protected

Typedef.

Definition at line 188 of file basiccontainer.h.

◆ WidgetListReverseIterator

typedef WidgetList::reverse_iterator BasicContainer::WidgetListReverseIterator
protected

Typedef.

Definition at line 198 of file basiccontainer.h.

Constructor & Destructor Documentation

◆ BasicContainer()

BasicContainer::BasicContainer ( const Widget2 *const  widget)
inlineexplicit

◆ ~BasicContainer()

BasicContainer::~BasicContainer ( )
virtual

Destructor

Definition at line 74 of file basiccontainer.cpp.

References clear().

Referenced by BasicContainer().

75 {
76  clear();
77 }
virtual void clear()

Member Function Documentation

◆ add()

void BasicContainer::add ( Widget *const  widget)

Adds a widget to the basic container.

Parameters
widgetThe widget to add.
See also
remove, clear

Definition at line 246 of file basiccontainer.cpp.

References Widget::getFocusHandler(), Widget::mInternalFocusHandler, mLogicWidgets, and mWidgets.

Referenced by BasicContainer2::add(), BasicContainer2::addXY(), BasicContainer(), TabbedArea::enableScrollButtons(), Tab::init(), TabbedArea::postInit(), and ScrollArea::setContent().

247 {
248  if (widget == nullptr)
249  return;
250  mWidgets.push_back(widget);
251  if (widget->isAllowLogic())
252  mLogicWidgets.push_back(widget);
253 
254  if (mInternalFocusHandler == nullptr)
255  widget->setFocusHandler(getFocusHandler());
256  else
258 
259  widget->setParent(this);
260  widget->addDeathListener(this);
261 }
FocusHandler * getFocusHandler()
Definition: widget.h:473
WidgetList mLogicWidgets
FocusHandler * mInternalFocusHandler
Definition: widget.h:1121
virtual void setParent(Widget *parent)
Definition: widget.h:625
WidgetList mWidgets
void addDeathListener(WidgetDeathListener *const deathListener)
Definition: widget.cpp:261
bool isAllowLogic() const
Definition: widget.h:932
virtual void setFocusHandler(FocusHandler *const focusHandler)
Definition: widget.cpp:237

◆ clear()

void BasicContainer::clear ( )
virtual

Clears the basic container from all widgets.

See also
remove, clear

Reimplemented in PopupMenu, TradeWindow, SetupTabScroll, MailWindow, HorizontContainer, VertContainer, and WidgetGroup.

Definition at line 289 of file basiccontainer.cpp.

References FOR_EACH, mLogicWidgets, mWidgets, and restrict.

Referenced by BasicContainer(), WidgetGroup::clear(), HorizontContainer::clear(), VertContainer::clear(), Window::clearLayout(), TabbedArea::removeTab(), ScrollArea::setContent(), and ~BasicContainer().

290 {
292  {
293  Widget *restrict const widget = *iter;
294  widget->setFocusHandler(nullptr);
295  widget->setWindow(nullptr);
296  widget->setParent(nullptr);
297  widget->removeDeathListener(this);
298  }
299 
300  mWidgets.clear();
301  mLogicWidgets.clear();
302 }
#define FOR_EACH(type, iter, array)
Definition: foreach.h:24
WidgetList::const_iterator WidgetListConstIterator
WidgetList mLogicWidgets
Definition: widget.h:97
#define restrict
Definition: localconsts.h:176
WidgetList mWidgets

◆ death()

void BasicContainer::death ( const Event event)
virtual

Called when a widget dies. It is used to be able to recieve a notification when a death of a widget occurs.

Parameters
eventThe event of the death.

Implements WidgetDeathListener.

Reimplemented in TabbedArea.

Definition at line 120 of file basiccontainer.cpp.

References AttributesEnum::find(), mLogicWidgets, and mWidgets.

Referenced by BasicContainer(), and TabbedArea::death().

121 {
122  const WidgetListIterator iter = std::find(mWidgets.begin(),
123  mWidgets.end(), event.getSource());
124  if (iter != mWidgets.end())
125  mWidgets.erase(iter);
126 
127  const WidgetListIterator iter2 = std::find(mLogicWidgets.begin(),
128  mLogicWidgets.end(), event.getSource());
129  if (iter2 != mLogicWidgets.end())
130  mLogicWidgets.erase(iter2);
131 }
WidgetList mLogicWidgets
bool find(const std::string &key)
WidgetList mWidgets
WidgetList::iterator WidgetListIterator

◆ drawChildren()

void BasicContainer::drawChildren ( Graphics *const  graphics)
protectedvirtual

Draws the children widgets of the basic container.

Parameters
graphicsA graphics object to draw with.

Reimplemented in WindowMenu.

Definition at line 304 of file basiccontainer.cpp.

References BLOCK_END, BLOCK_START, CAST_S32, FOR_EACH, getChildrenArea(), Rect::height, mWidgets, restrict, Visible_true, Rect::width, Rect::x, and Rect::y.

Referenced by BasicContainer(), ConnectionDialog::draw(), MiniStatusWindow::draw(), Popup::draw(), TabbedArea::draw(), Tab::draw(), Window::draw(), ScrollArea::draw(), BasicContainer2::draw(), and WindowMenu::drawChildren().

305 {
306  BLOCK_START("BasicContainer::drawChildren")
307  graphics->pushClipArea(getChildrenArea());
308 
310  {
311  Widget *restrict const widget = *iter;
312  if (widget->mVisible == Visible_true)
313  {
314  // If the widget has a frame,
315  // draw it before drawing the widget
316  if (widget->mFrameSize > 0)
317  {
318  Rect rec = widget->mDimension;
319  const int frame = CAST_S32(widget->mFrameSize);
320  const int frame2 = frame * 2;
321  rec.x -= frame;
322  rec.y -= frame;
323  rec.width += frame2;
324  rec.height += frame2;
325  graphics->pushClipArea(rec);
326  BLOCK_START("BasicContainer::drawChildren 1")
327  widget->drawFrame(graphics);
329  graphics->popClipArea();
330  }
331 
332  graphics->pushClipArea(widget->mDimension);
334  widget->draw(graphics);
336  graphics->popClipArea();
337  }
338  }
339 
340  graphics->popClipArea();
342 }
#define FOR_EACH(type, iter, array)
Definition: foreach.h:24
int width
Definition: rect.h:218
void popClipArea() restrict2 override final
const bool Visible_true
Definition: visible.h:29
virtual void draw(Graphics *const graphics)=0
WidgetList::const_iterator WidgetListConstIterator
void pushClipArea(const Rect &restrict area) restrict2 override final
Definition: rect.h:72
#define BLOCK_START(name)
Definition: perfomance.h:78
#define BLOCK_END(name)
Definition: perfomance.h:79
int x
Definition: rect.h:208
#define CAST_S32
Definition: cast.h:29
int y
Definition: rect.h:213
int height
Definition: rect.h:223
Definition: widget.h:97
virtual void drawChildren(Graphics *const graphics)
virtual void pushClipArea(const Rect &area)
Definition: graphics.cpp:676
#define restrict
Definition: localconsts.h:176
WidgetList mWidgets
virtual void drawFrame(Graphics *graphics)
Definition: widget.h:148
Rect mDimension
Definition: widget.h:1100

◆ findFirstWidget()

Widget * BasicContainer::findFirstWidget ( const std::set< Widget *> &  list)

Definition at line 430 of file basiccontainer.cpp.

References FOR_EACHR, and mWidgets.

Referenced by BasicContainer(), and InventoryWindow::getFirstVisible().

432 {
434  {
435  if (list.find(*iter) != list.end())
436  return *iter;
437  }
438  return nullptr;
439 }
#define FOR_EACHR(type, iter, array)
Definition: foreach.h:27
WidgetList::reverse_iterator WidgetListReverseIterator
WidgetList mWidgets

◆ focusNext()

void BasicContainer::focusNext ( )
virtual

Focuses the next widget in the widget.

See also
moveToBottom

Reimplemented from Widget.

Definition at line 138 of file basiccontainer.cpp.

References mWidgets.

Referenced by BasicContainer().

139 {
141 
142  for (it = mWidgets.begin(); it != mWidgets.end(); ++ it)
143  {
144  if ((*it)->isFocused())
145  break;
146  }
147 
148  const WidgetListConstIterator end = it;
149 
150  if (it == mWidgets.end())
151  it = mWidgets.begin();
152 
153  ++ it;
154 
155  for ( ; it != end; ++ it)
156  {
157  if (it == mWidgets.end())
158  it = mWidgets.begin();
159 
160  if ((*it)->isFocusable())
161  {
162  (*it)->requestFocus();
163  return;
164  }
165  }
166 }
WidgetList::const_iterator WidgetListConstIterator
WidgetList mWidgets

◆ focusPrevious()

void BasicContainer::focusPrevious ( )
virtual

Focuses the previous widget in the widget.

See also
moveToBottom

Reimplemented from Widget.

Definition at line 168 of file basiccontainer.cpp.

References mWidgets.

Referenced by BasicContainer().

169 {
171 
172  for (it = mWidgets.rbegin(); it != mWidgets.rend(); ++ it)
173  {
174  if ((*it)->isFocused())
175  break;
176  }
177 
178  const WidgetListReverseIterator end = it;
179 
180  ++ it;
181 
182  if (it == mWidgets.rend())
183  it = mWidgets.rbegin();
184 
185  for ( ; it != end; ++ it)
186  {
187  if (it == mWidgets.rend())
188  it = mWidgets.rbegin();
189 
190  if ((*it)->isFocusable())
191  {
192  (*it)->requestFocus();
193  return;
194  }
195  }
196 }
WidgetList::reverse_iterator WidgetListReverseIterator
WidgetList mWidgets

◆ getChildrenArea()

Rect BasicContainer::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 from Widget.

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

Definition at line 133 of file basiccontainer.cpp.

References Rect::height, Widget::mDimension, and Rect::width.

Referenced by BasicContainer(), drawChildren(), getWidgetAt(), safeDrawChildren(), showWidgetPart(), and LayoutHelper::widgetResized().

134 {
135  return Rect(0, 0, mDimension.width, mDimension.height);
136 }
int width
Definition: rect.h:218
Definition: rect.h:72
int height
Definition: rect.h:223
Rect mDimension
Definition: widget.h:1100

◆ getWidgetAt()

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

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 from Widget.

Reimplemented in ScrollArea.

Definition at line 198 of file basiccontainer.cpp.

References getChildrenArea(), Rect::isPointInRect(), mWidgets, restrict, x, Rect::x, y, and Rect::y.

Referenced by BasicContainer(), and TabbedArea::mousePressed().

199 {
200  const Rect r = getChildrenArea();
201 
202  if (!r.isPointInRect(x, y))
203  return nullptr;
204 
205  x -= r.x;
206  y -= r.y;
207 
208  for (WidgetListReverseIterator it = mWidgets.rbegin();
209  it != mWidgets.rend(); ++ it)
210  {
211  const Widget *restrict const widget = *it;
212  if (widget->isVisible() &&
213  widget->getDimension().isPointInRect(x, y))
214  {
215  return *it;
216  }
217  }
218 
219  return nullptr;
220 }
Definition: rect.h:72
bool isPointInRect(const int x_, const int y_) const
Definition: rect.h:196
int x
Definition: rect.h:208
WidgetList::reverse_iterator WidgetListReverseIterator
int y
Definition: rect.h:213
Definition: widget.h:97
#define restrict
Definition: localconsts.h:176
WidgetList mWidgets

◆ logic()

void BasicContainer::logic ( )
virtual

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 from Widget.

Reimplemented in NpcDialog, TabbedArea, ScrollArea, NetDebugTab, UpdaterWindow, TargetDebugTab, ServerDialog, CharCreateDialog, Viewport, Viewport, WhoIsOnline, MiniStatusWindow, MapDebugTab, CutInWindow, and DebugTab.

Definition at line 222 of file basiccontainer.cpp.

References BLOCK_END, BLOCK_START, logicChildren(), Widget::mVisible, and Visible_false.

Referenced by ChatWindow::addTab(), BasicContainer(), Window::isMovable(), MiniStatusWindow::logic(), ServerDialog::logic(), NpcDialog::logic(), Window::resizeToContent(), and BeingPopup::show().

223 {
224  BLOCK_START("BasicContainer::logic")
226  {
227  BLOCK_END("BasicContainer::logic")
228  return;
229  }
230  logicChildren();
232 }
#define BLOCK_START(name)
Definition: perfomance.h:78
if(!vert) return
#define BLOCK_END(name)
Definition: perfomance.h:79
Visible mVisible
Definition: widget.h:962
const bool Visible_false
Definition: visible.h:29
virtual void logicChildren()

◆ logicChildren()

void BasicContainer::logicChildren ( )
protectedvirtual

Calls logic for the children widgets of the basic container.

Definition at line 385 of file basiccontainer.cpp.

References BLOCK_END, BLOCK_START, FOR_EACH, and mLogicWidgets.

Referenced by MiniStatusWindow::arrowsChanged(), BasicContainer(), ChatWindow::clearAwayLog(), MiniStatusWindow::getBars(), WindowMenu::getButtonTexts(), logic(), TabbedArea::logic(), WindowMenu::optionChanged(), ShortcutWindow::prevTab(), Window::resizeToContent(), SocialWindow::setProcessedPortals(), BeingPopup::show(), ChatWindow::unHideWindow(), SocialWindow::updateAll(), and DebugWindow::widgetResized().

386 {
387  BLOCK_START("BasicContainer::logicChildren")
389  (*iter)->logic();
391 }
#define FOR_EACH(type, iter, array)
Definition: foreach.h:24
WidgetList::const_iterator WidgetListConstIterator
#define BLOCK_START(name)
Definition: perfomance.h:78
#define BLOCK_END(name)
Definition: perfomance.h:79
WidgetList mLogicWidgets
virtual void logicChildren()

◆ moveToBottom()

void BasicContainer::moveToBottom ( Widget *const  widget)
virtual

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 from Widget.

Definition at line 101 of file basiccontainer.cpp.

References AttributesEnum::find(), mLogicWidgets, and mWidgets.

Referenced by BasicContainer().

102 {
103  const WidgetListIterator iter = std::find(mWidgets.begin(),
104  mWidgets.end(), widget);
105  if (iter != mWidgets.end())
106  {
107  mWidgets.erase(iter);
108  mWidgets.insert(mWidgets.begin(), widget);
109  }
110 
111  const WidgetListIterator iter2 = std::find(mLogicWidgets.begin(),
112  mLogicWidgets.end(), widget);
113  if (iter2 != mLogicWidgets.end())
114  {
115  mLogicWidgets.erase(iter2);
116  mLogicWidgets.insert(mLogicWidgets.begin(), widget);
117  }
118 }
WidgetList mLogicWidgets
bool find(const std::string &key)
WidgetList mWidgets
WidgetList::iterator WidgetListIterator

◆ moveToTop()

void BasicContainer::moveToTop ( Widget *const  widget)
virtual

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 from Widget.

Definition at line 79 of file basiccontainer.cpp.

References FOR_EACH, mLogicWidgets, and mWidgets.

Referenced by BasicContainer().

80 {
82  {
83  if (*iter == widget)
84  {
85  mWidgets.erase(iter);
86  mWidgets.push_back(widget);
87  break;
88  }
89  }
91  {
92  if (*iter == widget)
93  {
94  mLogicWidgets.erase(iter);
95  mLogicWidgets.push_back(widget);
96  return;
97  }
98  }
99 }
#define FOR_EACH(type, iter, array)
Definition: foreach.h:24
WidgetList mLogicWidgets
WidgetList mWidgets
WidgetList::iterator WidgetListIterator

◆ remove()

void BasicContainer::remove ( Widget *const  widget)
virtual

Removes a widget from the basic container.

Parameters
widgetThe widget to remove.
See also
add, clear

Definition at line 263 of file basiccontainer.cpp.

References FOR_EACH, mLogicWidgets, and mWidgets.

Referenced by TabbedArea::removeTab(), and TabbedArea::setSelectedTab().

264 {
265  if (widget == nullptr)
266  return;
268  {
269  if (*iter == widget)
270  {
271  mWidgets.erase(iter);
272  widget->setFocusHandler(nullptr);
273  widget->setWindow(nullptr);
274  widget->setParent(nullptr);
275  widget->removeDeathListener(this);
276  break;
277  }
278  }
280  {
281  if (*iter == widget)
282  {
283  mLogicWidgets.erase(iter);
284  return;
285  }
286  }
287 }
#define FOR_EACH(type, iter, array)
Definition: foreach.h:24
void removeDeathListener(WidgetDeathListener *const deathListener)
Definition: widget.cpp:266
WidgetList mLogicWidgets
virtual void setWindow(Widget *const window)
Definition: widget2.h:96
virtual void setParent(Widget *parent)
Definition: widget.h:625
WidgetList mWidgets
virtual void setFocusHandler(FocusHandler *const focusHandler)
Definition: widget.cpp:237
WidgetList::iterator WidgetListIterator

◆ safeDrawChildren()

void BasicContainer::safeDrawChildren ( Graphics *const  graphics)
protectedvirtual

Reimplemented in WindowMenu.

Definition at line 344 of file basiccontainer.cpp.

References BLOCK_END, BLOCK_START, CAST_S32, FOR_EACH, getChildrenArea(), Rect::height, mWidgets, restrict, Visible_true, Rect::width, Rect::x, and Rect::y.

Referenced by BasicContainer(), ConnectionDialog::safeDraw(), MiniStatusWindow::safeDraw(), Popup::safeDraw(), TabbedArea::safeDraw(), Tab::safeDraw(), Window::safeDraw(), ScrollArea::safeDraw(), BasicContainer2::safeDraw(), and WindowMenu::safeDrawChildren().

346 {
347  BLOCK_START("BasicContainer::drawChildren")
348  graphics->pushClipArea(getChildrenArea());
349 
351  {
352  Widget *restrict const widget = *iter;
353  if (widget->mVisible == Visible_true)
354  {
355  // If the widget has a frame,
356  // draw it before drawing the widget
357  if (widget->mFrameSize > 0)
358  {
359  Rect rec = widget->mDimension;
360  const int frame = CAST_S32(widget->mFrameSize);
361  const int frame2 = frame * 2;
362  rec.x -= frame;
363  rec.y -= frame;
364  rec.width += frame2;
365  rec.height += frame2;
366  graphics->pushClipArea(rec);
367  BLOCK_START("BasicContainer::drawChildren 1")
368  widget->safeDrawFrame(graphics);
370  graphics->popClipArea();
371  }
372 
373  graphics->pushClipArea(widget->mDimension);
375  widget->safeDraw(graphics);
377  graphics->popClipArea();
378  }
379  }
380 
381  graphics->popClipArea();
383 }
#define FOR_EACH(type, iter, array)
Definition: foreach.h:24
int width
Definition: rect.h:218
virtual void safeDrawFrame(Graphics *graphics)
Definition: widget.h:151
void popClipArea() restrict2 override final
const bool Visible_true
Definition: visible.h:29
WidgetList::const_iterator WidgetListConstIterator
void pushClipArea(const Rect &restrict area) restrict2 override final
Definition: rect.h:72
virtual void safeDraw(Graphics *const graphics)=0
#define BLOCK_START(name)
Definition: perfomance.h:78
#define BLOCK_END(name)
Definition: perfomance.h:79
int x
Definition: rect.h:208
#define CAST_S32
Definition: cast.h:29
int y
Definition: rect.h:213
int height
Definition: rect.h:223
Definition: widget.h:97
virtual void drawChildren(Graphics *const graphics)
virtual void pushClipArea(const Rect &area)
Definition: graphics.cpp:676
#define restrict
Definition: localconsts.h:176
WidgetList mWidgets
Rect mDimension
Definition: widget.h:1100

◆ setFocusHandler()

void BasicContainer::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 from Widget.

Definition at line 234 of file basiccontainer.cpp.

References FOR_EACH, Widget::mInternalFocusHandler, mWidgets, and Widget::setFocusHandler().

Referenced by BasicContainer().

236 {
237  Widget::setFocusHandler(focusHandler);
238 
239  if (mInternalFocusHandler != nullptr)
240  return;
241 
243  (*iter)->setFocusHandler(focusHandler);
244 }
#define FOR_EACH(type, iter, array)
Definition: foreach.h:24
WidgetList::const_iterator WidgetListConstIterator
FocusHandler * mInternalFocusHandler
Definition: widget.h:1121
WidgetList mWidgets
virtual void setFocusHandler(FocusHandler *const focusHandler)
Definition: widget.cpp:237

◆ setInternalFocusHandler()

void BasicContainer::setInternalFocusHandler ( FocusHandler *const  focusHandler)

Definition at line 417 of file basiccontainer.cpp.

References FOR_EACH, Widget::getFocusHandler(), Widget::mInternalFocusHandler, mWidgets, restrict, and Widget::setInternalFocusHandler().

Referenced by BasicContainer().

419 {
420  Widget::setInternalFocusHandler(focusHandler);
421 
422  FocusHandler *const restrict handler = mInternalFocusHandler != nullptr ?
425  {
426  (*iter)->setFocusHandler(handler);
427  }
428 }
#define FOR_EACH(type, iter, array)
Definition: foreach.h:24
WidgetList::const_iterator WidgetListConstIterator
FocusHandler * getFocusHandler()
Definition: widget.h:473
FocusHandler * mInternalFocusHandler
Definition: widget.h:1121
#define restrict
Definition: localconsts.h:176
WidgetList mWidgets
void setInternalFocusHandler(FocusHandler *const internalFocusHandler)
Definition: widget.cpp:460

◆ showWidgetPart()

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

Shows a certain part of a widget in the basic container. 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
widgetThe widget whom wants a specific part of itself to be visible.
areaThe rectangle to be visible.

Reimplemented from Widget.

Reimplemented in ScrollArea.

Definition at line 393 of file basiccontainer.cpp.

References getChildrenArea(), Rect::height, Rect::width, x, and y.

Referenced by BasicContainer(), and ScrollArea::showWidgetPart().

395 {
396  if (widget == nullptr)
397  return;
398 
399  const Rect widgetArea = getChildrenArea();
400 
401  const int x = widget->mDimension.x;
402  const int y = widget->mDimension.y;
403  const int ax = area.x + x;
404  const int ay = area.y + y;
405 
406  if (ax < 0)
407  widget->setX(-area.x);
408  else if (ax + area.width > widgetArea.width)
409  widget->setX(widgetArea.width - area.x - area.width);
410 
411  if (ay < 0)
412  widget->setY(-area.y);
413  else if (ay + area.height > widgetArea.height)
414  widget->setY(widgetArea.height - area.y - area.height);
415 }
int width
Definition: rect.h:218
void setY(const int y)
Definition: widget.cpp:153
Definition: rect.h:72
int x
Definition: rect.h:208
void setX(const int x)
Definition: widget.cpp:146
int y
Definition: rect.h:213
int height
Definition: rect.h:223
Rect mDimension
Definition: widget.h:1100

Field Documentation

◆ mLogicWidgets

WidgetList BasicContainer::mLogicWidgets
protected

◆ mWidgets

WidgetList BasicContainer::mWidgets
protected

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