Widget::WidgetsList Widget::GetWidgetsByClass( const std::string& class_name ) { WidgetsList result; for( const auto& root_widget : root_widgets ) { if( root_widget->GetClass() == class_name ) { result.push_back( root_widget->shared_from_this() ); } auto container = std::dynamic_pointer_cast<Container>( root_widget->shared_from_this() ); if( container ) { auto container_result = SearchContainerForClass( container, class_name ); // Splice the 2 vectors. if( !container_result.empty() ) { result.reserve( container_result.size() ); result.insert( result.end(), container_result.begin(), container_result.end() ); } } } return result; }
virtual void onBroadcastMouseMessage(WidgetsList& targets) override { Window::onBroadcastMouseMessage(targets); // Add the editor as receptor of mouse events too. targets.push_back(View::getView(m_editor)); }
void Widget::getParents(bool ascendant, WidgetsList& parents) { for (Widget* widget=this; widget; widget=widget->m_parent) { // append parents in tail if (ascendant) parents.push_back(widget); // append parents in head else parents.insert(parents.begin(), widget); } }
void Description::printPage() { TextPage *page = text->getPage(currentPage); if (! page) return; int len = page->getWidgetsCount(); for (int i = 0; i < len; i++) { Widget *w = page->getWidget(i); if (w) { widgets.push_back(w); area.add(w); } } }
void Workspace::updateTabs() { WidgetsList children = this->children(); while (!children.empty()) { Widget* child = children.back(); children.erase(--children.end()); if (child->type() == WorkspacePanel::Type()) static_cast<WorkspacePanel*>(child)->tabs()->updateTabs(); for (auto subchild : child->children()) children.push_back(subchild); } }