예제 #1
0
파일: Widget.cpp 프로젝트: Cruel/SFGUI
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;
}
예제 #2
0
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);
  }
}