No Data Structures

gtk3a

The following code works, but not smart at all, because there are no data structures.

#include "radiobuttons.h"
#include <iostream>
void myfunc (int);

RadioButtons::RadioButtons() :
  m_Box_Top(Gtk::ORIENTATION_VERTICAL),
  m_Box1 (Gtk::ORIENTATION_HORIZONTAL, 10),
  m_Box10(Gtk::ORIENTATION_VERTICAL  , 10),
  m_Box11(Gtk::ORIENTATION_VERTICAL  , 10),
  m_Box12(Gtk::ORIENTATION_VERTICAL  , 10),
  m_Box2 (Gtk::ORIENTATION_VERTICAL  , 10),
  m_RadioButton1("CW"),
  m_RadioButton2("CW-R"),
  m_RadioButton3("LSB"),
  m_RadioButton4("USB"),
  m_RadioButton5("DSP FIL1"),
  m_RadioButton6("DSP FIL2"),
  m_RadioButton7("DSP FIL3"),
  m_RadioButton8("DSP SHARP"),
  m_RadioButton9("DSP SOFT"),
  m_Button_Quit ("Quit")
{
  set_title("Spinor Lab");
  set_border_width(10);

  Gtk::RadioButton::Group group1 = m_RadioButton1.get_group();
  m_RadioButton2.set_group(group1);
  m_RadioButton3.set_group(group1);
  m_RadioButton4.set_group(group1);

  Gtk::RadioButton::Group group2 = m_RadioButton5.get_group();
  m_RadioButton6.set_group(group2);
  m_RadioButton7.set_group(group2);

  Gtk::RadioButton::Group group3 = m_RadioButton8.get_group();
  m_RadioButton9.set_group(group3);

  add(m_Box_Top);

  m_Box_Top.pack_start(m_Box1);
  m_Box_Top.pack_start(m_Separator1);
  m_Box_Top.pack_start(m_Box2);

  m_Box1.set_border_width(10);
  m_Box2.set_border_width(10);

  m_Box1.pack_start(m_Box10);
  m_Box1.pack_start(m_Separator2);
  m_Box1.pack_start(m_Box11);
  m_Box1.pack_start(m_Separator3);
  m_Box1.pack_start(m_Box12);
  
  m_Box10.pack_start(m_RadioButton1, FALSE, FALSE, 0);
  m_Box10.pack_start(m_RadioButton2, FALSE, FALSE, 0);
  m_Box10.pack_start(m_RadioButton3, FALSE, FALSE, 0);
  m_Box10.pack_start(m_RadioButton4, FALSE, FALSE, 0);

  m_Box11.pack_start(m_RadioButton5, FALSE, FALSE, 0);
  m_Box11.pack_start(m_RadioButton6, FALSE, FALSE, 0);
  m_Box11.pack_start(m_RadioButton7, FALSE, FALSE, 0);

  m_Box12.pack_start(m_RadioButton8, FALSE, FALSE, 0);
  m_Box12.pack_start(m_RadioButton9, FALSE, FALSE, 0);

  m_RadioButton1.set_active();

  m_Box2.pack_start(m_Button_Quit);

  m_Button_Quit.set_can_default();
  m_Button_Quit.grab_default();

  m_Button_Quit.signal_clicked().connect (sigc::            mem_fun(*this, &RadioButtons::on_button_clicked )    );
  m_RadioButton1.signal_clicked().connect(sigc::bind<gint> (mem_fun(*this, &RadioButtons::on_button_clicked9), 1));
  m_RadioButton2.signal_clicked().connect(sigc::bind<gint> (mem_fun(*this, &RadioButtons::on_button_clicked9), 2));
  m_RadioButton3.signal_clicked().connect(sigc::bind<gint> (mem_fun(*this, &RadioButtons::on_button_clicked9), 3));
  m_RadioButton4.signal_clicked().connect(sigc::bind<gint> (mem_fun(*this, &RadioButtons::on_button_clicked9), 4));
  m_RadioButton5.signal_clicked().connect(sigc::bind<gint> (mem_fun(*this, &RadioButtons::on_button_clicked9), 5));
  m_RadioButton6.signal_clicked().connect(sigc::bind<gint> (mem_fun(*this, &RadioButtons::on_button_clicked9), 6));
  m_RadioButton7.signal_clicked().connect(sigc::bind<gint> (mem_fun(*this, &RadioButtons::on_button_clicked9), 7));
  m_RadioButton8.signal_clicked().connect(sigc::bind<gint> (mem_fun(*this, &RadioButtons::on_button_clicked9), 8));
  m_RadioButton9.signal_clicked().connect(sigc::bind<gint> (mem_fun(*this, &RadioButtons::on_button_clicked9), 9));

  show_all_children();
}
void RadioButtons::on_button_clicked9(gint data)
{
  if(data == 1) {
    if(m_RadioButton1.get_active()) {
      std::cout << "button1 is active " << std::endl;
	  myfunc(1);
	}
  }
  /* this kind of stuff deleted */
}
#ifndef GTKMM_EXAMPLE_RADIOBUTTONS_H
#define GTKMM_EXAMPLE_RADIOBUTTONS_H

#include <gtkmm/box.h>
#include <gtkmm/window.h>
#include <gtkmm/radiobutton.h>
#include <gtkmm/separator.h>

class RadioButtons : public Gtk::Window
{
public:
  RadioButtons();
  virtual ~RadioButtons();
protected:
  void on_button_clicked ();
  void on_button_clicked9(gint data);
  Gtk::Box         m_Box_Top, m_Box1, m_Box10, m_Box11, m_Box12, m_Box2;
  Gtk::RadioButton m_RadioButton1, m_RadioButton2, m_RadioButton3, m_RadioButton4;
  Gtk::RadioButton m_RadioButton5, m_RadioButton6, m_RadioButton7;
  Gtk::RadioButton m_RadioButton8, m_RadioButton9;
  Gtk::HSeparator  m_Separator1;
  Gtk::VSeparator  m_Separator2, m_Separator3;
  Gtk::Button      m_Button_Quit;
};

#endif //GTKMM_EXAMPLE_RADIOBUTTONS_H

Leave a Reply

Your email address will not be published. Required fields are marked *