ModernJava
http://www.modernminds.com
M odule WVPanelHScroll

The smooth horizontal scrolling text module (WVPanelHScroll) allows you to scroll text horizontally, from left to right.

The WVPanelHScroll module is always added to a WildView display by using a <PANEL> tag in a WildView layout file.

This module's documentation is divided into four sections:
M odule Attributes

Each possible attribute that can be specified for a panel tag that uses the WVPanelHScroll module is listed below along with a link to the attribute's description.

Be aware that attribute values are shown for illustrative purposes only: refer to each attribute's description for information regarding attribute requirements.

<PANEL
   module="WVPanelHScroll"
   name=HScroller
   clock=75
   x=10
   y=10
   w=200
   h=25
   mouseX=0
   mouseY=0
   mouseW=400
   mouseH=200
   font="TimesRoman"
   fontSize=14
   fontStyle=bold
   fontColor=FFFF00
   rate=2
   justify=middle
   pause=enter
   background=FFFFFF
   initWait=Image1Panel
>

Note that attribute names and attribute values are always converted to lowercase internally (this does not apply to the tag type name -- "PANEL" -- which must always be in uppercase characters).

If you wish to preserve the case of an attribute value (e.g., you are specifying a file name that has upper and lower case characters), then you should surround the attribute value with quotation marks. Also, if there is a space character in an attribute value, then you should use quotation marks around the entire attribute value.

A ttribute Descriptions

Each attribute of the WVPanelHScroll panel tag is defined below. The attribute's use is described and the valid attribute values are listed.
module

The module attribute identifies the Java component that will be associated with the panel.

In order to use the WVPanelHScroll module, this attribute must be set as:

module="WVPanelHScroll"

Note that the module name is within quotation marks in order to preserve the case of the characters.

Be sure that the spelling and the capitalization of the module name match exactly, or WildView will not be able to locate the module.
name

The name attribute allows you to assign a name to the panel.

Panel names are primarily used in conjunction with triggers in order to identify what panel a trigger is being sent to, or in some cases, what panel the trigger was received from.

Panel names are also used by WildView when logging error conditions in order to identify the panel that encountered the error.

The name attribute is optional, but if it is not specified then you will not be able to send triggers to this panel from other panels.
clock

The clock attribute defines how frequently the module will get a chance to draw in the WildView display area.

For the WVPanelHScroll module, the clock attribute controls how fast the text will be scrolled in the panel.

The clock attribute value is expressed in milliseconds (250 milliseconds is equivalent to ¼ seconds -- which would be extremely slow for this module).

To increase the scrolling speed, decrease the clock value; to decrease the scrolling speed , increase the clock value.

A good value to try initially is 50 milliseconds. Using this value, the attribute specification will be:

clock=50

Note that the rate attribute also affects the scrolling speed.

If the clock attribute is not specified, then the clock value defaults to zero, which disables animation (i.e., nothing will ever be drawn in the panel).
x

The x attribute determines where the left edge of the panel will be located in the WildView display area.

For instance, if the WildView display area has a total width of 200, and if a value of 100 is specified for the panel's x attribute, then the panel will be drawn with its left edge located in the middle of the WildView display.

A module will only draw within the rectangle defined by the x, y, w, and h attributes.

Panel Area

In order for a panel to be completely visible in the WildView display area, the x attribute value must be greater than or equal to zero and less than the total width of the WildView display area.

If the x attribute is not specified, then the attribute's value will default to zero (i.e., the left edge of the WildView display area).
y

The y attribute determines where the top edge of the panel will be located in the WildView display area.

For instance, if the WildView display area has a total height of 100, and if a value of 50 is specified for the panel's y attribute, then the panel will be drawn with its top edge located in the middle of the WildView display.

A module will only draw within the rectangle defined by the x, y, w, and h attributes.

Panel Area

In order for a panel to be completely visible in the WildView display area, the y attribute value must be greater than or equal to zero and less than the total height of the WildView display area.

If the y attribute is not specified, then the attribute's value will default to zero (i.e., the top edge of the WildView display area).
w

