Purpose
Returns information about a style item within a legend frame. You can call this function from the MapBasic window in MapInfo Pro.
Syntax
LegendStyleInfo( window_id, frame_id, style_id, attribute )
window_id is a number that specifies which legend window you want to query.
frame_id is a number that specifies which frame within the legend window you want to query. Frames are numbered 1 to n where n is the number of frames in the legend.
style_id is a number that specifies which style within a frame you want to query. Styles are numbered 1 to n where n is the number of styles in the frame.
attribute is an integer code indicating which type of information to return.
Return Value
Attribute Code | ID | LegendStyleInfo() Return Values |
---|---|---|
LEGEND_STYLE_INFO_TEXT | 1 | Returns the text of the style. |
LEGEND_STYLE_INFO_FONT | 2 | Returns the font of the style. |
LEGEND_STYLE_INFO_OBJ | 3 |
Returns the object of the style. For legend theme type, possible values are:
|
LEGEND_STYLE_INFO_ROW_VISIBLE | 4 | Returns whether the style row is visible in the legend. For Cartographic Legend windows (prior to version 11.5), returns true. |
LEGEND_STYLE_INFO_COUNT | 5 | DT_LARGEINT. Returns the count value for this legend row. Returns -1 if count is not applicable for this legend frame or row. Also returns -1 if no count was specified for a raster legend. |
Error Conditions
Generates an error when issued on a frame that has no styles (theme frame).
Example
The following example highlights how to call the LegendStyleInfo() function to only return style information for thematic frame styles in the Legendwindow. This example assumes that the Legend window is the front-most window. It obtains style information from a Ranged Theme Frame #1, Style Sample 1.
dim objStyle as object
dim tBrush as Brush
dim tPen as Pen
dim tSymbol as Symbol
dim tFont as Font
dim strSampleText as string
objStyle = LegendStyleInfo(FrontWindow(), 1, 1, LEGEND_STYLE_INFO_OBJ)
tFont = LegendStyleInfo(FrontWindow(), 1, 1, LEGEND_STYLE_INFO_FONT)
strSampleText = LegendStyleInfo(FrontWindow(), 1, 1, LEGEND_STYLE_INFO_TEXT)
Do Case ObjectInfo(objStyle, OBJ_INFO_TYPE)
Case OBJ_TYPE_POINT
tSymbol = ObjectInfo(objStyle, OBJ_INFO_SYMBOL)
Print tSymbol
'or use StyleAttr() to return specific properties of the Symbol Style, for example: StyleAttr(tSymbol, SYMBOL_FONT_NAME)
Case OBJ_TYPE_LINE
tPen = ObjectInfo(objStyle, OBJ_INFO_PEN)
Print tPen
'or use StyleAttr() to return specific properties of the Pen\Line Style, for example: StyleAttr(tPen, PEN_COLOR)
Case OBJ_TYPE_RECT
tBrush = ObjectInfo(objStyle, OBJ_INFO_BRUSH)
Print tBrush
'or use StyleAttr() to return specific properties of the Brush\Region Style, for example: StyleAttr(tBrush, BRUSH_FORECOLOR)
Case Else
Note "Unexpected Object type"
End Case
Print tFont 'for example: Font ("Arial",0,8,0,0)
Use the StyleAttr() function to return specific properties of the Font Style, such as:
StyleAttr(tFont, FONT_NAME)
and print text of the first thematic range value (such as 5,700,000 to 23,700,000).
Print strSampleText
See Also:
StyleAttr() function