Getting Started Documentation Glish Learn More Programming Contact Us
Version 1.9 Build 1556
News FAQ
Search Home


next up previous contents index
Next: widgetserver - Constructor Up: widgets - Module Previous: twodactionoptionmenu.newselection - Function


widgetserver - Tool



Package display
Module widgets


Postscript file available

Tool to provide Tk widgets and AIPS++ megawidgets

include "widgetserver.g"

Constructors
widgetserver Construct a widgetserver
Functions
actionoptionmenu Make an action optionmenu megawidget
addpopuphelp add popup help to a GUI
blinklabel Make a blinklabel megawidget
busy Set the busy cursor and optionally disable a frame
button Make a button widget
canvas Make a canvas widget
checkmenu Make a checkmenu megawidget
combobox Make a combobox megawidget
deleteregions Make a deleteregions megawidget
dialogbox Make a dialogbox megawidget
entry Make a entry widget
extendoptionmenu Make an extendoptionmenu megawidget
fontchooser Make a fontchooser megawidget
frame Make a frame widget
guientry Make a guientry megawidget
have_gui Query whether GUIs can be built
helpmenu Add a Help menu which contains the standard AIPS++ Help menu items
label Make a label widget
listbox Make a listbox widget
menuframes Add a widget to hold named embedded frames
message Make a message widget
messageline Make a messageline megawidget
multiscale Make a multiscale megawidget
notbusy Set the normal cursor and optionally enable a frame
optionmenu Make an optionmenu megawidget
pgplot Make a pgplot widget
popuphelp add popup help to a GUI
popupmenu add a popup type selection help menu to a GUI
popupremove remove popup help from a GUI
popupselectmenu Make a popupselectmenu megawidget
recordbrowser Make a recordbrowser megawidget
resources Query what resources are used by various widgets
restoreregions Make a restoreregions megawidget
rollup Make a rollup megawidget
saveregions Make a saveregions megawidget
scale Make a scale widget
scrollbar Make a scrollbar widget
scrolllistbox Make a scrolllistbox megawidget
selectablelist Make a selectablelist megawidget
setmode Set the context/mode
synclistboxes Make a synclistboxes megawidget
tabdialog Make a tabdialog megawidget
tapedeck Make a tapedeck megawidget
text Make a text widget
tk_hold Hold Glish/Tk widget events
tk_iconpath ???
tk_release Release Glish/Tk widget events
type Return the type of this tool
unsetmode Unset (pop) the context/mode
[*]



Description

The basic purpose of this tool is to provide wrappers for the Glish/Tk widgets and the AIPS++ megawidgets. The wrappers implement a new, context-sensitive set of defaults for the relief, font, background and foreground arguments to widget constructors. In one context, the widgetserver will yield defaults which are identical to the standard Glish/Tk defaults; in another context, the widgetserver returns widgets which by default conform to the AIPS++ Graphical User Interface Guidelines (see AIPS++ Note 2??). As a programmer, you will almost always interact with defaultwidgetserver, which is provided upon inclusion of widgetserver.g, and is also known as dws for brevity.

The widgetserver now provides the capability for supporting multiple instances of the Glish/Tk client. If the construction argument widgetset is over-ridden from its default, then the constructed widgetserver will use the supplied Glish/Tk client instead of the default client. The default Glish/Tk client is stored in the global Glish record dgtk. A new Glish/Tk client can be made using the init_glishtk function.

The widgetserver has two modes:

Mode 'glish':
widgets constructed by the widgetserver will have construction argument defaults that are identical to the "unwrapped" Glish/Tk constructors. For example, the code:
include 'widgetserver.g';
dws.setmode('glish');
f1 := frame();
b1 := button(f1, 'Dismiss');
f2 := dws.frame();
b2 := dws.button(f2, 'Dismiss');
produces two identical frames with identical "Dismiss" buttons in them.
Mode 'app':
widgets constructed by the widgetserver will have construction argument defaults set such that the relief, font, background and foreground correspond to the AIPS++ GUI Guidelines for that particular widget. The AIPS++ GUI Guidelines specify, for example, that all "Dismiss" buttons should have orange backgrounds. Thus, the code:
include 'widgetserver.g';
dws.setmode('app');
f1 := frame();
b1 := button(f1, 'Dismiss');
f2 := dws.frame();
b2 := dws.button(f2, 'Dismiss');
produces two identical frames, but with different "Dismiss" buttons: the second one will have an orange background.

The user is, however, able to control the relief, font, background and foreground defaults for the 'app' mode using their .aipsrc file. In the example above, they could make all "Dismiss" buttons created using a widgetserver in 'app' mode have a yellow (rather than orange) background by adding the following line to their .aipsrc file:

gui.prefs.dismissbutton.background: yellow

Any context-sensitive default implemented by a widgetserver is always over-written (ie. ignored) if the programmer explicitly specifies that construction argument. For example, the following code:

include 'widgetserver.g';
dws.setmode('glish');
f1 := dws.frame();
b1 := dws.button(f1, 'Dismiss', background='green');
dws.setmode('app');
f2 := dws.frame();
b2 := dws.button(f2, 'Dismiss', background='green');
produces two identical frames, with identical green "Dismiss" buttons. In both cases, regardless of the mode of dws, the explicit background argument over-writes the defaults.

Control of the various defaults for 'app' mode Glish/Tk widgets and AIPS++ megawidgets is provided in the .aipsrc file. All resources related to GUI relief, font, background and foreground defaults are stored in gui.prefs.

