1 7 8 22 23 package com.sun.java.swing.plaf.windows; 24 25 import java.awt.*; 26 import java.util.*; 27 28 import javax.swing.*; 29 30 import sun.awt.windows.ThemeReader; 31 32 40 class TMSchema { 41 42 46 public static enum Control { 47 BUTTON, 48 COMBOBOX, 49 EDIT, 50 HEADER, 51 LISTBOX, 52 LISTVIEW, 53 MENU, 54 PROGRESS, 55 REBAR, 56 SCROLLBAR, 57 SPIN, 58 TAB, 59 TOOLBAR, 60 TRACKBAR, 61 TREEVIEW, 62 WINDOW 63 } 64 65 66 69 public static enum Part { 70 MENU (Control.MENU, 0), MP_BARBACKGROUND (Control.MENU, 7), 72 MP_BARITEM (Control.MENU, 8), 73 MP_POPUPBACKGROUND (Control.MENU, 9), 74 MP_POPUPBORDERS (Control.MENU, 10), 75 MP_POPUPCHECK (Control.MENU, 11), 76 MP_POPUPCHECKBACKGROUND (Control.MENU, 12), 77 MP_POPUPGUTTER (Control.MENU, 13), 78 MP_POPUPITEM (Control.MENU, 14), 79 MP_POPUPSEPARATOR (Control.MENU, 15), 80 MP_POPUPSUBMENU (Control.MENU, 16), 81 82 BP_PUSHBUTTON (Control.BUTTON, 1), 83 BP_RADIOBUTTON(Control.BUTTON, 2), 84 BP_CHECKBOX (Control.BUTTON, 3), 85 BP_GROUPBOX (Control.BUTTON, 4), 86 87 CP_COMBOBOX (Control.COMBOBOX, 0), 88 CP_DROPDOWNBUTTON(Control.COMBOBOX, 1), 89 CP_BACKGROUND (Control.COMBOBOX, 2), 90 CP_TRANSPARENTBACKGROUND (Control.COMBOBOX, 3), 91 CP_BORDER (Control.COMBOBOX, 4), 92 CP_READONLY (Control.COMBOBOX, 5), 93 CP_DROPDOWNBUTTONRIGHT (Control.COMBOBOX, 6), 94 CP_DROPDOWNBUTTONLEFT (Control.COMBOBOX, 7), 95 CP_CUEBANNER (Control.COMBOBOX, 8), 96 97 EP_EDIT (Control.EDIT, 0), 98 EP_EDITTEXT(Control.EDIT, 1), 99 100 HP_HEADERITEM(Control.HEADER, 1), 101 HP_HEADERSORTARROW(Control.HEADER, 4), 102 103 LBP_LISTBOX(Control.LISTBOX, 0), 104 105 LVP_LISTVIEW(Control.LISTVIEW, 0), 106 107 PP_PROGRESS (Control.PROGRESS, 0), 108 PP_BAR (Control.PROGRESS, 1), 109 PP_BARVERT (Control.PROGRESS, 2), 110 PP_CHUNK (Control.PROGRESS, 3), 111 PP_CHUNKVERT(Control.PROGRESS, 4), 112 113 RP_GRIPPER (Control.REBAR, 1), 114 RP_GRIPPERVERT(Control.REBAR, 2), 115 116 SBP_SCROLLBAR (Control.SCROLLBAR, 0), 117 SBP_ARROWBTN (Control.SCROLLBAR, 1), 118 SBP_THUMBBTNHORZ (Control.SCROLLBAR, 2), 119 SBP_THUMBBTNVERT (Control.SCROLLBAR, 3), 120 SBP_LOWERTRACKHORZ(Control.SCROLLBAR, 4), 121 SBP_UPPERTRACKHORZ(Control.SCROLLBAR, 5), 122 SBP_LOWERTRACKVERT(Control.SCROLLBAR, 6), 123 SBP_UPPERTRACKVERT(Control.SCROLLBAR, 7), 124 SBP_GRIPPERHORZ (Control.SCROLLBAR, 8), 125 SBP_GRIPPERVERT (Control.SCROLLBAR, 9), 126 SBP_SIZEBOX (Control.SCROLLBAR, 10), 127 128 SPNP_SPINUP (Control.SPIN, 1), 129 SPNP_SPINDOWN(Control.SPIN, 2), 130 131 TABP_TABITEM (Control.TAB, 1), 132 TABP_TABITEMLEFTEDGE (Control.TAB, 2), 133 TABP_TABITEMRIGHTEDGE(Control.TAB, 3), 134 TABP_PANE (Control.TAB, 9), 135 136 TP_TOOLBAR (Control.TOOLBAR, 0), 137 TP_BUTTON (Control.TOOLBAR, 1), 138 TP_SEPARATOR (Control.TOOLBAR, 5), 139 TP_SEPARATORVERT (Control.TOOLBAR, 6), 140 141 TKP_TRACK (Control.TRACKBAR, 1), 142 TKP_TRACKVERT (Control.TRACKBAR, 2), 143 TKP_THUMB (Control.TRACKBAR, 3), 144 TKP_THUMBBOTTOM(Control.TRACKBAR, 4), 145 TKP_THUMBTOP (Control.TRACKBAR, 5), 146 TKP_THUMBVERT (Control.TRACKBAR, 6), 147 TKP_THUMBLEFT (Control.TRACKBAR, 7), 148 TKP_THUMBRIGHT (Control.TRACKBAR, 8), 149 TKP_TICS (Control.TRACKBAR, 9), 150 TKP_TICSVERT (Control.TRACKBAR, 10), 151 152 TVP_TREEVIEW(Control.TREEVIEW, 0), 153 TVP_GLYPH (Control.TREEVIEW, 2), 154 155 WP_WINDOW (Control.WINDOW, 0), 156 WP_CAPTION (Control.WINDOW, 1), 157 WP_MINCAPTION (Control.WINDOW, 3), 158 WP_MAXCAPTION (Control.WINDOW, 5), 159 WP_FRAMELEFT (Control.WINDOW, 7), 160 WP_FRAMERIGHT (Control.WINDOW, 8), 161 WP_FRAMEBOTTOM (Control.WINDOW, 9), 162 WP_SYSBUTTON (Control.WINDOW, 13), 163 WP_MDISYSBUTTON (Control.WINDOW, 14), 164 WP_MINBUTTON (Control.WINDOW, 15), 165 WP_MDIMINBUTTON (Control.WINDOW, 16), 166 WP_MAXBUTTON (Control.WINDOW, 17), 167 WP_CLOSEBUTTON (Control.WINDOW, 18), 168 WP_MDICLOSEBUTTON (Control.WINDOW, 20), 169 WP_RESTOREBUTTON (Control.WINDOW, 21), 170 WP_MDIRESTOREBUTTON(Control.WINDOW, 22); 171 172 private final Control control; 173 private final int value; 174 175 private Part(Control control, int value) { 176 this.control = control; 177 this.value = value; 178 } 179 180 public int getValue() { 181 return value; 182 } 183 184 public String getControlName(Component component) { 185 String str = ""; 186 if (component instanceof JComponent) { 187 JComponent c = (JComponent)component; 188 String subAppName = (String )c.getClientProperty("XPStyle.subAppName"); 189 if (subAppName != null) { 190 str = subAppName + "::"; 191 } 192 } 193 return str + control.toString(); 194 } 195 196 public String toString() { 197 return control.toString()+"."+name(); 198 } 199 } 200 201 202 205 public static enum State { 206 ACTIVE, 207 ASSIST, 208 BITMAP, 209 CHECKED, 210 CHECKEDDISABLED, 211 CHECKEDHOT, 212 CHECKEDNORMAL, 213 CHECKEDPRESSED, 214 CHECKMARKNORMAL, 215 CHECKMARKDISABLED, 216 BULLETNORMAL, 217 BULLETDISABLED, 218 CLOSED, 219 DEFAULTED, 220 DISABLED, 221 DISABLEDHOT, 222 DISABLEDPUSHED, 223 DOWNDISABLED, 224 DOWNHOT, 225 DOWNNORMAL, 226 DOWNPRESSED, 227 FOCUSED, 228 HOT, 229 HOTCHECKED, 230 INACTIVE, 231 INACTIVENORMAL, INACTIVEHOT, INACTIVEPUSHED, INACTIVEDISABLED, LEFTDISABLED, 236 LEFTHOT, 237 LEFTNORMAL, 238 LEFTPRESSED, 239 MIXEDDISABLED, 240 MIXEDHOT, 241 MIXEDNORMAL, 242 MIXEDPRESSED, 243 NORMAL, 244 PRESSED, 245 OPENED, 246 PUSHED, 247 READONLY, 248 RIGHTDISABLED, 249 RIGHTHOT, 250 RIGHTNORMAL, 251 RIGHTPRESSED, 252 SELECTED, 253 UNCHECKEDDISABLED, 254 UNCHECKEDHOT, 255 UNCHECKEDNORMAL, 256 UNCHECKEDPRESSED, 257 UPDISABLED, 258 UPHOT, 259 UPNORMAL, 260 UPPRESSED; 261 262 263 266 private static EnumMap<Part, State[]> stateMap; 267 268 private static synchronized void initStates() { 269 stateMap = new EnumMap<Part, State[]>(Part.class); 270 271 stateMap.put(Part.EP_EDITTEXT, 272 new State[] { 273 NORMAL, HOT, SELECTED, DISABLED, FOCUSED, READONLY, ASSIST 274 }); 275 276 stateMap.put(Part.BP_PUSHBUTTON, 277 new State[] { NORMAL, HOT, PRESSED, DISABLED, DEFAULTED }); 278 279 stateMap.put(Part.BP_RADIOBUTTON, 280 new State[] { 281 UNCHECKEDNORMAL, UNCHECKEDHOT, UNCHECKEDPRESSED, UNCHECKEDDISABLED, 282 CHECKEDNORMAL, CHECKEDHOT, CHECKEDPRESSED, CHECKEDDISABLED 283 }); 284 285 stateMap.put(Part.BP_CHECKBOX, 286 new State[] { 287 UNCHECKEDNORMAL, UNCHECKEDHOT, UNCHECKEDPRESSED, UNCHECKEDDISABLED, 288 CHECKEDNORMAL, CHECKEDHOT, CHECKEDPRESSED, CHECKEDDISABLED, 289 MIXEDNORMAL, MIXEDHOT, MIXEDPRESSED, MIXEDDISABLED 290 }); 291 292 State[] comboBoxStates = new State[] { NORMAL, HOT, PRESSED, DISABLED }; 293 stateMap.put(Part.CP_COMBOBOX, comboBoxStates); 294 stateMap.put(Part.CP_DROPDOWNBUTTON, comboBoxStates); 295 stateMap.put(Part.CP_BACKGROUND, comboBoxStates); 296 stateMap.put(Part.CP_TRANSPARENTBACKGROUND, comboBoxStates); 297 stateMap.put(Part.CP_BORDER, comboBoxStates); 298 stateMap.put(Part.CP_READONLY, comboBoxStates); 299 stateMap.put(Part.CP_DROPDOWNBUTTONRIGHT, comboBoxStates); 300 stateMap.put(Part.CP_DROPDOWNBUTTONLEFT, comboBoxStates); 301 stateMap.put(Part.CP_CUEBANNER, comboBoxStates); 302 303 stateMap.put(Part.HP_HEADERITEM, new State[] { NORMAL, HOT, PRESSED }); 304 305 State[] scrollBarStates = new State[] { NORMAL, HOT, PRESSED, DISABLED }; 306 stateMap.put(Part.SBP_SCROLLBAR, scrollBarStates); 307 stateMap.put(Part.SBP_THUMBBTNVERT, scrollBarStates); 308 stateMap.put(Part.SBP_THUMBBTNHORZ, scrollBarStates); 309 stateMap.put(Part.SBP_GRIPPERVERT, scrollBarStates); 310 stateMap.put(Part.SBP_GRIPPERHORZ, scrollBarStates); 311 312 stateMap.put(Part.SBP_ARROWBTN, 313 new State[] { 314 UPNORMAL, UPHOT, UPPRESSED, UPDISABLED, 315 DOWNNORMAL, DOWNHOT, DOWNPRESSED, DOWNDISABLED, 316 LEFTNORMAL, LEFTHOT, LEFTPRESSED, LEFTDISABLED, 317 RIGHTNORMAL, RIGHTHOT, RIGHTPRESSED, RIGHTDISABLED 318 }); 319 320 321 State[] spinnerStates = new State[] { NORMAL, HOT, PRESSED, DISABLED }; 322 stateMap.put(Part.SPNP_SPINUP, spinnerStates); 323 stateMap.put(Part.SPNP_SPINDOWN, spinnerStates); 324 325 stateMap.put(Part.TVP_GLYPH, new State[] { CLOSED, OPENED }); 326 327 State[] frameButtonStates = new State[] { 328 NORMAL, HOT, PUSHED, DISABLED, INACTIVENORMAL, INACTIVEHOT, INACTIVEPUSHED, INACTIVEDISABLED, 330 }; 331 334 if (ThemeReader.getInt(Control.WINDOW.toString(), 336 Part.WP_CLOSEBUTTON.getValue(), 1, 337 Prop.IMAGECOUNT.getValue()) == 10) { 338 frameButtonStates = new State[] { 339 NORMAL, HOT, PUSHED, DISABLED, null, 340 INACTIVENORMAL, INACTIVEHOT, INACTIVEPUSHED, INACTIVEDISABLED, null 341 }; 342 } 343 344 stateMap.put(Part.WP_MINBUTTON, frameButtonStates); 345 stateMap.put(Part.WP_MAXBUTTON, frameButtonStates); 346 stateMap.put(Part.WP_RESTOREBUTTON, frameButtonStates); 347 stateMap.put(Part.WP_CLOSEBUTTON, frameButtonStates); 348 349 stateMap.put(Part.TKP_TRACK, new State[] { NORMAL }); 351 stateMap.put(Part.TKP_TRACKVERT, new State[] { NORMAL }); 352 353 State[] sliderThumbStates = 354 new State[] { NORMAL, HOT, PRESSED, FOCUSED, DISABLED }; 355 stateMap.put(Part.TKP_THUMB, sliderThumbStates); 356 stateMap.put(Part.TKP_THUMBBOTTOM, sliderThumbStates); 357 stateMap.put(Part.TKP_THUMBTOP, sliderThumbStates); 358 stateMap.put(Part.TKP_THUMBVERT, sliderThumbStates); 359 stateMap.put(Part.TKP_THUMBRIGHT, sliderThumbStates); 360 361 State[] tabStates = new State[] { NORMAL, HOT, SELECTED, DISABLED, FOCUSED }; 363 stateMap.put(Part.TABP_TABITEM, tabStates); 364 stateMap.put(Part.TABP_TABITEMLEFTEDGE, tabStates); 365 stateMap.put(Part.TABP_TABITEMRIGHTEDGE, tabStates); 366 367 368 stateMap.put(Part.TP_BUTTON, 369 new State[] { 370 NORMAL, HOT, PRESSED, DISABLED, CHECKED, HOTCHECKED 371 }); 372 373 State[] frameStates = new State[] { ACTIVE, INACTIVE }; 374 stateMap.put(Part.WP_WINDOW, frameStates); 375 stateMap.put(Part.WP_FRAMELEFT, frameStates); 376 stateMap.put(Part.WP_FRAMERIGHT, frameStates); 377 stateMap.put(Part.WP_FRAMEBOTTOM, frameStates); 378 379 State[] captionStates = new State[] { ACTIVE, INACTIVE, DISABLED }; 380 stateMap.put(Part.WP_CAPTION, captionStates); 381 stateMap.put(Part.WP_MINCAPTION, captionStates); 382 stateMap.put(Part.WP_MAXCAPTION, captionStates); 383 384 stateMap.put(Part.MP_BARBACKGROUND, 385 new State[] { ACTIVE, INACTIVE }); 386 stateMap.put(Part.MP_BARITEM, 387 new State[] { NORMAL, HOT, PUSHED, 388 DISABLED, DISABLEDHOT, DISABLEDPUSHED }); 389 stateMap.put(Part.MP_POPUPCHECK, 390 new State[] { CHECKMARKNORMAL, CHECKMARKDISABLED, 391 BULLETNORMAL, BULLETDISABLED }); 392 stateMap.put(Part.MP_POPUPCHECKBACKGROUND, 393 new State[] { DISABLEDPUSHED, NORMAL, BITMAP }); 394 stateMap.put(Part.MP_POPUPITEM, 395 new State[] { NORMAL, HOT, DISABLED, DISABLEDHOT }); 396 stateMap.put(Part.MP_POPUPSUBMENU, 397 new State[] { NORMAL, DISABLED }); 398 399 } 400 401 402 public static synchronized int getValue(Part part, State state) { 403 if (stateMap == null) { 404 initStates(); 405 } 406 407 Enum [] states = stateMap.get(part); 408 if (states != null) { 409 for (int i = 0; i < states.length; i++) { 410 if (state == states[i]) { 411 return i + 1; 412 } 413 } 414 } 415 416 if (state == null || state == State.NORMAL) { 417 return 1; 418 } 419 420 return 0; 421 } 422 423 } 424 425 426 430 public static enum Prop { 431 COLOR(Color.class, 204), 432 SIZE(Dimension.class, 207), 433 434 FLATMENUS(Boolean .class, 1001), 435 436 BORDERONLY(Boolean .class, 2203), 438 IMAGECOUNT(Integer .class, 2401), BORDERSIZE(Integer .class, 2403), 441 PROGRESSCHUNKSIZE(Integer .class, 2411), PROGRESSSPACESIZE(Integer .class, 2412), 444 TEXTSHADOWOFFSET(Point.class, 3402), 446 NORMALSIZE(Dimension.class, 3409), 448 449 SIZINGMARGINS ( Insets.class, 3601), CONTENTMARGINS(Insets.class, 3602), CAPTIONMARGINS(Insets.class, 3603), 453 BORDERCOLOR(Color.class, 3801), FILLCOLOR ( Color.class, 3802), TEXTCOLOR ( Color.class, 3803), 457 TEXTSHADOWCOLOR(Color.class, 3818), 459 BGTYPE(Integer .class, 4001), 461 TEXTSHADOWTYPE(Integer .class, 4010); 463 464 465 private final Class type; 466 private final int value; 467 468 private Prop(Class type, int value) { 469 this.type = type; 470 this.value = value; 471 } 472 473 public int getValue() { 474 return value; 475 } 476 477 public String toString() { 478 return name()+"["+type.getName()+"] = "+value; 479 } 480 } 481 482 483 486 public static enum TypeEnum { 487 BT_IMAGEFILE (Prop.BGTYPE, "imagefile", 0), 488 BT_BORDERFILL(Prop.BGTYPE, "borderfill", 1), 489 490 TST_SINGLE(Prop.TEXTSHADOWTYPE, "single", 1), 491 TST_CONTINUOUS(Prop.TEXTSHADOWTYPE, "continuous", 2); 492 493 494 private TypeEnum(Prop prop, String enumName, int value) { 495 this.prop = prop; 496 this.enumName = enumName; 497 this.value = value; 498 } 499 500 private final Prop prop; 501 private final String enumName; 502 private final int value; 503 504 public String toString() { 505 return prop+"="+enumName+"="+value; 506 } 507 508 String getName() { 509 return enumName; 510 } 511 512 513 static TypeEnum getTypeEnum(Prop prop, int enumval) { 514 for (TypeEnum e : TypeEnum.values()) { 515 if (e.prop == prop && e.value == enumval) { 516 return e; 517 } 518 } 519 return null; 520 } 521 } 522 } 523 | Popular Tags |