The w attribute determines the width of the panel in the WildView display area.

For instance, if the WildView display area has a total width of 200, and if the panel's x attribute has a value of 20, and the panel's w attribute has a value of 160 (positioning the right edge of the panel at 20 + 160 = 180), then the panel will be centered horizontally in the WildView display (there is a margin of 20 to the left of the left panel edge and a margin of 200 - 180 = 20 to the right of the right panel edge).

A module will only draw within the rectangle defined by the x, y, w, and h attributes.

Panel Area

In order for a panel to be completely visible in the WildView display area, the w attribute value added to the x attribute value must be less than or equal to the total width of the WildView display area.

If the w attribute is not specified, then the attribute's value will default to zero (i.e., the panel will not be visible in the WildView display area).
h

The h attribute determines the height of the panel in the WildView display area.

For instance, if the WildView display area has a total height of 100, and if the panel's y attribute has a value of 10, and the panel's h attribute has a value of 80 (positioning the bottom edge of the panel at 10 + 80 = 90), then the panel will be centered vertically in the WildView display (there is a margin of 10 above the top panel edge and a margin of 100 - 90 = 10 below the bottom panel edge).

A module will only draw within the rectangle defined by the x, y, w, and h attributes.

Panel Area

In order for a panel to be completely visible in the WildView display area, the h attribute value added to the y attribute value must be less than or equal to the total height of the WildView display area.

If the h attribute is not specified, then the attribute's value will default to zero (i.e., the panel will not be visible in the WildView display area).
mouseX

The mouseX attribute is an optional attribute that defines the left most side of a rectangle in which mouse events will be recognized by the panel.

Normally, the mouse area (defined by the mouseX, mouseY, mouseW, and mouseH attributes) is identical to the panel display area (defined by the x, y, w, and h attributes).

Occasionally it is useful to define a mouse area that is different from the display area. For instance, you might have a small panel in a corner of a WildView display that contains vertically scrolling text. If you want the scrolling to pause whenever the mouse enters the WildView display area (as opposed to when the mouse enters the panel area), you can define a mouse area equal to the entire WildView display area (of which the scrolling text panel occupies just a part).

A module will only respond to mouse events that occur within the rectangle defined by the mouseX, mouseY, mouseW, and mouseH attributes.

The illustration below shows a panel with a mouse area that is smaller than the panel area.

Mouse Area

If the mouseX attribute is not specified, then the attribute's value will default to value of the x attribute.
mouseY

The mouseY attribute is an optional attribute that defines the top most side of a rectangle in which mouse events will be recognized by the panel.

Normally, the mouse area (defined by the mouseX, mouseY, mouseW, and mouseH attributes) is identical to the panel display area (defined by the x, y, w, and h attributes).

Occasionally it is useful to define a mouse area that is different from the display area. For instance, you might have a small panel in a corner of a WildView display that contains vertically scrolling text. If you want the scrolling to pause whenever the mouse enters the WildView display area (as opposed to when the mouse enters the panel area), you can define a mouse area equal to the entire WildView display area (of which the scrolling text panel occupies just a part).

A module will only respond to mouse events that occur within the rectangle defined by the mouseX, mouseY, mouseW, and mouseH attributes.

The illustration below shows a panel with a mouse area that is smaller than the panel area.

Mouse Area

If the mouseY attribute is not specified, then the attribute's value will default to value of the y attribute.
mouseW

The mouseW attribute is an optional attribute that defines the width of a rectangle in which mouse events will be recognized by the panel.

Normally, the mouse area (defined by the mouseX, mouseY, mouseW, and mouseH attributes) is identical to the panel display area (defined by the x, y, w, and h attributes).

Occasionally it is useful to define a mouse area that is different from the display area. For instance, you might have a small panel in a corner of a WildView display that contains vertically scrolling text. If you want the scrolling to pause whenever the mouse enters the WildView display area (as opposed to when the mouse enters the panel area), you can define a mouse area equal to the entire WildView display area (of which the scrolling text panel occupies just a part).