Start-up mode:
The default start-up mode for newly constructed widgetservers can be set in the user's .aipsrc file as follows:
gui.prefs.mode: glish
or
gui.prefs.mode: app

Fonts:
Four different fonts can be specified for use by the widgetserver: small, medium, large and bold. They can be specified using the following syntax in the .aipsrc file:
gui.prefs.fonts.small: -*-helvetica-medium-r-normal-*-11-*
gui.prefs.fonts.medium: -*-helvetica-medium-r-normal-*-13-*
gui.prefs.fonts.large: -*-helvetica-medium-r-normal-*-18-*
gui.prefs.fonts.bold: -*-helvetica-bold-r-normal-*-13-*
The strings given must be valid X fonts. You might find it useful to use the X program xfontsel to create X font strings. Glish/Tk does not deal particularly well with the case of ill-formed X font strings, or of missing fonts, so modify with these settings with caution. When using a widgetserver, fonts for particular widgets (eg. buttons, listboxes, etc.) can be specified using ordinary X font strings (examples above) or more simply the strings 'small', 'medium', 'large' or 'bold'. The widgetserver will detect what you have given, and map it accordingly.

Frames:
The first place to start modifying your .aipsrc is probably the frame section. Any background, foreground and font settings applied to Glish/Tk frames are automatically forwarded on to all Glish/Tk widgets and AIPS++ megawidgets, where they can of course be over-written by specific default settings. The defaults for frames in the 'app' mode can be set as follows:
gui.prefs.frame.background: #c0d0e0
gui.prefs.frame.foreground: white
gui.prefs.frame.font: medium
gui.prefs.frame.relief: flat
Note that colors can be given as a string or as a hexadecimal RGB triple, preceded by a '#' character. The user is free to put any of the above lines in their .aipsrc file and view the difference in GUIs built using the default widgetserver. The user need not give all the settings; just those they wish to modify.

To indicate the behaviour of "cascading defaults," the following code:

dws.setmode('app');
f := dws.frame();
b := dws.button(f, 'Orangutan');
when the above four gui.prefs.frame.* lines are installed in the user's .aipsrc file, would produce a pale blue button with white text. Since the user has not specified default font, foreground and background parameters for buttons, either in their .aipsrc file or explicitly in the Glish code, they will get the appropriate defaults from their .aipsrc settings for frames.

Note that the relief default for frames is not cascaded to lower level widgets, since relief is the primary--and often the only--visual distinction between the various Glish/Tk widgets.

Buttons:
Three different types of buttons are known to the widgetserver: check, radio and plain buttons. The user can set .aipsrc defaults for each type, eg.:
gui.prefs.plainbutton.background: #f0f0d0
gui.prefs.checkbutton.background: #f0f0d0
gui.prefs.checkbutton.relief: ridge 
gui.prefs.radiobutton.background: #f0f0d0
gui.prefs.radiobutton.relief: ridge
Those preferences that are not specified default first to the .aipsrc settings for frames (for font, foreground and background) if given, otherwise to the AIPS++ GUI Guidelines specifications.

Special buttons:
In addition to the four standard button types (plain, check, radio and menu), the widgetserver knows three additional types: action, halt and dismiss. When asked to create a button of type halt, for example, the widgetserver will make the button with foreground, background and font according to preferences set in the user's .aipsrc file. These preferences can be set, for example, as follows:
gui.prefs.dismissbutton.background: yellow
gui.prefs.actionbutton.font: bold
gui.prefs.haltbutton.relief: groove
The defaults, which apply when the user doesn't overwrite them in their .aipsrc file, are for action buttons to be bold text on green background, halt buttons to be bold white text on a red background and dismiss buttons to be bold text on an orange background.

Other Glish/Tk widgets:
Most remaining Glish/Tk widgets (scale, text, scrollbar, label, entry, message, listbox and canvas) can have preferences specified in the .aipsrc file in just the same way as frames and buttons. Note that for the canvas widget, only background and relief are meaningful, and for the scrollbar widget, only background and foreground preferences are useful. A summary of the syntax for the Glish/Tk widget preference settings in the .aipsrc file is:
gui.prefs.widget.resource: value
where widget is one of frame, plainbutton, radiobutton, checkbutton, gobutton, abortbutton, dismissbutton, scale, text, scrollbar, label, entry, message, listbox, canvas; resource is one of font, relief, foreground, background; and value is: one of small, medium, large, bold or an X font string for the font resource; one of flat, raised, groove, ridge, sunken for the relief resource; and a valid X color for the foreground and background resources.

The Pgplot widget:
The pgplot widget is supplied and supported by the widgetserver, but at present default preferences are not supported.

AIPS++ megawidgets:
Most AIPS++ megawidgets (rollup, optionmenu, ...), like the Glish/Tk widgets, are supported by the widgetserver, and have context-sensitive defaults. The user can specify them in an identical fashion to the previously listed "Other Glish/Tk widgets" (see above), where widget can also be one of rollup, optionmenu, .... The remaining AIPS++ megawidgets (dialogbox, ...) are supported by the widgetserver, but do not have context-sensitive defaults: they derive their defaults from the widgetserver-provided base Glish/Tk widgets.




next up previous contents index
Next: widgetserver - Constructor Up: widgets - Module Previous: twodactionoptionmenu.newselection - Function   Contents   Index
Please send questions or comments about AIPS++ to aips2-request@nrao.edu.
Copyright © 1995-2000 Associated Universities Inc., Washington, D.C.

Return to AIPS++ Home Page
2006-10-15