Yes. This code compiles successfully. I have just completed an experiment based on the tutorial from Programming with GTKmm by Murray Cumming.
Here is the code:
main.cpp
#include<gtkmm.h>
#include "MyWindow.h"
int main(int argc,char** argv)
{
Gtk::Main kit(argc,argv);
MyWindow window;
Gtk::Main::run(window);
return 0;
}
MyWindow.h
#ifndef GTKMM_TUT_CHKBUTTON_H
#define GTKMM_TUT_CHKBUTTON_H
#include<gtkmm.h>
#include<gtkmm/window.h>
class MyWindow: public Gtk::Window
{
public:
MyWindow();
~MyWindow();
protected:
//Signal Handlers
//virtual void OnChkDisplayFlag_Toggled();
virtual void OnBtnClose_Clicked();
//virtual void OnAdjDigit();
//virtual void OnAdjPageSize();
Gtk::VBox m_vbxMain, m_vbxScale_Scroll;
Gtk::HBox m_hbxVert_Horiz, m_hbxValuePos,
m_hbxUpdatePolicy, m_hbxDigit, m_hbxPageSize;
Gtk::CheckButton m_chkDisplayFlag;
Gtk::Label m_lblValuePos, m_lblUpdatePolicy,
m_lblDigit, m_lblPageSize;
//ComboBox
Gtk::ComboBox m_cbxValuePos, m_cbxUpdatePolicy;
class ModelColumns : public Gtk::TreeModelColumnRecord
{
public:
ModelColumns()
{
add(m_iID); add(m_sChoice);
}
Gtk::TreeModelColumn<int> m_iID;
Gtk::TreeModelColumn<Glib::ustring> m_sChoice;
};
ModelColumns m_MC_UpdatePolicy, m_MC_ValuePos;
Glib::RefPtr<Gtk::ListStore> mpLS_ValuePos,
mpLS_UpdatePolicy;
Gtk::Adjustment m_adjVert, m_adjDigit, m_adjPageSize;
Gtk::VScale m_vscVert ;
Gtk::HScale m_hscHoriz,m_hscDigit,m_hscPageSize;
Gtk::HScrollbar m_hsScroll;
Gtk::HSeparator m_hspSep;
Gtk::Button m_btnClose;
};
#endif //GTKMM_TUT_CHKBUTTON_H
MyWindow.cpp
#include"MyWindow.h"
#include<stdio.h>
MyWindow::MyWindow()
:
m_vbxMain(false,30),
m_vbxScale_Scroll(false,10),
//m_vbxCloseButton(false,10),
m_hbxVert_Horiz(false,10),
m_hbxValuePos(false,10),
m_hbxUpdatePolicy(false,10),
m_hbxDigit(false,10),
m_hbxPageSize(false,10),
m_chkDisplayFlag("Display values in the Widgets",0),
m_lblValuePos("Value Position"),
m_lblUpdatePolicy("Update Policy"),
m_lblDigit("Scale Digits"),
m_lblPageSize("Page Size"),
//Gtk::Adjustment::Adjustment (value,lower,upper,
step_increment,page_increment,page_size)
m_adjVert(0.0 , 0.0, 101.0, 0.1, 1.0, 1.0),
m_adjDigit(1.0, 0.0, 5.0),
m_adjPageSize(1.0, 0.0, 101.1),
m_hscHoriz(m_adjVert),
m_vscVert(m_adjVert),
m_hscDigit(m_adjDigit),
m_hscPageSize(m_adjPageSize),
m_hsScroll(m_adjVert),
m_btnClose("Close")
{
set_title("Ranging Widgets");
//Vertical Scaler widget
m_vscVert.set_update_policy(Gtk::UPDATE_CONTINUOUS);
m_vscVert.set_digits(1);
m_vscVert.set_value_pos(Gtk::POS_TOP);
m_vscVert.set_draw_value();
//Vertical Scaler widget
m_hscHoriz.set_update_policy(Gtk::UPDATE_CONTINUOUS);
m_hscHoriz.set_digits(1);
m_hscHoriz.set_value_pos(Gtk::POS_TOP);
m_hscHoriz.set_draw_value();
m_hscHoriz.set_size_request(200,30);
m_hscDigit.set_update_policy(Gtk::UPDATE_CONTINUOUS);
m_hscDigit.set_digits(1);
m_hscDigit.set_value_pos(Gtk::POS_TOP);
m_hscDigit.set_draw_value();
m_hscDigit.set_size_request(200,30);
m_hscPageSize.set_update_policy(Gtk::UPDATE_CONTINUOUS);
m_hscPageSize.set_digits(1);
m_hscPageSize.set_value_pos(Gtk::POS_TOP);
m_hscPageSize.set_draw_value();
m_hscPageSize.set_size_request(200,30);
//ComboBox-ValuePos
mpLS_ValuePos = Gtk::ListStore::create(m_MC_ValuePos);
m_cbxValuePos.set_model(mpLS_ValuePos);
Gtk::TreeModel::Row row = *(mpLS_ValuePos->append());
row[m_MC_ValuePos.m_iID] = 1;
row[m_MC_ValuePos.m_sChoice] = "Top";
row = *(mpLS_ValuePos->append());
row[m_MC_ValuePos.m_iID] = 2;
row[m_MC_ValuePos.m_sChoice] = "Right";
row = *(mpLS_ValuePos->append());
row[m_MC_ValuePos.m_iID] = 3;
row[m_MC_ValuePos.m_sChoice] = "Bottom";
row = *(mpLS_ValuePos->append());
row[m_MC_ValuePos.m_iID] = 4;
row[m_MC_ValuePos.m_sChoice] = "Left";
m_cbxValuePos.pack_start(m_MC_ValuePos.m_iID);
m_cbxValuePos.pack_start(m_MC_ValuePos.m_sChoice);
//ComboBox-UpdatePolicy
mpLS_UpdatePolicy =Gtk::ListStore::create(m_MC_UpdatePolicy);
m_cbxUpdatePolicy.set_model(mpLS_UpdatePolicy);
row = *(mpLS_UpdatePolicy->append());
row[m_MC_UpdatePolicy.m_iID] = 1;
row[m_MC_UpdatePolicy.m_sChoice] = "Continuous";
row = *(mpLS_UpdatePolicy->append());
row[m_MC_UpdatePolicy.m_iID] = 2;
row[m_MC_UpdatePolicy.m_sChoice] = "Discontinuous";
row = *(mpLS_UpdatePolicy->append());
row[m_MC_UpdatePolicy.m_iID] = 3;
row[m_MC_UpdatePolicy.m_sChoice] = "Delayed";
m_cbxUpdatePolicy.pack_start(m_MC_UpdatePolicy.m_iID);
m_cbxUpdatePolicy.pack_start(m_MC_UpdatePolicy.m_sChoice);
m_btnClose.set_flags(Gtk::CAN_DEFAULT);
m_btnClose.grab_default();
m_btnClose.signal_clicked().connect(
sigc::mem_fun(*this,&MyWindow::OnBtnClose_Clicked));
//Packing
add(m_vbxMain);
m_vbxMain.pack_start(m_hbxVert_Horiz);
m_vbxMain.pack_start(m_chkDisplayFlag);
m_vbxMain.pack_start(m_hbxValuePos);
m_vbxMain.pack_start(m_hbxUpdatePolicy);
m_vbxMain.pack_start(m_hbxDigit);
m_vbxMain.pack_start(m_hbxPageSize);
m_vbxMain.pack_start(m_btnClose);
m_hbxVert_Horiz.pack_start(m_vscVert);
m_hbxVert_Horiz.pack_start(m_vbxScale_Scroll);
m_vbxScale_Scroll.pack_start(m_hscHoriz);
m_vbxScale_Scroll.pack_start(m_hsScroll);
m_hbxValuePos.pack_start(m_lblValuePos);
m_hbxValuePos.pack_start(m_cbxValuePos);
m_hbxUpdatePolicy.pack_start(m_lblUpdatePolicy);
m_hbxUpdatePolicy.pack_start(m_cbxUpdatePolicy);
m_hbxDigit.pack_start(m_lblDigit);
m_hbxDigit.pack_start(m_hscDigit);
m_hbxPageSize.pack_start(m_lblPageSize);
m_hbxPageSize.pack_start(m_hscPageSize);
show_all_children();
}
MyWindow::~MyWindow()
{
}
void MyWindow::OnBtnClose_Clicked()
{
printf("\nI'm over.. !!");
hide();
}
Here is the code:
main.cpp
#include<gtkmm.h>
#include "MyWindow.h"
int main(int argc,char** argv)
{
Gtk::Main kit(argc,argv);
MyWindow window;
Gtk::Main::run(window);
return 0;
}
MyWindow.h
#ifndef GTKMM_TUT_CHKBUTTON_H
#define GTKMM_TUT_CHKBUTTON_H
#include<gtkmm.h>
#include<gtkmm/window.h>
class MyWindow: public Gtk::Window
{
public:
MyWindow();
~MyWindow();
protected:
//Signal Handlers
//virtual void OnChkDisplayFlag_Toggled();
virtual void OnBtnClose_Clicked();
//virtual void OnAdjDigit();
//virtual void OnAdjPageSize();
Gtk::VBox m_vbxMain, m_vbxScale_Scroll;
Gtk::HBox m_hbxVert_Horiz, m_hbxValuePos,
m_hbxUpdatePolicy, m_hbxDigit, m_hbxPageSize;
Gtk::CheckButton m_chkDisplayFlag;
Gtk::Label m_lblValuePos, m_lblUpdatePolicy,
m_lblDigit, m_lblPageSize;
//ComboBox
Gtk::ComboBox m_cbxValuePos, m_cbxUpdatePolicy;
class ModelColumns : public Gtk::TreeModelColumnRecord
{
public:
ModelColumns()
{
add(m_iID); add(m_sChoice);
}
Gtk::TreeModelColumn<int> m_iID;
Gtk::TreeModelColumn<Glib::ustring> m_sChoice;
};
ModelColumns m_MC_UpdatePolicy, m_MC_ValuePos;
Glib::RefPtr<Gtk::ListStore> mpLS_ValuePos,
mpLS_UpdatePolicy;
Gtk::Adjustment m_adjVert, m_adjDigit, m_adjPageSize;
Gtk::VScale m_vscVert ;
Gtk::HScale m_hscHoriz,m_hscDigit,m_hscPageSize;
Gtk::HScrollbar m_hsScroll;
Gtk::HSeparator m_hspSep;
Gtk::Button m_btnClose;
};
#endif //GTKMM_TUT_CHKBUTTON_H
MyWindow.cpp
#include"MyWindow.h"
#include<stdio.h>
MyWindow::MyWindow()
:
m_vbxMain(false,30),
m_vbxScale_Scroll(false,10),
//m_vbxCloseButton(false,10),
m_hbxVert_Horiz(false,10),
m_hbxValuePos(false,10),
m_hbxUpdatePolicy(false,10),
m_hbxDigit(false,10),
m_hbxPageSize(false,10),
m_chkDisplayFlag("Display values in the Widgets",0),
m_lblValuePos("Value Position"),
m_lblUpdatePolicy("Update Policy"),
m_lblDigit("Scale Digits"),
m_lblPageSize("Page Size"),
//Gtk::Adjustment::Adjustment (value,lower,upper,
step_increment,page_increment,page_size)
m_adjVert(0.0 , 0.0, 101.0, 0.1, 1.0, 1.0),
m_adjDigit(1.0, 0.0, 5.0),
m_adjPageSize(1.0, 0.0, 101.1),
m_hscHoriz(m_adjVert),
m_vscVert(m_adjVert),
m_hscDigit(m_adjDigit),
m_hscPageSize(m_adjPageSize),
m_hsScroll(m_adjVert),
m_btnClose("Close")
{
set_title("Ranging Widgets");
//Vertical Scaler widget
m_vscVert.set_update_policy(Gtk::UPDATE_CONTINUOUS);
m_vscVert.set_digits(1);
m_vscVert.set_value_pos(Gtk::POS_TOP);
m_vscVert.set_draw_value();
//Vertical Scaler widget
m_hscHoriz.set_update_policy(Gtk::UPDATE_CONTINUOUS);
m_hscHoriz.set_digits(1);
m_hscHoriz.set_value_pos(Gtk::POS_TOP);
m_hscHoriz.set_draw_value();
m_hscHoriz.set_size_request(200,30);
m_hscDigit.set_update_policy(Gtk::UPDATE_CONTINUOUS);
m_hscDigit.set_digits(1);
m_hscDigit.set_value_pos(Gtk::POS_TOP);
m_hscDigit.set_draw_value();
m_hscDigit.set_size_request(200,30);
m_hscPageSize.set_update_policy(Gtk::UPDATE_CONTINUOUS);
m_hscPageSize.set_digits(1);
m_hscPageSize.set_value_pos(Gtk::POS_TOP);
m_hscPageSize.set_draw_value();
m_hscPageSize.set_size_request(200,30);
//ComboBox-ValuePos
mpLS_ValuePos = Gtk::ListStore::create(m_MC_ValuePos);
m_cbxValuePos.set_model(mpLS_ValuePos);
Gtk::TreeModel::Row row = *(mpLS_ValuePos->append());
row[m_MC_ValuePos.m_iID] = 1;
row[m_MC_ValuePos.m_sChoice] = "Top";
row = *(mpLS_ValuePos->append());
row[m_MC_ValuePos.m_iID] = 2;
row[m_MC_ValuePos.m_sChoice] = "Right";
row = *(mpLS_ValuePos->append());
row[m_MC_ValuePos.m_iID] = 3;
row[m_MC_ValuePos.m_sChoice] = "Bottom";
row = *(mpLS_ValuePos->append());
row[m_MC_ValuePos.m_iID] = 4;
row[m_MC_ValuePos.m_sChoice] = "Left";
m_cbxValuePos.pack_start(m_MC_ValuePos.m_iID);
m_cbxValuePos.pack_start(m_MC_ValuePos.m_sChoice);
//ComboBox-UpdatePolicy
mpLS_UpdatePolicy =Gtk::ListStore::create(m_MC_UpdatePolicy);
m_cbxUpdatePolicy.set_model(mpLS_UpdatePolicy);
row = *(mpLS_UpdatePolicy->append());
row[m_MC_UpdatePolicy.m_iID] = 1;
row[m_MC_UpdatePolicy.m_sChoice] = "Continuous";
row = *(mpLS_UpdatePolicy->append());
row[m_MC_UpdatePolicy.m_iID] = 2;
row[m_MC_UpdatePolicy.m_sChoice] = "Discontinuous";
row = *(mpLS_UpdatePolicy->append());
row[m_MC_UpdatePolicy.m_iID] = 3;
row[m_MC_UpdatePolicy.m_sChoice] = "Delayed";
m_cbxUpdatePolicy.pack_start(m_MC_UpdatePolicy.m_iID);
m_cbxUpdatePolicy.pack_start(m_MC_UpdatePolicy.m_sChoice);
m_btnClose.set_flags(Gtk::CAN_DEFAULT);
m_btnClose.grab_default();
m_btnClose.signal_clicked().connect(
sigc::mem_fun(*this,&MyWindow::OnBtnClose_Clicked));
//Packing
add(m_vbxMain);
m_vbxMain.pack_start(m_hbxVert_Horiz);
m_vbxMain.pack_start(m_chkDisplayFlag);
m_vbxMain.pack_start(m_hbxValuePos);
m_vbxMain.pack_start(m_hbxUpdatePolicy);
m_vbxMain.pack_start(m_hbxDigit);
m_vbxMain.pack_start(m_hbxPageSize);
m_vbxMain.pack_start(m_btnClose);
m_hbxVert_Horiz.pack_start(m_vscVert);
m_hbxVert_Horiz.pack_start(m_vbxScale_Scroll);
m_vbxScale_Scroll.pack_start(m_hscHoriz);
m_vbxScale_Scroll.pack_start(m_hsScroll);
m_hbxValuePos.pack_start(m_lblValuePos);
m_hbxValuePos.pack_start(m_cbxValuePos);
m_hbxUpdatePolicy.pack_start(m_lblUpdatePolicy);
m_hbxUpdatePolicy.pack_start(m_cbxUpdatePolicy);
m_hbxDigit.pack_start(m_lblDigit);
m_hbxDigit.pack_start(m_hscDigit);
m_hbxPageSize.pack_start(m_lblPageSize);
m_hbxPageSize.pack_start(m_hscPageSize);
show_all_children();
}
MyWindow::~MyWindow()
{
}
void MyWindow::OnBtnClose_Clicked()
{
printf("\nI'm over.. !!");
hide();
}