01: /*
02: * GWT-Ext Widget Library
03: * Copyright(c) 2007-2008, GWT-Ext.
04: * licensing@gwt-ext.com
05: *
06: * http://www.gwt-ext.com/license
07: */
08: package com.gwtext.client.core;
09:
10: import com.google.gwt.core.client.JavaScriptObject;
11: import com.gwtext.client.util.JavaScriptObjectHelper;
12:
13: /**
14: * Class that represents the Paddings around an element.
15: */
16: public class Paddings {
17:
18: private int top;
19: private int left;
20: private int right;
21: private int bottom;
22:
23: /**
24: * Create a new instance.
25: *
26: * @param top the top padding
27: * @param left the left padding
28: * @param right the right padding
29: * @param bottom the bottom padding
30: */
31: public Paddings(int top, int left, int right, int bottom) {
32: this .top = top;
33: this .left = left;
34: this .right = right;
35: this .bottom = bottom;
36: }
37:
38: private static Paddings instance(JavaScriptObject jsObj) {
39: return new Paddings(JavaScriptObjectHelper.getIntArrayValue(
40: jsObj, 0), JavaScriptObjectHelper.getIntArrayValue(
41: jsObj, 1), JavaScriptObjectHelper.getIntArrayValue(
42: jsObj, 2), JavaScriptObjectHelper.getIntArrayValue(
43: jsObj, 3));
44: }
45:
46: /**
47: * @return the top padding
48: */
49: public int getTop() {
50: return top;
51: }
52:
53: /**
54: * @return the left padding
55: */
56: public int getLeft() {
57: return left;
58: }
59:
60: /**
61: * @return the right padding
62: */
63: public int getRight() {
64: return right;
65: }
66:
67: /**
68: * @return the bottom padding
69: */
70: public int getBottom() {
71: return bottom;
72: }
73:
74: /**
75: * Return the paddings as a CSS style string.
76: *
77: * @return padding as style String
78: */
79: public String getStyleString() {
80: return "padding:" + top + "px " + right + "px " + bottom
81: + "px " + left + "px;";
82: }
83: }
|