Rename ui::Widget::getChildren() -> children()

Extra changes:
* Removed UI_FOREACH_WIDGET(), replaced with range-based for-loops
This commit is contained in:
David Capello 2015-12-03 19:46:13 -03:00
parent d5e3f3d3e8
commit 78ba213471
30 changed files with 160 additions and 205 deletions

View File

@ -297,9 +297,7 @@ void AppMenus::applyShortcutToMenuitemsWithCommand(Command* command, const Param
void AppMenus::applyShortcutToMenuitemsWithCommand(Menu* menu, Command* command, const Params& params, Key* key) void AppMenus::applyShortcutToMenuitemsWithCommand(Menu* menu, Command* command, const Params& params, Key* key)
{ {
UI_FOREACH_WIDGET(menu->getChildren(), it) { for (auto child : menu->children()) {
Widget* child = *it;
if (child->type() == kMenuItemWidget) { if (child->type() == kMenuItemWidget) {
AppMenuItem* menuitem = dynamic_cast<AppMenuItem*>(child); AppMenuItem* menuitem = dynamic_cast<AppMenuItem*>(child);
if (!menuitem) if (!menuitem)

View File

@ -400,7 +400,7 @@ private:
for (auto listBox : listBoxes) { for (auto listBox : listBoxes) {
Separator* group = nullptr; Separator* group = nullptr;
for (auto item : listBox->getChildren()) { for (auto item : listBox->children()) {
if (KeyItem* keyItem = dynamic_cast<KeyItem*>(item)) { if (KeyItem* keyItem = dynamic_cast<KeyItem*>(item)) {
std::string itemText = std::string itemText =
base::string_to_lower(keyItem->getText()); base::string_to_lower(keyItem->getText());
@ -414,7 +414,7 @@ private:
if (matches == int(parts.size())) { if (matches == int(parts.size())) {
if (!group) { if (!group) {
group = new Separator( group = new Separator(
section()->getChildren()[sectionIdx]->getText(), HORIZONTAL); section()->children()[sectionIdx]->getText(), HORIZONTAL);
group->setBgColor(SkinTheme::instance()->colors.background()); group->setBgColor(SkinTheme::instance()->colors.background());
searchList()->addChild(group); searchList()->addChild(group);
@ -496,7 +496,7 @@ private:
} }
void fillList(ListBox* listbox, Menu* menu, int level) { void fillList(ListBox* listbox, Menu* menu, int level) {
for (Widget* child : menu->getChildren()) { for (auto child : menu->children()) {
if (AppMenuItem* menuItem = dynamic_cast<AppMenuItem*>(child)) { if (AppMenuItem* menuItem = dynamic_cast<AppMenuItem*>(child)) {
if (menuItem == AppMenus::instance()->getRecentListMenuitem()) if (menuItem == AppMenus::instance()->getRecentListMenuitem())
continue; continue;

View File

@ -189,7 +189,7 @@ private:
} }
void selectState(const undo::UndoState* state) { void selectState(const undo::UndoState* state) {
for (auto child : actions()->getChildren()) { for (auto child : actions()->children()) {
Item* item = static_cast<Item*>(child); Item* item = static_cast<Item*>(child);
if (item->state() == state) { if (item->state() == state) {
actions()->selectChild(item); actions()->selectChild(item);

View File

@ -83,8 +83,8 @@ private:
const char* oldSelected = (m_filter.getMatrix() ? m_filter.getMatrix()->getName(): NULL); const char* oldSelected = (m_filter.getMatrix() ? m_filter.getMatrix()->getName(): NULL);
// Clean the list // Clean the list
while (!m_stockListBox->getChildren().empty()) { while (!m_stockListBox->children().empty()) {
Widget* listitem = m_stockListBox->getChildren().front(); Widget* listitem = m_stockListBox->children().front();
m_stockListBox->removeChild(listitem); m_stockListBox->removeChild(listitem);
delete listitem; delete listitem;
} }
@ -101,12 +101,10 @@ private:
void selectMatrixByName(const char* oldSelected) void selectMatrixByName(const char* oldSelected)
{ {
Widget* select_this = UI_FIRST_WIDGET(m_stockListBox->getChildren()); Widget* select_this = UI_FIRST_WIDGET(m_stockListBox->children());
if (oldSelected) { if (oldSelected) {
UI_FOREACH_WIDGET(m_stockListBox->getChildren(), it) { for (auto child : m_stockListBox->children()) {
Widget* child = *it;
if (child->getText() == oldSelected) { if (child->getText() == oldSelected) {
select_this = child; select_this = child;
break; break;

View File

@ -433,8 +433,8 @@ bool CustomizedGuiManager::onProcessMessage(Message* msg)
// Commands are executed only when the main window is // Commands are executed only when the main window is
// the current window running at foreground. // the current window running at foreground.
UI_FOREACH_WIDGET(getChildren(), it) { for (auto childWidget : children()) {
Window* child = static_cast<Window*>(*it); Window* child = static_cast<Window*>(childWidget);
// There are a foreground window executing? // There are a foreground window executing?
if (child->isForeground()) { if (child->isForeground()) {

View File

@ -122,7 +122,7 @@ BrushPopup::BrushPopup(BrushPopupDelegate* delegate)
void BrushPopup::setBrush(Brush* brush) void BrushPopup::setBrush(Brush* brush)
{ {
for (auto child : m_buttons->getChildren()) { for (auto child : m_buttons->children()) {
Item* item = static_cast<Item*>(child); Item* item = static_cast<Item*>(child);
// Same type and same image // Same type and same image
@ -141,7 +141,7 @@ void BrushPopup::regenerate(const gfx::Rect& box, const Brushes& brushes)
int columns = 3; int columns = 3;
if (m_buttons) { if (m_buttons) {
for (auto child : m_buttons->getChildren()) for (auto child : m_buttons->children())
m_tooltipManager->removeTooltipFor(child); m_tooltipManager->removeTooltipFor(child);
removeChild(m_buttons.get()); removeChild(m_buttons.get());
m_buttons.reset(); m_buttons.reset();
@ -186,7 +186,7 @@ void BrushPopup::regenerate(const gfx::Rect& box, const Brushes& brushes)
addChild(m_buttons.get()); addChild(m_buttons.get());
gfx::Rect rc = box; gfx::Rect rc = box;
int buttons = m_buttons->getChildren().size(); int buttons = m_buttons->children().size();
int rows = (buttons/columns + ((buttons%columns) > 0 ? 1: 0)); int rows = (buttons/columns + ((buttons%columns) > 0 ? 1: 0));
rc.w *= columns; rc.w *= columns;
rc.h = rows * (rc.h-2*guiscale()) + 2*guiscale(); rc.h = rows * (rc.h-2*guiscale()) + 2*guiscale();

View File

@ -271,7 +271,7 @@ ButtonSet::Item* ButtonSet::getItem(int index)
int ButtonSet::selectedItem() const int ButtonSet::selectedItem() const
{ {
int index = 0; int index = 0;
for (Widget* child : getChildren()) { for (Widget* child : children()) {
if (child->isSelected()) if (child->isSelected())
return index; return index;
++index; ++index;
@ -281,7 +281,7 @@ int ButtonSet::selectedItem() const
void ButtonSet::setSelectedItem(int index) void ButtonSet::setSelectedItem(int index)
{ {
if (index >= 0 && index < (int)getChildren().size()) if (index >= 0 && index < (int)children().size())
setSelectedItem(static_cast<Item*>(at(index))); setSelectedItem(static_cast<Item*>(at(index)));
else else
setSelectedItem(static_cast<Item*>(NULL)); setSelectedItem(static_cast<Item*>(NULL));
@ -338,11 +338,11 @@ void ButtonSet::onRightClick(Item* item)
ButtonSet::Item* ButtonSet::findSelectedItem() const ButtonSet::Item* ButtonSet::findSelectedItem() const
{ {
for (Widget* child : getChildren()) { for (auto child : children()) {
if (child->isSelected()) if (child->isSelected())
return static_cast<Item*>(child); return static_cast<Item*>(child);
} }
return NULL; return nullptr;
} }
} // namespace app } // namespace app

View File

@ -153,7 +153,7 @@ DataRecoveryView::~DataRecoveryView()
void DataRecoveryView::fillList() void DataRecoveryView::fillList()
{ {
WidgetsList children = m_listBox.getChildren(); WidgetsList children = m_listBox.children();
for (auto child : children) { for (auto child : children) {
m_listBox.removeChild(child); m_listBox.removeChild(child);
child->deferDelete(); child->deferDelete();

View File

@ -200,7 +200,7 @@ FontPopup::FontPopup()
m_listBox.addChild(new FontItem(file)); m_listBox.addChild(new FontItem(file));
} }
if (m_listBox.getChildren().empty()) if (m_listBox.children().empty())
m_listBox.addChild(new ListItem("No system fonts were found")); m_listBox.addChild(new ListItem("No system fonts were found"));
} }

View File

@ -141,7 +141,7 @@ void Workspace::duplicateActiveView()
void Workspace::updateTabs() void Workspace::updateTabs()
{ {
WidgetsList children = getChildren(); WidgetsList children = this->children();
while (!children.empty()) { while (!children.empty()) {
Widget* child = children.back(); Widget* child = children.back();
children.erase(--children.end()); children.erase(--children.end());
@ -149,7 +149,7 @@ void Workspace::updateTabs()
if (child->type() == WorkspacePanel::Type()) if (child->type() == WorkspacePanel::Type())
static_cast<WorkspacePanel*>(child)->tabs()->updateTabs(); static_cast<WorkspacePanel*>(child)->tabs()->updateTabs();
for (auto subchild : child->getChildren()) for (auto subchild : child->children())
children.push_back(subchild); children.push_back(subchild);
} }
} }
@ -164,7 +164,7 @@ void Workspace::onResize(ui::ResizeEvent& ev)
setBoundsQuietly(ev.getBounds()); setBoundsQuietly(ev.getBounds());
gfx::Rect rc = getChildrenBounds(); gfx::Rect rc = getChildrenBounds();
for (Widget* child : getChildren()) for (auto child : children())
child->setBounds(rc); child->setBounds(rc);
} }

View File

@ -176,7 +176,7 @@ void WorkspacePanel::adjustActiveViewBounds()
rc.h -= int(inbetween(0.0, threshold, top) + inbetween(0.0, threshold, bottom)); rc.h -= int(inbetween(0.0, threshold, top) + inbetween(0.0, threshold, bottom));
} }
for (Widget* child : getChildren()) for (auto child : children())
if (child->isVisible()) if (child->isVisible())
child->setBounds(rc); child->setBounds(rc);
} }

View File

@ -1,4 +1,4 @@
Copyright (c) 2001-2014 David Capello Copyright (c) 2001-2015 David Capello
Permission is hereby granted, free of charge, to any person obtaining Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the a copy of this software and associated documentation files (the

View File

@ -43,13 +43,13 @@ void Box::onPreferredSize(PreferredSizeEvent& ev)
} }
int visibleChildren = 0; int visibleChildren = 0;
for (Widget* child : getChildren()) { for (auto child : children()) {
if (!child->hasFlags(HIDDEN)) if (!child->hasFlags(HIDDEN))
++visibleChildren; ++visibleChildren;
} }
Size prefSize(0, 0); Size prefSize(0, 0);
for (Widget* child : getChildren()) { for (auto child : children()) {
if (child->hasFlags(HIDDEN)) if (child->hasFlags(HIDDEN))
continue; continue;
@ -87,7 +87,7 @@ void Box::onResize(ResizeEvent& ev)
\ \
Rect childPos(getChildrenBounds()); \ Rect childPos(getChildrenBounds()); \
int i = 0, j = 0; \ int i = 0, j = 0; \
for (Widget* child : getChildren()) { \ for (auto child : children()) { \
if (child->hasFlags(HIDDEN)) \ if (child->hasFlags(HIDDEN)) \
continue; \ continue; \
\ \
@ -123,7 +123,7 @@ void Box::onResize(ResizeEvent& ev)
int visibleChildren = 0; int visibleChildren = 0;
int expansiveChildren = 0; int expansiveChildren = 0;
for (Widget* child : getChildren()) { for (auto child : children()) {
if (!child->hasFlags(HIDDEN)) { if (!child->hasFlags(HIDDEN)) {
++visibleChildren; ++visibleChildren;
if (child->isExpansive()) if (child->isExpansive())

View File

@ -364,8 +364,8 @@ void RadioButton::deselectRadioGroup()
radioButton->setSelected(false); radioButton->setSelected(false);
} }
UI_FOREACH_WIDGET(widget->getChildren(), it) { for (auto child : widget->children()) {
allChildrens.push(*it); allChildrens.push(child);
} }
} }
} }

View File

@ -32,7 +32,7 @@ ListBox::ListBox()
Widget* ListBox::getSelectedChild() Widget* ListBox::getSelectedChild()
{ {
for (Widget* child : getChildren()) for (auto child : children())
if (child->isSelected()) if (child->isSelected())
return child; return child;
@ -43,7 +43,7 @@ int ListBox::getSelectedIndex()
{ {
int i = 0; int i = 0;
for (Widget* child : getChildren()) { for (auto child : children()) {
if (child->isSelected()) if (child->isSelected())
return i; return i;
@ -55,7 +55,7 @@ int ListBox::getSelectedIndex()
void ListBox::selectChild(Widget* item) void ListBox::selectChild(Widget* item)
{ {
for (Widget* child : getChildren()) { for (auto child : children()) {
if (child->isSelected()) { if (child->isSelected()) {
if (item && child == item) if (item && child == item)
return; return;
@ -74,7 +74,7 @@ void ListBox::selectChild(Widget* item)
void ListBox::selectIndex(int index) void ListBox::selectIndex(int index)
{ {
const WidgetsList& children = getChildren(); const WidgetsList& children = this->children();
if (index < 0 || index >= (int)children.size()) if (index < 0 || index >= (int)children.size())
return; return;
@ -85,7 +85,7 @@ void ListBox::selectIndex(int index)
std::size_t ListBox::getItemsCount() const std::size_t ListBox::getItemsCount() const
{ {
return getChildren().size(); return children().size();
} }
void ListBox::makeChildVisible(Widget* child) void ListBox::makeChildVisible(Widget* child)
@ -129,7 +129,7 @@ inline bool sort_by_text(Widget* a, Widget* b) {
void ListBox::sortItems() void ListBox::sortItems()
{ {
WidgetsList widgets = getChildren(); WidgetsList widgets = children();
std::sort(widgets.begin(), widgets.end(), &sort_by_text); std::sort(widgets.begin(), widgets.end(), &sort_by_text);
// Remove all children and add then again. // Remove all children and add then again.
@ -207,10 +207,10 @@ bool ListBox::onProcessMessage(Message* msg)
} }
case kKeyDownMessage: case kKeyDownMessage:
if (hasFocus() && !getChildren().empty()) { if (hasFocus() && !children().empty()) {
int select = getSelectedIndex(); int select = getSelectedIndex();
View* view = View::getView(this); View* view = View::getView(this);
int bottom = MAX(0, getChildren().size()-1); int bottom = MAX(0, children().size()-1);
KeyMessage* keymsg = static_cast<KeyMessage*>(msg); KeyMessage* keymsg = static_cast<KeyMessage*>(msg);
switch (keymsg->scancode()) { switch (keymsg->scancode()) {
@ -288,9 +288,7 @@ void ListBox::onResize(ResizeEvent& ev)
Rect cpos = getChildrenBounds(); Rect cpos = getChildrenBounds();
UI_FOREACH_WIDGET(getChildren(), it) { for (auto child : children()) {
Widget* child = *it;
cpos.h = child->getPreferredSize().h; cpos.h = child->getPreferredSize().h;
child->setBounds(cpos); child->setBounds(cpos);
@ -302,7 +300,7 @@ void ListBox::onPreferredSize(PreferredSizeEvent& ev)
{ {
int w = 0, h = 0; int w = 0, h = 0;
UI_FOREACH_WIDGET_WITH_END(getChildren(), it, end) { UI_FOREACH_WIDGET_WITH_END(children(), it, end) {
Size reqSize = static_cast<ListItem*>(*it)->getPreferredSize(); Size reqSize = static_cast<ListItem*>(*it)->getPreferredSize();
w = MAX(w, reqSize.w); w = MAX(w, reqSize.w);

View File

@ -39,8 +39,8 @@ void ListItem::onResize(ResizeEvent& ev)
setBoundsQuietly(ev.getBounds()); setBoundsQuietly(ev.getBounds());
Rect crect = getChildrenBounds(); Rect crect = getChildrenBounds();
UI_FOREACH_WIDGET(getChildren(), it) for (auto child : children())
(*it)->setBounds(crect); child->setBounds(crect);
} }
void ListItem::onPreferredSize(PreferredSizeEvent& ev) void ListItem::onPreferredSize(PreferredSizeEvent& ev)
@ -53,8 +53,8 @@ void ListItem::onPreferredSize(PreferredSizeEvent& ev)
else else
maxSize.w = maxSize.h = 0; maxSize.w = maxSize.h = 0;
UI_FOREACH_WIDGET(getChildren(), it) { for (auto child : children()) {
Size reqSize = (*it)->getPreferredSize(); Size reqSize = child->getPreferredSize();
maxSize.w = MAX(maxSize.w, reqSize.w); maxSize.w = MAX(maxSize.w, reqSize.w);
maxSize.h = MAX(maxSize.h, reqSize.h); maxSize.h = MAX(maxSize.h, reqSize.h);

View File

@ -170,7 +170,7 @@ void Manager::run()
set_mouse_cursor(kArrowCursor); set_mouse_cursor(kArrowCursor);
} }
while (!getChildren().empty()) while (!children().empty())
loop.pumpMessages(); loop.pumpMessages();
} }
@ -205,14 +205,12 @@ void Manager::flipDisplay()
bool Manager::generateMessages() bool Manager::generateMessages()
{ {
// First check: there are windows to manage? // First check: there are windows to manage?
if (getChildren().empty()) if (children().empty())
return false; return false;
// New windows to show? // New windows to show?
if (!new_windows.empty()) { if (!new_windows.empty()) {
UI_FOREACH_WIDGET(new_windows, it) { for (auto window : new_windows) {
Widget* window = *it;
// Relayout // Relayout
window->layout(); window->layout();
@ -401,9 +399,9 @@ void Manager::handleMouseMove(const gfx::Point& mousePos,
broadcastMouseMessage(mouse_widgets_list); broadcastMouseMessage(mouse_widgets_list);
// Get the widget under the mouse // Get the widget under the mouse
Widget* widget = NULL; Widget* widget = nullptr;
UI_FOREACH_WIDGET(mouse_widgets_list, it) { for (auto mouseWidget : mouse_widgets_list) {
widget = (*it)->pick(mousePos); widget = mouseWidget->pick(mousePos);
if (widget) if (widget)
break; break;
} }
@ -502,8 +500,8 @@ void Manager::handleWindowZOrder()
if (window->isOnTop()) if (window->isOnTop())
win_manager->insertChild(0, window); win_manager->insertChild(0, window);
else { else {
int pos = (int)win_manager->getChildren().size(); int pos = (int)win_manager->children().size();
UI_FOREACH_WIDGET_BACKWARD(win_manager->getChildren(), it) { UI_FOREACH_WIDGET_BACKWARD(win_manager->children(), it) {
if (static_cast<Window*>(*it)->isOnTop()) if (static_cast<Window*>(*it)->isOnTop())
break; break;
@ -576,18 +574,18 @@ void Manager::enqueueMessage(Message* msg)
Window* Manager::getTopWindow() Window* Manager::getTopWindow()
{ {
return static_cast<Window*>(UI_FIRST_WIDGET(getChildren())); return static_cast<Window*>(UI_FIRST_WIDGET(children()));
} }
Window* Manager::getForegroundWindow() Window* Manager::getForegroundWindow()
{ {
UI_FOREACH_WIDGET(getChildren(), it) { for (auto child : children()) {
Window* window = static_cast<Window*>(*it); Window* window = static_cast<Window*>(child);
if (window->isForeground() || if (window->isForeground() ||
window->isDesktop()) window->isDesktop())
return window; return window;
} }
return NULL; return nullptr;
} }
Widget* Manager::getFocus() Widget* Manager::getFocus()
@ -951,8 +949,8 @@ void Manager::_closeWindow(Window* window, bool redraw_background)
// Close all windows to this desktop // Close all windows to this desktop
if (window->isDesktop()) { if (window->isDesktop()) {
while (!getChildren().empty()) { while (!children().empty()) {
Window* child = static_cast<Window*>(getChildren().front()); Window* child = static_cast<Window*>(children().front());
if (child == window) if (child == window)
break; break;
else { else {
@ -1019,11 +1017,11 @@ bool Manager::onProcessMessage(Message* msg)
// Continue sending the message to the children of all windows // Continue sending the message to the children of all windows
// (until a desktop or foreground window). // (until a desktop or foreground window).
Window* win = nullptr; Window* win = nullptr;
for (Widget* manchild : getChildren()) { for (auto manchild : children()) {
win = static_cast<Window*>(manchild); win = static_cast<Window*>(manchild);
// Send to the window. // Send to the window.
for (auto winchild : win->getChildren()) for (auto winchild : win->children())
if (winchild->sendMessage(msg)) if (winchild->sendMessage(msg))
return true; return true;
@ -1058,8 +1056,8 @@ void Manager::onResize(ResizeEvent& ev)
int dw = new_pos.w - old_pos.w; int dw = new_pos.w - old_pos.w;
int dh = new_pos.h - old_pos.h; int dh = new_pos.h - old_pos.h;
UI_FOREACH_WIDGET(getChildren(), it) { for (auto child : children()) {
Window* window = static_cast<Window*>(*it); Window* window = static_cast<Window*>(child);
if (window->isDesktop()) { if (window->isDesktop()) {
window->setBounds(new_pos); window->setBounds(new_pos);
break; break;
@ -1097,7 +1095,7 @@ void Manager::onBroadcastMouseMessage(WidgetsList& targets)
{ {
// Ask to the first window in the "children" list to know how to // Ask to the first window in the "children" list to know how to
// propagate mouse messages. // propagate mouse messages.
Widget* widget = UI_FIRST_WIDGET(getChildren()); Widget* widget = UI_FIRST_WIDGET(children());
if (widget) if (widget)
widget->broadcastMouseMessage(targets); widget->broadcastMouseMessage(targets);
} }
@ -1134,8 +1132,8 @@ void Manager::onPreferredSize(PreferredSizeEvent& ev)
else { else {
gfx::Rect pos = getParent()->getChildrenBounds(); gfx::Rect pos = getParent()->getChildrenBounds();
UI_FOREACH_WIDGET(getChildren(), it) { for (auto child : children()) {
gfx::Rect cpos = (*it)->getBounds(); gfx::Rect cpos = child->getBounds();
pos = pos.createUnion(cpos); pos = pos.createUnion(cpos);
} }
@ -1179,8 +1177,7 @@ void Manager::pumpQueue()
} }
bool done = false; bool done = false;
UI_FOREACH_WIDGET(msg->recipients(), it2) { for (auto widget : msg->recipients()) {
Widget* widget = *it2;
if (!widget) if (!widget)
continue; continue;
@ -1289,8 +1286,10 @@ void Manager::invalidateDisplayRegion(const gfx::Region& region)
// Redraw windows from top to background. // Redraw windows from top to background.
bool withDesktop = false; bool withDesktop = false;
UI_FOREACH_WIDGET(getChildren(), it) { for (auto child : children()) {
Window* window = static_cast<Window*>(*it); ASSERT(dynamic_cast<Window*>(child));
ASSERT(child->type() == kWindowWidget);
Window* window = static_cast<Window*>(child);
// Invalidate regions of this window // Invalidate regions of this window
window->invalidateRegion(reg1); window->invalidateRegion(reg1);
@ -1358,8 +1357,8 @@ Widget* Manager::findMagneticWidget(Widget* widget)
{ {
Widget* found; Widget* found;
UI_FOREACH_WIDGET(widget->getChildren(), it) { for (auto child : widget->children()) {
found = findMagneticWidget(*it); found = findMagneticWidget(child);
if (found) if (found)
return found; return found;
} }
@ -1421,7 +1420,7 @@ static bool move_focus(Manager* manager, Message* msg)
if (focus_widget) { if (focus_widget) {
window = focus_widget->getRoot(); window = focus_widget->getRoot();
} }
else if (!manager->getChildren().empty()) { else if (!manager->children().empty()) {
window = manager->getTopWindow(); window = manager->getTopWindow();
} }
@ -1520,8 +1519,8 @@ static int count_widgets_accept_focus(Widget* widget)
int count = 0; int count = 0;
UI_FOREACH_WIDGET(widget->getChildren(), it) for (auto child : widget->children())
count += count_widgets_accept_focus(*it); count += count_widgets_accept_focus(child);
if ((count == 0) && (ACCEPT_FOCUS(widget))) if ((count == 0) && (ACCEPT_FOCUS(widget)))
count++; count++;
@ -1531,21 +1530,21 @@ static int count_widgets_accept_focus(Widget* widget)
static bool childs_accept_focus(Widget* widget, bool first) static bool childs_accept_focus(Widget* widget, bool first)
{ {
UI_FOREACH_WIDGET(widget->getChildren(), it) for (auto child : widget->children())
if (childs_accept_focus(*it, false)) if (childs_accept_focus(child, false))
return true; return true;
return first ? false: ACCEPT_FOCUS(widget); return (first ? false: ACCEPT_FOCUS(widget));
} }
static Widget* next_widget(Widget* widget) static Widget* next_widget(Widget* widget)
{ {
if (!widget->getChildren().empty()) if (!widget->children().empty())
return UI_FIRST_WIDGET(widget->getChildren()); return UI_FIRST_WIDGET(widget->children());
while (widget->getParent()->type() != kManagerWidget) { while (widget->getParent()->type() != kManagerWidget) {
WidgetsList::const_iterator begin = widget->getParent()->getChildren().begin(); WidgetsList::const_iterator begin = widget->getParent()->children().begin();
WidgetsList::const_iterator end = widget->getParent()->getChildren().end(); WidgetsList::const_iterator end = widget->getParent()->children().end();
WidgetsList::const_iterator it = std::find(begin, end, widget); WidgetsList::const_iterator it = std::find(begin, end, widget);
ASSERT(it != end); ASSERT(it != end);

View File

@ -210,10 +210,10 @@ MenuItem::~MenuItem()
Menu* MenuBox::getMenu() Menu* MenuBox::getMenu()
{ {
if (getChildren().empty()) if (children().empty())
return NULL; return nullptr;
else else
return static_cast<Menu*>(getChildren().front()); return static_cast<Menu*>(children().front());
} }
MenuBaseData* MenuBox::createBase() MenuBaseData* MenuBox::createBase()
@ -264,7 +264,7 @@ void MenuItem::setHighlighted(bool state)
bool MenuItem::hasSubmenu() const bool MenuItem::hasSubmenu() const
{ {
return (m_submenu && !m_submenu->getChildren().empty()); return (m_submenu && !m_submenu->children().empty());
} }
void Menu::showPopup(const gfx::Point& pos) void Menu::showPopup(const gfx::Point& pos)
@ -319,8 +319,7 @@ void Menu::onResize(ResizeEvent& ev)
Rect cpos = getChildrenBounds(); Rect cpos = getChildrenBounds();
bool isBar = (getParent()->type() == kMenuBarWidget); bool isBar = (getParent()->type() == kMenuBarWidget);
UI_FOREACH_WIDGET(getChildren(), it) { for (auto child : children()) {
Widget* child = *it;
Size reqSize = child->getPreferredSize(); Size reqSize = child->getPreferredSize();
if (isBar) if (isBar)
@ -342,7 +341,7 @@ void Menu::onPreferredSize(PreferredSizeEvent& ev)
Size size(0, 0); Size size(0, 0);
Size reqSize; Size reqSize;
UI_FOREACH_WIDGET_WITH_END(getChildren(), it, end) { UI_FOREACH_WIDGET_WITH_END(children(), it, end) {
reqSize = (*it)->getPreferredSize(); reqSize = (*it)->getPreferredSize();
if (getParent() && getParent()->type() == kMenuBarWidget) { if (getParent() && getParent()->type() == kMenuBarWidget) {
@ -502,8 +501,7 @@ bool MenuBox::onProcessMessage(Message* msg)
bool used = false; bool used = false;
// Search a child with highlight or the submenu opened // Search a child with highlight or the submenu opened
UI_FOREACH_WIDGET(menu->getChildren(), it) { for (auto child : menu->children()) {
Widget* child = *it;
if (child->type() != kMenuItemWidget) if (child->type() != kMenuItemWidget)
continue; continue;
@ -779,9 +777,7 @@ bool MenuItem::onProcessMessage(Message* msg)
// Select the first child // Select the first child
MenuItem* first_child = NULL; MenuItem* first_child = NULL;
UI_FOREACH_WIDGET(m_submenu->getChildren(), it) { for (auto child : m_submenu->children()) {
Widget* child = *it;
if (child->type() != kMenuItemWidget) if (child->type() != kMenuItemWidget)
continue; continue;
@ -938,8 +934,7 @@ static MenuBaseData* get_base(Widget* widget)
MenuItem* Menu::getHighlightedItem() MenuItem* Menu::getHighlightedItem()
{ {
UI_FOREACH_WIDGET(getChildren(), it) { for (auto child : children()) {
Widget* child = *it;
if (child->type() != kMenuItemWidget) if (child->type() != kMenuItemWidget)
continue; continue;
@ -953,8 +948,7 @@ MenuItem* Menu::getHighlightedItem()
void Menu::highlightItem(MenuItem* menuitem, bool click, bool open_submenu, bool select_first_child) void Menu::highlightItem(MenuItem* menuitem, bool click, bool open_submenu, bool select_first_child)
{ {
// Find the menuitem with the highlight // Find the menuitem with the highlight
UI_FOREACH_WIDGET(getChildren(), it) { for (auto child : children()) {
Widget* child = *it;
if (child->type() != kMenuItemWidget) if (child->type() != kMenuItemWidget)
continue; continue;
@ -1027,8 +1021,7 @@ void MenuItem::openSubmenu(bool select_first)
// Close all siblings of 'menuitem' // Close all siblings of 'menuitem'
if (menu->getParent()) { if (menu->getParent()) {
UI_FOREACH_WIDGET(menu->getChildren(), it) { for (auto child : menu->children()) {
Widget* child = *it;
if (child->type() != kMenuItemWidget) if (child->type() != kMenuItemWidget)
continue; continue;
@ -1074,8 +1067,7 @@ void MenuItem::closeSubmenu(bool last_of_close_chain)
menu = m_submenu_menubox->getMenu(); menu = m_submenu_menubox->getMenu();
ASSERT(menu != NULL); ASSERT(menu != NULL);
UI_FOREACH_WIDGET(menu->getChildren(), it) { for (auto child : menu->children()) {
Widget* child = *it;
if (child->type() != kMenuItemWidget) if (child->type() != kMenuItemWidget)
continue; continue;
@ -1149,8 +1141,7 @@ void Menu::closeAll()
menuitem->closeSubmenu(true); menuitem->closeSubmenu(true);
} }
else { else {
UI_FOREACH_WIDGET(menu->getChildren(), it) { for (auto child : menu->children()) {
Widget* child = *it;
if (child->type() != kMenuItemWidget) if (child->type() != kMenuItemWidget)
continue; continue;
@ -1198,8 +1189,7 @@ void MenuItem::executeClick()
static MenuItem* check_for_letter(Menu* menu, int ascii) static MenuItem* check_for_letter(Menu* menu, int ascii)
{ {
UI_FOREACH_WIDGET(menu->getChildren(), it) { for (auto child : menu->children()) {
Widget* child = *it;
if (child->type() != kMenuItemWidget) if (child->type() != kMenuItemWidget)
continue; continue;
@ -1215,8 +1205,8 @@ static MenuItem* check_for_letter(Menu* menu, int ascii)
// from the first item in `menu' // from the first item in `menu'
static MenuItem* find_nextitem(Menu* menu, MenuItem* menuitem) static MenuItem* find_nextitem(Menu* menu, MenuItem* menuitem)
{ {
WidgetsList::const_iterator begin = menu->getChildren().begin(); WidgetsList::const_iterator begin = menu->children().begin();
WidgetsList::const_iterator it, end = menu->getChildren().end(); WidgetsList::const_iterator it, end = menu->children().end();
if (menuitem) { if (menuitem) {
it = std::find(begin, end, menuitem); it = std::find(begin, end, menuitem);
@ -1240,8 +1230,8 @@ static MenuItem* find_nextitem(Menu* menu, MenuItem* menuitem)
static MenuItem* find_previtem(Menu* menu, MenuItem* menuitem) static MenuItem* find_previtem(Menu* menu, MenuItem* menuitem)
{ {
WidgetsList::const_reverse_iterator begin = menu->getChildren().rbegin(); WidgetsList::const_reverse_iterator begin = menu->children().rbegin();
WidgetsList::const_reverse_iterator it, end = menu->getChildren().rend(); WidgetsList::const_reverse_iterator it, end = menu->children().rend();
if (menuitem) { if (menuitem) {
it = std::find(begin, end, menuitem); it = std::find(begin, end, menuitem);

View File

@ -69,8 +69,8 @@ void Message::broadcastToChildren(Widget* widget)
{ {
ASSERT_VALID_WIDGET(widget); ASSERT_VALID_WIDGET(widget);
UI_FOREACH_WIDGET(widget->getChildren(), it) for (auto child : widget->children())
broadcastToChildren(*it); broadcastToChildren(child);
addRecipient(widget); addRecipient(widget);
} }

View File

@ -22,8 +22,7 @@ Panel::Panel()
void Panel::showChild(Widget* widget) void Panel::showChild(Widget* widget)
{ {
UI_FOREACH_WIDGET(getChildren(), it) { for (auto child : children()) {
Widget* child = *it;
if (!child->isDecorative()) if (!child->isDecorative())
child->setVisible(child == widget); child->setVisible(child == widget);
} }
@ -37,8 +36,7 @@ void Panel::onResize(ResizeEvent& ev)
// Set all the children to the same "cpos" // Set all the children to the same "cpos"
gfx::Rect cpos = getChildrenBounds(); gfx::Rect cpos = getChildrenBounds();
UI_FOREACH_WIDGET(getChildren(), it) { for (auto child : children()) {
Widget* child = *it;
if (!child->isDecorative()) if (!child->isDecorative())
child->setBounds(cpos); child->setBounds(cpos);
} }
@ -49,9 +47,7 @@ void Panel::onPreferredSize(PreferredSizeEvent& ev)
gfx::Size maxSize(0, 0); gfx::Size maxSize(0, 0);
gfx::Size reqSize; gfx::Size reqSize;
UI_FOREACH_WIDGET(getChildren(), it) { for (auto child : children()) {
Widget* child = *it;
if (!child->isDecorative()) { if (!child->isDecorative()) {
reqSize = child->getPreferredSize(); reqSize = child->getPreferredSize();

View File

@ -163,13 +163,11 @@ void PopupWindow::onPreferredSize(PreferredSizeEvent& ev)
resultSize.w += border().width(); resultSize.w += border().width();
resultSize.h += border().height(); resultSize.h += border().height();
if (!getChildren().empty()) { if (!children().empty()) {
Size maxSize(0, 0); Size maxSize(0, 0);
Size reqSize; Size reqSize;
UI_FOREACH_WIDGET(getChildren(), it) { for (auto child : children()) {
Widget* child = *it;
reqSize = child->getPreferredSize(); reqSize = child->getPreferredSize();
maxSize.w = MAX(maxSize.w, reqSize.w); maxSize.w = MAX(maxSize.w, reqSize.w);

View File

@ -38,8 +38,7 @@ void Separator::onPreferredSize(PreferredSizeEvent& ev)
{ {
Size maxSize(0, 0); Size maxSize(0, 0);
UI_FOREACH_WIDGET(getChildren(), it) { for (auto child : children()) {
Widget* child = *it;
Size reqSize = child->getPreferredSize(); Size reqSize = child->getPreferredSize();
maxSize.w = MAX(maxSize.w, reqSize.w); maxSize.w = MAX(maxSize.w, reqSize.w);
maxSize.h = MAX(maxSize.h, reqSize.h); maxSize.h = MAX(maxSize.h, reqSize.h);

View File

@ -55,7 +55,7 @@ bool Splitter::onProcessMessage(Message* msg)
bar = click_bar = 0; bar = click_bar = 0;
UI_FOREACH_WIDGET_WITH_END(getChildren(), it, end) { UI_FOREACH_WIDGET_WITH_END(children(), it, end) {
if (it+1 != end) { if (it+1 != end) {
c1 = *it; c1 = *it;
c2 = *(it+1); c2 = *(it+1);
@ -136,7 +136,7 @@ bool Splitter::onProcessMessage(Message* msg)
int x1, y1, x2, y2; int x1, y1, x2, y2;
bool change_cursor = false; bool change_cursor = false;
UI_FOREACH_WIDGET_WITH_END(getChildren(), it, end) { UI_FOREACH_WIDGET_WITH_END(children(), it, end) {
if (it+1 != end) { if (it+1 != end) {
c1 = *it; c1 = *it;
c2 = *(it+1); c2 = *(it+1);
@ -256,7 +256,7 @@ void Splitter::onPreferredSize(PreferredSizeEvent& ev)
Size reqSize; Size reqSize;
visibleChildren = 0; visibleChildren = 0;
for (Widget* child : getChildren()) { for (auto child : children()) {
if (child->isVisible()) if (child->isVisible())
visibleChildren++; visibleChildren++;
} }
@ -264,7 +264,7 @@ void Splitter::onPreferredSize(PreferredSizeEvent& ev)
int w, h; int w, h;
w = h = 0; w = h = 0;
for (Widget* child : getChildren()) { for (auto child : children()) {
if (!child->isVisible()) if (!child->isVisible())
continue; continue;
@ -297,7 +297,7 @@ void Splitter::onLoadLayout(LoadLayoutEvent& ev)
m_pos *= guiscale(); m_pos *= guiscale();
// Do for all children // Do for all children
for (Widget* child : getChildren()) for (auto child : children())
child->loadLayout(); child->loadLayout();
} }
@ -307,13 +307,13 @@ void Splitter::onSaveLayout(SaveLayoutEvent& ev)
ev.stream() << pos; ev.stream() << pos;
// Do for all children // Do for all children
for (Widget* child : getChildren()) for (auto child : children())
child->saveLayout(); child->saveLayout();
} }
Widget* Splitter::panel1() const Widget* Splitter::panel1() const
{ {
const WidgetsList& list = getChildren(); const WidgetsList& list = children();
if (list.size() >= 1 && list[0]->isVisible()) if (list.size() >= 1 && list[0]->isVisible())
return list[0]; return list[0];
else else
@ -322,7 +322,7 @@ Widget* Splitter::panel1() const
Widget* Splitter::panel2() const Widget* Splitter::panel2() const
{ {
const WidgetsList& list = getChildren(); const WidgetsList& list = children();
if (list.size() >= 2 && list[1]->isVisible()) if (list.size() >= 2 && list[1]->isVisible())
return list[1]; return list[1];
else else

View File

@ -243,13 +243,11 @@ void TipWindow::onPreferredSize(PreferredSizeEvent& ev)
resultSize.w += border().width(); resultSize.w += border().width();
resultSize.h += border().height(); resultSize.h += border().height();
if (!getChildren().empty()) { if (!children().empty()) {
Size maxSize(0, 0); Size maxSize(0, 0);
Size reqSize; Size reqSize;
UI_FOREACH_WIDGET(getChildren(), it) { for (auto child : children()) {
Widget* child = *it;
reqSize = child->getPreferredSize(); reqSize = child->getPreferredSize();
maxSize.w = MAX(maxSize.w, reqSize.w); maxSize.w = MAX(maxSize.w, reqSize.w);

View File

@ -52,7 +52,7 @@ void View::attachToView(Widget* viewable_widget)
Widget* View::attachedWidget() Widget* View::attachedWidget()
{ {
return UI_FIRST_WIDGET(m_viewport.getChildren()); return UI_FIRST_WIDGET(m_viewport.children());
} }
void View::makeVisibleAllScrollableArea() void View::makeVisibleAllScrollableArea()
@ -147,7 +147,7 @@ void View::setViewScroll(const Point& pt)
void View::updateView() void View::updateView()
{ {
Widget* vw = UI_FIRST_WIDGET(m_viewport.getChildren()); Widget* vw = UI_FIRST_WIDGET(m_viewport.children());
Point scroll = getViewScroll(); Point scroll = getViewScroll();
// Set minimum (remove scroll-bars) // Set minimum (remove scroll-bars)

View File

@ -38,8 +38,7 @@ void Viewport::onResize(ResizeEvent& ev)
cpos.x = rect.x + border().left() - scroll.x; cpos.x = rect.x + border().left() - scroll.x;
cpos.y = rect.y + border().top() - scroll.y; cpos.y = rect.y + border().top() - scroll.y;
UI_FOREACH_WIDGET(getChildren(), it) { for (auto child : children()) {
Widget* child = *it;
Size reqSize = child->getPreferredSize(); Size reqSize = child->getPreferredSize();
cpos.w = MAX(reqSize.w, rect.w - border().width()); cpos.w = MAX(reqSize.w, rect.w - border().width());
@ -65,8 +64,8 @@ Size Viewport::calculateNeededSize()
Size maxSize(0, 0); Size maxSize(0, 0);
Size reqSize; Size reqSize;
UI_FOREACH_WIDGET(getChildren(), it) { for (auto child : children()) {
reqSize = (*it)->getPreferredSize(); reqSize = child->getPreferredSize();
maxSize.w = MAX(maxSize.w, reqSize.w); maxSize.w = MAX(maxSize.w, reqSize.w);
maxSize.h = MAX(maxSize.h, reqSize.h); maxSize.h = MAX(maxSize.h, reqSize.h);
} }

View File

@ -448,20 +448,18 @@ bool Widget::hasAncestor(Widget* ancestor)
Widget* Widget::findChild(const char* id) Widget* Widget::findChild(const char* id)
{ {
Widget* child; for (auto child : m_children) {
UI_FOREACH_WIDGET(m_children, it) {
child = *it;
if (child->getId() == id) if (child->getId() == id)
return child; return child;
} }
UI_FOREACH_WIDGET(m_children, it) { for (auto child : m_children) {
if ((child = (*it)->findChild(id))) auto subchild = child->findChild(id);
return child; if (subchild)
return subchild;
} }
return NULL; return nullptr;
} }
Widget* Widget::findSibling(const char* id) Widget* Widget::findSibling(const char* id)
@ -562,8 +560,8 @@ void Widget::loadLayout()
} }
// Do for all children // Do for all children
UI_FOREACH_WIDGET(m_children, it) for (auto child : m_children)
(*it)->loadLayout(); child->loadLayout();
} }
void Widget::saveLayout() void Widget::saveLayout()
@ -582,8 +580,8 @@ void Widget::saveLayout()
} }
// Do for all children // Do for all children
UI_FOREACH_WIDGET(m_children, it) for (auto child : m_children)
(*it)->saveLayout(); child->saveLayout();
} }
void Widget::setDecorativeWidgetBounds() void Widget::setDecorativeWidgetBounds()
@ -659,7 +657,7 @@ void Widget::getDrawableRegion(gfx::Region& region, DrawableRegionFlags flags)
manager = window ? window->getManager(): NULL; manager = window ? window->getManager(): NULL;
while (manager) { while (manager) {
const WidgetsList& windows_list = manager->getChildren(); const WidgetsList& windows_list = manager->children();
WidgetsList::const_reverse_iterator it = WidgetsList::const_reverse_iterator it =
std::find(windows_list.rbegin(), windows_list.rend(), window); std::find(windows_list.rbegin(), windows_list.rend(), window);
@ -683,12 +681,11 @@ void Widget::getDrawableRegion(gfx::Region& region, DrawableRegionFlags flags)
} }
// Clip the areas where are children // Clip the areas where are children
if (!(flags & kUseChildArea) && !getChildren().empty()) { if (!(flags & kUseChildArea) && !children().empty()) {
Region reg1; Region reg1;
Region reg2(getChildrenBounds()); Region reg2(getChildrenBounds());
UI_FOREACH_WIDGET(getChildren(), it) { for (auto child : children()) {
Widget* child = *it;
if (child->isVisible()) { if (child->isVisible()) {
Region reg3; Region reg3;
child->getRegion(reg3); child->getRegion(reg3);
@ -888,8 +885,7 @@ void Widget::flushRedraw()
if (!widget->isVisible()) if (!widget->isVisible())
continue; continue;
UI_FOREACH_WIDGET(widget->getChildren(), it) { for (auto child : widget->children()) {
Widget* child = *it;
if (child->hasFlags(DIRTY)) { if (child->hasFlags(DIRTY)) {
child->disableFlags(DIRTY); child->disableFlags(DIRTY);
processing.push(child); processing.push(child);
@ -941,10 +937,8 @@ void Widget::paint(Graphics* graphics, const gfx::Region& drawRegion)
if (!widget->isVisible()) if (!widget->isVisible())
continue; continue;
UI_FOREACH_WIDGET(widget->getChildren(), it) { for (auto child : widget->children())
Widget* child = *it;
processing.push(child); processing.push(child);
}
// Intersect drawRegion with widget's drawable region. // Intersect drawRegion with widget's drawable region.
Region region; Region region;
@ -1027,8 +1021,8 @@ void Widget::invalidate()
mark_dirty_flag(this); mark_dirty_flag(this);
UI_FOREACH_WIDGET(getChildren(), it) for (auto child : m_children)
(*it)->invalidate(); child->invalidate();
} }
} }
@ -1301,8 +1295,8 @@ bool Widget::onProcessMessage(Message* msg)
case kCloseMessage: case kCloseMessage:
case kWinMoveMessage: case kWinMoveMessage:
// Broadcast the message to the children. // Broadcast the message to the children.
UI_FOREACH_WIDGET(getChildren(), it) for (auto child : m_children)
(*it)->sendMessage(msg); child->sendMessage(msg);
break; break;
case kPaintMessage: { case kPaintMessage: {
@ -1318,8 +1312,8 @@ bool Widget::onProcessMessage(Message* msg)
case kKeyUpMessage: case kKeyUpMessage:
if (static_cast<KeyMessage*>(msg)->propagateToChildren()) { if (static_cast<KeyMessage*>(msg)->propagateToChildren()) {
// Broadcast the message to the children. // Broadcast the message to the children.
UI_FOREACH_WIDGET(getChildren(), it) for (auto child : m_children)
if ((*it)->sendMessage(msg)) if (child->sendMessage(msg))
return true; return true;
} }
@ -1387,8 +1381,8 @@ void Widget::onInvalidateRegion(const Region& region)
mark_dirty_flag(this); mark_dirty_flag(this);
UI_FOREACH_WIDGET(getChildren(), it) for (auto child : m_children)
(*it)->invalidateRegion(reg1); child->invalidateRegion(reg1);
} }
} }
@ -1413,8 +1407,8 @@ void Widget::onResize(ResizeEvent& ev)
// Set all the children to the same "cpos". // Set all the children to the same "cpos".
gfx::Rect cpos = getChildrenBounds(); gfx::Rect cpos = getChildrenBounds();
UI_FOREACH_WIDGET(getChildren(), it) for (auto child : m_children)
(*it)->setBounds(cpos); child->setBounds(cpos);
} }
void Widget::onPaint(PaintEvent& ev) void Widget::onPaint(PaintEvent& ev)
@ -1479,8 +1473,8 @@ void Widget::offsetWidgets(int dx, int dy)
m_updateRegion.offset(dx, dy); m_updateRegion.offset(dx, dy);
m_bounds.offset(dx, dy); m_bounds.offset(dx, dy);
UI_FOREACH_WIDGET(m_children, it) for (auto child : m_children)
(*it)->offsetWidgets(dx, dy); child->offsetWidgets(dx, dy);
} }
} // namespace ui } // namespace ui

View File

@ -168,7 +168,7 @@ namespace ui {
void getParents(bool ascendant, WidgetsList& parents); void getParents(bool ascendant, WidgetsList& parents);
// Returns a list of children. // Returns a list of children.
const WidgetsList& getChildren() const { return m_children; } const WidgetsList& children() const { return m_children; }
Widget* at(int index) { return m_children[index]; } Widget* at(int index) { return m_children[index]; }
@ -201,8 +201,7 @@ namespace ui {
template<class T> template<class T>
T* findFirstChildByType() { T* findFirstChildByType() {
UI_FOREACH_WIDGET(m_children, it) { for (auto child : m_children) {
Widget* child = *it;
if (T* specificChild = dynamic_cast<T*>(child)) if (T* specificChild = dynamic_cast<T*>(child))
return specificChild; return specificChild;
} }

View File

@ -1,5 +1,5 @@
// Aseprite UI Library // Aseprite UI Library
// Copyright (C) 2001-2013 David Capello // Copyright (C) 2001-2013, 2015 David Capello
// //
// This file is released under the terms of the MIT license. // This file is released under the terms of the MIT license.
// Read LICENSE.txt for more information. // Read LICENSE.txt for more information.
@ -10,13 +10,6 @@
#include <vector> #include <vector>
#define UI_FOREACH_WIDGET(list_name, iterator_name) \
for (WidgetsList::const_iterator \
iterator_name = (list_name).begin(), \
__end = (list_name).end(); \
iterator_name != __end; \
++iterator_name)
#define UI_FOREACH_WIDGET_BACKWARD(list_name, iterator_name) \ #define UI_FOREACH_WIDGET_BACKWARD(list_name, iterator_name) \
for (WidgetsList::const_reverse_iterator \ for (WidgetsList::const_reverse_iterator \
iterator_name = (list_name).rbegin(), \ iterator_name = (list_name).rbegin(), \

View File

@ -102,8 +102,8 @@ HitTest Window::hitTest(const gfx::Point& point)
void Window::removeDecorativeWidgets() void Window::removeDecorativeWidgets()
{ {
while (!getChildren().empty()) while (!children().empty())
delete getChildren().front(); delete children().front();
} }
void Window::onClose(CloseEvent& ev) void Window::onClose(CloseEvent& ev)
@ -266,8 +266,8 @@ void Window::closeWindow(Widget* killer)
bool Window::isTopLevel() bool Window::isTopLevel()
{ {
Widget* manager = getManager(); Widget* manager = getManager();
if (!manager->getChildren().empty()) if (!manager->children().empty())
return (this == UI_FIRST_WIDGET(manager->getChildren())); return (this == UI_FIRST_WIDGET(manager->children()));
else else
return false; return false;
} }
@ -435,9 +435,7 @@ void Window::onPreferredSize(PreferredSizeEvent& ev)
Size maxSize(0, 0); Size maxSize(0, 0);
Size reqSize; Size reqSize;
UI_FOREACH_WIDGET(getChildren(), it) { for (auto child : children()) {
Widget* child = *it;
if (!child->isDecorative()) { if (!child->isDecorative()) {
reqSize = child->getPreferredSize(); reqSize = child->getPreferredSize();
@ -486,9 +484,7 @@ void Window::windowSetPosition(const gfx::Rect& rect)
Rect cpos = getChildrenBounds(); Rect cpos = getChildrenBounds();
// Set all the children to the same "cpos" // Set all the children to the same "cpos"
UI_FOREACH_WIDGET(getChildren(), it) { for (auto child : children()) {
Widget* child = *it;
if (child->isDecorative()) if (child->isDecorative())
child->setDecorativeWidgetBounds(); child->setDecorativeWidgetBounds();
else else