A module will only respond to mouse events that occur within the rectangle defined by the mouseX, mouseY, mouseW, and mouseH attributes.

The illustration below shows a panel with a mouse area that is smaller than the panel area.

Mouse Area

If the mouseW attribute is not specified, then the attribute's value will default to value of the w attribute.
mouseH

The mouseH attribute is an optional attribute that defines the height of a rectangle in which mouse events will be recognized by the panel.

Normally, the mouse area (defined by the mouseX, mouseY, mouseW, and mouseH attributes) is identical to the panel display area (defined by the x, y, w, and h attributes).

Occasionally it is useful to define a mouse area that is different from the display area. For instance, you might have a small panel in a corner of a WildView display that contains vertically scrolling text. If you want the scrolling to pause whenever the mouse enters the WildView display area (as opposed to when the mouse enters the panel area), you can define a mouse area equal to the entire WildView display area (of which the scrolling text panel occupies just a part).

A module will only respond to mouse events that occur within the rectangle defined by the mouseX, mouseY, mouseW, and mouseH attributes.

The illustration below shows a panel with a mouse area that is smaller than the panel area.

Mouse Area

If the mouseH attribute is not specified, then the attribute's value will default to value of the h attribute.
font

This attribute specifies the typeface to be used when drawing the text.

The font name can be any of the standard Java fonts:
  • "Dialog"
  • "Helvetica"
  • "TimesRoman"
  • "Courier"
  • "Symbol"
Note that the font name must be surrounded with quotation marks in order for Java to find and load the correct font.

If a value for this attribute is not specified, then the text font will default to "Helvetica".
fontSize

This attribute assigns the size of the font used to draw the text.

If a value for this attribute is not specified, then the text font size will default to 12.
fontStyle

This attribute assigns the style of the font used to draw the text.

The value for the style attribute can be any one of the following:
  • plain
  • bold
  • italic
  • italic+bold
  • bold+italic
If a value for this parameter is not specified, then the font style will default to "plain".
fontColor

This attribute assigns the font color used to draw the text.

The value for this attribute must be a RGB value in hexadecimal format. For instance, the color red would be FF0000, and a medium gray would be 888888.

If a value for this attribute is not specified, then the font color will default to black.
rate

The speed at which the text scrolls in a WVPanelHScroll panel is primarily governed by the clock attribute, which determines how long it takes to scroll the text to the left by the number of pixels specified by the rate attribute.

The rate attribute defaults to one pixel if not specified, and this default value will produce the smoothest scrolling animation.

A rate value that is greater than one is useful if you wish to increase the speed at which the text is scrolled, but you do not want to decrease the clock value (the lower the clock value, the faster is the animation, but the greater are the demands that are placed on the computer).

While increasing the rate attribute value will result in text that scrolls faster, in will also result in animation that is "rougher" or "choppier."
justify

The justify attribute enables you to specify the text justification within the panel display area.

The valid values for the justify attribute are:
  • top - text is justified vertically along the top edge of the panel display area
  • middle - text is justified vertically in the middle of the panel display area
  • bottom - text is justified vertically along the bottom edge of the panel display area
If a value for this attribute is not specified, then the text will be middle justified.
pause

The pause attribute allows you to specify an action that, when detected, will cause the scrolling animation to pause. By allowing the panel display to be paused, you give the person reading the text the ability to pause the scrolling text in a situation where the text is scrolling too quickly.

There are three valid values that can be assigned to this attribute:
  • false - the animation cannot be paused
  • enter - the animation will pause whenever the mouse enters the panel's mouse area
  • click - the animation will pause whenever the mouse is clicked within the panel's mouse area
(See the mouseX, mouseY, mouseW, and mouseH attributes for details concerning the mouse area.)

There are some situations where you will want to be sure that the animation can not be paused. For instance, if you are using triggers to synchronize animation in two or more panels, then allowing the user to pause one or more of those panels might cause the panel synchronization to become unsynchronized.

If this attribute is not specified, then the attribute default value will be "false" (animation cannot be paused).
background

The background color of the panel's display area is assigned using this attribute.

