Source Code Cross Referenced for MScrollbarPeer.java in  » 6.0-JDK-Platform » solaris » sun » awt » motif » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » 6.0 JDK Platform » solaris » sun.awt.motif 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 1995-2002 Sun Microsystems, Inc.  All Rights Reserved.
003:         * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
004:         *
005:         * This code is free software; you can redistribute it and/or modify it
006:         * under the terms of the GNU General Public License version 2 only, as
007:         * published by the Free Software Foundation.  Sun designates this
008:         * particular file as subject to the "Classpath" exception as provided
009:         * by Sun in the LICENSE file that accompanied this code.
010:         *
011:         * This code is distributed in the hope that it will be useful, but WITHOUT
012:         * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
013:         * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
014:         * version 2 for more details (a copy is included in the LICENSE file that
015:         * accompanied this code).
016:         *
017:         * You should have received a copy of the GNU General Public License version
018:         * 2 along with this work; if not, write to the Free Software Foundation,
019:         * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
020:         *
021:         * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
022:         * CA 95054 USA or visit www.sun.com if you need additional information or
023:         * have any questions.
024:         */
025:        package sun.awt.motif;
026:
027:        import java.awt.*;
028:        import java.awt.peer.*;
029:        import java.awt.event.AdjustmentEvent;
030:
031:        class MScrollbarPeer extends MComponentPeer implements  ScrollbarPeer {
032:            static {
033:                initIDs();
034:            }
035:
036:            private boolean inUpCall = false;
037:
038:            native void create(MComponentPeer parent);
039:
040:            MScrollbarPeer(Scrollbar target) {
041:                super (target);
042:            }
043:
044:            // Initialize JNI field and method IDs
045:            private static native void initIDs();
046:
047:            public native void pSetValues(int value, int visible, int minimum,
048:                    int maximum);
049:
050:            public native void setLineIncrement(int l);
051:
052:            public native void setPageIncrement(int l);
053:
054:            /**
055:             * Returns default size of Motif scrollbar on the platform
056:             * Currently uses hardcoded values
057:             */
058:            int getDefaultDimension() {
059:                if (System.getProperty("os.name").equals("Linux")) {
060:                    return 15;
061:                } else {
062:                    return 19;
063:                }
064:            }
065:
066:            public Dimension getMinimumSize() {
067:                if (((Scrollbar) target).getOrientation() == Scrollbar.VERTICAL) {
068:                    return new Dimension(getDefaultDimension(), 50);
069:                } else {
070:                    return new Dimension(50, getDefaultDimension());
071:                }
072:            }
073:
074:            // NOTE: Callback methods are called by privileged threads.
075:            //	     DO NOT INVOKE CLIENT CODE ON THIS THREAD!
076:
077:            private void postAdjustmentEvent(final int type, final int value,
078:                    final boolean isAdjusting) {
079:                final Scrollbar sb = (Scrollbar) target;
080:                MToolkit.executeOnEventHandlerThread(sb, new Runnable() {
081:                    public void run() {
082:                        inUpCall = true;
083:                        sb.setValueIsAdjusting(isAdjusting);
084:                        sb.setValue(value);
085:                        postEvent(new AdjustmentEvent(sb,
086:                                AdjustmentEvent.ADJUSTMENT_VALUE_CHANGED, type,
087:                                value, isAdjusting));
088:                        inUpCall = false;
089:                    }
090:                });
091:            }
092:
093:            void lineUp(int value) {
094:                postAdjustmentEvent(AdjustmentEvent.UNIT_DECREMENT, value,
095:                        false);
096:            }
097:
098:            void lineDown(int value) {
099:                postAdjustmentEvent(AdjustmentEvent.UNIT_INCREMENT, value,
100:                        false);
101:            }
102:
103:            void pageUp(int value) {
104:                postAdjustmentEvent(AdjustmentEvent.BLOCK_DECREMENT, value,
105:                        false);
106:            }
107:
108:            void pageDown(int value) {
109:                postAdjustmentEvent(AdjustmentEvent.BLOCK_INCREMENT, value,
110:                        false);
111:            }
112:
113:            // SB_TOP/BOTTOM are mapped to tracking
114:            void warp(int value) {
115:                postAdjustmentEvent(AdjustmentEvent.TRACK, value, false);
116:            }
117:
118:            private boolean dragInProgress = false;
119:
120:            void drag(final int value) {
121:                if (!dragInProgress) {
122:                    dragInProgress = true;
123:                }
124:                postAdjustmentEvent(AdjustmentEvent.TRACK, value, true);
125:            }
126:
127:            void dragEnd(final int value) {
128:                final Scrollbar sb = (Scrollbar) target;
129:
130:                if (!dragInProgress) {
131:                    return;
132:                }
133:
134:                dragInProgress = false;
135:                MToolkit.executeOnEventHandlerThread(sb, new Runnable() {
136:                    public void run() {
137:                        // NB: notification only, no sb.setValue()
138:                        // last TRACK event will have done it already
139:                        inUpCall = true;
140:                        sb.setValueIsAdjusting(false);
141:                        postEvent(new AdjustmentEvent(sb,
142:                                AdjustmentEvent.ADJUSTMENT_VALUE_CHANGED,
143:                                AdjustmentEvent.TRACK, value, false));
144:                        inUpCall = false;
145:                    }
146:                });
147:            }
148:
149:            /**
150:             * Set the value of the slider in the ScrollBar.
151:             */
152:            public void setValues(int value, int visible, int minimum,
153:                    int maximum) {
154:                // Fix for BugTraq ID 4048060.  Prevent unnecessary redrawing
155:                // of the slider, when the slider is already in the correct
156:                // position.  Since the ScrollBar widget now receives the
157:                // ButtonRelease X event before the Java Adjustor event is
158:                // handled, the slider is already in the correct position and
159:                // does not need to be set again and redrawn, when processing
160:                // the Adjustor event.
161:                if (!inUpCall) {
162:                    pSetValues(value, visible, minimum, maximum);
163:                }
164:            }
165:
166:            public void print(Graphics g) {
167:                Scrollbar sb = (Scrollbar) target;
168:                Dimension d = sb.size();
169:                Color bg = sb.getBackground();
170:
171:                boolean horiz = (sb.getOrientation() == Scrollbar.HORIZONTAL);
172:
173:                drawScrollbar(g, bg, horiz ? d.height : d.width,
174:                        horiz ? d.width : d.height, sb.getMinimum(), sb
175:                                .getMaximum(), sb.getValue(), sb.getVisible(),
176:                        horiz);
177:
178:                target.print(g);
179:            }
180:
181:            /**
182:             * DEPRECATED
183:             */
184:            public Dimension minimumSize() {
185:                return getMinimumSize();
186:            }
187:
188:            protected boolean shouldFocusOnClick() {
189:                // Changed in 1.4 - scroll bars are made focusable by mouse clicks.
190:                return true;
191:            }
192:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.