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

The frame module (WVPanelFrame) allows you to draw a rectangular frame in a WildView display. A frame can be useful for defining the area occupied by another module, or for providing visual feedback of mouse actions in a particular area.

The WVPanelFrame 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 three sections:
M odule Attributes

Each possible attribute that can be specified for a panel tag that uses the WVPanelFrame 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="WVPanelFrame"
   name=Frame2
   clock=250
   x=0
   y=0
   w=50
   h=75
   mouseX=0
   mouseY=0
   mouseW=400
   mouseH=200
   size=4
   color1=+25
   color2=-25
   blink=true
   blinkColor1=FAFAFA
   blinkColor2=8A8A8A
   background=00AA00
   visible=true
   clear=false
>

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 WVPanelFrame 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 WVPanelFrame module, this attribute must be set as:

module="WVPanelFrame"

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 WVPanelFrame module, the clock attribute is used in combination with the blink attribute to determine how fast the frame will blink (if enabled).

See the blink attribute for more details about making a frame blink.

The clock attribute value is expressed in milliseconds (1000 milliseconds is equivalent to 1 second -- which would be slow for this module).

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

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

clock=250

If the clock attribute is not specified, then the clock value defaults to zero. A clock value of zero will disable the blinking frame capability, regardless of the setting of the blink attribute.
x

The x attribute determines where the left edge of the panel will be located in the WildView display area (note that the frame area is defined by the dimensions of the panel).

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 (note that the frame area is defined by the dimensions of the panel).

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 (note that the frame area is defined by the dimensions of the panel).

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 (note that the frame area is defined by the dimensions of the panel).

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.
size

The size attribute defines the size (i.e., the width) of the frame in pixels.

For instance, if the following attribute is specified:

size=5

then each of the four sides of the frame will have a width of five pixels.

Note that the frame is always drawn inside of the area defined by the x, y, w, and h attributes. This means that if you would like to draw a frame around another panel, then the dimension of the frame panel should be larger than the dimensions of the panel around which the frame is to be drawn by at least the same number of pixels that is specified for the size attribute. An example of this is illustrated below:

<PANEL name=Scroll module="WVPanelVScroll"
       x=5 y=60 w=180 h=90 clock=30
       fontSize=18 rate=2>

<PANEL name=ScrollFrame module="WVPanelFrame"
       x=0 y=55 w=190 h=100 size=5
       color1=008800 color2=00ff00>
color1

The color1 attribute defines the color used to draw all or part of the frame.

If the color2 attribute is not specified, then the color1 attribute assigns the color of the entire frame.

If the color2 attribute is specified, then the color1 attribute assigns the color of the top and left sides of the frame.

The value of the color1 attribute 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 a "brighten" amount.

When a "brighten" amount is used, the panel's background is used to create the frame. In other words, the background area starting at the panel's boundaries (as defined by the x, y, w, and h attributes) and extending inward the number of pixels defined by the size attribute, are "brightened" to give the effect of a frame.

To "brighten" the background for use as a frame, a value between "+255" and "-255" may be used.

If the attribute value begins with a "+", then the background will be brightened (made lighter) by the amount specified. For instance, the specification

color1=+75

will brighten the background by 75.

If the attribute value begins with a "-", then the background will be dimmed (made darker) by the amount specified. For instance, the specification

color1=-75

will dim the background by 75.

Note that in order to "brighten" the background for use as a frame, you must use a "+" or a "-" as the first character of the attribute value.
color2

The color2 attribute defines the color used to draw the bottom and right sides of the frame.

If the color2 attribute is not specified, then the entire frame will be drawn using the color defined by the color1 attribute.

The value of the color2 attribute 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 a "brighten" amount.

When a "brighten" amount is used, the panel's background is used to create the bottom and right portions of the frame. In other words, the bottom and right portions of the background area starting at the panel's boundaries (as defined by the x, y, w, and h attributes) and extending inward the number of pixels defined by the size attribute, are "brightened" to give the effect of a frame.

To "brighten" the background for use as a frame, a value between "+255" and "-255" may be used.

If the attribute value begins with a "+", then the background will be brightened (made lighter) by the amount specified. For instance, the specification

color2=+75

will brighten the background by 75.

If the attribute value begins with a "-", then the background will be dimmed (made darker) by the amount specified. For instance, the specification

color2=-75

will dim the background by 75.

Note that in order to "brighten" the background for use as a frame, you must use a "+" or a "-" as the first character of the attribute value.
blink

The blink attribute can be used to make the frame blink by alternating between the color set defined by the color1 and color2 attributes, and the color set defined by the blinkColor1 and blinkColor2 attributes.

The following are the valid values that can be specified for the blink attribute:
  • true - the frame will blink constantly

  • false - the frame will not blink

  • enter - the frame will blink whenever the mouse enters the panel's mouse area (see the mouseX, mouseY, mouseW, and mouseH attributes for details about the mouse area)

  • number - the frame will blink the number of times specified by number, and then will stop blinking. For instance, blink=3 will cause the frame to blink just three times.
