Page 1 of 1
Radio Button Text Colors
Posted: Wed Jul 05, 2006 16:19
by Gf11speed
I am trying to modify the color of the text for my radio buttons, but I do not want all of them to be the same in my game.
I know I can edit the game's looknfeel file and add this under the radio button section in order to change the colors:
Code: Select all
...
<WidgetLook name="GameLook/RadioButton">
<Property name="NormalTextColour" value="FF6600CC " />
<Property name="HoverTextColour" value="FF4F5F18" />
<Property name="PushedTextColour" value="FFFFFFFF" />
...
However, I want to it to be different for different parts of my game. Basically I want to be able to do it in the same way as text:
Code: Select all
...
<Window Type="GameLook/StaticText" Name="Text" >
<Property Name="Text" Value="text here" />
<Property Name="TextColours" Value="tl:FF330099 tr:FF330099 bl:FF000000 br:FF000000 " />
...
Instead with radio buttons, perhaps something like this:
Code: Select all
<Window Type="GameLook/RadioButton" Name="RadioButton" >
<Property Name="Text" Value="text here" />
<Property Name="TextColours" Value="tl:FF330099 tr:FF330099 bl:FF000000 br:FF000000 " />
Is this possible?
Posted: Tue Jul 11, 2006 18:21
by Gf11speed
Can't be done?
Posted: Tue Jul 11, 2006 18:49
by Rackle
I would think something like this could work:
Radiobutton* rb = static_cast<Radiobutton*>(getWindow("MyRadiobutton"));
Color color(red, green, blue, alpha);
rb->
setNormalTextColour(color);
Posted: Tue Jul 11, 2006 19:36
by lindquist
Make the look'n'feel use a ColourRect property instead.
Posted: Tue Jul 11, 2006 20:25
by Rackle
Second attempt...
This might be what lindquist was saying:
rb->setProperty("TextColours", "tl:FFFF0000 tr:FFFF0000 bl:FFFF0000 br:FFFF0000");
The sad thing is that this code comes from this
post from myself...where oh where is my memory going!
Posted: Wed Jul 12, 2006 01:46
by lindquist
If the looknfeel defines the TextColours property and uses it as a ColourRect then yes.
Posted: Wed Jul 12, 2006 02:57
by Gf11speed
I'm not sure exactly what you mean by making the look'n'feel use a ColourRect property. Is this simple to do?
I'd certainly prefer to specify the colors in the look'n'feel and layout files instead of modifying any C++ code, if this is possible.
Posted: Wed Jul 12, 2006 11:51
by Rackle
Within TaharezLook.looknfeel, under the TaharezLook/RadioButton section:
Code: Select all
<PropertyDefinition name="NormalTextColour" initialValue="FFFFFFFF" redrawOnWrite="true" />
<PropertyDefinition name="HoverTextColour" initialValue="FFFFFFFF" redrawOnWrite="true" />
<PropertyDefinition name="PushedTextColour" initialValue="FFFFFFFF" redrawOnWrite="true" />
<PropertyDefinition name="DisabledTextColour" initialValue="FF7F7F7F" redrawOnWrite="true" />
which means that we can use:
Code: Select all
rb->setProperty("NormalTextColour", "FFFF0000"); // AARRGGBB
Posted: Fri Jul 14, 2006 16:12
by Gf11speed
Rackle wrote:Within TaharezLook.looknfeel, under the TaharezLook/RadioButton section:
Code: Select all
<PropertyDefinition name="NormalTextColour" initialValue="FFFFFFFF" redrawOnWrite="true" />
<PropertyDefinition name="HoverTextColour" initialValue="FFFFFFFF" redrawOnWrite="true" />
<PropertyDefinition name="PushedTextColour" initialValue="FFFFFFFF" redrawOnWrite="true" />
<PropertyDefinition name="DisabledTextColour" initialValue="FF7F7F7F" redrawOnWrite="true" />
which means that we can use:
Code: Select all
rb->setProperty("NormalTextColour", "FFFF0000"); // AARRGGBB
When I add the <propertyDefinition...> tags, I get an error that says it already exists within the system. Here is what my RadioButton looks like:
Code: Select all
<!--
***************************************************
GameLook/RadioButton
***************************************************
-->
<WidgetLook name="GameLook/RadioButton">
<PropertyDefinition name="NormalTextColour" initialValue="FFFFFFFF" redrawOnWrite="true" />
<PropertyDefinition name="HoverTextColour" initialValue="FFFFFFFF" redrawOnWrite="true" />
<PropertyDefinition name="PushedTextColour" initialValue="FFFFFFFF" redrawOnWrite="true" />
<PropertyDefinition name="DisabledTextColour" initialValue="FF7F7F7F" redrawOnWrite="true" />
<ImagerySection name="label">
<TextComponent>
<Area>
<Dim type="LeftEdge" >
<ImageDim imageset="GameLook" image="RadioButtonNormal" dimension="Width">
<DimOperator op="Add">
<AbsoluteDim value="3" />
</DimOperator>
</ImageDim>
</Dim>
<Dim type="TopEdge" ><AbsoluteDim value="0" /></Dim>
<Dim type="RightEdge" ><UnifiedDim scale="1" type="Width" /></Dim>
<Dim type="Height" ><UnifiedDim scale="1" type="Height" /></Dim>
</Area>
<VertFormat type="CentreAligned" />
<HorzFormat type="LeftAligned" />
</TextComponent>
</ImagerySection>
<ImagerySection name="normal">
<ImageryComponent>
<Area>
<Dim type="LeftEdge" ><AbsoluteDim value="0" /></Dim>
<Dim type="TopEdge" ><AbsoluteDim value="0" /></Dim>
<Dim type="Width" ><UnifiedDim scale="1" type="Width" /></Dim>
<Dim type="Height" ><UnifiedDim scale="1" type="Height" /></Dim>
</Area>
<Image imageset="GameLook" image="RadioButtonNormal" />
<VertFormat type="CentreAligned" />
<HorzFormat type="LeftAligned" />
</ImageryComponent>
</ImagerySection>
<ImagerySection name="hover">
<ImageryComponent>
<Area>
<Dim type="LeftEdge" ><AbsoluteDim value="0" /></Dim>
<Dim type="TopEdge" ><AbsoluteDim value="0" /></Dim>
<Dim type="Width" ><UnifiedDim scale="1" type="Width" /></Dim>
<Dim type="Height" ><UnifiedDim scale="1" type="Height" /></Dim>
</Area>
<Image imageset="GameLook" image="RadioButtonHover" />
<VertFormat type="CentreAligned" />
<HorzFormat type="LeftAligned" />
</ImageryComponent>
</ImagerySection>
<ImagerySection name="select_mark">
<ImageryComponent>
<Area>
<Dim type="LeftEdge" ><AbsoluteDim value="0" /></Dim>
<Dim type="TopEdge" ><AbsoluteDim value="0" /></Dim>
<Dim type="Width" ><UnifiedDim scale="1" type="Width" /></Dim>
<Dim type="Height" ><UnifiedDim scale="1" type="Height" /></Dim>
</Area>
<Image imageset="GameLook" image="RadioButtonMark" />
<VertFormat type="CentreAligned" />
<HorzFormat type="LeftAligned" />
</ImageryComponent>
</ImagerySection>
<StateImagery name="Normal">
<Layer>
<Section section="normal" />
<Section section="label">
<ColourProperty name="NormalTextColour" />
</Section>
</Layer>
</StateImagery>
<StateImagery name="Hover">
<Layer>
<Section section="hover" />
<Section section="label">
<ColourProperty name="HoverTextColour" />
</Section>
</Layer>
</StateImagery>
<StateImagery name="Disabled">
<Layer>
<Section section="normal">
<Colours topLeft="FF7F7F7F" topRight="FF7F7F7F" bottomLeft="FF7F7F7F" bottomRight="FF7F7F7F" />
</Section>
<Section section="label">
<ColourProperty name="DisabledTextColour" />
</Section>
</Layer>
</StateImagery>
<StateImagery name="SelectedNormal">
<Layer>
<Section section="normal" />
<Section section="select_mark" />
<Section section="label">
<ColourProperty name="NormalTextColour" />
</Section>
</Layer>
</StateImagery>
<StateImagery name="SelectedHover">
<Layer>
<Section section="hover" />
<Section section="select_mark" />
<Section section="label">
<ColourProperty name="HoverTextColour" />
</Section>
</Layer>
</StateImagery>
<StateImagery name="SelectedDisabled">
<Layer>
<Section section="normal">
<Colours topLeft="FF7F7F7F" topRight="FF7F7F7F" bottomLeft="FF7F7F7F" bottomRight="FF7F7F7F" />
</Section>
<Section section="select_mark">
<Colours topLeft="FF7F7F7F" topRight="FF7F7F7F" bottomLeft="FF7F7F7F" bottomRight="FF7F7F7F" />
</Section>
<Section section="label">
<ColourProperty name="DisabledTextColour" />
</Section>
</Layer>
</StateImagery>
</WidgetLook>
What am I doing wrong?
Posted: Fri Jul 14, 2006 16:29
by Rackle
I have not played with looknfeel yet so can't help you much. But what happens if you do not add these first 4 lines to your looknfeel, can you use rb->setProperty("NormalTextColour", "FFFF0000") nonetheless?
Posted: Fri Jul 14, 2006 16:38
by Gf11speed
When I call the following, it just sets to the default white radio button color:
<Property name="NormalTextColour" value="FFFFF444" />
So basically it just ignores the call. This is what it looks like:
Code: Select all
<Window Type="GameLook/RadioButton" Name="Radio10" >
<Property name="NormalTextColour" value="FFFFF444" />
<Property Name="Font" Value="Tahoma-10" />
<Property Name="Text" Value="radio text" />
<Property Name="UnifiedAreaRect" Value="{{0.380000,0.000000},{0.800000,0.000000},{0.630000,0.000000},{0.850000,0.000000}}" />
<Property Name="UnifiedMaxSize" Value="{{1.000000,0.000000},{1.000000,0.000000}}" />
</Window>
Posted: Fri Jul 14, 2006 17:00
by Gf11speed
I'm not sure how to use ColourRect properly for what lindquist is referring to. Do you know how to do that?
Posted: Tue Jul 18, 2006 02:07
by Gf11speed
Ok I fixed it. The problem was that my .imageset file was missing some stuff, and for some reason it prevented me from changing radio button text colors.
So now I can change their color like so:
Code: Select all
<Window Type="GameLook/RadioButton" Name="Radio_Race1">
<Property Name="HoverTextColour" Value="FFFF0000" />
<Property Name="Font" Value="Tahoma-10" />
<Property Name="Text" Value="Yay it works!" />
</Window>