Difference between revisions of "Reference: MSEgui/TWidget"

From Free Pascal wiki
Jump to navigationJump to search
Line 177: Line 177:
  
 
[[Image:msegui_widget_hint2.png]]
 
[[Image:msegui_widget_hint2.png]]
 +
 +
====OnEnter, OnFocus, OnActivate====
 +
 +
We have three pairs of events regarding the change of a focus:
 +
 +
<syntaxhighlight>
 +
property OnEnter: notifyeventty;
 +
property OnExit: notifyeventty;
 +
 +
property OnFocus: notifyeventty;
 +
property OnDefocus: notifyeventty;
 +
 +
property OnActivate: notifyeventty;
 +
property OnDeactivate: notifyeventty;
 +
</syntaxhighlight>
 +
 +
For an example we have two forms with both have two edits.
  
 
==known issues==
 
==known issues==

Revision as of 07:51, 15 January 2016

TWiget

work in progress

Ancestor for visual components.

Reference

Hierarchy

  • TObject
  • TPersistent
  • TComponent
  • TMseComponent
  • TActComponent
  • TWidget

Properties

Anchors

Anchors combines the traditional Anchors and the traditions Align properties.

msegui anchors.png

property anchors: anchorsty read fanchors write setanchors default defaultanchors;

By default your anchors are an_left and an_top. Then your widget stays at the same position when sizing the form. When your widget should have a constant distance to the right border of its parent, you add an_right and remove an_left (in this order...). The same you can do with an_bottom and an_top.

If you have only one anchor, and the widget is suitable for this sizing, the widget is using the full size of the not anchored dimension. The behaviour is near the traditional property Align, but the widget is not aligned directly to the border, but you can free position it.

msegui an top.png

By having no anchors set, the widget fills the client size of its parent (the traditional alClient).

By setting an_left and an_top, the widget change its horizontal size by sizing its parent, the same with the vertical size by setting an_top and an_bottom together.

Bounds

The size and the position of the widget is condensed in the property bounds, but you have also the traditional properties like left an width.

msegui bounds.png

// the types
sizety = record
  cx, cy: integer;
end;

pointty = record
  x,y: integer;
end;

rectty = record
case integer of
  0: (x, y, cx, cy: integer);
  1: (pos: pointty; size: sizety);
end;


// the properties
property Widgetrect: rectty read FWidgetrect write SetWidgetrect;
property Pos: pointty read FWidgetrect.pos write SetPos;
property Size: sizety read FWidgetrect.size write SetSize;

property Bounds_x: integer read FWidgetrect.x write SetBounds_x;
property Bounds_y: integer read FWidgetrect.y write SetBounds_y;
property Bounds_cx: integer read FWidgetrect.cx write SetBounds_cx
               {default defaultwidgetwidth} stored true;
property Bounds_cy: integer read FWidgetrect.cy write SetBounds_cy
               {default defaultwidgetheight} stored true;
property Bounds_cxmin: integer read FMinSize.cx
                                   write SetBounds_cxmin default 0;
property Bounds_cymin: integer read FMinSize.cy
                                   write SetBounds_cymin default 0;
property Bounds_cxmax: integer read FMaxSize.cx
                                   write SetBounds_cxmax default 0;
property Bounds_cymax: integer read FMaxSize.cy
                                   write SetBounds_cymax default 0;

property Left: integer read FWidgetrect.x write SetBounds_x;
property Right: integer read GetRight write SetRight;
             //widgetrect.x + widgetrect.cx, sets cx if an_left is set
property Top: integer read FWidgetrect.y write SetBounds_y;
property Bottom: integer read GetBottom write SetBottom;
             //widgetrect.y + widgetrect.cy, sets cy if an_top is set
property Width: integer read FWidgetrect.cx write SetBounds_cx;
property Height: integer read FWidgetrect.cy write SetBounds_cy;

property MinSize: sizety read FMinSize write SetMinSize;
function WidgetMinSize: sizety;
        //calls checkwidgetsize and frame.checkwidgetsize
property MaxSize: sizety read FMaxSize write SetMaxSize;

Color

property Color: colorty default defaultwidgetcolor;

Specifies the color of the widget. With Face and Frame other colors for the whole or a part of the widget can set.

Cursor

property Cursor: cursorshapety default cr_default;

Specifies the look of the mouse cursor if it is over the widget.

Enabled

property Enabled: boolean default true;

Sets the widget enabled or not. Some Widgets change their look if they are not enabled, others do not (UPDATE: Meanwhile TSlider change it's look when setting enabled).

msegui enabled.png

Face

See TFace


Font

See TFont

Frame

See TFrame

Hint

A hint is a small text displayed when the mouse cursor is over the widget. With the text editor of the object inspector you can add additional lines (SHIFT+ENTER), you can also use [r[n:

Label1.Hint := 'This is a simple hin text[r[nof a simple label[r[nwith more than on line.'

msegui widget hint.png

See also OnHint

Visible

property Visible: boolean default true;

Sets the widget visible or hides it.

Methods

Events

OnHint

showhinteventty = procedure(const Sender: TObject; var Info: hintinfoty) of object;

The event OnHint is triggered, when a hint is displayed for the widget. With the var-parameter Info you can specify details of the displayed hint.

procedure tmainfo.FormShowHint(const Sender: TObject; var Info: hintinfoty);
begin
  Info.Caption := 'Trololo';
  Info.PosRect.X := Info.PosRect.X + 60;
  Info.PosRect.y := Info.PosRect.y - 20;
end;

msegui widget hint2.png

OnEnter, OnFocus, OnActivate

We have three pairs of events regarding the change of a focus:

property OnEnter: notifyeventty;
property OnExit: notifyeventty;

property OnFocus: notifyeventty;
property OnDefocus: notifyeventty;

property OnActivate: notifyeventty;
property OnDeactivate: notifyeventty;

For an example we have two forms with both have two edits.

known issues

issues of the class

issues of this documentation

Feel free to add your points here.