08年05月07日

Posted on 2008-05-07 17:00 RichardHe 阅读(271) 评论(0)  编辑 收藏 引用
今天在参考WindowsLook.looknfeel自己写了一个Button
<?xml version="1.0" ?>
<Falagard>
    <WidgetLook name="WindowsLook/MyButton">
 1 <ImagerySection name="normal">
 2             <FrameComponent>
 3                 <Area>
 4                     <Dim type="LeftEdge">
 5                         <AbsoluteDim value="0" />
 6                     </Dim>
 7                     <Dim type="TopEdge">
 8                         <AbsoluteDim value="0" />
 9                     </Dim>
10                     <Dim type="RightEdge">
11                         <UnifiedDim scale="1" type="RightEdge" />
12                     </Dim>
13                     <Dim type="BottomEdge">
14                         <UnifiedDim scale="1" type="BottomEdge" />
15                     </Dim>
16                 </Area>
17                 <Image type="TopLeftCorner" imageset="WindowsLook" image="ButtonNormalTopLeft" />
18                 <Image type="TopRightCorner" imageset="WindowsLook" image="ButtonNormalTopRight" />
19                 <Image type="BottomLeftCorner" imageset="WindowsLook" image="ButtonNormalBottomLeft" />
20                 <Image type="BottomRightCorner" imageset="WindowsLook" image="ButtonNormalBottomRight" />
21                 <Image type="LeftEdge" imageset="WindowsLook" image="ButtonNormalLeft" />
22                 <Image type="TopEdge" imageset="WindowsLook" image="ButtonNormalTop" />
23                 <Image type="RightEdge" imageset="WindowsLook" image="ButtonNormalRight" />
24                 <Image type="BottomEdge" imageset="WindowsLook" image="ButtonNormalBottom" />
25             </FrameComponent>
26             <ImageryComponent>
27                 <Area>
28                     <Dim type="LeftEdge">
29                         <ImageDim imageset="WindowsLook" image="ButtonNormalLeft" dimension="Width" />
30                     </Dim>
31                     <Dim type="TopEdge">
32                         <ImageDim imageset="WindowsLook" image="ButtonNormalTop" dimension="Height" />
33                     </Dim>
34                     <Dim type="RightEdge">
35                         <UnifiedDim scale="1" type="RightEdge">
36                             <DimOperator op="Subtract">
37                                 <ImageDim imageset="WindowsLook" image="ButtonNormalRight" dimension="Width" />
38                             </DimOperator>
39                         </UnifiedDim>
40                     </Dim>
41                     <Dim type="BottomEdge">
42                         <UnifiedDim scale="1" type="BottomEdge">
43                             <DimOperator op="Subtract">
44                                 <ImageDim imageset="WindowsLook" image="ButtonNormalBottom" dimension="Height" />
45                             </DimOperator>
46                         </UnifiedDim>
47                     </Dim>
48                 </Area>
49                 <Image imageset="WindowsLook" image="Background" />
50                 <Colours topLeft="FFAFAFAF" topRight="FFFFFFFF" bottomLeft="FFFFFFFF" bottomRight="FFAFAFAF" />
51                 <VertFormat type="Stretched" />
52                 <HorzFormat type="Stretched" />
53             </ImageryComponent>
54         </ImagerySection>


上面的意思大慨是明白的.但是
1 <StateImagery name="Normal">
2             <Layer>
3                 <Section section="normal" />
4                 <Section section="label">
5                     <ColourProperty name="NormalTextColour" />
6                 </Section>
7             </Layer>
8         </StateImagery>

section = "normal"不是已经设置好了这个Button的所有东西吗?为什么还要一个section = "label"??这是什么意思呢?
 1 <ImagerySection name="label">
 2             <TextComponent>
 3                 <Area>
 4                     <Dim type="LeftEdge">
 5                         <AbsoluteDim value="0" />
 6                     </Dim>
 7                     <Dim type="TopEdge">
 8                         <AbsoluteDim value="0" />
 9                     </Dim>
10                     <Dim type="RightEdge">
11                         <UnifiedDim scale="1" type="RightEdge" />
12                     </Dim>
13                     <Dim type="BottomEdge">
14                         <UnifiedDim scale="1" type="BottomEdge" />
15                     </Dim>
16                 </Area>
17                 <VertFormat type="CentreAligned" />
18                 <HorzFormat type="WordWrapCentreAligned" />
19             </TextComponent>
20         </ImagerySection>
这个lable主要是用来干嘛的呢?一个朋友的BLOG说是为这个BUTTON设置文本??
还是不明白是什么意思??

虽然不明白,但是还是自己写了一个BUTTON.首先,用CELayoutEditor.exe 来加载TaharezLook.scheme的,
去对应的TaharezLook.looknfeel里,将这个按钮添加在后面.你可以改为任意名字,我们把刚才写的Button外观改成MyButton
再到TaharezLook.scheme文件里照着Button复制一下,然后修改
<FalagardMapping WindowType="WindowsLook/MyButton" TargetType='CEGUI/Button'        Renderer="Falagard/Editbox"             LookNFeel="TaharezLook/MyButton" />
这个就可以在添加新的窗口下面你的MyButton.

---------------------------------------------------------------
用MSN用了一个朋友总算知道大慨是怎么回事了.一个BUUTON相当于图片加LABEL文字了...
section 是一个外观配置,多个Section构成了 某个状态的 外观
StateImagery 是指 某个状态下的外观
section是可以复用的。而StateImagery 就象是自由组装它们的 人
为什么 StateImagery 有那些状态?因为CEGUI 规定了这些状态。
那什么是 section, section就是 具体的表现。它对应着Imageset里具体的 Image区域。
所以, section 负责实现各种外观, StateImagery 负责为各种状态选择、组合 合适的外观
但是 对于其他的 控件 ,一个图片就不够了。一般来说,定义一个窗口,我们需要定义9个部分:
1 2 3
4 5 6
7 8 9
4个边 4个角, 1个中间
相当于 一个 Button+ 一个Laber 的复合控件

只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理


posts - 94, comments - 138, trackbacks - 0, articles - 94

Copyright © RichardHe