home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Datafile PD-CD 5
/
DATAFILE_PDCD5.iso
/
utilities
/
v
/
vista
/
!Manual
/
manual
/
objects
< prev
next >
Wrap
Text File
|
1996-01-27
|
19KB
|
554 lines
<html>
<title>Objects</title>
<h1>Objects</h1>
A Window in Vista can contain a number of 'Objects'. These are things which reside
inside the window are need to be redrawn. Icons are effectively objects which are
handled by the WIMP. An object is created inside a window and every time the
window needs redrawn (for a resize or scroll) the objects are asked to redraw
themselves by the Window. They are passed the <b>WORK AREA</b> coordinates within the
window which needs updated. They can be used to perform clipping of the
redraw in order to make it more efficient.
<p>
Objects in a window has a priority assicoated with them. This is to allow
objects to overlap. A higher priority object will receive events
such as mouse clicks and key presses before lower priority ones.
<p>
<h2>Synopsis</h2>
<pre>
class Object
{
public:
<a href="file:objects#ct">Object</a> (Window *w, char *name, int priority = 0, char *menu = 0) ;
virtual <a href="file:objects#dt">~Object</a>() ;
virtual void <a href="file:objects#redraw">redraw</a> (int x0, int y0, int x1, int y1) ;
virtual void <a href="file:objects#update">update</a> (int x0, int y0, int x1, int y1) ;
virtual int <a href="file:objects#compare">compare</a> (int x, int y) ;
virtual void <a href="file:objects#move1">move</a> (int x0, int y0, int x1, int y1) ;
virtual void <a href="file:objects#move2">move</a> (int dx, int dy) ;
virtual void <a href="file:objects#drag">drag</a> (int mx, int my, int buttons) ;
virtual void <a href="file:objects#end_drag">end_drag</a> (int x0, int y0, int x1, int y1, int id) ;
virtual void <a href="file:objects#click">click</a>(int mx, int my, int button) ;
virtual void <a href="file:objects#key">key</a> (int x, int y, int height, int index, int code) ;
virtual void <a href="file:objects#double_click">double_click</a> (int mx, int my, int buttons) ;
virtual void <a href="file:objects#select">select</a>() ;
virtual void <a href="file:objects#unselect">unselect</a>() ;
virtual int <a href="file:objects#width">width</a>() ;
virtual int <a href="file:objects#height">height</a>() ;
virtual void <a href="file:objects#pointer">pointer</a> (int entering) ;
virtual void <a href="file:objects#mode_change">mode_change</a>() ;
Menu *<a href="file:objects#display_menu">display_menu</a> (int x, int y, int button, int icon) ;
virtual void <a href="file:objects#pre_menu">pre_menu</a>(Menu *m, int x, int y, int button, int icon) ;
virtual char *<a href="file:objects#get_menu">get_menu</a> (int x, int y, int button, int icon) ;
virtual void <a href="file:objects#menu">menu</a> (MenuItem items[]) ;
virtual char (<a href="file:objects#help">help</a> (int mx, int my, int buttons) ;
int <a href="file:objects#x0">x0</a> ;
int <a href="file:objects#x0">y0</a> ;
int <a href="file:objects#x0">x1</a> ;
int <a href="file:objects#x0">y1</a> ;
Window *<a href="file:objects#window">window</a> ;
Menu *<a href="file:objects#default_menu">default_menu</a> ;
Object *<a href="file:objects#next">next, *prev</a> ;
char <a href="file:objects#name">name</a>[32] ;
int <a href="file:objects#priority">priority</a> ;
int <a href="file:objects#selected">selected</a> ;
} ;
</pre>
<p>
<h2>Members</h2>
<p>
<a name="ct"></a>
<h3>Object::Object (Window *w, char *name, int priority = 0, char *menu = 0)</h3>
This is the Object constructor. The parameters are:
<p>
<ul>
<li><b>w</b>: The window in which the object exists
<li><b>name</b>: The name of the object (a text string - may be "")
<li><b>priority</b>: The priority of the object. This determines the
order in which the object is placed in the window. Higher priority
objects are handled as if they are "on top" of other objects and therefore
are first to be given mouse clicks. They are also the first to be redrawn.
<li><b>menu</b>: A menu to use as default if the object responds to menu
clicks.
</ul>
<p>
<a name="dt"></a>
<h3>Object::~Object()</h3>
This is the object destructor. It will remove the object from the
window.
<p>
<a name="redraw"></a>
<h3>Object::redraw (int x0, int y0, int x1, int y1)</h3>
This function is called when the object may need to be redrawn. The
function should check if the object boundary box lies within the
coordinates passed before redrawing itself. The background
has already been cleared by the WIMP.
<p>
The object can check the coordinates using the following code:
<pre>
if (x0 <= this->x1 && x1 >= this->x0 && y0 <= this->y1 && y1 >= this->y0)
{
// redraw the object
}
</pre>
The coordinates passed are window coordinates (not screen coordinates),
but can be converted to screen coordinates by code such as:
<pre>
sx = window->x0 + this->x0 - window->scx ; // screen x
sy = window->y1 + this->y0 - window->scy ; // screen y
</pre>
or by calling the Window functions <a href="file:window#coords">xtoscreen(), ytoscreen()</a>.
<p>
<a name="update"></a>
<h3>Object::update (int x0, int y0, int x1, int y1)</h3>
This function is called when the user has requested an update of the
window by use of the Wimp_UpdateWindow call. The coords passed are
window coordinates (as in redraw). The window is not cleared to the
background colour.
<p>
<a name="compare"></a>
<h3>Object::compare (int x, int y)</h3>
This function is called to check if the coordinates passed (in screen coordinates
this time) are within the object's boundary.
<p>
In the simplest case, the following code is provided as part of the
Object base class. It simply compares the bounding box of the
object. If the object is not a simple box, more complex code is
required:
<pre>
int Object::compare (int x, int y)
{
x = x + (window->scx - window->x0) ; // x in window coords
y = y + (window->scy - window->y1) ; // y in window coords
return x <= this->x1 && x >= this->x0 && y <= this->y1 && y >= this->y0 ;
}
</pre>
<p>
<a name="move1"></a>
<h3>Object::move (int x0, int y0, int x1, int y1)</h3>
This function moves the object to a new position (in window coordinates).
It also allows the object's bounding box to be resized.
<p>
<a name="move2"></a>
<h3>Object::move (int dx, int dy)</h3>
This function moves the object a certain distance from its current
position. The deltas are in the x and y direction and are in
window coordinates.
<p>
<a name="drag"></a>
<h3>Object::drag (int mx, int my, int buttons)</h3>
This function begins an object drag. The default function as provided
by the Object base class starts a drag by using the do_drag function
in the window.
<p>
<a name="end_drag"></a>
<h3>Object::end_drag (int x0, int y0, int x1, int y1, int id)</h3>
This function is called by the Task when the drag operation has completed.
It is passed the drag bounding box coordinates (screen coordinates)
and an integral identifier passed to the dragger. The default
function provided by the Object base class moves the object to the
new position.
<p>
<a name="click"></a>
<h3>Object::click(int mx, int my, int button)</h3>
This function is called when the user clicks select over the object.
The parameters passed are exactly as returned from Wimp_Poll for this
event.
<p>
Note that the window must have an appropriate button type for this
event to be received.
<p>
<a name="key"></a>
<h3>Object::key (int x, int y, int height, int index, int code)</h3>
This function is called when the user presses a key over the object.
The paramaters passed are as returned from Wimp_Poll.
<p>
<a name="double_click"></a>
<h3>Object::double_click (int mx, int my, int buttons)</h3>
This function is called when the user has double-clicked the mouse
over the object. Note that the window must have an appropriate
button type for this event to be received.
<p>
<a name="select"></a>
<h3>Object::select()</h3>
Mark the object as selected. The selection state can be read by
accessing the variable 'selected' within the object class.
<p>
<a name="unselect"></a>
<h3>Object::unselect()</h3