001: /*
002: * Copyright (c) 2002-2007 JGoodies Karsten Lentzsch. All Rights Reserved.
003: *
004: * Redistribution and use in source and binary forms, with or without
005: * modification, are permitted provided that the following conditions are met:
006: *
007: * o Redistributions of source code must retain the above copyright notice,
008: * this list of conditions and the following disclaimer.
009: *
010: * o Redistributions in binary form must reproduce the above copyright notice,
011: * this list of conditions and the following disclaimer in the documentation
012: * and/or other materials provided with the distribution.
013: *
014: * o Neither the name of JGoodies Karsten Lentzsch nor the names of
015: * its contributors may be used to endorse or promote products derived
016: * from this software without specific prior written permission.
017: *
018: * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
019: * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
020: * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
021: * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
022: * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
023: * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
024: * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
025: * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
026: * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
027: * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
028: * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
029: */
030:
031: package com.jgoodies.forms.util;
032:
033: import com.jgoodies.forms.layout.ConstantSize;
034: import com.jgoodies.forms.layout.Size;
035: import com.jgoodies.forms.layout.Sizes;
036:
037: /**
038: * A {@link LayoutStyle} that aims to provide layout constants as defined by
039: * Microsoft's <i>Design Specifications and Guidelines - Visual Design</i>.
040: *
041: * @author Karsten Lentzsch
042: * @version $Revision: 1.2 $
043: */
044:
045: final class MacLayoutStyle extends LayoutStyle {
046:
047: static final MacLayoutStyle INSTANCE = new MacLayoutStyle();
048:
049: private MacLayoutStyle() {
050: // Suppresses default constructor, ensuring non-instantiability.
051: }
052:
053: // Component Sizes ******************************************************
054:
055: private static final Size BUTTON_WIDTH = Sizes.dluX(39);
056: private static final Size BUTTON_HEIGHT = Sizes.dluY(14);
057:
058: // Gaps ******************************************************************
059:
060: private static final ConstantSize DIALOG_MARGIN_X = Sizes.DLUX9;
061: private static final ConstantSize DIALOG_MARGIN_Y = Sizes.DLUY9;
062:
063: private static final ConstantSize TABBED_DIALOG_MARGIN_X = Sizes.DLUX4;
064: private static final ConstantSize TABBED_DIALOG_MARGIN_Y = Sizes.DLUY4;
065:
066: private static final ConstantSize LABEL_COMPONENT_PADX = Sizes.DLUX3;
067: private static final ConstantSize RELATED_COMPONENTS_PADX = Sizes.DLUX4;
068: private static final ConstantSize UNRELATED_COMPONENTS_PADX = Sizes.DLUX8;
069:
070: private static final ConstantSize RELATED_COMPONENTS_PADY = Sizes.DLUY3;
071: private static final ConstantSize UNRELATED_COMPONENTS_PADY = Sizes.DLUY6;
072: private static final ConstantSize NARROW_LINE_PAD = Sizes.DLUY2;
073: private static final ConstantSize LINE_PAD = Sizes.DLUY3;
074: private static final ConstantSize PARAGRAPH_PAD = Sizes.DLUY9;
075: private static final ConstantSize BUTTON_BAR_PAD = Sizes.DLUY4;
076:
077: // Layout Sizes *********************************************************
078:
079: /**
080: * Returns this style's default button width.
081: *
082: * @return the default button width
083: *
084: * @see #getDefaultButtonHeight()
085: */
086: public Size getDefaultButtonWidth() {
087: return BUTTON_WIDTH;
088: }
089:
090: /**
091: * Returns this style's default button height.
092: *
093: * @return the default button height
094: *
095: * @see #getDefaultButtonWidth()
096: */
097: public Size getDefaultButtonHeight() {
098: return BUTTON_HEIGHT;
099: }
100:
101: /**
102: * Returns this style's horizontal margin for general dialogs.
103: *
104: * @return the horizontal margin for general dialogs
105: *
106: * @see #getDialogMarginY()
107: * @see #getTabbedDialogMarginX()
108: */
109: public ConstantSize getDialogMarginX() {
110: return DIALOG_MARGIN_X;
111: }
112:
113: /**
114: * Returns this style's vertical margin for general dialogs.
115: *
116: * @return the vertical margin for general dialogs
117: *
118: * @see #getDialogMarginX()
119: * @see #getTabbedDialogMarginY()
120: */
121: public ConstantSize getDialogMarginY() {
122: return DIALOG_MARGIN_Y;
123: }
124:
125: /**
126: * Returns this style's horizontal margin for dialogs that consist of
127: * a tabbed pane.
128: *
129: * @return the horizontal margin for dialogs that consist of a tabbed pane
130: * @since 1.0.3
131: *
132: * @see #getTabbedDialogMarginY()
133: * @see #getDialogMarginX()
134: */
135: public ConstantSize getTabbedDialogMarginX() {
136: return TABBED_DIALOG_MARGIN_X;
137: }
138:
139: /**
140: * Returns this style's vertical margin for dialogs that consist of
141: * a tabbed pane.
142: *
143: * @return the vertical margin for dialogs that consist of a tabbed pane
144: * @since 1.0.3
145: *
146: * @see #getTabbedDialogMarginX()
147: * @see #getDialogMarginY()
148: */
149: public ConstantSize getTabbedDialogMarginY() {
150: return TABBED_DIALOG_MARGIN_Y;
151: }
152:
153: /**
154: * Returns a gap used to separate a label and associated control.
155: *
156: * @return a gap between label and associated control
157: *
158: * @see #getRelatedComponentsPadX()
159: * @see #getUnrelatedComponentsPadX()
160: */
161: public ConstantSize getLabelComponentPadX() {
162: return LABEL_COMPONENT_PADX;
163: }
164:
165: /**
166: * Returns a horizontal gap used to separate related controls.
167: *
168: * @return a horizontal gap between related controls
169: *
170: * @see #getLabelComponentPadX()
171: * @see #getRelatedComponentsPadY()
172: * @see #getUnrelatedComponentsPadX()
173: */
174: public ConstantSize getRelatedComponentsPadX() {
175: return RELATED_COMPONENTS_PADX;
176: }
177:
178: /**
179: * Returns a vertical gap used to separate related controls.
180: *
181: * @return a vertical gap between related controls
182: *
183: * @see #getRelatedComponentsPadX()
184: * @see #getUnrelatedComponentsPadY()
185: */
186: public ConstantSize getRelatedComponentsPadY() {
187: return RELATED_COMPONENTS_PADY;
188: }
189:
190: /**
191: * Returns a horizontal gap used to separate unrelated controls.
192: *
193: * @return a horizontal gap between unrelated controls
194: *
195: * @see #getLabelComponentPadX()
196: * @see #getUnrelatedComponentsPadY()
197: * @see #getRelatedComponentsPadX()
198: */
199: public ConstantSize getUnrelatedComponentsPadX() {
200: return UNRELATED_COMPONENTS_PADX;
201: }
202:
203: /**
204: * Returns a vertical gap used to separate unrelated controls.
205: *
206: * @return a vertical gap between unrelated controls
207: *
208: * @see #getUnrelatedComponentsPadX()
209: * @see #getRelatedComponentsPadY()
210: */
211: public ConstantSize getUnrelatedComponentsPadY() {
212: return UNRELATED_COMPONENTS_PADY;
213: }
214:
215: /**
216: * Returns a narrow vertical pad used to separate lines.
217: *
218: * @return a narrow vertical pad used to separate lines
219: *
220: * @see #getLinePad()
221: * @see #getParagraphPad()
222: */
223: public ConstantSize getNarrowLinePad() {
224: return NARROW_LINE_PAD;
225: }
226:
227: /**
228: * Returns a narrow vertical pad used to separate lines.
229: *
230: * @return a vertical pad used to separate lines
231: *
232: * @see #getNarrowLinePad()
233: * @see #getParagraphPad()
234: */
235: public ConstantSize getLinePad() {
236: return LINE_PAD;
237: }
238:
239: /**
240: * Returns a pad used to separate paragraphs.
241: *
242: * @return a vertical pad used to separate paragraphs
243: *
244: * @see #getNarrowLinePad()
245: * @see #getLinePad()
246: */
247: public ConstantSize getParagraphPad() {
248: return PARAGRAPH_PAD;
249: }
250:
251: /**
252: * Returns a pad used to separate a button bar from a component.
253: *
254: * @return a vertical pad used to separate paragraphs
255: * @since 1.0.3
256: *
257: * @see #getRelatedComponentsPadY()
258: * @see #getUnrelatedComponentsPadY()
259: */
260: public ConstantSize getButtonBarPad() {
261: return BUTTON_BAR_PAD;
262: }
263:
264: /**
265: * Checks and answers whether buttons are typically ordered from
266: * left to right or from right to left. Useful for building button bars
267: * that shall comply with the platform's layout style guide.<p>
268: *
269: * For example the Windows style guide recommends to layout out
270: * <em>OK, Cancel, Apply</em> from left to right, where the
271: * Mac Aqua style guide recommends to layout out these buttons
272: * from right to left.<p>
273: *
274: * Although most button sequences shall honor this order
275: * some buttons require a left to right order. For example
276: * <em>Back, Next</em> or <em>Move Left, Move Right</em>.<p>
277: *
278: * @return true if buttons are typically ordered from left to right
279: * @since 1.0.3
280: *
281: * @see com.jgoodies.forms.builder.ButtonBarBuilder
282: * @see com.jgoodies.forms.factories.ButtonBarFactory
283: */
284: public boolean isLeftToRightButtonOrder() {
285: return false;
286: }
287:
288: }
|