virtual functions, prototypes, argument passing questions



Ok I am little confused. Well I was testing the “Programming with Gtkmm”
improved Hello World example. I number my question as they came up. There it
uses a function named 
virtual void on_button_clicked(Glib::ustring data);

1) Since it's virtual I am wondering where is her prototype? (the base class
in which it appears first?)

I searched in Gtk::Button with no success, BUT I found another function
named:
virtual void Gtk::Button::on_clicked ( )  [protected, virtual]

There was no extra information on that function. So I deducted the
following:
it's virtual so I can overloaded in my derived class. It takes no argument
(as in it's prototype there isn't any!). Well wrong (I don't know why
though).

2) Why the prototype lies? Is it because the reference is incomplete so
there are arguments but they are not written? Or something else?

I am using the reference for my edition (2.4) in my machine so they should
be compatible. I tested the example with  on_clicked without argument and 2
errors appeared. I run it with argument (the same as the other virtual
function, that is Glib::ustring data) and it worked fine!

3) How am I supposed to know that I should use argument in this function
when it's prototype manifests differently? Where can I get this information
from?

4) The 2 versions (with  on_clicked() and  on_button_clicked()) works fine
both. So what's the differences between them? How am I supposed to pick one
or the other?

(I have asked this question before but I still don't get the whole picture I
think)
We use syntax like:
m_button2.signal_clicked().connect(sigc::bind<-1, Glib::ustring>(
sigc::mem_fun(*this, &HelloWorld::on_clicked), "button 1"));
where I can say that "button 1" is the argument needed in  on_clicked(), and
also (in the TreeStore example) syntax like this:
m_TreeView.signal_row_activated().connect(sigc::mem_fun(*this,
              &ExampleWindow::on_treeview_row_activated) );
where as I can say THERE ISN'T any argument. BUT there is! First the
prototype of on_treeview_row_activated says:
void on_treeview_row_activated(const Gtk::TreeModel::Path& path,
Gtk::TreeViewColumn* column); 
Voila 2 arguments! 

5) Is this a different way to connect a function to a signal? Is it
equivalent to a syntax like:
m_TreeView.signal_row_activated().connect(sigc::mem_fun(*this,
              &ExampleWindow::on_treeview_row_activated), path,  column);

6) And how does the argument pass in the first version (that with no
argument defined) in 
m_TreeView.signal_row_activated().connect(sigc::mem_fun(*this,
              &ExampleWindow::on_treeview_row_activated) ); 
If the arguments are not needed then why they appear in the prototype?

If you can enlighten this issues for me it would be great!

-- 
View this message in context: http://old.nabble.com/virtual-functions%2C-prototypes%2C-argument-passing-questions-tp32711924p32711924.html
Sent from the Gtkmm mailing list archive at Nabble.com.



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]