[comp.windows.x] Widget Questions

kek%dinorah@UUNET.UU.NET.UUCP (05/13/88)

We have the following questions about the athena widgets:

1 ****** We experience difficulties controlling which font is used by
the label widget.

We are using ... .font:  fg-20
             ... .label: Text To Be In Label.

It seems that those "fixed text" labels for which the text is from the
app-defaults file do use the given font but if the text of the label
is supplied from within the program, e.g.  the current date, it uses
some default font and is independent of whether the ... .label: Text
was supplied in the file or not.

2 ****** We wanted to put two lines of text into a command widget so it
would not be as wide but perhaps a little taller.  Label widget is
advertised to be one line only but command does not say so.

Has anybody ever succeeded in doing multiline command button?
Do you remember how you tricked it to break the line?
If so, please take a moment and reply either to xpert or to:

ken k. at  uunet!wucs1!dinorah!kek
TIA

guido@cwi.nl (Guido van Rossum) (05/16/88)

Sorry, I can't answer your questions, but I have one word of advice.
The Release 2 version of Xt and Xaw are better than those in R1, but
they are still highly experimental, and broken in many ways.  You are
essentially beta-testing the code.  Personally, I'm waiting for another
release (or two) before attempting again to use them.   For now, you're
probably much better off writing your own, not-so-sophisticated toolkit
using the core Xlib directly.

--
Guido van Rossum, Centre for Mathematics and Computer Science (CWI), Amsterdam
guido@piring.cwi.nl or mcvax!piring!guido or guido%piring.cwi.nl@uunet.uu.net

cc@sam.cs.cmu.edu (Chiun-Hong Chien) (02/18/90)

I am trying to create multiple x-windows (xterms) from a program for
printing-out/reading-in different types of messages (e.g. warning message,
error message, standard I/0).  I think X toolkit Widgets will do the job I
need.  So I decided to use textWidgets and dialogWidgets.

As a beginning of the Widget user, I am not sure how to use dialogWidgets.
What I need is to "gets" a string into a buffer when the string is typed
into the dialog window along with a carriage return (just like a regular
gets() does).  I understand that I may be able to use
XtDialogGetValueString, but I don't know how the Xserver can inform the
dialog Widget that the string has been typed in.  I tried to use the
client callback interface, but couldn't find the appropriate resourse in the
dialog resource database listed in the X11/R3 X Toolkit Athena Widgets
Manual (yes, I am still using X11/R3).

Could anybody tell me how do use dialogWidgets to achieve what I need?  Of
course I would also appreicate if anybody could show me a better way to
achieve what I need (i.e. using multiple windows for various messages in a
program) using something other than textWidget and dialogWidget.

Thanks in advance.

Chien  (cc@sam.cs.cmu.edu)

kit@EXPO.LCS.MIT.EDU (Chris D. Peterson) (02/22/90)

> As a beginning of the Widget user, I am not sure how to use dialogWidgets.
> What I need is to "gets" a string into a buffer when the string is typed
> into the dialog window along with a carriage return (just like a regular
> gets() does).  I understand that I may be able to use
> XtDialogGetValueString, but I don't know how the Xserver can inform the
> dialog Widget that the string has been typed in.  I tried to use the
> client callback interface, but couldn't find the appropriate resourse in the
> dialog resource database listed in the X11/R3 X Toolkit Athena Widgets
> Manual (yes, I am still using X11/R3).

You can certainly perform operations similar to gets() with widgets, the
interface is a bit different, however, as well as the style of programming.
To really do this in the X model you need to have an event driven interface. 
This to say rather than doing this:

	
	.
	.
	.
	printf("enter a value");
	gets(string);
	PerformOperation(string);
    }

You would do this:

	.
	.
	.
	PutUpDialogBox("enter a value");
	return();
   }

   PutUpDialogBox(string)
   {
	/* Create box, and bind function DialogReturn() to
	   the action of the user saying that the string has been entered. */
   }

   DialogReturn(dialog, ...)
   {
	string = XtDialogGetValueString(dialog);	
	PreformOperation(string);
   }

Basically it is the assumption that your application is just performing a bunch
of operations, based on the actions of the user within the user interface. 
There is no longer a single line of obvious program flow control.

Once you have bitten off this change in logic, using a dialog box to get a
string from the user should be pretty simple.  You simple create a dialog box
with the proper prompt, and position it on the display.  The you drop back into
XtAppMainLoop() and wait until your callback routine that is bound to the "okay"
button is called.  When this happens you get the string from the dialog box's
text entry field, pop down the dialog box, and off you go.

To bind the action of carridge return in the dialog's text entry widget to
the same action as the "okay" buttin you need to define a global application 
action and bind it to a keypress of carridge_return in that text widget, by
modifying that widget's translation table.  This is most easily accomplished
using the resource database, and an app-defaults file.

Take a look at the Xt Specification under XtAppAddActions(), and the 
Text widget's translation table.

hvr@kimba.Sun.COM (Heather Rose) (03/03/90)

