Browse Source

add outline property

tags/release-1.3.2
Julien Dramaix 13 years ago
parent
commit
ee7b59d4c8

+ 5
- 6
gwtquery-core/src/main/java/com/google/gwt/query/client/css/BorderProperty.java View File

@@ -17,16 +17,15 @@ package com.google.gwt.query.client.css;

import com.google.gwt.dom.client.Style;
import com.google.gwt.dom.client.Style.HasCssName;
import com.google.gwt.query.client.css.BorderStyleProperty.BorderStyle;
import com.google.gwt.query.client.css.BorderWidthProperty.BorderWidth;
import com.google.gwt.query.client.css.BorderStyleProperty.LineStyle;
import com.google.gwt.query.client.css.BorderWidthProperty.LineWidth;

/**
*
*
*/
public class BorderProperty
implements
CssShorthandProperty3<BorderWidthProperty.BorderWidth, BorderStyleProperty.BorderStyle, RGBColor> {
public class BorderProperty implements
CssShorthandProperty3<LineWidth, LineStyle, RGBColor> {

private static final String CSS_PROPERTY = "border";

@@ -48,7 +47,7 @@ public class BorderProperty
return CSS_PROPERTY;
}

public void set(Style s, BorderWidth borderWidth, BorderStyle borderStyle,
public void set(Style s, LineWidth borderWidth, LineStyle borderStyle,
RGBColor borderColor) {
String value = notNull(borderWidth) + notNull(borderStyle)
+ notNull(borderColor).trim();

+ 3
- 2
gwtquery-core/src/main/java/com/google/gwt/query/client/css/BorderStyleProperty.java View File

@@ -21,9 +21,9 @@ import com.google.gwt.dom.client.Style.HasCssName;
* This property describes the foreground color of an element's text content.
*/
public class BorderStyleProperty extends
AbstractCssProperty<BorderStyleProperty.BorderStyle> {
AbstractCssProperty<BorderStyleProperty.LineStyle> {

public static enum BorderStyle implements HasCssName {
public static enum LineStyle implements HasCssName {
DASHED {
@Override
public String getCssName() {
@@ -93,6 +93,7 @@ public class BorderStyleProperty extends

public abstract String getCssName();
}

private static final String BORDER_BOTTOM_STYLE_PROPERTY = "borderBottomStyle";
private static final String BORDER_LEFT_STYLE_PROPERTY = "borderLeftStyle";
private static final String BORDER_RIGHT_STYLE_PROPERTY = "borderRightStyle";

+ 15
- 15
gwtquery-core/src/main/java/com/google/gwt/query/client/css/BorderWidthProperty.java View File

@@ -23,34 +23,34 @@ import com.google.gwt.dom.client.Style.Unit;
* This property set the width of an element's border.
*/
public class BorderWidthProperty extends
AbstractCssProperty<BorderWidthProperty.BorderWidth> implements TakesLength {
AbstractCssProperty<BorderWidthProperty.LineWidth> implements TakesLength {

public static class BorderWidth implements HasCssName {
public static class LineWidth implements HasCssName {

public static BorderWidth INHERIT;
public static BorderWidth MEDIUM;
public static BorderWidth THICK;
public static BorderWidth THIN;
public static LineWidth INHERIT;
public static LineWidth MEDIUM;
public static LineWidth THICK;
public static LineWidth THIN;

static {
MEDIUM = new BorderWidth("medium");
THICK = new BorderWidth("thick");
THIN = new BorderWidth("thin");
INHERIT = new BorderWidth(CSS.INHERIT_VALUE);
MEDIUM = new LineWidth("medium");
THICK = new LineWidth("thick");
THIN = new LineWidth("thin");
INHERIT = new LineWidth(CSS.INHERIT_VALUE);

}

public static BorderWidth length(int l, Unit unit) {
return new BorderWidth("" + l + (unit != null ? unit.getType() : ""));
public static LineWidth length(int l, Unit unit) {
return new LineWidth("" + l + (unit != null ? unit.getType() : ""));
}

public static BorderWidth length(Length l) {
return new BorderWidth(l.getCssName());
public static LineWidth length(Length l) {
return new LineWidth(l.getCssName());
}

private String cssValue;

private BorderWidth(String value) {
private LineWidth(String value) {
cssValue = value;
}


+ 62
- 31
gwtquery-core/src/main/java/com/google/gwt/query/client/css/CSS.java View File

@@ -22,7 +22,7 @@ package com.google.gwt.query.client.css;
public class CSS {

public static BackgroundProperty BACKGROUND;
/**
* background image is specified, this property specifies whether it is fixed
* with regard to the viewport ('fixed') or scrolls along with the containing
@@ -53,19 +53,19 @@ public class CSS {
public static BorderStyleProperty BORDER_LEFT_STYLE;

public static BorderWidthProperty BORDER_LEFT_WIDTH;
public static BorderColorProperty BORDER_RIGHT_COLOR;
public static BorderStyleProperty BORDER_RIGHT_STYLE;
public static BorderWidthProperty BORDER_RIGHT_WIDTH;
public static BorderStyleProperty BORDER_STYLE;

public static BorderColorProperty BORDER_TOP_COLOR;
public static BorderStyleProperty BORDER_TOP_STYLE;
public static BorderWidthProperty BORDER_TOP_WIDTH;

public static BorderWidthProperty BORDER_WIDTH;
@@ -90,15 +90,15 @@ public class CSS {
* that generate boxes that are not absolutely positioned.
*/
public static FloatProperty FLOAT;
public static FontSizeProperty FONT_SIZE;
public static FontStyleProperty FONT_STYLE;
public static FontVariantProperty FONT_VARIANT;
public static FontWeightProperty FONT_WEIGHT;
/**
* This property specifies the content height of boxes generated by
* block-level, inline-block and replaced elements.
@@ -108,55 +108,55 @@ public class CSS {
* for the rules used instead.
*/
public static HeightProperty HEIGHT;
public static final String INHERIT_VALUE = "inherit";
public static ListStyleProperty LIST_STYLE;
public static ListStyleImageProperty LIST_STYLE_IMAGE;
public static ListStylePositionProperty LIST_STYLE_POSITION;
public static ListStyleTypeProperty LIST_STYLE_TYPE;
public static MarginProperty MARGIN;
public static MarginProperty MARGIN_BOTTOM;
public static MarginProperty MARGIN_LEFT;
public static MarginProperty MARGIN_RIGHT;
public static MarginProperty MARGIN_TOP;
public static PaddingProperty PADDING;
public static PaddingProperty PADDING_BOTTOM;
public static PaddingProperty PADDING_LEFT;
public static PaddingProperty PADDING_RIGHT;
public static PaddingProperty PADDING_TOP;
/**
* This property describes how inline content of a block is aligned.
*/
public static TextAlignProperty TEXT_ALIGN;
/**
* This property affects the vertical positioning inside a line box of the
* boxes generated by an inline-level element.
*/
public static VerticalAlignProperty VERTICAL_ALIGN;
/**
* The 'visibility' property specifies whether the boxes generated by an
* element are rendered. Invisible boxes still affect layout (set the
* 'display' property to 'none' to suppress box generation altogether).
*/
public static VisibilityProperty VISIBILITY;
/**
* This property specifies the content width of boxes generated by block-level
* and replaced elements.
@@ -173,6 +173,36 @@ public class CSS {
*/
public static WidthProperty WIDTH;

/**
* An outline is a line that is drawn around elements (outside the borders) to
* make the element "stand out". The outline-color property specifies the
* color of an outline.
*/
public static OutlineColorProperty OUTLINE_COLOR;

/**
* An outline is a line that is drawn around elements (outside the borders) to
* make the element "stand out". The outline-color property specifies the
* style of an outline.
*/
public static OutlineStyleProperty OUTLINE_STYLE;
/**
* An outline is a line that is drawn around elements (outside the borders) to
* make the element "stand out".
* The outline-width specifies the width of an outline
*/
public static OutlineWidthProperty OUTLINE_WIDTH;

/**
* An outline is a line that is drawn around elements (outside the borders) to
* make the element "stand out".
*
* The outline shorthand property sets all the outline properties in one
* declaration.
*/
public static OutlineProperty OUTLINE;

static {
BackgroundProperty.init();
BorderProperty.init();
@@ -187,6 +217,7 @@ public class CSS {
HeightProperty.init();
ListStyleProperty.init();
MarginProperty.init();
OutlineProperty.init();
PaddingProperty.init();
TextAlignProperty.init();
VerticalAlignProperty.init();

+ 38
- 0
gwtquery-core/src/main/java/com/google/gwt/query/client/css/OutlineColorProperty.java View File

@@ -0,0 +1,38 @@
/*
* Copyright 2011, The gwtquery team.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.google.gwt.query.client.css;

/**
* An outline is a line that is drawn around elements (outside the borders) to
* make the element "stand out". The outline-color property specifies the color
* of an outline.
*/
public class OutlineColorProperty extends AbstractCssProperty<RGBColor> {

private static final String CSS_PROPERTY = "outlineColor";

public static void init() {
CSS.OUTLINE_COLOR = new OutlineColorProperty();
}


private OutlineColorProperty() {
}

public String getCssName() {
return CSS_PROPERTY;
}
}

+ 64
- 0
gwtquery-core/src/main/java/com/google/gwt/query/client/css/OutlineProperty.java View File

@@ -0,0 +1,64 @@
/*
* Copyright 2011, The gwtquery team.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.google.gwt.query.client.css;

import com.google.gwt.dom.client.Style;
import com.google.gwt.dom.client.Style.HasCssName;
import com.google.gwt.query.client.css.BorderStyleProperty.LineStyle;
import com.google.gwt.query.client.css.BorderWidthProperty.LineWidth;

/**
* An outline is a line that is drawn around elements (outside the borders) to
* make the element "stand out".
*
* The outline shorthand property sets all the outline properties in one
* declaration.
*/
public class OutlineProperty implements
CssShorthandProperty3<RGBColor, LineStyle, LineWidth> {

private static final String CSS_PROPERTY = "outline";

static void init() {
CSS.OUTLINE = new OutlineProperty();
OutlineStyleProperty.init();
OutlineColorProperty.init();
OutlineWidthProperty.init();
}

private OutlineProperty() {
}

public String get(Style s) {
return s.getProperty(CSS_PROPERTY);
}

public String getCssName() {
return CSS_PROPERTY;
}

public void set(Style s, RGBColor outlineColor, LineStyle outlineStyle,
LineWidth outlineWidth) {
String value = notNull(outlineColor) + notNull(outlineStyle)
+ notNull(outlineWidth).trim();
s.setProperty(CSS_PROPERTY, value);
}

private String notNull(HasCssName value) {
return value != null ? value.getCssName() + " " : "";
}

}

+ 40
- 0
gwtquery-core/src/main/java/com/google/gwt/query/client/css/OutlineStyleProperty.java View File

@@ -0,0 +1,40 @@
/*
* Copyright 2011, The gwtquery team.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.google.gwt.query.client.css;

import com.google.gwt.query.client.css.BorderStyleProperty.LineStyle;

/**
* An outline is a line that is drawn around elements (outside the borders) to
* make the element "stand out". The outline-color property specifies the style
* of an outline.
*/
public class OutlineStyleProperty extends AbstractCssProperty<LineStyle> {

private static final String CSS_PROPERTY = "outlineStyle";

public static void init() {
CSS.OUTLINE_STYLE = new OutlineStyleProperty();
}


private OutlineStyleProperty() {
}

public String getCssName() {
return CSS_PROPERTY;
}
}

+ 46
- 0
gwtquery-core/src/main/java/com/google/gwt/query/client/css/OutlineWidthProperty.java View File

@@ -0,0 +1,46 @@
/*
* Copyright 2011, The gwtquery team.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.google.gwt.query.client.css;

import com.google.gwt.dom.client.Style;
import com.google.gwt.query.client.css.BorderWidthProperty.LineWidth;

/**
* An outline is a line that is drawn around elements (outside the borders) to
* make the element "stand out". The outline-width specifies the width of an
* outline
*/
public class OutlineWidthProperty extends AbstractCssProperty<LineWidth>
implements TakesLength {

private static final String CSS_PROPERTY = "outlineWidth";

public static void init() {
CSS.OUTLINE_WIDTH = new OutlineWidthProperty();
}

private OutlineWidthProperty() {
}

public String getCssName() {
return CSS_PROPERTY;
}

public void set(Style s, Length p) {
s.setProperty(CSS_PROPERTY, p.getCssName());

}
}

+ 43
- 17
gwtquery-core/src/test/java/com/google/gwt/query/client/GQueryCssTest.java View File

@@ -34,8 +34,8 @@ import com.google.gwt.query.client.css.RGBColor;
import com.google.gwt.query.client.css.BackgroundAttachmentProperty.BackgroundAttachment;
import com.google.gwt.query.client.css.BackgroundPositionProperty.BackgroundPosition;
import com.google.gwt.query.client.css.BackgroundRepeatProperty.BackgroundRepeat;
import com.google.gwt.query.client.css.BorderStyleProperty.BorderStyle;
import com.google.gwt.query.client.css.BorderWidthProperty.BorderWidth;
import com.google.gwt.query.client.css.BorderStyleProperty.LineStyle;
import com.google.gwt.query.client.css.BorderWidthProperty.LineWidth;
import com.google.gwt.query.client.css.FontSizeProperty.FontSize;
import com.google.gwt.query.client.css.FontVariantProperty.FontVariant;
import com.google.gwt.query.client.css.ListStylePositionProperty.ListStylePosition;
@@ -218,13 +218,13 @@ public class GQueryCssTest extends GWTTestCase {

$(e).html("<div id='test'>Content</div>");

$("#test").css(CSS.BORDER, BorderWidth.THICK, BorderStyle.DASHED,
$("#test").css(CSS.BORDER, LineWidth.THICK, LineStyle.DASHED,
RGBColor.BLACK);
assertEquals("thick dashed black", $("#test").css("border"));
assertEquals("thick dashed black", $("#test").css(CSS.BORDER));

$("#test").css(CSS.BORDER, BorderWidth.length(15, Unit.PX),
BorderStyle.SOLID, RGBColor.rgb("#000000"));
$("#test").css(CSS.BORDER, LineWidth.length(15, Unit.PX),
LineStyle.SOLID, RGBColor.rgb("#000000"));
assertEquals("15px solid #000000", $("#test").css("border"));
assertEquals("15px solid #000000", $("#test").css(CSS.BORDER));

@@ -234,23 +234,23 @@ public class GQueryCssTest extends GWTTestCase {

$(e).html("<div id='test'>Content</div>");

$("#test").css(CSS.BORDER_STYLE, BorderStyle.DOTTED);
$("#test").css(CSS.BORDER_STYLE, LineStyle.DOTTED);
assertEquals("dotted", $("#test").css("borderStyle"));
assertEquals("dotted", $("#test").css(CSS.BORDER_STYLE));

$("#test").css(CSS.BORDER_BOTTOM_STYLE, BorderStyle.DASHED);
$("#test").css(CSS.BORDER_BOTTOM_STYLE, LineStyle.DASHED);
assertEquals("dashed", $("#test").css("borderBottomStyle"));
assertEquals("dashed", $("#test").css(CSS.BORDER_BOTTOM_STYLE));

$("#test").css(CSS.BORDER_TOP_STYLE, BorderStyle.DOUBLE);
$("#test").css(CSS.BORDER_TOP_STYLE, LineStyle.DOUBLE);
assertEquals("double", $("#test").css("borderTopStyle"));
assertEquals("double", $("#test").css(CSS.BORDER_TOP_STYLE));

$("#test").css(CSS.BORDER_LEFT_STYLE, BorderStyle.HIDDEN);
$("#test").css(CSS.BORDER_LEFT_STYLE, LineStyle.HIDDEN);
assertEquals("hidden", $("#test").css("borderLeftStyle"));
assertEquals("hidden", $("#test").css(CSS.BORDER_LEFT_STYLE));

$("#test").css(CSS.BORDER_RIGHT_STYLE, BorderStyle.SOLID);
$("#test").css(CSS.BORDER_RIGHT_STYLE, LineStyle.SOLID);
assertEquals("solid", $("#test").css("borderRightStyle"));
assertEquals("solid", $("#test").css(CSS.BORDER_RIGHT_STYLE));

@@ -260,32 +260,32 @@ public class GQueryCssTest extends GWTTestCase {

$(e).html("<div id='test'>Content</div>");

$("#test").css(CSS.BORDER_WIDTH, BorderWidth.MEDIUM);
$("#test").css(CSS.BORDER_WIDTH, LineWidth.MEDIUM);
assertEquals("medium", $("#test").css("borderWidth"));
assertEquals("medium", $("#test").css(CSS.BORDER_WIDTH));

$("#test").css(CSS.BORDER_WIDTH, Length.px(15));
assertEquals("15px", $("#test").css(CSS.BORDER_WIDTH));

$("#test").css(CSS.BORDER_WIDTH, BorderWidth.length(Length.px(20)));
$("#test").css(CSS.BORDER_WIDTH, LineWidth.length(Length.px(20)));
assertEquals("20px", $("#test").css(CSS.BORDER_WIDTH));

$("#test").css(CSS.BORDER_WIDTH, BorderWidth.length(20, Unit.MM));
$("#test").css(CSS.BORDER_WIDTH, LineWidth.length(20, Unit.MM));
assertEquals("20mm", $("#test").css(CSS.BORDER_WIDTH));

$("#test").css(CSS.BORDER_BOTTOM_WIDTH, BorderWidth.THICK);
$("#test").css(CSS.BORDER_BOTTOM_WIDTH, LineWidth.THICK);
assertEquals("thick", $("#test").css("borderBottomWidth"));
assertEquals("thick", $("#test").css(CSS.BORDER_BOTTOM_WIDTH));

$("#test").css(CSS.BORDER_TOP_WIDTH, BorderWidth.THIN);
$("#test").css(CSS.BORDER_TOP_WIDTH, LineWidth.THIN);
assertEquals("thin", $("#test").css("borderTopWidth"));
assertEquals("thin", $("#test").css(CSS.BORDER_TOP_WIDTH));

$("#test").css(CSS.BORDER_LEFT_WIDTH, BorderWidth.THIN);
$("#test").css(CSS.BORDER_LEFT_WIDTH, LineWidth.THIN);
assertEquals("thin", $("#test").css("borderLeftWidth"));
assertEquals("thin", $("#test").css(CSS.BORDER_LEFT_WIDTH));

$("#test").css(CSS.BORDER_RIGHT_WIDTH, BorderWidth.THICK);
$("#test").css(CSS.BORDER_RIGHT_WIDTH, LineWidth.THICK);
assertEquals("thick", $("#test").css("borderRightWidth"));
assertEquals("thick", $("#test").css(CSS.BORDER_RIGHT_WIDTH));

@@ -591,6 +591,32 @@ public class GQueryCssTest extends GWTTestCase {
assertEquals("50px", $("#test").css(CSS.MARGIN_RIGHT));
}
public void testOutlineProperty(){
$(e).html("<div id='test'>Content</div>");
$("#test").css(CSS.OUTLINE_WIDTH, Length.px(10));
assertEquals("10px", $("#test").css("outlineWidth"));
assertEquals("10px", $("#test").css(CSS.OUTLINE_WIDTH));
$("#test").css(CSS.OUTLINE_WIDTH, LineWidth.MEDIUM);
assertEquals("medium", $("#test").css("outlineWidth"));
assertEquals("medium", $("#test").css(CSS.OUTLINE_WIDTH));
$("#test").css(CSS.OUTLINE_COLOR, RGBColor.GRAY);
assertEquals("gray", $("#test").css("outlineColor"));
assertEquals("gray", $("#test").css(CSS.OUTLINE_COLOR));
$("#test").css(CSS.OUTLINE_STYLE, LineStyle.DOTTED);
assertEquals("dotted", $("#test").css("outlineStyle"));
assertEquals("dotted", $("#test").css(CSS.OUTLINE_STYLE));

$("#test").css(CSS.OUTLINE, RGBColor.BLACK, LineStyle.DASHED, LineWidth.length(15, Unit.PX));
assertEquals("black dashed 15px", $("#test").css("outline"));
assertEquals("black dashed 15px", $("#test").css(CSS.OUTLINE));
}
public void testPaddingProperty() {

$(e).html("<div id='test'>Content</div>");

Loading…
Cancel
Save