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 InfoClanTab Pincode Popup RelationClanTab SetupTab SliderList StatsClanTab StatsPage StatsPageBasic VertContainer WidgetGroup WindowContainer WindowMenu BankWindow BuyDialog BuySellDialog ChangeEmailDialog ChangePasswordDialog CharCreateDialog CharSelectDialog ChatWindow ClanWindow ConfirmDialog ConnectionDialog CutInWindow DebugWindow DidYouKnowWindow EditDialog EditServerDialog EmoteWindow EquipmentWindow HelpWindow InventoryWindow ItemAmountWindow KillStats LoginDialog MailEditWindow MailViewWindow MailWindow MiniStatusWindow Minimap NpcDialog OkDialog OutfitWindow PincodeDialog QuestsWindow QuitDialog RegisterDialog SellDialog ServerDialog ServerInfoWindow SetupWindow ShopWindow ShortcutWindow SkillDialog SocialWindow StatusWindow TextCommandEditor TextDialog TextSelectDialog TradeWindow UpdaterWindow WhoIsOnline WorldSelectDialog BattleTab ChannelTab ClanTab EmulateGuildTab GmTab GuildTab LangTab PartyTab TradeTab WhisperTab SocialAttackTab SocialFriendsTab SocialGuildTab SocialGuildTab2 SocialNavigationTab SocialPartyTab SocialPickupTab SocialPlayersTab

Public Member Functions

 BasicContainer (const Widget2 *const widget)
 
 ~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)
 
 ~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) 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 79 of file basiccontainer.h.

Member Typedef Documentation

◆ WidgetList

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

Typedef.

Definition at line 184 of file basiccontainer.h.

◆ WidgetListConstIterator

typedef WidgetList::const_iterator BasicContainer::WidgetListConstIterator
protected

Typedef.

Definition at line 194 of file basiccontainer.h.

◆ WidgetListCReverseIterator

typedef WidgetList::const_reverse_iterator BasicContainer::WidgetListCReverseIterator
protected

Typedef.

Definition at line 204 of file basiccontainer.h.

◆ WidgetListIterator

typedef WidgetList::iterator BasicContainer::WidgetListIterator
protected

Typedef.

Definition at line 189 of file basiccontainer.h.

◆ WidgetListReverseIterator

typedef WidgetList::reverse_iterator BasicContainer::WidgetListReverseIterator
protected

Typedef.

Definition at line 199 of file basiccontainer.h.

Constructor & Destructor Documentation

◆ BasicContainer()

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

Definition at line 83 of file basiccontainer.h.

83  :
84  Widget(widget),
86  mWidgets(),
88  { }
WidgetList mWidgets
WidgetList mLogicWidgets
Widget(const Widget2 *const widget)
Definition: widget.cpp:85

◆ ~BasicContainer()

BasicContainer::~BasicContainer ( )

Destructor

Definition at line 76 of file basiccontainer.cpp.

77 {
78  // +++ virtual method call
79  clear();
80 }
virtual void clear()

References 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 260 of file basiccontainer.cpp.

261 {
262  if (widget == nullptr)
263  return;
264  mWidgets.push_back(widget);
265  if (widget->isAllowLogic())
266  mLogicWidgets.push_back(widget);
267 
268  if (mInternalFocusHandler == nullptr)
269  widget->setFocusHandler(getFocusHandler());
270  else
272 
273  widget->setParent(this);
274  widget->addDeathListener(this);
275 }
virtual void setFocusHandler(FocusHandler *const focusHandler)
Definition: widget.cpp:238
FocusHandler * getFocusHandler()
Definition: widget.h:474
bool isAllowLogic() const
Definition: widget.h:933
virtual void setParent(Widget *parent)
Definition: widget.h:626
FocusHandler * mInternalFocusHandler
Definition: widget.h:1122
void addDeathListener(WidgetDeathListener *const deathListener)
Definition: widget.cpp:262

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

◆ clear()

void BasicContainer::clear ( )
virtual

Clears the basic container from all widgets.

See also
remove, clear

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

Definition at line 303 of file basiccontainer.cpp.

304 {
306  {
307  Widget *restrict const widget = *iter;
308  widget->setFocusHandler(nullptr);
309  widget->setWindow(nullptr);
310  widget->setParent(nullptr);
311  widget->removeDeathListener(this);
312  }
313 
314  mWidgets.clear();
315  mLogicWidgets.clear();
316 }
WidgetList::const_iterator WidgetListConstIterator
Definition: widget.h:99
#define FOR_EACH(type, iter, array)
Definition: foreach.h:25
#define restrict
Definition: localconsts.h:165

