StaticText without Scrollbars

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

daves
Home away from home
Home away from home
Posts: 253
Joined: Thu Feb 02, 2006 20:12

StaticText without Scrollbars

Postby daves » Fri Nov 07, 2008 18:52

What is the easiest way for me to create a custom widget that is identical to a StaticText widget (in terms of the properties and the setters), except that it does not include any child scrollbars, nor any of the functionality associated with scrollbars?

I was thinking of taking the looknfeel definition of a StaticText and simply stripping out everything that relates to scrollbar. However when I look at the scheme file entry for StaticText it is associated with a Falagard/StaticText. Does the Falagard/StaticText expect to find child scrollbars?

Within one of my specialized functions, I currently instantiate a number of these StaticText items and never use the scrollbars. I want to eliminate them for performance reasons only. So I want to do a simple refactor that replaces my creation of StaticText items (for the specific function of interest only) with the trimmed down object. I want to refactor in a fashion that I can be sure that all the current properties and functions of the StaticText still work.

The Falagard documentation says:
Child widget definitions:

* Scrollbar based widget with name suffix "__auto_vscrollbar__". This widget will be used to control vertical scroll position.
* Scrollbar based widget with name suffix "__auto_hscrollbar__". This widget will be used to control horizontal scroll position.


These seem to be required, though the area elements are optional:
# TextRenderAreaHScroll – Target area where text will appear when the horizontal scrollbar is visible. Optional.
# TextRenderAreaVScroll – Target area where text will appear when the vertical scrollbar is visible. Optional.
# TextRenderAreaHVScroll – Target area where text will appear when both the horizontal and vertical scrollbars are visible. Optional.

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

Postby CrazyEddie » Sat Nov 08, 2008 10:23

Hi,

From a technical standpoint, within the code there is no such thing as a StaticText widget - it's just a DefaultWindow that is customised via the WindowRenderer. And no, I'm actually not going to say you need to write a new WindowRenderer :P

I've looked over the StaticText WindowRenderer and I can't quite make out why those non-scrollbar related properties are there and not implemented via the WidgetLook specification.

Anyway, as far as I can tell you can get what you need (a widget that displays text with configurable colours and horz/vert formatting) by using the default window / default window renderer and a WidgetLook definition that first adds the required properties (TextColours, HorzFormatting and VertFormatting) via PropertyDefinition elements. The core of the widget would then be a TextComponent element that defines an area for the text to appear and uses ColourRectProperty, HorzFormatProperty and VertFormatProperty to fetch the required formatting from the earlier defined properties. Beyond this, the rest of the widget imagery can be coped from the existing static text.

No specific example since I think you have the experience to understand the above :) If you need a specific example, ask and I'll do my best.

CE.

daves
Home away from home
Home away from home
Posts: 253
Joined: Thu Feb 02, 2006 20:12

Postby daves » Sat Nov 08, 2008 13:52

thx, i'll give it a crank, btw i've been away from the forums for almost two months, indeed i've been away from my cegui project for about that long. Its good to get back into it (even if i only get a chance to do a little bit). I'm still waiting for our company to kick in some real R&D dollars to keep on building.

thx for the help.

Pompei2
Home away from home
Home away from home
Posts: 489
Joined: Tue May 23, 2006 16:31

Postby Pompei2 » Mon Nov 10, 2008 09:11

Hi Daves, I have something that may make you happy. That is no R&D Dollars ;) but I made a widget named "Label" that I use to render text, without any scrollbar or text wrapping functionality whatsoever.

Here is ArkanaLook.Label.looknfeel:

Code: Select all

<?xml version="1.0" ?>

<Falagard>
   <!--
   ***************************************************
   Just simple text, nothing more.
   ***************************************************
   -->

   <WidgetLook name="ArkanaLook/Label">

      <!-- The Property definitions. These are properties you can set in your layout/code. -->
      <!-- ******************************************************************************* -->

      <PropertyDefinition name="TextColourNormal" initialValue="FF373737" redrawOnWrite="true" />
      <PropertyDefinition name="TextColourDisabled" initialValue="FF1B56A0" redrawOnWrite="true" />
      <PropertyDefinition name="VertFormat" initialValue="CentreAligned" redrawOnWrite="true" />
      <PropertyDefinition name="HorzFormat" initialValue="LeftAligned" redrawOnWrite="true" />

      <Property name="WantsMultiClickEvents" value="False" />
      <Property name="Font" value="old2" />

      <!-- The Imagery sections. This specifies how a section is drawn. -->
      <!-- ************************************************************ -->

      <!-- This section draws the text and that's all. -->
      <ImagerySection name="label">
         <TextComponent>
            <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>
            <VertFormatProperty name="VertFormat" />
            <HorzFormatProperty name="HorzFormat" />
         </TextComponent>
      </ImagerySection>

      <!-- The Imagery states. This specifies what sections are drawn in wich state. -->
      <!-- ************************************************************************* -->

      <!-- Enabled -->
      <StateImagery name="Enabled">
         <Layer>
            <Section section="label">
               <ColourProperty name="TextColourNormal" />
            </Section>
         </Layer>
      </StateImagery>

      <!-- Disabled -->
      <StateImagery name="Disabled">
         <Layer>
            <Section section="label">
               <ColourProperty name="TextColourDisabled" />
            </Section>
         </Layer>
      </StateImagery>

   </WidgetLook>
