move WaveTo from synedit to GraphUtil

git-svn-id: trunk@27699 -
This commit is contained in:
paul 2010-10-14 00:48:35 +00:00
parent 274f67d4c4
commit 7cfcf487e3
3 changed files with 60 additions and 63 deletions

View File

@ -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);

View File

@ -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,

View File

@ -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.