Jump to content
Excelsior Forums
qnr

Need help with Intrinsic.XtSetValues

Recommended Posts

I don't quite understand the relationship between

Intrinsic.Arg and Intrinsic ArgList

I'm using

  n := 0;
  Xt.XtSetArg(arg[n], Xt.XtNwidth, 500);
  INC(n);
  Xt.XtSetArg(arg[n], Xt.XtNwidth, 750);
  INC(n);
  Xt.XtSetValues(button, args, 2);

but it doesn't work - I get

01:54:08 $ ./frame 

#RTS: unhandled exception #3: invalid location
             Source file              LineNo   CodeOffset     Procedure name
                                           0    0804db53   main:F              
                                           0    0804db53   main:F              
frame.mod                                 45    080497e3   main:F       

This is the whole program, the the program works until I add code to try to modify the widget resources (in this case, trying to make the button larger).

Here is the whole thing:

<* M2EXTENSIONS + *>
<* GENDEBUG + *>
<* LINENO + *>

MODULE frame;

IMPORT SYSTEM,
       Frame,
       PushB,
       Xt:=Intrinsic,
       Xm,
       ProgEnv,
       STextIO;
FROM SYSTEM IMPORT ADR;
FROM Storage IMPORT ALLOCATE, DEALLOCATE;

TYPE
  paChar = POINTER TO ARRAY [0..MAX(INTEGER)-1] OF CHAR;

VAR
  app_context : Xt.XtAppContext;
  top_wid, button, frame : Xt.Widget;
  argc : INTEGER;
  argv : Xt.StringList;
  pp : paChar;
  i : INTEGER;
  n : INTEGER;
  arg : ARRAY [0..1] OF Xt.Arg;
  args : Xt.ArgList;
  
PROCEDURE ["C"] pushed_fn ( Widget : Xt.Widget;
                            XtPointer : Xt.XtPointer;
		    XmPushButtonCallbackStruct : Xt.XtPointer);
BEGIN
  STextIO.WriteString("Don't push me!!");
  STextIO.WriteLn;
END pushed_fn;

BEGIN
  n := 0;
  Xt.XtSetArg(arg[n], Xt.XtNwidth, 500);
  INC(n);
  Xt.XtSetArg(arg[n], Xt.XtNwidth, 750);
  INC(n);
  Xt.XtSetValues(button, args, n);

  argc := ProgEnv.ArgNumber();
  ALLOCATE(argv, VAL(INTEGER,SIZE(Xt.String))*(argc+1));
  ALLOCATE(argv^[0], SIZE(CHAR)*(ProgEnv.ProgramNameLength()+1));
  pp := SYSTEM.CAST(paChar, argv^[0]);
  ProgEnv.ProgramName( pp^ );
  FOR i := 1 TO argc DO
    ALLOCATE(argv^[i], SIZE(CHAR)*(ProgEnv.ArgLength(i)+1));
    pp := SYSTEM.CAST(paChar, argv^[i]);
    ProgEnv.GetArg(i, pp^);
  END;
  INC(argc);
  
  top_wid := Xt.XtVaAppInitialize( app_context, "Push", NIL, 0,
                                   argc, argv, NIL, NIL );

  button := PushB.XmCreatePushButton(top_wid, "Push_me", NIL, 0);
  (* Tell Xt to manage button *)
  Xt.XtManageChild(button);
  
  frame := Frame.XmCreateFrame(top_wid, "frame", NIL, 0);
  Xt.XtManageChild(frame);				   

  (* Attach callback procedure to widget *)
  Xt.XtAddCallback(button, Xm.XmNactivateCallback, pushed_fn, NIL);

  Xt.XtRealizeWidget(top_wid); (* display widget hierarchy *)
  Xt.XtAppMainLoop(app_context);  (* enter processing loop *)

  
  

END frame.

Share this post


Link to post
Share on other sites

Well, I'm using Xt.XtVaSetValues instead, seems to be working fine with that SEQ stuff.

But I'd still like to know how to use it.?

Share this post


Link to post
Share on other sites

Ok, I think I have it now.  After all these years, I still have problems with pointers I guess.

VAR
  args : ARRAY [0..1] OF Xt.Arg;
  argl : Xt.ArgList;

BEGIN
    argl := sys.ADR(args);

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×