The speed at which the frame will blink is controlled by the clock attribute. If the clock attribute has a value of zero, then no blinking will occur, regardless of the value of the blink attribute.

If this attribute is not specified, then the frame will not blink (i.e., the attribute value will default to "false").
blinkColor1

The blinkColor1 attribute defines the color used to draw all or part of the frame when the frame is blinking (see the description of the blink attribute for information regarding how to make a frame blink).

When a frame blinks, it alternates between two color sets. One color set is defined by the color1 and color2 attributes, and the second color set is defined by the blinkColor1 and blinkColor2 attributes.

If the blinkColor2 attribute is not specified, then the blinkColor1 attribute assigns the color of the entire frame.

If the blinkColor2 attribute is specified, then the blinkColor1 attribute assigns the color of the top and left sides of the frame.

The value of the blinkColor1 attribute 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 a "brighten" amount.

When a "brighten" amount is used, the panel's background is used to create the frame. In other words, the background area starting at the panel's boundaries (as defined by the x, y, w, and h attributes) and extending inward the number of pixels defined by the size attribute, are "brightened" to give the effect of a frame.

Note that the background for the blinkColor1 attribute is really whatever is displayed after the frame is drawn using color1 (unless the clear attribute is used -- though that can get tricky). In other words, if color1 is 0000FF (red) and blinkColor1 is "+75", then what will be displayed during the blink is the color red brightened by 75.

To "brighten" the background for use as a frame, a value between "+255" and "-255" may be used.

If the attribute value begins with a "+", then the background will be brightened (made lighter) by the amount specified. For instance, the specification

color1=+75

will brighten the background by 75.

If the attribute value begins with a "-", then the background will be dimmed (made darker) by the amount specified. For instance, the specification

color1=-75

will dim the background by 75.

Note that in order to "brighten" the background for use as a frame, you must use a "+" or a "-" as the first character of the attribute value.

NOTE: Using "brighten" values for any of the color attributes when a frame is blinking places greater demands on the computer than if solid colors are used. You might want to check the performance on all target platforms to be sure that it meets your requirements.
blinkColor2

The blinkColor2 attribute defines the color used to draw the bottom and right sides of the frame when the frame is blinking (see the description of the blink attribute for information regarding how to make a frame blink).

When a frame blinks, it alternates between two color sets. One color set is defined by the color1 and color2 attributes, and the second color set is defined by the blinkColor1 and blinkColor2 attributes.

If the blinkColor2 attribute is not specified, then the blinkColor1 attribute assigns the color of the entire frame.

The value of the blinkColor2 attribute 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 a "brighten" amount.

When a "brighten" amount is used, the panel's background is used to create the frame. In other words, the background area starting at the panel's boundaries (as defined by the x, y, w, and h attributes) and extending inward the number of pixels defined by the size attribute, are "brightened" to give the effect of a frame.

Note that the background for the blinkColor2 attribute is really whatever is displayed after the frame is drawn using color2 (or the color1 attribute if the color2 attribute is not specified), unless the clear attribute is used (though that can get tricky). In other words, if color2 is 0000FF (red) and blinkColor2 is "+75", then what will be displayed during the blink is the color red brightened by 75.

To "brighten" the background for use as a frame, a value between "+255" and "-255" may be used.

If the attribute value begins with a "+", then the background will be brightened (made lighter) by the amount specified. For instance, the specification

color1=+75

will brighten the background by 75.

If the attribute value begins with a "-", then the background will be dimmed (made darker) by the amount specified. For instance, the specification

color1=-75

will dim the background by 75.

Note that in order to "brighten" the background for use as a frame, you must use a "+" or a "-" as the first character of the attribute value.

NOTE: Using "brighten" values for any of the color attributes when a frame is blinking places greater demands on the computer than if solid colors are used. You might want to check the performance on all target platforms to be sure that it meets your requirements.
background

The background color for the frame is assigned using this attribute. The frame's background is the area inside the area defined by the x, y, w, and h attributes.

The attribute's value must be color in RGB hexadecimal format (for example, the color red would be FF0000, and a medium gray would be 888888).

Note that in general, it is preferable to define a frame in a panel set before defining the panel that the frame surrounds. This will help eliminate any drawing order problems which might cause the panel being framed to be obscured with the frame's background. Here is an example of the appropriate panel order for frame that has a solid green background:

<PANEL name=ScrollFrame module="WVPanelFrame"
       x=0 y=55 w=190 h=100 size=5
       color1=008800 color2=00ff00
       background=00FF00>

<PANEL name=Scroll module="WVPanelVScroll"
       x=10 y=65 w=170 h=80 clock=30
       fontSize=18 rate=2>

Note that the clear attribute must be true in order for the background color to be drawn.

If the background attribute is not specified, then the frame's background will be "clear."
visible

The visible attribute determines if the frame will initially be visible.

This attribute can be useful if you do not want the frame displayed in the panel's display area when the panel is first initialized. Once the frame should be made visible, a trigger can be sent to the panel to change the image's visible state.

