os_area
|
 |
An association between a URL and a
region within a mapped image.
An os_area
is an association between a URL and a region within an image. This association
causes the region to behave as a hyperlink. An os_area
is not rendered on screen by browsers.
The region defined by an os_area
can be a rectangle, circle, polygon, or the default area. The default area is
the set of all points not mapped by an os_area .
Coordinates that define the boundaries of a region are specified in pixels,
relative to the upper left corner of the image. The shape of the region is
specified by selecting the appropriate constructor, and can be modified through
the rectangle() , circle()
, polygon() , and default_area()
member functions.
You can specify null-hyperlink
behavior for an os_area by selecting the
appropriate constructor or through the nohref()
member function. In this case, rather than behaving as a hyperlink, no action is
taken in the os_area when a user clicks within the
region. Hyperlink behavior can be enabled through the href()
member function.
os_area objects are collected
within an os_image_map to define a client-side
image map. The os_image_map is associated with an os_image
through the os_image::usemap() member function.
Declaration
#include <ospace/web/area.h>
class os_area : public os_element
Interface
Constructor
os_area(
const string& href ,
int ul_x ,
int ul_y ,
int lr_x ,
int lr_y )
Constructs an area to
associate the URL href with the rectangular region
that has upper left corner ( ul_x , ul_y
) and lower right corner ( lr_x , lr_y
).
Constructor
os_area(
int ul_x ,
int ul_y ,
int lr_x ,
int lr_y )
Constructs an area to
associate no URL with the rectangular region that has upper left corner (
ul_x , ul_y) and lower right corner (
lr_x , lr_y ).
Constructor
os_area(
const string& href ,
int c_x ,
int c_y ,_int
radius )
Constructs an area to
associate the URL href with the circular region
that has center ( c_x , c_y)
and radius radius .
Constructor
os_area(
int c_x ,
int c_y ,_int
radius )
Constructs an area to
associate no URL with the circular region that has center (
c_x , c_y ) and radius radius
.
Constructor
os_area(
const string& href ,
const vector< pair< int, int > >& points
)
Constructs an area to
associate URL href with the polygon defined by the
vector of points points . To complete the polygon,
the last point is connected to the first point.
Constructor
os_area(
const vector< pair< int, int > >& points
)
Constructs an area to
associate no URL with the polygon defined by the vector of points points
. To close the polygon, the last point is connected to the first point.
Constructor
os_area(
const string& href )
Constructs an area to
associate the URL href with the default region,
that is, the set of all points within the image not mapped by another area.
circle
os_area&
circle( int c_x ,
int c_y ,_int
radius )
Sets the region to be a
circle with center ( c_x , c_y
) and radius radius , and returns a reference to
the area.
clone
/*
virtual */ os_element* clone() const
Returns a base class
pointer to a heap-based deep copy of the area.
default_area
os_area&
default_area()
Sets the region to be the
set of all points within the image not mapped by another area, and returns a
reference to the area.
href
string
href() const
Returns the URL associated
with the region. Returns the empty string if the region is not associated
with a URL.
href
os_area&
href( const string& url )
Associates URL url
with the region and returns a reference to the area.
is_circle
bool
is_circle( int& x ,
int& y ,
int& radius )
const
Returns true
if the region is a circle; then sets ( x , y
) to the center of the circle and radius to the
radius of the circle.
is_default_area
bool
is_default_area() const
Returns true
if the region represents the default region, that is, if it contains the set
of all points within the image not mapped by another area.
is_nohref
bool
is_nohref() const
Returns true
if region is not associated with a URL.
is_polygon
bool
is_polygon( vector< pair< int, int > >& points
) const
Returns true
if the region is a polygon, and inserts an ( x , y
) pair into points for each point in the polygon.
is_rectangle
bool
is_rectangle( int& ul_x ,
int& ul_y ,
int& lr_x ,
int& lr_y )
const
Returns true
if the region is a rectangle; then sets ( ul_x , ul_y
) to the upper left corner of the rectangle, and ( lr_x
, lr_y) to the lower right corner of the
rectangle.
nohref
os_area&
nohref()
Sets the region to be
associated with no URL and returns a reference to the area.
polygon
os_area&
polygon( const vector< pair< int, int > >& points
)
Sets the region to be a
polygon defined by the vector of points points and
returns a reference to the area. To complete the polygon, the last point is
connected to the first point.
print
/*
virtual */ void print( ostream& os )
const
Prints the area to os
.
rectangle
os_area&
rectangle( int ul_x ,
int ul_y ,
int lr_x ,
int lr_y )
Sets the region to be a
rectangle that has upper left corner ( ul_x , ul_y)
and lower right corner ( lr_x , lr_y
), and returns a reference to the area.
Copyright©1994-2026 Recursion
Software LLC
All Rights Reserved