* NEW: Now Mouse class gives mouse buttons and modifiers.



git-svn-id: svn://localhost/gambas/trunk@3728 867c0c6c-44f3-4631-809d-bfa615b0a4ec
This commit is contained in:
Laurent Carlier 2011-04-02 17:28:48 +00:00
parent 63c56db5d4
commit 9e7b057eb9
3 changed files with 80 additions and 0 deletions

View file

@ -119,12 +119,14 @@ END_PROPERTY
BEGIN_PROPERTY(CMOUSE_x)
CHECK_VALID()
GB.ReturnInteger(CMOUSE_info.x);
END_PROPERTY
BEGIN_PROPERTY(CMOUSE_y)
CHECK_VALID()
GB.ReturnInteger(CMOUSE_info.y);
END_PROPERTY
@ -143,6 +145,69 @@ BEGIN_PROPERTY(CMOUSE_starty)
END_PROPERTY
BEGIN_PROPERTY(CMOUSE_left)
CHECK_VALID()
GB.ReturnBoolean(CMOUSE_info.state == SDL_BUTTON_LEFT);
END_PROPERTY
BEGIN_PROPERTY(CMOUSE_right)
CHECK_VALID()
GB.ReturnBoolean(CMOUSE_info.state == SDL_BUTTON_RIGHT);
END_PROPERTY
BEGIN_PROPERTY(CMOUSE_middle)
CHECK_VALID()
GB.ReturnBoolean(CMOUSE_info.state == SDL_BUTTON_MIDDLE);
END_PROPERTY
BEGIN_PROPERTY(CMOUSE_button)
CHECK_VALID()
GB.ReturnInteger(CMOUSE_info.state);
END_PROPERTY
BEGIN_PROPERTY(CMOUSE_shift)
CHECK_VALID()
GB.ReturnBoolean(CMOUSE_info.keymod & KMOD_SHIFT);
END_PROPERTY
BEGIN_PROPERTY(CMOUSE_control)
CHECK_VALID()
GB.ReturnBoolean(CMOUSE_info.keymod & KMOD_CTRL);
END_PROPERTY
BEGIN_PROPERTY(CMOUSE_alt)
CHECK_VALID()
GB.ReturnBoolean(CMOUSE_info.keymod & KMOD_ALT);
END_PROPERTY
BEGIN_PROPERTY(CMOUSE_meta)
CHECK_VALID()
GB.ReturnBoolean(CMOUSE_info.keymod & KMOD_META);
END_PROPERTY
BEGIN_PROPERTY(CMOUSE_normal)
CHECK_VALID()
GB.ReturnBoolean(CMOUSE_info.keymod < KMOD_NUM);
END_PROPERTY
/***************************************************************************/
GB_DESC CCursor[] =
@ -171,6 +236,16 @@ GB_DESC CMouse[] =
GB_STATIC_PROPERTY_READ("X", "i", CMOUSE_x),
GB_STATIC_PROPERTY_READ("Y", "i", CMOUSE_y),
GB_STATIC_PROPERTY_READ("Left", "b", CMOUSE_left),
GB_STATIC_PROPERTY_READ("Right", "b", CMOUSE_right),
GB_STATIC_PROPERTY_READ("Middle", "b", CMOUSE_middle),
GB_STATIC_PROPERTY_READ("Button", "i", CMOUSE_button),
GB_STATIC_PROPERTY_READ("Shift", "b", CMOUSE_shift),
GB_STATIC_PROPERTY_READ("Control", "b", CMOUSE_control),
GB_STATIC_PROPERTY_READ("Alt", "b", CMOUSE_alt),
GB_STATIC_PROPERTY_READ("Meta", "b", CMOUSE_meta),
GB_STATIC_PROPERTY_READ("Normal", "b", CMOUSE_normal),
GB_CONSTANT("Default", "i", SDL::DefaultCursor),
GB_CONSTANT("Custom", "i", SDL::CustomCursor),
GB_CONSTANT("Blank", "i", SDL::BlankCursor),

View file

@ -37,6 +37,7 @@ typedef
int relx;
int rely;
int state;
SDLMod keymod;
}
CMOUSE_INFO;

View file

@ -451,6 +451,8 @@ void myWin::MouseButtonEvent(SDL_MouseButtonEvent *mouseEvent)
CMOUSE_info.valid = true;
CMOUSE_info.x = mouseEvent->x;
CMOUSE_info.y = mouseEvent->y;
CMOUSE_info.state = mouseEvent->button;
CMOUSE_info.keymod = SDL_GetModState();
if (mouseEvent->type == SDL_MOUSEBUTTONDOWN)
GB.Raise(hWindow, EVENT_MouseDown,0);
@ -473,6 +475,8 @@ void myWin::MouseMotionEvent(SDL_MouseMotionEvent *mouseEvent)
CMOUSE_info.valid = true;
CMOUSE_info.x = mouseEvent->x;
CMOUSE_info.y = mouseEvent->y;
CMOUSE_info.state = mouseEvent->state;
CMOUSE_info.keymod = SDL_GetModState();
GB.Raise(hWindow, EVENT_MouseMove,0);
CMOUSE_info.valid = false;
}