The valid values for the visible attribute are:
  • true - the image will be visible in the panel's display area

  • false - the image will not be visible in the panel's display area

  • enter - the frame will become visible whenever the mouse enters the panel's mouse area and will become invisible whenever the mouse leaves the panel's mouse area (see the mouseX, mouseY, mouseW, and mouseH attributes for details about the mouse area)
If the visible attribute is not specified, then the attribute's value will default to true (the frame will be visible).
clear

The clear attribute allows you to tell the WVPanelFrame module to clear the area defined by the frame panel's x, y, w, and h attributes every time before the frame is drawn.

The attribute's value can be assigned "true" (automatically clear the frame area), or "false" (do not clear the frame area automatically).

Note that the clear attribute must be true in order for the frame's background color to be drawn.

For an example of when clearing the frame area automatically can be useful, see the description of the blinkColor1 or the blinkColor2 attribute.

If the clear attribute is not specified, then the attribute's value will default to "false."
R eceiving Triggers

The frame displayed by a WVPanelFrame panel can be completely controlled by a <TRIGGER> sent to the WVPanelFrame by another panel.

This means that you can change the frame size, the frame background color, the blink setting, etc., based on a <TRIGGER>.

As an example, suppose that there are two panels in a panel set: one panel is a WVPanelVScroll panel that displays vertically scrolling text for news articles, and the other panel is a WVPanelFrame panel that draws a frame around the scrolling text.

Embedded in the WVPanelVScroll article text are triggers that are fired at the WVPanelFrame panel. These triggers cause the frame to blink three times whenever a new news article is about to be displayed. Here's how the WVPanelFrame panel might be defined:

<PANEL name=frame module="WVPanelFrame"
       x=0 y=0 w=110 h=210 size=5
       color1=000000 blinkColor1=FF0000
       clock=150>

And here is an example of how the WVPanelVScroll panel might be defined:

<PANEL name=article module="WVPanelVScroll"
       x=5 y=5 w=100 h=200
       fontSize=14 fontColor=000000
       leading=-2 clock=25>

<TRIGGER panel=frame blink=3>
This is the first article's text.<P>

<TRIGGER panel=frame blink=3>
This is the second article's text.<P>

<TRIGGER panel=frame blink=3>
This is the third article's text.

Just before the first line of each article's text is displayed, a trigger is fired at the "frame" panel with the attribute blink=3. This causes the frame to blink three times by alternating between color1 (black) and blinkColor1 (red).

The attributes that can be included in a <TRIGGER> sent to a WVPanelFrame panel and which behave identically to the <PANEL> attributes are:
There are two trigger attributes that behave a bit differently in a trigger then they do when they are specified in a <PANEL> tag. These two attributes are the size attribute and the clear attribute.
  • The size trigger attribute

    Like the size attribute in a <PANEL> tag, the size attribute in a <TRIGGER> tag controls the width of the frame. However, by default the size attribute in a <TRIGGER> tag will not clear the old frame before redrawing the frame using the new size.

    If you have a frame with size=2 and you change the size with a trigger so that now size=5, the fact that the frame is not cleared does not matter: the new wider frame simply covers the smaller frame. However, if the situation is reversed (originally size=5, trigger size=2) then the total width of the frame will still be 5 because the frame is not cleared first.

    This can be handy if you want to drawn a multi-colored frame. For instance, if you want a red, white, and blue frame, you can create the frame with an initial width of 6 and a frame color of blue. In another panel (say, a scroller panel), the following triggers can be sent to the frame to create the red and white portions:

    <TRIGGER panel=frame color=FFFFFF size=4> <TRIGGER panel=frame color=FF0000 size=2>

    The first trigger changes the outside portion of the frame to white (four pixels wide), then the second trigger changes the outside portion of the frame to red (two pixels wide). What you end up with is a 6 pixel wide frame with the first two pixels red, the next two pixels white, and the last two pixels blue.

    If you want to change from a wide to a narrow frame without the "striping" effect, then you can use the clear attribute in a <TRIGGER> tag, as described below.

    One final point to remember about changing the frame size: make sure you make the frame panel large enough to contain the largest frame size that you intend to use. If you define a WVPanelFrame panel with dimensions large enough for a frame with a size of 5 and you send a trigger to the frame to change the size to 10, then the frame panel will draw into the area that contains the panel that the frame panel is framing. This might produce unexpected, and possibly unpleasant looking, results.

  • The clear trigger attribute

    The difference between the clear attribute in a <PANEL> tag, and the clear attribute in a <TRIGGER> tag is that the clear attribute in a <TRIGGER> tag only clears the frame area once, whereas the clear attribute in a <PANEL> tag causes the frame area to be cleared every time before the frame is drawn.

    Using the clear attribute can be useful if, for instance, you are making the frame size smaller (see above).
The value of any of the above attributes that are not specified in the trigger will remain unchanged.
Copyright © 1997 by Modern Minds, Inc.