</Falagard>


and this is the scheme entry:

Code: Select all

    <LookNFeel Filename="ArkanaLook.Label.looknfeel" />
    <FalagardMapping WindowType="ArkanaLook/Label" TargetType="DefaultWindow" Renderer="Falagard/Default" LookNFeel="ArkanaLook/Label" />


Hope that is useful for you.

daves
Home away from home
Home away from home
Posts: 253
Joined: Thu Feb 02, 2006 20:12

Postby daves » Mon Nov 10, 2008 17:03

Thanks. One more quick comment, though I am not using the scrollbars associated with the StaticText, I have been using the "frame" (sometimes showing it, sometimes not). There are a number of "with frame" and "without frame" sections to the StaticText looknfeel. I'm trying to figure out how to reuse all these, so that the only thing that I've eliminated is the scrollbars themselves.

Jamarr
CEGUI MVP
CEGUI MVP
Posts: 812
Joined: Tue Jun 03, 2008 23:59
Location: USA

Postby Jamarr » Mon Nov 10, 2008 18:32

How do you even get scrollbars working with the StaticText widget? Like this guy, geniephics, the scrollbars for the default StaticText widget are never shown, even though the widget is properly defined to have them in the .looknfeel (TaharezLook and WindowsLook). It also does not provide word wrapping.

Are you using version of cegui checked out from SVN or something?

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

Postby CrazyEddie » Tue Nov 11, 2008 09:52

daves wrote:There are a number of "with frame" and "without frame" sections to the StaticText looknfeel. I'm trying to figure out how to reuse all these, so that the only thing that I've eliminated is the scrollbars themselves.


There will be limits to the amount of what I will call reuse without redefinition that will be possible. We already reuse ImageySections from the common "StaticShared" definition for the supplied StaticImage and StaticText definitions. This is done by specifying a WidgetLook within the Section element(s) when specifying the imagery layers in the StateImagery definitions (obviously if you're basing this on a DefaultWindow, you just have the Enabled and Disabled states to work with. But anyway, as seen here:

Code: Select all

<Section look="TaharezLook/StaticShared" section="frame" />

This can be placed in any other WidgetLook and it will reuse that section that was defined within "TaharezLook/StaticShared" WidgetLook.

Obviously when using the DefaultWindow WindowRenderer you lose some of the customisations as far as enabling and disabling the frame, although you can get some of that back by the use of control properties. Basically you define a property that will be set to boolean "True" or "False", and then use that property to control whether or not a particular Section within the StateImagery will be drawn or not. For example:

Code: Select all

<Section look="TaharezLook/StaticShared" section="frame" controlProperty="FrameEnabled" />

(this assumes that you added a PropertyDefinition for the "FrameEnabled" property earlier in the WidgetLook Definition.

Jamarr wrote:How do you even get scrollbars working with the StaticText widget?

The scrollbar use is disabled by default, to enable to scrollbar do something like:

Code: Select all

myStaticText->setProperty( "VertScrollbar", "True" );

Or you can obviously use the property in a layout.

HTH

CE

Pompei2
Home away from home
Home away from home
Posts: 489
Joined: Tue May 23, 2006 16:31

Postby Pompei2 » Sat Nov 15, 2008 23:12

Jamarr wrote:How do you even get scrollbars working with the StaticText widget? Like this guy, geniephics, the scrollbars for the default StaticText widget are never shown, even though the widget is properly defined to have them in the .looknfeel (TaharezLook and WindowsLook). It also does not provide word wrapping.

Are you using version of cegui checked out from SVN or something?

Huh ? I am still using some 0.5 svn version from before 0.6 was out ! Had to do nothing special, word wrapping and scrollbars, just put this into your layout:

Code: Select all

            <Property Name="HorzFormatting"  Value="WordWrapLeftAligned" />
            <Property Name="VertScrollbar"   Value="True" />
            <Property Name="HorzScrollbar"   Value="True" />


Return to “Help”

Who is online

Users browsing this forum: No registered users and 8 guests