From 7cfcf487e335eaf875e76800a165a63b32fcf6ba Mon Sep 17 00:00:00 2001 From: paul Date: Thu, 14 Oct 2010 00:48:35 +0000 Subject: [PATCH] move WaveTo from synedit to GraphUtil git-svn-id: trunk@27699 - --- components/synedit/syntextdrawer.pp | 61 +---------------------------- ide/frames/editor_color_options.pas | 4 +- lcl/graphutil.pp | 58 ++++++++++++++++++++++++++- 3 files changed, 60 insertions(+), 63 deletions(-) diff --git a/components/synedit/syntextdrawer.pp b/components/synedit/syntextdrawer.pp index a08c342ce0..4770be25f1 100644 --- a/components/synedit/syntextdrawer.pp +++ b/components/synedit/syntextdrawer.pp @@ -75,7 +75,7 @@ uses {$ELSE} Windows, {$ENDIF} - SysUtils, Classes, Graphics, Types, SynEditTypes, SynEditMiscProcs; + SysUtils, Classes, Graphics, GraphUtil, Types, SynEditTypes, SynEditMiscProcs; type TheStockFontPatterns = 0..(1 shl (1 + Ord(High(TFontStyle)))); @@ -307,8 +307,6 @@ type function GetFontsInfoManager: TheFontsInfoManager; - procedure WaveTo(ADC: HDC; X, Y, R: Integer); - {$IFNDEF VER93} {$IFNDEF VER90} {$IFNDEF VER80} @@ -1240,63 +1238,6 @@ begin {$ENDIF} end; -procedure WaveTo(ADC: HDC; X, Y, R: Integer); -var - Direction, Cur: Integer; - PenPos, Dummy: TPoint; -begin - dec(R); - // get the current pos - MoveToEx(ADC, 0, 0, @PenPos); - MoveToEx(ADC, PenPos.X, PenPos.Y, @Dummy); - - Direction := 1; - // vertical wave - if PenPos.X = X then - begin - Cur := PenPos.Y; - if Cur < Y then - while (Cur < Y) do - begin - X := X + Direction * R; - LineTo(ADC, X, Cur + R); - Direction := -Direction; - inc(Cur, R); - end - else - while (Cur > Y) do - begin - X := X + Direction * R; - LineTo(ADC, X, Cur - R); - Direction := -Direction; - dec(Cur, R); - end; - LineTo(ADC, X, Y); - end - else - // horizontal wave - begin - Cur := PenPos.X; - if (Cur < X) then - while (Cur < X) do - begin - Y := Y + Direction * R; - LineTo(ADC, Cur + R, Y); - Direction := -Direction; - inc(Cur, R); - end - else - while (Cur > X) do - begin - Y := Y + Direction * R; - LineTo(ADC, Cur - R, Y); - Direction := -Direction; - dec(Cur, R); - end; - LineTo(ADC, X, Y); - end; -end; - procedure TheTextDrawer.ExtTextOut(X, Y: Integer; fuOptions: UINT; const ARect: TRect; Text: PChar; Length: Integer; FrameBottom: Integer = -1); diff --git a/ide/frames/editor_color_options.pas b/ide/frames/editor_color_options.pas index 8edfffbd26..ea2d79a5ea 100644 --- a/ide/frames/editor_color_options.pas +++ b/ide/frames/editor_color_options.pas @@ -25,8 +25,8 @@ unit editor_color_options; interface uses - Classes, Controls, StdCtrls, sysutils, ExtCtrls, Graphics, ColorBox, ComCtrls, - LCLProc, LCLType, LCLIntf, Dialogs, Menus, + Classes, Controls, StdCtrls, sysutils, ExtCtrls, Graphics, GraphUtil, ColorBox, + ComCtrls, LCLProc, LCLType, LCLIntf, Dialogs, Menus, SynEdit, SynEditMiscClasses, SynGutterCodeFolding, SynGutterLineNumber, SynEditTypes, SynGutterChanges, SynEditMouseCmds, SynEditHighlighter, SynTextDrawer, DividerBevel, EditorOptions, IDEOptionsIntf, editor_general_options, IDEImagesIntf, diff --git a/lcl/graphutil.pp b/lcl/graphutil.pp index c910f720d0..dca97fc78c 100644 --- a/lcl/graphutil.pp +++ b/lcl/graphutil.pp @@ -27,7 +27,7 @@ unit GraphUtil; interface uses - Types, Graphics, GraphType, Math, LCLType; + Types, Graphics, GraphType, Math, LCLType, LCLIntf; function ColorToGray(const AColor: TColor): Byte; procedure ColorToHLS(const AColor: TColor; out H, L, S: Byte); @@ -70,6 +70,7 @@ function GetShadowColor(const Color: TColor; Luminance: Integer = -50): TColor; // misc function NormalizeRect(const R: TRect): TRect; +procedure WaveTo(ADC: HDC; X, Y, R: Integer); implementation @@ -481,4 +482,59 @@ begin DrawVerticalGradient(Canvas, WindowRect, GetHighLightColor(BaseColor), GetShadowColor(BaseColor)); end; +procedure WaveTo(ADC: HDC; X, Y, R: Integer); +var + Direction, Cur: Integer; + PenPos, Dummy: TPoint; +begin + dec(R); + // get the current pos + MoveToEx(ADC, 0, 0, @PenPos); + MoveToEx(ADC, PenPos.X, PenPos.Y, @Dummy); + + Direction := 1; + // vertical wave + if PenPos.X = X then + begin + Cur := PenPos.Y; + if Cur < Y then + while (Cur < Y) do + begin + X := X + Direction * R; + LineTo(ADC, X, Cur + R); + Direction := -Direction; + inc(Cur, R); + end + else + while (Cur > Y) do + begin + X := X + Direction * R; + LineTo(ADC, X, Cur - R); + Direction := -Direction; + dec(Cur, R); + end; + end + else + // horizontal wave + begin + Cur := PenPos.X; + if (Cur < X) then + while (Cur < X) do + begin + Y := Y + Direction * R; + LineTo(ADC, Cur + R, Y); + Direction := -Direction; + inc(Cur, R); + end + else + while (Cur > X) do + begin + Y := Y + Direction * R; + LineTo(ADC, Cur - R, Y); + Direction := -Direction; + dec(Cur, R); + end; + end; +end; + end.