In article <9002212306.AA03914@expo.lcs.mit.edu> kit@EXPO.LCS.MIT.EDU (Chris D. Peterson) writes:
>
>> As a beginning of the Widget user, I am not sure how to use dialogWidgets.
>> What I need is to "gets" a string into a buffer when the string is typed
>> into the dialog window along with a carriage return (just like a regular
>> gets() does).  I understand that I may be able to use
>> XtDialogGetValueString, but I don't know how the Xserver can inform the
>> dialog Widget that the string has been typed in.  I tried to use the
>> client callback interface, but couldn't find the appropriate resourse in the
>> dialog resource database listed in the X11/R3 X Toolkit Athena Widgets
>> Manual (yes, I am still using X11/R3).
>
>You can certainly perform operations similar to gets() with widgets, the
>interface is a bit different, however, as well as the style of programming.
>To really do this in the X model you need to have an event driven interface. 
>This to say rather than doing this:
>
>	
>	.
>	.
>	.
>	printf("enter a value");
>	gets(string);
>	PerformOperation(string);
>    }
>
>You would do this:
>
>	.
>	.
>	.
>	PutUpDialogBox("enter a value");
>	return();
>   }
>
>   PutUpDialogBox(string)
>   {
>	/* Create box, and bind function DialogReturn() to
>	   the action of the user saying that the string has been entered. */
>   }
>
>   DialogReturn(dialog, ...)
>   {
>	string = XtDialogGetValueString(dialog);	
>	PreformOperation(string);
>   }
>
>Basically it is the assumption that your application is just performing a bunch
>of operations, based on the actions of the user within the user interface. 
>There is no longer a single line of obvious program flow control.

Well, this really depends upon your toolkit and what it offers.  The XView
toolkit has a function called, "notify_set_input_func()", which will tell
you when you should call gets in your program.  Since the input function
reads from any file descriptor, this could be stdin, or it could be the
output from a ttysw within the application.

Often dialog boxes can be cumbersome, and if your user base is used to
typing into a tty, it might be easier for them to continue to type into
a tty.  

Basically, one should let the needs of the end users define the user
interface parameters and thus which tools best fit those parameters.
If you let the constraints of your choosen tools define the user interface,
then you end up with applications which may not fit your end user's needs.

Also, if you have an existing application which looks like:

	printf("enter a value");
	gets(string);
	PerformOperation(string);

XView provides a function, "notify_do_dispatch", which allows an easier
port from this style to a window based style.  This is very handy if the
application is large and you want to minimize the time spent on it.  If
it is a new application, I would suggest using the event driven style
Chris mentions above.

The difference between using the notify_set_input_func and the 
notify_do_dispatch function is strickly a choice of programming style.
The value they provide is pretty much the same:  dispatch window events
while waiting for input on some file descriptor[s].  The difference is that
notify_set_input_func uses a callback to start some action while
notify_do_dispatch is inline.

There are programs in the on line O'Reilly examples which demonstrate how
to use both of the above mentioned functions.  See <XVIEW>/clients/examples/
notifier/[notify_input.c ntfy_do_dis.c].  <XVIEW> is on the X11R4 tape in
contrib/toolkits/XView.  Two patches on expo in contrib/XView.

Regards,

Heather

niebres@mct-1.UUCP (Caroline Niebres) (04/11/91)

	Hi All!

	Sorry, I forgot to mention that I am using 11R3 and Motif 1.0.
	(I know, but hopefully soon we'll catch up!  We're waiting for
	 Interactive to get us up to date.)

	I need some guidence on a couple of things.

	In my application, many values are enter in engineering notation.
	The way I have dealt with this so far is to use two text widgets
	that are adjacent to each other.  I chose not to use just a single
	text because the user can modify either the number or the units
	and affect the value to send out.  I thought maybe subclassing with
	the two texts that would give me the value times the units when
	read.  Would this be reasonable?  What is the best way to go about
	this?  Is there already something out there that does this?
		
			--------------
			| -100.5 | mA|
			--------------

	Another object that my application uses quite a bit of is a 
	RowColumn that has a label, a widget like the above mentioned,
	two text widgets, and a toggle in that order.  I need 256 of them.
	I need to be able to access the individual widgets in it.  Is there
	a way to access them without having to save each individual
	widget ID?  Do I need to subclass here as well?

	I also need to save the "state" of the application to a file.
	Of course, this means being able to come up in saved state by
	reading this file.  Is there some standard way to do this?

	HELP!

	Thanks in advance.

				Caroline

&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
!	Caroline Niebres			Software Engineer	 !
!	Micro Component Technology, Inc.	St. Paul, MN		 !
!	(612) 482 - 6335			uunet!mct-1!niebres	 !
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&

niebres@mct-1.UUCP (Caroline Niebres) (04/12/91)

	Hi All!

	I need some guidence on a couple of things.

	In my application, many values are entered in engineering notation.
	The way I have dealt with this so far is to use two text widgets
	that are adjacent to each other.  I chose not to use just a single
	text because the user can modify either the number or the units
	and affect the value to send out.  I thought maybe subclassing with
	the two texts that would give me the value times the units when
	read.  Would this be reasonable?  What is the best way to go about
	this?  Is there already something out there that does this?
		
			--------------
			| -100.5 | mA|
			--------------

	Another object that my application uses quite a bit of is a 
	RowColumn that has a label, a widget like the above mentioned,
	two text widgets, and a toggle in that order.  I need 256 of them.
	I need to be able to access the individual widgets in it.  Is there
	a way to access them without having to save each individual
	widget ID?  Do I need to subclass here as well?

	Along with entering values, my application also reads the state
	of an instrument and displays these values in engineering
	notation among other things.

	I also need to save the "state" of the application to a file.
	Of course, this means being able to come up in saved state by
	reading this file.  Is there some standard way to do this?

	HELP!

	Thanks in advance.

				Caroline

	
	Sorry, I forgot to mention that I am using 11R3 and Motif 1.0.
	(I know, but hopefully soon we'll catch up!  We're waiting for
	 Interactive to get us up to date.)

&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
!	Caroline Niebres			Software Engineer	 !
!	Micro Component Technology, Inc.	St. Paul, MN		 !
!	(612) 482 - 6335			uunet!mct-1!niebres	 !
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&