[Solved] Accessing Custom ItemEntry Widget TextComponents?

For help with general CEGUI usage:
- Questions about the usage of CEGUI and its features, if not explained in the documentation.
- Problems with the CMAKE configuration or problems occuring during the build process/compilation.
- Errors or unexpected behaviour.

Moderators: CEGUI MVP, CEGUI Team

mithryanna
Just popping in
Just popping in
Posts: 13
Joined: Fri Jun 25, 2010 15:00
Location: USA

[Solved] Accessing Custom ItemEntry Widget TextComponents?

Postby mithryanna » Wed Oct 27, 2010 16:00

I'm a beginner at making custom CEGUI widgets. I've made a few, but mostly where I've copied the looknfeel from another widget and slightly modified it. I understand how to use the child tag to add widgets to my new widget; it's what I've used the most up to this point. I don't have a great understanding of properties yet, though, which I think is why I'm faltering on this latest widget.

I'll start by explaining what I'm trying to do:

I want to make a custom ItemEntry-based class/widget that I can use in an ItemListbox to display some simple information about map layer objects in our program. My MapLayerItemEntry should have a toggle button and a few text fields. Pretty simple stuff. The text fields include the name of the map layer and a brief description.

I'm hung up on the looknfeel. What I have right now is this:

Code: Select all

   <!--
    ***************************************************
        Immersive_Border/MapLayerItemEntry
    ***************************************************
    -->
    <WidgetLook name="Immersive_Border/MapLayerItemEntry">
      <PropertyDefinition name="TextColour" initialValue="FF000000" redrawOnWrite="true" />
      <PropertyDefinition name="SelectedTextColour" initialValue="FFFFFFFF" redrawOnWrite="true" />
      <PropertyDefinition name="SelectionBrush" initialValue="set:Immersive_Border image:StaticBackdrop" redrawOnWrite="true" />
      <PropertyDefinition name="SelectionColour" initialValue="FF3030FF" redrawOnWrite="true" />
      <Property name="Selectable" value="True" />
      <NamedArea name="ContentSize">
         <Area>
            <Dim type="LeftEdge" >
               <AbsoluteDim value="0" />
            </Dim>
            <Dim type="TopEdge" >
               <AbsoluteDim value="0" />
            </Dim>
            <Dim type="Width" >
               <FontDim type="HorzExtent" padding="6" />
            </Dim>
            <Dim type="Height" >
               <FontDim type="LineSpacing" />
            </Dim>
         </Area>
      </NamedArea>
      <ImagerySection name="layername">
         <TextComponent>
            <Area>
               <Dim type="TopEdge">
                  <AbsoluteDim value="0" />
               </Dim>
               <Dim type="LeftEdge">
                  <AbsoluteDim value="3" />
               </Dim>
               <Dim type="RightEdge">
                  <UnifiedDim scale="1" offset="-3" type="RightEdge" />
               </Dim>
               <Dim type="BottomEdge">
                  <UnifiedDim scale="1" type="BottomEdge" />
               </Dim>
            </Area>
         </TextComponent>
      </ImagerySection>
      <ImagerySection name="description">
         <TextComponent>
            <Area>
               <Dim type="TopEdge">
                  <AbsoluteDim value="5" />
               </Dim>
               <Dim type="LeftEdge">
                  <AbsoluteDim value="3" />
               </Dim>
               <Dim type="RightEdge">
                  <UnifiedDim scale="1" offset="-3" type="RightEdge" />
               </Dim>
               <Dim type="BottomEdge">
                  <UnifiedDim scale="1" type="BottomEdge" />
               </Dim>
            </Area>
         </TextComponent>
      </ImagerySection>
      <ImagerySection name="selection">
         <ImageryComponent>
            <Area>
               <Dim type="TopEdge">
                  <AbsoluteDim value="0" />
               </Dim>
               <Dim type="LeftEdge">
                  <AbsoluteDim value="0" />
               </Dim>
               <Dim type="RightEdge">
                  <UnifiedDim scale="1" type="RightEdge" />
               </Dim>
               <Dim type="BottomEdge">
                  <UnifiedDim scale="1" type="BottomEdge" />
               </Dim>
            </Area>
            <ImageProperty name="SelectionBrush" />
            <ColourProperty name="SelectionColour" />
            <VertFormat type="Stretched" />
            <HorzFormat type="Stretched" />
         </ImageryComponent>
      </ImagerySection>
      <StateImagery name="Enabled">
         <Layer>
            <Section section="layername">
               <ColourProperty name="TextColour" />
            </Section>
            <Section section="description">
               <ColourProperty name="TextColour" />
            </Section>
         </Layer>
      </StateImagery>
      <StateImagery name="Disabled">
         <Layer>
            <Section section="layername">
               <ColourProperty name="TextColour" />
            </Section>
            <Section section="description">
               <ColourProperty name="TextColour" />
            </Section>
         </Layer>
      </StateImagery>
      <StateImagery name="SelectedEnabled">
         <Layer>
            <Section section="selection" />
            <Section section="layername">
               <ColourProperty name="SelectedTextColour" />
            </Section>
            <Section section="description">
               <ColourProperty name="SelectedTextColour" />
            </Section>
         </Layer>
      </StateImagery>
      <StateImagery name="SelectedDisabled">
         <Layer>
            <Section section="selection" />
            <Section section="layername">
               <ColourProperty name="SelectedTextColour" />
            </Section>
            <Section section="description">
               <ColourProperty name="SelectedTextColour" />
            </Section>
         </Layer>
      </StateImagery>
    </WidgetLook>


