ManaPlus
Public Member Functions | Protected Attributes | Friends
MouseEvent Class Reference

#include <mouseevent.h>

Inheritance diagram for MouseEvent:
InputGuiEvent Event

Public Member Functions

 MouseEvent (Widget *const source, const MouseEventTypeT type, const MouseButtonT button, const int x, const int y, const int clickCount)
 
MouseButtonT getButton () const
 
int getX () const
 
int getY () const
 
int getClickCount () const
 
MouseEventTypeT getType () const
 
void setX (int n)
 
void setY (int n)
 
- Public Member Functions inherited from InputGuiEvent
 InputGuiEvent (Widget *const source)
 
void consume ()
 
bool isConsumed () const
 
- Public Member Functions inherited from Event
 Event (Widget *const source)
 
virtual ~Event ()
 
WidgetgetSource () const
 

Protected Attributes

MouseEventTypeT mType
 
MouseButtonT mButton
 
int mX
 
int mY
 
int mClickCount
 
- Protected Attributes inherited from InputGuiEvent
bool mIsConsumed
 
- Protected Attributes inherited from Event
WidgetmSource
 

Friends

class Gui
 

Detailed Description

Represents a mouse event.

Author
Olof Naessén

Definition at line 79 of file mouseevent.h.

Constructor & Destructor Documentation

◆ MouseEvent()

MouseEvent::MouseEvent ( Widget *const  source,
const MouseEventTypeT  type,
const MouseButtonT  button,
const int  x,
const int  y,
const int  clickCount 
)
inline

Constructor.

Parameters
sourceThe source widget of the mouse event.
typeThe type of the mouse event.
buttonThe button of the mouse event.
xThe x coordinate of the event relative to the source widget.
yThe y coordinate of the event relative the source widget.
clickCountThe number of clicks generated with the same button. It's set to zero if another button is used.

Definition at line 93 of file mouseevent.h.

98  :
99  InputGuiEvent(source),
100  mType(type),
101  mButton(button),
102  mX(x),
103  mY(y),
104  mClickCount(clickCount)
105  {
106  }
InputGuiEvent(Widget *const source)
Definition: inputguievent.h:82
int mClickCount
Definition: mouseevent.h:186
MouseButtonT mButton
Definition: mouseevent.h:170
MouseEventTypeT mType
Definition: mouseevent.h:165

Member Function Documentation

◆ getButton()

MouseButtonT MouseEvent::getButton ( ) const
inline

◆ getClickCount()

int MouseEvent::getClickCount ( ) const
inline

Gets the number of clicks generated with the same button. It's set to zero if another button is used.

Returns
The number of clicks generated with the same button.

Definition at line 144 of file mouseevent.h.

References mClickCount.

Referenced by MailWindow::mouseClicked(), ServerDialog::mouseClicked(), CharacterDisplay::mousePressed(), and ListBox::mouseReleased().

145  { return mClickCount; }
int mClickCount
Definition: mouseevent.h:186

◆ getType()

MouseEventTypeT MouseEvent::getType ( ) const
inline

Gets the type of the event.

Returns
The type of the event.

Definition at line 152 of file mouseevent.h.

References mType.

Referenced by ShopListBox::mouseReleased(), and ItemContainer::mouseReleased().

153  { return mType; }
MouseEventTypeT mType
Definition: mouseevent.h:165

◆ getX()

int MouseEvent::getX ( ) const
inline

Gets the x coordinate of the mouse event. The coordinate relative to widget the mouse listener receiving the events have registered to.

Returns
The x coordinate of the mouse event.
See also
Widget::addMouseListener, Widget::removeMouseListener

Definition at line 124 of file mouseevent.h.

References mX.

Referenced by Viewport::getMouseTile(), Window::getResizeHandles(), ItemShortcutContainer::mouseDragged(), SpellShortcutContainer::mouseDragged(), VirtShortcutContainer::mouseDragged(), OutfitWindow::mouseDragged(), ShortcutWindow::mouseDragged(), Viewport::mouseDragged(), Slider::mouseDragged(), GuiTable::mouseDragged(), ChatWindow::mouseDragged(), Window::mouseDragged(), SpellShortcutContainer::mouseMoved(), ItemShortcutContainer::mouseMoved(), VirtShortcutContainer::mouseMoved(), ItemContainer::mouseMoved(), StaticBrowserBox::mouseMoved(), BrowserBox::mouseMoved(), EmotePage::mousePressed(), OutfitWindow::mousePressed(), WindowMenu::mousePressed(), ItemShortcutContainer::mousePressed(), SpellShortcutContainer::mousePressed(), VirtShortcutContainer::mousePressed(), MiniStatusWindow::mousePressed(), ItemContainer::mousePressed(), StaticBrowserBox::mousePressed(), BrowserBox::mousePressed(), GuiTable::mousePressed(), TextField::mousePressed(), TabbedArea::mousePressed(), TextBox::mousePressed(), OutfitWindow::mouseReleased(), ItemShortcutContainer::mouseReleased(), SpellShortcutContainer::mouseReleased(), VirtShortcutContainer::mouseReleased(), and ItemContainer::mouseReleased().

125  { return mX; }

◆ getY()

int MouseEvent::getY ( ) const
inline

Gets the y coordinate of the mouse event. The coordinate relative to widget the mouse listener receiving the events have registered to.

Returns
The y coordinate of the mouse event.
See also
Widget::addMouseListener, Widget::removeMouseListener

Definition at line 135 of file mouseevent.h.

References mY.

Referenced by Viewport::getMouseTile(), ShortcutWindow::mouseDragged(), Viewport::mouseDragged(), Slider::mouseDragged(), ListBox::mouseDragged(), GuiTable::mouseDragged(), ChatWindow::mouseDragged(), PopupList::mousePressed(), ListBox::mousePressed(), GuiTable::mousePressed(), PopupList::mouseReleased(), ShopListBox::mouseReleased(), ListBox::mouseReleased(), and ListBox::mouseReleased1().

136  { return mY; }

◆ setX()

void MouseEvent::setX ( int  n)
inline

Definition at line 155 of file mouseevent.h.

References mX.

156  { mX = n; }

◆ setY()

void MouseEvent::setY ( int  n)
inline

Definition at line 158 of file mouseevent.h.

References mY.

159  { mY = n; }

Friends And Related Function Documentation

◆ Gui

friend class Gui
friend

Gui is a friend of this class in order to be able to manipulate the protected member variables of this class and at the same time keep the MouseEvent class as const as possible. Gui needs to update the x och y coordinates for the coordinates to be relative to widget the mouse listener receiving the events have registered to.

Definition at line 196 of file mouseevent.h.

Field Documentation

◆ mButton

MouseButtonT MouseEvent::mButton
protected

Holds the button of the mouse event.

Definition at line 170 of file mouseevent.h.

Referenced by getButton().

◆ mClickCount

int MouseEvent::mClickCount
protected

The number of clicks generated with the same button. It's set to zero if another button is used.

Definition at line 186 of file mouseevent.h.

Referenced by getClickCount().

◆ mType

MouseEventTypeT MouseEvent::mType
protected

Holds the type of the mouse event.

Definition at line 165 of file mouseevent.h.

Referenced by getType().

◆ mX

int MouseEvent::mX
protected

Holds the x-coordinate of the mouse event.

Definition at line 175 of file mouseevent.h.

Referenced by getX(), and setX().

◆ mY

int MouseEvent::mY
protected

Holds the y-coordinate of the mouse event.

Definition at line 180 of file mouseevent.h.

Referenced by getY(), and setY().


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