int main(int argc, char* argv[]) { Gtk::Main kit(argc, argv); //this must be first ListArray<CD>* cds = CD::readCDs("cds.txt"); //DO THIS //create the sorted linked list (call it sorted_list) SortedListLinked<CD>* sorted_list = new SortedListLinked<CD>(&CD::compare_items); String title("CDs"); ListBox<CD>* lstCDs = new ListBox<CD>(&title, sorted_list); addCDs(cds, lstCDs); Gtk::Window win; win.set_title("Music!"); win.set_position(Gtk::WIN_POS_CENTER); //the size of the window int width = 640; int height = 520; win.set_size_request(width, height); win.set_resizable(false); //10 rows, 1 column Gtk::Table tbl(10, 1, true); Gtk::Button btnRemove("Remove"); //left attach, right attach, top attach, bottom attach tbl.attach(*lstCDs, 0, 1, 0, 9, Gtk::FILL | Gtk::EXPAND, Gtk::FILL | Gtk::EXPAND, 0, 0); tbl.attach(btnRemove, 0, 1, 9, 10, Gtk::FILL | Gtk::EXPAND, Gtk::FILL | Gtk::EXPAND, 0, 0); win.add(tbl); //a button must register with a method that has a void return type btnRemove.signal_clicked().connect(sigc::mem_fun(lstCDs, &ListBox<CD>::removeSelectedItem)); win.show_all_children(); Gtk::Main::run(win); deleteCDs(cds); delete cds; delete lstCDs; return 0; }
int main(int argc, char** argv) { Matrix* mat = Matrix::readMatrix("maze.txt"); Gtk::Main kit(argc, argv); Gtk::Window win; win.set_title("Maze!"); win.set_position(Gtk::WIN_POS_CENTER); //the size of the window int width = 875; int height = 445; win.set_size_request(width, height); win.set_resizable(false); Gtk::Table tbl(10, 1, true); int rows = tbl.property_n_rows(); int button_height = (int) (((double) height)/rows + 0.5); Maze* maze = new Maze(mat); MazeGUI mg(width, height - button_height, maze); //needs to know its own dimensions Gdk::Color c("#FF0000"); Gtk::Button btnMaze("Solve!"); btnMaze.signal_clicked().connect(sigc::mem_fun(mg, &MazeGUI::on_maze_button_click_event)); tbl.attach(mg, 0, 1, 0, 9, Gtk::FILL | Gtk::EXPAND, Gtk::FILL | Gtk::EXPAND, 0, 0); tbl.attach(btnMaze, 0, 1, 9, 10, Gtk::FILL | Gtk::EXPAND, Gtk::FILL | Gtk::EXPAND, 0, 0); win.add(tbl); win.show_all_children(); Gtk::Main::run(win); return 0; }
// Main int main(int argc, char *argv[]) { // Init GTK Gtk::Main kit(argc, argv); Gtk::Window window; window.set_size_request(450, 350); Gtk::Fixed fixed; window.add(fixed); // Lines //////// Lines lines; lines.set_size_request(500, 425); // FLTK lines.add_line(230, 45, 110, 115); lines.add_line(270, 45, 270, 90); lines.add_line(290, 45, 400, 165); lines.add_line(310, 40, 350, 60); // Point lines.add_line(110, 55, 110, 115); lines.add_line(150, 55, 210, 90); // Graph lines.add_line(110, 160, 90, 240); lines.add_line(110, 160, 170, 340); // Window lines.add_line(250, 135, 230, 190); lines.add_line(270, 135, 270, 265); lines.add_line(320, 135, 400, 165); // GUI lines.add_line(340, 210, 270, 265); lines.add_line(390, 210, 400, 240); // Simple lines.add_line(200, 310, 170, 340); // So difficult... >.< fixed.add(lines); // Nodes //////// TitledText tt1("Point.h", "struct Point { ... };"); fixed.put(tt1, 50, 25); TitledText tt2("Graph.h", "// graphing interface\nstruct Shape { ... };\n..."); fixed.put(tt2, 50, 100); TitledText tt3("Graph.cpp", "Graph code"); fixed.put(tt3, 25, 225); TitledText tt4("Window.h", "// window interface\nclass Window { ... };\n..."); fixed.put(tt4, 200, 75); TitledText tt5("Window.cpp", "Window code"); fixed.put(tt5, 150, 175); TitledText tt6("GUI.h", "// GUI interface\nstruct In_box { ... };\n..."); fixed.put(tt6, 325, 150); TitledText tt7("GUI.cpp", "GUI code"); fixed.put(tt7, 350, 225); TitledText tt8("Simple_window.h", "// window interface\nclass Simple_window { ... };\n..."); fixed.put(tt8, 175, 250); TitledText tt9("chapter12.cpp", "#include \"Graph.h\"\n#include \"Simple_window.h\"\nint main { ... }"); fixed.put(tt9, 75, 325); FramedText ft1("FLTK headers"); ShadowFrame<FramedText> sfa1(ft1); ShadowFrame<ShadowFrame<FramedText> > sfb1(sfa1, 2); fixed.put(sfb1, 225, 25); FramedText ft2("FLTK code"); ShadowFrame<FramedText> sfa2(ft2); ShadowFrame<ShadowFrame<FramedText> > sfb2(sfa2, 2); fixed.put(sfb2, 350, 50); // Done, run the application window.show_all_children(); Gtk::Main::run(window); return EXIT_SUCCESS; }