You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flex.apache.org by ah...@apache.org on 2015/07/28 20:40:29 UTC
[03/36] git commit: [flex-asjs] [refs/heads/develop] - Add
StyleableCSSTextField for more control over styles in pieces of a skin
Add StyleableCSSTextField for more control over styles in pieces of a skin
Project: http://git-wip-us.apache.org/repos/asf/flex-asjs/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-asjs/commit/5e4cd97b
Tree: http://git-wip-us.apache.org/repos/asf/flex-asjs/tree/5e4cd97b
Diff: http://git-wip-us.apache.org/repos/asf/flex-asjs/diff/5e4cd97b
Branch: refs/heads/develop
Commit: 5e4cd97b56b28c8012dbb4abbde2dc603b61e8f6
Parents: cfded8d
Author: Alex Harui <ah...@apache.org>
Authored: Mon Jul 13 21:51:30 2015 -0700
Committer: Alex Harui <ah...@apache.org>
Committed: Mon Jul 13 21:51:30 2015 -0700
----------------------------------------------------------------------
frameworks/projects/Core/as/src/CoreClasses.as | 1 +
.../apache/flex/core/StyleableCSSTextField.as | 200 +++++++++++++++++++
2 files changed, 201 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/5e4cd97b/frameworks/projects/Core/as/src/CoreClasses.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/Core/as/src/CoreClasses.as b/frameworks/projects/Core/as/src/CoreClasses.as
index 337e5f3..0c04ca4 100644
--- a/frameworks/projects/Core/as/src/CoreClasses.as
+++ b/frameworks/projects/Core/as/src/CoreClasses.as
@@ -30,6 +30,7 @@ internal class CoreClasses
import org.apache.flex.core.BeadViewBase; BeadViewBase;
import org.apache.flex.core.BrowserWindow; BrowserWindow;
import org.apache.flex.core.CSSTextField; CSSTextField;
+ import org.apache.flex.core.StyleableCSSTextField; StyleableCSSTextField;
import org.apache.flex.core.ItemRendererClassFactory; ItemRendererClassFactory;
import org.apache.flex.core.FilledRectangle; FilledRectangle;
import org.apache.flex.core.IAlertModel; IAlertModel;
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/5e4cd97b/frameworks/projects/Core/as/src/org/apache/flex/core/StyleableCSSTextField.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/Core/as/src/org/apache/flex/core/StyleableCSSTextField.as b/frameworks/projects/Core/as/src/org/apache/flex/core/StyleableCSSTextField.as
new file mode 100644
index 0000000..cbd7a08
--- /dev/null
+++ b/frameworks/projects/Core/as/src/org/apache/flex/core/StyleableCSSTextField.as
@@ -0,0 +1,200 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// Licensed to the Apache Software Foundation (ASF) under one or more
+// contributor license agreements. See the NOTICE file distributed with
+// this work for additional information regarding copyright ownership.
+// The ASF licenses this file to You 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 org.apache.flex.core
+{
+ import flash.display.DisplayObjectContainer;
+ import flash.text.Font;
+
+ import org.apache.flex.core.IStyleableObject;
+ import org.apache.flex.events.Event;
+
+ /**
+ * The StyleableCSSTextField class implements more CSS text styles in a TextField.
+ * This makes it easier to use one in a "shadow DOM" in a complex skin.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion FlexJS 0.0
+ */
+ public class StyleableCSSTextField extends CSSTextField implements IStyleableObject, IChild
+ {
+ /**
+ * Constructor.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion FlexJS 0.0
+ */
+ public function StyleableCSSTextField()
+ {
+ super();
+ // this is the object passed into CSS lookups since it can
+ // have its own individual styles and isn't subordinate
+ // to a parent.
+ styleParent = this;
+ }
+
+ /**
+ * @private
+ * The CSSParent property is set if the CSSTextField
+ * is used in a SimpleButton-based instance because
+ * the parent property is null, defeating CSS lookup.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion FlexJS 0.0
+ */
+ public var CSSParent:Object;
+
+ override public function get parent():DisplayObjectContainer
+ {
+ if (CSSParent)
+ return CSSParent as DisplayObjectContainer;
+
+ return super.parent;
+ }
+
+ private var _id:String;
+
+ /**
+ * An id property for MXML documents.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion FlexJS 0.0
+ */
+ public function get id():String
+ {
+ return _id;
+ }
+
+ /**
+ * @private
+ */
+ public function set id(value:String):void
+ {
+ if (_id != value)
+ {
+ _id = value;
+ dispatchEvent(new Event("idChanged"));
+ }
+ }
+
+ private var _styles:Object;
+
+ /**
+ * The object that contains
+ * "styles" and other associated
+ * name-value pairs. You can
+ * also specify a string in
+ * HTML style attribute format.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion FlexJS 0.0
+ */
+ public function get style():Object
+ {
+ return _styles;
+ }
+
+ /**
+ * @private
+ */
+ public function set style(value:Object):void
+ {
+ if (_styles != value)
+ {
+ if (value is String)
+ {
+ _styles = ValuesManager.valuesImpl.parseStyles(value as String);
+ }
+ else
+ _styles = value;
+ dispatchEvent(new Event("stylesChanged"));
+ }
+ }
+
+ /**
+ * A list of type names. Often used for CSS
+ * type selector lookups.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion FlexJS 0.0
+ */
+ public var typeNames:String;
+
+ private var _className:String;
+
+ /**
+ * The classname. Often used for CSS
+ * class selector lookups.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion FlexJS 0.0
+ */
+ public function get className():String
+ {
+ return _className;
+ }
+
+ /**
+ * @private
+ */
+ public function set className(value:String):void
+ {
+ if (_className != value)
+ {
+ _className = value;
+ dispatchEvent(new Event("classNameChanged"));
+ }
+ }
+
+ /**
+ * @private
+ */
+ override public function set text(value:String):void
+ {
+ super.text = value;
+ var font:String = ValuesManager.valuesImpl.getValue(this, "fontFamily") as String;
+ var embeddedFonts:Array = Font.enumerateFonts();
+ if (embeddedFonts.length)
+ embedFonts = isEmbedded(embeddedFonts, font);
+ }
+
+ private function isEmbedded(list:Array, name:String):Boolean
+ {
+ for each (var f:Font in list)
+ {
+ if (f.fontName == name)
+ return true;
+ }
+ return false;
+ }
+ }
+}
\ No newline at end of file