Purpose
Returns one attribute of a Pen, Brush, Font, or Symbol style. You can call this function from the MapBasic window in MapInfo Pro.
Syntax
StyleAttr( style, attribute )
style is a Pen, Brush, Font, or Symbol style value.
attribute is an integer code specifying which component of the style should be returned.
Return Value
string or integer, depending on the attribute parameter.
Description
The StyleAttr() function returns information about a Pen, Brush, Symbol, or Font style.
Each style type consists of several components. For example, a Brush style definition consists of three components: pattern, foreground color, and background color. When you call the StyleAttr() function, the attribute parameter controls which style attribute is returned.
The attribute parameter must be one of the codes in the table below. Codes in the left column (for example, PEN_WIDTH) are defined in MAPBASIC.DEF.
Brush settings:
attribute setting | ID | StyleAttr() returns: |
---|---|---|
BRUSH_PATTERN | 1 | Integer, indicating the Brush style's pattern. |
BRUSH_FORECOLOR | 2 | Integer, indicating the Brush style's foreground color, as an RGB value. |
BRUSH_BACKCOLOR | 3 | Integer, indicating the Brush style's background color as an RGB value, or -1 if the brush has a transparent background. |
Font settings:
attribute setting | ID | StyleAttr() returns: |
---|---|---|
FONT_NAME | 1 | String, indicating the Font name. |
FONT_STYLE | 2 | Integer value, indicating the Font style (0 = Plain, 1 = Bold, etc.); see Font clause for details. |
FONT_POINTSIZE | 3 | Integer indicating the Font size, in points.
Note: If the Text object is in a mappable table (as opposed to a Layout window), the point size is returned as zero, and the text height is dictated by the Map window's current zoom.
|
FONT_FORECOLOR | 4 | Integer value representing the RGB color of the font foreground. |
FONT_BACKCOLOR | 5 | Integer value representing the RGB color of the font background, or -1 if the font has a transparent background. If the font style includes a halo, the RGB color represents the halo color. |
Pen settings:
attribute setting | ID | StyleAttr() returns: |
---|---|---|
PEN_WIDTH | 1 | Integer, indicating the Pen style's line width, in pixels or points. |
PEN_PATTERN | 2 | Integer, indicating the Pen style's pattern. |
PEN_COLOR | 4 | Integer, indicating the Pen style's RGB color value. |
PEN_INDEX | 5 | Integer, representing the pen index number from the pen pattern. |
PEN_INTERLEAVED | 6 | Logical, TRUE if line style is interleaved. |
Symbol settings:
attribute setting | ID | StyleAttr() returns: |
---|---|---|
SYMBOL_CODE | 1 | Integer, indicating the Symbol style's shape code. Applies to TrueType symbols. |
SYMBOL_COLOR | 2 | Integer, indicating the Symbol style's color as an RGB value. |
SYMBOL_POINTSIZE | 3 | Integer from 1 to 48, indicating the Symbol's size, in points. |
SYMBOL_ANGLE | 4 | Float number, indicating the rotation angle of a TrueType symbol. |
SYMBOL_FONT_NAME | 5 | String, indicating the name of the font used by a TrueType symbol. |
SYMBOL_FONT_STYLE | 6 | Integer, indicating the style attributes of a TrueType symbol (0 = plain, 1 = Bold, etc.). See Symbol clause for a listing of possible values. |
SYMBOL_KIND | 7 | Integer, indicating the type of symbol: 2 for TrueType symbols; 3 for bitmap file symbols. |
SYMBOL_CUSTOM_NAME | 8 | String, indicating the file name used by a bitmap file symbol. |
SYMBOL_CUSTOM_STYLE | 9 | Integer, indicating the style attributes of a bitmap file symbol (0 = plain, 1 = show background, etc.). See Symbol clause for a listing of possible values. |
Error Conditions
ERR_FCN_ARG_RANGE (644) error is generated if an argument is outside of the valid range.
Example
The following example uses the CurrentPen() function to determine the pen style currently in use by MapInfo Pro, then uses the StyleAttr() function to determine the thickness of the pen, in pixels.
Include "mapbasic.def"
Dim cur_width As Integer
cur_width = StyleAttr(CurrentPen(), PEN_WIDTH)
See Also:
Brush clause, Font clause, Pen clause, Symbol clause, MakeBrush() function, MakeFont() function, MakePen() function, MakeSymbol() function