KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > jgoodies > forms > util > WindowsLayoutStyle


1 /*
2  * Copyright (c) 2003 JGoodies Karsten Lentzsch. All Rights Reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions are met:
6  *
7  * o Redistributions of source code must retain the above copyright notice,
8  * this list of conditions and the following disclaimer.
9  *
10  * o Redistributions in binary form must reproduce the above copyright notice,
11  * this list of conditions and the following disclaimer in the documentation
12  * and/or other materials provided with the distribution.
13  *
14  * o Neither the name of JGoodies Karsten Lentzsch nor the names of
15  * its contributors may be used to endorse or promote products derived
16  * from this software without specific prior written permission.
17  *
18  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
20  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
21  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
22  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
23  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
25  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
26  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
27  * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
28  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29  */

30
31 package com.jgoodies.forms.util;
32
33 import com.jgoodies.forms.layout.ConstantSize;
34 import com.jgoodies.forms.layout.Size;
35 import com.jgoodies.forms.layout.Sizes;
36
37 /**
38  * A {@link LayoutStyle} that aims to provide layout constants as defined by
39  * Microsoft's <i>Design Specifications and Guidelines - Visual Design</i>.
40  *
41  * @author Karsten Lentzsch
42  * @version $Revision: 1.3 $
43  */

44
45 final class WindowsLayoutStyle extends LayoutStyle {
46     
47     static final WindowsLayoutStyle INSTANCE = new WindowsLayoutStyle();
48     
49     private WindowsLayoutStyle() {
50         // Suppresses default constructor, ensuring non-instantiability.
51
}
52     
53
54     // Component Sizes ******************************************************
55

56     private static final Size BUTTON_WIDTH = Sizes.dluX(50);
57     private static final Size BUTTON_HEIGHT = Sizes.dluY(14);
58     
59
60     // Gaps ******************************************************************
61

62     private static final ConstantSize DIALOG_MARGIN_X = Sizes.DLUX7;
63     private static final ConstantSize DIALOG_MARGIN_Y = Sizes.DLUY7;
64     
65     private static final ConstantSize LABEL_COMPONENT_PADX = Sizes.DLUX3;
66     private static final ConstantSize RELATED_COMPONENTS_PADX = Sizes.DLUX4;
67     private static final ConstantSize RELATED_COMPONENTS_PADY = Sizes.DLUY4;
68     private static final ConstantSize UNRELATED_COMPONENTS_PADX = Sizes.DLUX7;
69     private static final ConstantSize UNRELATED_COMPONENTS_PADY = Sizes.DLUY7;
70     private static final ConstantSize NARROW_LINE_PAD = Sizes.DLUY2;
71     private static final ConstantSize LINE_PAD = Sizes.DLUY3;
72     private static final ConstantSize PARAGRAPH_PAD = Sizes.DLUY9;
73
74
75     // Layout Sizes *********************************************************
76

77     /**
78      * Answers the style's default button width.
79      *
80      * @return the default button width
81      */

82     public Size getDefaultButtonWidth() {
83         return BUTTON_WIDTH;
84     }
85
86     /**
87      * Answers the style's default button height.
88      *
89      * @return the default button height
90      */

91     public Size getDefaultButtonHeight() {
92         return BUTTON_HEIGHT;
93     }
94
95     /**
96      * Answers the style's horizontal dialog margin.
97      *
98      * @return the horizontal dialog margin
99      */

100     public ConstantSize getDialogMarginX() {
101         return DIALOG_MARGIN_X;
102     }
103
104     /**
105      * Answers the style's vertical dialog margin.
106      *
107      * @return the vertical dialog margin
108      */

109     public ConstantSize getDialogMarginY() {
110         return DIALOG_MARGIN_Y;
111     }
112
113     /**
114      * Answers a gap used to separate a label and associated control.
115      *
116      * @return a gap between label and associated control
117      */

118     public ConstantSize getLabelComponentPadX() {
119         return LABEL_COMPONENT_PADX;
120     }
121
122     /**
123      * Answers a horizontal gap used to separate related controls.
124      *
125      * @return a horizontal gap between related controls
126      */

127     public ConstantSize getRelatedComponentsPadX() {
128         return RELATED_COMPONENTS_PADX;
129     }
130
131     /**
132      * Answers a vertical gap used to separate related controls.
133      *
134      * @return a vertical gap between related controls
135      */

136     public ConstantSize getRelatedComponentsPadY() {
137         return RELATED_COMPONENTS_PADY;
138     }
139
140     /**
141      * Answers a horizontal gap used to separate unrelated controls.
142      *
143      * @return a horizontal gap between unrelated controls
144      */

145     public ConstantSize getUnrelatedComponentsPadX() {
146         return UNRELATED_COMPONENTS_PADX;
147     }
148
149     /**
150      * Answers a vertical gap used to separate unrelated controls.
151      *
152      * @return a vertical gap between unrelated controls
153      */

154     public ConstantSize getUnrelatedComponentsPadY() {
155         return UNRELATED_COMPONENTS_PADY;
156     }
157
158     /**
159      * Answers a narrow vertical pad used to separate lines.
160      *
161      * @return a vertical pad used to separate lines
162      */

163     public ConstantSize getLinePad() {
164         return LINE_PAD;
165     }
166
167     /**
168      * Answers a narrow vertical pad used to separate lines.
169      *
170      * @return a narrow vertical pad used to separate lines
171      */

172     public ConstantSize getNarrowLinePad() {
173         return NARROW_LINE_PAD;
174     }
175
176     /**
177      * Answers a pad used to paragraphs.
178      *
179      * @return a vertical pad used to separate paragraphs
180      */

181     public ConstantSize getParagraphPad() {
182         return PARAGRAPH_PAD;
183     }
184
185 }
Popular Tags