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;
}
Example #2
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;
}