Function:cs2scbx
From S2PLOT
(Difference between revisions)
Revision as of 23:33, 27 November 2007 S2plot admin (Talk | contribs) ← Previous diff |
Current revision S2plot admin (Talk | contribs) |
||
Line 11: | Line 11: | ||
Set the dynamic callback function - this one takes a void data ptr which gets handed off to the callback when it is invoked. | Set the dynamic callback function - this one takes a void data ptr which gets handed off to the callback when it is invoked. | ||
The callback function must be of the form: | The callback function must be of the form: | ||
+ | |||
<tt>void cbfn(double *time, int *keycount, VAR *data)</tt> | <tt>void cbfn(double *time, int *keycount, VAR *data)</tt> | ||
+ | |||
where time is the current system time, keycount records the number of times that the space bar has been pressed, and VAR is a valid data type. | where time is the current system time, keycount records the number of times that the space bar has been pressed, and VAR is a valid data type. | ||
Current revision
cs2scbx
Set dynamic callback with initialisation data.
Prototype
void cs2scbx(void *icbfnx, void *data);
Description
Set the dynamic callback function - this one takes a void data ptr which gets handed off to the callback when it is invoked. The callback function must be of the form:
void cbfn(double *time, int *keycount, VAR *data)
where time is the current system time, keycount records the number of times that the space bar has been pressed, and VAR is a valid data type.
The callback function can be toggled on/off by pressing the z key.
See Also
cs2scb | Set the callback function. |
Code Example
#include <stdio.h>
#include <stdlib.h>
#include "s2plot.h"
/* Global variales used in callback */
int master_panel = 0; /* Default ID of main panel */
int slave_panel; /* ID of newly created panel */
void cb(double *t, int *kc, int *value)
{
char string[32];
sprintf(string,"I am panel: %d",*value); /* Data passed to callback */
s2textxy(0,0,0,string); /* Write the text */
}
int main(int argc, char *argv[])
{
s2opend("/s2mono", argc, argv); /* Open in mono mode */
s2swin(-1.,1., -1.,1., -1.,1.); /* Set the window coordinates */
s2box("BCDET",0,0,"BCDET",0,0,"BCDET",0,0); /* Draw coordinate box */
xs2mp(master_panel, 0.0, 0.5, 0.5, 1.0); /* Move to top left */
slave_panel = xs2ap(0.5, 0.0, 1.0, 0.5); /* Create panel in bottom right */
xs2cp(slave_panel); /* Choose this panel */
s2swin(-2.,2., -2.,2., -2.,2.); /* Set the window coordinates */
s2box("BCDE",0,0,"BCDE",0,0,"BCDE",0,0); /* Draw coordinate box */
cs2scbx(cb, &slave_panel); /* Dynamic callback with data */
xs2cp(master_panel); /* Go back to main panel */
cs2scbx(cb, &master_panel); /* Dynamic callback with data */
s2sch(3); /* Set character height */
s2show(1); /* Open the s2plot window */
return 1;
}
Back to S2PLOT function list.