[Libufo-commits] ufo-0.5/test morewidgets.cpp,NONE,1.1
Status: Beta
Brought to you by:
schmidtjf
|
From: Johannes S. <sch...@us...> - 2005-10-29 11:55:01
|
Update of /cvsroot/libufo/ufo-0.5/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31834 Added Files: morewidgets.cpp Log Message: Merged several example files in morewidgets.cpp --- NEW FILE: morewidgets.cpp --- /*************************************************************************** LibUFO - UI For OpenGL copyright : (C) 2001-2005 by Johannes Schmidt email : schmidtjf at users.sourceforge.net ------------------- file : test/theme.cpp begin : Thu Mar 27 2003 $Id: morewidgets.cpp,v 1.1 2005/10/29 11:54:53 schmidtjf Exp $ ***************************************************************************/ #include <ufo/ufo.hpp> #include <ufo/ux/ux.hpp> // This example shows the use of list boxes, spin boxes, // tab boxes, sliders and progress bars using namespace ufo; void createContent(UWidget * content); int main(int argc, char ** argv) { // creates the toolkit object, initializes UFO UXToolkit tk; // loads the video driver and creates the event queue UXDisplay display; // creates a frame UXFrame * frame = display.createFrame(); frame->setTitle("more widgets"); frame->setBounds(0, 0, 640, 480); frame->setResizable(true); frame->setVisible(true); // Now you have a valid OpenGL context // user created widgets are placed in the content pane // create some widgets and add them to the content pane createContent(frame->getContentPane()); // main event loop bool done = false; while (!done) { // pumps events from the system event queue display.pumpEvents(); // dispatchEvents returns true when a quit event was processed. done = display.dispatchEvents(); if (!done) { // repaint the frame frame->repaint(); // give other processes a chance tk.sleep(1); } } return 0; } void selectionChanged(UListBox * box, int first, int last) { std::cout << "Selected item " << box->getSelectedIndex() << ": " << box->getSelectedItem() << "\n"; } // // selection adjusting widgets // void addListBox(UWidget * parent) { // add a list box UListBox * box = new UListBox(); box->addItem("this is a list box"); box->addItem("item1"); box->addItem("item2"); box->addItem("item3"); box->addItem("item4"); box->addItem("item5"); box->addItem("item6"); // make the list scrollable parent->add(new UScrollPane(box)); box->sigSelectionChanged().connect(slot(&selectionChanged)); } void addTabWidget(UWidget * parent) { UTabWidget * box = new UTabWidget(); box->addTab(new ULabel("tab 1"), "&label"); box->addTab(new UButton("tab 2"), "&button"); box->addTab(new UTextEdit("this is a \nlonger text"), "&text"); parent->add(box); } // // value adjusting widgets // void addSlider(UWidget * parent) { USlider * slider = new USlider(); slider->setRange(0, 100); slider->setValue(20); parent->add(slider); } void addSpinBox(UWidget * parent) { USpinBox * box = new USpinBox(); box->setRange(10, 100); box->setValue(20); parent->add(box); } void addProgressBar(UWidget * parent) { UProgressBar * bar = new UProgressBar(); bar->setRange(0, 100); bar->setValue(20); parent->add(bar); } // creates our widgets void createContent(UWidget * content) { content->setOrientation(Vertical); UWidget * listboxPane = new UWidget(); listboxPane->setOrientation(Horizontal); content->add(listboxPane); // add a label (static text) listboxPane->add(new ULabel("label")); addListBox(listboxPane); addTabWidget(content); addSlider(content); addSpinBox(content); addProgressBar(content); } |