The attribute's value may be a color in RGB hexadecimal format (for example, the color red would be FF0000, and a medium gray would be 888888), or it may be the special value "clear".

If the special value "clear" is used as the background color, then the panel area will not be filled with a color, but rather the text will be scrolled over whatever image lies under the panel area.

If the background attribute is not specified, then the background color will default to "clear".
initWait

The initWait attribute can be used to assign an id that the panel will wait for before drawing anything in its display area. In other words, the panel will wait until it receives a <TRIGGER> with the specified id, before it will begin to scroll the text.

One of the more common ways of using this attribute is in conjunction with a <COLOR> tag embedded in the text to be scrolled.

When embedding a <COLOR> tag in the text for a WVPanelHScroll panel, you may set the panel's background to an image contained in a WVPanelImage panel. However, when WildView initializes a WVPanelHScroll panel, there is no guarantee that the image in the WVPanelImage panel has been completely loaded.

Since a WVPanelImage panel can send a trigger to another panel when its image has been completely loaded, we can use the WVPanelHScroll initWait attribute to cause the WVPanelHScroll panel to wait until it receives this trigger before it begins scrolling the text and executing the <COLOR> tags embedded in the text.
T ags

The text that is to be scrolled follows the <PANEL> tag. The WVPanelHScroll module allows the following tags to be embedded in the text:
  • <WAIT> - stop scrolling the text
  • <TRIGGER> - send a trigger to a panel
  • <RATE> - change the text scroll rate
  • <COLOR> - change the text color or panel background
  • <SET> - load another panel set
  • <LOAD> - load one or more URLs
<WAIT>

The <WAIT> tag allows you stop the scrolling animation immediately before the character of text that follows the <WAIT> tag is displayed.

When a <WAIT> is encountered, the text that precedes the tag will continue to scroll to the left, but no additional characters will be scrolled into the display area. Once all of the text has been scrolled out of the display area, then scrolling will be resumed when one of the following two conditions occur.
  1. The panel receives a <TRIGGER> (with the appropriate id, if specified), or

  2. The (optional) <WAIT> timeout expires.
The format of the <WAIT> tag is:

<WAIT id=idName timeout=seconds>

The <WAIT> tag attributes are:
  • id

    This optional attribute is the id that a <TRIGGER> must send in order for scrolling to resume. If the attribute is omitted, then any <TRIGGER> sent to this panel will cause the scrolling to resume.

  • timeout

    If a timeout attribute is specified, then the scrolling will resume if a <TRIGGER> is received (with the appropriate id, if specified), or when the number of seconds specified for the timeout attribute have elapsed.
A <WAIT> tag with a timeout attribute is a good way to insert a pause of a specific number of seconds between sections of text, if desired.

<TRIGGER>

The <TRIGGER> tag allows you send a message to one or more panels immediately before the character of text that follows the <TRIGGER> tag is displayed.

The format of the <TRIGGER> tag is:

<TRIGGER panel=panelName id=idName ... >

The <TRIGGER> tag attributes are:
  • panel

    This required attribute is the name of a panel (or panels) to which this trigger should be sent.

    The attribute value can be the name of a single panel to which the trigger should be sent, as for example:

    panel=panel1

    or, multiple panels can be sent a trigger by separating the panel names with commas, like:

    panel=panel1,panel2,panel3

    Note that without quotation marks, you cannot put spaces in the attribute value. If you surround the attribute value with quotation marks, however, you can place spaces in the attribute value: in fact, you can use spaces instead of commas to separate the panel names to which triggers should be sent.

    With quotation marks, you can use spaces after a comma:

    panel="panel1, panel2, panel3"

    Or you can use spaces instead of commas:

    panel="panel1 panel2 panel3"


  • id

    This optional attribute is commonly used, and so it is documented here.

    The attribute is most often specified when another panel has executed a <WAIT> tag and is waiting for a <TRIGGER> with a specific ID.

    In this case, you can cause the <WAIT>ing panel to resume by sending it a <TRIGGER> with an id attribute that matches the id for which the panel is <WAIT>ing.

  • ...

    The ellipse indicates that there can be any number of additional attribute/value pairs that can be sent to the panel.

    The attributes in the <TRIGGER> that are recognized by the target panel depends upon the module that was used to create the panel.

    See the documentation for the appropriate module to determine what <TRIGGER> attributes can be sent to the particular target panel.
