Methods for objects handled by the XVisual Interface Builder(XIB)
Libxv comes in two versions, static and shared. Note that if you opt to use the shared version, you will require that the target system has the shared libxv libraries installed.
NOTE: A knowledge of the Athena Widget Library is recommended since it's beyond the scope of this document to list every resource of each Widget.
An Example program construction using libxv
It's probably easier to show you a simple libxv program and to
describe its construction...
#include X11/xv/xv.h void cmd_exit(Widget aw, XtPointer client, XtPointer call) { app_window.Close(); exit(0); } main(int argc, char **argv) { xvContext app_context; xvWindow app_window; xvButton app_exit; // Now Initialise the Objects... app_context.init("example", argc, argv); app_window.init("Example libxv program", "example", app_context); app_exit.init("Exit", app_window, cmd_exit); app_exit.SetDistance(50, 50); app_exit.SetFixedPosition(TRUE); app_window.SetWindowResource(XtNgeometry, (XtArgVal) "400x400"); app_window.Open(); XtAppMainLoop(app_context.GetContext()); }
|
This simple program displays a window with a button near to top-left corner. Pressing the button causes the window to close and the program to exit.
The construction is pretty simple, but shows the basic concepts needed to use libxv successfully.
The first line includes the X11/xv/xv.h header file which is required for all programs using libxv.
Application exit is handled by a callback function. This closes the window and calls the exit function to quit the application. A callback is a function which is called by a widget when a certain event occurs - in this case when the button is pressed. Callbacks have the same structure, must be declared void (this type of function is typedef'ed by Xt) and have the same three parameters (Widget and two XtPointers). An XtPointer is a pointer to data which may be passed from the widget calling the function and may be cast as required. For example, if you had a group of buttons using the same callback, each could pass a unique item of data to the function to identify which button was pressed.
Many objects have callbacks to perform different actions, and they may also have event callbacks to perform actions in certain circumstances. Event callbacks have a different parameter list and are covered later. The xvTimer object has a timeout callback which is called at a specific interval, and again has different parameters.
On to the main section, and we declare three objects; an xvContext, an xvWindow and an xvButton. Every program using libxv must have an xvContext which declares the programs 'application context'; a data structure used by Xt to manage a program currently running. Most programs will require an xvWindow object in order to display anything at all. A program may have several xvWindows (and may also have multiple xvContexts, although it's unlikely) to display different information.
In this example, we use one window and one xvButton object.
Each xv object has an init function and the order of initialisation is important. An xvContext object is the 'parent' of anything that is declared within it's scope, these objects being it's 'children'. The xvWindow object is the 'child' of xvContext, but anything that appears within that window is the window's child. Most libxv objects require the name of the parent to be passed to them during initialisation, the exception being the xvContext itself.
In this example, the first init function called is the xvContext.init function, which takes a string name, argc and argv as parameters. Next, the xvWindow object is declared. This takes a string (the window title), a string (the classname) and a context name (in this case the app_context object declared as xvContext).
Now we can initialise the button which takes a string (the button name and it's label), a parent name (in this case the xvWindow object) and a pointer to callback function to be executed when the button is pressed. Note that xvButton objects can take an optional 4th paramter, which is a string containing 'client' data to be passed to the callback.
Additionally, the core SetDistance method is used to position the button at co-ordinates 50, 50 on the window (0,0 = top left of window) and the core SetFixedPosition method is called to fix it's position and size (otherwise Xt would change its size if the window was resized - to see what happens, comment this line out!)
Before opening the window with the xvWindow Open method, we make a call to the xvWindow SetWindowResource method to set the size of the window to 400x400 pixels. Note that this is done just before opening the window because objects declared before sometimes cause Xt to automatically resize the window, which may not be what you want. In the Xvisual Interface Builder, you can set and fix the window size if you wish.
The xvWindow Open method is called to actually open and display the window and it's child objects. It is at this point that Xt realizes all the widgets and displays them in the requested positions.
Now we call XtAppMainLoop which retrieves and processes X Window events. This will continue indefinately and there is no return from this call. The application will only exit when the callback function is activated by pressing the button and the program exits.
NOTE: Although we used the init methods to initialise the instances of these objects, we could just have easily written:
main(int argc, char **argv) { ... xvWindow *app_window=new xvWindow("Example libxv program", "example", app_context); ... etc.. } |
Note that because we would be using a pointer to a class, methods would be called using the -> operator (e.g. app_window->Open();) and references to the object would require '*' (e.g. *app_window).
g++ -L/usr/X11/lib -o example example.o -lxv -lXaw3D -lXmu -lXt -lSM -lICE -lXext
-lX11
The need for a Makefile is obvious and an example
Makefile is shown
later. The XIB generates it's own makefiles depending on the forms and
modules currently loaded, but the basic structure is pretty much the
same.
All methods return 'void' unless otherwise indicated
Where the parameter 'xvObject & parent' appears, simply pass the name of the instance of
the class of the parent object.
These methods allow control over display of the object.
The Hide and Show methods call XtUnrealize and XtRealize and thus affect the way
that the parent object will manage them.
The Unmap and Map methods allow the objects to be hidden or shown, but do not
affect the management of them
These methods change the background and foreground pixel colour values and they will
accept a value of type 'Pixel', or a String containing the name of the colour as defined in
the X11 rgb.txt system file. If a String us used, and the name is not in the rgb.txt file,
no change takes place.
Used to set the border pixmap. The pixmap shoud already be defined
As for SetBackground, but sets the border colour.
Sets the objects border width. Ideally should be done before the object's parent window
is opened.
Returns the value of the objects border width
Sets the objects height.
Returns the height of the object. Note that the parent's management may try to fight
you when you change this resource!
This should be used before the object's parent window is opened. Calling this
method with FALSE will prevent the object being mapped on the window, but it's
space will still be allocated and the object may be displayed later using the Map()
method. Default condition is TRUE.
Calling this method with FALSE will disable the object (and it's children if the object
is a form, box or window). Calling with TRUE will enable the object. Objects are
instantiated with this condition TRUE.
Used to override or augment an objects translations. A knowledge of Xt translation
management is recommended before using these methods
Similar to above but unconditionally overrides all translations.
Sets the objects width. The parent's management may try to fight you if you
change this resource.
Returns the objects width.
Used to set the X and/or Y position of an object in a box object. Use SetDistance or
SetVert/HorizDistance normally.
Returns the X and/or Y of the object within a box parent.
Gets/sets the object's width and height.
Gets/Sets a resource value for an object. This is included mainly to allow
manipulation of resources which so not have a specific method. The String is the
XtN resource string and the XtArgVal is the value to be returned or set. When
using GetResource, pass a pointer to the variable (including strings), cast to
(XtArgVal *). For Example :
char buffer[30];
object.GetResource(XtNgeometry, (XtArgVal *) &buffer)
Note how even a char type passes a pointer to this method.
Add an event handler for a specific event type to an object. Only use this method
if you are familiar with XEvents.
Remove an event previously added with AddEvent. The mask, handler and pointer
data should match that used in the AddEvent method.
Make the object (usually an xvWindow) grab the pointer. Events to other objects in
the application not in the heirachy of this object will not respond to pointer events. This
effectively makes the object modal. Recommended values are FALSE and FALSE.
Remove a previously added Grab.
Sets the caption on the object (e.g. xvButton, xvLabel, etc)
Sets the object's font. Typically, this is used with an xvFont object's FontRef() method
to set the object's font instead of the objects own ChangeFont method.
Sets the text justification in the object. Values are XtJustifyLeft, XtJustifyCenter and
XtJustifyRight.
Sets/Gets the objects internal height which is normally the distance between the
contents and border of the object's display area.
As above but for width.
Sets the object's cursor. When the pointer is over the object, the cursor graphic
will change to the type set by this function. String value should be the name of the
cursor as defined in the X11/cursorfont.h system file.
Sets the xvWindow's icon to the specified pixmap.
Sets the distance between this object and others if no value has been set by the
SetnDistance methods.
...where n is Bottom, Top, Left or Right. Sets the mode of the specified edge of the
object when the parent is resized. Values are XawChainn or XawRubber.
Tells the parent to position the object relative to another object in a vertical and/or
horizontal orientation. Use this if you don't specify positions using the SetnDistance
methods.
Combines the actions of the SetReln methods.
Sets/Gets the relative distance from the top-left of the xvWindow or xvForm parent, or
from an object if any of the SetRelative methods have been used.
Sets/Gets the relative distance as above.
Sets the default distance between objects on an xvWindow or xvForm when no other
distance has been specified using the above methods.
If the parameter is TRUE, the edges of the object will be fixed and resizing the parent
will have no effect. Otherwise the object will be resized by the parent. The default
value when an object is instantiated is FALSE.
Sets the width of the objects shadow. This is the resource that gives the object a
3D look and feel.
Sets the value of the colours for the upper and lower sections of the shadow.
Define the relative density of the upper and lower sections of the shadow.
Convert a string colour value into the correspoding Pixel and allocate a colormap cell. This
method will return -1 if unsuccessful.
Creates and return a pointer to a Pixmap from the data supplied from a standard
X11 .xbm file. If the final String is set to an XtN resource value, that resource will
be set too.
Creates and return a pointer to a colour Pixmap from the data supplied from a standard
X11 .xpm file. If the final String is set to an XtN resource value, that resource will
be set too.
Returns the widget ID of the object.
Note that objects with init methods may also be instatiated in the following way:-
Initialise the object. Simply pass argc and argv in main. The name is
the application name.
Return the application context.
Service X events for this context. This should be called from within a loop somewhere in
your program (see the example program above).
Register a work procedure to be carried out during system idle time. Be very careful
with this since system performance may be affected by a badly implemented work
procedure. The proc is the procedure to be executed, the client is the
data to be passed each time the procedure is called.
Remove a work procedure.
Register an action procedure in the translation table.
Insert and action hook procedure into the system's action processing method.
Removes an action hook.
Call Xt's XtAppErrorMessage routine.
Init the window with titlebar wintitle. The winclass is name used to
source a resource file (not used). The parent is normally the xvContext object.
Open and Close the window. Basically, this will realize or unrealize the window and
it's children.
Move the pointer to co-ordinates x, y inside this window.
Set a resource for the application shell.
Return a resource from the application shell.
Return the widget ID of the application shell.
Loads a new icon for the application shell. Returns non-zero if it fails. The pixtype
is either XVBITMAP (.xbm) or XVPIXMAP (.xpm).
Fix the border size. Resize attempts are ignored.
Release the lock on the border size..
Set the window's geometry resource to position x, y on the root window.
Initialise the timer object. The timer callback will be executed when the time (in milliseconds)
expires. Normally, this is a one-shot timer, so use the Reset() method in the callback
function to re-prime the timer.
Re-primes the timer to run again for the specified time.
Initialise the visual list. A list is actually a combination of an xvView and xvList pair. The
view manages the list's visible display, creating scrollbars as required. The callback is
called when an item is selected in the list. The numdata parameter is the numbers of
items in the list, whilst the listdata is the char list. The number of columns defaults to
1 if no parameter is passed.
Sends new list data to be displayed. The numdata is the number of items, the listdata
is the actual list.
Highlight item number item in the list.
Unhighlight any currently highlighted item in the list.
Returns an XawListReturnStruct containing information about the currently selected
item (if any).
Returns the length (in pixels) of the longest list entry.
When passed a standard X font specification, this method will load and set the object's
new font.
Initialise the button object. The name will appear as the button caption unless a
subsequent SetLabel method is called. The callback will be executed when the
button is pressed. The optional client parameter will be passed to the callback
function to identify the button pressed. The startcall and stopcall are
legal only in an xvRepeater class and are called at the appropriate times.
When passed a standard X font specification, this method will load and set the object's
new font.
When passes a pathname/filename, this method will load and set the object's new bitmap.
A non-zero value indicates failure and the bitmap is not set. The pixtype is
either XVBITMAP (.xbm) or XVPIXMAP (.xpm). The position is either
XVCENTREBITMAP (default) or XVLEFTBITMAP.
Initialise the edit field. The edit etype can be XawAsciiString or XawAsciiFile. If the
edit etype is XawAsciiFile, the datasrc String is the filename. The mode
will be one of XawtextRead (read only), XawtextAppend (existing text is read-only but may
be added to) or XawtextEdit (read/write). The callback and clientdata, if
specified, will allow the programmer to involk the callback every time the text
buffer is changed.
When passed a standard X font specification, this method will load and set the object's
new font.
Used to set selection data in a text field. The XawTestPosition passes the
information to the Athena text widget and is a typedef long.
Unsets a prevoiusly set selection.
Get the current text selection start and end.
Replaces the text marked by start and end with that pointed to by the
XawTextBlock. This structure has the following construction:-
Search for a text segment contained in the XawTextBlock, scanning in the direction
dictated by dir which will be one of XawsdLeft or XawsdRight. If the search is
successful, the location of the first character is returned, otherwise XawTextSearchError
is returned.
Invalidate (redisplay) a range of characters.
Use these methods to suspend re-display of text in the field. Useful if you are making
many changes to the text.
Display all changes. Text redisplays are often queued and this method flushes them.
When scrolling through large amounts of data, this method is useful for returning the
text position in the buffer of the top-left character in the edit window.
Assign a new selection array. For those programmers with a knowledge of the
operation of the Athena Widget set.
Move the insertion point in the text.
Return the current position of the insertion point. .
An edit widget is made up of three parts, the source, sink and text editor. This
method changes the source. For experienced programmers only.
Returns the source widget ID.
Controls the visibility if the caret cursor.
Returns a pointer to the string in the Editfield's memory buffer. You should use this
with strcpy to retreive the data:
strcpy(dest, an_edit_buffer.ReturnString(buffer_ptr));
For editfields using XawAsciiFile, this will save the data back to the source file.
As above but allows the data to be saved to a different file.
Returns TRUE if the data has been altered in the editfield's memory.
Controls character echo. If this is FALSE, then text is entered, but nothing is displayed
which is useful for password fields...
Controls what happens at the right margin of the edit field when the text moves
beyond it. Values are XawtextWrapNever, XawtextWrapLine and
XawtextWrapWord.
Adds a callback function. This is called when the buffer is updated.
If this is set TRUE, then the editfield will automatically break a line when the user attempts
to type beyond the right margin.
if this is set TRUE, all non-printable characters will be displayed.
Sets the mode for the object to resize should it need to do so. Options are
XawtextResizeNever (default), XawtextResizeWidth, XawtextResizeHeight or
XawtextResizeBoth.
These control the placement of the scrollbars. Options are XawtextScrollAlways,
XawtextScrollWhenNeeded (default) or XawtextScrollNever.
Allows the edit buffer to be set after initialization. You should pass a char array big enough
to contain all expected text following an edit.
The name is the filename of the bitmap. If visual is true, the
bitmap object will appear in the window, otherwise xvBitmap operates as a hidden
bitmap store for other objects.
Returns a pointer to the internal pixmap.
Loads an X11 bitmap file (.xbm format). A non-zero return value indicates a failure. The
pixtype is either XVBITMAP (.xbm) or XVPIXMAP (.xpm).
The name will appear as the caption unless a SetLabel method is used afterwards.
When passed a standard X font specification, this method will load and set the object's
new font.
When passes a pathname/filename, this method will load and set the object's new bitmap.
A non-zero value indicates failure and the bitmap is not set. The pixtype is
either XVBITMAP (.xbm) or XVPIXMAP (.xpm)The position is either
XVCENTREBITMAP (default) or XVLEFTBITMAP.
The callback is executed when the slider is moved. The initial size of the
pan field is set using sizeH and sizeW and the slider position set by
InitX and InitY.
Set the slider position.
Sets the size of the slider graphic in pixels.
Change the size of the slider 'canvas' area.
Set the scale of the canvas.
Return the current slider position.
Creates a box object which may contain child objects. Boxes exert their own, somewhat
basic, control over the placement of childern, but it's useful for containing groups of
toggles or buttons.
Create a form object which may contain it's own child objects. This composite object
allows similar layout control that the xvWindow object does (in fact xvWindow uses a
form for it's layout control).
Enable (TRUE) or disable (FALSE) the layout control of the form object. Useful if
you plan to move a lot of child objects around.
Create a toggle object. The callback is executed when the toggle is pressed, and the radiodata
passed to the callback as client data.
Change this toggle's group. When a toggle is a member of a group, only one in that group
can be pressed at any one time (radio-button style).Use UnsetGroup to remove from a
group.
Change the currently selected toggle in a radio-group to that whose radiodata string
matches rdata.
Remove this toggle from any group.
Returns an XtPointer to the radiodata of the currently selected toggle in a group. Cast the
return value to a (char *) to read the radiodata string.
When passed a standard X font specification, this method will load and set the object's
new font.
When passes a pathname/filename, this method will load and set the object's new bitmap.
A non-zero value indicates failure and the bitmap is not set. The pixtype is
either XVBITMAP (.xbm) or XVPIXMAP (.xpm). The position is either
XVCENTREBITMAP (default) or XVLEFTBITMAP.
Create a scrollbar. The orient parameter is either of XtOrientVertical or
XtOrientHorizontal. The sizeL is the length of the bar. The three callbacks
are executed depending on the action performed on the scrollbar.
void SetThumb(float t_pos, float t_size)
Move the thumb and set it's size.
Create a filelist or dirlist box. The initial path is set to path. The mode
parameter is one of XVFILELIST (list files only), XVDIRLIST (list directories only)
or XVALLLIST (list everything). If hidden is TRUE, hidden files are listed
too (those starting with a period). The callback is executed when an item is selected.
The path should be terminated with a '/'
The callback call is intended to allow you to change paths for the file list:
Set a new path. Parameters are similar to the init function above
Designed to be called from a callback routine, this method returns the selected item.
The mode is either XVRELATIVEPATH (return item only) or XVABSOLUTEPATH
(return item with root-relative path). Use this with the Directory method below.
Takes a return from GetSelectedItem (in XVRELATIVEPATH mode) and returns a string
suitable for SetNewPath.
Create a drop-down listbox. The numargs and argdata are as for the
xvVisualList object. The button-call is excuted when the drop-down button is clicked,
and the select_call is executed when an item is selected from the list. The vdepth
is the number of text lines in the drop-list beyond which the object will scroll the data. The
currentindex is the item that will be selected by default.
Open the drop-down list. To be called from the button_callback.
Sets the current item in the list (this appears in the label box).
To be called from the select callback, passes the call_data parameter from the callback
and selects the appropriate entry.
Sets a new list. Parameters are similar to init.
When passed a standard X font specification, this method will load and set the object's
new font.
Sets resources specifically in the contained objects.
Sets resources of ALL contained objects.
Changes the width of the dropdown object without distorting the contained objects. It
also ensures that the droplist will be the same width as the label.
Used to return the Widget ID of the menubar button whose caption is name. Use
this method when setting up a pulldown menu object to bind it to the menubar button.
Set a resource of menu button name.
Set a resource on all menubar items.
When passed a standard X font specification, this method will load and set the object's
new font.
Change the menu entry name to newname.
These methods allow you to display or hide a small 'X' checkmark on the menu
entry name.
Change a resource of menu list entry name to value.
Set resource to value in all menu list entries.
Return the Widget ID of entry name.
When passed a standard X font specification, this method will load and set the object's
new font.
Each xvWindow object supports three graphics contexts and you may select the context
to be used with the GCSwitchGC(int) method (see below). The GC remains in force until
the method is called again.
Flush all current GC commands.
These methods allow you to set the foreground, background and planemask values
individually, or all at once. The func sets the draw mode which is one of GXclear,
GXand, GXandReverse, GXcopy (default), GXandInverted, GXnoop, GXxor, GXor,
GXnor, GXequiv, GXinvert, GXorReverse, GXcopyInverted, GXorInverted, GXnand
or GXSet.
Changes the current GC. Values are XVDEFAULTGC, XVAUXGC1, XVAUXGC2. The
change remains in force until a further call is made.
Return the current pointer position in this window.
Convert Window co-ordinates to root window co-ordinates.
As above but in reverse.
A grip widget is a small rectangular graphic (8x8 pixels) used as a pointer grip to
move objects. This init method sets up the grip callback which is called when the
mouse button is pressed whilst the pointer is over the widget.
Initialize an instance of a popup shell. This object is intended to be sub-classed to
provide an Override shell to 'popup' a window independent of the window manager. If
the parent is another object, such as a window, then the popup co-ordinates are relative
to that object. If the xvContext object is used, then the popup co-ordinates are relative
to the root window.
All objects that sub-class this class (e.g PopupDialog, PopupMenu) inherit this objects
Open and Close methods.
Open the popupshell window. The co-ordinate version is useful for popupshells using
the application context as it's parent.
Popdown the shell.
Initialise an instance of a popup menu. The menu list items are passed in a char
pointer array argv and the number of list elements in argc. The callbacks
for the list items are passed in the procs array. The menu name is passed in
the header and will appear at the top of the menu.
Change menu entry name to be newname.
Change list entry name's resource to value.
Mark or unmask list entry name.
Return the widget ID if list entry name.
Change resource to value in all list entries.
When passed a standard X font specification, this method will load and set the
new font on all list menbers.
Initialize an instance of a dialog widget. The header is the widget's text
information and the defaultdata is the default text.
Returns a pointer to the data in the text edit area.
Add a button and it's callback to the dialog widget.
When passed a standard X font specification, this method will load and set the
new font on this object.
Initialize an instance of a popup dialog box. The header appears as the dialog box's
info text and the defaultdata is placed in the dialog box's text area.
Initialize an instance of the filedialog objects. This is intended as a complete file
dialog as it contains a file list, directory list and file name edit box, along with a
set of buttons and toggles. The pathname is the initial path that the dialog
will use. The mask is placed in the filename edit box and if useMask
is TRUE, the files listed must contain this substring.
There are 6 callbacks as follows:
Basically, all you need to do is call the EditEntry Method for this object.
The callbacks for the file and dirlist are intended to allow you to change paths for
the object:
Obviously you can perform a number of other tasks in these callbacks if you with, but these are
the minimums needed to make the file dialog operate directory changes.
Call this from the errcall callback function, passing the call data.
Change the file dialog's current path.
Call this from the editcall callback as described above.
Changes the dialogs record of the current file. See the example above to see how this
is called from the file listbox callback.
Changes the dialogs record of the current path. See the examples above.
Gets the information from the dialog. In the okcallback function, you could use this
method to get the final path and filename:
Manually update the file edit box.
This object was primarily designed for use in the XIB. It creates an independant
edit window with an OK and CANCEL button and inherits the methods from xvWindow
and xvEditField.
The parent is usually the xvContext of the application.
The header is the name of the window (on the title bar). The mode is the
edit mode (XawtextRead, XawtextEdit, XawtextAppend - see the xvEditField object
information). The two callbacks are for the OK and CANCEL buttons. The datasource
if the char buffer to be edited. This buffer should be made large enough to handle any
text info expected from the xvEditWindow object. The client parameter is passed
to the ok and cancel callbacks to identify which xvEditWindow initiated the action.
Init. a instance of a message box. The name is the message box's window's
title bar caption and the message is the text you wish to appear inside the
message box. The type is one of XVSIMPLEWARN which has a warning
icon and one button; XVSIMPLEFATAL which has a STOP icon and one
button and XVSIMPLECHOICE which has a question mark icon and a
YES and NO button. For boxes with one button, only the b1_call is used, but both
should be specified anyway. The String back_colour is the background colour
of the messagebox.
When passed a standard X font specification, this method will load and set the
new font on this object.
Init. this object and load the fontname. These objects are intended for use with
graphics functions since most other text-using objects have their own font controls.
Load a new font.
Using the current font, return the width of this string in pixels.
Return the font reference. Use this when setting resources:
The xvFontList object is designed to query the system and store a list of available
fonts in a character pointer array. Storage of this list is internal to the object but you
need to pass the maximum numfonts to load into the list. The pattern
specifies the search parameters. Setting this to "*" will load all fonts which is a
standard set of 700-900 font specs...
Use these functions to pass the list information to a list objects. GetList returns a pointer
to the actual list and FontsInList returns the number in the list.
Inits. the region. Pass the points in the points array and the number of points in
num.
Returns a pointer to a Region.
Offset points in a region by dx and/or dy.
Make the region smaller by dx and/or dy.
Returns TRUE if the region is empty (no points).
Returns TRUE is the points x, y falls inside the region.
Checks if the specified rectangular area falls anywhere inside the region.
Simply enter the files to be compiled into the 'OBJFILES=' list (with the .o extension instead
of .cc) and then type 'make' at the command line.
Compiling a libxv program
The above program can be compiled as follows:
g++ -c -o example.o example.cc
Core methods common to most objects
Core methods as those defined in the xvCore class which is inherited by the majority of objects
in libxv. These allow you to change the basic resources of a particular object without having to
use Xt argument lists or the XtVaSet/Getvalues calls. Although these methods are the preferred
way to change object resources, you can still use the Xt routines since libxv will update it's own
information as required.Core Methods for all xvCore objects
Dimension heightval;
object.GetResource(XtNheight, (XtArgVal *) &heightval)Core Methods for most objects
The methods listed in this sub-section apply only to certain objects such as xvButton and
xvLabel which use the particular resource
Constraint Methods
Objects that are children of xvWindow or xvForm objects can use these methods
Three-D methods
Some objects respond to the setting of these resources and thus provide a pseudo-three-D visual effect.
Misc. Methods
These methods were included in the core set for ease of access and use.
Methods for objects handled by the XVisual Interface Builder(XIB)
This section covers the specific methods provided by objects directly handled by the XIB. You
can of course create these objects outside the XIB if you wish.
xvObtype object=new xvObtype(...);
Where the parameter 'xvObject & parent' appears, simply pass the name of the instance of
the class of the parent object.
XvContext
xvWindow
xvTimer
xvVisualList
xvButton & xvRepeater
xvEditField
struct {
This function will return one of the following: XawEditDone (replacement successful),
XawPositionError (text position problem. Trying to replace text in existing string
when mode is XawtextAppend) or XawEditError (trying to replace text in a read-only
edit field.
int firstPos;
int length;
char *ptr;
unsigned long format;
} XawTextBlock, *XawTextBlockPtr;
xvBitmap
xvLabel
xvPanner
xvBox
xvForm
xvToggle
xvScrollbar
xvFileList & xvDirList
void func_dirlist_call(Widget aw, XtPointer client, XtPointer call)
{
char *temp=pathlist.GetSelectedItem(call, XVRELATIVEPATH);
strcpy(prov, pathlist.Directory(temp));
int dirstatus=pathlist.SetNewPath(prov, XVDIRLIST, TRUE)
int filestatus=filelist.SetNewPath(prov, XVFILELIST, TRUE)
...
}
xvDropDown
xvMenuBar
xvPulldownMenu
GC & Graphics methods for xvWindows.
An object of type xvWindow also supports a number of Graphics Context (GC) and Graphics
methods. Note that if you are drawing to a window, you will need to arrange for graphics info
to be re-drawn should the window be obscured and then exposed. Use the X_Expose event
to do this.
Graphics Context Methods
Graphics Methods
Other libXV objects
The following objects are also available to the programmer, even though they are not directly
supported by the XIB. Just how useful these will be depends pretty much on your application and
some of these were intended to be used by the XIB rather than client programs.
xvGrip
xvPopupShell
xvPopupMenu
This class inherits all of xvPopupShell's methods.
xvDialog
xvPopupDialog
This class inherits all of xvPopupShell's methods and all of xvDialog's methods.
xvFileDialog
filelistcall is executed when an item is clicked in the file list box.
The editcall should be an XtActionProc. An example is shown below:
dirlistcall is executed when an item is clicked in the directory list box.
okcall is executed when the ok button is clicked.
cancelcall is executed when the cancel button is clicked.
errcall is executed when a path access error occurs.
editcall is the edit action callback.
void fileselect_edit_call(Widget w, XEvent *event, String *params, Cardinal *num)
{
xvisSelFile.EditEntry();
}
void fileselect_file_call(Widget aw, XtPointer client, XtPointer call)
{
xvisSelFile.File(call);
}
void fileselect_dir_call(Widget aw, XtPointer client, XtPointer call)
{
xvisSelFile.Directory(call);
}
void func_fileselect_ok(Widget aw, XtPointer client, XtPointer call)
{
strcpy(relpath, xvisSelFile.SelectedFile(abspath));
/* ...
now relpath is the file name.
and abspath is the full path name incl. file name
.. /*
}
xvEditWindow
This object inherits methods from xvWindow and xvEditField.
xvMsgBox
xvFont
object.SetResource(XtNfont, fontobject.FontRef());
xvFontList
xvRegion
This object is a libxv representation of the XLib Region calls. Refer to an XLib Programming
reference for info on Regions.
Typical Makefile used to compile programs using libxv
Shown below is a typical Makefile generated by the XIB to compile and
link programs under libxv. You can copy and modify this to suit your
requirements.
CC=g++
CFLAGS= -O
INCLUDES= -I.
XLIBS= -lxv -lXaw3d -lXmu -lXt -lSM -lICE -lXext -lX11
BIN26LINKOPTS=-L/usr/X11/lib
OBJFILES= example.o window1.o global.o
.cc.o:
$(CC) -c $(CFLAGS) $(INCLUDES) $*.cc
all:: xvis
xvis: $(OBJFILES)
$(CC) $(BIN26LINKOPTS) -o $@ $(OBJFILES) $(XLIBS)
clean:
rm -f *.o xvis
remake:: clean all
Return to the XVisual Homepage
Steve Carrie. steve@phoenix.bim.napier.ac.uk
Last Update 24/05/96 at 16:00 hrs