1  /*
     2   Copyright aswing.org, see the LICENCE.txt.
     3  */
     4   
     5  import org.aswing.*;
     6  import org.aswing.plaf.*;
     7  import org.aswing.plaf.basic.*;
     8   
     9  /**
    10   *
    11   * @author Firdosh
    12   */
    13  class org.aswing.plaf.winxp.WinXpLookAndFeel extends BasicLookAndFeel{
    14  	
    15  	public function WinXpLookAndFeel(){
    16  		super();
    17  	}
    18  	
    19  	private function initClassDefaults(table:UIDefaults):Void{
    20  		super.initClassDefaults(table);
    21  		var uiDefaults:Array = [
    22  			   "ButtonUI", org.aswing.plaf.winxp.WinXpButtonUI,
    23  			   "PanelUI", org.aswing.plaf.basic.BasicPanelUI,
    24  			   "WindowUI", org.aswing.plaf.basic.BasicWindowUI,
    25  			   "ToggleButtonUI", org.aswing.plaf.winxp.WinXpToggleButtonUI,
    26  			   "RadioButtonUI", org.aswing.plaf.winxp.WinXpRadioButtonUI,
    27  			    "FrameUI", org.aswing.plaf.winxp.WinXpFrameUI,
    28  			     "TextFieldUI", org.aswing.plaf.winxp.WinXpTextFieldUI,
    29  			      "TextAreaUI", org.aswing.plaf.winxp.WinXpTextAreaUI,
    30  			         "CheckBoxUI", org.aswing.plaf.winxp.WinXpCheckBoxUI
    31  			   ];
    32  		table.putDefaults(uiDefaults);
    33  	}
    34  	
    35  	private function initSystemColorDefaults(table:UIDefaults):Void{
    36  			var defaultSystemColors:Array = [
    37  				  "activeCaption", 0xE0E0E0, /* Color for captions (title bars) when they are active. */
    38  			      "activeCaptionText", 0x000000, /* Text color for text in captions (title bars). */
    39  			    "activeCaptionBorder", 0xC0C0C0, /* Border color for caption (title bar) window borders. */
    40  			        "inactiveCaption", 0x808080, /* Color for captions (title bars) when not active. */
    41  			    "inactiveCaptionText", 0xC0C0C0, /* Text color for text in inactive captions (title bars). */
    42  			  "inactiveCaptionBorder", 0xC0C0C0, /* Border color for inactive caption (title bar) window borders. */
    43  				         "window", 0xF4F4F4, /* Default color for the interior of windows */
    44  				   "windowBorder", 0x000000, /* ??? */
    45  				     "windowText", 0x000000, /* ??? */
    46  					   "menu", 0xC0C0C0, /* Background color for menus */
    47  				       "menuText", 0x000000, /* Text color for menus  */
    48  					   "text", 0xC0C0C0, /* Text background color */
    49  				       "textText", 0x000000, /* Text foreground color */
    50  				  "textHighlight", 0x000080, /* Text background color when selected */
    51  			      "textHighlightText", 0xFFFFFF, /* Text color when selected */
    52  			       "textInactiveText", 0x808080, /* Text color when disabled */
    53  				        "control", 0xF4F4F4,//0xEFEFEF, /* Default color for controls (buttons, sliders, etc) */
    54  				    "controlText", 0x000000, /* Default color for text in controls */
    55  			       "controlHighlight", 0xEEEEEE, /* Specular highlight (opposite of the shadow) */
    56  			     "controlLtHighlight", 0x666666, /* Highlight color for controls */
    57  				  "controlShadow", 0xC7C7C5, /* Shadow color for controls */
    58  			        "controlDkShadow", 0x666666, /* Dark shadow color for controls */
    59  				      "scrollbar", 0xE0E0E0 /* Scrollbar background (usually the "track") */
    60  			];
    61  					
    62  			for(var i:Number=0; i<defaultSystemColors.length; i+=2){
    63  				table.put(defaultSystemColors[i], new ASColorUIResource(defaultSystemColors[i+1]));
    64  			}
    65  					
    66  	}
    67  	
    68  	private function initComponentDefaults(table:UIDefaults):Void{
    69  		super.initComponentDefaults(table);
    70  		
    71  	    // *** Buttons
    72  	    var comDefaults:Array = [
    73  	    "Button.upperBgGradDown", new ASColorUIResource(0xdcd8cf),
    74  	    "Button.lowerBgGradDown", new ASColorUIResource(0xf2f1ee),
    75  	    "Button.upperBgGradUp", new ASColorUIResource(0xFFFFFF),
    76  	    "Button.lowerBgGradUp", new ASColorUIResource(0xd6d0c5),
    77          "Button.highlight", new ASColorUIResource(0x003c74),
    78  	    "Button.border", org.aswing.plaf.winxp.border.ButtonBorder,
    79  	    "Button.margin", new InsetsUIResource(2, 14, 2, 14),
    80  	    "Button.textIconGap", 2,
    81  	    "Button.textShiftOffset", 1];
    82  	    table.putDefaults(comDefaults);
    83  	    
    84  	     // *** ToggleButton
    85  	     comDefaults = [
    86  	    "ToggleButton.upperBgGradDown", new ASColorUIResource(0xdcd8cf),
    87  	    "ToggleButton.lowerBgGradDown", new ASColorUIResource(0xe0e0d7),
    88  	    "ToggleButton.upperBgGradUp", new ASColorUIResource(0xFFFFFF),
    89  	    "ToggleButton.lowerBgGradUp", new ASColorUIResource(0xd6d0c5),
    90          "ToggleButton.highlight", new ASColorUIResource(0x003c74),
    91          "ToggleButton.font", table.getFont("controlFont"),
    92  		"ToggleButton.border", org.aswing.plaf.winxp.border.ButtonBorder,
    93  		"ToggleButton.margin", new InsetsUIResource(0, 0, 0, 0),
    94  		"ToggleButton.textShiftOffset", 1];
    95  	    table.putDefaults(comDefaults);
    96  	    
    97  	    // *** Panel
    98  	    comDefaults = [
    99  	    "Panel.background", new ASColorUIResource(0xece9d8),
   100  	    "Panel.foreground", table.get("windowText")
   101  	    ];
   102  	    table.putDefaults(comDefaults);
   103  	    
   104  	     // *** RadioButton
   105  	    comDefaults = [
   106  	    "RadioButton.background", new ASColorUIResource(0xece9d8),
   107  	    "RadioButton.foreground", table.get("controlText"),
   108  	    "RadioButton.shadow", new ASColorUIResource(0xEAEAEA),
   109          "RadioButton.upperGradUp", new ASColorUIResource(0xe5e5e2),
   110          "RadioButton.lowerGradUp",new ASColorUIResource(0xfbfbfa),
   111          "RadioButton.dotUpperGradUp", new ASColorUIResource(0x55d551),
   112          "RadioButton.dotLowerGradUp",new ASColorUIResource(0x22a220),
   113          "RadioButton.highlight",new ASColorUIResource(0x003c74),
   114          "RadioButton.font", table.getFont("controlFont"),
   115  		"RadioButton.icon", org.aswing.plaf.winxp.icon.RadioButtonIcon,
   116  		"RadioButton.margin", new InsetsUIResource(0, 0, 0, 0),
   117  		"RadioButton.textShiftOffset", 1];
   118  	    table.putDefaults(comDefaults);	    
   119  	    
   120  	    // *** CheckBox
   121  	    comDefaults = [
   122  	    "CheckBox.background",new ASColorUIResource(0xece9d8),
   123  	    "CheckBox.foreground", table.get("controlText"),
   124  	    "CheckBox.shadow", table.getColor("controlShadow"),
   125  	     "CheckBox.highlight",new ASColorUIResource(0x003c74),
   126          "CheckBox.upperGradUp", new ASColorUIResource(0xe5e5e2),
   127          "CheckBox.lowerGradUp", new ASColorUIResource(0xfbfbfa),
   128          "CheckBox.dotUpperGradUp", new ASColorUIResource(0x21a121),
   129           "CheckBox.dotLowerGradUp",new ASColorUIResource(0x22a220),
   130          "CheckBox.font", table.getFont("controlFont"),
   131  		"CheckBox.icon", org.aswing.plaf.winxp.icon.CheckBoxIcon,
   132  		"CheckBox.margin", new InsetsUIResource(0, 0, 0, 0),
   133  		"CheckBox.textShiftOffset", 1];
   134  	    table.putDefaults(comDefaults);
   135  	    
   136  	     // *** TextField
   137  	    comDefaults = [
   138  	    "TextField.background", new ASColorUIResource(0xffffff),
   139  	    "TextField.foreground", new ASColorUIResource(0x000000),
   140          "TextField.shadow", new ASColorUIResource(0x999999),
   141          "TextField.darkShadow", new ASColorUIResource(0xDCDEDD),
   142          "TextField.light", new ASColorUIResource(0xDCDEDD),
   143          "TextField.highlight", new ASColorUIResource(0x7f9db9),
   144          "TextField.font", table.getFont("controlFont"),
   145  		"TextField.border", org.aswing.plaf.winxp.border.TextFieldBorder];
   146  	    table.putDefaults(comDefaults);
   147  	    
   148  	     // *** TextField
   149  	    comDefaults = [
   150  	    "TextArea.background", new ASColorUIResource(0xffffff),
   151  	    "TextArea.foreground", new ASColorUIResource(0x000000),
   152          "TextArea.shadow", new ASColorUIResource(0x999999),
   153          "TextArea.darkShadow", new ASColorUIResource(0xDCDEDD),
   154          "TextArea.light", new ASColorUIResource(0xDCDEDD),
   155          "TextArea.highlight", new ASColorUIResource(0x7f9db9),
   156          "TextArea.font", table.getFont("controlFont"),
   157  		"TextArea.border", org.aswing.plaf.winxp.border.TextAreaBorder];
   158  	    table.putDefaults(comDefaults);
   159  	    
   160  	     // *** Frame
   161  	    comDefaults = [
   162  	    "Frame.background", table.get("window"),
   163  	    "Frame.foreground", new ASColorUIResource(0xffffff),
   164  	    "Frame.activeCaption", table.get("activeCaption"),
   165  	    "Frame.activeCaptionText", table.get("activeCaptionText"),
   166  	    "Frame.activeCaptionBorder", table.get("activeCaptionBorder"),
   167  	    "Frame.inactiveCaption", table.get("inactiveCaption"),
   168  	    "Frame.inactiveCaptionText", table.get("inactiveCaptionText"),
   169  	    "Frame.inactiveCaptionBorder", table.get("inactiveCaptionBorder"),
   170  	    "Frame.resizeArrow", table.get("inactiveCaption"),
   171  	    "Frame.resizeArrowLight", table.get("window"),
   172  	    "Frame.resizeArrowDark", table.get("activeCaptionText"),
   173  	    "Frame.titleBarUI", org.aswing.plaf.winxp.frame.WinXpTitleBarUI,
   174  	    "Frame.resizer", org.aswing.plaf.basic.frame.Resizer,
   175  	    "Frame.font", table.get("windowFont"),
   176  	    "Frame.border", org.aswing.plaf.basic.border.FrameBorder,
   177  	    "Frame.icon", org.aswing.plaf.basic.frame.TitleIcon,
   178  	    "Frame.iconifiedIcon", org.aswing.plaf.basic.icon.FrameIconifiedIcon,
   179  	    "Frame.normalIcon", org.aswing.plaf.basic.icon.FrameNormalIcon,
   180  	    "Frame.maximizeIcon", org.aswing.plaf.basic.icon.FrameMaximizeIcon,
   181  	    "Frame.closeIcon", org.aswing.plaf.basic.icon.FrameCloseIcon
   182  	    ];
   183  	    table.putDefaults(comDefaults);	  
   184  	    
   185  	    // *** Window
   186  	    comDefaults = [
   187  	    "Window.background", new ASColorUIResource(0xece9d8),
   188  	    "Window.foreground", table.get("windowText"),
   189  	    "Window.modalColor", table.get("controlShadow")
   190  	    ];
   191  	    table.putDefaults(comDefaults);
   192  	}	
   193  	
   194  	
   195  }
   196