Drawing Area Widget

gtk3e

The further I do, I get more and more confused..

int main(int argc, char *argv[])
{
  serial_init ();

  Glib::RefPtr<Gtk::Application> app = Gtk::Application::create(argc, argv, "org.gtkmm.example");

  Gtk::Window  win;
  Gtk::Box     bigbox;
  RadioButtons buttons;
  MyArea       area;

  win.set_title("Spinor Lab");
  win.set_default_size(1000,400);
  win.set_border_width(10);

  bigbox.set_orientation(Gtk::ORIENTATION_VERTICAL);
  bigbox.pack_start(buttons, FALSE, FALSE, 0);
  bigbox.pack_start(area   , FALSE, FALSE, 0);

  buttons.show();
  area.show();
  bigbox.show();

  win.add(bigbox);
  return app->run(win);
}
#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
class RadioButtons : public Gtk::Box
{
public:
  RadioButtons();
  virtual ~RadioButtons();
protected:
  void on_button_clicked ();
  void on_button_clicked9(gint data);
  Gtk::Box         m_Box_Top, m_Box1, m_Box2;
  Gtk::Box         m_Box10       [  8];
  Gtk::RadioButton::Group m_group[  8];
  Gtk::RadioButton m_RadioButton [100];
  Gtk::HSeparator  m_HSeparator;
  Gtk::VSeparator  m_VSeparator  [  7];
  Gtk::Button      m_Button_Quit;
};

#endif //GTKMM_EXAMPLE_RADIOBUTTONS_H

No Data Structures (3)

gtk3c

Maybe this only reveals that I am not object-oriented at all. These codes are quite ugly, I must say.

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

RadioButtons::RadioButtons() :
  m_Box_Top(Gtk::ORIENTATION_VERTICAL),
  m_Box1   (Gtk::ORIENTATION_HORIZONTAL, 10),
  m_Box2   (Gtk::ORIENTATION_VERTICAL  , 10),
  m_Button_Quit ("Quit")
{
  set_title("Spinor Lab");
  set_border_width(10);

  char label[100][256] = { "CW", "CW-R", "LSB", "USB", "DSP FIL1", "DSP FIL2", "DSP FIL3", "DSP SHARP", "DSP SOFT",
    "IF FIL1", "IF FIL2", "IF FIL3", "PRE-AMP1", "PRE-AMP2", "ATT 20dB", "BOTH OFF", "AGC FAST", "AGC MID", "AGC SLOW",
    "ANT 1", "ANT 2", "BKIN OFF", "BKIN ON", "BKIN FULL"};
  int ngroup = 8;
  int nbuttons[8] = { 4, 3, 2, 3, 4, 3, 2, 3 };

  for(int i=0;i<ngroup;i++) {
    m_Box10[i].set_orientation(Gtk::ORIENTATION_VERTICAL);
    m_Box10[i].set_border_width(3);
  }

  int index = 0;
  for(int i=0;i<ngroup;i++) {
    for(int j=0;j<nbuttons[i];j++) {
      m_RadioButton[index].set_label(label[index]);
      if(j==0) {
        m_RadioButton[index].set_active();
        m_group[i] = m_RadioButton[index].get_group();
      } else {
        m_RadioButton[index].set_group(m_group[i]);
      }
      m_Box10[i].pack_start(m_RadioButton[index], FALSE, FALSE, 0);
      m_RadioButton[index].signal_clicked().connect(sigc::bind<gint> (mem_fun(*this, &RadioButtons::on_button_clicked9), index));
      index++;
    }
    m_Box1.pack_start(m_Box10[i]);
    if(i != ngroup-1) {
      m_Box1.pack_start(m_VSeparator[i]);
    }
  }

  add(m_Box_Top);

  m_Box1.set_border_width(10);
  m_Box2.set_border_width(10);
  m_Box_Top.pack_start(m_Box1);
  m_Box_Top.pack_start(m_HSeparator);
  m_Box_Top.pack_start(m_Box2);
  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 )    );

  show_all_children();
}
#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_Box2;
  Gtk::Box         m_Box10       [  8];
  Gtk::RadioButton::Group m_group[  8];
  Gtk::RadioButton m_RadioButton [100];
  Gtk::HSeparator  m_HSeparator;
  Gtk::VSeparator  m_VSeparator  [  7];
  Gtk::Button      m_Button_Quit;
};

#endif //GTKMM_EXAMPLE_RADIOBUTTONS_H