References FOR_EACH, mLogicWidgets, mWidgets, and restrict.

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

◆ 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 134 of file basiccontainer.cpp.

135 {
136  const WidgetListIterator iter = std::find(mWidgets.begin(),
137  mWidgets.end(), event.getSource());
138  if (iter != mWidgets.end())
139  mWidgets.erase(iter);
140 
141  const WidgetListIterator iter2 = std::find(mLogicWidgets.begin(),
142  mLogicWidgets.end(), event.getSource());
143  if (iter2 != mLogicWidgets.end())
144  mLogicWidgets.erase(iter2);
145 }
WidgetList::iterator WidgetListIterator
Widget * getSource() const
Definition: event.h:104
bool find(const std::string &key)

References AttributesEnum::find().

Referenced by TabbedArea::death().

◆ 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 318 of file basiccontainer.cpp.

319 {
320  BLOCK_START("BasicContainer::drawChildren")
321  graphics->pushClipArea(getChildrenArea());
322 
324  {
325  Widget *restrict const widget = *iter;
326  if (widget->mVisible == Visible_true)
327  {
328  // If the widget has a frame,
329  // draw it before drawing the widget
330  if (widget->mFrameSize > 0)
331  {
332  Rect rec = widget->mDimension;
333  const int frame = CAST_S32(widget->mFrameSize);
334  const int frame2 = frame * 2;
335  rec.x -= frame;
336  rec.y -= frame;
337  rec.width += frame2;
338  rec.height += frame2;
339  graphics->pushClipArea(rec);
340  BLOCK_START("BasicContainer::drawChildren 1")
341  widget->drawFrame(graphics);
343  graphics->popClipArea();
344  }
345 
346  graphics->pushClipArea(widget->mDimension);
348  widget->draw(graphics);
350  graphics->popClipArea();
351  }
352  }
353 
354  graphics->popClipArea();
356 }
#define CAST_S32
Definition: cast.h:30
virtual void drawChildren(Graphics *const graphics)
virtual void pushClipArea(const Rect &area)
Definition: graphics.cpp:677
Definition: rect.h:74
int y
Definition: rect.h:214
int width
Definition: rect.h:219
int x
Definition: rect.h:209
int height
Definition: rect.h:224
virtual void drawFrame(Graphics *graphics)
Definition: widget.h:149
Rect mDimension
Definition: widget.h:1101
virtual void draw(Graphics *const graphics)=0
void popClipArea() restrict2 override final
void pushClipArea(const Rect &restrict area) restrict2 override final
#define BLOCK_END(name)
Definition: perfomance.h:80
#define BLOCK_START(name)
Definition: perfomance.h:79
const bool Visible_true
Definition: visible.h:30

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

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

◆ findFirstWidget()

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

Definition at line 444 of file basiccontainer.cpp.

446 {
448  {
449  if (list.find(*iter) != list.end())
450  return *iter;
451  }
452  return nullptr;
453 }
WidgetList::reverse_iterator WidgetListReverseIterator
#define FOR_EACHR(type, iter, array)
Definition: foreach.h:28

References FOR_EACHR.

Referenced by InventoryWindow::getFirstVisible().

◆ focusNext()

void BasicContainer::focusNext ( )
virtual

Focuses the next widget in the widget.

See also
moveToBottom

Reimplemented from Widget.

Definition at line 152 of file basiccontainer.cpp.

153 {
155 
156  for (it = mWidgets.begin(); it != mWidgets.end(); ++ it)
157  {
158  if ((*it)->isFocused())
159  break;
160  }
161 
162  const WidgetListConstIterator end = it;
163 
164  if (it == mWidgets.end())
165  it = mWidgets.begin();
166 
167  ++ it;
168 
169  for ( ; it != end; ++ it)
170  {
171  if (it == mWidgets.end())
172  it = mWidgets.begin();
173 
174  if ((*it)->isFocusable())
175  {
176  (*it)->requestFocus();
177  return;
178  }
179  }
180 }

References mWidgets.

◆ focusPrevious()

void BasicContainer::focusPrevious ( )
virtual

Focuses the previous widget in the widget.

See also
moveToBottom

Reimplemented from Widget.

Definition at line 182 of file basiccontainer.cpp.

