Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members  

ImageMap Class Reference

A collection of regions that react to clicks and mouseovers. More...

#include <imgmap.h>

Inheritance diagram for ImageMap:

Inheritance graph
[legend]
Collaboration diagram for ImageMap:

Collaboration graph
[legend]
List of all members.

Public Methods

void seek_over ()
 Finds the region that the mouse is currently over and sets the appropriate member.

void set_watcher (Watcher< ImageMap > &my_watch)
 Sets the watcher that will watch this TreeView.

void me_modified ()
gint motion_notify_event_impl (GdkEventMotion *event)
 Updates the information about which region the pointer is over.

gint button_press_event_impl (GdkEventButton *event)
 Updates the display when a mouse button is clicked.

gint enter_notify_event_impl (GdkEventCrossing *event)
 Updates the display when the mouse enters the map area.

gint leave_notify_event_impl (GdkEventCrossing *event)
 Updates the display when the mouse leaves the map area.

virtual bool clicked (EntryRect const *, int button)=0
virtual void hover (EntryRect const *)
virtual void left ()
virtual void entered ()

Protected Attributes

EntryRectover_rect
bool mouse_in
std::vector< EntryRectrectangles

Detailed Description

A collection of regions that react to clicks and mouseovers.


Member Function Documentation

void ImageMap::seek_over  
 

Finds the region that the mouse is currently over and sets the appropriate member.

00066 {
00067    int x=mouse_x;
00068    int y=mouse_y;
00069    if (over_rect!=NULL && over_rect->contains(x, y)) return;
00070    for (size_t i=0; i<rectangles.size(); ++i)
00071    {
00072       if (rectangles[i].contains(x, y)) 
00073       {
00074          over_rect=&rectangles[i];
00075          me_modified();
00076          return;
00077       }
00078    }
00079    over_rect=NULL;
00080 }

void ImageMap::set_watcher Watcher< ImageMap > &    my_watch
 

Sets the watcher that will watch this TreeView.

Parameters:
my_watch  The watcher

00169 {
00170    this->my_watch=&my_watch;
00171 }

void ImageMap::me_modified   [inline]
 

00155    {
00156       if (my_watch!=NULL) my_watch->modified(*this);
00157    }

gint ImageMap::motion_notify_event_impl GdkEventMotion *    event
 

Updates the information about which region the pointer is over.

Parameters:
event  The event containing information about the xy coordinates of the pointer return true (event handled)

00089 {
00090    int x, y;
00091    GdkModifierType state;
00092    Gdk_Window window(event->window);
00093    if (event->window);
00094    if (event->is_hint)
00095       window.get_pointer (x,y,state);
00096    else
00097    {
00098       x=(int)event->x;
00099       y=(int)event->y;
00100       state=(GdkModifierType) event->state;
00101    }
00102    mouse_x=x;
00103    mouse_y=y;
00104    EntryRect *old_over=over_rect;
00105    seek_over();
00106    //if (over_rect!=old_over) hover(over_rect);
00107    if (over_rect!=old_over && over_rect!=NULL) over_rect->hover();
00108    DrawingArea::motion_notify_event_impl(event);
00109    return true;
00110 }

gint ImageMap::button_press_event_impl GdkEventButton *    event
 

Updates the display when a mouse button is clicked.

Parameters:
event  The information about the click event \

00118 {
00119    DrawingArea::button_press_event_impl(event);
00120    clicked(over_rect, event->button);
00121    return true;
00122 }

gint ImageMap::enter_notify_event_impl GdkEventCrossing *    event
 

Updates the display when the mouse enters the map area.

Parameters:
event  Unused (but required by gtkmm)

00129 {
00130    mouse_in=true;
00131    entered();
00132    DrawingArea::leave_notify_event_impl(event);
00133    return true;
00134 }

gint ImageMap::leave_notify_event_impl GdkEventCrossing *    event
 

Updates the display when the mouse leaves the map area.

Parameters:
event  Unused (but required by gtkmm)

00141 {
00142    if (event==NULL) return false;
00143    if (!DrawingArea::leave_notify_event_impl(event))
00144    mouse_in=false;
00145    me_modified();
00146    return false;
00147 }

virtual bool ImageMap::clicked EntryRect const *   ,
int    button
[pure virtual]
 

Implemented in TreeView.

void ImageMap::hover EntryRect const *    [virtual]
 

00150 {
00151    me_modified();
00152 }

void ImageMap::left   [virtual]
 

00160 {
00161    me_modified();
00162 }

void ImageMap::entered   [virtual]
 

00155 {
00156    me_modified();
00157 }


Member Data Documentation

EntryRect* ImageMap::over_rect [protected]
 

bool ImageMap::mouse_in [protected]
 

std::vector<EntryRect> ImageMap::rectangles [protected]
 


The documentation for this class was generated from the following files:
Generated on Mon Apr 7 19:43:16 2003 for DuTree by doxygen1.2.18