1 /* 2 * Copyright (c) 1996, 2009, 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 AWT_SCROLLBAR_H 27 #define AWT_SCROLLBAR_H 28 29 #include "awt_Component.h" 30 31 #include "java_awt_Scrollbar.h" 32 #include "sun_awt_windows_WScrollbarPeer.h" 33 34 35 #define Java_java_awt_Scrollbar_HORIZONTAL 0 36 #define Java_java_awt_Scrollbar_VERTICAL 1 37 38 39 /************************************************************************ 40 * AwtScrollbar class 41 */ 42 43 class AwtScrollbar : public AwtComponent { 44 public: 45 46 /* java.awt.Scrollbar fields */ 47 static jfieldID lineIncrementID; 48 static jfieldID pageIncrementID; 49 static jfieldID orientationID; 50 51 AwtScrollbar(); 52 virtual ~AwtScrollbar(); 53 54 virtual void Dispose(); 55 56 virtual LPCTSTR GetClassName(); 57 58 static AwtScrollbar* Create(jobject self, jobject parent); 59 60 void SetValue(int value); 61 void SetLineIncrement(int value) { m_lineIncr = value; } 62 void SetPageIncrement(int value) { m_pageIncr = value; } 63 64 virtual LRESULT WindowProc(UINT message, WPARAM wParam, LPARAM lParam); 65 66 /* 67 * Windows message handler functions 68 */ 69 virtual MsgRouting WmHScroll(UINT scrollCode, UINT pos, HWND hScrollBar); 70 virtual MsgRouting WmVScroll(UINT scrollCode, UINT pos, HWND hScrollBar); 71 72 // Prevent KB Q102552 race. 73 virtual MsgRouting WmMouseDown(UINT flags, int x, int y, int button); 74 virtual MsgRouting WmNcHitTest(UINT x, UINT y, LRESULT& retVal); 75 76 virtual MsgRouting HandleEvent(MSG *msg, BOOL synthetic); 77 78 INLINE virtual BOOL IsScrollbar() { return TRUE; } 79 80 // invoked on Toolkit thread 81 static void _SetValues(void *param); 82 83 private: 84 UINT m_orientation; /* SB_HORZ or SB_VERT */ 85 86 int m_lineIncr; 87 int m_pageIncr; 88 89 // Work around KB Q73839 bug. 90 void UpdateFocusIndicator(); 91 92 // Don't do redundant callbacks. 93 const char *m_prevCallback; 94 int m_prevCallbackPos; 95 96 static const char * const SbNlineDown; 97 static const char * const SbNlineUp; 98 static const char * const SbNpageDown; 99 static const char * const SbNpageUp; 100 static const char * const SbNdrag; 101 static const char * const SbNdragEnd; 102 static const char * const SbNwarp; 103 104 static int ms_instanceCounter; 105 static HHOOK ms_hMouseFilter; 106 static BOOL ms_isInsideMouseFilter; 107 static LRESULT CALLBACK MouseFilter(int nCode, WPARAM wParam, 108 LPARAM lParam); 109 110 void DoScrollCallbackCoalesce(const char* methodName, int newPos); 111 }; 112 113 #endif /* AWT_SCROLLBAR_H */