183 {
185 
186  for (it = mWidgets.rbegin(); it != mWidgets.rend(); ++ it)
187  {
188  if ((*it)->isFocused())
189  break;
190  }
191 
192  const WidgetListReverseIterator end = it;
193 
194  ++ it;
195 
196  if (it == mWidgets.rend())
197  it = mWidgets.rbegin();
198 
199  for ( ; it != end; ++ it)
200  {
201  if (it == mWidgets.rend())
202  it = mWidgets.rbegin();
203 
204  if ((*it)->isFocusable())
205  {
206  (*it)->requestFocus();
207  return;
208  }
209  }
210 }

References 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 MiniStatusWindow, Window, ScrollArea, Popup, and DropDown.

Definition at line 147 of file basiccontainer.cpp.

148 {
149  return Rect(0, 0, mDimension.width, mDimension.height);
150 }

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

Referenced by LayoutHelper::widgetResized().

◆ 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 212 of file basiccontainer.cpp.

213 {
214  const Rect r = getChildrenArea();
215 
216  if (!r.isPointInRect(x, y))
217  return nullptr;
218 
219  x -= r.x;
220  y -= r.y;
221 
222  for (WidgetListReverseIterator it = mWidgets.rbegin();
223  it != mWidgets.rend(); ++ it)
224  {
225  const Widget *restrict const widget = *it;
226  if (widget->isVisible() &&
227  widget->getDimension().isPointInRect(x, y))
228  {
229  return *it;
230  }
231  }
232 
233  return nullptr;
234 }
bool isPointInRect(const int x_, const int y_) const
Definition: rect.h:197

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

Referenced by TabbedArea::mousePressed().

◆ 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 Viewport, Viewport, WhoIsOnline, UpdaterWindow, ServerDialog, NpcDialog, MiniStatusWindow, CutInWindow, CharCreateDialog, TargetDebugTab, StatDebugTab, NetDebugTab, MapDebugTab, DebugTab, TabbedArea, and ScrollArea.

Definition at line 236 of file basiccontainer.cpp.

237 {
238  BLOCK_START("BasicContainer::logic")
240  {
241  BLOCK_END("BasicContainer::logic")
242  return;
243  }
244  logicChildren();
246 }
virtual void logicChildren()
Visible mVisible
Definition: widget.h:963
if(!vert) return
const bool Visible_false
Definition: visible.h:30

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

Referenced by ChatWindow::addTab(), MiniStatusWindow::logic(), NpcDialog::logic(), ServerDialog::logic(), and ClanWindow::slowLogic().

◆ logicChildren()

void BasicContainer::logicChildren ( )
protectedvirtual

Calls logic for the children widgets of the basic container.

Definition at line 399 of file basiccontainer.cpp.

400 {
401  BLOCK_START("BasicContainer::logicChildren")
403  (*iter)->logic();
405 }

References BLOCK_END, BLOCK_START, FOR_EACH, and mLogicWidgets.

Referenced by logic(), and TabbedArea::logic().

◆ 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 110 of file basiccontainer.cpp.

111 {
112  if (widget == nullptr)
113  {
114  reportAlways("BasicContainer::moveToBottom empty widget.")
115  return;
116  }
117  const WidgetListIterator iter = std::find(mWidgets.begin(),
118  mWidgets.end(), widget);
119  if (iter != mWidgets.end())
120  {
121  mWidgets.erase(iter);
122  mWidgets.insert(mWidgets.begin(), widget);
123  }
124 
125  const WidgetListIterator iter2 = std::find(mLogicWidgets.begin(),
126  mLogicWidgets.end(), widget);
127  if (iter2 != mLogicWidgets.end())
128  {
129  mLogicWidgets.erase(iter2);
130  mLogicWidgets.insert(mLogicWidgets.begin(), widget);
131  }
132 }
#define reportAlways(...)
Definition: checkutils.h:253

References AttributesEnum::find(), and reportAlways.

◆ 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 82 of file basiccontainer.cpp.

83 {
84  if (widget == nullptr)
85  {
86  reportAlways("BasicContainer::moveToTop empty widget.")
87  return;
88  }
89 
91  {
92  if (*iter == widget)
93  {
94  mWidgets.erase(iter);
95  mWidgets.push_back(widget);
96  break;
97  }
98  }
100  {
101  if (*iter == widget)
102  {
103  mLogicWidgets.erase(iter);
104  mLogicWidgets.push_back(widget);
105  return;
106  }
107  }
108 }

References FOR_EACH, and reportAlways.

◆ 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 277 of file basiccontainer.cpp.

