paragui-users
[Top][All Lists]
Advanced

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

Re: [paragui-users] Problems with Signals


From: Sergio Ruiz
Subject: Re: [paragui-users] Problems with Signals
Date: Fri, 4 Mar 2005 15:14:27 +0100

Great answers! I've tried the 2) and works perfect!!! i had no clue.
The 1) is looks very good, but i haven't tried it yet :-)

Thanks a lot! :-D

Sergio


On Thu, 3 Mar 2005 22:17:58 +0100, Ulf Lorenz <address@hidden> wrote:
> On Wed, Mar 02, 2005 at 11:04:09PM +0100, Sergio Ruiz wrote:
> > Hi!!
> > I am getting sick trying to figure out how to use the signals with paragui.
> >
> > I have two questions that can save my live (and hopefully many others!!!).
> >
> > 1)
> > PG_Button* btnquit = app.GetWidget<PG_Button>("btnquit");
> > btnquit->sigClick.connect(slot(handle_quit));
> >
> > How can I pass arguments to the handle_quit function? Is it possible??
> On the fly, I can think of two ways:
> 
> 1. (crude) Each paragui widget can be given some user data via
>    PG_Widget::SetUserData() and some casts. :)
>    Maybe this already helps.
> 
> 2. From the design point of view, you will usually derive e.g. a dialog
>    from PG_Window or PG_Widget. If something out of the scope of this
>    dialog is to be called, nothing prevents you from defining your own
>    signals for the dialog with the correct arguments.
> 
> For some more definite answers: What exactly is the situation?
> 
> > 2) Inside one class, with no parent class.
> >
> > PG_Button* btnquit = app->GetWidget<PG_Button>("btnquit");
> > btnquit->sigClick.connect(slot(??,&Widget::handle_quit));
> >
> > I dont know to put inside there!. Any solution??
> First, AFAIR if you want to connect the signal to a member function of a
> class, this class has to derive from SigC::Object, so nothing with "no
> parent class". :)
> 
> An example may work like this:
> 
> class MyDialog : public SigC::Object
> {
>     MyDialog(PG_Rect rect)
>     {
>         PG_Button* btn = new PG_Button(0, rect);
>         btn->sigClick.connect(slot(*this, &MyDialog::handleClick));
>         ...
>     }
> 
>     ...
>     bool handleClick(PG_Button* btn);
>     ...
> };
> 
> So, first parameter has to be the (dereferenced!!) instance of the
> class, the second is the address of the function (which BTW has to have
> the proper arguments).
> 
> > I think it would be a great idea to have a small FAQ in the doc, cause
> > with the examples is hard to make a simple nice gui
> I have just made a note and will write one in the nearer future. The
> paragui autoconf macro needs some patching anyway, so I may even become
> active. :)
> 
> > Thanks for reading this, and...cool gui!!!!
> Quite nice. And you can fix the errors yourself. =8-)
> 
> cu,
> Ulf
> 
> --
> recursive:
>             see recursive
> 
> _______________________________________________
> paragui-users mailing list
> address@hidden
> http://lists.nongnu.org/mailman/listinfo/paragui-users
>




reply via email to

[Prev in Thread] Current Thread [Next in Thread]