home *** CD-ROM | disk | FTP | other *** search
/ Chip 2001 December / Chip_2001-12_cd1.bin / zkuste / delphi / kolekce / d345 / JWTOOL.ZIP / jwtool / Jwlabel.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  2001-09-29  |  23.9 KB  |  756 lines

  1. unit Jwlabel;
  2.  
  3. {
  4.         **   VERSION History   **
  5.    Version     Date     Notes
  6.     v1.00  - 01APR99    Original Release
  7. }
  8.  
  9.  
  10. //  Created By:
  11. //    Joseph Wilcock
  12. //    Coockoo@hotmail.com
  13. //    http://msnhomepages.talkcity.com/RedmondAve/coockoo/
  14.  
  15. interface
  16.  
  17. uses {$IFDEF WIN32} Windows, {$ELSE} WinProcs, WinTypes, {$ENDIF}
  18.      Stdctrls, Controls, Classes, SysUtils, Messages, Graphics, Menus;
  19.  
  20. type
  21.   {     Introduction:
  22.         The purpose of this component is to illustrate the methods used
  23.   in creating a component.  To do this, this component will give a label
  24.   full control over the various aspects of the FONT that is used to draw
  25.   itself.  In addition, we will explore some other possible uses and
  26.   expansions of the original "TLabel" idea.  The main features of this Label
  27.   are full rotation, a "border" will full styles and offsets, and the
  28.   possiblility of really cool looking DYNAMIC fonts!
  29.         Remember, only YOU can make me famous! - JW}
  30.  
  31.  
  32.   {     Okay, we are about to select a new name for our component AND some of the enumerated
  33.   types.  So how do we name it?  USE A PREFIX OR A POSTFIX!!!!  Sometime you will run into
  34.   another perfectly valid object that has nothing to do with what you are doing, but will
  35.   have a similar name.  But if you give it a prefix (like JW for Joseph Wilcock, or Exp for
  36.   Example) you should avoid the obvious ones. }
  37.  
  38.  
  39.   {     Whenever you make a class you SHOULD always make a custom exception so that you can
  40.   handle errors with. }
  41.   EExpLabelError = Class( Exception );
  42.  
  43.   {     Why enumerated types?  All of these values have actual constants defined (I think
  44.   in "WinTypes") but when you are dealing with the Object Inspector, do you want to have to
  45.   remember them all?  This way, the code will reassign the enumerated type easily. }
  46.   TExpFontWeight = ( fwDontCare, fwThin, fwExtraLight, fwUltraLight, fwLight, fwNormal,
  47.               fwRegular, fwMedium, fwSemiBold, fwDemiBold, fwBold, fwExtraBold,
  48.               fwUltraBold, fwBlack, fwHeavy );
  49.   TExpCharSet = ( csAnsiCharSet, csDefaultCharSet, csSymbolCharSet,
  50.               csShiftJisCharSet, csOemCharSet );
  51.   TExpOutputPrecision = ( opOutCharacterPrecis, opOutDefaultPrecis, opOutDevicePrecis,
  52.               opOutRasterPrecis, opOutStringPrecis, opOutStrokePrecis, opOutTTPrecis );
  53.   TExpClipPrecision = ( cpClipCharacterPrecis, cpClipDefaultPrecis, cpClipEncapsulate,
  54.               cpClipLHAngles, cpClipMask, cpClipStrokePrecis, cpClipTTAlways );
  55.   TExpFontQuality = ( fqDefaultQuality, fqDraftQuality, fqProofQuality );
  56.   TExpFontPitch = ( fpDefaultPitch, fpFixedPitch, fpVariablePitch );
  57.   TExpFontFamily = ( ffDecorative, ffDontCare, ffModern, ffRoman, ffScript, ffSwiss );
  58.  
  59.   TJwExpLabel = Class( TLabel )
  60.     private
  61.       {  We've already inherited all the other stuff, but we can only touch the
  62.       protected and public values.  This will be our declairations. }
  63.       FOverFontColor: TColor;
  64.       FFontHeight: Integer;
  65.       FFontWidth: Integer;
  66.       FEscapement: Integer;
  67.       FOrientation: Integer;
  68.       FFontWeight: TExpFontWeight;
  69.       FItalic: Integer;
  70.       FUnderline: Integer;
  71.       FStrikeOut: Integer;
  72.       FCharSet: TExpCharSet;
  73.       FOutputPrecision: TExpOutputPrecision;
  74.       FClipPrecision: TExpClipPrecision;
  75.       FFontQuality: TExpFontQuality;
  76.       FFontPitch: TExpFontPitch;
  77.       FFontFamily: TExpFontFamily;
  78.       FFacename: array[0..255] of char;
  79.  
  80.       {For a nice change of pace, I thought I might want a border for my label
  81.       and throw in a few extra options as well.}
  82.       FBorder: Boolean;
  83.       FBorderStyle: TPenStyle;
  84.       FBorderWidth: Integer;
  85.       FBorderColor: TColor;
  86.  
  87.       {Yes I know there's a better way of doing this, but I'd rather not worry about
  88.       the "perfect" algorythm to autosize a rotated font.  Maybe someday... but for
  89.       now, this is the best I'M goint to do... unless someone else wants to do it
  90.       for me?}
  91.       FLeftOffset: LongInt;
  92.       FTopOffset: LongInt;
  93.       FRightOffset: LongInt;
  94.       FBottomOffset: LongInt;
  95.  
  96.       {NOTE ON NAMING:  True story!  For some reason I had made the name of a
  97.       private member the same as the published property!  AND whenever it was
  98.       updated, invalidate was called, and got caught into a total loop.  Moral:
  99.       BE CAREFULL WITH THOSE NAMES!}
  100.       PvFontWeight: Integer;
  101.       PvFontCharSet: Word;
  102.       PvFontOutPrecision: Word;
  103.       PvFontClipPrecision: Word;
  104.       PvFontQuality: Word;
  105.       PvFontPitchAndFamily: Word;
  106.  
  107.       Procedure SetOverFontColor( Value: TColor );
  108.       Procedure SetFontFaceName( Value: String );
  109.       Function GetFontFaceName: String;
  110.       Procedure SetFontFamily( Value: TExpFontFamily );
  111.       Procedure SetFontPitch( Value: TExpFontPitch );
  112.       Procedure SetFontQuality( Value: TExpFontQuality );
  113.       Procedure SetClipPrecision( Value: TExpClipPrecision );
  114.       Procedure SetOutputPrecision( Value: TExpOutputPrecision );
  115.       Procedure SetCharSet( Value: TExpCharSet );
  116.       Procedure SetFontStrikeout( Value: Integer );
  117.       Procedure SetFontUnderline( Value: Integer );
  118.       Procedure SetFontItalic( Value: Integer );
  119.       Procedure SetFontWeight( Value: TExpFontWeight );
  120.       Procedure SetFontOrientation( Value: Integer );
  121.       Procedure SetFontEscapement( Value: Integer );
  122.       Procedure SetFontWidth( Value: Integer );
  123.       Procedure SetFontHeight( Value: Integer );
  124.       Procedure SetBorder( Value: Boolean );
  125.       Procedure SetBorderStyle( Value: TPenStyle );
  126.       Procedure SetBorderWidth( Value: Integer );
  127.       Procedure SetBorderColor( Value: TColor );
  128.       Procedure SetLeftOffset( Value: LongInt );
  129.       Procedure SetTopOffset( Value: LongInt );
  130.       Procedure SetRightOffset( Value: LongInt );
  131.       Procedure SetBottomOffset( Value: LongInt );
  132.  
  133.     protected
  134.       procedure WMSize(var Message: TWMSize); message WM_SIZE;
  135.       procedure Paint; override;
  136.       {Alright! I lifted this from the VCL, but I did change a lot AND I didn't want
  137.       to conflict with the old one by using the same name!}
  138.       procedure ExpDoDrawText(var Rect: TRect; Flags: Word);
  139.  
  140.     public
  141.       constructor Create( AOwner : TComponent ); override;
  142.  
  143.     published
  144.       {  Now, we want to make accessable some of the previously declaired properties.
  145.       If we don't do it here, not all of them will translate!}
  146.       Property Anchors;
  147.       Property Align;
  148.       Property Alignment;
  149.       Property AutoSize;
  150.       Property Caption;
  151.       Property Color;
  152.       Property Cursor;
  153.       Property DragCursor;
  154.       Property DragMode;
  155.       Property Enabled;
  156.       Property FocusControl;
  157.       {Property Font; NO!  We *DON'T* want to have this one available!
  158.       ...for some reason, it's still there!  Don't know how to remove it...}
  159.       Property Height;
  160.       Property Hint;
  161.       Property Left;
  162.       Property Name;
  163.       Property ParentColor;
  164.       {Property ParentFont; This one either!}
  165.       Property ParentShowHint;
  166.       Property PopupMenu;
  167.       Property ShowAccelChar;
  168.       Property ShowHint;
  169.       Property Tag;
  170.       Property Top;
  171.       Property Transparent;
  172.       Property Visible;
  173.       Property Width;
  174.       Property WordWrap;
  175.       {Now the inherited EVENTS!}
  176.       Property OnClick;
  177.       Property OnDblClick;
  178.       Property OnDragDrop;
  179.       Property OnDragOver;
  180.       Property OnEndDrag;
  181.       Property OnMouseDown;
  182.       Property OnMouseMove;
  183.       Property OnMouseUp;
  184.  
  185.       {Down here, we'll add our *NEW* properties.  The reason we supply a default
  186.     is that if the value is equal to the default when the form is saved, it doesn't
  187.     store anything.  But if it doesn't, it stores the value, so try to always have
  188.     a default, but REMEMBER to address this in the constructor.}
  189.       Property OverFontColor: TColor
  190.                Read FOverFontColor
  191.                Write SetOverFontColor
  192.                Default clBlack;
  193.  
  194.       Property FontHeight: Integer
  195.                Read FFontHeight
  196.                Write SetFontHeight
  197.                Default 15;
  198.  
  199.       Property FontWidth: Integer
  200.                Read FFontWidth
  201.                Write SetFontWidth
  202.                Default 0;
  203.  
  204.       Property FontEscapement: Integer
  205.                Read FEscapement
  206.                Write SetFontEscapement
  207.                Default 0;
  208.  
  209.       Property FontOrientation: Integer
  210.                Read FOrientation
  211.                Write SetFontOrientation
  212.                Default 0;
  213.  
  214.       Property FontWeight: TExpFontWeight
  215.                Read FFontWeight
  216.                Write SetFontWeight
  217.                Default fwRegular;
  218.  
  219.       Property FontItalic: Integer
  220.                Read FItalic
  221.                Write SetFontItalic
  222.                Default 0;
  223.  
  224.       Property FontUnderline: Integer
  225.                Read FUnderline
  226.                Write SetFontUnderline
  227.                Default 0;
  228.  
  229.       Property FontStrikeout: Integer
  230.                Read FStrikeOut
  231.                Write SetFontStrikeout
  232.                Default 0;
  233.  
  234.       Property CharacterSet: TExpCharSet
  235.                Read FCharSet
  236.                Write SetCharSet
  237.                Default csDefaultCharSet;
  238.  
  239.       Property OutputPrecision: TExpOutputPrecision
  240.                Read FOutputPrecision
  241.                Write SetOutputPrecision
  242.                Default opOutDefaultPrecis;
  243.  
  244.       Property ClipPrecision: TExpClipPrecision
  245.                Read FClipPrecision
  246.                Write SetClipPrecision
  247.                Default cpClipDefaultPrecis;
  248.  
  249.       Property FontQuality: TExpFontQuality
  250.                Read FFontQuality
  251.                Write SetFontQuality
  252.                Default fqDefaultQuality;
  253.  
  254.       Property FontPitch: TExpFontPitch
  255.                Read FFontPitch
  256.                Write SetFontPitch
  257.                Default fpDefaultPitch;
  258.  
  259.       Property FontFamily: TExpFontFamily
  260.                Read FFontFamily
  261.                Write SetFontFamily
  262.                Default ffRoman;
  263.  
  264.       Property FontFaceName: String
  265.                Read GetFontFaceName
  266.                Write SetFontFaceName;
  267.  
  268.       Property Border: Boolean
  269.                Read FBorder
  270.                Write SetBorder
  271.                default False;
  272.  
  273.       Property BorderStyle: TPenStyle
  274.                Read FBorderStyle
  275.                Write SetBorderStyle
  276.                default psSolid;
  277.  
  278.       Property BorderWidth: Integer
  279.                Read FBorderWidth
  280.                Write SetBorderWidth
  281.                default 1;
  282.  
  283.       Property BorderColor: TColor
  284.                Read FBorderColor
  285.                Write SetBorderColor
  286.                default clBlack;
  287.  
  288.       Property OffsetLeft: LongInt
  289.                Read FLeftOffset
  290.                Write SetLeftOffset
  291.                Default 0;
  292.  
  293.       Property OffsetTop: LongInt
  294.                Read FTopOffset
  295.                Write SetTopOffset
  296.                Default 0;
  297.  
  298.       Property OffsetRight: LongInt
  299.                Read FRightOffset
  300.                Write SetRightOffset
  301.                Default 0;
  302.  
  303.       Property OffsetBottom: LongInt
  304.                Read FBottomOffset
  305.                Write SetBottomOffset
  306.                Default 0;
  307.  
  308.     end;
  309.  
  310. procedure Register;
  311.  
  312. implementation
  313.  
  314. constructor TJwExpLabel.Create( AOwner : TComponent );
  315. begin
  316.   Inherited Create( AOwner );
  317.   ParentFont := False;
  318.   FFontHeight := 15;
  319.   FFontWidth := 0;
  320.   Font.Size := FFontWidth;
  321.   Font.Height := FFontHeight;
  322.   FEscapement := 0;
  323.   FOrientation := 0;
  324.   FFontWeight := fwRegular;
  325.   FItalic := 0;
  326.   FUnderline := 0;
  327.   FStrikeOut := 0;
  328.   FCharSet := csDefaultCharSet;
  329.   FOutputPrecision := opOutDefaultPrecis;
  330.   FClipPrecision := cpClipDefaultPrecis;
  331.   FFontQuality := fqDefaultQuality;
  332.   FFontPitch := fpDefaultPitch;
  333.   FFontFamily := ffRoman;
  334.   FOverFontColor := clBlack;
  335.   StrCopy( FFacename, 'Arial' );
  336.   FBorder := False;
  337.   FBorderStyle := psSolid;
  338.   FBorderWidth := 1;
  339.   FBorderColor := clBlack;
  340.   FLeftOffset := 0;
  341.   FTopOffset := 0;
  342.   FRightOffset := 0;
  343.   FBottomOffset := 0;
  344.   AutoSize := False;
  345.   Width := 120;
  346.   Height := 17;
  347. end;
  348.  
  349. {    Okay, so how did I know to do all of this stuff?  Well, I cheated.  I REALLY want to have
  350. control over what happens when this component is painted, so rather than trust what it does, I
  351. will override it... and rather than have to rewrite everything, I copied it right from the VCL
  352. code....}
  353.  
  354. procedure TJwExpLabel.WMSize(var Message: TWMSize);
  355. var
  356.      W, H: Integer;
  357. begin
  358.      inherited;
  359.  
  360.      { Copy the new width and height of the component
  361.        so we can use SetBounds to change both at once }
  362.      W := Width;
  363.      H := Height;
  364.  
  365.      { Code to check and adjust W and H }
  366.  
  367.      { Update the component size if we adjusted W or H }
  368.      if (W <> Width) or (H <> Height) then
  369.         inherited SetBounds(Left, Top, W, H);
  370.  
  371.      Message.Result := 0;
  372. end;
  373.  
  374. procedure TJwExpLabel.Paint;
  375. const
  376.   Alignments: array[TAlignment] of Word = (DT_LEFT, DT_RIGHT, DT_CENTER);
  377. var
  378.   Rect: TRect;
  379. begin
  380.   with Canvas do
  381.   begin
  382.     Rect := ClientRect;
  383.     Rect.Left := Rect.Left + FLeftOffset;
  384.     Rect.Top := Rect.Top + FTopOffset;
  385.     Rect.Right := Rect.Right - FRightOffset;
  386.     Rect.Bottom := Rect.Bottom - FBottomOffset;
  387.     if not Transparent then
  388.     begin
  389.       Brush.Color := Self.Color;
  390.       Brush.Style := bsSolid;
  391.       FillRect(ClientRect);
  392.     end;
  393.     Brush.Style := bsClear;
  394.     if FBorder then
  395.       begin
  396.         Pen.Style := FBorderStyle;
  397.         Pen.Width := FBorderWidth;
  398.         Pen.Color := FBorderColor;
  399.         Rectangle( Rect.Left, Rect.Top, Rect.Right, Rect.Bottom );
  400.       end;
  401.     ExpDoDrawText(Rect, (DT_EXPANDTABS or DT_WORDBREAK) or
  402.       Alignments[Alignment]);
  403.   end;
  404. end;
  405.  
  406. procedure TJwExpLabel.ExpDoDrawText(var Rect: TRect; Flags: Word);
  407. var
  408.   Text: array[0..255] of Char;
  409.  
  410. begin
  411.   GetTextBuf(Text, SizeOf(Text));
  412.   if (Flags and DT_CALCRECT <> 0) and ((Text[0] = #0) or ShowAccelChar and
  413.     (Text[0] = '&') and (Text[1] = #0)) then StrCopy(Text, ' ');
  414.   if not ShowAccelChar then Flags := Flags or DT_NOPREFIX;
  415.   if FEscapement > 0 then
  416.     Flags := DT_NOCLIP;
  417.  
  418.   {Right here is where we break ranks with the old code.  We want to change the font
  419.   to have the properties that WE set.  We'll do this in a case statement so that
  420.   changes to the API Wont ruin our code.}
  421.  
  422.   Canvas.Font.Color := FOverFontColor;
  423.   Canvas.Font.Handle := CreateFont(   FFontHeight,  {Height}
  424.                                 FFontWidth,  {Width}
  425.                                FEscapement,  {Escapement}
  426.                               FOrientation,  {Orientation}
  427.                      PvFontWeight,           {Weight}
  428.                                    FItalic,  {Italic}
  429.                                 FUnderline,  {Underline}
  430.                                 FStrikeOut,  {StrikeOut}
  431.                      PvFontCharSet,          {CharSet}
  432.                      PvFontOutPrecision,     {OutputPrecision}
  433.                      PvFontClipPrecision,    {ClipPrecision}
  434.                      PvFontQuality,          {Quality}
  435.                      PvFontPitchAndFamily,   {PitchAndFamily}
  436.                                  FFaceName );{FaceName}
  437.  
  438.  
  439.   {Canvas.Font := Font;}
  440.   if not Enabled then Canvas.Font.Color := clGrayText;
  441.   DrawText(Canvas.Handle, Text, StrLen(Text), Rect, Flags);
  442. end;
  443.  
  444. {*************************************************************************
  445.        Now we deal with our accessor functions.  These will modify our
  446.    component's properties at both design AND run time.  The main idea
  447.    is that if you change something to do with the visual part, invalidate
  448.    before you go on!  This is where we will also convert our Enumerated Types
  449.    into actual usable constants.
  450. *************************************************************************}
  451.  
  452. Procedure TJwExpLabel.SetOverFontColor( Value: TColor );
  453. begin
  454.   if FOverFontColor <> Value then
  455.     begin
  456.       FOverFontColor := Value;
  457.       InValidate;
  458.     end;
  459. end;
  460.  
  461. Procedure TJwExpLabel.SetFontFaceName( Value: String );
  462. var
  463.   OldName, TmpStr: array[0..255] of Char;
  464. begin
  465.   StrPCopy( TmpStr, Value );
  466.   if StrComp( TmpStr, FFacename ) <> 0 then
  467.     begin
  468.       StrCopy( OldName, FFaceName );
  469.       StrCopy( FFacename, TmpStr );
  470.       try
  471.         Invalidate;
  472.       except
  473.         { NOTE:  The possiblity of this happening isn't really big, but I wanted to
  474.         make a point here....}
  475.         StrCopy( FFaceName, OldName );
  476.         Raise EExpLabelError.Create( 'Invalid font name' );
  477.       end;
  478.     end;
  479. end;
  480.  
  481. Function TJwExpLabel.GetFontFaceName: String;
  482. begin
  483.   Result := StrPas( FFacename );
  484. end;
  485.  
  486. Procedure TJwExpLabel.SetFontFamily( Value: TExpFontFamily );
  487. begin
  488.   if FFontFamily <> Value then
  489.     begin
  490.       FFontFamily := Value;
  491.       { We want to clear out the old values before we add a new one. }
  492.       PvFontPitchAndFamily := PvFontPitchAndFamily AND $0F;
  493.       Case FFontFamily of
  494.         ffDecorative: PvFontPitchAndFamily := PvFontPitchAndFamily + FF_DECORATIVE;
  495.           ffDontCare: PvFontPitchAndFamily := PvFontPitchAndFamily + FF_DONTCARE;
  496.             ffModern: PvFontPitchAndFamily := PvFontPitchAndFamily + FF_MODERN;
  497.              ffRoman: PvFontPitchAndFamily := PvFontPitchAndFamily + FF_ROMAN;
  498.             ffScript: PvFontPitchAndFamily := PvFontPitchAndFamily + FF_SCRIPT;
  499.              ffSwiss: PvFontPitchAndFamily := PvFontPitchAndFamily + FF_SWISS;
  500.       end;
  501.       InValidate;
  502.     end;
  503. end;
  504.  
  505. Procedure TJwExpLabel.SetFontPitch( Value: TExpFontPitch );
  506. begin
  507.   if FFontPitch <> Value then
  508.     begin
  509.       FFontPitch := Value;
  510.       { We want to clear out the old values before we add a new one. }
  511.       PvFontPitchAndFamily := PvFontPitchAndFamily AND $F0;
  512.       case FFontPitch of
  513.          fpDefaultPitch: PvFontPitchAndFamily := PvFontPitchAndFamily + DEFAULT_PITCH;
  514.            fpFixedPitch: PvFontPitchAndFamily := PvFontPitchAndFamily + FIXED_PITCH;
  515.         fpVariablePitch: PvFontPitchAndFamily := PvFontPitchAndFamily + VARIABLE_PITCH;
  516.       end;
  517.       InValidate;
  518.     end;
  519. end;
  520.  
  521. Procedure TJwExpLabel.SetFontQuality( Value: TExpFontQuality );
  522. begin
  523.   if FFontQuality <> Value then
  524.     begin
  525.       FFontQuality := Value;
  526.       case FFontQuality of
  527.         fqDefaultQuality: PvFontQuality := DEFAULT_QUALITY;
  528.           fqDraftQuality: PvFontQuality := DRAFT_QUALITY;
  529.           fqProofQuality: PvFontQuality := PROOF_QUALITY;
  530.       end;
  531.       InValidate;
  532.     end;
  533. end;
  534.  
  535. Procedure TJwExpLabel.SetClipPrecision( Value: TExpClipPrecision );
  536. begin
  537.   if FClipPrecision <> Value then
  538.     begin
  539.       FClipPrecision := Value;
  540.       case FClipPrecision of
  541.         cpClipCharacterPrecis: PvFontClipPrecision := CLIP_CHARACTER_PRECIS;
  542.           cpClipDefaultPrecis: PvFontClipPrecision := CLIP_DEFAULT_PRECIS;
  543.             cpClipEncapsulate: PvFontClipPrecision := CLIP_EMBEDDED;
  544.                cpClipLHAngles: PvFontClipPrecision := CLIP_LH_ANGLES;
  545.                    cpClipMask: PvFontClipPrecision := CLIP_MASK;
  546.            cpClipStrokePrecis: PvFontClipPrecision := CLIP_STROKE_PRECIS;
  547.                cpClipTTAlways: PvFontClipPrecision := CLIP_TT_ALWAYS;
  548.       end;
  549.       InValidate;
  550.     end;
  551. end;
  552.  
  553. Procedure TJwExpLabel.SetOutputPrecision( Value: TExpOutputPrecision );
  554. begin
  555.   if FOutputPrecision <> Value then
  556.     begin
  557.       FOutputPrecision := Value;
  558.       case FOutputPrecision of
  559.         opOutCharacterPrecis: PvFontOutPrecision := OUT_CHARACTER_PRECIS;
  560.           opOutDefaultPrecis: PvFontOutPrecision := OUT_DEFAULT_PRECIS;
  561.            opOutDevicePrecis: PvFontOutPrecision := OUT_DEVICE_PRECIS;
  562.            opOutRasterPrecis: PvFontOutPrecision := OUT_RASTER_PRECIS;
  563.            opOutStringPrecis: PvFontOutPrecision := OUT_STRING_PRECIS;
  564.            opOutStrokePrecis: PvFontOutPrecision := OUT_STROKE_PRECIS;
  565.                opOutTTPrecis: PvFontOutPrecision := OUT_TT_PRECIS;
  566.       end;
  567.       InValidate;
  568.     end;
  569. end;
  570.  
  571. Procedure TJwExpLabel.SetCharSet( Value: TExpCharSet );
  572. begin
  573.   if FCharSet <> Value then
  574.     begin
  575.       FCharSet := Value;
  576.       case FCharSet of
  577.             csAnsiCharSet: PvFontCharSet := ANSI_CHARSET;
  578.          csDefaultCharSet: PvFontCharSet := DEFAULT_CHARSET;
  579.           csSymbolCharSet: PvFontCharSet := SYMBOL_CHARSET;
  580.         csShiftJisCharSet: PvFontCharSet := SHIFTJIS_CHARSET;
  581.              csOemCharSet: PvFontCharSet := OEM_CHARSET;
  582.       end;
  583.       InValidate;
  584.     end;
  585. end;
  586.  
  587. Procedure TJwExpLabel.SetFontStrikeout( Value: Integer );
  588. begin
  589.   if FStrikeOut <> Value then
  590.     begin
  591.       FStrikeOut := Value;
  592.       InValidate;
  593.     end;
  594. end;
  595.  
  596. Procedure TJwExpLabel.SetFontUnderline( Value: Integer );
  597. begin
  598.   if FUnderline <> Value then
  599.     begin
  600.       FUnderline := Value;
  601.       InValidate;
  602.     end;
  603. end;
  604.  
  605. Procedure TJwExpLabel.SetFontItalic( Value: Integer );
  606. begin
  607.   if FItalic <> Value then
  608.     begin
  609.       FItalic := Value;
  610.       InValidate;
  611.     end;
  612. end;
  613.  
  614. Procedure TJwExpLabel.SetFontWeight( Value: TExpFontWeight );
  615. begin
  616.   if FFontWeight <> Value then
  617.     begin
  618.       FFontWeight := Value;
  619.       Case FFontWeight of
  620.         fwDontCare: PvFontWeight := FW_DONTCARE;
  621.             fwThin: PvFontWeight := FW_THIN;
  622.       fwExtraLight: PvFontWeight := FW_EXTRALIGHT;
  623.       fwUltraLight: PvFontWeight := FW_ULTRALIGHT;
  624.            fwLight: PvFontWeight := FW_LIGHT;
  625.           fwNormal: PvFontWeight := FW_NORMAL;
  626.          fwRegular: PvFontWeight := FW_REGULAR;
  627.           fwMedium: PvFontWeight := FW_MEDIUM;
  628.         fwSemiBold: PvFontWeight := FW_SEMIBOLD;
  629.         fwDemiBold: PvFontWeight := FW_DEMIBOLD;
  630.             fwBold: PvFontWeight := FW_BOLD;
  631.        fwExtraBold: PvFontWeight := FW_EXTRABOLD;
  632.        fwUltraBold: PvFontWeight := FW_ULTRABOLD;
  633.            fwBlack: PvFontWeight := FW_BLACK;
  634.            fwHeavy: PvFontWeight := FW_HEAVY;
  635.        end;
  636.       InValidate;
  637.     end;
  638. end;
  639.  
  640. Procedure TJwExpLabel.SetFontOrientation( Value: Integer );
  641. begin
  642.   if FOrientation <> Value then
  643.     begin
  644.       FOrientation := Value;
  645.       InValidate;
  646.     end;
  647. end;
  648.  
  649. Procedure TJwExpLabel.SetFontEscapement( Value: Integer );
  650. begin
  651.   if FEscapement <> Value then
  652.     begin
  653.       FEscapement := Value;
  654.       InValidate;
  655.     end;
  656. end;
  657.  
  658. Procedure TJwExpLabel.SetFontWidth( Value: Integer );
  659. begin
  660.   if FFontWidth <> Value then
  661.     begin
  662.       FFontWidth := Value;
  663.       InValidate;
  664.     end;
  665. end;
  666.  
  667. Procedure TJwExpLabel.SetFontHeight( Value: Integer );
  668. begin
  669.   if FFontHeight <> Value then
  670.     begin
  671.       FFontHeight := Value;
  672.       InValidate;
  673.     end;
  674. end;
  675.  
  676. Procedure TJwExpLabel.SetBorder( Value: Boolean );
  677. begin
  678.   if FBorder <> Value then
  679.     begin
  680.       FBorder := Value;
  681.       InValidate;
  682.     end;
  683. end;
  684.  
  685. Procedure TJwExpLabel.SetBorderStyle( Value: TPenStyle );
  686. begin
  687.   if FBorderStyle <> Value then
  688.     begin
  689.       FBorderStyle := Value;
  690.       InValidate;
  691.     end;
  692. end;
  693.  
  694. Procedure TJwExpLabel.SetBorderWidth( Value: Integer );
  695. begin
  696.   if FBorderWidth <> Value then
  697.     begin
  698.       FBorderWidth := Value;
  699.       InValidate;
  700.     end;
  701. end;
  702.  
  703. Procedure TJwExpLabel.SetBorderColor( Value: TColor );
  704. begin
  705.   if FBorderColor <> Value then
  706.     begin
  707.       FBorderColor := Value;
  708.       InValidate;
  709.     end;
  710. end;
  711.  
  712. Procedure TJwExpLabel.SetLeftOffset( Value: LongInt );
  713. begin
  714.   if FLeftOffset <> Value then
  715.     begin
  716.       FLeftOffset := Value;
  717.       InValidate;
  718.     end;
  719. end;
  720.  
  721. Procedure TJwExpLabel.SetTopOffset( Value: LongInt );
  722. begin
  723.   if FTopOffset <> Value then
  724.     begin
  725.       FTopOffset := Value;
  726.       InValidate;
  727.     end;
  728. end;
  729.  
  730. Procedure TJwExpLabel.SetRightOffset( Value: LongInt );
  731. begin
  732.   if FRightOffset <> Value then
  733.     begin
  734.       FRightOffset := Value;
  735.       InValidate;
  736.     end;
  737. end;
  738.  
  739. Procedure TJwExpLabel.SetBottomOffset( Value: LongInt );
  740. begin
  741.   if FBottomOffset <> Value then
  742.     begin
  743.       FBottomOffset := Value;
  744.       InValidate;
  745.     end;
  746. end;
  747.  
  748. {  Don't forget the Register function!  Nothing can be done withou}
  749.  
  750. procedure Register;
  751. begin
  752.   RegisterComponents( 'JwTools', [ TJwExpLabel ] );
  753. end;
  754.  
  755. end.
  756.