1 /*
   2  * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 #ifndef VIEWCONTAINER_H
  27 #define VIEWCONTAINER_H
  28 
  29 class GlassView;
  30 
  31 class ViewContainer {
  32     private:
  33         GlassView * m_view;
  34         BOOL m_bTrackingMouse;
  35         HKL m_kbLayout;
  36         UINT m_codePage;
  37         LANGID m_idLang;
  38         WPARAM m_deadKeyWParam;
  39 
  40         std::auto_ptr<IDropTarget> m_spDropTarget;
  41 
  42         IManipulationProcessor*             m_manipProc;
  43         IInertiaProcessor*                  m_inertiaProc;
  44         _IManipulationEvents*               m_manipEventSink;
  45         jclass                              m_gestureSupportCls;
  46 
  47         LPARAM m_lastMouseMovePosition; // or -1
  48         unsigned int m_mouseButtonDownCounter;
  49 
  50         void WmImeComposition(HWND hwnd, WPARAM wParam, LPARAM lParam);
  51         void WmImeNotify(HWND hwnd, WPARAM wParam, LPARAM lParam);
  52         void SendInputMethodEvent(jstring text,
  53             int cClause, int* rgClauseBoundary,
  54             int cAttrBlock, int* rgAttrBoundary, BYTE *rgAttrValue,
  55             int commitedTextLength, int caretPos, int visiblePos);
  56         void GetCandidatePos(LPPOINT curPos);
  57 
  58         void SendViewTypedEvent(int repCount, jchar wChar);
  59 
  60     protected:
  61         void HandleViewMenuEvent(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
  62         void HandleViewInputLangChange(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
  63         void HandleViewPaintEvent(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
  64         void HandleViewSizeEvent(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
  65         void HandleViewKeyEvent(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
  66         void HandleViewDeadKeyEvent(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
  67         void HandleViewTypedEvent(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
  68         BOOL HandleViewMouseEvent(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
  69         BOOL HandleViewInputMethodEvent(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
  70         void HandleViewTouchEvent(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
  71         LRESULT HandleViewGetAccessible(HWND hwnd, WPARAM wParam, LPARAM lParam);
  72     
  73         virtual void HandleViewTimerEvent(HWND hwnd, UINT_PTR timerID);
  74 
  75         void InitDropTarget(HWND hwnd);
  76         void ReleaseDropTarget();
  77 
  78         void InitManipProcessor(HWND hwnd);
  79         void ReleaseManipProcessor();
  80 
  81         void NotifyCaptureChanged(HWND hwnd, HWND to);
  82 
  83     private:
  84         ViewContainer(const ViewContainer&);
  85         ViewContainer& operator = (const ViewContainer&);
  86     
  87     public:
  88         enum {
  89             IDT_GLASS_ANIMATION_ENTER = 0x101,
  90             IDT_GLASS_ANIMATION_EXIT,
  91             IDT_GLASS_INERTIAPROCESSOR,
  92         };
  93         
  94         ViewContainer();
  95 
  96         inline GlassView * GetGlassView() const { return m_view; }
  97         inline void SetGlassView(GlassView * view) { m_view = view; }
  98         inline LANGID GetInputLanguage() { return m_idLang; }
  99 
 100         jobject GetView();
 101 
 102         void ResetMouseTracking(HWND hwnd);
 103 
 104         void NotifyViewSize(HWND hwnd);
 105         
 106         void NotifyGesturePerformed(HWND hWnd, 
 107             bool isDirect, bool isInertia,
 108             FLOAT x, FLOAT y, 
 109             FLOAT deltaX, FLOAT deltaY,
 110             FLOAT scaleDelta, FLOAT expansionDelta, FLOAT rotationDelta,
 111             FLOAT cumulativeDeltaX, FLOAT cumulativeDeltaY,
 112             FLOAT cumulativeScale, FLOAT cumulativeExpansion, FLOAT cumulativeRotation);
 113         
 114         void StartTouchInputInertia(HWND hwnd);
 115         void StopTouchInputInertia(HWND hwnd);
 116 };
 117 
 118 #endif // VIEWCONTAINER_H
 119