Main Page | Namespace List | Class Hierarchy | Alphabetical List | Data Structures | File List | Namespace Members | Data Fields | Globals

Ars::XToolTip Class Reference

#include <arstooltip.h>

Inheritance diagram for Ars::XToolTip:

Inheritance graph
[legend]
Collaboration diagram for Ars::XToolTip:

Collaboration graph
[legend]

Public Member Functions

 XToolTip (Window *pToolWindow, const int aNrMSec=1000)
virtual ~XToolTip (void)
 Standard destructor.

virtual const bool SetupWindow (const Message &msg)
 Deregister the setup_window message.

virtual void SetWndText (const std::string &sText)
void ShowTip (const XPoint &DrawPoint)
void HideTip (void)
 Hides the tooltip.

virtual const bool SetParent (Window *pNewParent)
virtual WindowGetParent (void) const

Protected Member Functions

virtual const bool evMouseMove (const MouseMessage &msg)
virtual const bool evTimer (const CtrlMessage &msg)

Private Attributes

Timertimer
 A pointer to a timer so that tooltips only appear after the mouse has been motionless for a bit.

XPoint lastMousePosition
 The last mouse position.

Windowtarget
const int nrMSec

Detailed Description

A tooltip that can pop up over windows They are attached to an existing CWindow object, and watch for the mouse cursor to stop over the object. When the cursor stops, the tooltip makes itself visible.

Definition at line 9 of file arstooltip.h.


Constructor & Destructor Documentation

Ars::XToolTip::XToolTip Window pToolWindow,
const int  aNrMSec = 1000
 

Construct a new label

Parameters:
pToolWindow A pointer to the CWindow based object the tooltip is for

Definition at line 5 of file arstooltip.cpp.

References SetParent(), and timer.

00006 : nrMSec( aNrMSec )
00007 {
00008         SetParent( pToolWindow );
00009         timer = new Timer( this );
00010 }

Ars::XToolTip::~XToolTip void   )  [virtual]
 

Standard destructor.

Definition at line 13 of file arstooltip.cpp.

References timer.

00014 {
00015         if( timer )
00016                 delete timer;
00017         timer = 0;
00018 }


Member Function Documentation

const bool Ars::XToolTip::evMouseMove const MouseMessage msg  )  [protected, virtual]
 

Reimplemented from Ars::XLabel.

Definition at line 70 of file arstooltip.cpp.

References Ars::Window::FindWindow(), Ars::Window::GetParent(), GetParent(), HideTip(), Ars::Window::IsVisible(), lastMousePosition, nrMSec, Ars::MouseMessage::Point, Ars::Timer::StartTimer(), Ars::Timer::StopTimer(), and timer.

00071 {
00072         if( GetParent()->GetParent() )
00073         {
00074                 lastMousePosition = msg.Point;
00075                 timer->StopTimer();
00076                 if( IsVisible() )
00077                         HideTip();
00078 
00079                 if( GetParent()->FindWindow( &msg.Point ) == GetParent() )
00080                         timer->StartTimer( nrMSec );
00081         }
00082         return XLabel::evMouseMove( msg );
00083 }

const bool Ars::XToolTip::evTimer const CtrlMessage msg  )  [protected, virtual]
 

Reimplemented from Ars::MessageClient.

Definition at line 58 of file arstooltip.cpp.

References Ars::Message::Destination(), lastMousePosition, and ShowTip().

00059 {
00060         bool ans = XLabel::evTimer( msg );
00061 
00062         if( msg.Destination() == this )
00063         {
00064                 ShowTip( lastMousePosition + XPoint( -6 , 18 ) );
00065                 ans = true;
00066         }
00067         return ans;
00068 }

virtual Window* Ars::XToolTip::GetParent void   )  const [inline, virtual]
 

Reimplemented from Ars::Window.

Definition at line 41 of file arstooltip.h.

References target.

Referenced by evMouseMove(), and ShowTip().

00041 {       return target;  }

void Ars::XToolTip::HideTip void   ) 
 

Hides the tooltip.

Definition at line 52 of file arstooltip.cpp.

References Ars::Window::HideWindow(), and Ars::Window::UpdateWindow().

Referenced by evMouseMove(), and SetupWindow().

00053 {
00054         HideWindow();
00055         UpdateWindow( true );
00056 }

virtual const bool Ars::XToolTip::SetParent Window pNewParent  )  [inline, virtual]
 

Transfer the ownership of the window, so it has a new parent

Parameters:
pNewParent A pointer to a window that should be set as the parent

Reimplemented from Ars::Window.

Definition at line 40 of file arstooltip.h.

References target.

Referenced by XToolTip().

00040 {       target = pNewParent;    return true;    }

const bool Ars::XToolTip::SetupWindow const Message msg  )  [virtual]
 

Deregister the setup_window message.

Reimplemented from Ars::XLabel.

Definition at line 20 of file arstooltip.cpp.

References HideTip().

Referenced by Ars::Window::SetupWindow().

00021 {
00022         XLabel::SetupWindow( msg );
00023 
00024         MessageServer::Instance().RegisterMessageClient(this, Message::MOUSE_MOVE);
00025         MessageServer::Instance().RegisterMessageClient(this, Message::CTRL_TIMER);
00026 
00027         HideTip();
00028 
00029         return true;
00030 }

void Ars::XToolTip::SetWndText const std::string &  sText  )  [virtual]
 

Set the WindowText of the control

Parameters:
sText The text to assign to the window

Reimplemented from Ars::XLabel.

Definition at line 32 of file arstooltip.cpp.

References Ars::Window::clientRect, Ars::HPaint::GetFontSize(), Ars::HPaint::GetTextSize(), Ars::Window::GetWindowText(), Ars::XPoint::x, and Ars::XPoint::y.

00033 {
00034         XLabel::SetWndText( sText );
00035         XPoint  p = GetTextSize( GetWindowText() );
00036         clientRect.w = w = p.x + 4;
00037         clientRect.h = h = p.y + GetFontSize();
00038 }

void Ars::XToolTip::ShowTip const XPoint DrawPoint  ) 
 

Displays the tooltip

Parameters:
DrawPoint Where to poisition the top left corner of the tooltip

Definition at line 40 of file arstooltip.cpp.

References GetParent(), Ars::Window::IsVisible(), Ars::Window::ShowWindow(), Ars::Window::UpdateWindow(), Ars::XPoint::x, and Ars::XPoint::y.

Referenced by evTimer().

00041 {
00042         if( GetParent()->IsVisible() )
00043         {
00044                 x = p.x;
00045                 y = p.y;
00046                 ShowWindow();
00047                 UpdateWindow( true );
00048         }
00049 }


Field Documentation

XPoint Ars::XToolTip::lastMousePosition [private]
 

The last mouse position.

Definition at line 13 of file arstooltip.h.

Referenced by evMouseMove(), and evTimer().

const int Ars::XToolTip::nrMSec [private]
 

Definition at line 15 of file arstooltip.h.

Referenced by evMouseMove().

Window* Ars::XToolTip::target [private]
 

Definition at line 14 of file arstooltip.h.

Referenced by GetParent(), and SetParent().

Timer* Ars::XToolTip::timer [private]
 

A pointer to a timer so that tooltips only appear after the mouse has been motionless for a bit.

Definition at line 12 of file arstooltip.h.

Referenced by evMouseMove(), XToolTip(), and ~XToolTip().


The documentation for this class was generated from the following files:
Generated on Fri Dec 5 04:07:05 2003 for Borqueror by doxygen 1.3.3