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