MouseEvent.h revision 8e35f3cfc7fba1d1c829dc557ebad6409cbe16a2
1/* 2 * Copyright (C) 2001 Peter Kelly (pmk@post.com) 3 * Copyright (C) 2001 Tobias Anton (anton@stud.fbi.fh-darmstadt.de) 4 * Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com) 5 * Copyright (C) 2003, 2004, 2005, 2006, 2008 Apple Inc. All rights reserved. 6 * 7 * This library is free software; you can redistribute it and/or 8 * modify it under the terms of the GNU Library General Public 9 * License as published by the Free Software Foundation; either 10 * version 2 of the License, or (at your option) any later version. 11 * 12 * This library is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 * Library General Public License for more details. 16 * 17 * You should have received a copy of the GNU Library General Public License 18 * along with this library; see the file COPYING.LIB. If not, write to 19 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 20 * Boston, MA 02110-1301, USA. 21 * 22 */ 23 24#ifndef MouseEvent_h 25#define MouseEvent_h 26 27#include "Clipboard.h" 28#include "EventTargetNode.h" 29#include "MouseRelatedEvent.h" 30 31namespace WebCore { 32 33 // Introduced in DOM Level 2 34 class MouseEvent : public MouseRelatedEvent { 35 public: 36 static PassRefPtr<MouseEvent> create() 37 { 38 return adoptRef(new MouseEvent); 39 } 40 static PassRefPtr<MouseEvent> create(const AtomicString& type, bool canBubble, bool cancelable, PassRefPtr<AbstractView> view, 41 int detail, int screenX, int screenY, int pageX, int pageY, 42 bool ctrlKey, bool altKey, bool shiftKey, bool metaKey, unsigned short button, 43 PassRefPtr<EventTargetNode> relatedTarget, PassRefPtr<Clipboard> clipboard = 0, bool isSimulated = false) 44 { 45 return adoptRef(new MouseEvent(type, canBubble, cancelable, view, detail, screenX, screenY, pageX, pageY, 46 ctrlKey, altKey, shiftKey, metaKey, button, relatedTarget, clipboard, isSimulated)); 47 } 48 virtual ~MouseEvent(); 49 50 void initMouseEvent(const AtomicString& type, bool canBubble, bool cancelable, PassRefPtr<AbstractView>, 51 int detail, int screenX, int screenY, int clientX, int clientY, 52 bool ctrlKey, bool altKey, bool shiftKey, bool metaKey, 53 unsigned short button, PassRefPtr<EventTargetNode> relatedTarget); 54 55 // WinIE uses 1,4,2 for left/middle/right but not for click (just for mousedown/up, maybe others), 56 // but we will match the standard DOM. 57 unsigned short button() const { return m_button; } 58 bool buttonDown() const { return m_buttonDown; } 59 EventTargetNode* relatedTarget() const { return m_relatedTarget.get(); } 60 61 Clipboard* clipboard() const { return m_clipboard.get(); } 62 63 Node* toElement() const; 64 Node* fromElement() const; 65 66 Clipboard* dataTransfer() const { return isDragEvent() ? m_clipboard.get() : 0; } 67 68 virtual bool isMouseEvent() const; 69 virtual bool isDragEvent() const; 70 virtual int which() const; 71 72 private: 73 MouseEvent(); 74 MouseEvent(const AtomicString& type, bool canBubble, bool cancelable, PassRefPtr<AbstractView>, 75 int detail, int screenX, int screenY, int pageX, int pageY, 76 bool ctrlKey, bool altKey, bool shiftKey, bool metaKey, unsigned short button, 77 PassRefPtr<EventTargetNode> relatedTarget, PassRefPtr<Clipboard> clipboard, bool isSimulated); 78 79 unsigned short m_button; 80 bool m_buttonDown; 81 RefPtr<EventTargetNode> m_relatedTarget; 82 RefPtr<Clipboard> m_clipboard; 83 }; 84 85} // namespace WebCore 86 87#endif // MouseEvent_h 88