TTagCloud

Fuente: source/classes/tagcloud.prg

Inherits from: TControl

TTagCloud displays a weighted tag cloud where each tag is rendered in one of seven font sizes based on its weight (frequency). Tags auto-arrange in a flowing layout, highlight on mouse hover with a customizable text and background color, and respond to click events. The control is ideal for keyword navigation, category browsing, or any scenario requiring a visually weighted list.

Key DATA Members

DATATypeDescription
aItemsArrayArray of items, each { cText, nPeso, nFontIndex, nOriginalPos }
aFontsArraySeven font handles, one per size level (largest to smallest)
nHLineNumericLine height for tag row wrapping (default 30)
nClrTextNumericDefault tag text color
nClrTextOverNumericHover highlight text color (default orange)
nClrPaneNumericDefault background color
nClrPaneOverNumericHover highlight background color
aCoorsArrayBounding rectangles per item, used for hit testing
nMaxDescendNumericMaximum font descent across all seven fonts
nOverNumericIndex of the currently hovered item, or -1 if none

Methods

MethodDescription
New( nTop, nLeft, nW, nH, oWnd, oFont )Create a new TTagCloud control
AddItem( cText, nPeso )Add a tag with text and weight value
AsignFonts()Assign font size indices to items based on sorted weights
GetFonts()Build the seven font sizes from the current base font

Example: Tag Cloud with Three Tags

#include "FiveWin.ch"

function Main()

   local oWnd, oTagCloud

   DEFINE WINDOW oWnd TITLE "Tag Cloud" SIZE 400, 300

   oTagCloud := TTagCloud():New( 10, 10, 360, 240, oWnd )

   oTagCloud:AddItem( "FiveWin", 95 )
   oTagCloud:AddItem( "Harbour", 80 )
   oTagCloud:AddItem( "xHarbour", 60 )
   oTagCloud:AsignFonts()

   ACTIVATE WINDOW oWnd CENTERED

return nil

Notes

Ver También