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     static void _SetLineIncrement(void *param);
  81     static void _SetPageIncrement(void *param);
  82     // invoked on Toolkit thread
  83     static void _SetValues(void *param);
  84 
  85 private:
  86     UINT          m_orientation; /* SB_HORZ or SB_VERT */
  87 
  88     int           m_lineIncr;
  89     int           m_pageIncr;
  90 
  91     // Work around KB Q73839 bug.
  92     void UpdateFocusIndicator();
  93 
  94     // Don't do redundant callbacks.
  95     const char *m_prevCallback;
  96     int m_prevCallbackPos;
  97 
  98     static const char * const SbNlineDown;
  99     static const char * const SbNlineUp;
 100     static const char * const SbNpageDown;
 101     static const char * const SbNpageUp;
 102     static const char * const SbNdrag;
 103     static const char * const SbNdragEnd;
 104     static const char * const SbNwarp;
 105 
 106     static int ms_instanceCounter;
 107     static HHOOK ms_hMouseFilter;
 108     static BOOL ms_isInsideMouseFilter;
 109     static LRESULT CALLBACK MouseFilter(int nCode, WPARAM wParam,
 110                                         LPARAM lParam);
 111 
 112     void DoScrollCallbackCoalesce(const char* methodName, int newPos);
 113 };
 114 
 115 #endif /* AWT_SCROLLBAR_H */