001: /*
002: * Copyright (c) 2001-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.looks;
032:
033: import java.awt.Insets;
034:
035: import javax.swing.plaf.InsetsUIResource;
036:
037: /**
038: * Describes the insets and margins used by a Look&Feel or theme.
039: *
040: * @author Karsten Lentzsch
041: * @version $Revision: 1.4 $
042: *
043: * @since 2.1
044: */
045: public final class MicroLayout {
046:
047: private final InsetsUIResource textInsets;
048: private final InsetsUIResource wrappedTextInsets;
049: private final InsetsUIResource comboBoxEditorInsets;
050: private final Insets buttonBorderInsets;
051: private final InsetsUIResource buttonMargin;
052: private final InsetsUIResource commitButtonMargin;
053: private final int comboBorderSize;
054: private final int comboPopupBorderSize;
055: private final InsetsUIResource checkBoxMargin;
056: private final InsetsUIResource menuItemMargin;
057: private final InsetsUIResource menuMargin;
058: private final InsetsUIResource popupMenuSeparatorMargin;
059:
060: // Instance Creation ******************************************************
061:
062: public MicroLayout(InsetsUIResource textInsets,
063: InsetsUIResource wrappedTextInsets,
064: InsetsUIResource comboBoxEditorInsets, int comboBorderSize,
065: int comboPopupBorderSize, Insets buttonBorderInsets,
066: InsetsUIResource buttonMargin,
067: InsetsUIResource commitButtonMargin,
068: InsetsUIResource checkBoxMargin,
069: InsetsUIResource menuItemMargin,
070: InsetsUIResource menuMargin,
071: InsetsUIResource popupMenuSeparatorMargin) {
072: this .textInsets = textInsets;
073: this .wrappedTextInsets = wrappedTextInsets;
074: this .comboBoxEditorInsets = comboBoxEditorInsets;
075: this .buttonBorderInsets = buttonBorderInsets;
076: this .buttonMargin = buttonMargin;
077: this .commitButtonMargin = commitButtonMargin;
078: this .comboBorderSize = comboBorderSize;
079: this .comboPopupBorderSize = comboPopupBorderSize;
080: this .checkBoxMargin = checkBoxMargin;
081: this .menuItemMargin = menuItemMargin;
082: this .menuMargin = menuMargin;
083: this .popupMenuSeparatorMargin = popupMenuSeparatorMargin;
084: }
085:
086: // Getters ****************************************************************
087:
088: /**
089: * Returns the insets used for button borders.
090: *
091: * @return the insets used for button borders.
092: */
093: public Insets getButtonBorderInsets() {
094: return buttonBorderInsets;
095: }
096:
097: /**
098: * Returns the margin used for standard buttons. These insets describe
099: * buttons that are arranged with other components in a row of a form.
100: * The standard button <em>height</em> will often be the same for
101: * text fields, combo boxes, and other components that are arranged in
102: * a row.<p>
103: *
104: * Toolbar buttons may have a different height, as well as
105: * commit buttons that are placed in a special command bar area,
106: * for example OK, Cancel, Apply.
107: *
108: * @return the margin for standard buttons.
109: *
110: * @see #getCommitButtonMargin()
111: */
112: public InsetsUIResource getButtonMargin() {
113: return buttonMargin;
114: }
115:
116: /**
117: * Returns the margin used for commit buttons in command areas.
118: * Such command areas are often at the bottom or side of a dialog or pane;
119: * frequently used labels are OK, Cancel, Apply, Yes, No, Retry.
120: * The <em>height</em> of a commit button may differ from the height
121: * used for buttons that are arranged in a row with other components
122: * in a form.
123: *
124: * @return the margin for commit buttons in command areas.
125: *
126: * @see #getButtonMargin()
127: */
128: public InsetsUIResource getCommitButtonMargin() {
129: return commitButtonMargin;
130: }
131:
132: public int getComboBorderSize() {
133: return comboBorderSize;
134: }
135:
136: public int getComboPopupBorderSize() {
137: return comboPopupBorderSize;
138: }
139:
140: public InsetsUIResource getComboBoxEditorInsets() {
141: return comboBoxEditorInsets;
142: }
143:
144: public InsetsUIResource getCheckBoxMargin() {
145: return checkBoxMargin;
146: }
147:
148: public InsetsUIResource getMenuItemMargin() {
149: return menuItemMargin;
150: }
151:
152: public InsetsUIResource getMenuMargin() {
153: return menuMargin;
154: }
155:
156: public InsetsUIResource getPopupMenuSeparatorMargin() {
157: return popupMenuSeparatorMargin;
158: }
159:
160: public InsetsUIResource getTextInsets() {
161: return textInsets;
162: }
163:
164: public InsetsUIResource getWrappedTextInsets() {
165: return wrappedTextInsets;
166: }
167:
168: }
|