Packages
 In this topic

*Constructors

*Methods

*Fields

 

Packages   PreviousThis PackageNext
Package com.ms.fx   Previous This
Package
Next

 


Class FxComponentImage

public abstract class FxComponentImage extends FxStateConfigurableUIImage
{
  // Fields
  public final static int CHECK_BOX;
  public final static int DOWN_ARROW;
  public final static int EXPAND_BOX;
  public final static int LEFT_ARROW;
  public final static int RADIO_BUTTON;
  public final static int RIGHT_ARROW;
  public final static int UP_ARROW;

  // Constructors
  public FxComponentImage(int states[]);

  // Methods
  public void drawChar(Graphics g, String s, int x, int y,
        int size);
  public static FxComponentImage getFactory(int idx);
  public Image getImage(Dimension size, int state);
  public Image getImage(Dimension size, IUIComponent comp);
  public Image getImage(Dimension size, int state, Color backColor,
        Color foreColor);
  public int getStateID(int state);
  public Font getWidgetFont(int c);
  public static void setFactory(int idx, FxComponentImage factory);
}

This class is a class factory that provides a set of consistent, cross-platform images that are used by the com.ms.ui classes for Graphical User Interface(GUI) display components. The class provides a consistent set of images, regardless of the underlying platform, but can be configured to the underlying platform (if required).

The following example shows how to create an FxComponentImage class factory, and then associate it with a component image.

// Create an object that contains images for the 
various states of a 
// check box component image. 
int states[] = { FxStateConfigurableUIImage.CHECKED,
                 FxStateConfigurableUIImage.INDETERMINATE };
FxComponentImage fxci = new FxComponentImage(states);

// You must specify what type of component image you want
// to create the class factory for, with the setFactory method.
fxci.setFactory (FxComponentImage.CHECK_BOX, this);

By default, the FxComponentImage class creates seven kinds of image class factories. The following table lists these factory styles.
RADIO_BUTTON CHECK_BOX EXPAND_BOX
LEFT_ARROW RIGHT_ARROW
UP_ARROW DOWN_ARROW

The FxComponentImage objects provide a set of state-dependant images for each component image, depending on what states the image may have. For example, a LEFT_ARROW component image cannot have an INDETERMINATE state, so an image for this state is not provided in the LEFT_ARROW class factory.

You can use the static getFactory method to get the default class factory for an image that the FxComponentImage class provides. You can use the getImage method to retrieve the image for a specified state. The following example shows how to create a default factory for a CHECK_BOX image.

FxToolkit.getSystemInterface() ; // Initialize FxToolkit.

// Retrieve the default class factory for CHECK_BOX provided by FxComponentImage.
FxComponentImage fxi = FxComponent.getFactory(FxComponentImage.CHECK_BOX);

// Retrieve the image with dimension 20x20 of a selected check box.
Image checkedImg = 
     fxi.getImage(new Dimension(20, 20), FxStateConfigurableUIImage.CHECKED);

// This will draw a selected check box at (50,50) with dimension 20x20.
g.drawImage( checkedImg, 50, 50, this );
FxStateConfigurableImage
  |
  +--FxStateConfigurableUIImage
    |
    +--FxComponentImage

Constructors

FxComponentImage

public FxComponentImage(int states[]);

Creates an FxComponentImage class factory using the specified array of component states.

ParameterDescription
states The component states. This can be one or an array of the following states, depending on the image.
HOT PRESSED CHECKED INDETERMINATE ENABLED

Methods

drawChar

public void drawChar(Graphics g, String s, int x, int y, int size);

Draws a character using the graphics object's current font and color.

Return Value:

No return value.

ParameterDescription
g The graphics object to use.
s The string to draw.
x The x coordinate of the location where the string should be drawn.
y The y coordinate of the location where the string should be drawn.
size The size of the character (in points).

getFactory

public static FxComponentImage getFactory(int idx);

Retrieves the FxComponentImage object associated with the component image at the specified index.

Return Value:

Returns the texture factory associated with the component image.

ParameterDescription
idx The index of the component image. This can be any one of the following images.
RADIO_BUTTON CHECK_BOX EXPAND_BOX
LEFT_ARROW RIGHT_ARROW UP_ARROW DOWN_ARROW

Exceptions:

ArrayIndexOutOfBoundsException if the index of the component image idx is not valid.

getImage

public Image getImage(Dimension size, int state);

Retrieves a system image with the specified Dimension and state.

Return Value:

Returns the Image object that corresponds to the specified state.

ParameterDescription
size The size of the image.
state The image is associated with a specific state. This may be one of the following states.
HOT PRESSED CHECKED INDETERMINATE ENABLED

getImage

public Image getImage(Dimension size, IUIComponent comp);

Retrieves a system image from a component, with the specified Dimension. The image retrieved depends on the foreground, background, and state of the component.

Return Value:

Returns the requested system image.

ParameterDescription
size The image size.
comp The component to obtain the image from.

getImage

public Image getImage(Dimension size, int state, Color backColor,
        Color foreColor);

Retrieves a system image with the specified Dimension, state, and user-specified colors.

Return Value:

Returns the Image object that corresponds to the specified state.

ParameterDescription
size The size of the image.
state The image is associated with a specific state. This may be one of the following states.
HOT PRESSED CHECKED INDETERMINATE ENABLED
backColor The specified background color of the image.
foreColor The specified foreground color of the image.

getStateID

public int getStateID(int state);

Retrieves the state's array index for the specified state. This method is used by the getImage method.

Return Value:

Returns either the HOT or ENABLED state identifier, or a combination of the two. This method is used specifically for these two states, and other states are masked in the return value.

ParameterDescription
state The state to retrieve the array index for.

getWidgetFont

public Font getWidgetFont(int c);

Retrieves the font the FxComponentImage image set uses, if available, to cleanly draw scalable images. If the font is not available, the method calls back to the class (by default, there is no widget font except for the system defined images, which use the Marlett font).

Return Value:

Returns the font that the image set uses.

ParameterDescription
c The size of the requested font.

setFactory

public static void setFactory(int idx, FxComponentImage factory);

Sets an FxComponentImage factory for the specified component image.

Return Value:

No return value.

ParameterDescription
idx The component image or images to set the factory for. This can be any one of the following images.
RADIO_BUTTON CHECK_BOX EXPAND_BOX
LEFT_ARROW RIGHT_ARROW UP_ARROW DOWN_ARROW
factory The FxComponentImage class factory to associate with the component image.

Exceptions:

ArrayIndexOutOfBoundsException if the index of the component image idx is not valid.

Fields

CHECK_BOX
A check box image.
DOWN_ARROW
A down-arrow glyph used in a scroll bar or combo box drop-down button.
EXPAND_BOX
An expanding box image.
LEFT_ARROW
A left-arrow glyph used in horizontal scroll bars.
RADIO_BUTTON
A radio button image.
RIGHT_ARROW
A right-arrow glyph used in horizontal scroll bars.
UP_ARROW
An up-arrow glyph used in a scroll bar or combo box drop-down button.

upnrm.gif © 1998 Microsoft Corporation. All rights reserved. Terms of use.