<RATE>

The <RATE> tag allows you to change the rate at which the text is scrolled once a particular character in the text is reached.

The format of the <RATE> tag is:

<RATE pixels>

where the pixels value is equal to the number of pixels to advance the scrolling for each master clock (see the rate attribute for more information regarding how this works).

Be aware that there is no attribute name for this tag, just a value. For instance, if you want to change the rate to 2 pixels, the tag might look like:

... some sample text. <RATE 2>Some additional text ...

<COLOR>

The <COLOR> tag allows the color being used to draw the scrolling text to be changed, or the appearance of the panel's background to be changed, just before the character that follows the <COLOR> tag is displayed.

The format of the <COLOR> tag is:

<COLOR font=fontColor background=bkgndColor>

The <COLOR> tag attributes are:
  • font

    This optional attribute assigns the font color used to draw the text.

    The value for this attribute must be a RGB value in hexadecimal format. For instance, the color red would be FF0000, and a medium gray would be 888888.

    If the font attribute is not specified, then the font color will remain unchanged.

  • background

    This optional attribute defines the appearance of the panel's background. The attribute value can be:

    • An RGB Value

      A solid color to be used as the panel's background must be specified in RGB hexadecimal format. For instance, the color red would be FF0000, and a medium gray would be 888888.

      An example of this tag using a color value is:

      <COLOR background=FFFF00>

    • "clear"

      The special value of "clear" can be used to make the panel's background transparent. This means that the WildView background will be seen beneath the scrolling text.

      An example of this tag using the "clear" special value is:

      <COLOR background=clear>

    • An Image Panel Name

      Using the name of panel created by the WVPanelImage module as a background value allows you to "grab" the image that is currently being displayed by the image panel and use it as a background image for the scrolling text panel (i.e., the text will be scrolled over the "grabbed" image).

      Note that the image panel does not need to be visible in order to "grab" its image. If you are using the image panel only to provide a background image for the scrolling text panel, then you can position the image panel at a location outside of the WildView display area.

      If used in conjunction with the <TRIGGER> tag, you can change the background image depending on the text that is being displayed. See the documentation for the WVPanelImage module for additional information regarding this capability.

      An example of this tag using an image panel name is:

      <COLOR background=image1>

    If the background attribute is not specified, then the panel's background will remain unchanged.
<SET>

The <SET> tag can be used to load another panel set (i.e., a layout file) to replace the panel set currently being displayed. The <SET> tag is executed immediately before the character following the <SET> tag is displayed.

The format of the <SET> tag is:

<SET panelSet="panelSetToLoad" stop=stopDisplay loadMessage="messageText">

The <SET> tag attributes are:
  • panelSet

    This required attribute is the panel set file name or the number of the panel set that should be loaded.

    If a file name is specified, then the file name must exactly match a file name assigned to one of the panelSet parameters entered with <APPLET> tag.

    An example of a <SET> tag using a file name is:

    <SET panelSet="SecondPanelSet.TXT">

    Remember, in order to preserve upper and lower case characters, you must surround the attribute value with quotation marks.

    If a panel set number is entered, then it should correspond to one of the panelSet parameters entered with <APPLET> tag.

    An example of a <SET> tag using a number is:

    <SET panelSet=2>

    The above example would load the panel set associated with the panelSet2 applet parameter.

  • stop

    If this optional attribute is set to "true", then all WildView animation will be stopped while the new panel set is loaded.

    If the attribute value is set to "false", then animation will continue while the next panel set is loaded.

    If the stop attribute is not specified, then its value will default to "false".

  • loadMessage

    If a text string is specified for this optional attribute, then the text will be displayed on a single line in the center of the applet display area while the next panel set is loaded.
<LOAD>

