Ok, in this post I present one possible solution to adding an icon to the titlebar. You should not feel the need to use this solution verbatim, there are other ways to do this completely, and this particular effort could be hacked around some more also
Basically, we're defining a new ImagerySection for the AquaLook/Titlebar, named 'icon'. The imagery section will have an area, image name and colours all defined via properties. We will subsequently expose these properties via AquaLook/FrameWindow.
First of all we need the properties in AquaLook/Titlebar for the various things we'll be needing...
Code: Select all
<PropertyDefinition name="IconX" initialValue="0" redrawOnWrite="true" />
<PropertyDefinition name="IconY" initialValue="0" redrawOnWrite="true" />
<PropertyDefinition name="IconWidth" initialValue="16" redrawOnWrite="true" />
<PropertyDefinition name="IconHeight" initialValue="16" redrawOnWrite="true" />
<PropertyDefinition name="IconImage" initialValue="" redrawOnWrite="true" />
<PropertyDefinition name="IconColour" initialValue="FFFFFFFF" redrawOnWrite="true" />
Now, the ImagerySection. This basically is built completely in a way that depends on the properties defined above. Note that the way we use "PropertyDim" here is expecting a property name that will return a single float value which will be interpreted as pixels.
Code: Select all
<ImagerySection name="icon" >
<ImageryComponent>
<Area>
<Dim type="LeftEdge" >
<PropertyDim name="IconX" />
</Dim>
<Dim type="TopEdge" >
<PropertyDim name="IconY" />
</Dim>
<Dim type="Width" >
<PropertyDim name="IconWidth" />
</Dim>
<Dim type="Height" >
<PropertyDim name="IconHeight" />
</Dim>
</Area>
<ImageProperty name="IconImage" />
<ColourProperty name="IconColour" />
<VertFormat type="Stretched" />
<HorzFormat type="Stretched" />
</ImageryComponent>
</ImagerySection>
Now we add a reference to this in the imagery section definitions. Here I have shown a whole section definition for context:
Code: Select all
<StateImagery name="Active">
<Layer>
<Section section="main" />
<Section section="caption" />
<Section section="icon" />
</Layer>
</StateImagery>
Since I want my icon on the left side of the titlebar, I thought it would be good if the caption label would auto-adjust its position based upon the size and position of the icon - so here is a modifed Area specification for the "caption" imagery section (note that if the icon were to appear on the right of the caption, you would not need to do this):
Code: Select all
<Area>
<!-- new LeftEdge specification that allows for size and position of icon -->
<Dim type="LeftEdge" >
<ImageDim imageset="AquaLook" image="NewTitlebarLeft" dimension="Width" >
<DimOperator op="Add">
<PropertyDim name="IconWidth">
<DimOperator op="Add">
<PropertyDim name="IconX" />
</DimOperator>
</PropertyDim>
</DimOperator>
</ImageDim>
</Dim>
<Dim type="TopEdge" >
<AbsoluteDim value="0" />
</Dim>
<Dim type="Width" >
<UnifiedDim scale="1" offset="-75" type="Width" />
</Dim>
<Dim type="Height" >
<ImageDim imageset="AquaLook" image="NewTitlebarMiddle" dimension="Height">
<DimOperator op="Add">
<ImageDim imageset="AquaLook" image="NewTitlebarDivider" dimension="Height" />
</DimOperator>
</ImageDim>
</Dim>
</Area>
Finally, since we use FrameWindows and not Titlebars directly, we need to make all this accessible from the FrameWindow. This is easily done by defining property links (note the need to re-specify the default values, if we do not do this, they all default to 0/null/empty values) in AquaLook/FrameWindow:
Code: Select all
<PropertyLinkDefinition name="IconX" widget="__auto_titlebar__" targetProperty="IconX" initialValue="0" />
<PropertyLinkDefinition name="IconY" widget="__auto_titlebar__" targetProperty="IconY" initialValue="0" />
<PropertyLinkDefinition name="IconWidth" widget="__auto_titlebar__" targetProperty="IconWidth" initialValue="16" />
<PropertyLinkDefinition name="IconHeight" widget="__auto_titlebar__" targetProperty="IconHeight" initialValue="16" />
<PropertyLinkDefinition name="IconImage" widget="__auto_titlebar__" targetProperty="IconImage" initialValue="" />
<PropertyLinkDefinition name="IconColour" widget="__auto_titlebar__" targetProperty="IconColour" initialValue="FFFFFFFF" />
HTH
CE.