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

  1. unit Jwrtfsh;
  2.  
  3. {
  4.         **   VERSION History   **
  5.    Version     Date     Notes
  6.     v1.00  - 01APR99    Original Release
  7. }
  8.  
  9. {
  10.      Three stage buttons:
  11.            The idea is that you want one "look" in an "unfocused" state, another
  12.      when you are in a "mouseover" state, and a third when you are clicking.  This
  13.      idea is taken in the FlashClick, FlashPanel, and PopButton.
  14.  
  15.           This incarnation of the FlashClick uses the JwLabel as a model.  The idea
  16.      is that I want this to have TOTAL control over the font, just like with the
  17.      JwLabel.  Since I wanted to have each component illistrate something, I've taken
  18.      the move to create a new structure that will hold all of the information that
  19.      was in the JwLabel seperatly.
  20.  
  21. }
  22.  
  23. //  Created By:
  24. //    Joseph Wilcock
  25. //    Coockoo@hotmail.com
  26. //    http://msnhomepages.talkcity.com/RedmondAve/coockoo/
  27.  
  28.  
  29. interface
  30.  
  31. uses {$IFDEF WIN32} Windows, {$ELSE} WinProcs, WinTypes, {$ENDIF} Messages,
  32.      SysUtils, Classes, Controls, Forms, Graphics, Stdctrls, JwLabel, JwFshCl;
  33.  
  34. type
  35.   {  what?  where did this record come from?  Well, if you look at the JwLabel
  36.   everything is jumbled together.  But here we want to place it all into a big
  37.   record. }
  38.   EApiFontError = Class( Exception );
  39.  
  40.   TApiFontRec = Class( TGraphicsObject )
  41.     private
  42.       FOverFontColor: TColor;
  43.       FFontHeight: Integer;
  44.       FFontWidth: Integer;
  45.       FEscapement: Integer;
  46.       FOrientation: Integer;
  47.       FFontWeight: TExpFontWeight;
  48.       FItalic: Integer;
  49.       FUnderline: Integer;
  50.       FStrikeOut: Integer;
  51.       FCharSet: TExpCharSet;
  52.       FOutputPrecision: TExpOutputPrecision;
  53.       FClipPrecision: TExpClipPrecision;
  54.       FFontQuality: TExpFontQuality;
  55.       FFontPitch: TExpFontPitch;
  56.       FFontFamily: TExpFontFamily;
  57.       FFacename: array[0..255] of char;
  58.  
  59.       {FChanged: TNotifyEvent;}
  60.  
  61.       {NOTE ON NAMING:  True story!  For some reason I had made the name of a
  62.       private member the same as the published property!  AND whenever it was
  63.       updated, invalidate was called, and got caught into a total loop.  Moral:
  64.       BE CAREFULL WITH THOSE NAMES!}
  65.       FApiFontWeight: Integer;
  66.       FApiFontCharSet: Word;
  67.       FApiFontOutPrecision: Word;
  68.       FApiFontClipPrecision: Word;
  69.       FApiFontQuality: Word;
  70.       FApiFontPitchAndFamily: Word;
  71.       Procedure SetFaceName( Value: String );
  72.       Function GetFaceName: String;
  73.       Procedure SetFontWeight( Value: TExpFontWeight );
  74.       Procedure SetCharSet( Value: TExpCharSet );
  75.       Procedure SetOutputPrecision( Value: TExpOutputPrecision );
  76.       Procedure SetClipPrecision( Value: TExpClipPrecision );
  77.       Procedure SetFontQuality( Value: TExpFontQuality );
  78.       Procedure SetFontPitch( Value: TExpFontPitch );
  79.       Procedure SetFontFamily( Value: TExpFontFamily );
  80.  
  81.       Procedure SetOverFontColor( Value: TColor );
  82.       Procedure SetFontHeight( Value: Integer );
  83.       Procedure SetFontWidth( Value: Integer );
  84.       Procedure SetEscapement( Value: Integer );
  85.       Procedure SetOrientation( Value: Integer );
  86.       Procedure SetItalic( Value: Integer );
  87.       Procedure SetUnderline( Value: Integer );
  88.       Procedure SetStrikeOut( Value: Integer );
  89.     public
  90.       Constructor Create;
  91.  
  92.       Procedure Assign( ObjRef: TApiFontRec );
  93.  
  94.       Property ApiFontWeight: Integer Read FApiFontWeight;
  95.       Property ApiFontCharSet: Word Read FApiFontCharSet;
  96.       Property ApiFontOutPrecision: Word Read FApiFontOutPrecision;
  97.       Property ApiFontClipPrecision: Word Read FApiFontClipPrecision;
  98.       Property ApiFontQuality: Word Read FApiFontQuality;
  99.       Property ApiFontPitchAndFamily: Word Read FApiFontPitchAndFamily;
  100.  
  101.       {Property Changed: TNotifyEvent Read FChanged Write FChanged;}
  102.     published
  103.       Property OverFontColor: TColor Read FOverFontColor Write SetOverFontColor;
  104.       Property FontHeight: Integer Read FFontHeight Write SetFontHeight;
  105.       Property FontWidth: Integer Read FFontWidth Write SetFontWidth;
  106.       Property Escapement: Integer Read FEscapement Write SetEscapement;
  107.       Property Orientation: Integer Read FOrientation Write SetOrientation;
  108.       Property FontWeight: TExpFontWeight Read FFontWeight Write SetFontWeight;
  109.       Property Italic: Integer Read FItalic Write SetItalic;
  110.       Property Underline: Integer Read FUnderline Write SetUnderline;
  111.       Property StrikeOut: Integer Read FStrikeOut Write SetStrikeOut;
  112.       Property CharSet: TExpCharSet Read FCharSet Write SetCharSet;
  113.       Property OutputPrecision: TExpOutputPrecision Read FOutputPrecision Write SetOutputPrecision;
  114.       Property ClipPrecision: TExpClipPrecision Read FClipPrecision Write SetClipPrecision;
  115.       Property FontQuality: TExpFontQuality Read FFontQuality Write SetFontQuality;
  116.       Property FontPitch: TExpFontPitch Read FFontPitch Write SetFontPitch;
  117.       Property FontFamily: TExpFontFamily Read FFontFamily Write SetFontFamily;
  118.       Property FaceName: String Read GetFaceName Write SetFaceName;
  119.     end;
  120.  
  121.   TJwRotateFlashClick = class( TLabel )
  122.     private
  123.       { Private fields of TJwRotateFlashClick }
  124.  
  125.         {The TNotifyEvent objects to use on the specific events}
  126.         FOnEnter: TMouseEnter;
  127.         FOnExit: TMouseExit;
  128.  
  129.         {Our new font properties}
  130.         FFontAttributes: TApiFontRec;
  131.  
  132.         {For a nice change of pace, I thought I might want a border for my label
  133.         and throw in a few extra options as well.}
  134.         FBorder: Boolean;
  135.         FBorderStyle: TPenStyle;
  136.         FBorderWidth: Integer;
  137.         FBorderColor: TColor;
  138.  
  139.         {Yes I know there's a better way of doing this, but I'd rather not worry about
  140.         the "perfect" algorythm to autosize a rotated font.  Maybe someday... but for
  141.         now, this is the best I'M goint to do... unless someone else wants to do it
  142.         for me?}
  143.         FLeftOffset: LongInt;
  144.         FTopOffset: LongInt;
  145.         FRightOffset: LongInt;
  146.         FBottomOffset: LongInt;
  147.  
  148.       { Private methods of TJwRotateFlashClick }
  149.         procedure WMSize(var Message: TWMSize); message WM_SIZE;
  150.         procedure WMLButtonDown(var Message: TWMLButtonDown); message WM_LBUTTONDOWN;
  151.         procedure WMLButtonUp(var Message: TWMLButtonUp); message WM_LBUTTONUP;
  152.  
  153.         {FINALLY.. we have a 3-stage event.  The CMMouseEnter and CMMouseLeave are the functions
  154.         that actually look for the CM_MOUSEENTER and CM_MOUSELEAVE in the WinMain command loop.
  155.         Once it hits, it will call the corresponding "Do" method which will call the "Mouse..."
  156.         and that will call the TNotfy event if it is assigned.}
  157.         procedure CMMouseEnter({var msg: TMessage}var Message: TWMMouseEnter); message CM_MOUSEENTER;
  158.         procedure CMMouseLeave({var msg: TMessage}var Message: TWMMouseExit); message CM_MOUSELEAVE;
  159.         procedure MouseEnter(Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
  160.         procedure DoMouseEnter(var Message: TWMMouseEnter; Button: TMouseButton;
  161.                     Shift: TShiftState);
  162.         procedure DoMouseExit(var Message: TWMMouseExit; Button: TMouseButton;
  163.                     Shift: TShiftState);
  164.         procedure MouseExit(Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
  165.  
  166.         Procedure SetFlareFont( Value: TApiFontRec );
  167.         Procedure SetBaseFont( Value: TApiFontRec );
  168.         Procedure SetClickFont( Value: TApiFontRec );
  169.         Procedure SetCommonFont( Value: TApiFontRec );
  170.     protected
  171.       { Protected fields of TJwRotateFlashClick }
  172.         FFlareMode: Byte;
  173.         FBaseFont: TApiFontRec;
  174.         FFlareFont: TApiFontRec;
  175.         FClickFont: TApiFontRec;
  176.  
  177.       { Protected methods of TJwRotateFlashClick }
  178.         procedure Click; override;
  179.         procedure Loaded; override;
  180.         procedure Paint; override;
  181.         procedure ExpDoDrawText(var Rect: TRect; Flags: Word);
  182.  
  183.  
  184.         Procedure SetBorder( Value: Boolean );
  185.         Procedure SetBorderStyle( Value: TPenStyle );
  186.         Procedure SetBorderWidth( Value: Integer );
  187.         Procedure SetBorderColor( Value: TColor );
  188.         Procedure SetLeftOffset( Value: LongInt );
  189.         Procedure SetTopOffset( Value: LongInt );
  190.         Procedure SetRightOffset( Value: LongInt );
  191.         Procedure SetBottomOffset( Value: LongInt );
  192.  
  193.         Procedure OnChangeFont( Sender: TObject );
  194.     public
  195.       { Public fields and properties of TJwRotateFlashClick }
  196.  
  197.       { Public methods of TJwRotateFlashClick }
  198.         constructor Create(AOwner: TComponent); override;
  199.         destructor Destroy; override;
  200.  
  201.     published
  202.       { Published properties of TJwRotateFlashClick }
  203.  
  204.         Property Anchors;
  205.         Property BaseFont: TApiFontRec Read FBaseFont Write SetBaseFont;
  206.         Property FlareFont: TApiFontRec Read FFlareFont Write SetFlareFont;
  207.         Property ClickFont: TApiFontRec Read FClickFont Write SetClickFont;
  208.         Property CommonFont: TApiFontRec Read FBaseFont Write SetCommonFont;
  209.  
  210.         Property OnEnter: TMouseEnter Read FOnEnter Write FOnEnter;
  211.         Property OnExit: TMouseExit Read FOnExit Write FOnExit;
  212.  
  213.         property OnClick;
  214.         property OnDblClick;
  215.         property OnDragDrop;
  216.         property OnMouseDown;
  217.         property OnMouseMove;
  218.         property OnMouseUp;
  219.  
  220.         Property Border: Boolean Read FBorder Write SetBorder
  221.           default False;
  222.         Property BorderStyle: TPenStyle Read FBorderStyle Write SetBorderStyle
  223.           default psSolid;
  224.         Property BorderWidth: Integer Read FBorderWidth Write SetBorderWidth
  225.           default 1;
  226.         Property BorderColor: TColor Read FBorderColor Write SetBorderColor
  227.           default clBlack;
  228.         Property OffsetLeft: LongInt Read FLeftOffset Write SetLeftOffset
  229.           Default 0;
  230.         Property OffsetTop: LongInt Read FTopOffset Write SetTopOffset
  231.           Default 0;
  232.         Property OffsetRight: LongInt Read FRightOffset Write SetRightOffset
  233.           Default 0;
  234.         Property OffsetBottom: LongInt Read FBottomOffset Write SetBottomOffset
  235.           Default 0;
  236.   end;
  237.  
  238. procedure Register;
  239.  
  240. implementation
  241.  
  242. {****************************************************************************************}
  243.  
  244. {****************************************************************************************}
  245.  
  246. Constructor TApiFontRec.Create;
  247. begin
  248.   Inherited Create;
  249.   FFontHeight := 15;
  250.   FFontWidth := 10;
  251.   FEscapement := 0;
  252.   FOrientation := 0;
  253.   FFontWeight := fwRegular;
  254.   FItalic := 0;
  255.   FUnderline := 0;
  256.   FStrikeOut := 0;
  257.   FCharSet := csDefaultCharSet;
  258.   FOutputPrecision := opOutDefaultPrecis;
  259.   FClipPrecision := cpClipDefaultPrecis;
  260.   FFontQuality := fqDefaultQuality;
  261.   FFontPitch := fpDefaultPitch;
  262.   FFontFamily := ffRoman;
  263.   FOverFontColor := clBlack;
  264.   StrCopy( FFacename, 'Arial' );
  265.  
  266.   SetFontWeight( FFontWeight );
  267.   SetCharSet( FCharSet );
  268.   SetOutputPrecision( opOutDefaultPrecis );
  269.   SetClipPrecision( cpClipDefaultPrecis );
  270.   SetFontQuality( fqDefaultQuality );
  271.   SetFontPitch( fpDefaultPitch );
  272.   SetFontFamily( ffRoman );
  273. end;
  274.  
  275. Procedure TApiFontRec.Assign( ObjRef: TApiFontRec );
  276. begin
  277.   FFontHeight := ObjRef.FFontHeight;
  278.   FFontWidth := ObjRef.FFontWidth;
  279.   FEscapement := ObjRef.FEscapement;
  280.   FOrientation := ObjRef.FOrientation;
  281.   FFontWeight := ObjRef.FFontWeight;
  282.   FItalic := ObjRef.FItalic;
  283.   FUnderline := ObjRef.FUnderline;
  284.   FStrikeOut := ObjRef.FStrikeOut;
  285.   FCharSet := ObjRef.FCharSet;
  286.   FOutputPrecision := ObjRef.FOutputPrecision;
  287.   FClipPrecision := ObjRef.FClipPrecision;
  288.   FFontQuality := ObjRef.FFontQuality;
  289.   FFontPitch := ObjRef.FFontPitch;
  290.   FFontFamily := ObjRef.FFontFamily;
  291.   FOverFontColor := ObjRef.FOverFontColor;
  292.   StrCopy( FFacename, ObjRef.FFacename );
  293. end;
  294.  
  295. Procedure TApiFontRec.SetFaceName( Value: String );
  296. var
  297.   OldName, TmpStr: array[0..255] of Char;
  298. begin
  299.   StrPCopy( TmpStr, Value );
  300.   if StrComp( TmpStr, FFacename ) <> 0 then
  301.     begin
  302.       try
  303.         StrCopy( OldName, FFaceName );
  304.         StrCopy( FFacename, TmpStr );
  305.         {if Assigned( FChanged ) then FChanged( Self );}
  306.         Changed;
  307.       except
  308.         { NOTE:  The possiblity of this happening isn't really big, but I wanted to
  309.         make a point here....}
  310.         StrCopy( FFaceName, OldName );
  311.         Raise EApiFontError.Create( 'Invalid font name' );
  312.       end;
  313.     end;
  314. end;
  315.  
  316. Function TApiFontRec.GetFaceName: String;
  317. begin
  318.   Result := StrPas( FFacename );
  319. end;
  320.  
  321. Procedure TApiFontRec.SetFontWeight( Value: TExpFontWeight );
  322. begin
  323.   if FFontWeight <> Value then
  324.     begin
  325.       FFontWeight := Value;
  326.       Case FFontWeight of
  327.         fwDontCare: FApiFontWeight := FW_DONTCARE;
  328.             fwThin: FApiFontWeight := FW_THIN;
  329.       fwExtraLight: FApiFontWeight := FW_EXTRALIGHT;
  330.       fwUltraLight: FApiFontWeight := FW_ULTRALIGHT;
  331.            fwLight: FApiFontWeight := FW_LIGHT;
  332.           fwNormal: FApiFontWeight := FW_NORMAL;
  333.          fwRegular: FApiFontWeight := FW_REGULAR;
  334.           fwMedium: FApiFontWeight := FW_MEDIUM;
  335.         fwSemiBold: FApiFontWeight := FW_SEMIBOLD;
  336.         fwDemiBold: FApiFontWeight := FW_DEMIBOLD;
  337.             fwBold: FApiFontWeight := FW_BOLD;
  338.        fwExtraBold: FApiFontWeight := FW_EXTRABOLD;
  339.        fwUltraBold: FApiFontWeight := FW_ULTRABOLD;
  340.            fwBlack: FApiFontWeight := FW_BLACK;
  341.            fwHeavy: FApiFontWeight := FW_HEAVY;
  342.        end;
  343.       {if Assigned( FChanged ) then FChanged( Self );}
  344.       Changed;
  345.     end;
  346. end;
  347.  
  348. Procedure TApiFontRec.SetCharSet( Value: TExpCharSet );
  349. begin
  350.   if FCharSet <> Value then
  351.     begin
  352.       FCharSet := Value;
  353.       case FCharSet of
  354.             csAnsiCharSet: FApiFontCharSet := ANSI_CHARSET;
  355.          csDefaultCharSet: FApiFontCharSet := DEFAULT_CHARSET;
  356.           csSymbolCharSet: FApiFontCharSet := SYMBOL_CHARSET;
  357.         csShiftJisCharSet: FApiFontCharSet := SHIFTJIS_CHARSET;
  358.              csOemCharSet: FApiFontCharSet := OEM_CHARSET;
  359.       end;
  360.       {if Assigned( FChanged ) then FChanged( Self );}
  361.       Changed;
  362.     end;
  363. end;
  364.  
  365. Procedure TApiFontRec.SetOutputPrecision( Value: TExpOutputPrecision );
  366. begin
  367.   if FOutputPrecision <> Value then
  368.     begin
  369.       FOutputPrecision := Value;
  370.       case FOutputPrecision of
  371.         opOutCharacterPrecis: FApiFontOutPrecision := OUT_CHARACTER_PRECIS;
  372.           opOutDefaultPrecis: FApiFontOutPrecision := OUT_DEFAULT_PRECIS;
  373.            opOutDevicePrecis: FApiFontOutPrecision := OUT_DEVICE_PRECIS;
  374.            opOutRasterPrecis: FApiFontOutPrecision := OUT_RASTER_PRECIS;
  375.            opOutStringPrecis: FApiFontOutPrecision := OUT_STRING_PRECIS;
  376.            opOutStrokePrecis: FApiFontOutPrecision := OUT_STROKE_PRECIS;
  377.                opOutTTPrecis: FApiFontOutPrecision := OUT_TT_PRECIS;
  378.       end;
  379.       {if Assigned( FChanged ) then FChanged( Self );}
  380.       Changed;
  381.     end;
  382. end;
  383.  
  384. Procedure TApiFontRec.SetClipPrecision( Value: TExpClipPrecision );
  385. begin
  386.   if FClipPrecision <> Value then
  387.     begin
  388.       FClipPrecision := Value;
  389.       case FClipPrecision of
  390.         cpClipCharacterPrecis: FApiFontClipPrecision := CLIP_CHARACTER_PRECIS;
  391.           cpClipDefaultPrecis: FApiFontClipPrecision := CLIP_DEFAULT_PRECIS;
  392.             cpClipEncapsulate: FApiFontClipPrecision := CLIP_EMBEDDED;
  393.                cpClipLHAngles: FApiFontClipPrecision := CLIP_LH_ANGLES;
  394.                    cpClipMask: FApiFontClipPrecision := CLIP_MASK;
  395.            cpClipStrokePrecis: FApiFontClipPrecision := CLIP_STROKE_PRECIS;
  396.                cpClipTTAlways: FApiFontClipPrecision := CLIP_TT_ALWAYS;
  397.       end;
  398.       {if Assigned( FChanged ) then FChanged( Self );}
  399.       Changed;
  400.     end;
  401. end;
  402.  
  403. Procedure TApiFontRec.SetFontQuality( Value: TExpFontQuality );
  404. begin
  405.   if FFontQuality <> Value then
  406.     begin
  407.       FFontQuality := Value;
  408.       case FFontQuality of
  409.         fqDefaultQuality: FApiFontQuality := DEFAULT_QUALITY;
  410.           fqDraftQuality: FApiFontQuality := DRAFT_QUALITY;
  411.           fqProofQuality: FApiFontQuality := PROOF_QUALITY;
  412.       end;
  413.       {if Assigned( FChanged ) then FChanged( Self );}
  414.       Changed;
  415.     end;
  416. end;
  417.  
  418. Procedure TApiFontRec.SetFontPitch( Value: TExpFontPitch );
  419. begin
  420.   if FFontPitch <> Value then
  421.     begin
  422.       FFontPitch := Value;
  423.       { We want to clear out the old values before we add a new one. }
  424.       FApiFontPitchAndFamily := FApiFontPitchAndFamily AND $F0;
  425.       case FFontPitch of
  426.          fpDefaultPitch: FApiFontPitchAndFamily := FApiFontPitchAndFamily + DEFAULT_PITCH;
  427.            fpFixedPitch: FApiFontPitchAndFamily := FApiFontPitchAndFamily + FIXED_PITCH;
  428.         fpVariablePitch: FApiFontPitchAndFamily := FApiFontPitchAndFamily + VARIABLE_PITCH;
  429.       end;
  430.       {if Assigned( FChanged ) then FChanged( Self );}
  431.       Changed;
  432.     end;
  433. end;
  434.  
  435. Procedure TApiFontRec.SetFontFamily( Value: TExpFontFamily );
  436. begin
  437.   if FFontFamily <> Value then
  438.     begin
  439.       FFontFamily := Value;
  440.       { We want to clear out the old values before we add a new one. }
  441.       FApiFontPitchAndFamily := FApiFontPitchAndFamily AND $0F;
  442.       Case FFontFamily of
  443.         ffDecorative: FApiFontPitchAndFamily := FApiFontPitchAndFamily + FF_DECORATIVE;
  444.           ffDontCare: FApiFontPitchAndFamily := FApiFontPitchAndFamily + FF_DONTCARE;
  445.             ffModern: FApiFontPitchAndFamily := FApiFontPitchAndFamily + FF_MODERN;
  446.              ffRoman: FApiFontPitchAndFamily := FApiFontPitchAndFamily + FF_ROMAN;
  447.             ffScript: FApiFontPitchAndFamily := FApiFontPitchAndFamily + FF_SCRIPT;
  448.              ffSwiss: FApiFontPitchAndFamily := FApiFontPitchAndFamily + FF_SWISS;
  449.       end;
  450.       {if Assigned( FChanged ) then FChanged( Self );}
  451.       Changed;
  452.     end;
  453. end;
  454.  
  455. Procedure TApiFontRec.SetOverFontColor( Value: TColor );
  456. begin
  457.   if FOverFontColor <> Value then
  458.     begin
  459.       FOverFontColor := Value;
  460.       Changed;
  461.     end;
  462. end;
  463.  
  464. Procedure TApiFontRec.SetFontHeight( Value: Integer );
  465. begin
  466.   if FFontHeight <> Value then
  467.     begin
  468.       FFontHeight := Value;
  469.       Changed;
  470.     end;
  471. end;
  472.  
  473. Procedure TApiFontRec.SetFontWidth( Value: Integer );
  474. begin
  475.   if FFontWidth <> Value then
  476.     begin
  477.       FFontWidth := Value;
  478.       Changed;
  479.     end;
  480. end;
  481.  
  482. Procedure TApiFontRec.SetEscapement( Value: Integer );
  483. begin
  484.   if FEscapement <> Value then
  485.     begin
  486.       FEscapement := Value;
  487.       Changed;
  488.     end;
  489. end;
  490.  
  491. Procedure TApiFontRec.SetOrientation( Value: Integer );
  492. begin
  493.   if FOrientation <> Value then
  494.     begin
  495.       FOrientation := Value;
  496.       Changed;
  497.     end;
  498. end;
  499.  
  500. Procedure TApiFontRec.SetItalic( Value: Integer );
  501. begin
  502.   if FItalic <> Value then
  503.     begin
  504.       FItalic := Value;
  505.       Changed;
  506.     end;
  507. end;
  508.  
  509. Procedure TApiFontRec.SetUnderline( Value: Integer );
  510. begin
  511.   if FUnderline <> Value then
  512.     begin
  513.       FUnderline := Value;
  514.       Changed;
  515.     end;
  516. end;
  517.  
  518. Procedure TApiFontRec.SetStrikeOut( Value: Integer );
  519. begin
  520.   if FStrikeOut <> Value then
  521.     begin
  522.       FStrikeOut := Value;
  523.       Changed;
  524.     end;
  525. end;
  526.  
  527. {****************************************************************************************}
  528.  
  529. {****************************************************************************************}
  530.  
  531. procedure Register;
  532. begin
  533.      { Register TJwRotateFlashClick with Standard as its
  534.        default page on the Delphi component palette }
  535.      RegisterComponents('JwTools', [TJwRotateFlashClick]);
  536. end;
  537.  
  538. Procedure TJwRotateFlashClick.SetCommonFont( Value: TApiFontRec );
  539. begin
  540.   {if Value <> FClickFont then
  541.     begin}
  542.       FClickFont.Assign( Value );
  543.       FBaseFont.Assign( Value );
  544.       FFlareFont.Assign( Value );
  545.       FBaseFont.OnChange := OnChangeFont;
  546.       FFlareFont.OnChange := OnChangeFont;
  547.       FClickFont.OnChange := ONChangeFont;
  548.       Invalidate;
  549.     {end;}
  550. end;
  551.  
  552. Procedure TJwRotateFlashClick.SetClickFont( Value: TApiFontRec );
  553. begin
  554.   {if Value <> FClickFont then
  555.     begin}
  556.       FClickFont.Assign( Value );
  557.       FClickFont.OnChange := ONChangeFont;
  558.       Invalidate;
  559.     {end;}
  560. end;
  561.  
  562. Procedure TJwRotateFlashClick.SetBaseFont( Value: TApiFontRec );
  563. begin
  564.   {if Value <> FBaseFont then
  565.     begin}
  566.       FBaseFont.Assign( Value );
  567.       FBaseFont.OnChange := OnChangeFont;
  568.       Invalidate;
  569.     {end;}
  570. end;
  571.  
  572. Procedure TJwRotateFlashClick.SetFlareFont( Value: TApiFontRec );
  573. begin
  574.   {if Value <> FFlareFont then
  575.     begin}
  576.       FFlareFont.Assign( Value );
  577.       FFlareFont.OnChange := OnChangeFont;
  578.       Invalidate;
  579.     {end;}
  580. end;
  581.  
  582. Procedure TJwRotateFlashClick.SetBorder( Value: Boolean );
  583. begin
  584.   if FBorder <> Value then
  585.     begin
  586.       FBorder := Value;
  587.       InValidate;
  588.     end;
  589. end;
  590.  
  591. Procedure TJwRotateFlashClick.SetBorderStyle( Value: TPenStyle );
  592. begin
  593.   if FBorderStyle <> Value then
  594.     begin
  595.       FBorderStyle := Value;
  596.       InValidate;
  597.     end;
  598. end;
  599.  
  600. Procedure TJwRotateFlashClick.SetBorderWidth( Value: Integer );
  601. begin
  602.   if FBorderWidth <> Value then
  603.     begin
  604.       FBorderWidth := Value;
  605.       InValidate;
  606.     end;
  607. end;
  608.  
  609. Procedure TJwRotateFlashClick.SetBorderColor( Value: TColor );
  610. begin
  611.   if FBorderColor <> Value then
  612.     begin
  613.       FBorderColor := Value;
  614.       InValidate;
  615.     end;
  616. end;
  617.  
  618. Procedure TJwRotateFlashClick.SetLeftOffset( Value: LongInt );
  619. begin
  620.   if FLeftOffset <> Value then
  621.     begin
  622.       FLeftOffset := Value;
  623.       InValidate;
  624.     end;
  625. end;
  626.  
  627. Procedure TJwRotateFlashClick.SetTopOffset( Value: LongInt );
  628. begin
  629.   if FTopOffset <> Value then
  630.     begin
  631.       FTopOffset := Value;
  632.       InValidate;
  633.     end;
  634. end;
  635.  
  636. Procedure TJwRotateFlashClick.SetRightOffset( Value: LongInt );
  637. begin
  638.   if FRightOffset <> Value then
  639.     begin
  640.       FRightOffset := Value;
  641.       InValidate;
  642.     end;
  643. end;
  644.  
  645. Procedure TJwRotateFlashClick.SetBottomOffset( Value: LongInt );
  646. begin
  647.   if FBottomOffset <> Value then
  648.     begin
  649.       FBottomOffset := Value;
  650.       InValidate;
  651.     end;
  652. end;
  653.  
  654. { Override OnClick handler from TLabel }
  655. procedure TJwRotateFlashClick.Click;
  656. begin
  657.   inherited Click;
  658. end;
  659.  
  660.  
  661. constructor TJwRotateFlashClick.Create(AOwner: TComponent);
  662. begin
  663.      { Call the Create method of the parent class }
  664.   inherited Create(AOwner);
  665.   FBaseFont := TApiFontRec.Create;
  666.   FFlareFont := TApiFontRec.Create;
  667.   FClickFont := TApiFontRec.Create;
  668.  
  669.   FFlareMode := 0;
  670.   FBaseFont.OverFontColor := clWhite;
  671.   FFlareFont.Assign( FBaseFont );
  672.   FFlareFont.FontHeight := FFlareFont.FontHeight + 2;
  673.   FFlareFont.OverFontColor := clYellow;
  674.   FClickFont.Assign( FBaseFont );
  675.   FClickFont.FontHeight := ClickFont.FontHeight + 2;
  676.   FClickFont.OverFontColor := clRed;
  677.  
  678.   FBaseFont.OnChange := OnChangeFont;
  679.   FFlareFont.OnChange := OnChangeFont;
  680.   FClickFont.OnChange := ONChangeFont;
  681. end;
  682.  
  683. destructor TJwRotateFlashClick.Destroy;
  684. begin
  685.   FBaseFont.Free;
  686.   FFlareFont.Free;
  687.   FClickFont.Free;
  688.   inherited Destroy;
  689. end;
  690.  
  691. procedure TJwRotateFlashClick.Loaded;
  692. begin
  693.   inherited Loaded;
  694. end;
  695.  
  696. procedure TJwRotateFlashClick.Paint;
  697. const
  698.   Alignments: array[TAlignment] of Word = (DT_LEFT, DT_RIGHT, DT_CENTER);
  699. var
  700.   Rect: TRect;
  701. begin
  702.   with Canvas do
  703.   begin
  704.     Rect := ClientRect;
  705.     Rect.Left := Rect.Left + FLeftOffset;
  706.     Rect.Top := Rect.Top + FTopOffset;
  707.     Rect.Right := Rect.Right - FRightOffset;
  708.     Rect.Bottom := Rect.Bottom - FBottomOffset;
  709.     if not Transparent then
  710.     begin
  711.       Brush.Color := Self.Color;
  712.       Brush.Style := bsSolid;
  713.       FillRect(ClientRect);
  714.     end;
  715.     Brush.Style := bsClear;
  716.     if FBorder then
  717.       begin
  718.         Pen.Style := FBorderStyle;
  719.         Pen.Width := FBorderWidth;
  720.         Pen.Color := FBorderColor;
  721.         Rectangle( Rect.Left, Rect.Top, Rect.Right, Rect.Bottom );
  722.       end;
  723.     ExpDoDrawText(Rect, (DT_EXPANDTABS or DT_WORDBREAK) or
  724.       Alignments[Alignment]);
  725.   end;
  726. end;
  727.  
  728. procedure TJwRotateFlashClick.ExpDoDrawText(var Rect: TRect; Flags: Word);
  729. var
  730.   Text: array[0..255] of Char;
  731.   TmpFont: TApiFontRec;
  732.   TmpStr: array[0..255] of Char;
  733. begin
  734.   GetTextBuf(Text, SizeOf(Text));
  735.   if (Flags and DT_CALCRECT <> 0) and ((Text[0] = #0) or ShowAccelChar and
  736.     (Text[0] = '&') and (Text[1] = #0)) then StrCopy(Text, ' ');
  737.   if not ShowAccelChar then Flags := Flags or DT_NOPREFIX;
  738.  
  739.   {Right here is where we break ranks with the old code.  We want to change the font
  740.   to have the properties that WE set.  We'll do this in a case statement so that
  741.   changes to the API Wont ruin our code.}
  742.  
  743.   case FFlareMode of
  744.     0: begin
  745.          TmpFont := FBaseFont;
  746.        end;
  747.     1: begin
  748.          TmpFont := FFlareFont;
  749.        end;
  750.     2: begin
  751.          TmpFont := FClickFont;
  752.        end;
  753.   else
  754.     TmpFont := FBaseFont;
  755.   end;
  756.  
  757.   with TmpFont do begin
  758.       if Escapement > 0 then
  759.         Flags := DT_NOCLIP;
  760.       StrPCopy( TmpStr, FaceName );
  761.       Canvas.Font.Color := FOverFontColor;
  762.       Canvas.Font.Handle := CreateFont(   FontHeight,  {Height}
  763.                                            FontWidth,  {Width}
  764.                                           Escapement,  {Escapement}
  765.                                          Orientation,  {Orientation}
  766.                                 ApiFontWeight,          {Weight}
  767.                                               Italic,  {Italic}
  768.                                            Underline,  {Underline}
  769.                                            StrikeOut,  {StrikeOut}
  770.                                 ApiFontCharSet,         {CharSet}
  771.                                 ApiFontOutPrecision,    {OutputPrecision}
  772.                                 ApiFontClipPrecision,   {ClipPrecision}
  773.                                 ApiFontQuality,         {Quality}
  774.                                 ApiFontPitchAndFamily,  {PitchAndFamily}
  775.                                                TmpStr );{FaceName}
  776.   end; {end of with TmpFont}
  777.  
  778.  
  779.   {Canvas.Font := Font;}
  780.   if not Enabled then Canvas.Font.Color := clGrayText;
  781.   DrawText(Canvas.Handle, Text, StrLen(Text), Rect, Flags);
  782. end;
  783.  
  784. procedure TJwRotateFlashClick.WMSize(var Message: TWMSize);
  785. var
  786.      W, H: Integer;
  787. begin
  788.      inherited;
  789.  
  790.      { Copy the new width and height of the component
  791.        so we can use SetBounds to change both at once }
  792.      W := Width;
  793.      H := Height;
  794.  
  795.      { Code to check and adjust W and H }
  796.  
  797.      { Update the component size if we adjusted W or H }
  798.      if (W <> Width) or (H <> Height) then
  799.         inherited SetBounds(Left, Top, W, H);
  800.  
  801.      { Code to update dimensions of any owned sub-components
  802.        by reading their Height and Width properties and updating
  803.        via their SetBounds methods }
  804.  
  805.      Message.Result := 0;
  806. end;
  807.  
  808. procedure TJwRotateFlashClick.CMMouseEnter(var Message: TWMMouseEnter);
  809. begin
  810.   FFlareMode := 1;
  811.   Invalidate;
  812.   Inherited;
  813.   DoMouseEnter(Message, mbLeft, []);
  814. end;
  815.  
  816. procedure TJwRotateFlashClick.CMMouseLeave(var Message: TWMMouseExit);
  817. begin
  818.   FFlareMode := 0;
  819.   Invalidate;
  820.   Inherited;
  821.   DoMouseExit(Message, mbLeft, []);
  822. end;
  823.  
  824. procedure TJwRotateFlashClick.WMLButtonDown(var Message: TWMLButtonDown);
  825. begin
  826.   FFlareMode := 2;
  827.   Invalidate;
  828.   Inherited;
  829. end;
  830.  
  831. procedure TJwRotateFlashClick.WMLButtonUp(var Message: TWMLButtonUp);
  832. begin
  833.   FFlareMode := 1;
  834.   Invalidate;
  835.   Inherited;
  836. end;
  837.  
  838. procedure TJwRotateFlashClick.DoMouseEnter(var Message: TWMMouseEnter; Button: TMouseButton;
  839.   Shift: TShiftState);
  840. begin
  841.   with Message do
  842.     MouseEnter(Button, KeysToShiftState(Keys) + Shift, XPos, YPos);
  843. end;
  844.  
  845. procedure TJwRotateFlashClick.MouseEnter(Button: TMouseButton;
  846.   Shift: TShiftState; X, Y: Integer);
  847. begin
  848.   if Assigned(FOnEnter) then FOnEnter(Self, Button, Shift, X, Y);
  849. end;
  850.  
  851. procedure TJwRotateFlashClick.DoMouseExit(var Message: TWMMouseExit; Button: TMouseButton;
  852.   Shift: TShiftState);
  853. begin
  854.   with Message do
  855.     MouseExit(Button, KeysToShiftState(Keys) + Shift, XPos, YPos);
  856. end;
  857.  
  858. procedure TJwRotateFlashClick.MouseExit(Button: TMouseButton;
  859.   Shift: TShiftState; X, Y: Integer);
  860. begin
  861.   if Assigned(FOnExit) then FOnExit(Self, Button, Shift, X, Y);
  862. end;
  863.  
  864. Procedure TJwRotateFlashClick.OnChangeFont( Sender: TObject );
  865. begin
  866.   InValidate;
  867. end;
  868.  
  869.  
  870. end.
  871.