class PtCallbackInfo
{
event; // PhEvent
reason; // unsigned long
reason_subtype; // unsigned long
// one from the following group, depending on the widget:
basic; // PtBasicCallback
calendar; // PtCalendarSelectCallback
clock_time; // PtClockTimeCallback
container; // PtContainerCallback
divider; // PtDividerCallback
filesel; // PtFileSelCallback
filesel_bkgd; // PtFileSelBkgdCallback
font_name; // string
gen_tree_input; // PtGenTreeInput
graphic; // PhArea
hotkey; // PtHotkeyCallback
html; // PtHtmlCallback
list; // PtListCallback
list_input; // PtListInput
matrix; // CwMatrixCallback
numeric_float; // PtNumericFloatCallback
numeric_integer; // PtNumericIntegerCallback
on_off_button; // PtOnOffButtonCallback
rtmeter; // RtMeterCallback
scrollbar; // PtScrollbarCallback
slider; // PtSliderCallback
terminal_font_change; // PtTerminalFontChange
terminal_input; // PtTerminalInput
terminal_option_change; // PtTerminalOptionChange
terminal_scrlbk_cb; // PtTerminalScrlbkCb
terminal_size_change; // PtTerminalSizeChange
text; // PtTextCallback
tree; // PtTreeCallback
tty_output; // PtTtyOutput
}
This class gives access to callback information. It has three normal instance variables, and a group of widget-specific instance variables that correspond to one or more widgets in Gamma.
Whenever a callback is generated, a locally-scoped instance of PtCallbackInfo, called cbinfo, is created. It has the three regular instance variables, as well as one instance variable from the widget-specific group. You can access these callback variables using dot notation.
![]() | Only one of the instance variables from the group of widget-specific instance variables should be used: the one that actually corresponds to the widget. Using an instance variable that doesn't correspond to the widget will give unpredictable results. |
Most of the instance variables from the widget-specific group have a callback class associated with them, and they are documented with that class. Those that don't are documented here.
This example, ex_Raw.g, is included in the product distribution.
#!/usr/cogent/bin/phgamma
/*
* This example demonstrates how to access raw callback information.
*/
Ph_EV_PTR_STEADY := 2;
Ph_EV_PTR_UNSTEADY := 3;
function main ()
{
require_lisp("PhotonWidgets.lsp");
PtInit (nil);
w = new (PtWindow);
w.SetArea(100, 100, 120, 80);
b = new (PtButton);
b.SetPos(30, 30);
b.text_string = "Test Area";
PtAttachCallback (b, Pt_CB_RAW, #cbBoundary(), Ph_EV_BOUNDARY);
PtRealizeWidget (w);
PtMainLoop();
}
/* widget, cbinfo, event_data are all available here */
function cbBoundary ()
{
local event;
event = cbinfo.event;
if (event.subtype == Ph_EV_PTR_ENTER)
princ ("Enter\n");
else if (event.subtype == Ph_EV_PTR_LEAVE)
princ ("Leave\n");
else if (event.subtype == Ph_EV_PTR_STEADY)
princ ("Steady\n");
else if (event.subtype == Ph_EV_PTR_UNSTEADY)
princ ("Unsteady\n");
else
princ ("unexpected event subtype\n");
}
This example, ex_PtCallbackInfo.g, is included in the product distribution.
#!/usr/cogent/bin/phgamma
/*
* This example demonstrates how to get information from a callback,
* the PtCalendarSelectCallback in this case. The first three
* callback functions print the regular instance variables. The next
* callback function prints the PtCalendarSelectCallback instance
* variable named date. Then the instance variables of date are
* printed by the next three callback functions. The last two
* callback functions print the remaining two variables of
* PtCalendarSelect.
*/
require_lisp("PhotonWidgets.lsp");
PtInit(nil);
win = new(PtWindow);
win.SetPos (300,0);
cal = new(PtCalendar);
cal.SetDim(200,200);
cal.fill_color = 0x88ddbb;
PtAttachCallback(cal,Pt_CB_CALENDAR_SELECT,
#pretty_princ("Event: ",cbinfo.event,"\n"));
PtAttachCallback(cal,Pt_CB_CALENDAR_SELECT,
#princ("Reason: ",cbinfo.reason,"\n"));
PtAttachCallback(cal,Pt_CB_CALENDAR_SELECT,
#princ("Subtype: ",cbinfo.reason_subtype,"\n"));
PtAttachCallback(cal,Pt_CB_CALENDAR_SELECT,
#princ("Day: ",cbinfo.calendar.date.day + 1,"\n"));
PtAttachCallback(cal,Pt_CB_CALENDAR_SELECT,
#princ("Month: ",cbinfo.calendar.date.month + 1,"\n"));
PtAttachCallback(cal,Pt_CB_CALENDAR_SELECT,
#princ("Year: ",cbinfo.calendar.date.year,"\n"));
PtAttachCallback(cal,Pt_CB_CALENDAR_SELECT,
#princ("Time: ",cbinfo.calendar.time,"\n"));
PtAttachCallback(cal,Pt_CB_CALENDAR_SELECT,
#princ("Type: ",cbinfo.calendar.type,"\n\n"));
princ(Pt_CB_CALENDAR_SELECT);
PtRealizeWidget(win);
PtMainLoop();
Copyright © 1995-2012 by Cogent Real-Time Systems, Inc. All rights reserved.