Beispiel #1
0
MiApp1::MiApp1() :
  // Gtk_Window(GTK_WINDOW_TOPLEVEL) : not needed,
  // GTK_WINDOW_TOPLEVEL is the constructor arg's default value
  v_box( false, 0 ),
  m_box1(), // creates a box to pack widgets into
  m_button1("Run"),
  m_button2("Quit"),
  aCanvas(),
  aLine1(aCanvas, Gdk_Color("#00000000cd00")),
  aLine2(aCanvas, Gdk_Color("#ff0045000000"))
{

  // this is a new call, this just sets the title of our new window to
  // "Hello Buttons!"
  set_title("Draw on a Canvas");

  // sets the border width of the window.
  set_border_width(10);

  // Sets window size
  set_usize( 640, 400);

  // Create the vertical vbox
  add(&v_box);

  // put the box into the main window.
  v_box.pack_start(m_box1, false, true, 0);

  // Now when the button is clicked, we call the "callback" function
  // with a pointer to "button 1" as it's argument
  connect_to_method(m_button1.clicked, this, &run );

  // instead of gtk_container_add, we pack this button into the invisible
  // box, which has been packed into the window.
  // note that the pack_start default arguments are true, true, 0
  m_box1.pack_start(m_button1, false, true, 0);
  
  // always remember this step, this tells GTK that our preparation
  // for this button is complete, and it can be displayed now.
  m_button1.show();

  // call the same callback function with a different argument,
  // passing a pointer to "button 2" instead.
  connect_to_method(m_button2.clicked, Gtk_Main::instance(), &Gtk_Main::quit );

  m_box1.pack_start(m_button2, false, true, 0);

  // The order in which we show the buttons is not really important,
  // but I recommend showing the window last, so it all pops up at
  // once.
  m_button2.show();

  v_box.pack_end(aCanvas, true, true, 0);
 
  // now show
  show_all();
  aCanvas.draw();
}
Beispiel #2
0
AboutDialog::AboutDialog () : OK("OK"), canvas() {
  set_title ("About EOGI");
  set_usize (400, 200);
  // don't allow resizing
  set_policy ( false, false, false );

  get_vbox()->add( &canvas );
  get_action_area()->add( &OK );

  connect_to_method ( OK.clicked, this, &AboutDialog::ok_clicked );
	
  OK.show();
  canvas.show();
}
Beispiel #3
0
TDialogInit::TDialogInit(unsigned _max, 
			 unsigned *_generaciones, unsigned *_tamPop, 
			 unsigned *_numGenes, unsigned *_bitXgen,
			 unsigned *_rangeVal,
			 float *_rate, float *_select,
			 unsigned *_OkCancel) :
  OK("OK"), Cancel("Cancel"), 
  frameG("Number of Generations"), cajaG(false, 5),
  frameP("Initial Pop. Size"), cajaP(false, 5),
  frameNG("Num. Genes"), cajaNG(false, 5),
  frameBG("Bits x Gen"), cajaBG(false, 5),
  frameR("Rate to kill"), cajaR(false, 5),
  frameS("\% to reproduce"), cajaS(false, 5),
  devG(_generaciones), devP(_tamPop), devNG(_numGenes), devBG(_bitXgen),
  devR(_rate), devS(_select),
  OkCancel(_OkCancel), max(_max)
{
  set_title ("Initial Parameters");
  set_policy ( false, false, false );

  set_border_width(3);

  cajaG.set_border_width (7);
  cajaP.set_border_width (7);
  cajaNG.set_border_width (7);
  cajaBG.set_border_width (7);
  cajaR.set_border_width (7);
  cajaS.set_border_width (7);
  
  // value, lower, upper, step incr, page incr, page size
  //number of generations.
  AdjG = new Gtk_Adjustment ( (*devG), 0,max, 1,10, 0 );
  ScaleG = new Gtk_HScale(*AdjG);
  ScaleG->set_digits(0); // make scales use integers
  ScalesBoxG = new Gtk_VBox(false, 0);
  ScalesBoxG->pack_end (*ScaleG);
  ScaleG->show();
  ScalesBoxG->show();

  //pop. size
  AdjP = new Gtk_Adjustment ( (*devP), 0,max, 1,10, 0 );
  ScaleP = new Gtk_HScale(*AdjP);
  ScaleP->set_digits(0);
  ScalesBoxP = new Gtk_VBox(false, 0);
  ScalesBoxP->pack_end (*ScaleP);
  ScaleP->show();
  ScalesBoxP->show();

  //number of genes
  AdjNG = new Gtk_Adjustment ( (*devNG), 1,100, 1,10, 0 );
  ScaleNG = new Gtk_HScale(*AdjNG);
  ScaleNG->set_digits(0); // make scales use integers
  ScalesBoxNG = new Gtk_VBox(false, 0);
  ScalesBoxNG->pack_end (*ScaleNG);
  ScaleNG->show();
  ScalesBoxNG->show();

  //bits x gen
  AdjBG = new Gtk_Adjustment ( (*devBG), 1,100, 1,10, 0 );
  ScaleBG = new Gtk_HScale(*AdjBG);
  ScaleBG->set_digits(0); // make scales use integers
  ScalesBoxBG = new Gtk_VBox(false, 0);
  ScalesBoxBG->pack_end (*ScaleBG);
  ScaleBG->show();
  ScalesBoxBG->show();

  //rate for the coach
  AdjR = new Gtk_Adjustment ( (*devR), 0.0,1.0, 0.1,0.2, 0 );
  ScaleR = new Gtk_HScale(*AdjR);
  ScaleR->set_digits(1);
  ScalesBoxR = new Gtk_VBox(false, 0);
  ScalesBoxR->pack_end (*ScaleR);
  ScaleR->show();
  ScalesBoxR->show();

  //select for the chaperon
  AdjS = new Gtk_Adjustment ( (*devS), 0.0,100.0, 1.0,10.0, 0 );
  ScaleS = new Gtk_HScale(*AdjS);
  ScaleS->set_digits(1);
  ScalesBoxS = new Gtk_VBox(false, 0);
  ScalesBoxS->pack_end (*ScaleS);
  ScaleS->show();
  ScalesBoxS->show();

  // More assembly...
  Gtk_HBox * aa = get_action_area();
  aa->add(&OK);
  aa->add(&Cancel);
  OK.show();
  Cancel.show();

  Gtk_VBox * v = get_vbox();
  v->add(&frameG);
  v->add(&frameP);
  v->add(&frameNG);
  v->add(&frameBG);
  v->add(&frameR);
  v->add(&frameS);
  frameG.add(&cajaG);
  frameP.add(&cajaP);
  frameNG.add(&cajaNG);
  frameBG.add(&cajaBG);
  frameR.add(&cajaR);
  frameS.add(&cajaS);
  cajaG.pack_start(*ScalesBoxG);
  cajaP.pack_start(*ScalesBoxP);
  cajaNG.pack_start(*ScalesBoxNG);
  cajaBG.pack_start(*ScalesBoxBG);
  cajaR.pack_start(*ScalesBoxR);
  cajaS.pack_start(*ScalesBoxS);

  cajaG.show();
  cajaP.show();
  cajaNG.show();
  cajaBG.show();
  cajaR.show();
  cajaS.show();

  frameG.show();
  frameP.show();
  frameNG.show();
  frameBG.show();
  frameR.show();
  frameS.show();

  connect_to_method( OK.clicked,this,&TDialogInit::ok_clicked );
  connect_to_method( Cancel.clicked,this,&TDialogInit::cancel_clicked );

}

void TDialogInit::ok_clicked() {
  *devG=(unsigned) AdjG->get_value();
  *devP=(unsigned) AdjP->get_value();
  //  *devNG=(unsigned) AdjNG->get_value();
  //  *devBG=(unsigned) AdjBG->get_value();
  *devR=(float) AdjR->get_value();
  *devS=(float) AdjS->get_value();
  *OkCancel = 1;
  closed();
}
Gtk_Base::Gtk_Base()
{
  connect_to_method(this,&show);   // { dg-error "no match" } invalid pmf expression
  // { dg-message "candidate" "candidate note" { target *-*-* } 23 }
  connect_to_method(this,&expose); // { dg-error "pointer to member" } invalid pmf expression
}