Laxkit  0.0.7.1
Classes | Public Member Functions | Private Member Functions | Private Attributes
Laxkit::ButtonDownInfo Class Reference

Class to simplify keeping track of what buttons have been pressed. More...

List of all members.

Classes

class  ButtonDownInfoSpecific

Public Member Functions

void clear ()
 Flush any collected info.
void down (int device_id, int button_id, int x=0, int y=0, int i1=0, int i2=0, anObject *e=NULL, int absorb=0)
 Set up to remember that button_id has been pressed on device_id.
int move (int device_id, int x=0, int y=0, int *lastx=NULL, int *lasty=NULL)
 Updates any position tracking, for any button for the given device.
void moveinfo (int device_id, int button_id, int i1, int i2=0, int *oldi1=NULL, int *oldi2=NULL)
 Updates any extra info.
int up (int device_id, int button_id, int *i1=NULL, int *i2=NULL)
 Button has come up, so remove tracking of it.
int any (int device_id=0, int button_id=0, int *device=NULL)
 Return how many of the device id are down for that button, else return 0.
int whichdown (int afterthis, int button_id=0)
 Return the device id of the mouse that is down.
int isdown (int device_id, int button_id, int *i1=NULL, int *i2=NULL)
 Return 1 if button_id of device_id is logged as down, else return 0.
int isdragged (int device_id, int button_id)
 Return whether the device has been dragged since tracking the button.
int average (int button_id, int *xavg, int *yavg)
 Find the average position of all devices with button_id down.
int getextrainfo (int device_id, int button_id, int *i1=NULL, int *i2=NULL)
 Get only the extra info1 and info2 for a button press.
int getinitial (int device_id, int button_id, int *x0, int *y0)
 Get initial info for a button press.
int getlast (int device_id, int button_id, int *xp, int *yp)
 Get previous position info for a button press.
int getcurrent (int device_id, int button_id, int *xp, int *yp)
 Get current position info for a button press.
int getinfo (int device_id, int button_id, int *x0, int *y0, int *xp, int *yp, int *xc, int *yc, int *i1=NULL, int *i2=NULL)
 Get current info for a button press.
anObjectgetextra (int device_id, int button_id)
 Return the extra data if any from the info.
int replaceextra (int device_id, int button_id, anObject *e, int absorbcount)
 Replace arbitrary extra info of a device/button combination.

Private Member Functions

ButtonDownInfoSpecificexists (int d, int b)
 Return the info object for a device and button that already exists.

Private Attributes

ButtonDownInfoSpecificinfo

Detailed Description

Class to simplify keeping track of what buttons have been pressed.

Typically, windows will have their own instance of one of these classes to track what's been pressed in itself.

The data stored is not necessarily related to LaxDevice buttons. You can keep track of anything identified with any integer. You can store arbitrary data, as long as it is contained in an object derived from anObject.

When up() is called, it returns a rough approximation of how much the position has been dragged. If the position changes at all, then this drag value will be 1 or more.


Member Function Documentation

int Laxkit::ButtonDownInfo::any ( int  device_id = 0,
int  button_id = 0,
int device = NULL 
)

Return how many of the device id are down for that button, else return 0.

If device_id==0 and button_id!=0, then return how many of any device is down for that button. If device_id!=0 and button_id==0, then return how many buttons are down on that device. If button_id!=0 and device_id!=0, then return 1 if that device has that button down. If button_id==0 and device_id==0, then return the total number of button-device combinations are active.

If device!=NULL, then return the id of the first device that satisfies the above. If there is no such device, then device does not get assigned anything.

Referenced by Laxkit::ColorBox::CharInput(), Laxkit::SplitWindow::Event(), Laxkit::Scroller::Idle(), LaxInterfaces::RectInterface::KeyUp(), Laxkit::ColorBox::LBDown(), LaxInterfaces::GradientInterface::LBDown(), LaxInterfaces::RectInterface::LBDown(), Laxkit::ColorBox::MBDown(), Laxkit::ColorBox::MouseMove(), Laxkit::Scroller::MouseMove(), Laxkit::MessageBar::MouseMove(), Laxkit::SplitWindow::MouseMove(), LaxInterfaces::RectInterface::MouseMove(), Laxkit::CurveWindow::MouseMove(), Laxkit::MenuSelector::MouseMove(), Laxkit::TreeSelector::MouseMove(), Laxkit::ColorBox::RBDown(), Laxkit::SplitWindow::RBDown(), Laxkit::Scroller::RBUp(), Laxkit::ButtonBase::State(), Laxkit::Scroller::WheelDown(), and Laxkit::Scroller::WheelUp().

