Xforms4Perl
view release on metacpan or search on metacpan
X11/Xforms/Xforms.xs view on Meta::CPAN
Window window;
int int1;
int int2;
XEvent * event;
void * parm;
{
SV ** canv_event_cbs =
(get_object_data(object))->od_cevents;
SV * object_callback_ptr;
int retint;
if (canv_event_cbs == NULL)
croak("Canvas event callback routine not set");
call_perl_callback(canv_event_cbs[event->type],
"Canvas event",
CB_RET_INT, (void *)&retint,
"OiiieS",
object,window,int1,int2,event,parm);
return retint;
}
static int
process_single_event_callback(event,parm)
XEvent * event;
void * parm;
{
/*
* Individual XEvent callback
*/
int event_type, retint;
cb_data *this, **prev;
Window window;
/*
* We only allow one handler for XErrorEvents for
* all windows. this is because the XErrorEvent
* may not contain a valid window variable
*/
window = (event_type = event->type) ?
event->xany.window : 0;
prev = &(get_cb_data()[event_type]);
while ((this = *prev) && this->window != window)
prev = &(this->next_data);
call_perl_callback(this->callback, "Xevent",
CB_RET_INT, (void *)&retint,
"eS",
event,parm);
return retint;
}
static int
process_lose_sel_cb(object, type)
FLObject * object;
long type;
{
/*
* Generic lose clipboard selection callback
*/
int retint;
call_perl_callback((get_object_data(object))->od_losesel,
"Lose Selection",
CB_RET_INT, (void *)&retint,
"Ol",
object,type);
return retint;
}
static int
process_gain_sel_cb(object, type, data, size)
FLObject * object;
long type;
const void *data;
long size;
{
/*
* Generic gain clipboard selection data callback.
*/
int retint;
call_perl_callback((get_object_data(object))->od_gainsel,
"Gain Selection Data",
CB_RET_INT, (void *)&retint,
"Olsl",
object,type,data,size);
return retint;
}
/*
* This function does the real perl-specific stuff involved in calling
* a perl subroutine registered as a callback.
*/
static void
call_perl_callback(SV *callback, char * cbname, int outexpct, void *outvar, char *parmptrn, ...)
{
/*
* Sets up the perl stack, calls the SUB, returns output if required
* This replaces the need for multiple real callback routines.
* It accepts a variable length parm list, the first three of
* which are required and are:
*
* SV * pointer to perl subroutine to call
* char * character string identifying the callback
* int integer indicating whether a return value
* is expected, and what type it is:
* CB_FALSE - No return value
* CB_RET_INT - An integer
* CB_RET_STR - A character string
* void * Pointer to output variable
* char * a format string, one character for
* each parm to the perl sub, the chars
* being:
* d - a double float value
* n - a number indicating that the
* next parm is an array pointer
* P - an FL_POINT
* p - a pointer
* i - an integer
* j - a short integer
* l - a long integer
* I - an IV
* S - an SV
* s - a string
* e - an XEvent perl object
* F - an FL_FORM perl object
* O - an FL_OBJECT perl object
*
* the rest of the parms are the arguments to the perl subroutine.
*/
dSP ;
va_list ap;
FL_POINT *point;
int count, ival, array_count;
long lval;
X11/Xforms/Xforms.xs view on Meta::CPAN
canv_event_cbs =
(SV **)X4Pcalloc(LASTEvent, sizeof(SV *));
obdat->od_cevents = canv_event_cbs;
}
return_save_sv(&(ST(0)),
&(canv_event_cbs[event]),
callback);
fl_add_canvas_handler(object, event,
(SvNULL(callback) ? NULL :
process_canvas_event),
(void *)parm);
}
SV *
fl_register_raw_callback(form,mask,callback)
FLForm * form
long mask
SV * callback
CODE:
{
return_save_sv(&(ST(0)),
&(get_form_data(form)->fd_rawcallback),
callback);
fl_register_raw_callback(form, mask,
(SvNULL(callback) ? NULL : process_form_raw_callback));
}
SV *
fl_set_form_callback(form,callback,parm)
FLForm * form
SV * callback
SV * parm
ALIAS:
fl_set_form_atactivate = 1
fl_set_form_atdeactivate = 2
fl_set_form_atclose = 3
CODE:
{
return_save_sv(&(ST(0)),
&(((fd_array *)get_form_data(form))->cb_ptr[ix]),
callback);
(cb_FLF_cb_parm_funcs[ix])(form,
(SvNULL(callback) ? NULL : cb_FLF_cb_parm_handlers[ix]),
(void *)parm);
}
SV *
fl_set_object_callback(object,callback,parm=0)
FLObject * object
SV * callback
long parm
ALIAS:
fl_set_browser_dblclick_callback = 1
fl_set_object_posthandler = 2
fl_set_object_prehandler = 3
fl_set_input_filter = 4
fl_set_counter_filter = 5
fl_set_slider_filter = 6
fl_set_timer_filter = 7
fl_request_clipboard = 100
CODE:
{
int i;
if (ix < 100)
return_save_sv(&(ST(0)),
&(((od_array *)get_object_data(object))->cb_ptr[ix]),
callback);
switch (ix) {
#if FL_INCLUDE_VERSION < 87
case 100:
not_implemented(GvNAME(CvGV(cv)));
break;
#endif
case 0:
fl_set_object_callback(object,
(SvNULL(callback) ? NULL : process_object_callback),
parm);
break;
case 1:
fl_set_browser_dblclick_callback(object,
(SvNULL(callback) ? NULL : process_brdbl_callback),
parm);
break;
#if FL_INCLUDE_VERSION >= 87
case 100:
savesv(&((get_object_data(object))->od_gainsel), callback);
i = fl_request_clipboard(object, FL_STRING,
(SvNULL(callback) ? NULL : process_gain_sel_cb));
ST(0) = sv_newmortal();
sv_setiv(ST(0), (IV)i);
break;
#endif
default:
(cb_FLO_cb_funcs[ix-2])(object,
(SvNULL(callback) ? NULL : cb_FLO_cb_handlers[ix-2]));
break;
}
}
FLForm *
fl_bgn_form(box_type=0,width=0,height=0)
int box_type
int width
int height
ALIAS:
fl_current_form = 1
fl_get_app_mainform = 2
fl_get_fselector_form = 3
CODE:
{
switch (ix) {
case 0:
RETVAL = fl_bgn_form(box_type,width,height);
break;
case 1:
RETVAL = fl_current_form;
break;
case 2:
RETVAL = fl_get_app_mainform();
break;
case 3:
RETVAL = fl_get_fselector_form();
break;
}
ST(0) = bless_form(RETVAL);
}
FLObject *
fl_create_glcanvas(type,x,y,width,height,label,handle=0,int2=0)
int type
FL_Coord x
FL_Coord y
FL_Coord width
FL_Coord height
char * label
SV * handle
int int2
ALIAS:
fl_add_glcanvas = 1
fl_create_button = 2
fl_add_button = 3
fl_create_lightbutton = 4
fl_add_lightbutton = 5
fl_create_roundbutton = 6
fl_add_roundbutton = 7
fl_create_checkbutton = 8
fl_add_checkbutton = 9
X11/Xforms/Xforms.xs view on Meta::CPAN
const char * selstr;
selstr = fl_get_input_selected_range(object, &start, &finish);
if (selstr == NULL)
{
XPUSHs(&sv_undef);
}
else
{
EXTEND(sp, 3);
PUSHs(sv_2mortal(newSVpv((char *)selstr,0)));
PUSHs(sv_2mortal(newSViv(start)));
PUSHs(sv_2mortal(newSViv(finish)));
}
}
FLObject *
fl_get_focus_object(form)
FLForm * form
SV *
fl_set_xyplot_symbol(object,overlay,callback)
FLObject * object
int overlay
SV * callback
CODE:
{
return_save_sv(&(ST(0)),&((alloc_overlay_data(object, overlay))[overlay]),
callback);
fl_set_xyplot_symbol(object,overlay,process_xyplot_symbol);
}
long
fl_set_clock_adjustment(object,l)
FLObject * object
long l
FLObject *
fl_get_object_component(object,i1,i2,i3)
FLObject * object
int i1
int i2
int i3
CODE:
{
RETVAL = fl_get_object_component(object,i1,i2,i3);
if (RETVAL == NULL)
ST(0) = &sv_undef;
else
ST(0) = bless_object(RETVAL);
}
void
fl_point(x,y,c)
FL_Coord x
FL_Coord y
FL_COLOR c
int
fl_stuff_clipboard(object,string,callback)
FLObject * object
char * string
SV * callback
CODE:
{
int size = strlen(string);
savesv(&((get_object_data(object))->od_losesel), callback);
RETVAL = fl_stuff_clipboard(object, FL_STRING,
string, (long)strlen(string),
(SvNULL(callback) ? NULL : process_lose_sel_cb));
}
OUTPUT:
RETVAL
void
fl_get_xyplot_data(object,id=0)
FLObject * object
int id
ALIAS:
fl_get_xyplot_overlay_data = 1
PPCODE:
{
float *xf, *yf;
int pts, rpts, i;
/*
* Get the number of points that are in the requested plot
*/
pts = fl_get_xyplot_numdata(object,id);
/*
* If this is greater than 0, allocate an array of floats
* twice its size, get the data into the array and then
* send it back as x,y pairs in the result list
*/
if (pts > 0)
{
xf = (float *)X4Pcalloc(pts*2, sizeof(float));
yf = xf + pts;
if (ix == 0)
fl_get_xyplot_data(object, xf, yf, &rpts);
else
fl_get_xyplot_overlay_data(object, id,
xf, yf, &rpts);
/*
* Return the list of points
*/
EXTEND(sp, (pts*2));
for(i=0; i<pts; ++i)
{
PUSHs(sv_2mortal(newSVnv(xf[i])));
PUSHs(sv_2mortal(newSVnv(yf[i])));
}
X4Pfree((void *)xf);
}
else
{
XPUSHs(&sv_undef);
}
}
void
fl_setpup_menucb(menu,callback,parm=0)
int menu
SV * callback
SV * parm
ALIAS:
fl_setpup_entercb = 1
fl_setpup_leavecb = 2
( run in 0.853 second using v1.01-cache-2.11-cpan-81fc1098f69 )