fixed TCanvas.Pie

git-svn-id: trunk@4499 -
This commit is contained in:
mattias 2003-08-18 19:24:18 +00:00
parent 26c5eba0d4
commit e97f3e9562
11 changed files with 124 additions and 99 deletions

View File

@ -557,8 +557,10 @@ type
Procedure Line(X1,Y1,X2,Y2 : Integer); // short for MoveTo();LineTo();
Procedure LineTo(X1,Y1 : Integer);
Procedure MoveTo(X1,Y1 : Integer);
procedure Pie(x,y,width,height,angle1,angle2 : Integer);
procedure Pie(x,y,width,height,SX,SY,EX,EY : Integer);
procedure RadialPie(x,y,width,height,angle1,angle2 : Integer);
procedure RadialPie(x,y,width,height,sx,sy,ex,ey: Integer);
procedure Pie(EllipseX1,EllipseY1,EllipseX2,EllipseY2,
StartX,StartY,EndX,EndY: Integer);
procedure PolyBezier(Points: PPoint; NumPts: Integer;
Filled: boolean{$IFDEF VER1_1} = False{$ENDIF};
Continuous: boolean{$IFDEF VER1_1} = False{$ENDIF});
@ -1028,6 +1030,9 @@ end.
{ =============================================================================
$Log$
Revision 1.80 2003/08/18 19:24:18 mattias
fixed TCanvas.Pie
Revision 1.79 2003/07/20 06:27:19 mattias
fixed GetWindowRelativePosition

View File

@ -52,10 +52,10 @@ Procedure Angles2Coords(X,Y, Width, Height : Integer;
Procedure Arc2Bezier(X, Y, Width, Height : Longint; Angle1, Angle2,
Rotation : Extended; var Points : TBezier);
Function Bezier(C1,C2,C3,C4 : TFloatPoint): TBezier; Overload;
Function Bezier(C1,C2,C3,C4 : TPoint): TBezier; Overload;
Function Bezier(const C1,C2,C3,C4 : TFloatPoint): TBezier; Overload;
Function Bezier(const C1,C2,C3,C4 : TPoint): TBezier; Overload;
Procedure Bezier2Polyline(Bezier : TBezier; var Points : PPoint;
Procedure Bezier2Polyline(const Bezier : TBezier; var Points : PPoint;
var Count : Longint);
Procedure BezierArcPoints(X, Y, Width, Height : Longint; Angle1, Angle2,
@ -73,13 +73,11 @@ Function Distance(Pt, SP, EP : TFloatPoint) : Extended; overload;
Function EccentricAngle(PT : TPoint; Rect : TRect) : Extended;
Function EllipseRadialLength(Rect : TRect; EccentricAngle : Extended) :
Longint;
Function EllipseRadialLength(Rect : TRect; EccentricAngle : Extended) : Longint;
Function FloatPoint(AX,AY : Extended): TFloatPoint;
Function LineEndPoint(StartPoint : TPoint; Angle, Length : Extended) :
TPoint;
Function LineEndPoint(StartPoint : TPoint; Angle, Length : Extended) : TPoint;
Procedure PolyBezier2Polyline(Beziers: Array of TBezier;
var Points : PPoint; var Count : Longint); Overload;
@ -447,7 +445,7 @@ end;
routines.
------------------------------------------------------------------------------}
Function Bezier(C1,C2,C3,C4 : TFloatPoint): TBezier;
Function Bezier(const C1,C2,C3,C4 : TFloatPoint): TBezier;
begin
Result[0] := C1;
Result[1] := C2;
@ -464,7 +462,7 @@ end;
routines.
------------------------------------------------------------------------------}
Function Bezier(C1,C2,C3,C4 : TPoint): TBezier;
Function Bezier(const C1,C2,C3,C4 : TPoint): TBezier;
begin
Result[0] := FloatPoint(C1.X,C1.Y);
Result[1] := FloatPoint(C2.X,C2.Y);
@ -486,7 +484,7 @@ end;
by calling to ReallocMem(Points, 0).
------------------------------------------------------------------------------}
Procedure Bezier2Polyline(Bezier : TBezier; var Points : PPoint;
Procedure Bezier2Polyline(const Bezier : TBezier; var Points : PPoint;
var Count : Longint);
var
Pt : TPoint;
@ -635,10 +633,10 @@ end;
Use Coords2Angles to convert the coords for Start and End Radial-Points, such
as are used in the Windows API Arc Pie and Chord routines, into an Eccentric
(aka Radial) Angle and an Angle-Length, such as are used in X-Windows and
GTK. The angles angle1 and angle2 are returned in 1/16th of a degree. For
example, a full circle equals 5760 (16*360). Zero degrees is at the
3'o clock position.
(aka Radial) counter clockwise Angle and an Angle-Length, such as are used in
X-Windows and GTK. The angles angle1 and angle2 are returned in 1/16th of a
degree. For example, a full circle equals 5760 (16*360). Zero degrees is at
the 3'o clock position.
------------------------------------------------------------------------------}
Procedure Coords2Angles(X, Y, Width, Height : Integer; SX, SY,
@ -1087,6 +1085,9 @@ end.
{ =============================================================================
$Log$
Revision 1.3 2003/08/18 19:24:18 mattias
fixed TCanvas.Pie
Revision 1.2 2002/11/12 10:16:14 lazarus
MG: fixed TMainMenu creation

View File

@ -300,7 +300,7 @@ begin
end;
{------------------------------------------------------------------------------
Method: TCanvas.Pie
Method: TCanvas.RadialPie
Params: x,y,width,height,angle1,angle2
Returns: Nothing
@ -311,16 +311,16 @@ end;
Zero degrees is at the 3'o clock position.
------------------------------------------------------------------------------}
procedure TCanvas.Pie(x,y,width,height,angle1,angle2 : Integer);
procedure TCanvas.RadialPie(x,y,width,height,angle1,angle2 : Integer);
begin
Changing;
RequiredState([csHandleValid, csBrushValid, csPenValid]);
LCLLinux.Pie(FHandle,x,y,width,height,angle1,angle2);
LCLLinux.RadialPieWithAngles(FHandle,x,y,width,height,angle1,angle2);
Changed;
end;
{------------------------------------------------------------------------------
Method: TCanvas.Pie
Method: TCanvas.RadialPie
Params: x,y,width,height,sx,sy,ex,ey
Returns: Nothing
@ -329,7 +329,7 @@ end;
the Bounding-Arc is drawn.
------------------------------------------------------------------------------}
procedure TCanvas.Pie(x,y,width,height,sx,sy,ex,ey : Integer);
procedure TCanvas.RadialPie(x,y,width,height,sx,sy,ex,ey: Integer);
begin
Changing;
RequiredState([csHandleValid, csBrushValid, csPenValid]);
@ -337,6 +337,28 @@ begin
Changed;
end;
{------------------------------------------------------------------------------
Method: TCanvas.Pie
Params: EllipseX1, EllipseY1, EllipseX2, EllipseY2,
StartX, StartY, EndX, EndY
Returns: Nothing
Use Pie to draw a filled Pie-shaped wedge on the canvas. The pie is part of
an ellipse between the points EllipseX1, EllipseY1, EllipseX2, EllipseY2.
The values StartX, StartY and EndX, EndY represent the starting and ending
radial-points between which the Bounding-Arc is drawn.
------------------------------------------------------------------------------}
procedure TCanvas.Pie(EllipseX1, EllipseY1, EllipseX2, EllipseY2,
StartX, StartY, EndX, EndY: Integer);
begin
Changing;
RequiredState([csHandleValid, csBrushValid, csPenValid]);
LCLLinux.Pie(FHandle,EllipseX1,EllipseY1,EllipseX2,EllipseY2,
StartX,StartY,EndX,EndY);
Changed;
end;
{------------------------------------------------------------------------------
Method: TCanvas.PolyBezier
Params: Points, Filled, Continous
@ -1216,6 +1238,9 @@ end;
{ =============================================================================
$Log$
Revision 1.51 2003/08/18 19:24:18 mattias
fixed TCanvas.Pie
Revision 1.50 2003/07/04 08:54:53 mattias
implemented 16bit rawimages for gtk

View File

@ -1337,22 +1337,13 @@ Begin
End;
function TInterfaceBase.Pie(DC: HDC;
x,y,width,height,angle1,angle2 : Integer): Boolean;
var
Points : PPoint;
Count : Longint;
EllipseX1,EllipseY1,EllipseX2,EllipseY2,
StartX,StartY,EndX,EndY: Integer): Boolean;
begin
Result := False;
Points := nil;
Count := 0;
PolyBezierArcPoints(X,Y,Width,Height,Angle1, Angle2, 0, Points, Count);
Inc(Count,2);
ReallocMem(Points, Count*SizeOf(TPoint));
Points[Count - 2] := CenterPoint(Rect(X,Y,X+Width,Y+Height));
Points[Count - 1] := Points[0];
Polygon(DC, Points, Count, True);
ReallocMem(Points, 0);
Result := True;
Result := RadialPie(DC,
Min(EllipseX1,EllipseX2), Min(EllipseY1,EllipseY2),
Abs(EllipseX2-EllipseX1), Abs(EllipseY2-EllipseY1),
StartX,StartY, EndX,EndY);
end;
function TInterfaceBase.PolyBezier(DC: HDC; Points: PPoint; NumPts: Integer;
@ -1417,7 +1408,26 @@ var
A1, A2 : Extended;
Begin
Coords2Angles(x,y,width,height,sx,sy,ex,ey,A1,A2);
Result := Pie(DC, X, Y, Width, Height, Round(A1), Round(A2));
Result := RadialPieWithAngles(DC, X, Y, Width, Height, Round(A1), Round(A2));
End;
function TInterfaceBase.RadialPieWithAngles(DC: HDC; X,Y,Width,Height,
Angle1, Angle2: Integer): Boolean;
var
Points : PPoint;
Count : Longint;
begin
Result := False;
Points := nil;
Count := 0;
PolyBezierArcPoints(X,Y,Width,Height,Angle1, Angle2, 0, Points, Count);
Inc(Count,2);
ReallocMem(Points, Count*SizeOf(TPoint));
Points[Count - 2] := CenterPoint(Rect(X,Y,X+Width,Y+Height));
Points[Count - 1] := Points[0];
Polygon(DC, Points, Count, True);
ReallocMem(Points, 0);
Result := True;
End;
function TInterfaceBase.RadioMenuItemGroup(hndMenu: HMENU; bRadio: Boolean): Boolean;
@ -1525,10 +1535,10 @@ begin
Pen := SelectObject(DC, GetStockObject(NULL_PEN));
Pie(DC, X1, Y1, RX, RY, 90*16,90*16);
Pie(DC, X2 - RX, Y1, RX, RY, 0, 90*16);
Pie(DC, X1, Y2 - RY, RX, RY, 180*16,90*16);
Pie(DC, X2 - RX, Y2 - RY, RX, RY, 270*16,90*16);
RadialPieWithAngles(DC, X1, Y1, RX, RY, 90*16,90*16);
RadialPieWithAngles(DC, X2 - RX, Y1, RX, RY, 0, 90*16);
RadialPieWithAngles(DC, X1, Y2 - RY, RX, RY, 180*16,90*16);
RadialPieWithAngles(DC, X2 - RX, Y2 - RY, RX, RY, 270*16,90*16);
Rectangle(DC, X1 + (RX div 2) - 1, Y1, X2 - (RX div 2) + 1, Y2 + 1);
Rectangle(DC, X1, Y1 + (RY div 2) - 1, X2 + 1, Y2 - (RY div 2) + 1);
@ -1810,6 +1820,9 @@ end;
{ =============================================================================
$Log$
Revision 1.99 2003/08/18 19:24:18 mattias
fixed TCanvas.Pie
Revision 1.98 2003/07/20 06:39:03 mattias
added comments

View File

@ -750,9 +750,11 @@ begin
wMsgFilterMin,wMsgFilterMax,wRemoveMsg);
end;
function Pie(DC: HDC; x,y,width,height,angle1,angle2 : Integer): Boolean;
function Pie(DC: HDC; EllipseX1,EllipseY1,EllipseX2,EllipseY2,
StartX,StartY,EndX,EndY: Integer): Boolean;
begin
Result := InterfaceObject.Pie(DC,x,y,width,height,angle1,angle2);
Result := InterfaceObject.Pie(DC,EllipseX1,EllipseY1,EllipseX2,EllipseY2,
StartX,StartY,EndX,EndY);
end;
function PolyBezier(DC: HDC; Points: PPoint; NumPts: Integer;
@ -772,7 +774,8 @@ begin
Result := InterfaceObject.Polyline(DC,Points,NumPts);
end;
function PostMessage(Handle: HWND; Msg: Cardinal; wParam: LongInt; lParam: LongInt): Boolean;
function PostMessage(Handle: HWND; Msg: Cardinal; wParam: LongInt;
lParam: LongInt): Boolean;
begin
Result := InterfaceObject.PostMessage(Handle, Msg, wParam, lParam);
end;
@ -797,6 +800,13 @@ begin
Result := InterfaceObject.RadialPie(DC, x,y,width,height,sx,sy,ex,ey);
end;
function RadialPieWithAngles(DC: HDC; X,Y,Width,Height,
Angle1,Angle2: Integer): Boolean;
begin
Result := InterfaceObject.RadialPieWithAngles(DC,
X,Y,Width,Height,Angle1,Angle2);
end;
function RadioMenuItemGroup(hndMenu: HMENU; bRadio: Boolean): Boolean;
begin
Result := InterfaceObject.RadioMenuItemGroup(hndMenu,bRadio);
@ -1660,6 +1670,9 @@ end;
{ =============================================================================
$Log$
Revision 1.94 2003/08/18 19:24:18 mattias
fixed TCanvas.Pie
Revision 1.93 2003/07/29 00:28:42 marc
+ Implemented GetCursorPos

View File

@ -199,7 +199,8 @@ function PairSplitterAddSide(SplitterHandle, SideHandle: hWnd; Side: integer): B
function PairSplitterRemoveSide(SplitterHandle, SideHandle: hWnd; Side: integer): Boolean; {$IFDEF IF_BASE_MEMBER}virtual;{$ENDIF}
function PairSplitterSetPosition(SplitterHandle: hWnd; var NewPosition: integer): Boolean; {$IFDEF IF_BASE_MEMBER}virtual;{$ENDIF}
function PeekMessage(var lpMsg : TMsg; Handle : HWND; wMsgFilterMin, wMsgFilterMax,wRemoveMsg : UINT): Boolean; {$IFDEF IF_BASE_MEMBER}virtual;{$ENDIF}
function Pie(DC: HDC; x,y,width,height,angle1,angle2 : Integer): Boolean; {$IFDEF IF_BASE_MEMBER}virtual;{$ENDIF}
function Pie(DC: HDC; EllipseX1,EllipseY1,EllipseX2,EllipseY2,
StartX,StartY,EndX,EndY: Integer): Boolean; {$IFDEF IF_BASE_MEMBER}virtual;{$ENDIF}
function PolyBezier(DC: HDC; Points: PPoint; NumPts: Integer; Filled, Continuous: boolean): boolean; {$IFDEF IF_BASE_MEMBER}virtual;{$ENDIF}
function Polygon(DC: HDC; Points: PPoint; NumPts: Integer; Winding: boolean): boolean; {$IFDEF IF_BASE_MEMBER}virtual;{$ENDIF}
function Polyline(DC: HDC; Points: PPoint; NumPts: Integer): boolean; {$IFDEF IF_BASE_MEMBER}virtual;{$ENDIF}
@ -226,6 +227,7 @@ Function RequestInput(const InputCaption, InputPrompt : String; MaskInput : Bool
function RadialArc(DC: HDC; x,y,width,height,sx,sy,ex,ey : Integer): Boolean; {$IFDEF IF_BASE_MEMBER}virtual;{$ENDIF}
function RadialChord(DC: HDC; x,y,width,height,sx,sy,ex,ey : Integer): Boolean; {$IFDEF IF_BASE_MEMBER}virtual;{$ENDIF}
function RadialPie(DC: HDC; x,y,width,height,sx,sy,ex,ey : Integer): Boolean; {$IFDEF IF_BASE_MEMBER}virtual;{$ENDIF}
function RadialPieWithAngles(DC: HDC; X,Y,Width,Height,Angle1,Angle2: Integer): Boolean; {$IFDEF IF_BASE_MEMBER}virtual;{$ENDIF}
function RadioMenuItemGroup(hndMenu: HMENU; bRadio: Boolean): Boolean; {$IFDEF IF_BASE_MEMBER}virtual;{$ENDIF}
function RealizePalette(DC: HDC): Cardinal; {$IFDEF IF_BASE_MEMBER}virtual;{$ENDIF}
function Rectangle(DC: HDC; X1, Y1, X2, Y2: Integer): Boolean; {$IFDEF IF_BASE_MEMBER}virtual;{$ENDIF}
@ -389,6 +391,9 @@ procedure RaiseLastOSError;
{ =============================================================================
$Log$
Revision 1.84 2003/08/18 19:24:18 mattias
fixed TCanvas.Pie
Revision 1.83 2003/07/06 20:40:34 mattias
TWinControl.WmSize/Move now updates interface messages smarter

View File

@ -105,6 +105,8 @@ var
implementation
uses Math;
{$I interfacebase.inc}
initialization
@ -118,6 +120,9 @@ end.
{
$Log$
Revision 1.32 2003/08/18 19:24:18 mattias
fixed TCanvas.Pie
Revision 1.31 2003/08/12 23:51:51 marc
+ Introduced interface exceptions

View File

@ -5803,35 +5803,6 @@ begin
end;
end;
{------------------------------------------------------------------------------
Method: Pie
Params: DC,x,y,width,height,angle1,angle2
Returns: Nothing
Use Pie to draw a filled pie-shaped wedge on the canvas.
The angles angle1 and angle2 are 1/16th of a degree. For example, a full
circle equals 5760 (16*360). Positive values of Angle and AngleLength mean
counter-clockwise while negative values mean clockwise direction.
Zero degrees is at the 3'o clock position.
------------------------------------------------------------------------------}
function TgtkObject.Pie(DC: HDC;
x,y,width,height,angle1,angle2 : Integer): Boolean;
begin
Result := IsValidDC(DC);
if Result
then with TDeviceContext(DC) do
begin
if GC = nil
then begin
WriteLn('WARNING: [TgtkObject.Pie] Uninitialized GC');
Result := False;
end
else
Result := Inherited Pie(DC, x, y, width, height, angle1, angle2);
end;
end;
{------------------------------------------------------------------------------
Method: PolyBezier
Params: DC, Points, NumPts, Filled, Continous
@ -8730,6 +8701,9 @@ end;
{ =============================================================================
$Log$
Revision 1.269 2003/08/18 19:24:18 mattias
fixed TCanvas.Pie
Revision 1.268 2003/08/18 13:21:23 mattias
renamed lazqueue to lazlinkedlist, patch from Jeroen

View File

@ -143,7 +143,6 @@ function PairSplitterAddSide(SplitterHandle, SideHandle: hWnd; Side: integer): B
function PairSplitterRemoveSide(SplitterHandle, SideHandle: hWnd; Side: integer): Boolean; override;
function PairSplitterSetPosition(SplitterHandle: hWnd; var NewPosition: integer): Boolean; override;
function PeekMessage(var lpMsg : TMsg; Handle : HWND; wMsgFilterMin, wMsgFilterMax,wRemoveMsg : UINT): Boolean; override;
function Pie(DC: HDC; x,y,width,height,angle1,angle2 : Integer): Boolean; override;
function PolyBezier(DC: HDC; Points: PPoint; NumPts: Integer; Filled, Continuous: boolean): boolean; override;
function Polygon(DC: HDC; Points: PPoint; NumPts: Integer; Winding: boolean): boolean; override;
function Polyline(DC: HDC; Points: PPoint; NumPts: Integer): boolean; override;
@ -212,6 +211,9 @@ Procedure DeleteCriticalSection(var CritSection: TCriticalSection); Override;
{ =============================================================================
$Log$
Revision 1.75 2003/08/18 19:24:18 mattias
fixed TCanvas.Pie
Revision 1.74 2003/07/29 00:28:43 marc
+ Implemented GetCursorPos

View File

@ -1657,29 +1657,6 @@ Begin
Result := Windows.PeekMessage(@LPMsg, Handle, WMsgFilterMin, WMsgFilterMax, WRemoveMsg);
End;
{------------------------------------------------------------------------------
Method: Pie
Params: DC, X, Y, Width, Height, Angle1, Angle2
Returns: Nothing
Use Pie to draw a filled pie-shaped wedge on the canvas.
The angles angle1 and angle2 are 1/16th of a degree. For example, a full
circle equals 5760 (16*360). Positive values of Angle and AngleLength mean
counter-clockwise while negative values mean clockwise direction.
Zero degrees is at the 3'o clock position.
NOTE: This just calls Arc
------------------------------------------------------------------------------}
Function TWin32Object.Pie(DC: HDC;
X, Y, Width, Height, Angle1, Angle2: Integer): Boolean;
var
SX, SY, EX, EY : Longint;
Begin
// Old: Result := Arc(DC, X, Y, Width, Height, Angle1, Angle2);
Angles2Coords(X,Y,Width,Height,Angle1,Angle2, SX, SY, EX, EY);
Result := Windows.Pie(DC, X, Y, X+Width, Y+Height, SX,SY,EX,EY);
End;
{------------------------------------------------------------------------------
Method: PolyBezier
Params: DC, Points, NumPts, Filled, Continous
@ -2446,6 +2423,9 @@ end;
{ =============================================================================
$Log$
Revision 1.53 2003/08/18 19:24:18 mattias
fixed TCanvas.Pie
Revision 1.52 2003/08/17 12:51:35 mattias
added directory selection dialog from Vincent

View File

@ -121,7 +121,6 @@ Function MessageBox(HWnd: HWND; LPText, LPCaption: PChar; UType: Cardinal): Inte
Function MoveToEx(DC: HDC; X, Y: Integer; OldPoint: PPoint): Boolean; Override;
Function PeekMessage(Var LPMsg: TMsg; Handle: HWND; WMsgFilterMin, WMsgFilterMax, WRemoveMsg: UINT): Boolean; Override;
Function Pie(DC: HDC; X, Y, Width, Height, Angle1, Angle2: Integer): Boolean; Override;
Function PolyBezier(DC: HDC; Points: PPoint; NumPts: Integer; Filled, Continuous: Boolean): Boolean; Override;
Function Polygon(DC: HDC; Points: PPoint; NumPts: Integer; Winding: Boolean): Boolean; Override;
Function Polyline(DC: HDC; Points: PPoint; NumPts: Integer): Boolean; Override;
@ -179,6 +178,9 @@ Procedure DeleteCriticalSection(var CritSection: TCriticalSection); Override;
{ =============================================================================
$Log$
Revision 1.32 2003/08/18 19:24:18 mattias
fixed TCanvas.Pie
Revision 1.31 2003/08/13 21:23:10 mattias
fixed log