int Laxkit::ButtonDownInfo::average ( int  button_id,
int xavg,
int yavg 
)

Find the average position of all devices with button_id down.

Returns the number of devices with button_id down.

If button_id<0 then average all current position info.

Referenced by Laxkit::MessageBar::MouseMove().

void Laxkit::ButtonDownInfo::down ( int  device_id,
int  button_id,
int  x = 0,
int  y = 0,
int  i1 = 0,
int  i2 = 0,
anObject e = NULL,
int  absorb = 0 
)
int Laxkit::ButtonDownInfo::getcurrent ( int  device_id,
int  button_id,
int xc,
int yc 
)

Get current position info for a button press.

Return 0 for info found, or nonzero for error.

Parameters:
xcCurrent x
ycCurrent y

References exists().

Referenced by LaxInterfaces::RectInterface::MouseMove(), and LaxInterfaces::PathInterface::Refresh().

anObject * Laxkit::ButtonDownInfo::getextra ( int  device_id,
int  button_id 
)

Return the extra data if any from the info.

This does nothing to extra's count. If you intend to keep it beyond the buttoninfo, then you must increment the count.

References exists().

int Laxkit::ButtonDownInfo::getextrainfo ( int  device_id,
int  button_id,
int i1 = NULL,
int i2 = NULL 
)

Get only the extra info1 and info2 for a button press.

Return 0 for info found, or nonzero for error.

References exists().

Referenced by Laxkit::Scroller::Idle(), Laxkit::Scroller::LBDown(), LaxInterfaces::RectInterface::MouseMove(), Laxkit::CurveWindow::MouseMove(), Laxkit::TreeSelector::MouseMove(), and LaxInterfaces::PathInterface::MouseMove().

int Laxkit::ButtonDownInfo::getinfo ( int  device_id,
int  button_id,
int x0,
int y0,
int xp,
int yp,
int xc,
int yc,
int i1 = NULL,
int i2 = NULL 
)

Get current info for a button press.

Return 0 for info found, or nonzero for error.

Parameters:
x0Initial x
y0Initial y
xpLast x
ypLast y
xcCurrent x
ycCurrent y
i1Extra info 1
i2Extra info 2

References exists().

Referenced by Laxkit::ColorBox::MouseMove(), Laxkit::Scroller::MouseMove(), Laxkit::BoxSelector::MouseMove(), and Laxkit::Scroller::RBUp().

int Laxkit::ButtonDownInfo::getinitial ( int  device_id,
int  button_id,
int x0,
int y0 
)

Get initial info for a button press.

Return 0 for info found, or nonzero for error.

Parameters:
x0Initial x
y0Initial y

References exists().

Referenced by LaxInterfaces::ViewportWindow::MouseMove(), LaxInterfaces::RectInterface::MouseMove(), LaxInterfaces::PathInterface::MouseMove(), and LaxInterfaces::PathInterface::Refresh().

int Laxkit::ButtonDownInfo::getlast ( int  device_id,
int  button_id,
int xp,
int yp 
)

Get previous position info for a button press.

Return 0 for info found, or nonzero for error.

Parameters:
xpPrevious x
ypPrevious y

References exists().

int Laxkit::ButtonDownInfo::isdown ( int  device_id,
int  button_id,
int i1 = NULL,
int i2 = NULL 
)

Return 1 if button_id of device_id is logged as down, else return 0.

If device_id==0, then return the number of devices that say that button is down.

If device_id!=0 and i1 or i2 are not NULL, then also return the info1 and info2 for that button on that device. Otherwise i1 and i2 are not changed.

References exists().

