/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~FUNCTION~~~~~~ NOTES: Similar as the above, but it adds every element in the given list, rather than the list itself. */ void List::AppendListWithoutCopy( ListPtr X ) { unsigned int i; for( i = 0; i< X->GetInternalList().size(); i++ ) { PushWithoutCopy( X->GetInternalList()[i] ); } }
void Slice::ChecksumVisitor::visitList(const ListPtr& p) { if (p->isLocal()) { return; } ostringstream ostr; ostr << "list<" << typeToString(p->type()) << "> " << p->name() << endl; updateMap(p->scoped(), ostr.str()); }
List<Font::CHAR_INFO> parseFontSpec(const String& filename) { #ifdef _DEBUG printf("\t parsing fontSpec\n"); #endif String s; if (!load_text_file(filename, &s)) { //TODO: error } ListPtr<String*> strings; s.split(strings, " \n"); uint_d size = strings.getSize(); if (*strings[0] != "#spec" && *strings[size-1] != "#end") { //TODO: log error } List<Font::CHAR_INFO> charSpec; for (uint_d i = 1; i < size; i+=5) { String& character = *strings[i]; if (character == "#end") { break; } else if (character == "" || character == "\n" || character == " ") { continue; } else { Font::CHAR_INFO cInfo; cInfo.c = character[0]; const char c = (*strings[i + 1])[0]; if (c == '#') { Font::CHAR_INFO exist = getCharInfoFromSpec(charSpec, (*strings[i + 1])[1]); exist.c = cInfo.c; charSpec << exist; }else { cInfo.xOffset = (float)atof(**strings[i + 1]); cInfo.yOffset = (float)atof(**strings[i + 2]); cInfo.cWidth = (float)atof(**strings[i + 3]); cInfo.cHeight = (float)atof(**strings[i + 4]); charSpec << cInfo; #ifdef _DEBUG printf("\t\t Retriving %c\n", cInfo.c); #endif } } } #ifdef _DEBUG printf("\t Done!\n"); #endif return charSpec; }
VariableBasePtr List::PushOp::Operate( VariableBasePtr pX ) { ListPtr pXList = pX->CastToList(); const ListType& XList = pXList->GetInternalList(); size_t i; for( i = 0; i < XList.size(); i++ ) { mParentList.Push( XList[i] ); } return mParentList.CastToVariableBase(); }
int addMiddleList(ListPtr listp,NodePtr position,void* data){ /* Add new Node in the middle of the Queue */ int i=0; //there is always a previous and a next Node if(listp->items > 0){ if(position == NULL) { printf("Position not valid...\n"); return -1; } else { listp->Current = position->previous; //Current is the previous Node } listp->Current->next = malloc(sizeof(Node)); listp->Current->next->previous = listp->Current; listp->Current->next->next = position; position->previous = listp->Current->next; listp->allocateNode(&(listp->Current->next->data),data); listp->Current = listp->Head; (listp->items)++; } else{ printf("List is not properly initialised...\n"); return -1; } }
void removeLastList(ListPtr listp){ /* Removes 1 Node from the Start of the List */ if(listp->items > 0){ if(listp->items == 1){ popList(listp); } else{ listp->Current = listp->Last->previous; if(listp->Last != NULL){ listp->destroyNode(&(listp->Last->data)); free(listp->Last); (listp->items)--; } listp->Last = listp->Current; listp->Last->next = (Node*) NULL; } } }
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~FUNCTION~~~~~~ List::AppendList NOTES: Adds all the elements of one list onto another. */ void List::AppendList( const ListPtr OtherList ){ unsigned int i; const ListType& OtherVector = OtherList->GetInternalList(); for( i = 0; i < OtherVector.size(); i++ ){ mList.push_back( CreateVariable<Variable>( SS_BASE_ARGS_DEFAULTS, *(OtherVector[i]->CastToVariable()) ) ); } }
virtual void selectionChanged(const ListSelectionEventPtr e) { if(ExampleList->getSelectionModel()->getMinSelectionIndex() != -1) { beginEditCP(DetailsWindow, TextArea::TextFieldMask); DetailsWindow->setText(GenericInventoryItem::Ptr::dcast(ExampleInventory->getInventoryItems(ExampleList->getSelectionModel()->getMinSelectionIndex()))->getDetails()); endEditCP(DetailsWindow, TextArea::TextFieldMask); } }
int addLastList(ListPtr listp,void* data){ /* Adds a Node to the end of the List */ int i=0; if(listp->items == 0){ /* No items yet */ listp->Head = malloc(sizeof(Node)); listp->allocateNode(&(listp->Head->data),data); listp->Head->next = (Node*) NULL; listp->Head->previous = (Node*) NULL; listp->Current = listp->Head; listp->Last = listp->Head; (listp->items)++; return 0; } else if(listp->items > 0){ listp->Last->next = malloc(sizeof(Node)); listp->Last->next->previous = listp->Last; listp->Last = listp->Last->next; listp->Last->next = (Node*) NULL; listp->allocateNode(&(listp->Last->data),data); (listp->items)++; listp->Current = listp->Last; return 0; } else{ printf("List is not properly initialised...\n"); return -1; } }
void Bencoder::parseNextType(const std::string& str, unsigned int& pos, ListPtr list) { m_logger->log(logger::Logger::FINE, "Bencoder::parseNextType()"); switch (str[pos]) { case 'd': break; case 'l': { ListPtr l = parseList(str, pos); //m_lists.push_back( reinterpret_cast<AnyType>(l) ); break; } case 'i': { list->push_back( parseInteger(str, pos) ); break; } default: list->push_back( parseString(str, pos) ); break; } }
int addFirstList(ListPtr listp,void* data){ /* Add new Node as Head of the Queue */ int i=0; if(listp->items == 0){ listp->Head = malloc(sizeof(Node)); listp->allocateNode(&(listp->Head->data),data); listp->Head->next = (Node*) NULL; listp->Head->previous = (Node*) NULL; listp->Current = listp->Head; listp->Last = listp->Head; (listp->items)++; return 0; } else if(listp->items > 0){ listp->Head->previous = malloc(sizeof(Node)); listp->Head->previous->next = listp->Head; listp->Head = listp->Head->previous; listp->allocateNode(&(listp->Head->data),data); listp->Head->previous = (Node*) NULL; listp->Current = listp->Head; (listp->items)++; } else{ printf("List is not properly initialised...\n"); return -1; } }
/** * this method searches the nodes in the list to find one with the same jobid as the passed in value */ NodePtr search(const ListPtr list, const void * searchFor) { if (list == NULL ) return NULL ; if (list->size < 0 || (list->head != NULL && list->head->data == NULL) || (list->tail != NULL && list->tail->data == NULL)) return NULL; if (list ->size == 0 && list->head == NULL && list->tail ==NULL) return NULL; if (searchFor == NULL) return NULL; NodePtr temp = list->head; while (temp != NULL ) { if (list->compareTo(searchFor, temp->data)) return temp; else temp = temp->next; } return NULL; }
void popList(ListPtr listp){ /* Removes 1 Node from the End of the List */ if(listp->items > 0){ listp->Current = listp->Head; listp->Head = listp->Head->next; /* Make Head point to its next and make the previous of new Head be NULL */ if(listp->Head != NULL) listp->Head->previous = (Node*) NULL; if(listp->Current != NULL){ listp->destroyNode(&(listp->Current->data)); free(listp->Current); (listp->items)--; } listp->Current = listp->Head; } }
NodePtr search(ListPtr list, const void * o) { NodePtr tempNode; if (list == NULL ) { return NULL ; } if (list->head == NULL ) { return NULL ; } tempNode = list->head; while (tempNode->next) { if (list->compareTo(( void *)o,( void *)tempNode->obj)==0) { return tempNode; } tempNode = tempNode->next; } return NULL ; }
void removeCurrentNode(ListPtr listp){ /* Removes the Node Current points to */ Node* temp; if(listp->items > 0){ if(listp->items == 1){ popList(listp); } else{ if(listp->Current == listp->Last){ removeLastList(listp); } else{ if(listp->Current != NULL){ listp->destroyNode(&(listp->Current->data)); temp = listp->Current->next; listp->Current->previous->next = listp->Current->next; /* Make the previous of the Current have as next the next of Current and vice versa */ listp->Current->next->previous = listp->Current->previous; free(listp->Current); listp->Current = temp; (listp->items)--; //TODO: TEST AND FIX MIDDLE } } } } }
/////////////////////////////////////////////////////////////////////////////// // Creates UI for the field variable specified. // void ReflectStlSetInterpreter::InterpretField( const Reflect::Field* field, const std::vector<Reflect::Object*>& instances, Container* parent ) { if ( field->m_Flags & Reflect::FieldFlags::Hide ) { return; } // create the container ContainerPtr container = CreateControl< Container >(); parent->AddChild( container ); tstring temp; field->GetProperty( TXT( "UIName" ), temp ); if ( temp.empty() ) { bool converted = Helium::ConvertString( field->m_Name, temp ); HELIUM_ASSERT( converted ); } container->a_Name.Set( temp ); // create the data objects std::vector< Reflect::Object* >::const_iterator itr = instances.begin(); std::vector< Reflect::Object* >::const_iterator end = instances.end(); for ( ; itr != end; ++itr ) { Reflect::DataPtr ser = Reflect::AssertCast< Reflect::Data >( Reflect::Registry::GetInstance()->CreateInstance( field->m_DataClass ) ); uintptr_t fieldAddress = ( uintptr_t )( *itr ) + field->m_Offset; ser->ConnectData( ( void* )fieldAddress ); m_Datas.push_back( ser ); } // create the list ListPtr list = CreateControl< List >(); list->a_HelpText.Set( field->GetProperty( TXT( "HelpText" ) ) ); container->AddChild( list ); // bind the ui to the serialiers list->Bind( new MultiStringFormatter< Reflect::Data >( (std::vector<Reflect::Data*>&)m_Datas ) ); // create the buttons if we are not read only if ( !( field->m_Flags & Reflect::FieldFlags::ReadOnly ) ) { ContainerPtr buttonContainer = CreateControl< Container >(); container->AddChild( buttonContainer ); ButtonPtr buttonAdd = CreateControl< Button >(); buttonContainer->AddChild( buttonAdd ); buttonAdd->a_Label.Set( TXT( "Add" ) ); buttonAdd->a_HelpText.Set( TXT( "Add an item to the list." ) ); buttonAdd->ButtonClickedEvent().Add( ButtonClickedSignature::Delegate ( this, &ReflectStlSetInterpreter::OnAdd ) ); buttonAdd->SetClientData( new ClientData( list ) ); ButtonPtr buttonRemove = CreateControl< Button >(); buttonContainer->AddChild( buttonRemove ); buttonRemove->a_Label.Set( TXT( "Remove" ) ); buttonRemove->a_HelpText.Set( TXT( "Remove the selected item(s) from the list." ) ); buttonRemove->ButtonClickedEvent().Add( ButtonClickedSignature::Delegate ( this, &ReflectStlSetInterpreter::OnRemove ) ); buttonRemove->SetClientData( new ClientData( list ) ); } // for now let's just disable this container if there is more than one item selected. I'm not sure if it will behave properly in this case. if ( instances.size() > 1 ) { container->a_IsEnabled.Set( false ); } }
int main(int argc, char **argv) { // OSG init osgInit(argc,argv); TutorialWindowEventProducer = createDefaultWindowEventProducer(); WindowPtr MainWindow = TutorialWindowEventProducer->initWindow(); TutorialWindowEventProducer->setDisplayCallback(display); TutorialWindowEventProducer->setReshapeCallback(reshape); TutorialKeyListener TheKeyListener; TutorialWindowEventProducer->addKeyListener(&TheKeyListener); // Make Torus Node (creates Torus in background of scene) NodePtr TorusGeometryNode = makeTorus(.5, 2, 16, 16); // Make Main Scene Node and add the Torus NodePtr scene = osg::Node::create(); beginEditCP(scene, Node::CoreFieldMask | Node::ChildrenFieldMask); scene->setCore(osg::Group::create()); scene->addChild(TorusGeometryNode); endEditCP(scene, Node::CoreFieldMask | Node::ChildrenFieldMask); // Create the Graphics GraphicsPtr TutorialGraphics = osg::Graphics2D::create(); // Initialize the LookAndFeelManager to enable default settings LookAndFeelManager::the()->getLookAndFeel()->init(); //Create InventoryItems ExampleInventory = Inventory::create(); GenericInventoryItemPtr ExampleItem1 = GenericInventoryItem::create(); GenericInventoryItemPtr ExampleItem2 = GenericInventoryItem::create(); GenericInventoryItemPtr ExampleItem3 = GenericInventoryItem::create(); GenericInventoryItemPtr ExampleItem4 = GenericInventoryItem::create(); GenericInventoryItemPtr ExampleItem5 = GenericInventoryItem::create(); GenericInventoryItemPtr ExampleItem6 = GenericInventoryItem::create(); GenericInventoryItemPtr ExampleItem7 = GenericInventoryItem::create(); beginEditCP(ExampleItem1, InventoryItem::NameFieldMask | GenericInventoryItem::DetailsFieldMask); ExampleItem1->setName(std::string("David K")); ExampleItem1->setDetails(std::string("Major: Human Computer Interaction \nDegree: PhD \nDepartment: Computer Science \nCollege: LAS")); endEditCP(ExampleItem1, InventoryItem::NameFieldMask | GenericInventoryItem::DetailsFieldMask); beginEditCP(ExampleItem2, InventoryItem::NameFieldMask | GenericInventoryItem::DetailsFieldMask); ExampleItem2->setName(std::string("Eve W")); ExampleItem2->setDetails(std::string("Department: Genetics Development and Cell Biology\n\nCollege: Agriculture")); endEditCP(ExampleItem2, InventoryItem::NameFieldMask | GenericInventoryItem::DetailsFieldMask); beginEditCP(ExampleItem3, InventoryItem::NameFieldMask | GenericInventoryItem::DetailsFieldMask); ExampleItem3->setName(std::string("Will S")); ExampleItem3->setDetails(std::string("Major: Art And Design\nDegree: BFA\nDepartment: Art and Design\nCollege: Design")); endEditCP(ExampleItem3, InventoryItem::NameFieldMask | GenericInventoryItem::DetailsFieldMask); beginEditCP(ExampleItem4, InventoryItem::NameFieldMask | GenericInventoryItem::DetailsFieldMask); ExampleItem4->setName(std::string("Eric L")); ExampleItem4->setDetails(std::string("Major: Software Engineering\nDegree: BS\nDepartment: Software Engineering\nCollege: Engineering")); endEditCP(ExampleItem4, InventoryItem::NameFieldMask | GenericInventoryItem::DetailsFieldMask); beginEditCP(ExampleItem5, InventoryItem::NameFieldMask | GenericInventoryItem::DetailsFieldMask); ExampleItem5->setName(std::string("Jeffery F")); ExampleItem5->setDetails(std::string("Major: Integrated Studio Arts\nDegree: BFA\nDepartment: Art and Design\nCollege: Design")); endEditCP(ExampleItem5, InventoryItem::NameFieldMask | GenericInventoryItem::DetailsFieldMask); beginEditCP(ExampleItem6, InventoryItem::NameFieldMask | GenericInventoryItem::DetailsFieldMask); ExampleItem6->setName(std::string("Tao L")); ExampleItem6->setDetails(std::string("Major: Computer Engineering\nDegree: PhD\nDepartment: Computer Engineering\nCollege: Engineering")); endEditCP(ExampleItem6, InventoryItem::NameFieldMask | GenericInventoryItem::DetailsFieldMask); beginEditCP(ExampleItem7, InventoryItem::NameFieldMask | GenericInventoryItem::DetailsFieldMask); ExampleItem7->setName(std::string("Daniel G")); ExampleItem7->setDetails(std::string("Major: Computer Engineering\nDegree: BS\nDepartment: Computer Engineering\nCollege: Engineering")); endEditCP(ExampleItem7, InventoryItem::NameFieldMask | GenericInventoryItem::DetailsFieldMask); ExampleInventory->addItem(ExampleItem1); ExampleInventory->addItem(ExampleItem2); ExampleInventory->addItem(ExampleItem3); ExampleInventory->addItem(ExampleItem4); ExampleInventory->addItem(ExampleItem5); ExampleInventory->addItem(ExampleItem6); ExampleInventory->addItem(ExampleItem7); /****************************************************** Create a List. A List has several parts to it: -ListModel: Contains the data which is to be displayed in the List. Data is added as shown below -ListCellRenderer: Creates the Components to be used within the List (the default setting is to create Labels using the desired text). -ListSelectionModel: Determines how the List may be selected. To add values to the list: First, create SFStrings and use the .setValue("Value") function to set their values. Then, use the .pushBack(&SFStringName) to add them to the List. Next, create the CellRenderer and ListSelectionModel defaults. Finally, actually create the List. Set its Model, CellRenderer, and SelectionModel as shown below. Finally, choose the type of display for the List (choices outlined below). ******************************************************/ // Add data to it ExampleListModel = InventoryListModel::create(); beginEditCP(ExampleListModel, InventoryListModel::CurrentInventoryFieldMask); ExampleListModel->setCurrentInventory(ExampleInventory); endEditCP(ExampleListModel, InventoryListModel::CurrentInventoryFieldMask); /****************************************************** Create ListCellRenderer and ListSelectionModel. Most often the defauls will be used. Note: the ListSelectionModel was created above and is referenced by the ActionListeners. ******************************************************/ /****************************************************** Create List itself and assign its Model, CellRenderer, and SelectionModel to it. -setOrientation(ENUM): Determine the Layout of the cells (Horizontal or Vertical). Takes List::VERTICAL_ORIENTATION and List::HORIZONTAL_ORIENTATION arguments. ******************************************************/ ExampleList = List::create(); beginEditCP(ExampleList, List::PreferredSizeFieldMask | List::OrientationFieldMask | List::ModelFieldMask); ExampleList->setPreferredSize(Vec2f(200, 300)); ExampleList->setOrientation(List::VERTICAL_ORIENTATION); //ExampleList->setOrientation(List::HORIZONTAL_ORIENTATION); ExampleList->setModel(ExampleListModel); endEditCP(ExampleList, List::PreferredSizeFieldMask | List::OrientationFieldMask | List::ModelFieldMask); ExampleList->setSelectionModel(ExampleListSelectionModel); InventoryListListener TheInventoryListListener; ExampleList->getSelectionModel()->addListSelectionListener(&TheInventoryListListener); // Create The Main InternalWindow // Create Background to be used with the Main InternalWindow ColorLayerPtr MainInternalWindowBackground = osg::ColorLayer::create(); beginEditCP(MainInternalWindowBackground, ColorLayer::ColorFieldMask); MainInternalWindowBackground->setColor(Color4f(1.0,1.0,1.0,0.5)); endEditCP(MainInternalWindowBackground, ColorLayer::ColorFieldMask); /****************************************************** Determine the SelectionModel -SINGLE_SELECTION lets you select ONE item via a single mouse click -SINGLE_INTERVAL_SELECTION lets you select one interval via mouse and SHIFT key -MULTIPLE_INTERVAL_SELECTION lets you select via mouse, and SHIFT and CONTRL keys Note: this tutorial is currently set up to allow for this to be changed via TogggleButtons with ActionListeners attached to them so this code is commented out. ******************************************************/ //SelectionModel.setMode(DefaultListSelectionModel::SINGLE_SELECTION); //SelectionModel.setMode(DefaultListSelectionModel::SINGLE_INTERVAL_SELECTION); //SelectionModel.setMode(DefaultListSelectionModel::MULTIPLE_INTERVAL_SELECTION); // Create a ScrollPanel for easier viewing of the List (see 27ScrollPanel) ScrollPanelPtr ExampleScrollPanel = ScrollPanel::create(); beginEditCP(ExampleScrollPanel, ScrollPanel::PreferredSizeFieldMask | ScrollPanel::HorizontalResizePolicyFieldMask | ScrollPanel::BackgroundFieldMask); ExampleScrollPanel->setPreferredSize(Vec2f(200,100)); ExampleScrollPanel->setBackgrounds(MainInternalWindowBackground); ExampleScrollPanel->setHorizontalResizePolicy(ScrollPanel::RESIZE_TO_VIEW); //ExampleScrollPanel->setVerticalResizePolicy(ScrollPanel::RESIZE_TO_VIEW); endEditCP(ExampleScrollPanel, ScrollPanel::PreferredSizeFieldMask | ScrollPanel::HorizontalResizePolicyFieldMask | ScrollPanel::BackgroundFieldMask); ExampleScrollPanel->setViewComponent(ExampleList); // Create MainFramelayout FlowLayoutPtr MainInternalWindowLayout = osg::FlowLayout::create(); beginEditCP(MainInternalWindowLayout, FlowLayout::OrientationFieldMask | FlowLayout::MajorAxisAlignmentFieldMask | FlowLayout::MinorAxisAlignmentFieldMask); MainInternalWindowLayout->setOrientation(FlowLayout::HORIZONTAL_ORIENTATION); MainInternalWindowLayout->setMajorAxisAlignment(0.5f); MainInternalWindowLayout->setMinorAxisAlignment(0.5f); endEditCP(MainInternalWindowLayout, FlowLayout::OrientationFieldMask | FlowLayout::MajorAxisAlignmentFieldMask | FlowLayout::MinorAxisAlignmentFieldMask); DetailsWindow = osg::TextArea::create(); beginEditCP(DetailsWindow, TextArea::PreferredSizeFieldMask); DetailsWindow->setPreferredSize(Pnt2f(200,100)); DetailsWindow->setMinSize(Vec2f(200,100)); endEditCP(DetailsWindow, TextArea::PreferredSizeFieldMask); InternalWindowPtr MainInternalWindow = osg::InternalWindow::create(); beginEditCP(MainInternalWindow, InternalWindow::ChildrenFieldMask | InternalWindow::LayoutFieldMask | InternalWindow::BackgroundsFieldMask | InternalWindow::AlignmentInDrawingSurfaceFieldMask | InternalWindow::ScalingInDrawingSurfaceFieldMask | InternalWindow::DrawTitlebarFieldMask | InternalWindow::ResizableFieldMask); MainInternalWindow->getChildren().push_back(ExampleScrollPanel); MainInternalWindow->getChildren().push_back(DetailsWindow); MainInternalWindow->setLayout(MainInternalWindowLayout); MainInternalWindow->setBackgrounds(MainInternalWindowBackground); MainInternalWindow->setAlignmentInDrawingSurface(Vec2f(0.5f,0.5f)); MainInternalWindow->setScalingInDrawingSurface(Vec2f(0.7f,0.5f)); MainInternalWindow->setDrawTitlebar(false); MainInternalWindow->setResizable(false); endEditCP(MainInternalWindow, InternalWindow::ChildrenFieldMask | InternalWindow::LayoutFieldMask | InternalWindow::BackgroundsFieldMask | InternalWindow::AlignmentInDrawingSurfaceFieldMask | InternalWindow::ScalingInDrawingSurfaceFieldMask | InternalWindow::DrawTitlebarFieldMask | InternalWindow::ResizableFieldMask); // Create the Drawing Surface UIDrawingSurfacePtr TutorialDrawingSurface = UIDrawingSurface::create(); beginEditCP(TutorialDrawingSurface, UIDrawingSurface::GraphicsFieldMask | UIDrawingSurface::EventProducerFieldMask); TutorialDrawingSurface->setGraphics(TutorialGraphics); TutorialDrawingSurface->setEventProducer(TutorialWindowEventProducer); endEditCP(TutorialDrawingSurface, UIDrawingSurface::GraphicsFieldMask | UIDrawingSurface::EventProducerFieldMask); TutorialDrawingSurface->openWindow(MainInternalWindow); // Create the UI Foreground Object UIForegroundPtr TutorialUIForeground = osg::UIForeground::create(); beginEditCP(TutorialUIForeground, UIForeground::DrawingSurfaceFieldMask); TutorialUIForeground->setDrawingSurface(TutorialDrawingSurface); endEditCP(TutorialUIForeground, UIForeground::DrawingSurfaceFieldMask); // Create the SimpleSceneManager helper mgr = new SimpleSceneManager; // Tell the Manager what to manage mgr->setWindow(MainWindow); mgr->setRoot(scene); // Add the UI Foreground Object to the Scene ViewportPtr TutorialViewport = mgr->getWindow()->getPort(0); beginEditCP(TutorialViewport, Viewport::ForegroundsFieldMask); TutorialViewport->getForegrounds().push_back(TutorialUIForeground); beginEditCP(TutorialViewport, Viewport::ForegroundsFieldMask); // Show the whole Scene mgr->showAll(); Vec2f WinSize(TutorialWindowEventProducer->getDesktopSize() * 0.85f); Pnt2f WinPos((TutorialWindowEventProducer->getDesktopSize() - WinSize) *0.5); TutorialWindowEventProducer->openWindow(WinPos, WinSize, "09Inventory"); //Enter main Loop TutorialWindowEventProducer->mainLoop(); osgExit(); return 0; }
void ReflectStlVectorInterpreter::InterpretField(const Field* field, const std::vector<Reflect::Object*>& instances, Container* parent) { if (field->m_Flags & FieldFlags::Hide) { return; } // create the label ContainerPtr labelContainer = CreateControl<Container>(); parent->AddChild( labelContainer ); LabelPtr label = CreateControl< Label >(); label->a_HelpText.Set( field->GetProperty( TXT( "HelpText" ) ) ); labelContainer->AddChild( label ); tstring temp; field->GetProperty( TXT( "UIName" ), temp ); if ( temp.empty() ) { bool converted = Helium::ConvertString( field->m_Name, temp ); HELIUM_ASSERT( converted ); } label->BindText( temp ); // create the list view ContainerPtr listContainer = CreateControl<Container>(); parent->AddChild( listContainer ); ListPtr list = CreateControl<List>(); list->a_HelpText.Set( field->GetProperty( TXT( "HelpText" ) ) ); listContainer->AddChild( list ); // create the buttons ButtonPtr addButton; ButtonPtr removeButton; ButtonPtr upButton; ButtonPtr downButton; if ( !(field->m_Flags & FieldFlags::ReadOnly) ) { addButton = AddAddButton( list ); removeButton = AddRemoveButton( list ); upButton = AddMoveUpButton( list ); downButton = AddMoveDownButton( list ); } // add the buttons to the container ContainerPtr buttonContainer = CreateControl<Container>(); parent->AddChild( buttonContainer ); if ( addButton ) { buttonContainer->AddChild( addButton ); } if ( removeButton ) { buttonContainer->AddChild( removeButton ); } if ( upButton ) { buttonContainer->AddChild( upButton ); } if ( downButton ) { buttonContainer->AddChild( downButton ); } // create the data objects std::vector<Reflect::Object*>::const_iterator itr = instances.begin(); std::vector<Reflect::Object*>::const_iterator end = instances.end(); for ( ; itr != end; ++itr ) { DataPtr s = field->CreateData(); OnCreateFieldData( s ); s->ConnectField(*itr, field); m_Datas.push_back(s); } // bind the ui to the data objects Helium::SmartPtr< MultiStringFormatter<Data> > data = new MultiStringFormatter<Reflect::Data>( (std::vector<Reflect::Data*>&)m_Datas ); list->Bind( data ); // setup the default value DataPtr defaultData = field->CreateDefaultData(); if (defaultData) { tstringstream defaultStream; *defaultData >> defaultStream; list->a_Default.Set( defaultStream.str() ); } }
void MultiList::sortList() { if (ITEM_NONE == mSortColumnIndex) return; ListPtr list = mVectorColumnInfo[mSortColumnIndex].list; size_t count = list->getItemCount(); if (0 == count) return; VectorSizeT vec; size_t size = mToSortIndex.size(); vec.resize(size); for (size_t pos=0; pos<size; ++pos) vec[mToSortIndex[pos]] = pos; struct Keeper { inline void keep(VectorSizeT & vec, VectorSizeT & vec2, VectorColumnInfo & info, size_t _index) { text.resize(info.size()); std::vector<Ogre::UTFString>::iterator itext = text.begin(); for (VectorColumnInfo::iterator iter=info.begin(); iter!=info.end(); ++iter, ++itext) { (*itext) = (*iter).list->getItem(_index); } index1 = _index; index2 = vec2[_index]; } inline void restore(VectorSizeT & vec, VectorSizeT & vec2, VectorColumnInfo & info, size_t _index) { std::vector<Ogre::UTFString>::iterator itext = text.begin(); for (VectorColumnInfo::iterator iter=info.begin(); iter!=info.end(); ++iter, ++itext) { (*iter).list->setItem(_index, *itext); } vec[vec2[_index]] = index1; vec2[_index] = index2; } inline void swap(VectorSizeT & vec, VectorSizeT & vec2, VectorColumnInfo & info, size_t _index1, size_t _index2) { for (VectorColumnInfo::iterator iter=info.begin(); iter!=info.end(); ++iter) { (*iter).list->setItem(_index1, (*iter).list->getItem(_index2)); } vec[vec2[_index1]] = _index2; vec2[_index1] = vec2[_index2]; } std::vector<Ogre::UTFString> text; size_t index1, index2; }; Keeper keeper; int step = (int)count/2; if (mSortUp) { for( ; step>0 ; ) { for( size_t i=0; i<(count-step); ++i ) { int j = (int)i; while ( (j>=0) && (list->getItem(j) > list->getItem(j+step)) ){ keeper.keep(mToSortIndex, vec, mVectorColumnInfo, j); keeper.swap(mToSortIndex, vec, mVectorColumnInfo, j, j+step); keeper.restore(mToSortIndex, vec, mVectorColumnInfo, j+step); --j; } } step >>= 1; } } else { for( ; step>0 ; ) {
int main () { int a; short b; APTR ptr; WORD c; struct List l; ListPtr lptr; struct Node n; /* Store an int in a BE 16bit data type */ c = 15; a = c; // Check if all conversions work b = c; // Try to print the data printf ("Must be 15 15 15: %d %d %d\n", a, b, (int)c); putchar ('\n'); // Same with a pointer ptr = &lptr; // Note that the pointer must be casted but the compiler will print // a warning if the cast is missing: // warning: cannot pass objects of type `APTR' through `...' // These three lines must print the same values. printf ("APTR %p %p\n", &lptr, (void *)ptr); hexdump (&ptr, sizeof (ptr)); ptr.print (); putchar ('\n'); putchar ('\n'); // Same with a pointer char * p1; STRPTR p2; p1 = "hello"; p2 = p1; // Note that the pointer must be casted but the compiler will print // a warning if the cast is missing: // warning: cannot pass objects of type `STRPTR' through `...' // The first line must print two equal pointers and the second line // must print two times "hello". printf ("string %p %p\n", p1, (void *)p2); printf ("%s %s\n", p1, (UBYTE *)p2); putchar ('\n'); // Show the contents of the memory (to prove that the actual data is BE) printf ("Contents of p1 (host endianess) and p2 (big endian):\n"); hexdump (&p1, sizeof (p1)); hexdump (&p2, sizeof (p2)); putchar ('\n'); // Same with a structure lptr = &l; // Print address of list header printf ("&lptr %p\n", &lptr); // Print list pointers (host and BE) which must be equal (otherwise the // BE pointer is not converted correctly). printf ("List %p %p\n", &l, (void *)lptr); // Show that it's really a BE pointer hexdump (&lptr, sizeof (lptr)); // Print the real contents of the variable in host endianess lptr.print (); putchar ('\n'); putchar ('\n'); // Try some functions on the list NEWLIST(lptr); printf ("NewList %p %p %p\n", (void *)(l.lh_Head), (void *)l.lh_Tail, (void *)l.lh_TailPred); printf ("NewList %p %p %p\n", (void *)(lptr->lh_Head), (void *)lptr->lh_Tail, (void *)lptr->lh_TailPred); hexdump (&l, sizeof (struct List)); putchar ('\n'); ADDHEAD(lptr, &n); printf ("&Node %p\n", &n); printf ("AddHead %p %p %p\n", (void *)l.lh_Head, (void *)l.lh_Tail, (void *)l.lh_TailPred); putchar ('\n'); return 0; }