fixed wxMOUSE_BTN_XXX values, use them instead of hard coded constants
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@24076 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -660,10 +660,10 @@ private:
|
|||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
wxMOUSE_BTN_ANY = -1,
|
wxMOUSE_BTN_ANY = -1,
|
||||||
wxMOUSE_BTN_NONE = -1,
|
wxMOUSE_BTN_NONE = 0,
|
||||||
wxMOUSE_BTN_LEFT = 0,
|
wxMOUSE_BTN_LEFT = 1,
|
||||||
wxMOUSE_BTN_MIDDLE = 1,
|
wxMOUSE_BTN_MIDDLE = 2,
|
||||||
wxMOUSE_BTN_RIGHT = 2
|
wxMOUSE_BTN_RIGHT = 3
|
||||||
};
|
};
|
||||||
|
|
||||||
class WXDLLIMPEXP_CORE wxMouseEvent : public wxEvent
|
class WXDLLIMPEXP_CORE wxMouseEvent : public wxEvent
|
||||||
@@ -676,19 +676,19 @@ public:
|
|||||||
// Was it a button event? (*doesn't* mean: is any button *down*?)
|
// Was it a button event? (*doesn't* mean: is any button *down*?)
|
||||||
bool IsButton() const { return Button(wxMOUSE_BTN_ANY); }
|
bool IsButton() const { return Button(wxMOUSE_BTN_ANY); }
|
||||||
|
|
||||||
// Was it a down event from button 1, 2 or 3 or any?
|
// Was it a down event from this (or any) button?
|
||||||
bool ButtonDown(int but = wxMOUSE_BTN_ANY) const;
|
bool ButtonDown(int but = wxMOUSE_BTN_ANY) const;
|
||||||
|
|
||||||
// Was it a dclick event from button 1, 2 or 3 or any?
|
// Was it a dclick event from this (or any) button?
|
||||||
bool ButtonDClick(int but = wxMOUSE_BTN_ANY) const;
|
bool ButtonDClick(int but = wxMOUSE_BTN_ANY) const;
|
||||||
|
|
||||||
// Was it a up event from button 1, 2 or 3 or any?
|
// Was it a up event from this (or any) button?
|
||||||
bool ButtonUp(int but = wxMOUSE_BTN_ANY) const;
|
bool ButtonUp(int but = wxMOUSE_BTN_ANY) const;
|
||||||
|
|
||||||
// Was the given button 1,2,3 or any changing state?
|
// Was the given button?
|
||||||
bool Button(int but) const;
|
bool Button(int but) const;
|
||||||
|
|
||||||
// Was the given button 1,2,3 or any in Down state?
|
// Was the given button in Down state?
|
||||||
bool ButtonIsDown(int but) const;
|
bool ButtonIsDown(int but) const;
|
||||||
|
|
||||||
// Get the button which is changing state (wxMOUSE_BTN_NONE if none)
|
// Get the button which is changing state (wxMOUSE_BTN_NONE if none)
|
||||||
|
@@ -541,84 +541,103 @@ void wxMouseEvent::Assign(const wxMouseEvent& event)
|
|||||||
m_linesPerAction = event.m_linesPerAction;
|
m_linesPerAction = event.m_linesPerAction;
|
||||||
}
|
}
|
||||||
|
|
||||||
// True if was a button dclick event (1 = left, 2 = middle, 3 = right)
|
// return true if was a button dclick event
|
||||||
// or any button dclick event (but = -1)
|
|
||||||
bool wxMouseEvent::ButtonDClick(int but) const
|
bool wxMouseEvent::ButtonDClick(int but) const
|
||||||
{
|
{
|
||||||
switch (but)
|
switch (but)
|
||||||
{
|
{
|
||||||
case -1:
|
|
||||||
return (LeftDClick() || MiddleDClick() || RightDClick());
|
|
||||||
case 1:
|
|
||||||
return LeftDClick();
|
|
||||||
case 2:
|
|
||||||
return MiddleDClick();
|
|
||||||
case 3:
|
|
||||||
return RightDClick();
|
|
||||||
default:
|
default:
|
||||||
wxFAIL_MSG(wxT("invalid parameter in wxMouseEvent::ButtonDClick"));
|
wxFAIL_MSG(wxT("invalid parameter in wxMouseEvent::ButtonDClick"));
|
||||||
|
// fall through
|
||||||
|
|
||||||
|
case wxMOUSE_BTN_ANY:
|
||||||
|
return (LeftDClick() || MiddleDClick() || RightDClick());
|
||||||
|
|
||||||
|
case wxMOUSE_BTN_LEFT:
|
||||||
|
return LeftDClick();
|
||||||
|
|
||||||
|
case wxMOUSE_BTN_MIDDLE:
|
||||||
|
return MiddleDClick();
|
||||||
|
|
||||||
|
case wxMOUSE_BTN_RIGHT:
|
||||||
|
return RightDClick();
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// True if was a button down event (1 = left, 2 = middle, 3 = right)
|
// return true if was a button down event
|
||||||
// or any button down event (but = -1)
|
|
||||||
bool wxMouseEvent::ButtonDown(int but) const
|
bool wxMouseEvent::ButtonDown(int but) const
|
||||||
{
|
{
|
||||||
switch (but)
|
switch (but)
|
||||||
{
|
{
|
||||||
case -1:
|
|
||||||
return (LeftDown() || MiddleDown() || RightDown());
|
|
||||||
case 1:
|
|
||||||
return LeftDown();
|
|
||||||
case 2:
|
|
||||||
return MiddleDown();
|
|
||||||
case 3:
|
|
||||||
return RightDown();
|
|
||||||
default:
|
default:
|
||||||
wxFAIL_MSG(wxT("invalid parameter in wxMouseEvent::ButtonDown"));
|
wxFAIL_MSG(wxT("invalid parameter in wxMouseEvent::ButtonDown"));
|
||||||
|
// fall through
|
||||||
|
|
||||||
|
case wxMOUSE_BTN_ANY:
|
||||||
|
return (LeftDown() || MiddleDown() || RightDown());
|
||||||
|
|
||||||
|
case wxMOUSE_BTN_LEFT:
|
||||||
|
return LeftDown();
|
||||||
|
|
||||||
|
case wxMOUSE_BTN_MIDDLE:
|
||||||
|
return MiddleDown();
|
||||||
|
|
||||||
|
case wxMOUSE_BTN_RIGHT:
|
||||||
|
return RightDown();
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// True if was a button up event (1 = left, 2 = middle, 3 = right)
|
// return true if was a button up event
|
||||||
// or any button up event (but = -1)
|
|
||||||
bool wxMouseEvent::ButtonUp(int but) const
|
bool wxMouseEvent::ButtonUp(int but) const
|
||||||
{
|
{
|
||||||
switch (but)
|
switch (but)
|
||||||
{
|
{
|
||||||
case -1:
|
|
||||||
return (LeftUp() || MiddleUp() || RightUp());
|
|
||||||
case 1:
|
|
||||||
return LeftUp();
|
|
||||||
case 2:
|
|
||||||
return MiddleUp();
|
|
||||||
case 3:
|
|
||||||
return RightUp();
|
|
||||||
default:
|
default:
|
||||||
wxFAIL_MSG(wxT("invalid parameter in wxMouseEvent::ButtonUp"));
|
wxFAIL_MSG(wxT("invalid parameter in wxMouseEvent::ButtonUp"));
|
||||||
|
// fall through
|
||||||
|
|
||||||
|
case wxMOUSE_BTN_ANY:
|
||||||
|
return (LeftUp() || MiddleUp() || RightUp());
|
||||||
|
|
||||||
|
case wxMOUSE_BTN_LEFT:
|
||||||
|
return LeftUp();
|
||||||
|
|
||||||
|
case wxMOUSE_BTN_MIDDLE:
|
||||||
|
return MiddleUp();
|
||||||
|
|
||||||
|
case wxMOUSE_BTN_RIGHT:
|
||||||
|
return RightUp();
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// True if the given button is currently changing state
|
// return true if the given button is currently changing state
|
||||||
bool wxMouseEvent::Button(int but) const
|
bool wxMouseEvent::Button(int but) const
|
||||||
{
|
{
|
||||||
switch (but)
|
switch (but)
|
||||||
{
|
{
|
||||||
case -1:
|
|
||||||
return (ButtonUp(-1) || ButtonDown(-1) || ButtonDClick(-1));
|
|
||||||
case 1:
|
|
||||||
return (LeftDown() || LeftUp() || LeftDClick());
|
|
||||||
case 2:
|
|
||||||
return (MiddleDown() || MiddleUp() || MiddleDClick());
|
|
||||||
case 3:
|
|
||||||
return (RightDown() || RightUp() || RightDClick());
|
|
||||||
default:
|
default:
|
||||||
wxFAIL_MSG(wxT("invalid parameter in wxMouseEvent::Button"));
|
wxFAIL_MSG(wxT("invalid parameter in wxMouseEvent::Button"));
|
||||||
|
// fall through
|
||||||
|
|
||||||
|
case wxMOUSE_BTN_ANY:
|
||||||
|
return ButtonUp(wxMOUSE_BTN_ANY) ||
|
||||||
|
ButtonDown(wxMOUSE_BTN_ANY) ||
|
||||||
|
ButtonDClick(wxMOUSE_BTN_ANY);
|
||||||
|
|
||||||
|
case wxMOUSE_BTN_LEFT:
|
||||||
|
return LeftDown() || LeftUp() || LeftDClick();
|
||||||
|
|
||||||
|
case wxMOUSE_BTN_MIDDLE:
|
||||||
|
return MiddleDown() || MiddleUp() || MiddleDClick();
|
||||||
|
|
||||||
|
case wxMOUSE_BTN_RIGHT:
|
||||||
|
return RightDown() || RightUp() || RightDClick();
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
@@ -628,16 +647,21 @@ bool wxMouseEvent::ButtonIsDown(int but) const
|
|||||||
{
|
{
|
||||||
switch (but)
|
switch (but)
|
||||||
{
|
{
|
||||||
case -1:
|
|
||||||
return (LeftIsDown() || MiddleIsDown() || RightIsDown());
|
|
||||||
case 1:
|
|
||||||
return LeftIsDown();
|
|
||||||
case 2:
|
|
||||||
return MiddleIsDown();
|
|
||||||
case 3:
|
|
||||||
return RightIsDown();
|
|
||||||
default:
|
default:
|
||||||
wxFAIL_MSG(wxT("invalid parameter in wxMouseEvent::ButtonIsDown"));
|
wxFAIL_MSG(wxT("invalid parameter in wxMouseEvent::ButtonIsDown"));
|
||||||
|
// fall through
|
||||||
|
|
||||||
|
case wxMOUSE_BTN_ANY:
|
||||||
|
return LeftIsDown() || MiddleIsDown() || RightIsDown();
|
||||||
|
|
||||||
|
case wxMOUSE_BTN_LEFT:
|
||||||
|
return LeftIsDown();
|
||||||
|
|
||||||
|
case wxMOUSE_BTN_MIDDLE:
|
||||||
|
return MiddleIsDown();
|
||||||
|
|
||||||
|
case wxMOUSE_BTN_RIGHT:
|
||||||
|
return RightIsDown();
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
@@ -653,7 +677,7 @@ int wxMouseEvent::GetButton() const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return -1;
|
return wxMOUSE_BTN_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Find the logical position of the event given the DC
|
// Find the logical position of the event given the DC
|
||||||
|
Reference in New Issue
Block a user