Referenced by Laxkit::ColorBox::CharInput(), LaxInterfaces::ViewportWindow::CharInput(), Laxkit::ButtonBase::Event(), Laxkit::BoxSelector::Event(), Laxkit::ButtonBase::LBDown(), LaxInterfaces::ImageInterface::LBDown(), Laxkit::BoxSelector::LBDown(), Laxkit::SplitWindow::LBDown(), LaxInterfaces::PathInterface::LBDown(), Laxkit::MultiLineEdit::LBUp(), Laxkit::ButtonBase::LBUp(), LaxInterfaces::CaptionInterface::LBUp(), Laxkit::BoxSelector::LBUp(), Laxkit::SplitWindow::LBUp(), LaxInterfaces::GradientInterface::LBUp(), Laxkit::MenuSelector::LBUp(), Laxkit::TreeSelector::LBUp(), LaxInterfaces::ViewportWindow::MBUp(), Laxkit::DateSelector::MouseMove(), Laxkit::MultiLineEdit::MouseMove(), Laxkit::ColorBox::MouseMove(), Laxkit::LineEdit::MouseMove(), Laxkit::Scroller::MouseMove(), Laxkit::PaletteWindow::MouseMove(), Laxkit::BoxSelector::MouseMove(), Laxkit::SplitWindow::MouseMove(), LaxInterfaces::ViewportWindow::MouseMove(), LaxInterfaces::RectInterface::MouseMove(), LaxInterfaces::PointWarpInterface::MouseMove(), Laxkit::MenuSelector::MouseMove(), Laxkit::TreeSelector::MouseMove(), LaxInterfaces::PatchInterface::MouseMove(), LaxInterfaces::PathInterface::MouseMove(), Laxkit::MultiLineEdit::RBUp(), Laxkit::Scroller::RBUp(), Laxkit::MenuSelector::RBUp(), and Laxkit::TreeSelector::RBUp().

int Laxkit::ButtonDownInfo::move ( int  device_id,
int  x = 0,
int  y = 0,
int lastx = NULL,
int lasty = NULL 
)

Updates any position tracking, for any button for the given device.

Please note that if you are looking for lastx and lasty, it might return those coordinates from any button press, maybe not the button you were looking for.

Returns whether the mouse is considered to have been dragged yet. This will be very approximately the maximum distance the mouse was from the initial point.

Referenced by Laxkit::DateSelector::MouseMove(), Laxkit::MultiLineEdit::MouseMove(), Laxkit::ColorBox::MouseMove(), Laxkit::Scroller::MouseMove(), Laxkit::MessageBar::MouseMove(), Laxkit::SplitWindow::MouseMove(), LaxInterfaces::ViewportWindow::MouseMove(), LaxInterfaces::RectInterface::MouseMove(), Laxkit::CurveWindow::MouseMove(), Laxkit::TreeSelector::MouseMove(), and LaxInterfaces::PathInterface::MouseMove().

void Laxkit::ButtonDownInfo::moveinfo ( int  device_id,
int  button_id,
int  i1,
int  i2 = 0,
int oldi1 = NULL,
int oldi2 = NULL 
)

Updates any extra info.

If button_id==0 then affect any button for the given device. If device_id==0 then affect any device with the given button down.

If oldi1 or oldi2 are not NULL, then set with the old info.

Referenced by LaxInterfaces::PathInterface::LBDown(), Laxkit::BoxSelector::MouseMove(), LaxInterfaces::RectInterface::MouseMove(), and LaxInterfaces::PathInterface::MouseMove().

int Laxkit::ButtonDownInfo::replaceextra ( int  device_id,
int  button_id,
anObject e,
int  absorbcount 
)

Replace arbitrary extra info of a device/button combination.

If the device+button does not exist, then nothing is done, and 1 is returned. Otherwise e replaces any extra data (if any), and 0 is returned.

If absorbcount, then absorb e's count, otherwise, its count will be incremented. The old data will have its count decremented.

If e==NULL, then any old data is removed, and NULL replaces it.

References Laxkit::anObject::dec_count(), exists(), and Laxkit::anObject::inc_count().

int Laxkit::ButtonDownInfo::up ( int  device_id,
int  button_id,
int i1 = NULL,
int i2 = NULL 
)
int Laxkit::ButtonDownInfo::whichdown ( int  afterthis,
int  button_id = 0 
)

Return the device id of the mouse that is down.

If afterthis!=0, then search for any devices down AFTER the device with device id == afterthis. This allows enumerating all devices listed as down.

If button_id!=0, then search only for this kind.

Returns 0 if none down.

To find a device for a specific id or button, see any().

Todo:
this fails when many buttons are down for the same device...

Referenced by Laxkit::Scroller::Idle(), and LaxInterfaces::RectInterface::MouseMove().


The documentation for this class was generated from the following files:

Mon Feb 17 2014 11:52:59, Laxkit