Laxkit
0.0.7.1
|
Class to simplify keeping track of what buttons have been pressed. More...
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. | |
anObject * | getextra (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 | |
ButtonDownInfoSpecific * | exists (int d, int b) |
Return the info object for a device and button that already exists. |
Private Attributes | |
ButtonDownInfoSpecific * | info |
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.
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().
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 |
||
) |
Set up to remember that button_id has been pressed on device_id.
If the button/id combo is already there, then simply replace all the old info with the new.
References Laxkit::anObject::dec_count(), exists(), and Laxkit::anObject::inc_count().
Referenced by LaxInterfaces::ViewportWindow::CharInput(), LaxInterfaces::RectInterface::FakeLBDown(), Laxkit::MultiLineEdit::LBDown(), Laxkit::ColorBox::LBDown(), Laxkit::LineEdit::LBDown(), Laxkit::ButtonBase::LBDown(), Laxkit::Scroller::LBDown(), LaxInterfaces::CaptionInterface::LBDown(), Laxkit::PaletteWindow::LBDown(), LaxInterfaces::ImageInterface::LBDown(), Laxkit::BoxSelector::LBDown(), Laxkit::SplitWindow::LBDown(), LaxInterfaces::EngraverFillInterface::LBDown(), LaxInterfaces::ViewportWindow::LBDown(), LaxInterfaces::GradientInterface::LBDown(), LaxInterfaces::RectInterface::LBDown(), Laxkit::MenuSelector::LBDown(), Laxkit::TreeSelector::LBDown(), LaxInterfaces::PathInterface::LBDown(), Laxkit::ColorBox::MBDown(), LaxInterfaces::ViewportWindow::MBDown(), Laxkit::BoxSelector::MouseMove(), Laxkit::MultiLineEdit::RBDown(), Laxkit::Scroller::RBDown(), Laxkit::ColorBox::RBDown(), LaxInterfaces::ViewportWindow::RBDown(), Laxkit::MenuSelector::RBDown(), and Laxkit::TreeSelector::RBDown().
Get current position info for a button press.
Return 0 for info found, or nonzero for error.
xc | Current x |
yc | Current y |
References exists().
Referenced by LaxInterfaces::RectInterface::MouseMove(), and LaxInterfaces::PathInterface::Refresh().
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.
x0 | Initial x |
y0 | Initial y |
xp | Last x |
yp | Last y |
xc | Current x |
yc | Current y |
i1 | Extra info 1 |
i2 | Extra info 2 |
References exists().
Referenced by Laxkit::ColorBox::MouseMove(), Laxkit::Scroller::MouseMove(), Laxkit::BoxSelector::MouseMove(), and Laxkit::Scroller::RBUp().
Get initial info for a button press.
Return 0 for info found, or nonzero for error.
x0 | Initial x |
y0 | Initial y |
References exists().
Referenced by LaxInterfaces::ViewportWindow::MouseMove(), LaxInterfaces::RectInterface::MouseMove(), LaxInterfaces::PathInterface::MouseMove(), and LaxInterfaces::PathInterface::Refresh().
Get previous position info for a button press.
Return 0 for info found, or nonzero for error.
xp | Previous x |
yp | Previous 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().
Button has come up, so remove tracking of it.
Returns whether there has been dragging since tracking. This will be very approximately the maximum distance the mouse was from the initial point.
If the button was not down for the device, -1 is returned.
If i1 or i2 are not NULL, then set them to the info1 and info2 for device and button.
Referenced by LaxInterfaces::ViewportWindow::CharInput(), Laxkit::ColorBox::LBDown(), LaxInterfaces::CaptionInterface::LBDown(), LaxInterfaces::ImageInterface::LBDown(), LaxInterfaces::GradientInterface::LBDown(), LaxInterfaces::RectInterface::LBDown(), LaxInterfaces::PathInterface::LBDown(), Laxkit::MultiLineEdit::LBUp(), Laxkit::ButtonBase::LBUp(), LaxInterfaces::CaptionInterface::LBUp(), LaxInterfaces::ImageInterface::LBUp(), Laxkit::BoxSelector::LBUp(), Laxkit::SplitWindow::LBUp(), LaxInterfaces::ViewportWindow::LBUp(), LaxInterfaces::GradientInterface::LBUp(), Laxkit::MenuSelector::LBUp(), Laxkit::TreeSelector::LBUp(), LaxInterfaces::ViewportWindow::MBUp(), Laxkit::MultiLineEdit::RBUp(), Laxkit::Scroller::RBUp(), LaxInterfaces::ViewportWindow::RBUp(), Laxkit::MenuSelector::RBUp(), and Laxkit::TreeSelector::RBUp().
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().
Referenced by Laxkit::Scroller::Idle(), and LaxInterfaces::RectInterface::MouseMove().