int APIENTRY wWinMain(HINSTANCE hInstance, HINSTANCE /*hPrevInstance*/, LPTSTR /*lpCmdLine*/, int nCmdShow) { WNDCLASSEX wcex; wcex.cbSize = sizeof(WNDCLASSEX); wcex.style = CS_HREDRAW | CS_VREDRAW; wcex.lpfnWndProc = (WNDPROC)WndProc; wcex.cbClsExtra = 0; wcex.cbWndExtra = 0; wcex.hInstance = hInstance; wcex.hIcon = NULL; wcex.hCursor = LoadCursor(NULL, IDC_ARROW); wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1); wcex.lpszMenuName = NULL; wcex.lpszClassName = L"qtest"; wcex.hIconSm = NULL; ATOM windowClass = RegisterClassEx(&wcex); HWND hWnd = CreateWindow((TCHAR*)windowClass, L"Windows Migration Framework Example", WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, 0, 0, hInstance, 0); if (!hWnd) return FALSE; int argc = 0; QApplication a(argc, 0); QWinWidget win(hWnd); winId = win.winId(); QHBoxLayout hbox(&win); hbox.setSpacing(5); hbox.setMargin(0); QPushButton *pb = new QPushButton("Qt command button", &win); pb->setObjectName("pb"); hbox.addWidget(pb); QLabel *label = new QLabel("Some label", &win); label->setObjectName("label"); hbox.addWidget(label); QLineEdit *le1 = new QLineEdit(&win); le1->setObjectName("le1"); hbox.addWidget(le1); QLineEdit *le2 = new QLineEdit(&win); le1->setObjectName("le2"); hbox.addWidget(le2); QLineEdit *le3 = new QLineEdit(&win); le1->setObjectName("le3"); hbox.addWidget(le3); win.move(0, 0); win.show(); ShowWindow(hWnd, nCmdShow); UpdateWindow(hWnd); return a.exec(); }
int main(int argc, char **argv) { Iup::Open(argc, argv); Iup::Frame frame(Iup::List().SetAttributes("DROPDOWN=YES, 1=Test, 2=XXX, VALUE=1")); frame.SetAttribute("TITLE", "List"); Iup::Text text; text.SetAttributes("EXPAND = YES, VALUE = \"Enter your text here\""); /* Creates a label */ Iup::Label lbl("This element is a label"); /* Creatas a button */ Iup::Button btn("This button does nothing"); /* Creates handles for manipulating the zbox VALUE */ Iup::SetHandle("frame", frame); Iup::SetHandle("text", text); Iup::SetHandle("lbl", lbl); Iup::SetHandle("btn", btn); /* Creates zbox with four elements */ Iup::Zbox zbox(frame, text, lbl, btn); /* Sets zbox alignment */ zbox.SetAttribute("ALIGNMENT", "ACENTER"); zbox.SetAttribute("VALUE", "text"); zbox.SetAttribute("NAME", "ZBOX"); Iup::List list; Iup::Hbox hbox(list); /* Creates frame */ Iup::Frame frm(hbox); /* Creates dialog */ Iup::Dialog dlg ( Iup::Vbox ( frm, zbox ) ); list.SetAttributes("1 = frame, 2 = text, 3 = lbl, 4 = btn, VALUE=2"); frm.SetAttribute("TITLE", "Select an element"); dlg.SetAttributes("MARGIN=10x10, GAP=10, TITLE = \"IupZbox Example\""); list.SetCallback("ACTION", (Icallback)list_cb); dlg.ShowXY(IUP_CENTER, IUP_CENTER); Iup::MainLoop(); Iup::Close(); return 0; }
PolyGlyph* LayoutKit::hbox( Glyph* g1, Glyph* g2, Glyph* g3, Glyph* g4, Glyph* g5, Glyph* g6, Glyph* g7, Glyph* g8, Glyph* g9, Glyph* g10 ) const { return LayoutKitImpl::add( hbox(10), g1, g2, g3, g4, g5, g6, g7, g8, g9, g10 ); }
void build_democontent(int parent) { // some persistent variables for demonstration static float progress1 = 0.25f; static float progress2 = 0.75f; static int option1 = 1; static int option2 = 0; static int option3 = 0; int col = column(); uiInsert(parent, col); uiSetMargins(col, 10, 10, 10, 10); uiSetLayout(col, UI_TOP|UI_HFILL); column_append(col, button(BND_ICON_GHOST, "Item 1", demohandler)); if (option3) column_append(col, button(BND_ICON_GHOST, "Item 2", demohandler)); { int h = column_append(col, hbox()); hgroup_append(h, radio(BND_ICON_GHOST, "Item 3.0", &enum1)); if (option2) uiSetMargins(hgroup_append_fixed(h, radio(BND_ICON_REC, NULL, &enum1)), -1,0,0,0); uiSetMargins(hgroup_append_fixed(h, radio(BND_ICON_PLAY, NULL, &enum1)), -1,0,0,0); uiSetMargins(hgroup_append(h, radio(BND_ICON_GHOST, "Item 3.3", &enum1)), -1,0,0,0); } { int rows = column_append(col, row()); int coll = row_append(rows, vgroup()); vgroup_append(coll, label(-1, "Items 4.0:")); coll = vgroup_append(coll, vbox()); vgroup_append(coll, button(BND_ICON_GHOST, "Item 4.0.0", demohandler)); uiSetMargins(vgroup_append(coll, button(BND_ICON_GHOST, "Item 4.0.1", demohandler)),0,-2,0,0); int colr = row_append(rows, vgroup()); uiSetMargins(colr, 8, 0, 0, 0); uiSetFrozen(colr, option1); vgroup_append(colr, label(-1, "Items 4.1:")); colr = vgroup_append(colr, vbox()); vgroup_append(colr, slider("Item 4.1.0", &progress1)); uiSetMargins(vgroup_append(colr, slider("Item 4.1.1", &progress2)),0,-2,0,0); } column_append(col, button(BND_ICON_GHOST, "Item 5", NULL)); static char textbuffer[1024] = "The quick brown fox."; column_append(col, textbox(textbuffer, 1024)); column_append(col, check("Frozen", &option1)); column_append(col, check("Item 7", &option2)); column_append(col, check("Item 8", &option3)); }
//_______________________________________________________ void DemoWidget::realize( void ) { assert( !_mainWidget ); assert( _widget ); // create main widget (vbox) _mainWidget = gtk_box_new( GTK_ORIENTATION_VERTICAL, 0 ); gtk_box_set_spacing( GTK_BOX( _mainWidget ), 10 ); gtk_widget_show( _mainWidget ); // horizontal box GtkWidget* hbox( gtk_box_new( GTK_ORIENTATION_HORIZONTAL, 0 ) ); gtk_box_pack_start( GTK_BOX( _mainWidget ), hbox, false, true, 0 ); gtk_widget_show( hbox ); // label std::string comments( _comments.empty() ? _name:_comments ); GtkWidget* label( gtk_label_new( comments.c_str() ) ); PangoAttrList* attributes( pango_attr_list_new() ); pango_attr_list_insert( attributes, pango_attr_weight_new( PANGO_WEIGHT_BOLD ) ); gtk_label_set_attributes( GTK_LABEL( label ), attributes ); pango_attr_list_unref( attributes ); gtk_box_pack_start( GTK_BOX( hbox ), label, false, true, 0 ); gtk_widget_show( label ); // icon if( !_iconName.empty() ) { GtkIconTheme* theme( gtk_icon_theme_get_default() ); GdkPixbuf* icon( gtk_icon_theme_load_icon( theme, _iconName.c_str(), 22, (GtkIconLookupFlags) 0, 0L ) ); GtkWidget* image( gtk_image_new_from_pixbuf( icon ) ); gtk_box_pack_end( GTK_BOX( hbox ), image, false, false, 0 ); gtk_widget_show( image ); } // main content gtk_box_pack_start( GTK_BOX( _mainWidget ), _widget, true, true, 0 ); gtk_widget_show( _widget ); }
void mainwnd::file_import_dialog( void ) { FileSelection dialog( "Import..." ); HBox *abox = dialog.get_action_area(); HBox hbox( false, 2 ); m_adjust_load_offset = manage( new Adjustment( 0, -(c_max_sets - 1) , c_max_sets - 1, 1 )); m_spinbutton_load_offset = manage( new SpinButton( *m_adjust_load_offset )); m_spinbutton_load_offset->set_editable( false ); m_spinbutton_load_offset->set_wrap( true ); hbox.pack_end(*m_spinbutton_load_offset, false, false ); hbox.pack_end(*(manage( new Label( "Screen Set Offset" ))), false, false, 4); abox->pack_end(hbox, false, false ); dialog.show_all_children(); int result = dialog.run(); //Handle the response: switch(result) { case(Gtk::RESPONSE_OK): { try{ midifile f( dialog.get_filename() ); f.parse( m_mainperf, (int) m_adjust_load_offset->get_value() ); } catch(...){ Gtk::MessageDialog errdialog(*this, "Error reading file.", false, Gtk::MESSAGE_ERROR, (Gtk::ButtonsType)(Gtk::BUTTONS_OK), true); errdialog.run(); } global_filename = std::string(dialog.get_filename()); set_window_title_filename( global_filename ); m_main_wid->reset(); m_entry_notes->set_text( * m_mainperf->get_screen_set_notepad( m_mainperf->get_screenset() )); m_adjust_bpm->set_value( m_mainperf->get_bpm() ); break; } case(Gtk::RESPONSE_CANCEL): { break; } default: { break; } } }
int main(int argc, char* argv[]) { sf::RenderWindow window(sf::VideoMode(WIDTH, HEIGHT), "SpaceGameThing"); sf::Clock clock; sf::Clock physClock; float dt; HeavenlyBody* planet = new HeavenlyBody(0.25, 25000, QUIET); planet->Load("../bin/planet.png"); planet->SetPosition(WIDTH/2, 95); planet->SetCollidable(true); //planet->SetOrigin(95,95); planet->SetColor(sf::Color(255, 0, 0, 255)); HitBoxBase<std::pair<sf::Vector2f, float> > hbox(std::pair<sf::Vector2f, float>(sf::Vector2f(95, 95), planet->GetRadius())); planet->SetHitBox((void*)(&hbox), collision::RADIAL); HeavenlyBody* planet2 = new HeavenlyBody(2.0, 200000, QUIET); planet2->Load("../bin/planet.png"); planet2->SetPosition(WIDTH/2, HEIGHT+90); planet2->SetCollidable(true); //planet2->SetOrigin(95,95); planet2->SetColor(sf::Color(255, 0, 0, 255)); HitBoxBase<std::pair<sf::Vector2f, float> > hbox2(std::pair<sf::Vector2f, float>(sf::Vector2f(95, 95), planet2->GetRadius())); planet2->SetHitBox((void*)(&hbox2), collision::RADIAL); HeavenlyBody* planet3 = new HeavenlyBody(0.5, 20000, QUIET); planet3->Load("../bin/planet.png"); planet3->SetPosition(WIDTH/4, 90); planet3->SetCollidable(true); //planet3->SetOrigin(95,95); planet3->SetColor(sf::Color(255, 0, 0, 255)); HitBoxBase<std::pair<sf::Vector2f, float> > hbox3(std::pair<sf::Vector2f, float>(sf::Vector2f(95, 95), planet3->GetRadius())); planet3->SetHitBox((void*)(&hbox3), collision::RADIAL); //test a compound asset CompoundAsset* cst = new CompoundAsset(); cst->Load("../bin/scripts/assets/test.ass"); cst->SetOrigin(256, 256); cst->SetPosition(WIDTH/2, HEIGHT/2); cst->setMass(100000.0); cst->SetScale(0.25, 0.25); AssetManager manager; PhysicsManager physManager; manager.Add("planet", planet); manager.Add("planet2", planet2); manager.Add("planet3", planet3); manager.Add("cst", cst); //manager.Add("redPlanet", surface); physManager.Add(cst); physManager.Add(planet); physManager.Add(planet2); physManager.Add(planet3); physManager.InitPhysVec(); QuadTree QT(-3/2*WIDTH, 0, 3*WIDTH, HEIGHT); //QT.AddGeometry(*surface); WorldGeometry* Geoms[30]; std::string name = "surface"; std::string index; std::string fin; std::stringstream num (std::stringstream::in | std::stringstream::out); for (int i = 0; i < 30; ++i) { Geoms[i] = new WorldGeometry(); Geoms[i]->Load("../bin/planet.png"); Geoms[i]->SetPosition(192*(i-15), HEIGHT - 190); Geoms[i]->SetCollidable(true); Geoms[i]->SetOrigin(95,95); QT.AddGeometry(*Geoms[i]); num << i; index = num.str(); num.str(""); fin = name + index; manager.Add(fin, Geoms[i]); } /* WorldGeometry* surface = new WorldGeometry(); surface->Load("../bin/planet.png"); surface->SetPosition(0, HEIGHT-190); surface->SetCollidable(true); surface->SetOrigin(95,95); */ planet->setVx(-180); planet->setVy(-40.0); planet2->setVx(50); int nFrames = 0; sf::Clock fClock; sf::Font font; //make a frame counter in a class later font.loadFromFile("../bin/DroidSans.tff"); sf::Text Fps("0", font, 14); std::stringstream ss (std::stringstream::in | std::stringstream::out); std::set<WorldGeometry*> geoms; std::set<WorldGeometry*>::iterator geom; std::vector<HeavenlyBody*> bodies; bodies.push_back(planet); bodies.push_back(planet2); bodies.push_back(planet3); while (window.isOpen()) { sf::Event event; while (window.pollEvent(event)) { //player1->Interact(event); //shouldn't do this here if (event.type == sf::Event::Closed) window.close(); } physManager.UpdatePhysics(physClock.restart().asSeconds()); //quadTree experimentation for (int b = 0; b < 3; ++b) { HeavenlyBody* plnt = bodies[b]; for (int d = 0; d < 3; ++d) { if (d != b) { HeavenlyBody* other = bodies[d]; //if (HaveCollided(plnt, other)) { if (plnt->HasCollided(other)) { printf("Collision Detected\n"); //first, set up the change in radial velocity sf::Vector2f r = other->GetPosition() - plnt->GetPosition(); float R = hypotf(r.x,r.y); sf::Vector2f sxy = other->GetPosition(); sf::Vector2f pxy = plnt->GetPosition(); sf::Vector2f v = (plnt->GetVelocity()*plnt->getMass() - other->GetVelocity()*other->getMass()); // dealta v (this is a diffrence of v) sf::Vector2f v2 = other->GetVelocity()*other->getMass(); // dealta v (this is a diffrence of v) sf::Vector2f v1 = plnt->GetVelocity()*plnt->getMass(); // dealta v (this is a diffrence of v) float damping = 0.85; //damping factor sf::Vector2f frict = v; v1 -= r*(2.0f*(v.x*r.x+v.y*r.y)/(R*R)*damping); v2 += r*(2.0f*(v.x*r.x+v.y*r.y)/(R*R)*damping); //next, set up the change in tangential velocity v1 -= r*((frict.x*r.y-frict.y*r.x)/(R*R)*(1-damping)); //not real friction, v2 += r*((frict.x*r.y-frict.y*r.x)/(R*R)*(1-damping)); //not real friction, //but something at least, this can be fixed later //lastly, set up the change in angular momentum float omega, omega2; //sf::Vector2f delV = r*((frict.x*r.y-frict.y*r.x)/(R*R)*(1-damping)); //not real friction, sf::Vector2f delV = frict*(1-damping); //not real friction, omega = (1-damping)*(delV.x*r.x+delV.y*r.y/(R*R));//*plnt->getMass()/plnt->getI(); omega2 = -(1-damping)*(delV.x*r.x+delV.y*r.y/(R*R));//*plnt->getMass()/plnt->getI(); //then set the physics //plnt->setVx(v1.x/plnt->getMass()); //plnt->setVy(v1.y/plnt->getMass()); //plnt->setOmega(omega); plnt->setX(sxy.x-(95*other->GetRadius()+95*plnt->GetRadius())*(r.x)/R); plnt->setY(sxy.y-(95*other->GetRadius()+95*plnt->GetRadius())*(r.y)/R); //other->setVx(v2.x/other->getMass()); //other->setVy(v2.y/other->getMass()); //other->setOmega(omega2); //other->setX(pxy.x+(95*plnt->GetRadius()+95*other->GetRadius())*(r.x)/R); //other->setY(pxy.y+(95*plnt->GetRadius()+95*other->GetRadius())*(r.y)/R); } } } geoms = QT.GetContents(plnt->GetGlobalBounds()); if (geoms.size() != 0) { for (geom = geoms.begin(); geom != geoms.end(); ++geom) { WorldGeometry* surface = *geom; //get out collider sf::Vector2f r = surface->GetPosition() - plnt->GetPosition(); //dealta r float R = hypotf(r.x,r.y); if (R < 95+plnt->GetRadius()*95.0) { //first, set up the change in radial velocity sf::Vector2f sxy = surface->GetPosition(); sf::Vector2f v = plnt->GetVelocity(); // dealta v (this is a diffrence of v) float damping = 0.85; //damping factor sf::Vector2f frict = v; v -= r*(2.0f*(v.x*r.x+v.y*r.y)/(R*R)*damping); //next, set up the change in tangential velocity v -= r*((frict.x*r.y-frict.y*r.x)/(R*R)*(1-damping)); //not real friction, //but something at least, this can be fixed later //lastly, set up the change in angular momentum float omega; //sf::Vector2f delV = r*((frict.x*r.y-frict.y*r.x)/(R*R)*(1-damping)); //not real friction, sf::Vector2f delV = frict*(1-damping); //not real friction, omega = (1-damping)*(delV.x*r.x+delV.y*r.y/(R*R));//*plnt->getMass()/plnt->getI(); //then set the physics plnt->setVx(v.x); plnt->setVy(v.y); plnt->setOmega(omega); plnt->setX(sxy.x-(95+95*plnt->GetRadius())*(r.x)/R); plnt->setY(sxy.y-(95+95*plnt->GetRadius())*(r.y)/R); } } } } // if (clock.getElapsedTime().asSeconds() > 1.0/FPS) { clock.restart(); window.clear(); nFrames += 1; manager.DrawAll(window); window.draw(Fps); window.display(); } ++nFrames; if (fClock.getElapsedTime().asSeconds() > 2.0){ double fps = nFrames/fClock.restart().asSeconds(); nFrames = 0; ss << fps; Fps.setString(ss.str()); ss.str(""); } } return 0; }
int main() { // Create the main SFML window sf::RenderWindow app_window( sf::VideoMode( 800, 600 ), "SFGUI Combo Box Example", sf::Style::Titlebar | sf::Style::Close ); // Construct our SFML guard // See http://sfgui.sfml-dev.de/forum/topic52-crash-on-close.html for more info. sfg::SFGUI sfgui; // Create our main SFGUI window sfg::Window::Ptr window; window = sfg::Window::Create(); window->SetTitle( "Title" ); // Create the combo box itself. combo_box = sfg::ComboBox::Create(); // Set the entries of the combo box. combo_box->AppendItem( "Bar" ); combo_box->PrependItem( "Foo" ); sel_label = sfg::Label::Create( L"Please select an item!" ); sfg::Button::Ptr button( sfg::Button::Create( L"Add item" ) ); sfg::Box::Ptr hbox( sfg::Box::Create( sfg::Box::HORIZONTAL, 5 ) ); hbox->Pack( combo_box ); hbox->Pack( button, false ); sfg::Box::Ptr vbox( sfg::Box::Create( sfg::Box::VERTICAL, 5 ) ); vbox->Pack( hbox, false ); vbox->Pack( sel_label, true ); // Add the combo box to the window window->Add( vbox ); // So that our combo box has a meaningful purpose (besides just looking // awesome :P) we need to tell it to connect to a callback of our choosing to // notify us when it is clicked. combo_box->OnSelect.Connect( &OnComboSelect ); button->OnClick.Connect( &OnAddItemClick ); // If attempting to connect to a class method you need to provide // a pointer to it as the second parameter after the function address. // Start the game loop while ( app_window.isOpen() ) { // Process events sf::Event event; while ( app_window.pollEvent( event ) ) { // Handle events window->HandleEvent( event ); // Close window : exit if ( event.type == sf::Event::Closed ) { app_window.close(); } } // Update the GUI, note that you shouldn't normally // pass 0 seconds to the update method. window->Update( 0.f ); // Clear screen app_window.clear(); // Draw the GUI sfg::Renderer::Get().Display( app_window ); // Update the window app_window.display(); } // If you have any global or static widgets, // you need to reset their pointers before your // application exits. combo_box.reset(); sel_label.reset(); return EXIT_SUCCESS; }
void mainwnd::file_import_dialog( void ) { Gtk::FileChooserDialog dialog("Import MIDI file", Gtk::FILE_CHOOSER_ACTION_OPEN); dialog.set_transient_for(*this); Gtk::FileFilter filter_midi; filter_midi.set_name("MIDI files"); filter_midi.add_pattern("*.midi"); filter_midi.add_pattern("*.mid"); dialog.add_filter(filter_midi); Gtk::FileFilter filter_any; filter_any.set_name("Any files"); filter_any.add_pattern("*"); dialog.add_filter(filter_any); dialog.set_current_folder(last_used_dir); ButtonBox *btnbox = dialog.get_action_area(); HBox hbox( false, 2 ); m_adjust_load_offset = manage( new Adjustment( 0, -(c_max_sets - 1), c_max_sets - 1, 1 )); m_spinbutton_load_offset = manage( new SpinButton( *m_adjust_load_offset )); m_spinbutton_load_offset->set_editable( false ); m_spinbutton_load_offset->set_wrap( true ); hbox.pack_end(*m_spinbutton_load_offset, false, false ); hbox.pack_end(*(manage( new Label("Screen Set Offset"))), false, false, 4); btnbox->pack_start(hbox, false, false ); dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); dialog.add_button(Gtk::Stock::OPEN, Gtk::RESPONSE_OK); dialog.show_all_children(); int result = dialog.run(); //Handle the response: switch(result) { case(Gtk::RESPONSE_OK): { try{ midifile f( dialog.get_filename() ); f.parse( m_mainperf, (int) m_adjust_load_offset->get_value() ); } catch(...){ Gtk::MessageDialog errdialog(*this, "Error reading file.", false, Gtk::MESSAGE_ERROR, Gtk::BUTTONS_OK, true); errdialog.run(); } global_filename = std::string(dialog.get_filename()); update_window_title(); m_modified = true; m_main_wid->reset(); m_entry_notes->set_text(*m_mainperf->get_screen_set_notepad( m_mainperf->get_screenset() )); m_adjust_bpm->set_value( m_mainperf->get_bpm() ); break; } case(Gtk::RESPONSE_CANCEL): break; default: break; } }