The <LOAD> tag is used to load one or more URLs just before the character following the <LOAD> tag is displayed.

The format of the <LOAD> tag is:

<LOAD url="url1 url2 url3 ..." target="target1 target 2 target3 ...">

The <LOAD> tag attributes are:
  • url

    The value of the url attribute can be any valid URL, or it can be a list of URLs separated by at least one space character. For instance,

    url=http://www.modernminds.com

    or

    url="../HTML/Home.html  http://www.microsoft.com  http://home.netscape.com"

    Note that if you specify more than one URL, then the list must be enclosed within quotation marks. Also, you should specify a target for each of the URLs. If you do not specify targets when multiple URLs are used, then the URLs will just load on top of each other, each URL replacing the URL that was previously loaded.

    If you specify a partial URL, as for example,

    url="Home.html"

    then the root of the URL will be based on the URL of the directory that contains the the Java code.

    For instance, if the WildView Java classes are in a directory called "Java", and if a HTML file called "Home.html" is in a directory called "HTML" which is in the "Java" directory (i.e., "Java/HTML/Home.html"), then the attribute would be:

    url="HTML/Home.html"

    Note that you can also use the "mailto" option to launch a user's mail client. For example:

    url=mailto:comments@modernminds.com

    Make sure that you do not use the target attribute if you are using "mailto."

    If a value for this attribute is not specified, then the tag will be ignored.

  • target

    For each URL specified in the url attribute, a target can be specified. If a target is not specified, then the URL will load over the current page and replace the applet.

    The value of the target attribute can be any valid target frame name or symbol (some browsers will open a new browser window if the target name does not exist).

    Some special symbolic values are (warning: these values might not work for every browser):

    • _blank - Always load the URL into a new, unnamed window

    • _self - Always load the URL over the current page

    • _parent - Always load this URL over the parent page (becomes self if there was no parent)

    • _top - Always load this link at the top level (becomes self if current page is at the top)

    If more than one URL is specified for the url attribute, then the corresponding targets must be listed within quotation marks in the same order as the URLs.

    For example:

    <LOAD url="http://www.modernminds.com
      http://www.microsoft.com
      http://home.netscape.com"
      target="MMFrame MSFrame NSFrame">

    This example will load http://www.modernminds.com in MMFrame,
    http://www.microsoft.com in MSFrame, and
    http://home.netscape.com in NSFrame.

    If you do not wish to specify a target for a URL in a list, then you may enter a dash (i.e., "-") for the target. For instance:

    <LOAD url="http://www.modernminds.com
      mailto:support@modernminds.com
      http://home.netscape.com"
      target="MMFrame - NSFrame">
R eceiving Triggers

At present there is only one <TRIGGER> function that is supported by a panel based on the WVPanelHScroll module.

If the panel finds a <WAIT> tag in the text to be scrolled, then the panel will stop scrolling new characters onto the display as soon as the <WAIT> tag is reached.

If the <WAIT> tag specifies an id attribute, then the panel will wait until it receives a trigger that has a matching id.

For instance, suppose there is a panel named "scrolltext" and part of the panel's text looks like this:

... this is some sample text. <WAIT id=continue>And this is some additional sample text ...


Once the "scrolltext" panel has scrolled the text ending with "this is some sample text." into view, it will not scroll any additional characters (i.e., the text beginning with "And this is some additional sample text ...") into view until any text still in the display area has scrolled out of view and until another panel executes a trigger that might look something like this:

... and that's the end of this topic.<BR> <TRIGGER panel=scrolltext id=continue>Here is our next topic ...


Once the "scrolltext" panel receives this trigger, it sees that the id attribute of the <WAIT> tag matches the id attribute of the trigger received, and it will then resume scrolling the text.

If the <WAIT> tag had omitted the id attribute, then scrolling would have resumed when any trigger was received, regardless of the trigger's id attribute.

Also, if the <WAIT> tag had used the timeout attribute, then the scrolling would have resumed even if a trigger had not been received provided that the number of seconds specified by the timeout attribute had elapsed.
Copyright © 1997 by Modern Minds, Inc.