Re: [Ntw-devel] Timers
Status: Beta
Brought to you by:
drblast
|
From: Ian L. <dr...@gm...> - 2006-06-26 23:01:19
|
Whoops,
That callback declaration should be:
void
ping (struct ntw_event_data *edata, ntwWidget *userdata){
}
A pointer is passed to the event data, not the event data itself.
-Ian
On 6/26/06, Ian Larsen <dr...@gm...> wrote:
> At first glance, it looks like you're omitting the event data
> structure in your callback declaration.
>
> It should look like this:
>
> void
> ping(struct ntw_event_data, ntwWidget *userdata){
> //ping callback function
> }
>
> The problem is that the helloworld.c example isn't clear that this is
> the proper declaration for a callback function, you'd have to look at
> ntwtest for that. I'll fix that in the docs so nobody else falls into
> the same trap.
>
> By the way, the ntw_event_data structure looks like this:
>
> struct ntw_event_data {
> int32 id;
> int32 event;
> int32 synchronized;
> char data[];
> }
>
> With the last char data[] being any applicable data that the client
> sends back, such as the new text for an ENTRY_TEXT_CHANGED event, for
> example.
>
> Hope that helps,
> Ian
>
> On 6/26/06, Yua CaVan <ca...@gz...> wrote:
> > I've modified the helloworld.c to add in a timer to test something out and
> > realized that we don't have a clean way of closing out dialog windows...
> >
> > I've created a callback function called ping as well as setting the window
> > and timer variables to static:
> >
> > static ntwWidget * pMainWnd; /* is the main window */
> > static ntwWidget * pMainTimer; /* is the timer */
> >
> > void
> > ping (ntwWidget * user_data) {
> > ntwWidget *dlg;
> > ntwWidget *layout;
> > ntwWidget *label;
> > ntwWidget *button;
> > ntwWidget *btnLabel;
> >
> > dlg = ntw_dialog_new(
> > pMainWnd, /* parent window */
> > 100, /* width */
> > 80, /* height */
> > TRUE, /* Modality */
> > "PING!!!!!" /* Title */
> > );
> >
> > layout = ntw_grid_new(3,2,FALSE);
> >
> > ntw_container_add(dlg,layout);
> >
> > label = ntw_label_new("A timer event has just occured.\n"
> > "Please click the OK button");
> > ntw_grid_add(
> > layout,
> > label,
> > 1,
> > 2,
> > 1,
> > 2,
> > 0,
> > 0,
> > 0,
> > 0
> > );
> >
> > button = ntw_button_new();
> > btnLabel = ntw_label_new("OK");
> >
> > ntw_container_add(button,btnLabel);
> >
> > ntw_grid_add(
> > layout,
> > button,
> > 1,
> > 2,
> > 2,
> > 3,
> > 0,
> > 0,
> > 0,
> > 0
> > );
> >
> > ntw_add_callback(button, BUTTON_CLICKED, (func_ptr)&closePing,dlg,ASYNC);
> > ntw_add_callback(dlg, DESTROY_EVENT, (func_ptr)&resetPing,NULL,ASYNC);
> > ntw_add_callback(dlg, DELETE_EVENT,(func_ptr)&resetPing,NULL,ASYNC);
> >
> > ntw_widget_show(dlg);
> > }
> >
> > now, the dialog will pop up and the timer will be reset when the dialog is
> > closed using the close button ( 'X' in the upper-right ), but the closePing
> > function:
> >
> > void
> > closePing(ntwWidget * user_data) {
> > ntw_widget_destroy(user_data); /* should be dlg */
> > }
> >
> > seems to destroy the BUTTON, rather than the dialog even though dlg's
> > pointer is the user data. Any clues?
> >
> > for completeness, here's resetPing:
> >
> > void
> > resetPing() {
> > ntw_timer_reset(pMainTimer);
> > }
> >
> > and the timer is set up as:
> > ...
> > pMainTimer = ntw_timer_add(10 /* seconds */,ASYNC);
> > ntw_timer_set_callback(pMainTimer, (func_ptr)&ping, timer);
> >
> > Yua Ca Van
> > ----- Original Message -----
> > From: "Ian Larsen" <dr...@gm...>
> > To: "Yua CaVan" <ca...@gz...>
> > Cc: "NTW Mailing List" <ntw...@li...>
> > Sent: Monday, June 26, 2006 2:21 PM
> > Subject: Re: [Ntw-devel] Timers
> >
> >
> > > Oh yeah...thanks. Done. :-)
> > >
> > > -Ian
> > >
> > > On 6/26/06, Yua CaVan <ca...@gz...> wrote:
> > >> You need to update the Makefile.mingw for the Server and Client to add
> > >> timer.o to the list of objects to be compiled. :)
> > >>
> > >> Yua Ca Van
> > >> ----- Original Message -----
> > >> From: "Ian Larsen" <dr...@gm...>
> > >> To: "NTW Mailing List" <ntw...@li...>
> > >> Sent: Sunday, June 25, 2006 2:38 PM
> > >> Subject: [Ntw-devel] Timers
> > >>
> > >>
> > >> > All,
> > >> >
> > >> > I've added a timer widget to the C server and client. The latest is
> > >> > in CVS. It seems to work well, but I haven't tested it very much yet.
> > >> >
> > >> > The code is in the files timer.c and timer.h, in both the Client and
> > >> > Server directories.
> > >> >
> > >> > -Ian
> > >> >
> > >> > Using Tomcat but need to do more? Need to support web services,
> > >> > security?
> > >> > Get stuff done quickly with pre-integrated technology to make your job
> > >> > easier
> > >> > Download IBM WebSphere Application Server v.1.0.1 based on Apache
> > >> > Geronimo
> > >> > http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
> > >> > _______________________________________________
> > >> > Ntw-devel mailing list
> > >> > Ntw...@li...
> > >> > https://lists.sourceforge.net/lists/listinfo/ntw-devel
> > >> >
> > >> >
> > >>
> > >>
> > >>
> > >
> > >
> >
> >
> >
>
|