Reference: MSEgui/TFace

From Free Pascal wiki
Jump to navigationJump to search

TFace

work in progress

The visual appearance of a widget is specified by the properties Face and Frame. Face concerns the widget itself, Frame the appearance around it.

Reference

Hierarchy

  • TObject
  • TPersistent
  • TVirtualPersistent
  • TNullInterfacesPersistent
  • TOptionalPersistent
  • TCustomFace
  • TFace


Properties

Fade

You can specify a color fade with two or more colors. (You can specify with one color too, but that's no fade...)

The picture was generated with the following code. Please not, that green is not exactly in the middle, but moved to the left - the position isn't 0.5, it's 0.3.


msegui face fade.png

procedure tmainfo.Button3Execute(const sender: TObject);
begin 
  if Button3.Face = nil then
    Button3.Face := TFace.Create;
  Button3.Face.Fade_color.Count := 3;
  Button3.Face.Fade_color.Items[0] := cl_red;
  Button3.Face.Fade_color.Items[1] := cl_green;
  Button3.Face.Fade_color.Items[2] := cl_blue;
  Button3.Face.Fade_pos.Count := 3;
  Button3.Face.Fade_pos.Items[0] := 0;
  Button3.Face.Fade_pos.Items[1] := 0.3;
  Button3.Face.Fade_pos.Items[2] := 1;
end;

With the Fade_direction you specify the direction:

msegui face fade direction.png

property fade_direction: graphicdirectionty default gd_right;

You can also specify a opacity and a fade of it. In the following the left picture is without opacity, the middle is with a opacity fade from cl_white to cl_black from 0.7 to 1, and the right picture is a opacity fade from cl_white to cl_black from 0 to 1 and a underlying picture and options = [fao_fadeoverlay].

msegui frame fade opacity.png

With the property Fade_opacity you can specify a opacity for the whole face without any fade. Typical opacity colors are cl_black and cl_white, but you can use every other color.

property Fade_opacity: colorty default cl_none;
property Fade_opapos: trealarrayprop;
property fade_opacolor: tfadeopacolorarrayprop;

FrameImage

With the property FrameImage you can paint individual frames by using a TImageList. In the imalge list their are used 8 consecutive images. The images for the edges will be stretched as needed - this will look very strange, if this images are not suitable (look the followong picture).

msegui face frameimage.png

For a "good loking example" see TFrame.FrameImage.

property FrameImage_list: timagelist;
    // imagenr 0 = topleft, 1 = left, 2 = bottomleft, 3 = bottom,
    // 4 = bottomright 5 = right, 6 = topright, 7 = top
property FrameImage_offset: integer default 0;

Framei

You can specify spacings to the borders of the widget:

msequi face framei.png

procedure tmainfo.Button3Execute(const sender: TObject);
begin 
  if Button3.Face = nil then
    Button3.Face := TFace.Create;
  Button3.Face.Fade_color.Count := 1;
  Button3.Face.Fade_color.Items[0] := cl_blue;
  Button3.Face.Framei_left := 4;
  Button3.Face.Framei_bottom := 6;
  Button3.Face.Framei_right := 8;
  Button3.Face.Framei_top := 10;
end;

Image

Need input: When assigning the Picture in the ObjectInspector, masking works, if using Face.Image.Source, mask will be ignored. When trying assigning Picture via source code, I get a Graphic format error.

msegui face image 2.png

procedure tmainfo.Button3Execute(const sender: TObject);
begin
  Button3.Face.Image.Source := BitmapComp1;
  Button3.Face.Image.Alignment := [al_fit];
  Button3.Face.Image.X := 33;
  Button3.Face.Image.y := 11;
  Button3.Color := cl_red;
  Button3.Face.Image.Opacity := cl_dkgray;
  
  Button4.Face.Image.Source := BitmapComp2;
  Button4.Face.Image.Alignment := [al_fit];
  
  Button5.Face.Image.Source := BitmapComp1;
  Button5.Face.Image.Alignment := [al_fit];
  Button5.Face.Image.Mask_Source := BitmapComp2;

  Button6.Face.Image.LoadFromFile('I:\Images\FuBK.jpg');   // Leads to Graphic format error
  Button6.Face.Image.Alignment := [al_fit];
  Button6.Face.Image.Mask_Source := BitmapComp2;
end;

Template and LocalProps

You can assign Template to a TFaceComp-instance to take the face settings of this non-visual component.

If a special property of TFace should not specified by Template but the local TFace-settings, use LocalProps to except this property of template settings for this widget.

facelocalpropty = (fal_options,fal_framei_left,fal_framei_top,
                    fal_framei_right,fal_framei_bottom,
                    fal_fadirection,fal_image,
                    fal_fapos,fal_facolor,fal_faopapos,fal_faopacolor,
                    fal_fatransparency,
                    fal_faopacity,fal_frameimagelist,fal_frameimageoffset);
facelocalpropsty = set of facelocalpropty;

property LocalProps: facelocalpropsty; 
property Template: TFaceComp;

Options

msegui face options.png

faceoptionty = (fao_alphafadeimage,fao_alphafadenochildren,fao_alphafadeall,
                 fao_alphaimage,
                 fao_fadeoverlay,fao_overlay);
faceoptionsty = set of faceoptionty;

property options: faceoptionsty default [];

Methods

Events

known issues

issues of the class

issues of this documentation

Feel free to add your points here.