GLnB: Group, Label & Button
Properties (Details):
Types are mentioned, if not yet obvious by the property's name.
Aside from the properties listed below GLnB owns all the properties of TLabel. The ancestor is TGraphicControl.
(#: Modified properties of TLabel.)
public
- # Alignment
v. Autosize- AlignmentVertical (avTop, avCenter, avBottom)
Vertical text justification within the area of FrameText. Only effective with single line output. V. AutoSize.- # AutoSize
An autosized TLabel causes a 'SetBounds', i.e. an accomodation of the component's size to the size needed for text output.
TGLnB doesn't change the component's size, but solely the size of the text region within the component (FrameText). Regions which do not fit within the component will therefore not be shown. On the other hand, even with AutoSize:=True the component may be larger than its text output.
Alignment and AlignmentVertical in the same sense refer to the area of FrameText instead of Canvas.
For further details v. FixMargin.- BorderStyle
The option of an outer frame as known from TWinControls.- Ctl3D
The option of a 3D effect around the component as known from TWinControls.- FrameBack/Text/Top...: TFrameShape
Three framed layers within the component. Below them first the component's background as determined by the usual TLabel properties (Color, Transparent, etc.). Then follows FrameBack, then FrameText with the text output (Caption, Font, etc.) and above all FrameTop.
By default all of them are transparent and have (and keep in case of resizing) a margin of 0. This is when TGLnB behaves almost like a TLabel.
Each of these layers can be individually designed, justified, even be used as a dialog element.
- ButtonState: set of (bsRounded, bsDown, bsInvertDown, bsFocused, bsEnabled, bsSwitch)
bsRounded, bsDown, bsInvertDown, bsFocused: Possible layer states if showing a button style (v. Style). BsInvertDown inverts the layer surface if bsDown is set.
Note bsFocused: This state is solely a design option! A TGraphicControl like TGLnB or TSpeedButton cannot get the keyboard focus.
bsEnabled, bsSwitch: bsEnabled activates the layer as a button, i.e. it responds automatically to mouse clicks (bsDown is switched accordingly). With bsSwitch set it works as a switch (on/off), without as a push button (on/on).- Color2D
Border color for 2D styles without bsDown.
Color of the top and left border for 3D styles. Outer color of the top and left border for fsFrame. Vice versa in the state bsDown.- Color3D
Color of the bottom and right border for 3D styles. Outer color of the bottom and right border for fsFrame. Vice versa in the state bsDown.
Border color for 2D styles with bsDown.- FixMargin: set of (fmTop, fmLeft, fmBottom, fmRight)
On the selected borders the frame keeps its distance from the component's borders as set under MarginX if the component is resized. It follows any size changes of the component.
On non-selected borders the frame keeps its position, by accomodating its margin values to the size changes of the component. As soon as at least one of two opposite borders is not fixed the frame keeps its size on this axis (e.g., fmLeft and/or fmRight cause a constant width).
Example: A frame with fmLeft and fmTop will always 'stick' with constant size to the top left corner of the component (e.g. with MarginTop/Left:=0).
The described behavior is shown at runtime as well as at design time and is therefore perfectly suitable to create recurrent, size independent layouts.
Note FrameText with AutoSize: FixMargin limits the text expansion of AutoSize on the selected borders. This allows to use AutoSize (also combined with Alignment/AlignmentVertical) even more specifically.- MarginBottom/Left/Right/Top: Integer
Distance to the respective component border. These values stay constant, if 'FixMargin' is set for the respective border. Otherwise, size changes cause automatic accomodations of these values.
The values may be negative, i.e., parts of the frame may be outside the visible canvas, which offers additional design options.- Style: (bsAutoDetect, bsNew, bsWin31, fs2D, fs2DBordered, fs3D, fs3DBordered, fsFrame)
bsAutoDetect, bsNew, bsWin31: Button styles as known from TBitBtn. Like any of the remaining styles with shapable surface (v. Surface), attributes/behavior (v. ButtonState) and frame width (v. Width).
fs2D, fs2DBordered: Single frame using Color2D, on bsDown in Color3D. As fs2DBordered with an additional black border.
fs3D, fs3DBordered: 3D frame, bottom and right border in Color3D, top and right in Color2D, vice versa an bsDown. As fs3DBordered with an additional black border.
fsFrame: 3D frame with a single outer border as described under fs3D and - depending on the frame width (s. Width) - inner frames with switched colors.
- Surface: TSurface
There are several ways to color the surface of each frame:
- Color
Color or background color (if a 1-bit pattern is selected) of the surface.- Pattern: TBitmap
A 8x8 bitmap (read from a .BMP) for patterned surfaces. A pattern with 16 colors will be painted without changes, a 1-bit pattern will be colored using Color (background) and PatternColor (foreground).- PatternColor
Foreground color of 1-bit patterns.- Style: (ssSolidOrPattern, ssTransparent, ssShadow)
ssSolidOrPattern: If Pattern contains bitmap data, it will be used as a surface pattern. Otherwise the surface will be solid using Color.
ssTransparent: No surface will be created for this frame. Only its borders will be drawn.
ssShadow: No surface will be created for this frame, but the translucent background will be shadowed.- Width
Width of the frame borders.- LinkList: TLinkList
Persistent list of linked components. It can easily be changed by IDE editors (double click the component, the property in the object inspector or select 'Links' in the component's context menu).
Although at present without runtime effects, it can be read. (TLinkList is a descendant of TStringList. Therefore linked components can be accessed via its Objects property resp. the IndexOfObject method.)
IDE behavior:
Components that are linked to a GLnB follow any of its position changes caused by mouse events. As soon as the GLnB is picked up with the mouse linked components are picked up as well. No need for group selection or similar procedures! These links are a persistent part of the form!
The described behavior is even transferred to chained GLnBs and their links!
If you drop the GLnB with the shift or ctrl key pressed, the linked components remain selected and you can add further selections via shift-clicks.
Movements by keyboard work as usual.
Purposes:
1. Creating combined components, constisting e.g. of labels and edits or buttons and bitmaps.
2. Grouping components, without the side effects of TGroup (ressources, components have to placed inside the group box and become children of TGroup).- ParentControl: TWinControl
Caution: This property requires some experience with windows concepts!
For special purposes a GLnB can be fully integrated into a TWinControl (e.g. TTabSet) by assigning it as the ParentControl. After that the GLnB will be placed within its new ParentControl.
Note: Position values (Top, Left) will not be changed! We recommend to position the GLnB already at form coordinates, which would be visible coordinates in the future ParentControl as well.- TransparentText: Boolean
By default, text is shown with transparent spaces resp. translucent background. If the background is a bitmap or bitmap pattern text might become difficult to read. With TransparentText:=False text spaces will - regardless of other settings in FrameText.Surface - be filled with FrameText.Surface.Color.
New events:
- OnBefore/AfterPaint
Immediately before and after painting the GLnB these events are aroused. This allows to link additional, code driven actions (e.g. specific outputs to the canvas) to each repainting of the component.
New methods:
- procedure DrawFrame(Var Client: TRect; Color2D,Color3D: TColor ; BevelWidth: Integer; Style: TFrameStyle; IsRounded, IsDown, IsFocused: Boolean)
Method used by GLnB to draw a frame within the component Canvas. The parameters correspond with the respective properties (TFrameShape).- procedure DrawSurface(Const Frame: TFrameShape; Var Client: TRect)
Method used by GLnB to draw surfaces. The parameters correspond with the respective component properties.- function FrameShapeRect(Const Frame:TFrameShape):TRect
Method to get the coordinates of a given frame (FrameBack, FrameText, FrameTop). With this function you can - e.g. in your own mouse event handlers - find out which frame was clicked.Editors:
- TLinkListEditor
- TLinkListComponentEditor