1/* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License, Version 1.0 only 6 * (the "License"). You may not use this file except in compliance 7 * with the License. 8 * 9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10 * or http://www.opensolaris.org/os/licensing. 11 * See the License for the specific language governing permissions 12 * and limitations under the License. 13 * 14 * When distributing Covered Code, include this CDDL HEADER in each 15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16 * If applicable, add the following below this CDDL HEADER, with the 17 * fields enclosed by brackets "[]" replaced with your own identifying 18 * information: Portions Copyright [yyyy] [name of copyright owner] 19 * 20 * CDDL HEADER END 21 */ 22/* 23 * ident "%Z%%M% %I% %E% SMI" 24 * 25 * Copyright (c) 2000 by Sun Microsystems, Inc. 26 * All rights reserved. 27 */ 28 29/* 30 * Copyright (C) 1996 Active Software, Inc. 31 * All rights reserved. 32 * 33 * @(#) @(#) ScrollbarShadow.java 1.32 - last change made 07/28/97 34 */ 35 36package sunsoft.jws.visual.rt.shadow.java.awt; 37 38import sunsoft.jws.visual.rt.awt.GBConstraints; 39import sunsoft.jws.visual.rt.awt.VJScrollbar; 40import sunsoft.jws.visual.rt.type.OrientationEnum; 41import sunsoft.jws.visual.rt.base.Global; 42 43/** 44 * Wraps an AWT widget. The attributes available for this 45 * class are listed below. In the type column, type names beginning 46 * with "sunsoft.jws.visual.rt" have been abbreviated to begin with "rt". 47 * 48 * <pre> 49name type default value 50----------------------------------------------------------------------- 51lineIncrement java.lang.Integer 10 52maximum java.lang.Integer 100 53minimum java.lang.Integer 0 54orientation rt.type.OrientationEnum vertical 55pageIncrement java.lang.Integer 10 56value java.lang.Integer 0 57visiblePageSize java.lang.Integer 50 58* < /pre> 59* 60* Check the super class for additional attributes. 61* 62* @see VJScrollbar 63* @see Scrollbar 64* @version 1.32, 07/28/97 65*/ 66public class ScrollbarShadow extends ComponentShadow { 67 68 public ScrollbarShadow() { 69 attributes.add(/* NOI18N */"orientation", 70 /* NOI18N */"sunsoft.jws.visual.rt.type.OrientationEnum", 71 new OrientationEnum(VJScrollbar.VERTICAL), 72 CONSTRUCTOR); 73 attributes.add(/* NOI18N */"lineIncrement", 74 /* NOI18N */"java.lang.Integer", new Integer(10), 0); 75 attributes.add(/* NOI18N */"maximum", 76 /* NOI18N */"java.lang.Integer", new Integer(100), 0); 77 attributes.add(/* NOI18N */"minimum", 78 /* NOI18N */"java.lang.Integer", new Integer(0), 0); 79 attributes.add(/* NOI18N */"pageIncrement", 80 /* NOI18N */"java.lang.Integer", new Integer(10), 0); 81 attributes.add(/* NOI18N */"value", 82 /* NOI18N */"java.lang.Integer", new Integer(0), 0); 83 attributes.add(/* NOI18N */"visiblePageSize", 84 /* NOI18N */"java.lang.Integer", new Integer(50), 0); 85 86 GBConstraints c = (GBConstraints)get(/* NOI18N */"GBConstraints"); 87 c.fill = GBConstraints.VERTICAL; 88 attributes.add(/* NOI18N */"GBConstraints", 89 /* NOI18N */"sunsoft.jws.visual.rt.awt.GBConstraints", 90 c); 91 } 92 93 /** 94 * A change in the orientation of a scrollbar should also result 95 * in a change of the fill mode in its GBConstraints. 96 */ 97 private void setProperFill(int orientation) { 98 GBConstraints c = (GBConstraints)get(/* NOI18N */"GBConstraints"); 99 100 if (c == null) 101 /* JSTYLED */ 102 throw new Error(Global.getMsg("sunsoft.jws.visual.rt.awt.java.awt.ScrollbarShadow.NoLayoutConstraints")); 103 else if ((c.fill == GBConstraints.VERTICAL 104 && orientation == VJScrollbar.HORIZONTAL) || 105 (c.fill == GBConstraints.HORIZONTAL 106 && orientation == VJScrollbar.VERTICAL)) { 107 c = (GBConstraints) c.clone(); 108 if (orientation == VJScrollbar.VERTICAL) 109 c.fill = GBConstraints.VERTICAL; 110 else 111 c.fill = GBConstraints.HORIZONTAL; 112 set(/* NOI18N */"GBConstraints", c); 113 } 114 } 115 116 protected Object getOnBody(String key) { 117 VJScrollbar sbar = (VJScrollbar)body; 118 119 if (key.equals(/* NOI18N */"orientation")) 120 return (new OrientationEnum(sbar.getOrientation())); 121 else if (key.equals(/* NOI18N */"lineIncrement")) 122 return (new Integer(sbar.getLineIncrement())); 123 else if (key.equals(/* NOI18N */"maximum")) 124 return (new Integer(sbar.getMaximum())); 125 else if (key.equals(/* NOI18N */"minimum")) 126 return (new Integer(sbar.getMinimum())); 127 else if (key.equals(/* NOI18N */"pageIncrement")) 128 return (new Integer(sbar.getPageIncrement())); 129 else if (key.equals(/* NOI18N */"value")) 130 return (new Integer(sbar.getValue())); 131 else if (key.equals(/* NOI18N */"visiblePageSize")) 132 return (new Integer(sbar.getVisible())); 133 else 134 return (super.getOnBody(key)); 135 } 136 137 protected void setOnBody(String key, Object value) { 138 VJScrollbar sbar = (VJScrollbar)body; 139 140 if (key.equals(/* NOI18N */"lineIncrement")) { 141 sbar.setLineIncrement(((Integer) value).intValue()); 142 } else if (key.equals(/* NOI18N */"maximum")) { 143 sbar.setValues(sbar.getValue(), sbar.getVisible(), 144 sbar.getMinimum(), ((Integer) value).intValue()); 145 } else if (key.equals(/* NOI18N */"minimum")) { 146 sbar.setValues(sbar.getValue(), sbar.getVisible(), 147 ((Integer) value).intValue(), sbar.getMaximum()); 148 } else if (key.equals(/* NOI18N */"pageIncrement")) { 149 sbar.setPageIncrement(((Integer) value).intValue()); 150 } else if (key.equals(/* NOI18N */"value")) { 151 sbar.setValue(((Integer) value).intValue()); 152 } else if (key.equals(/* NOI18N */"visiblePageSize")) { 153 sbar.setValues(sbar.getValue(), 154 ((Integer) value).intValue(), 155 sbar.getMinimum(), sbar.getMaximum()); 156 } else if (key.equals(/* NOI18N */"orientation")) { 157 setProperFill(((OrientationEnum) value).intValue()); 158 } else { 159 super.setOnBody(key, value); 160 } 161 } 162 163 public void createBody() { 164 /* JSTYLED */ 165 int orientation = ((OrientationEnum) getFromTable(/* NOI18N */"orientation")).intValue(); 166 167 // Use the VJScrollbar because it has workarounds for the broken 168 // scrollbars on Windows. 169 body = new VJScrollbar(orientation); 170 } 171} 172