determine the class of an object
- From: Horváth Imre <blemidon kabelnet hu>
- To: gtkmm-list gnome org
- Subject: determine the class of an object
- Date: Wed, 27 Dec 2006 00:01:55 +0100
Hi!
Connecting the signal with virtual functions is working, so i've did
something wrong before.
Thanx!
Here is the working example (sorry, i haven't got the earliers emails
here):
// H
class RecordTabBase : public Gtk::Widget
{
public:
RecordTabBase(BaseObjectType * baseObjectType, const Glib::RefPtr<
Gnome::Glade::Xml > & gladeXml);
~RecordTabBase();
// RecordTabBase interface
void setConnection(pqxx::connection * aConnection);
virtual void onRecordFirst() = 0;
virtual void onRecordPrevious() = 0;
virtual void onRecordNext() = 0;
virtual void onRecordLast() = 0;
virtual void onRecordAdd() = 0;
virtual void onRecordRefresh() = 0;
virtual void onRecordDelete() = 0;
protected:
// RecordTabBase variables
pqxx::connection * mConnection;
};
// CC
RecordTabBase::RecordTabBase(BaseObjectType * baseObjectType, const
Glib::RefPtr< Gnome::Glade::Xml > & gladeXml)
: Gtk::Widget(baseObjectType)
{
// TODO: put constructor code here
}
RecordTabBase::~RecordTabBase()
{
// TODO: put destructor code here
}
void RecordTabBase::setConnection(pqxx::connection * aConnection)
{
mConnection = aConnection;
}
// H
class CustomersTab : public RecordTabBase
{
public:
CustomersTab( BaseObjectType * baseObjectType, const Glib::RefPtr<
Gnome::Glade::Xml > & gladeXml );
~CustomersTab();
// CustomersTab interface
// Signal handlers
void onRecordFirst();
void onRecordPrevious();
void onRecordNext();
void onRecordLast();
void onRecordAdd();
void onRecordRefresh();
void onRecordDelete();
protected:
Gtk::TreeView * mTreeViewCustomers;
};
// CC
CustomersTab::CustomersTab( BaseObjectType * baseObjectType, const
Glib::RefPtr< Gnome::Glade::Xml > & gladeXml )
: RecordTabBase( baseObjectType, gladeXml )
{
gladeXml->get_widget("treeview_customers", mTreeViewCustomers);
mTreeViewCustomers->append_column("adolf", );
}
CustomersTab::~CustomersTab()
{
// TODO: put destructor code here
}
// nothing interesting yet :)
void CustomersTab::onRecordFirst()
{
}
void CustomersTab::onRecordPrevious()
{
}
void CustomersTab::onRecordNext()
{
}
void CustomersTab::onRecordLast()
{
}
void CustomersTab::onRecordAdd()
{
}
void CustomersTab::onRecordRefresh()
{
}
void CustomersTab::onRecordDelete()
{
}
// H
class RecordToolbar : public Gtk::Toolbar
{
public:
RecordToolbar(BaseObjectType * baseObjectType, const Glib::RefPtr<
Gnome::Glade::Xml > & gladeXml);
~RecordToolbar();
// RecordToolbar interface
void reconnect(RecordTabBase * aWidget);
protected:
// RecordToolbar variables
Gtk::ToolButton * mToolButtonRecordFirst;
Gtk::ToolButton * mToolButtonRecordPrevious;
Gtk::ToolButton * mToolButtonRecordNext;
Gtk::ToolButton * mToolButtonRecordLast;
Gtk::ToolButton * mToolButtonRecordAdd;
Gtk::ToolButton * mToolButtonRecordRefresh;
Gtk::ToolButton * mToolButtonRecordDelete;
};
// CC
RecordToolbar::RecordToolbar(BaseObjectType * baseObjectType, const
Glib::RefPtr< Gnome::Glade::Xml > & gladeXml)
: Gtk::Toolbar(baseObjectType)
{
gladeXml->get_widget( "toolbutton_record_first",
mToolButtonRecordFirst );
gladeXml->get_widget( "toolbutton_record_previous",
mToolButtonRecordPrevious );
gladeXml->get_widget( "toolbutton_record_next",
mToolButtonRecordNext );
gladeXml->get_widget( "toolbutton_record_last",
mToolButtonRecordLast );
gladeXml->get_widget( "toolbutton_record_add", mToolButtonRecordAdd );
gladeXml->get_widget( "toolbutton_record_refresh",
mToolButtonRecordRefresh );
gladeXml->get_widget( "toolbutton_record_delete",
mToolButtonRecordDelete );
}
RecordToolbar::~RecordToolbar()
{
// TODO: put destructor code here
}
void RecordToolbar::reconnect(RecordTabBase * aWidget)
{
mToolButtonRecordNext->signal_clicked().connect(sigc::mem_fun(aWidget,
&RecordTabBase::onRecordFirst));
mToolButtonRecordNext->signal_clicked().connect(sigc::mem_fun(aWidget,
&RecordTabBase::onRecordPrevious));
mToolButtonRecordNext->signal_clicked().connect(sigc::mem_fun(aWidget,
&RecordTabBase::onRecordNext));
mToolButtonRecordNext->signal_clicked().connect(sigc::mem_fun(aWidget,
&RecordTabBase::onRecordLast));
mToolButtonRecordNext->signal_clicked().connect(sigc::mem_fun(aWidget,
&RecordTabBase::onRecordAdd));
mToolButtonRecordNext->signal_clicked().connect(sigc::mem_fun(aWidget,
&RecordTabBase::onRecordRefresh));
mToolButtonRecordNext->signal_clicked().connect(sigc::mem_fun(aWidget,
&RecordTabBase::onRecordDelete));
}
So I can connect any class derived from RecordTabBase to the
RecordToolbar
Thanx again,
Imre Horvath
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]