70 #include "render/graphics.h"
84 if (widget ==
nullptr)
95 mWidgets.push_back(widget);
103 mLogicWidgets.erase(iter);
104 mLogicWidgets.push_back(widget);
112 if (widget ==
nullptr)
114 reportAlways(
"BasicContainer::moveToBottom empty widget.")
118 mWidgets.end(), widget);
119 if (iter != mWidgets.end())
121 mWidgets.erase(iter);
122 mWidgets.insert(mWidgets.begin(), widget);
126 mLogicWidgets.end(), widget);
127 if (iter2 != mLogicWidgets.end())
129 mLogicWidgets.erase(iter2);
130 mLogicWidgets.insert(mLogicWidgets.begin(), widget);
137 mWidgets.end(), event.getSource());
138 if (iter != mWidgets.end())
139 mWidgets.erase(iter);
142 mLogicWidgets.end(), event.getSource());
143 if (iter2 != mLogicWidgets.end())
144 mLogicWidgets.erase(iter2);
158 if ((*it)->isFocused())
169 for ( ; it != end; ++ it)
174 if ((*it)->isFocusable())
176 (*it)->requestFocus();
188 if ((*it)->isFocused())
199 for ( ; it != end; ++ it)
204 if ((*it)->isFocusable())
206 (*it)->requestFocus();
214 const Rect r = getChildrenArea();
223 it != mWidgets.rend(); ++ it)
226 if (widget->isVisible() &&
227 widget->getDimension().isPointInRect(
x,
y))
253 if (mInternalFocusHandler !=
nullptr)
257 (*iter)->setFocusHandler(focusHandler);
262 if (widget ==
nullptr)
264 mWidgets.push_back(widget);
265 if (widget->isAllowLogic())
266 mLogicWidgets.push_back(widget);
268 if (mInternalFocusHandler ==
nullptr)
269 widget->setFocusHandler(getFocusHandler());
271 widget->setFocusHandler(mInternalFocusHandler);
273 widget->setParent(
this);
274 widget->addDeathListener(
this);
279 if (widget ==
nullptr)
285 mWidgets.erase(iter);
286 widget->setFocusHandler(
nullptr);
287 widget->setWindow(
nullptr);
288 widget->setParent(
nullptr);
289 widget->removeDeathListener(
this);
297 mLogicWidgets.erase(iter);
308 widget->setFocusHandler(
nullptr);
309 widget->setWindow(
nullptr);
310 widget->setParent(
nullptr);
311 widget->removeDeathListener(
this);
321 graphics->pushClipArea(getChildrenArea());
330 if (widget->mFrameSize > 0)
332 Rect rec = widget->mDimension;
333 const int frame =
CAST_S32(widget->mFrameSize);
334 const int frame2 = frame * 2;
339 graphics->pushClipArea(rec);
341 widget->drawFrame(graphics);
342 BLOCK_END(
"BasicContainer::drawChildren 1")
343 graphics->popClipArea();
346 graphics->pushClipArea(widget->mDimension);
348 widget->draw(graphics);
349 BLOCK_END(
"BasicContainer::drawChildren 2")
350 graphics->popClipArea();
354 graphics->popClipArea();
355 BLOCK_END(
"BasicContainer::drawChildren")
362 graphics->pushClipArea(getChildrenArea());
371 if (widget->mFrameSize > 0)
373 Rect rec = widget->mDimension;
374 const int frame =
CAST_S32(widget->mFrameSize);
375 const int frame2 = frame * 2;
380 graphics->pushClipArea(rec);
382 widget->safeDrawFrame(graphics);
383 BLOCK_END(
"BasicContainer::drawChildren 1")
384 graphics->popClipArea();
387 graphics->pushClipArea(widget->mDimension);
389 widget->safeDraw(graphics);
390 BLOCK_END(
"BasicContainer::drawChildren 2")
391 graphics->popClipArea();
395 graphics->popClipArea();
396 BLOCK_END(
"BasicContainer::drawChildren")
404 BLOCK_END(
"BasicContainer::logicChildren")
410 if (widget ==
nullptr)
413 const Rect widgetArea = getChildrenArea();
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;
421 widget->setX(-area.x);
422 else if (ax + area.width > widgetArea.
width)
423 widget->setX(widgetArea.
width - area.x - area.width);
426 widget->setY(-area.y);
427 else if (ay + area.height > widgetArea.
height)
428 widget->setY(widgetArea.
height - area.y - area.height);
437 mInternalFocusHandler : getFocusHandler();
440 (*iter)->setFocusHandler(handler);
449 if (list.find(*iter) != list.end())
#define reportAlways(...)
void moveToBottom(Widget *const widget)
virtual void safeDrawChildren(Graphics *const graphics)
virtual void logicChildren()
Widget * findFirstWidget(const std::set< Widget * > &list)
WidgetList::iterator WidgetListIterator
Widget * getWidgetAt(int x, int y)
void showWidgetPart(Widget *const widget, const Rect &area)
void moveToTop(Widget *const widget)
void setInternalFocusHandler(FocusHandler *const focusHandler)
virtual void remove(Widget *const widget)
void setFocusHandler(FocusHandler *const focusHandler)
WidgetList::reverse_iterator WidgetListReverseIterator
WidgetList::const_iterator WidgetListConstIterator
void add(Widget *const widget)
void death(const Event &event)
virtual void drawChildren(Graphics *const graphics)
bool isPointInRect(const int x_, const int y_) const
#define FOR_EACH(type, iter, array)
#define FOR_EACHR(type, iter, array)
bool find(const std::string &key)
#define BLOCK_START(name)