`
robindut
  • 浏览: 46315 次
  • 性别: Icon_minigender_1
  • 来自: 大连
社区版块
存档分类
最新评论

改变Panel标题栏背景填充色

    博客分类:
  • Flex
 
阅读更多
panel title的背景色修改,使用skin来解决
skin代码如下
<?xml version="1.0" encoding="utf-8"?>

<!--

ADOBE SYSTEMS INCORPORATED
Copyright 2008 Adobe Systems Incorporated
All Rights Reserved.

NOTICE: Adobe permits you to use, modify, and distribute this file
in accordance with the terms of the license agreement accompanying it.

-->

<!--- The default skin class for a Spark Panel container.  

    @see spark.components.Panel

    @langversion 3.0
    @playerversion Flash 10
    @playerversion AIR 1.5
    @productversion Flex 4
-->
<s:SparkSkin xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" 
    xmlns:fb="http://ns.adobe.com/flashbuilder/2009" blendMode="normal" mouseEnabled="false" 
    minWidth="131" minHeight="127" alpha.disabled="0.5" alpha.disabledWithControlBar="0.5">
    
    <fx:Metadata>
        <![CDATA[ 
        /** 
         * @copy spark.skins.spark.ApplicationSkin#hostComponent
         */
        [HostComponent("spark.components.Panel")]
        ]]>
    </fx:Metadata> 
    
    <fx:Script fb:purpose="styling">
        <![CDATA[
		import mx.core.FlexVersion;
		
		/* Define the skin elements that should not be colorized. 
        For panel, border and title background are skinned, but the content area, background, border, and title text are not. */
        static private const exclusions:Array = ["background", "titleDisplay", "contentGroup", "controlBarGroup", "border"];
			
		/* exclusions before Flex 4.5 for backwards-compatibility purposes */
		static private const exclusions_4_0:Array = ["background", "titleDisplay", "contentGroup", "controlBarGroup"];
		
		/**
		 * @private
		 */
		override public function get colorizeExclusions():Array 
		{
			// Since border is styleable via borderColor, no need to allow chromeColor to affect
			// the border.  This is wrapped in a compatibility flag since this change was added  
			// in Flex 4.5
			if (FlexVersion.compatibilityVersion < FlexVersion.VERSION_4_5)
			{
				return exclusions_4_0;
			}
			
			return exclusions;
		}
        
        /**
         * @private
         */
        override protected function initializationComplete():void
        {
            useChromeColor = true;
            super.initializationComplete();
        }
        
        /**
         * @private
         */
        override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void
        {
            if (getStyle("borderVisible") == true)
            {
                border.visible = true;
                background.left = background.top = background.right = background.bottom = 1;
                contents.left = contents.top = contents.right = contents.bottom = 1;
            }
            else
            {
                border.visible = false;
                background.left = background.top = background.right = background.bottom = 0;
                contents.left = contents.top = contents.right = contents.bottom = 0;
            }
            
            dropShadow.visible = getStyle("dropShadowVisible");
            
            var cr:Number = getStyle("cornerRadius");
            var withControls:Boolean = 
                (currentState == "disabledWithControlBar" || 
                 currentState == "normalWithControlBar");
            
            if (cornerRadius != cr)
            {
                cornerRadius = cr;
                
                dropShadow.tlRadius = cornerRadius;
                dropShadow.trRadius = cornerRadius;
                dropShadow.blRadius = withControls ? cornerRadius : 0;
                dropShadow.brRadius = withControls ? cornerRadius : 0;
                
                setPartCornerRadii(topMaskRect, withControls); 
                setPartCornerRadii(border, withControls); 
                setPartCornerRadii(background, withControls);                
            }
            
            if (bottomMaskRect) setPartCornerRadii(bottomMaskRect, withControls); 
            
            borderStroke.color = getStyle("borderColor");
            borderStroke.alpha = getStyle("borderAlpha");
            backgroundFill.color = getStyle("backgroundColor");
            backgroundFill.alpha = getStyle("backgroundAlpha");
            
            super.updateDisplayList(unscaledWidth, unscaledHeight);
        }
        
        /**
         * @private
         */  
        private function setPartCornerRadii(target:Rect, includeBottom:Boolean):void
        {            
            target.topLeftRadiusX = cornerRadius;
            target.topRightRadiusX = cornerRadius;
            target.bottomLeftRadiusX = includeBottom ? cornerRadius : 0;
            target.bottomRightRadiusX = includeBottom ? cornerRadius : 0;
        }
        
        private var cornerRadius:Number;
		]]>
    </fx:Script>
    
    <s:states>
        <s:State name="normal" />
        <s:State name="disabled" />
        <s:State name="normalWithControlBar" stateGroups="withControls" />
        <s:State name="disabledWithControlBar" stateGroups="withControls" />
    </s:states>
    
    <!-- drop shadow can't be hittable so it stays sibling of other graphics -->
    <!--- @private -->
    <s:RectangularDropShadow id="dropShadow" blurX="20" blurY="20" alpha="0.32" distance="11" 
                             angle="90" color="#000000" left="0" top="0" right="0" bottom="0"/>
    
    <!-- drop shadow can't be hittable so all other graphics go in this group -->
    <s:Group left="0" right="0" top="0" bottom="0">
        
        <!-- top group mask -->
        <!--- @private -->
        <s:Group left="1" top="1" right="1" bottom="1" id="topGroupMask" >
            <!--- @private -->
            <s:Rect id="topMaskRect" left="0" top="0" right="0" bottom="0">
                <s:fill>
                    <s:SolidColor alpha="0"/>
                </s:fill>
            </s:Rect>
        </s:Group>
        
        <!-- bottom group mask -->
        <!--- @private -->
        <s:Group left="1" top="1" right="1" bottom="1" id="bottomGroupMask" 
                 includeIn="normalWithControlBar, disabledWithControlBar">
            <!--- @private -->
            <s:Rect id="bottomMaskRect" left="0" top="0" right="0" bottom="0">
                <s:fill>
                    <s:SolidColor alpha="0"/>
                </s:fill>
            </s:Rect>
        </s:Group>
        
        <!-- layer 1: border -->
        <!--- @private -->
        <s:Rect id="border" left="0" right="0" top="0" bottom="0" >
            <s:stroke>
                <!--- @private -->
                <s:SolidColorStroke id="borderStroke" weight="1" />
            </s:stroke>
        </s:Rect>
        
        <!-- layer 2: background fill -->
        <!--- Defines the appearance of the PanelSkin class's background. -->
        <s:Rect id="background" left="1" top="1" right="1" bottom="1">
            <s:fill>
                <!--- @private
                      Defines the  PanelSkin class's background fill. The default color is 0xFFFFFF. -->
                <s:SolidColor id="backgroundFill" color="#FFFFFF"/>
            </s:fill>
        </s:Rect>
        
        <!-- layer 3: contents -->
        <!--- Contains the vertical stack of titlebar content and controlbar. -->
        <s:Group left="1" right="1" top="1" bottom="1" id="contents">
            <s:layout>
                <s:VerticalLayout gap="0" horizontalAlign="justify" />
            </s:layout>
            
            <!--- @private -->
            <s:Group id="topGroup" mask="{topGroupMask}">
                
                <!-- layer 0: title bar fill -->
                <!--- @private -->
                <s:Rect id="tbFill" left="0" right="0" top="0" bottom="1">
                    <s:fill>
                        <s:LinearGradient rotation="90">
                            <s:GradientEntry color="0xE2E2E2" />
                            <s:GradientEntry color="0xD9D9D9" />
                        </s:LinearGradient>
                    </s:fill>
                </s:Rect>
                
                <!-- layer 1: title bar highlight -->
                <!--- @private -->
                <s:Rect id="tbHilite" left="0" right="0" top="0" bottom="0">
                    <s:stroke>
                        <s:LinearGradientStroke rotation="90" weight="1">
                            <s:GradientEntry color="0xEAEAEA" />
                            <s:GradientEntry color="0xD9D9D9" />
                        </s:LinearGradientStroke>
                    </s:stroke>
                </s:Rect>
                
                <!-- layer 2: title bar divider -->
                <!--- @private -->
                <s:Rect id="tbDiv" left="0" right="0" height="1" bottom="0">
                    <s:fill>
                        <s:SolidColor color="0xFF0000" />
                    </s:fill>
                </s:Rect>
                
                <!-- layer 3: text -->
                <!--- @copy spark.components.Panel#titleDisplay -->
                <s:Label id="titleDisplay" maxDisplayedLines="1" width="100%"
                          minHeight="30" backgroundColor="#0070C0"
                         verticalAlign="middle" textAlign="center" fontWeight="bold">
                </s:Label>
            </s:Group>
            
            <!--
                Note: setting the minimum size to 0 here so that changes to the host component's
                size will not be thwarted by this skin part's minimum size.   This is a compromise,
                more about it here: http://bugs.adobe.com/jira/browse/SDK-21143
            -->
            <!--- @copy spark.components.SkinnableContainer#contentGroup -->
            <s:Group id="contentGroup" width="100%" height="100%" minWidth="0" minHeight="0">
            </s:Group>
            
            <!--- @private -->
            <s:Group id="bottomGroup" minWidth="0" minHeight="0"
                     includeIn="normalWithControlBar, disabledWithControlBar" >
                
                <s:Group left="0" right="0" top="0" bottom="0" mask="{bottomGroupMask}">

                    <!-- layer 0: control bar divider line -->
                    <s:Rect left="0" right="0" top="0" height="1" alpha="0.22">
                        <s:fill>
                            <s:SolidColor color="0x000000" />
                        </s:fill>
                    </s:Rect>
                    
                    <!-- layer 1: control bar highlight -->
                    <s:Rect left="0" right="0" top="1" bottom="0">
                        <s:stroke>
                            <s:LinearGradientStroke rotation="90" weight="1">
                                <s:GradientEntry color="0xE5E5E5" />
                                <s:GradientEntry color="0xD8D8D8" />
                            </s:LinearGradientStroke>
                        </s:stroke>
                    </s:Rect>
                    
                    <!-- layer 2: control bar fill -->
                    <s:Rect left="1" right="1" top="2" bottom="1">
                        <s:fill>
                            <s:LinearGradient rotation="90">
                                <s:GradientEntry color="0xDADADA" />
                                <s:GradientEntry color="0xC5C5C5" />
                            </s:LinearGradient>
                        </s:fill>
                    </s:Rect>
                </s:Group>
                <!-- layer 3: control bar -->
                <!--- @copy spark.components.Panel#controlBarGroup -->
                <s:Group id="controlBarGroup" left="0" right="0" top="1" bottom="1" minWidth="0" minHeight="0">
                    <s:layout>
                        <s:HorizontalLayout paddingLeft="10" paddingRight="10" paddingTop="7" paddingBottom="7" gap="10" />
                    </s:layout>
                </s:Group>
            </s:Group>
        </s:Group>
    </s:Group>
</s:SparkSkin>



第235行的label即是panel头部的信息,修改它可以改变头部的背景色,居中等设置,很方便
分享到:
评论

相关推荐

    ext js 培训资料

    在Panel的高级应用中,我们可以添加标题栏的tools按钮、面板上的操作按钮,以及在工具栏中放置各种内容。Panel的布局管理也是其强大之处,通过布局可以方便地调整内部组件的排列和尺寸。 Panel与HTML中的`div`元素...

    jQuery EasyUI API 中文文档 - Panel面板

    jQuery EasyUI 的 Panel 组件提供了一种简便的方法来创建具有丰富功能的用户界面元素,包括标题、图标、工具栏、可调整大小、可折叠等特性。通过结合 HTML 标签和 JavaScript,你可以轻松地定制和控制 Panel 的行为...

    Photoshop新手必看的工具使用方法及基础操作借鉴.pdf

    - 在工具箱底部双击前景色或背景色图标,打开颜色选择对话框。 - 可以通过HEX、RGB、CMYK等方式设定颜色值。 5. **图形工具的使用**: - 形状工具(Shape Tools):绘制矢量图形,如矩形、椭圆、多边形等。 - ...

    flex 组件的样式属性整理

    - **headerColors**: 设置标题栏背景的渐变颜色。需要指定两个颜色值,中间用逗号分隔。例如:`headerColors="colors:#0000ff,#ffffff"`。 - **footerColors**: 设置底部背景的渐变颜色。需要指定两个颜色值,中间用...

    无边框窗体(c#).rar

    总结,创建无边框窗体(C#)涉及到多个方面,包括改变窗体边框样式、自定义拖动和大小调整行为、构建自定义标题栏和控制按钮、添加键盘快捷键支持以及实现全屏模式。通过以上步骤,你可以根据具体需求定制出具有独特...

    无废话ExtJs 系统教程十四[列表:GridPanel]

    例如,通过添加插件可以实现行选择模式(单选或多选)、分页栏(Pagination Toolbar)、工具栏(Toolbar)以添加自定义按钮,甚至编辑功能(Inline或Cell Editing)。另外,GridPanel可以与TreePanel结合,形成一个...

    天空蓝三栏个人博客模板_蓝色博客html三栏简洁纯色.rar

    9. `templatemo_top_panel.jpg`: 顶部面板图片,可能用于导航栏背景或其他顶部元素。 HTML(HyperText Markup Language)是网页设计的基础,它通过标记来组织网页内容和结构。在这个模板中,`index.html` 文件使用...

    C#经典特效代码470例(PDF已经整理)

    - **实例说明**:实现窗口背景色的渐变效果,可以是水平渐变或垂直渐变。 - **技术要点**: - 使用`Graphics`对象绘制渐变背景。 - 使用`LinearGradientBrush`类创建渐变刷。 - 通过监听`Paint`事件来绘制背景。 ...

    语言程序设计资料:第11章__图形编程初步.ppt

    - 窗口(Frame):是Window类的子类,是顶级容器,可以设置布局管理器、背景色,并添加组件。通常,我们通过创建Frame的实例来创建窗口。 - 面板(Panel):是容器的子类,用作组件的载体,可以进行图形绘制并添加到...

    C#实现窗体圆角的一种方法

    4. **添加标题控件**:为了实现标题栏,可以在窗体上添加一个Panel控件,设置其Dock样式为Top,然后在Panel的Paint事件中绘制标题文本。 5. **处理最大化、最小化、关闭按钮**:可以使用Button控件模拟这些功能,...

    flex quick starts 中文版(翻译by dreamer)

    - **Panel**:用于创建带有标题栏的容器,如上例中的`&lt;mx:Panel&gt;`。 - **HDividedBox** 和 **VDividedBox**:用于创建具有可调节分割条的容器,使得用户可以调整每个部分的大小。 - **ApplicationControlBar**:位于...

    photoshop cs2 cs3快捷键大全

    - **Ctrl+Backspace/Delete**: 填充背景色(Fill with Background Color)。 - **Ctrl+Alt+0**: 放大至实际像素大小(Fit on Screen)。 - **Shift+Backspace**: 打开填充对话框(Fill Dialog Box)。 - **Ctrl+Alt+...

    某公司JAVA培训月PPT学习教案.pptx

    - `Color`类:表示颜色,用于设置组件的背景色或前景色。 - `Font`类:定义了字体的样式、大小和类型。 - `Component`类:所有可视化组件的基类,代表GUI中的一个元素。 - `Container`类:作为组件的容器,可以...

    ext 与 dwr 的结合

    4. **DWR的使用**:通过DWR,JavaScript可以调用Java方法,比如获取数据集填充Grid Panel,或执行增删改查操作。DWR自动处理JSON或XML的序列化和反序列化,简化了前后端通信。 5. **CRUD操作**:在Grid Panel中,...

    Delphi给窗体加一个简单的红色边框效果.rar

    除了OnPaint事件,还可以考虑使用WM_NCPAINT消息来处理非客户区的绘制,这样可以在窗口的标题栏和边框等非客户区域实现自定义效果。然而,这种方法更复杂,需要对Windows API有深入理解。 总的来说,这个实例展示了...

    JAVA绘图板的设计与实现

    圆", "填充椭圆", "空心圆", "填充圆", "圆角矩形", "填充圆角矩形", "橡皮擦", "颜色选择", "画笔粗细", "文字输入" }; //主方法,程序的入口点 public static void main(String[] args) { MiniDrawPad drawPad = ...

    JsAPI自己总结的归纳

    `Panel`组件常用于封装内容,提供标题、边框和自定义样式等功能。其主要属性和方法包括: - **属性**: - `title`:面板的标题文本。 - `iconCls`:16x16大小图标的CSS类。 - `cls`:对整个面板应用的CSS类。 ...

    2021-2022计算机二级等级考试试题及答案No.16271.docx

    在软件应用中,菜单项的颜色或背景色通常表示其是否可用。灰色表示该命令当前条件下不可用。因此,选项“正确”是正确的答案。 ### 12. JSP中的请求转发 在JSP中,`forward`动作用于将请求转发给其他JSP页面,而...

Global site tag (gtag.js) - Google Analytics