[Search for users]
[Overall Top Noters]
[List of all Conferences]
[Download this site]
Title: | DECWINDOWS 26-JAN-89 to 29-NOV-90 |
Notice: | See 1639.0 for VMS V5.3 kit; 2043.0 for 5.4 IFT kit |
Moderator: | STAR::VATNE |
|
Created: | Mon Oct 30 1989 |
Last Modified: | Mon Dec 31 1990 |
Last Successful Update: | Fri Jun 06 1997 |
Number of topics: | 3726 |
Total number of notes: | 19516 |
2412.0. "window to widget returns NULL in ADA" by COMICS::WOOD (Richard Wood - UK Workstation Support DTN 833 -3801) Thu Mar 08 1990 12:40
Hi,
I have a customer who is trying to use the xt_window_to_widget call in ADA.
He gets a NULL value returned every time. I don't know ADA that well,
but I have no problems calling it from C.
Can anybody help ? I enclose the test code he submitted.
Any suggestions appreciated.
Richard
--------------------------------------------------------------------------------
with x,dwt;
package shell is
procedure kjm_app_create_shell (
widget : out dwt.widget_type;
display : in x.display_type;
arglist : in dwt.arg_array_type;
argcount : in dwt.cardinal_type );
pragma interface (external, kjm_app_create_shell);
pragma import_valued_procedure (kjm_app_create_shell,
"kjm_app_create_shell",
(dwt.widget_type,
x.display_type,
dwt.arg_array_type,
dwt.cardinal_type ),
(value, value, reference, value));
end shell;
--------------------------------------------------------------------------------
with x,
dwt,
system,
text_io,
shell;
use x,
dwt,
system,
text_io,
shell;
procedure marsh is
w_top, w_win, w_bck, w_wid, w_app : widget_type;
x_evt : x.event_type;
x_dpy : display_id_type;
x_fun : integer;
x_afn : address;
d_ok : integer;
d_arg : arg_array_type (0..4);
d_argc : cardinal_type;
url : unsigned_longword_array (0..0) := ( 0=>0 );
argv : address_array (0..0) := (0 => address_zero);
argc : unsigned_longword := 0;
w_x, w_y, w_w, w_h : integer;
begin
xt_initialize (w_top,
"TopLevel",
"TopLevelClass",
url,
0,
argc,
argv);
xt_display (x_dpy, w_top);
synchronize ( x_fun, x_dpy, 1, x_afn);
w_x := 100;
w_y := 100;
w_w := 300;
w_h := 300;
vms_set_arg (w_x, d_arg, 0, c_nx );
vms_set_arg (w_y, d_arg, 1, c_ny );
vms_set_arg (w_w, d_arg, 2, c_nwidth );
vms_set_arg (w_h, d_arg, 3, c_nheight );
kjm_app_create_shell ( w_app, x_dpy, d_arg, 4 );
w_x := 0;
w_y := 0;
vms_set_arg (w_x, d_arg, 0, c_nx );
vms_set_arg (w_y, d_arg, 1, c_ny );
window_create (w_bck, w_app, "BackWindow", d_arg, 2);
xt_manage_child (w_bck);
--window_create (w_win, w_bck, "MainWindow", d_arg, 2);
--xt_manage_child(w_win);
xt_realize_widget (w_app);
loop
xt_next_event (x_evt);
put(integer'image (x_evt.evnt_type));
if x_evt.evnt_type = x.c_expose then
xt_window_to_widget (w_wid,
x_evt.exev_display,
x_evt.exev_window);
if w_wid = system.address_zero then
put(" - Widget is null");
end if;
else
put (" - not expose event");
end if;
new_line;
xt_dispatch_event (x_evt);
end loop;
end marsh;
T.R | Title | User | Personal Name | Date | Lines |
---|
2412.1 | ... | GSRC::WEST | Variables don't, Constants aren't | Thu Mar 08 1990 21:15 | 17 |
|
Ok...First, I don't recall there being a problem with this call but the fact
that it returns NULL might indicate that there is a problem.
You could try importing the C routine and try it out.
BTW, what exactly are you trying to do? Here is my guess; XtWindowToWidget
takes a window ID and a display structure and CREATES a widget instance. If
you are expecting this call to return the widget ID that is ASSOCIATED with
the window ID then this won't work. I've seen people try this... :^)
I don't have any doc handy to check out the C routine. It could be as
simple as an error in the passing mechanism...or just plain broke. If you
import the C routine and it works as you expect then QAR the VAX binding call.
-=> Jim <=-
|
2412.2 | ...more... | GSRC::WEST | Variables don't, Constants aren't | Thu Mar 08 1990 22:06 | 31 |
|
An observation ...
Your imported procedure for XtAppCreateShell won't work. If you are trying
to import the C routine it should look like :
procedure xtappcreateshell (
widget : out dwt.widget_type;
name : in string;
class : in string;
widget_class : in dwt.widget_cls_type;
display : in dwt.display_type;
arglist : in dwt.arg_array_type;
argcount : in dwt.cardinal_type);
pragma interface (external, xtappcreateshell);
pragma import_valued_procedure (
xtappcreateshell, "XtAppCreateShell",
(dwt.widget_type, string, string, dwt.widget_cls_type,
dwt.display_type, dwt.arg_array_type, dwt.cardinal_type),
(value, reference, reference, value, value, reference, value));
I'm at home...not on a workstation. I made the above modification to your
program and did get NULL for the created widget. As I stated in .-1 I don't
have any doc here so I can't try importing the C routine for XtWindowToWidget,
maybe someone else can.
-=> Jim <=-
|
2412.3 | | SCOTMN::WOOD | Richard Wood - UK Workstation Support DTN 833 -3801 | Fri Mar 09 1990 05:39 | 30 |
|
> Your imported procedure for XtAppCreateShell won't work.
Hi Jim,
Sorry, you're right, but I forgot to include this important bit of 'C' code.
#include <decw$include/decwdwtapplprog.h>
Widget kjm_app_create_shell (display, arg_list, arg_count)
Display *display;
ArgList arg_list;
Cardinal arg_count;
{
return (XtAppCreateShell ( "shell",
"Shell",
applicationShellWidgetClass,
display,
arg_list,
arg_count));
}
I think I'll suggest to the customer to import the C routine, as you can
see from the above, he's done it before. I just wonder how many other
routines outside of the MIT C binding have this problem ?
Thanks for your efforts
Richard
|
2412.4 | Maybe it still is null | TOOLEY::B_WACKER | | Fri Mar 09 1990 10:28 | 16 |
| RE .1:
>Here is my guess; XtWindowToWidget takes a window ID and a display
>structure and CREATES a widget instance. If you are expecting this
>call to return the widget ID that is ASSOCIATED with the window ID
>then this won't work.
My doc says that it does just return the existing widget id that is
the owner of the window. Besides, I don't think it would make much
sense to create a widget from a window -- no parent, arglist, etc.
RE probelm:
Perhaps your widget hasn't realized yet and therefore the window
doesn't yet exist. Try to get it from a callback after everything is
visible.
|
2412.5 | Parameter passing mechanism? | LEOVAX::TREGGIARI | | Sat Mar 10 1990 07:47 | 18 |
| I don't know ADA, but someone who does should check that the
parameter passing mechanism is correct. Here is the code from .0:
xt_window_to_widget (w_wid,
x_evt.exev_display,
x_evt.exev_window);
Here is the implemenation of XT$WINDOW_TO_WIDGET:
Widget XT$WINDOW_TO_WIDGET(display, Pwindow)
Display *display;
Window *Pwindow;
{
return( XtWindowToWidget(display, *Pwindow));
}
Leo
|
2412.6 | head screwed on backwards...fixed now... :^) | GSRC::WEST | Variables don't, Constants aren't | Sun Mar 11 1990 16:36 | 15 |
|
Well first let me say that I was wrong in my first reply. XtWindowToWidget
does return a widget ID that is associated with a window. I have old doc and
there is just one sentence for the description and I read it wrong. Bruce (.4)
pointed this out to me when I talked with him.
Now for the second. I'm still coming up to speed on C and based on what Leo
posted we need to look at the passing mechanisms in the Ada file. I believe
that Steve Lionel could definitly be the one to help here.
After looking at the Ada spec it has the mechanisms of WIDGET value,
DISPLAY reference, and WINDOW reference. These seem ok...Steve, any suggestion?
-=> Jim <=-
|
2412.7 | | SCOTMN::WOOD | Richard Wood - UK Workstation Support DTN 833 -3801 | Mon Mar 12 1990 07:36 | 6 |
|
Importing the 'C' routine works, so I suspect that the ADA binding is
causing a problem, although I haven't tried this on VMS v5.3. Can anybody
confirm that it is still a problem under 5.3.
Richard
|
2412.8 | | QUARK::LIONEL | Free advice is worth every cent | Mon Mar 12 1990 10:35 | 7 |
| I no longer have the V5.1 Ada bindings, but looking at the V5.3 bindings
show that they SEEM to be correct. The Display argument is a longword
display ID by reference, the Window argument is a longword window ID
by reference. I'm a bit baffled by the "Pwindow" type given by Leo - is
this something different than a window ID?
Steve
|
2412.9 | What I posted was actual code | LEOVAX::TREGGIARI | | Mon Mar 12 1990 12:23 | 6 |
| > I'm a bit baffled by the "Pwindow" type given by Leo - is
> this something different than a window ID?
Pwindow is just the name given to the window ID parameter by the code.
Leo
|
2412.10 | SPR logged | KERNEL::WOOD | Richard Wood - UK Workstation Support | Thu Mar 15 1990 09:35 | 5 |
| I've now logged an SPR on behalf of the customer, I've tried the
same code out on V5.3 with the same result. I know a little bit
of ADA but I'm not too hot on calling external functions.
Richard
|