ximage
[ XITE Reference Manual | XITE home ]
Contents
Name
ximage, ximage_init, ximageInit, ximage_layout, ximageLayout,
ximage_histogram, ximage_slice, ximage_info, ximage_colorbar,
ximage_mainloop,
ximage_exit, ximage_display, ximage_usage_text,
ximage_app_usage_text, set_init_color, set_init_ovl_color,
LogPosition, LogPositionCallback, Make_label_layout,
Make_command_layout, Make_prompt_layout, Make_scroll_layout,
Make_menu_layout, Make_entry_layout, Add_entry_layout,
Make_list_layout, Make_image_layout, add_callback_to_image,
init_image_callbacks, add_to_image_callbacks,
add_callback_to_image_layout, add_callback_first,
add_callback_last - toolkit for creating X11 applications
in XITE
#include <xite/ximage.h>
Widget ximage_init( int* argc, char** argv,
char* classname,
String fallback_resources[], int warn );
Widget ximageInit( int* argc, char** argv,
char* classname, XtResource* resources,
int num_resources, XtPointer resources_result,
XrmOptionDescRec* optionsTable,
int num_options,
String fallback_resources[], int warn );
Widget ximage_layout( Widget app_parent,
IBAND band, char** wids, Widget rwids[],
int nwids, XtCallbackProc ximage_work_fun,
char* res_inst_name );
Widget ximageLayout( Widget app_parent,
layout *layouts, int nwids );
char *ximage_app_usage_text( char *app_usage );
char *ximage_usage_text( void );
int ximage_histogram( Widget wid,
image_disp_cb_data *cb_data );
int ximage_slice( Widget wid );
int ximage_info( Widget wid );
int ximage_colorbar( Widget wid,
image_disp_cb_data *cb_data );
void ximage_mainloop( void );
void ximage_exit( Widget wid, XtPointer str,
XtPointer dummy );
Widget ximage_display( Widget parent,
char* resource_name, char *shell_resource_name,
IMAGE img, int bandno, WidgetClass widgetClass,
Visual* visual, int depth,
menu_button buttons, ArgList args,
Cardinal num_args, image_callbacks *callbacks );
void set_init_color( int color );
void set_init_ovl_color( int color );
void LogPosition( Widget image_wid, Widget label_wid );
void LogPositionCallback( Widget wid,
XtPointer client_data, XtPointer call_data );
layout_label Make_label_layout( layout_label lay_out,
char *type, char *resource_name,
char *shell_resource_name, Widget wid, int id );
layout_command Make_command_layout(
layout_command lay_out, char *type,
char *resource_name, char *shell_resource_name,
Widget wid, int id, XtCallbackProc callback,
XtPointer closure );
layout_prompt Make_prompt_layout( layout_prompt lay_out,
char *type, char *resource_name,
char *shell_resource_name, Widget wid, int id,
XtCallbackProc callback, XtPointer closure,
char *text );
layout_scroll Make_scroll_layout(
layout_scroll lay_out, char *type,
char *resource_name, char *shell_resource_name,
Widget wid, int id, XtCallbackProc jump_callback,
XtPointer jump_closure,
XtCallbackProc scroll_callback,
XtPointer scroll_closure );
layout_menu Make_menu_layout( layout_menu lay_out,
char *type, char *resource_name,
char *shell_resource_name, Widget wid, int id,
int num_entries, layout_menu_entry *menu_entries );
layout_menu_entry Make_entry_layout(
layout_menu_entry lay_out, char *resource_name,
char *label, Widget wid, XtCallbackProc callback,
XtPointer closure );
layout_menu_entry *Add_entry_layout(
layout_menu lay_out, char *resource_name,
char *label, Widget wid, XtCallbackProc callback,
XtPointer closure );
layout_list Make_list_layout( layout_list lay_out,
char *type, char *resource_name,
char *shell_resource_name, Widget wid, int id,
int num_entries, char **list_entries,
XtCallbackProc callback, XtPointer closure );
layout_image Make_image_layout( layout_image lay_out,
char *type, char *resource_name,
char *shell_resource_name, Widget wid, int id,
IMAGE img, image_callbacks *callbacks );
void add_callback_to_image_layout( layout_image lay_out,
String resource_name, XtCallbackProc callback,
XtPointer closure, Boolean first );
image_callbacks *init_image_callbacks( void );
image_callbacks *add_to_image_callbacks(
image_callbacks *image_cbs,
String resource_name_list,
XtCallbackProc callback, XtPointer closure,
Boolean first);
XtCallbackList add_callback_first(
XtCallbackList callback_list,
XtCallbackProc new_callback, XtPointer closure );
XtCallbackList add_callback_last(
XtCallbackList callback_list,
XtCallbackProc new_callback, XtPointer closure );
ximage is a toolkit for design of X11-applications in XITE,
using the Image and ImageOverlay widgets as well as some
Athena and Free Widget Foundation (FWF) widgets. This gives
the programs a common look and feel.
Prior to XITE version 3.3 the two main ximage functions were
ximage_init and ximage_layout. In version 3.3 each of them
got a sibling, ximageInit and ximageLayout respectively.
The former two provide the simplest and easiest programming
interface. The latter two provide greater flexibility and more
control at the cost of a somewhat more complex programming
interface.
The old functions are described before the new ones below.
See the section Compatibility below for information on
how you can increase the functionality of your existing
ximage toolkit based applications just by recompiling and
relinking them.
This section describes what changes must be made to function
calls ximage_init and ximage_layout for old ximage
based applications.
-
ximage_init
- If your application is based on XITE prior to version 3_01,
add a warn argument with value zero to the function call.
Refer to the description of ximage_init below for more
information.
-
ximage_layout
- If your application is based on XITE prior to version 3.0, add
the callback function ximage_work_fun (or whatever you
called the function which responds to events in your
application) to the list of arguments in the call to
ximage_layout.
If your application is based on XITE prior to version 3.2,
also add a NULL res_inst_name argument at the end of the
argument list in the call to ximage_layout. If you have
multiple calls to ximage_layout in your application, then
use a non-NULL res_inst_name argument in every call where
you have NULL for the parent argument, and replace the NULL
parent argument by the return value from ximage_init.
A non-NULL res_inst_name argument will lead to the creation
of a new window with shell resource instance name equal to
res_inst_name.
Refer to the description of ximage_layout below for more
information.
When you run your recompiled application it should look the
same as before. However, there may be some more menus or menu
entries available when you press one of the mouse buttons
along with the Shift key while the mouse pointer is inside the
image. Some of these may be familiar from the xshow XITE
application. One of the useful entries available from the
Options menu is to log the mouse pointer position.
Try the option -layout (see below) with your recompiled
application. This should give you a separate window for each
image. The images can now be resized with the mouse, just like
what has been possible in xshow.
You may also want to try the options -panelcontainer and
-adjustwidth along with -layout to get the desired result.
The -widgetset option can be used to choose between Athena
(Xaw) and Free Widget Foundation (Xfwf) widgets if they are
created with ximage_layout or ximageLayout.
If you get dangling windows containing only a label or single
buttons and you want to collect them into a larger control
panel window, refer to the description of ximage_layout
below for more information.
ximage_init initializes the ximage toolkit (the X11 toolkit
is also initialized) and assigns classname as the name of
the application class. The X11 resource file ("app-defaults"
file) has the same name as the application class.
-
fallback_resources
- ximage_init can handle fallback-resources. All XITE
applications should however use NULL as the value for the
fallback_resources argument. They generally don't expect to
find "app-default" files in a standard directory, such as in
/usr/lib/X11/app-defaults, and we don't want the fallback
resources to be used in this event. Resources will be
specified in files which are stored locally under the XITE
home-directory, and the XITE applications are able to find
these files. The fallback_resources argument is provided for
those who write their own applications which are not included
in the XITE distribution.
-
Resource and software version correspondence
- Set warn equal to zero unless the application is included in
the XITE distribution. If warn is non-zero, ximage_init
checks that the X resource xiteResourceVersion (class
XiteResourceVersion) is set equal to the XITE version. If not
equal, a warning is printed. The xiteResourceVersion resource
is set in all the supplied XITE application resource files.
This is to ensure correspondence between software version
and resource file version.
-
Window deletion
- ximage_init prepares for acceptance of window deletion by
the window manager. See comment below under ximage_layout.
-
Visuals
- ximage_init takes care of initializing the necessary
information concerning the preferred/requested visual type,
any other available visual types which the display and XITE
can support and corresponding XITE-initial colormaps. See also
the description of the "-iv" option and the "imageVisualClass"
application resource. For more information, refer to
Visual(3).
"reduced-color" mode is chosen as default for display of
images. This can be overridden with the Image and ImageOverlay
widget resources XtNdisplayMethod which can be set with the
option -full. See the Options section below.
-
Some options
- ximage_init can initialize popup (and menubar pulldown) menus
for the Image and ImageOverlay widgets, depending on some
application resources and options. The default behaviour is to
initialize the Colors, OverlayColors, Tools, Options and
Visuals menu (but the Visuals menu will not be able to
do any work unless the -multivisual option is used). The
OverlayColors menu will only be available, however, from
ImageOverlay widgets. Refer to the Options and Resources
sections below for more information on how to control the
presence of these menus.
-
Action functions
- ximage_init registers three action functions with the
application: "PopupMenu", "PopupExit" and "CloseShell". Refer
to the Actions section below for a description of these
functions.
A few other action functions are also registered, but they are
static (not globally available), and you don't really need to
know about them. Their tasks are to prepare the popup menus
every time they are popped up.
ximageInit is a new version of ximage_init (since XITE
version 3.3) with more flexibility. ximageInit is actually
called by ximage_init.
-
resources and options
- Application resources can be supplied in resources, and
application command-line options can be supplied in
optionsTable. If NULL is supplied for these arguments, then
the ximage toolkit will supply the application with a
default set of application resources and command-line options
respectively. Refer to the sections Options and Resources
below.
If you pass along your own set of resources,
resources_result must supply a reference to a structure for
storage of the resulting resource values. You will need to
unpack and interpret this information yourself.
ximage_usage_text returns the standard usage text for the
ximage toolkit.
ximage_app_usage_text returns the concatenation of
app_usage, the standard usage text for the ximage toolkit
(refer to ximage_usage_text) and the standard usage text for
XITE (refer to xite_standard_options_usage_text(3)).
Use this function in a call to InitMessage(3) early in the
main function of an application which is based on ximage.
ximage_layout creates nwids widgets and returns a pointer
to each through the rwids array. For a more flexible
method, also refer to the description of ximageLayout below.
-
app_parent
- This argument must not be NULL. It is typically the return
value from ximageInit.
-
ximage_work_fun
- This is the callback function which handles how
the widgets will react to events. It is added to callback
lists for some of the widget types specified below. Refer to
their individual description for details. The function must be
supplied by the application which uses the ximage toolkit.
Its prototype must be
void ximage_work_fun(Widget wid,
XtPointer client_data,
XtPointer call_data);
Unless otherwise stated, the client_data argument to the
callback function will be a pointer to an integer which
contains the widget number (the index into the wids array
for each particular widget, between 0 and nwids-1
inclusive). The callback function can test this number to
determine which widget the event occured in.
See the section See also below for references to
program examples on how to handle this.
The call_data argument of the callback function is a
reference to a chunk with various information from the widget
referenced by wid and client_data. This information is
collected in a struct of type ImageCallbackRec, defined by
the Image widget. The definition is as follows
typedef struct
{
int reason;
XEvent *event;
struct imagestruct *img;
struct bandstruct *band;
int x, y;
ImageData data;
pixel *pixtype;
float zoom, magnification;
int xpan, ypan;
} ImageCallbackRec, *ImageCallback;
reason is one of two predefined integral constants:
ACTIVATE or RESIZE.
x and y are the image coordinates where the event took
place, if the event was one of ButtonPress, ButtonRelease,
MotionNotify or Expose. In case of a different event type,
x and y refer to present cursor position.
data is a reference to the image pixel at position
(x,y).
-
wids
- wids is an array of pointers to strings. Each string is a
specification for a widget. Each widget specification is
divided into one or more fields, separated by ":". The first
field always determines the widget class, the second field
determines the widget instance resource name (for use in X11
resource specifications). The simplest widget specification
is
<widget_class>:<r_nam>
The widgets will be created in the order they are specified
in the wids array.
If a third field is present in a widget specification, it
determines whether a widget should be displayed inside the
same window as the previous widget or be the first one in a
new window. A new window will by default be launched if the
third field is non-empty, like this
<widget_class>:<r_nam>:<sh_r_nam>
sh_r_nam will be the resource instance name of the new
shell widget. Whether or not a new window will be created can
also be controlled via the option -layout and the application
resource layout.
The widget_class field can be chosen among
-
Ascii_page
- Class Text. From the Athena widget set. The widget size will
be set to hold 80 by 24 characters.
-
Ascii
- Class Text. From the Athena widget set. Like "Ascii_page", but
without the fixed size. "Ascii" should be used for
small Text widgets, such as for small input fields. See the
"Prompt" entry below for a better alternative.
-
Command
- Class Command (from the Athena widget set) or XfwfButton (from
the Xfwf widget set). The widget label will be set equal to
r_nam.
ximage_work_fun will be installed as the XtNcallback (or
XtNactivate for XfwfButton) callback function, with the widget
number (the index into the wids array for this widget)
supplied through the client_data argument.
Choose between Athena and Xfwf widgets with the option
-widgetset or corresponding application resource.
-
Image
- Class Image. Defined in XITE. In the absence of
sh_r_nam a new window will as usual not be created for
an Image widget, i.e. the Image widget will become a child of
a Box child of app_parent. In this case the Image may be
inside the same window as buttons and other widgets. It can
not be resized with the mouse, and no menubar will be available
above the image. With sh_r_nam present in the widget
specification, a separate window will be made for the image.
This is the recommended usage.
As usual a separate window can be created for the image in
the absence of the sh_r_nam specification if the option
-layout (or the application resource layout) is used.
In this case, the shell resource name will by default be
set equal to "imageShell".
The resource instance name for an Image widget is set to
"image", regardless of the r_nam string.
band must supply the image data. By default, the display of
the image will be in "reduced-color" mode. This can be
overridden with the option -full.
ximage_work_fun is installed as the XtNcallback callback
function for the widget with the widget number (the index into
the wids array for this widget) supplied through the
client_data argument. LogPositionCallback is also added
to the XtNcallback callback list, in front of
ximage_work_fun. See the description of LogPositionCallback
below.
Additional callback functions may be installed after the call
to ximage_layout by calling XtAddCallback or one of the
functions add_to_image_callbacks, add_callback_first or
add_callback_last. They are described below.
An Image widget is actually created by the function
ximage_display, which is described below.
-
Label
- Class Label. From the Athena widget set. The widget label
will equal r_nam.
-
List
- Class List. From the Athena widget set. The widget
specification should be on the following form
List:r_nam:sh_r_nam:lab1:lab2
where r_nam is the resource instance name of the widget
as usual and sh_r_nam is only required if the list
widget is the first one in a new window. lab1 will be the
label of the first list element, lab2 the label of the
second element etc.
If a label must contain the character ":", escape it with
a backslash, like this
List:r_nam:sh_r_nam:lab1:lab\\:2
If a label must contain a backslash, use the following
kind of specification
List:r_nam:sh_r_nam:lab1:l\\ab2
ximage_work_fun will be installed as the XtNcallback
callback function for the widget with the widget number (the
index into the wids array for this widget) supplied through
the client_data argument.
-
Menu
- Class menuButtonWidget. From the Athena widget set. The
corresponding string in wids should be on the following
form
Menu:r_nam:sh_r_nam:nm1:lb1:int1:nm2:lb2:int2
where r_nam is the resource instance name of the widget
as usual, sh_r_nam is only required if the menubutton
widget is the first one in a new window, nm1 is the
resource instance name of the first menuentry button, lb1
is the visible text in the first menuentry button, and int1
is the client_data returned to the menuentry button callback
function when this entry is selected (actually a pointer to
the integer, cast to XtPointer, is returned). int1, int2,
..., must be integers.
If a label must contain the character ":", escape it with
a backslash, like this
Menu:r_nam:sh_r_nam:nm1:l\\:b1:int1
If a label must contain a backslash, use the following
kind of specification
Menu:r_nam:sh_r_nam:nm1:l\\b1:int1
ximage_work_fun will be installed as the XtNcallback
callback function for the menuentry buttons. It is important
that int1, int2 etc. are not in the range zero to
nwids-1, because ximage_work_fun will typically test its
client_data arument to determine from which widget it was
called. Integers in the range zero to nwids-1 are probably
already used as client_data by some of the widgets specified
in wids.
-
Overlay
- Class ImageOverlay. Defined in XITE. See the description of
"Image" above.
-
Prompt
- Class XfwfPrompt. From the Free Widget Foundation. It is
suitable to use as an input field. It is recommended to use
this widget only for the input field itself. Any leading text
(telling the user what kind of input is expected) should be
supplied in a Label widget to the left of the Prompt widget.
The widget specification should be on the following form
Prompt:r_nam:sh_r_nam:text
where r_nam and sh_r_nam have the usual meaning
and text will be shown initially in the Prompt widget.
ximage_work_fun will be installed as the XtNactivate
callback function for the widget with the widget number (the
index into the wids array for this widget) supplied through
the client_data argument.
-
Scroll
- Class Scrollbar. From the Athena widget set.
ximage_work_fun will be installed as the XtNjumpProc
callback function for the widget with the widget number (the
index into the wids array for this widget) supplied through
the client_data argument. No callback function is supplied
for the XtNscrollProc callback list.
-
Toggle
- Class Toggle (from the Athena widget set) or XfwfToggle (form
the Xfwf widget set). The widget label will equal r_nam.
ximage_work_fun will be installed as the XtNcallback (or
XtNonCallback and XtNoffcallback for XfwfToggle) callback
function for the widget with the widget number (the index into
the wids array for this widget) supplied through the
client_data argument.
Choose between Athena and Xfwf widgets with the option
-widgetset or corresponding application resource.
Examples of widget specifications
-
A single window
String rwids[] = {
"Label:label1",
"Command:command1",
"Image:image",
"Label:label2",
"Command:command2",
};
-
Several windows
- One window for the first two widgets, one for the image and
one for the remaining two widgets:
String rwids[] = {
"Label:label1",
"Command:command1",
"Image:image:imageShell",
"Label:label2:Control panel",
"Command:command2",
};
If several widgets are to appear inside the same window, they
will be children of a container widget which itself is the
child of a shell widget. The default widget class for the
container widget is Box (Athena widget). Alternatively, the
class may be forced to be Form (Athena widget), if no image
widgets are to appear in the container, by using the option
-panelcontainer (or the application resource
panelContainer).
In the event that the container widget class is Form, the
labels, command buttons, toggle buttons etc. inside the
container, need resources specified for their relative
placement (resources fromVert and fromHoriz). With a container
widget of class Box they will be placed after each other
according to their order in the wids array.
-
res_inst_name
- If res_inst_name is not NULL, a new popup shell will be the
parent of the given widgets. This popup shell will appear as a
new window. (If the number of specified widgets are zero, the
window will not be visible on the screen).
ximage_layout sets the windowmanager protocol for window
deletion. Refer to the Actions section below for information
on how to close a window upon requeste from the window
manager.
ximageLayout is a new version of ximage_layout (since XITE
version 3.3) with more flexibility.
The differences between ximage_layout and ximageLayout are:
-
Separate image windows
- Image widgets will by default be created in separate windows.
This can be overridden with the option -layout (and
application resource layout).
-
Container widget class
- By default the container widget is of class Form (Athena
widget). Alternatively, the class may be forced to be class Box
(Athena widget) by using the option -panelcontainer (or the
application resource panelContainer).
-
Multiple images
- Several images can be supplied for each call to ximageLayout.
-
Multiple callback functions
- There is no need to use one common callback function
ximage_work_fun for all the widgets. Separate functions
can be installed for each widget.
-
Widget specifications
- The widget specifications are different. This is explained
below.
The widget specifications are supplied in the layouts
argument. The number of widget specifications are given by
nwids.
-
layouts
- layouts is an array of pointers to layout references.
Each layout reference in the array refers to one of a set
of predefined structures. There is a structure type for each
of the widget types described for the ximage_layout function
above. The details of the structures are given in the
file $XITE_HOME/include/layout.h. A number of functions have
been defined to handle the widget-type specific structures and
hide the internal definition from the programmer. These
functions will be described in the following.
-
Make_label_layout
- This function returns a reference of type layout_label to
a structure of type layout_label_rec. This can be used for
widgets of type "Label", "Ascii_page" and "Ascii", as defined
above in the description of function ximage_layout.
The function prototype for Make_label_layout is shown in the
Syntax section above.
If the function argument lay_out is NULL, a new object which
can contain "Label" layout data is created. Otherwise, the one
referenced by lay_out is used. type, resource_name and
shell_resource_name should be used in the same way as the
fields widget_class, r_nam and sh_r_nam described for
the ximage_layout function above. wid is not used. id
supplies an identification for the widget. It is not used for
a "Label" widget.
-
Make_command_layout
- The differences from Make_label_layout are that callback
will be installed as a callback function, and closure will
be the client_data argument for the callback function.
If closure is NULL, id (actually a reference to an integer
variable containing the id value) will be passed along as the
client_data argument.
-
Make_prompt_layout
- The difference from Make_command_layout is that text
is shown initially in the widget.
-
Make_scroll_layout
- The differences from Make_command_layout are that two
callback functions may be specified, one for the XtNjumpProc
callback list, and one for the XtNscrollProc callback list.
id will be used instead of a NULL closure argument.
-
Make_image_layout
- The differences from Make_label_layout are that img is
a reference to a BIFF image and that callbacks refers to
a structure containing callback function data for an Image
or ImageOverlay widget.
To construct the callbacks argument, use the functions
add_to_image_callbacks and/or init_image_callbacks.
Prototypes for these functions are shown in the Syntax
section above.
init_image_callbacks simply initializes an object of type
image_callbacks and returns a reference to this object.
add_to_image_callbacks adds the function callback with
client_data given by closure to the callback list given by
resource_name. With first nonzero, callback is added at
the front of the callback list, otherwise it is added at the
end of the list.
Three other convenience functions are also available for
handling callback lists: add_callback_to_image_layout,
add_callback_first and add_callback_last. The latter two
are independent of the layout definitions, they operate
completely within the X Toolkit terminology.
-
Make_menu_layout
- The difference from Make_label_layout are that num_entries
gives the number of menu entries and that menu_entries is
a reference to an array of pointers (of type
layout_menu_entry) to menu entry objects (of type
layout_menu_entry_rec).
To construct the menu_entries argument, use the functions
Make_entry_layout and/or Add_entry_layout. The function
prototypes are shown in the Syntax section above.
The resource_name argument to Make_entry_layout gives the
X11 resource instance name of the menu entry widget. If
lay_out is NULL, an object of type layout_menu_entry_rec
will be constructed. The other arguments should be
self-explanatory.
Add_entry_layout adds a menu entry to the menu referenced
by lay_out (which must be non-NULL). The new entry is
added after any previous entries.
-
Make_list_layout
- The differences from Make_command_layout are that
num_entries gives the number of entries in the list and that
list_entries is an array of strings, one for each list
entry. callback is the same for all the list entries.
For all the funtions above, the wid argument will refer to
the actual widget upon return from ximageLayout.
If you need access to the various members of the layout
structures, use the following definitions
-
TypeOfLayout(layout)
- Return type is "char *".
-
ResourceNameOfLayout(layout)
- Return type is "char *".
-
ShellResourceNameOfLayout(layout)
- Return type is "char *".
-
WidgetOfLayout(layout)
- Return type is "Widget".
-
IdOfLayout(layout)
- Return type is "int".
-
CallbackOfCommandLayout(layout)
- Return type is "XtCallbackList".
-
CallbackOfPromptLayout(layout)
- Return type is "XtCallbackList".
-
TextOfPromptLayout(layout)
- Return type is "char *".
-
ResourceNameOfMenuEntry(layout_menu_entry)
- Return type is "char *".
-
LabelOfMenuEntry(layout_menu_entry)
- Return type is "char *".
-
WidgetOfMenuEntry(layout_menu_entry)
- Return type is "Widget".
-
CallbackOfMenuEntry(layout_menu_entry)
- Return type is "XtCallbackList".
-
NumEntriesOfMenuLayout(layout)
- Return type is "int".
-
EntriesOfMenuLayout(layout)
- Return type is "layout_menu_entry *".
-
JumpCallbackOfScrollLayout(layout)
- Return type is "XtCallbackList".
-
ScrollCallbackOfScrollLayout(layout)
- Return type is "XtCallbackList".
-
NumEntriesOfListLayout(layout)
- Return type is "int".
-
EntriesOfListLayout(layout)
- Return type is "char **".
-
CallbackOfListLayout(layout)
- Return type is "XtCallbackList".
-
ImgOfImageLayout(layout)
- Return type is "IMAGE".
-
CallbacksOfImageLayout(layout)
- Return type is "image_callbacks *".
-
DestroyCallbackOfImageLayout(layout)
- Return type is "XtCallbackList".
-
CallbackCallbackOfImageLayout(layout)
- Return type is "XtCallbackList".
-
ResizeCallbackOfImageLayout(layout)
- Return type is "XtCallbackList".
-
DrawCallbackOfImageLayout(layout)
- Return type is "XtCallbackList".
-
RoiCallbackOfImageLayout(layout)
- Return type is "XtCallbackList".
ximage_mainloop starts the X11 event loop.
ximage_exit exits the application. The three arguments are
not used by the function. It used to be added to the
XtNdestroyCallback callback list for every Image or
ImageOverlay widget created with ximage_layout, but this
is not the case any more.
ximage_info prints image widget information, specifically
the image name (title), size, start coordinates, pixel type,
panning and zoom, minimum and maximum, visual class, depth
and text (history) field.
The minimum and maximum may not correspond to actual extrema
values in the image. For pixeltype unsigned byte
(ImageBytePixel), the minimum is assumed to be 0, the maximum
to be 256, regardless of the actual values. The colormap
values are distributed over the pixel value range given by the
minimum and the maximum. An image with pixeltype unsigned byte
may thus not look identical to the same image with pixeltype
real.
ximage_histogram makes a histogram window. A copy of the
current image colormap is added to the Colors colortable menu
and made the current image colormap (in "reduced-color" mode).
This colormap can be manipulated from the histogram window.
cb_data is a reference to an object of type
image_disp_cb_data
typedef struct {
int index;
ximage_display_func display_func;
image_callbacks *callbacks;
} image_disp_cb_data
display_func is the function used to send histogram
transformed images back from the histogram window. This should
typically be the function ximage_display which is described
below. The type definition of ximage_display_func is
typedef Widget (*ximage_display_func)( Widget parent,
char *resource_name, char *shell_resource_name,
IMAGE img, int bandno, WidgetClass widgetClass,
Visual *visual, int depth, menu_button buttons,
ArgList args, Cardinal num_args,
image_callbacks *callbacks );
callbacks is a collection of callback lists for the
Image and ImageOverlay widget displayed with display_func.
callbacks should be constructed with the functions
init_image_callbacks and/or add_to_image_callbacks
described above.
index is not used.
ximage_histogram calls the xhistogram function. Refer to
xhistogram(3) for more information.
ximage_slice makes a color palette window. A copy of the
current image colormap is added to the Colors colortable
menu and made the current image colormap (in "reduced-color"
mode). This colormap can be manipulated from the palette
(slice) window by specifying rgb or ihs color values.
ximage_slice calls the xslice function. Refer to
xslice(3) for more information.
ximage_colorbar makes a colorbar window for the colortable
currently active in an image window.
ximage_display creates an Image or ImageOverlay widget
(depending on widgetClass) with image contents given by
the first (or three first) band(s) in img. A new window
may be created for the widget. See the description of the
parent argument.
parent must be non-NULL. If it refers to a shell widget,
a new window will be created for the image.
resource_name gives the widget resource instance name
(default "image" if the argument is NULL). We recommend the
default value, to make it easier to write X resource files.
shell_resource_name gives the resource instance name of the
ancestor shell (default "imageShell" if the argument is NULL).
shell_resource_name is only used if a new window is created
for the image.
args may be a list of num_args widget resource settings.
buttons determines which menus should be available from the
image widget. The menus can be reached from a menubar above
the image (unless the menubar has been made invisible, e.g.
with the use of option -mb) and as popup menus inside the
image widget. buttons is a bitwise OR between COLORS_BUTTON,
OVERLAYS_BUTTON, TOOLS_BUTTON, OPTIONS_BUTTON and
VISUALS_BUTTON. The value of buttons can be controlled via
some options, such as -colorsmenu. The necessary
translations for popup menus are added automatically. Refer to
the Options and Actions sections below. A request for an
Overlay menu is only honored if widgetClass refers to
imageOverlayWidgetClass.
img specifies the image data to be displayed. bandno
specifies the band number from img which will be displayed
in the Image widget.
If img has exactly three bands, bandno is equal to one and
the -rgb options is used (or the rgbImages resource is
set), then img is displayed as an rgb color image where band
1 represents red, band 2 represents green and band 3
represents the blue component. For this to work as expected,
the visual class must be selected appropriately. See the
descriptions of options -rgb and -iv below.
bandno equal to zero will give the default value of one.
An image will be displayed with a default monotonously rising
colormap. When only one band of an image is used in the
display, the default colormap is a gray-scale colormap (in
"reduced-color" mode). For a three-band image the default
colormap is the same for all the three bands, and the image
will appear with its expected colors (subject to the
conditions of an appropriate visual class as described above).
The choice of colormap can be changed with the function
set_init_color, the option -colortable or the application
resource colorTable described below. The initial colortable
for an image overlay is by default a predefined 32-element
table. It can be overridden with the function
set_init_ovl_color, the option -overlaytable or the
application resource overlayTable described below.
If the display hardware does not have a changeable colormap,
the default colormap for the display will be used to display
the image.
callbacks is a collection of callback lists for the Image
or ImageOverlay widget. It should be constructed with the
functions add_to_image_callbacks and/or
init_image_callbacks described above.
Default value for visual is the requested/preferred visual
type, and default for depth is the depth of visual.
To get the default values, use NULL and 0 respectively.
The option -iv can be used to change the requested/preferred
visual type.
args are overridden by img (and its bands), visual and
depth.
ximage_display is used for the Image and ImageOverlay
widgets created by ximage_layout and ximageLayout.
The return value from ximage_display is a reference to the
created image widget (not its ancestor). This widget is
realized, but not popped up. It needs a call to XtPopup to
become visible.
set_init_color sets the colortable which will be used
when new images are created. By default this is a predefined
gray-scale colortable (in "reduced-color" mode). It can
also be overridden with option -colortable (or the
application resource colorTable).
color is an index into the list of colortables available
via the Colors menu in the image widget.
set_init_ovl_color sets the colortable for new image
overlays. Default is the built-in standard 32-element table.
It can also be overridden with option -overlaytable (or the
application resource overlayTable).
color is an index into the list of colortables available
via the OverlayColors menu in the image widget.
This function is added at the front of the XtNcallback
callback list of all images created with ximage_layout or
ximageLayout. LogPositionCallback may also be added to
the callback lists of images created without the use of
ximage_layout or ximageLayout.
LogPositionCallback will enable the coordinates of the
cursor position in an image window to be displayed. The
client_data input argument to the callback function must
refer to the label widget into which the cursor position will
be written.
If the label widget referred to by the client_data argument
of the callback function is the "label" part of an Xaw dialog
widget, then this dialog widget is assumed to be the child of
a popup shell which will be popped up/down when needed.
Otherwise, it is assumed that the label widget is permanently
visible, and no popping up or down is handled.
call_data must supply an ImageCallback reference which
contains cursor coordinates etc.
The functions on the XtNcallback list are called by the
"notify" Image widget action function. The action function
supplies the proper call_data argument.
Add LogPositionCallback to the XtNcallback callback list of
widget image_wid with client data label_wid.
ximage based programs accept all standard X Toolkit command
line options in addition to the following. They don't all
apply to all the widget types supplied to ximage_layout or
ximageLayout.
All the options have their X resource equivalents. This is
the reason why many of the options have two legal forms,
one to give a certain effect, the other to cancel the effect.
This is necessary in order to be able to override X resource
settings. See also the section Resources below.
Unique abbreviations for the options will be accepted.
-
-adjustwidth
- Try to automatically adjust the width of "Label", "Scroll"
and "Ascii_page" widgets to match the widest widget in
container-widgets of class Box. +adjustwidth has the reverse
effect.
-
-aspect
- Don't preserve image aspect ratio when resizing windows.
Normally an image window will have the same width/height ratio
as the image data. When a window is resized, it will be forced
to keep this ratio unchanged. If -aspect is specified, it is
possible to resize the window independently in the width and
height directions. This can also be switched on/off
individually for each image (in the Options menu).
-
-cl filename, -colorlist filename
- The file given by filename contains a list of colortable
filenames which will be used instead of the default list of
colortables. Leading "~" and environment variables in
filename will be expanded. If not found, try to find
filename in one of the directories listed in the environment
variable XSHOWPATH. The colortables will be available from the
Colors menu of the image windows. See also option
-colortable.
The default value for filename is "xshow_colortabs".
-
-colmenu, -colorsmenu
- Supply the Image and ImageOverlay widgets with a color menu.
Default: Supply menu. The form +colmenu has the reverse
effect.
-
-ct filename, -colortable filename
- The file filename contains a colortable. Leading "~" and
environment variables in filename will be expanded. If not
found, try to find filename in one of the directories listed
int the environment variable XSHOWPATH. The colortable will be
available from the Colors menu of the image windows.
Image command-line arguments will initially be displayed with
this colortable. Default is a monotonously rising colormap,
grayscale for single band image displays.
-
-full
- Do not use "Reduced color" display of images to reduce
"technicolor" problems. The default is that only 128 colors
will be used to display images with PseudoColor visuals and
only about 2 million colors will be used to display images
with DirectColor visuals. This can be toggled individually for
each image, from the Options menu. This option directly sets
the XtNdisplayMethod Image and ImageOverlay widget resource
to one.
-
-ih height, -imageheight height
- Height of Image and ImageOverlay widgets. -aspect can
be useful with -ih, along with toggling the fixed aspect
ratio entry of the Image Options menu.
-
-iv VisualClassName
- Use VisualClassName for all image windows (and certain parts
of the histogram and slice application windows). Default:
PseudoColor. If this is not available, try DirectColor. If
this also fails, try TrueColor.
Legal choices: PseudoColor, DirectColor and TrueColor. The
depth of the visual can not be chosen. For PseudoColor, a
depth of 8 is used, for DirectColor and TrueColor, a depth of
24 is used. See also the menu entry in the Visuals menu of
the image widget, the -visualsmenu, the -multivisual and
the -rgb options.
-
-iw width, -imagewidth width
- Width of Image and ImageOverlay widgets. -aspect can
be useful with -iw, along with toggling the fixed aspect
ratio entry of the Image Options menu.
-
-layout type
- Determines whether images get separate windows or are included
in container widgets along with buttons etc. Default for
ximage_layout is to obey the widget specifications in the
wids argument. Default for ximageLayout is to separate
images from other widgets. type can be one of "separate",
"together" or "check", where the latter means to obey the
wids argument.
-
-logpos
- Turn log position mode on. When the cursor is moved inside an
image and the Log position option is on, the cursor
position and pixel value are printed. Default: Off.
-
-mb, -menubar
- Start without menubar above image windows. The menubar will
be a widget of class XfwfMenuBar.
-
-multivisual
- Enable display of images for all available visual classes, via
the Image visuals menu. Implies -visualsmenu.
-
-optionsmenu
- Supply the Image and ImageOverlay widgets with an options
menu. Default: Supply menu. The form +optionsmenu has the
reverse effect.
-
-ovlmenu, -overlaysmenu
- Supply the ImageOverlay widgets with a color menu for image
overlays. Default: Supply menu. The form +ovlmenu has the
reverse effect.
-
-ovt filename, -overlaytable filename
- Similar to option -colortable, but filename now contains a
colortable for an image overlay. It will be available from the
image widget OverlayColors menu for widgets of class
ImageOverlay.
Image overlay command-line arguments will initially be
displayed with this colortable. Default is a built-in
32-element table.
-
-panelcontainer type
- Determines the widget class of container widgets which will
hold buttons etc. Default for ximage_layout is Box, for
ximageLayout it is Form. type can be "Box" or "Form"
(case is not considered).
-
-protect
- Set protect mode on. It will then not be possible to overdraw
nonzero pixels in the overlay plane.
-
-rgb
- Assume that all three-band images represent 24-bit color
images, where the first, second and third bands represent the
red, green and blue colors respectively. If a three-band image
is displayed on a 24 bitplane RGB Color screen and the -rgb
switch is specified, the program will combine the three bands
to a color image. If the image is displayed on a different
kind of screen, the three bands will be shown separately. For
this to work, you may need to consider option -iv or the
resource imageVisualClass. Default: No.
-
-share
- Let non-image windows use the same initial colormap as image
windows. This can reduce colormap flashing on displays with
a single hardware colormap. It is especially useful in this
case for applications which involve manipulation of a non-image
widget with real-time image changes, such as using the slider
in the XITE applications xadd and xfilter.
Non-image windows will use a copy of the "Work-map" image
colormap or the image colormap given by the ximage option
-ct. The non-image windows colormap will not change when the
image colormap is changed via the Colors image menu.
Every ximage based application will issue a recommendation
to use this option if it determines that the option may reduce
colormap flashing.
The drawback of using this option is that the colors of the
non-image windows may not be set equal to the colors requested
in the X resource file (or with X toolkit options -bg and -fg).
Warnings will be issued to this effect, from the X toolkit.
This option only works when the preferred image visual class
equals the default display visual class.
-
-toolsmenu
- Supply the Image and ImageOverlay widgets with a tools menu.
Default: Supply menu. The form +toolsmenu has the reverse
effect.
-
-version
- Print XITE version number and exit. Default: Don't.
-
-visualsmenu
- Supply the Image and ImageOverlay widgets with a visuals menu.
Default: Supply menu. The form +visualsmenu has the
reverse effect.
-
-widgetset name
- name can be Xaw or Xfwf. Choose between the Athena widgets
Command and Toggle and the Xfwf widgets XfwfButton and
XfwfToggle. This only affects widgets created with
ximage_layout or ximageLayout.
-
-zoomall
- Turn zoom all mode on. With this mode set, all images
will be zoomed/panned with the same parameters.
The two following options are obsolete since XITE version
3.3.
-
-iow width, -imageoverlaywidth width
- This used to set the width of ImageOverlay widgets only.
This is now handled by -iw as long as the widget resource
instance name of the ImageOverlay widget equals "image"
(the default).
-
-ioh height, -imageoverlayheight height
- This used to set the height of ImageOverlay widgets only.
This is now handled by -ih as long as the widget resource
instance name of the ImageOverlay widget equals "image"
(the default).
Refer to Image(3) and ImageOverlay(3) for descriptions
of available Image and ImageOverlay widget action functions.
Applications initialized with ximage_init or ximageInit
have a few additional action functions available. These are
-
PopupMenu
- Refer to PopupMenu(3). This is added to the default
translations described below.
-
PopupExit
- Refer to PopupExit(3). This is added to the default
translations described below.
-
CloseShell
- Destroy the shell widget ancestor of a widget. This is not
added to the default translations. To close a window when
requested by a window manager operation, add the following
translation to an application resource file
*TopLevelShell.baseTranslations: #override \n\
<ClientMessage>WM_PROTOCOLS: CloseShell()
Apart from the mouse button and key bindings defined by the
Image(3) and ImageOverlay(3) widgets, the following are
added by the initialization functions ximage_init and
ximageInit.
-
Menues
- Whether these bindings are in effect depend on the options
-colmenu, -ovlmenu, -toolsmenu, -optionsmenu and
-visualsmenu and the corresponding application resources.
Shift <Btn1Down>: ColorsHook()
PopupMenu(colorsmenu)
Shift <Btn2Down>: PopupMenu(toolsmenu)
Shift <Btn3DOwn>: OptionsHook()
PopupMenu(optionsmenu)
Shift Mod1 <Btn1Down>: OverlaysHook()
PopupMenu(overlaysmenu)
(Overlay colortables, only for
ImageOverlay widgets)
Shift Mod1 <Btn3Down>: VisualsHook()
PopupMenu(visualsmenu)
The Hook functions in the above translations take care of
adding marks to active menu entries and desensitizing
illegal/irrelevant entries.
ximage-based programs accept all standard X Toolkit
resources. Some other common resources are mentioned below.
See also the description of ximage_layout and ximageLayout
above.
Options take precedence over resources.
Application resources. (Application name and class is given
by the actual application which calls ximage_init or
ximageInit. The application name can also be changed
with the X Toolkit option -name.):
-
adjustWidth (Class AdjustWidth)
- See option -adjustwidth.
-
colorList (Class ColorList)
- See option -cl.
-
colorsMenu (Class ImageMenu)
- See option -colmenu.
-
colorTable (Class ColorTable)
- See option -ct.
-
imageVisualClass (Class VisualClass)
- See option -iv.
-
layout (Class Layout)
- See option -layout.
-
logpos (Class LogPos)
- See option -logpos.
-
optionsMenu (Class ImageMenu)
- See option -optionsmenu.
-
overlaysMenu (Class ImageMenu)
- See option -ovlmenu.
-
overlayTable (Class ColorTable)
- See option -overlaytable.
-
panelContainer (Class PanelContainer)
- See option -panelcontainer.
-
rgbImages (Class RgbImages)
- See option -rgb.
-
toolsMenu (Class ImageMenu)
- See option -toolsmenu.
-
version (Class Version)
- See option -version.
-
visualsMenu (Class ImageMenu)
- See option -visualsmenu.
-
widgetSet (Class WidgetSet)
- See option -widgetset.
-
xiteHelper (Class XiteHelper)
- Determines which program is started when the help button
is pushed. Colon-separated list of strings, started in the
order listed until one is successful.
-
xiteHelperOption (Class XiteHelperOption)
- Options for the resource xiteHelper.
-
xiteResourceVersion
- This resource should typically be the same as the XITE version
(given in response to option -version). If the warn
argument to ximage_init or ximageInit is True, the ximage
application will check whether xiteResourceVersion is too
old for the running XITE version.
-
zoomAll (Class ZoomAll)
- See option -zoomall.
Some of the Image widget resources:
-
displayMethod (Class DisplayMethod)
- See option -full.
-
imageHeight (class ImageHeight)
- See option -ih.
-
imageWidth (class ImageWidth)
- See option -iw.
-
menubar (Class Menubar)
- See option -mb.
-
protectOverlay (Class ProtectOverlay)
- See option -protect.
-
variableAspect (Class VariableAspect)
- See option -aspect.
See the section Widget hierarchy on how to specify resources.
-
ximage_layout
- The top of the hierarchy is always
<application name> (Class <application class>)
The second level depends on how the widgets have been created.
If the application consists of a single window which contains
an image as well as buttons etc., the second level will most
likely be
topContainer (Class Box or Form) (if nwids > 1)
The class of topContainer is Box by default, but can be set
to Form with option -panelcontainer or the resource
panelContainer.
With multiple windows or if sh_r_nam was given in the
widget specification in wids, the second level will be
<sh_r_nam> (Class TopLevelShell)
The level below sh_r_nam will be
topContainer (Class Box or Form)
if at least one of the widgets "belonging" to sh_r_nam
is not an image. If there is only one widget which is an image,
then the level will be
imageForm (Class ImageForm)
followed by
image (Class Image or ImageOverlay)
Below a "topContainer" level follows any number of widgets
according to the widget specifications in the wids argument
to ximage_layout (described above). The widget
specifications give both resource instance name and class.
See the documentation for each specific application to find
out which widget classes are used and the specific widget
instance names.
-
ximageLayout
- The hierarchy will be the same as for ximage_layout,
but the widget specifications are of course not given by
wids, but when creating the layout structures by calld to
Make_label_layout, Make_image_layout etc.
Image(3), ImageOverlay(3), xshow(1), xadd(1),
xfft(1), xfilter(1), xhistogram(1), xmovie(1),
xpyramid(1), xregion(1), ximage_example(1),
XfwfButton(3), XfwfMenuBar(3), XfwfPrompt(3),
XfwfPullDown(3), XfwfToggle(3).
Otto Milvang and Svein Bøe
Svein Bøe
$Id: ximage.c,v 1.146 1997/08/01 09:42:56 svein Exp $