Basically just the WindowsLook ListboxItem with two ImagerySections with TextComponents instead of one.

I haven't added the togglebutton child yet, but I know how to do that. I also haven't messed with sizing or positioning yet. My question is, how do I access these textcomponents I've made to change the text they display...? Could I somehow set them up to be linked to a property? (Like make it so there's a MapName property and a MapDesc property, and setting the MapName property sets the text in the layername textcomponent, and MapDesc sets description.) How would I do that? If there's a good document that talks all about properties, how to make new ones, etc., that would be helpful; I have difficulty navigating through some of the documents on the CE site and a lot of the XML wiki pages I've read deal with older versions.
Last edited by mithryanna on Tue Nov 02, 2010 14:43, edited 1 time in total.

User avatar
CrazyEddie
CEGUI Project Lead
Posts: 6760
Joined: Wed Jan 12, 2005 12:06
Location: England
Contact:

Re: Accessing Custom ItemEntry-based Widget TextComponents?

Postby CrazyEddie » Tue Nov 02, 2010 09:44

Basically what you do is add a PropertyDefinition for the two text fields, and then reference those properties in the TextComponents.

So, add the property definitions:

Code: Select all

<PropertyDefinition name="MapName" initialValue="" redrawOnWrite="true" />
<PropertyDefinition name="MapDesc" initialValue="" redrawOnWrite="true" />


Then reference these in TextComponents via the TextProperty element:

Code: Select all

      <ImagerySection name="layername">
         <TextComponent>
            <Area>
               <Dim type="TopEdge">
                  <AbsoluteDim value="0" />
               </Dim>
               <Dim type="LeftEdge">
                  <AbsoluteDim value="3" />
               </Dim>
               <Dim type="RightEdge">
                  <UnifiedDim scale="1" offset="-3" type="RightEdge" />
               </Dim>
               <Dim type="BottomEdge">
                  <UnifiedDim scale="1" type="BottomEdge" />
               </Dim>
            </Area>

            <TextProperty name="MapName" />

         </TextComponent>
      </ImagerySection>

      <ImagerySection name="description">
         <TextComponent>
            <Area>
               <Dim type="TopEdge">
                  <AbsoluteDim value="5" />
               </Dim>
               <Dim type="LeftEdge">
                  <AbsoluteDim value="3" />
               </Dim>
               <Dim type="RightEdge">
                  <UnifiedDim scale="1" offset="-3" type="RightEdge" />
               </Dim>
               <Dim type="BottomEdge">
                  <UnifiedDim scale="1" type="BottomEdge" />
               </Dim>
            </Area>

            <TextProperty name="MapDesc" />

         </TextComponent>
      </ImagerySection>


HTH

CE

mithryanna
Just popping in
Just popping in
Posts: 13
Joined: Fri Jun 25, 2010 15:00
Location: USA

Re: Accessing Custom ItemEntry-based Widget TextComponents?

Postby mithryanna » Tue Nov 02, 2010 14:41

Thanks! I put in a workaround with child static text windows while I was waiting, but I'd prefer to do it with properties. This should do it. :)


Return to “Help”

Who is online

Users browsing this forum: No registered users and 7 guests