278 {
279  if (widget == nullptr)
280  return;
282  {
283  if (*iter == widget)
284  {
285  mWidgets.erase(iter);
286  widget->setFocusHandler(nullptr);
287  widget->setWindow(nullptr);
288  widget->setParent(nullptr);
289  widget->removeDeathListener(this);
290  break;
291  }
292  }
294  {
295  if (*iter == widget)
296  {
297  mLogicWidgets.erase(iter);
298  return;
299  }
300  }
301 }
virtual void setWindow(Widget *const window)
Definition: widget2.h:97
void removeDeathListener(WidgetDeathListener *const deathListener)
Definition: widget.cpp:267

References FOR_EACH.

Referenced by StatsClanTab::clearLabels(), RelationClanTab::clearLabels(), TabbedArea::enableScrollButtons(), TabbedArea::removeTab(), Container::safeRemove(), CharCreateDialog::setAttributes(), TabbedArea::setSelectedTab(), MiniStatusWindow::updateBars(), and TabbedArea::~TabbedArea().

◆ safeDrawChildren()

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

Reimplemented in WindowMenu.

Definition at line 358 of file basiccontainer.cpp.

360 {
361  BLOCK_START("BasicContainer::drawChildren")
362  graphics->pushClipArea(getChildrenArea());
363 
365  {
366  Widget *restrict const widget = *iter;
367  if (widget->mVisible == Visible_true)
368  {
369  // If the widget has a frame,
370  // draw it before drawing the widget
371  if (widget->mFrameSize > 0)
372  {
373  Rect rec = widget->mDimension;
374  const int frame = CAST_S32(widget->mFrameSize);
375  const int frame2 = frame * 2;
376  rec.x -= frame;
377  rec.y -= frame;
378  rec.width += frame2;
379  rec.height += frame2;
380  graphics->pushClipArea(rec);
381  BLOCK_START("BasicContainer::drawChildren 1")
382  widget->safeDrawFrame(graphics);
384  graphics->popClipArea();
385  }
386 
387  graphics->pushClipArea(widget->mDimension);
389  widget->safeDraw(graphics);
391  graphics->popClipArea();
392  }
393  }
394 
395  graphics->popClipArea();
397 }
virtual void safeDrawFrame(Graphics *graphics)
Definition: widget.h:152
virtual void safeDraw(Graphics *const graphics)=0

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

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

◆ 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 248 of file basiccontainer.cpp.

250 {
251  Widget::setFocusHandler(focusHandler);
252 
253  if (mInternalFocusHandler != nullptr)
254  return;
255 
257  (*iter)->setFocusHandler(focusHandler);
258 }

References FOR_EACH, and Widget::setFocusHandler().

◆ setInternalFocusHandler()

void BasicContainer::setInternalFocusHandler ( FocusHandler *const  focusHandler)

Definition at line 431 of file basiccontainer.cpp.

433 {
434  Widget::setInternalFocusHandler(focusHandler);
435 
436  FocusHandler *const restrict handler = mInternalFocusHandler != nullptr ?
439  {
440  (*iter)->setFocusHandler(handler);
441  }
442 }
void setInternalFocusHandler(FocusHandler *const internalFocusHandler)
Definition: widget.cpp:461

References FOR_EACH, restrict, and Widget::setInternalFocusHandler().

◆ 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 407 of file basiccontainer.cpp.

409 {
410  if (widget == nullptr)
411  return;
412 
413  const Rect widgetArea = getChildrenArea();
414 
415  const int x = widget->mDimension.x;
416  const int y = widget->mDimension.y;
417  const int ax = area.x + x;
418  const int ay = area.y + y;
419 
420  if (ax < 0)
421  widget->setX(-area.x);
422  else if (ax + area.width > widgetArea.width)
423  widget->setX(widgetArea.width - area.x - area.width);
424 
425  if (ay < 0)
426  widget->setY(-area.y);
427  else if (ay + area.height > widgetArea.height)
428  widget->setY(widgetArea.height - area.y - area.height);
429 }
void setY(const int y)
Definition: widget.cpp:154
void setX(const int x)
Definition: widget.cpp:147

References Rect::height, Rect::width, x, and y.

Referenced by ScrollArea::showWidgetPart().

Field Documentation

◆ mLogicWidgets

WidgetList BasicContainer::mLogicWidgets
protected

Definition at line 211 of file basiccontainer.h.

Referenced by clear(), logicChildren(), and WindowContainer::moveWidgetAfter().

◆ mWidgets

WidgetList BasicContainer::mWidgets
protected

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