Home | History | Annotate | Download | only in haiku
      1 /*
      2  * Copyright (C) 2007 Ryan Leavengood <leavengood (at) gmail.com>
      3  * Copyright (C) 2009 Maxime Simon <simon.maxime (at) gmail.com>
      4  * Copyright (C) 2010 Stephan Amus <superstippi (at) gmx.de>
      5  *
      6  * All rights reserved.
      7  *
      8  * Redistribution and use in source and binary forms, with or without
      9  * modification, are permitted provided that the following conditions
     10  * are met:
     11  * 1. Redistributions of source code must retain the above copyright
     12  *    notice, this list of conditions and the following disclaimer.
     13  * 2. Redistributions in binary form must reproduce the above copyright
     14  *    notice, this list of conditions and the following disclaimer in the
     15  *    documentation and/or other materials provided with the distribution.
     16  *
     17  * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
     18  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     19  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     20  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
     21  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
     22  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
     23  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
     24  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
     25  * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     26  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
     27  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     28  */
     29 
     30 #include "config.h"
     31 #include "PlatformWheelEvent.h"
     32 
     33 #include "Scrollbar.h"
     34 
     35 #include <InterfaceDefs.h>
     36 #include <Message.h>
     37 #include <Point.h>
     38 
     39 
     40 namespace WebCore {
     41 
     42 PlatformWheelEvent::PlatformWheelEvent(BMessage* message)
     43     : m_position(message->FindPoint("be:view_where"))
     44     , m_globalPosition(message->FindPoint("screen_where"))
     45     , m_deltaX(message->FindFloat("be:wheel_delta_x"))
     46     , m_deltaY(message->FindFloat("be:wheel_delta_y"))
     47     , m_wheelTicksX(m_deltaX)
     48     , m_wheelTicksY(m_deltaY)
     49     , m_granularity(ScrollByPixelWheelEvent)
     50     , m_isAccepted(false)
     51 {
     52     m_deltaX *= -Scrollbar::pixelsPerLineStep();
     53     m_deltaY *= -Scrollbar::pixelsPerLineStep();
     54 
     55     int32 modifiers = message->FindInt32("modifiers");
     56     m_shiftKey = modifiers & B_SHIFT_KEY;
     57     m_ctrlKey = modifiers & B_CONTROL_KEY;
     58     m_altKey = modifiers & B_COMMAND_KEY;
     59     m_metaKey = modifiers & B_OPTION_KEY;
     60 }
     61 
     62 } // namespace WebCore
     63 
     64