| Try this and see if it will work for your customer. It is written
in Pascal and does not really do anything, but it seems to solve your
customer's problem.
BTW, you have to hack on the cda$def.pas file to get it into a
format that will compile to form the .pen file. Otherwise just define
the necessary constants that it contains in your program and don't inherit
it.
Hope this helps...
Bill
(* PROGRAM LIST_BOX.PAS: *)
(* Example of creating a List_Box Widget in Pascal with a single *)
(* Callback routine and one item selected. *)
[Inherit( 'sys$library:decw$dwtwidgetdef', (* DECwindows Toolkit *)
'sys$library:pascal$lib_routines',(* RTL's definitions *)
'sys$library:cda$def', (* Charset definitions*)
'sys$library:starlet' )] (* System definitions *)
Program list_box(output);
Var
toplevel,
listbox,
workbox : dwt$widget; (* Widget ID's *)
arglist : array[0..7] of dwt$arg; (* Array of Arg's *)
argc : dwt$cardinal := 0; (* Null argc *)
i,status : integer; (* Control varibles *)
visible_count : integer; (* Visible in list *)
items_count : integer; (* Total in list *)
sel_items_count : integer; (* Selected items *)
position : boolean := false; (* Default postion *)
charset : unsigned := cda$k_iso_latin1; (* CharSet *)
rend : dwt$rend_mask := NIL; (* Null redtion mask *)
cancel_label : packed array [1..15] of char; (* Button label *)
excallback : array [1..2] of dwt$callback; (* Callback *)
callback : array [1..2] of dwt$callback; (* Callback *)
strings : array [1..4] of packed array [1..12] of char;
cs_cancel_label : dwt$comp_string; (* Compound strings *)
sel_items : array [1..1] of dwt$comp_string;
items : array [1..4] of dwt$comp_string;
sel_bool : boolean:=FALSE;
(* Callback routine for the listbox widget. It manages the *)
(* workbox and displays the selected item in the workbox. *)
(* Tag is the widget id of the unmanaged workbox widget. *)
Procedure ListboxCallback( widget : dwt$widget;
VAR tag : dwt$widget;
VAR list : dwt$listbox_cb_st);
Var
arglist : array[0..1] of dwt$arg;
Begin (* ListboxCallback *)
if list.dwt$l_listbox_item_number = 4 then
$EXIT(1);
Dwt$VMS_Set_Arg(list.dwt$a_listbox_item,
arglist, 0, Dwt$C_Nlabel);
Xt$Set_Values( tag, arglist, 1 );
Xt$Manage_Child( tag );
End; (* ListboxCallback *)
(* Callback routine for the listbox widget. It manages the *)
(* workbox and displays the selected item in the workbox. *)
(* Tag is the widget id of the unmanaged workbox widget. *)
Procedure ListboxExCallback( widget : dwt$widget;
VAR tag : dwt$widget;
VAR list : dwt$listbox_cb_st);
Var
arglist : array[0..1] of dwt$arg;
Begin (* ListboxExCallback *)
WriteLn('This is the extended callback');
if list.dwt$l_listbox_item_number = 4 then
$EXIT(1);
Dwt$VMS_Set_Arg(list.dwt$a_listbox_item,
arglist, 0, Dwt$C_Nlabel);
Xt$Set_Values( tag, arglist, 1 );
Xt$Manage_Child( tag );
End; (* ListboxExCallback *)
Begin (* Main program *)
(* Initialize the Toolkit. *)
toplevel:= Xt$Initialize( 'List', (* application name *)
'listclass', (* application class *)
0, 0, argc);
Dwt$VMS_Set_Arg(400, arglist, 0, Dwt$C_Nx);
Dwt$VMS_Set_Arg(200, arglist, 1, Dwt$C_Ny);
Xt$Set_Values( toplevel, arglist, 2 );
(* Cancel label for cancel button in the workbox. *)
cancel_label := 'Acknowledged';
status := Dwt$CS_String(cancel_label,charset,
dwt$c_language_not_specified,
0,rend,
cs_cancel_label);
if (not odd(status)) then lib$stop(status);
(* Set up the arg list for the workbox. *)
Dwt$VMS_Set_Arg(Dwt$C_Modal, arglist, 0, Dwt$C_Nstyle);
Dwt$VMS_Set_Arg( position, arglist, 1, Dwt$C_Ndefault_Position);
Dwt$VMS_Set_Arg(200, arglist,2, Dwt$C_Nx);
Dwt$VMS_Set_Arg(200, arglist, 3, Dwt$C_Ny);
Dwt$VMS_Set_Arg(cs_cancel_label, arglist, 4, Dwt$C_Ncancel_label);
(* Create a modal workbox, but do not manage it. It will *)
(* be managed in the callback routine. *)
workbox := Dwt$Work_Box_Create(toplevel, 'WorkBox', arglist,5);
(* Set up the items to be displayed as the list in the list *)
(* box widget. *)
strings[1] := 'Begin';
strings[2] := 'Continue';
strings[3] := 'Finish';
strings[4] := 'Stop';
(* Convert the list to a list of compound strings. *)
for i := 1 to 4 do
begin
status := Dwt$CS_String(strings[i],charset,
dwt$c_language_not_specified,
0,rend,
items[i]);
if (not odd(status)) then lib$stop(status);
end;
(* Listbox attributes *)
items_count := 4;
sel_items_count := 1;
visible_count := 4;
sel_items[1] := items[1];
(* Initialize a callback routine data structure with the *)
(* listbox's callback routine's address. *)
callback[1].dwt$a_callback_proc::integer := iaddress(ListboxCallback);
callback[1].dwt$l_callback_tag::integer := iaddress(workbox);
callback[2].dwt$a_callback_proc::integer := 0;
excallback[1].dwt$a_callback_proc::integer := iaddress(ListboxExCallback);
excallback[1].dwt$l_callback_tag::integer := iaddress(workbox);
excallback[2].dwt$a_callback_proc::integer := 0;
(* Set up an arg list for the listbox. *)
Dwt$VMS_Set_Arg( iaddress(items), arglist, 0, Dwt$C_Nitems );
Dwt$VMS_Set_Arg( items_count, arglist, 1, Dwt$C_Nitems_Count );
Dwt$VMS_Set_Arg( iaddress(sel_items), arglist, 2, Dwt$C_Nselected_Items);
Dwt$VMS_Set_Arg( sel_items_count, arglist, 3,
Dwt$C_NSelected_items_count);
Dwt$VMS_Set_Arg( visible_count, arglist, 4, Dwt$C_Nvisible_Items_Count);
Dwt$VMS_Set_Arg( sel_bool, arglist, 5, Dwt$C_Nsingle_Selection);
Dwt$VMS_Set_Callback_Arg( callback, arglist, 6, Dwt$C_Nsingle_Callback);
Dwt$VMS_Set_Callback_Arg( excallback, arglist, 7, Dwt$C_Nextend_Callback);
(* Create and Manage the listbox widget. *)
listbox := Dwt$List_Box_Create(toplevel,'l_box',arglist,8);
Xt$Manage_Child( listbox );
(* Realize the toplevel widget *)
Xt$Realize_Widget( toplevel );
(* Enter the Main Loop. *)
Xt$Main_Loop
End (* listbox *).
|