mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-12-16 02:00:30 +01:00
lcl: add TCanvas.AntialiasingMode
qt: implement DCSetAntialiasing git-svn-id: trunk@17392 -
This commit is contained in:
parent
90d0441b14
commit
36ed21e333
@ -928,13 +928,22 @@ type
|
||||
EInvalidGraphicOperation = class(EGraphicException);
|
||||
|
||||
type
|
||||
TGradientDirection = (gdVertical, // Fill vertical
|
||||
gdHorizontal); // Fill Horizontal
|
||||
TGradientDirection = (
|
||||
gdVertical, // Fill vertical
|
||||
gdHorizontal // Fill Horizontal
|
||||
);
|
||||
|
||||
TAntialiasingMode = (
|
||||
amDontCare, // default antialiasing
|
||||
amOn, // enabled
|
||||
amOff // disabled
|
||||
);
|
||||
|
||||
{ TCanvas }
|
||||
|
||||
TCanvas = class(TFPCustomCanvas)
|
||||
private
|
||||
FAntialiasingMode: TAntialiasingMode;
|
||||
FAutoRedraw: Boolean;
|
||||
FState: TCanvasState;
|
||||
FSavedFontHandle: HFont;
|
||||
@ -957,6 +966,7 @@ type
|
||||
procedure PenChanged(APen: TObject);
|
||||
procedure RegionChanged(ARegion: TObject);
|
||||
function GetHandle: HDC;
|
||||
procedure SetAntialiasingMode(const AValue: TAntialiasingMode);
|
||||
procedure SetAutoRedraw(Value: Boolean); virtual;
|
||||
procedure SetLazFont(value: TFont);
|
||||
procedure SetLazPen(value: TPen);
|
||||
@ -1011,6 +1021,7 @@ type
|
||||
procedure BrushChanging(APen: TObject); virtual;
|
||||
procedure RegionChanging(APen: TObject); virtual;
|
||||
procedure RealizeAutoRedraw; virtual;
|
||||
procedure RealizeAntialiasing; virtual;
|
||||
procedure RequiredState(ReqState: TCanvasState); virtual;
|
||||
procedure SetHandle(NewHandle: HDC); virtual;
|
||||
procedure SetInternalPenPos(const Value: TPoint); virtual;
|
||||
@ -1098,14 +1109,15 @@ type
|
||||
property Handle: HDC read GetHandle write SetHandle;
|
||||
property TextStyle: TTextStyle read FTextStyle write FTextStyle;
|
||||
published
|
||||
property AntialiasingMode: TAntialiasingMode read FAntialiasingMode write SetAntialiasingMode default amDontCare;
|
||||
property AutoRedraw: Boolean read FAutoRedraw write SetAutoRedraw;
|
||||
property Brush: TBrush read FBrush write SetLazBrush;
|
||||
property CopyMode: TCopyMode read FCopyMode write FCopyMode default cmSrcCopy;
|
||||
property Font: TFont read FFont write SetLazFont;
|
||||
property Height : integer read GetHeight;
|
||||
property Height: integer read GetHeight;
|
||||
property Pen: TPen read FPen write SetLazPen;
|
||||
property Region: TRegion read FRegion write SetRegion;
|
||||
property Width : integer read GetWidth;
|
||||
property Width: integer read GetWidth;
|
||||
property OnChange: TNotifyEvent read FOnChange write FOnChange;
|
||||
property OnChanging: TNotifyEvent read FOnChanging write FOnChanging;
|
||||
end;
|
||||
|
||||
@ -122,6 +122,19 @@ begin
|
||||
WidgetSet.DCRedraw(Handle);
|
||||
end;
|
||||
|
||||
procedure TCanvas.RealizeAntialiasing;
|
||||
begin
|
||||
if (FAntialiasingMode <> amDontCare) and HandleAllocated then
|
||||
begin
|
||||
Changing;
|
||||
case FAntialiasingMode of
|
||||
amOn: WidgetSet.DCSetAntialiasing(FHandle, True);
|
||||
amOff: WidgetSet.DCSetAntialiasing(FHandle, False);
|
||||
end;
|
||||
Changed;
|
||||
end;
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
Method: TCanvas.CreateBrush
|
||||
Params: None
|
||||
@ -1364,6 +1377,7 @@ begin
|
||||
FRegion.OnChange := @RegionChanged;
|
||||
FSavedRegionHandle := 0;
|
||||
FCopyMode := cmSrcCopy;
|
||||
FAntialiasingMode := amDontCare;
|
||||
// FLock will be initialized on demand, because most canvas don't use it
|
||||
with FTextStyle do
|
||||
begin
|
||||
@ -1451,6 +1465,15 @@ begin
|
||||
Result := FHandle;
|
||||
end;
|
||||
|
||||
procedure TCanvas.SetAntialiasingMode(const AValue: TAntialiasingMode);
|
||||
begin
|
||||
if FAntialiasingMode <> AValue then
|
||||
begin
|
||||
FAntialiasingMode := AValue;
|
||||
RealizeAntialiasing;
|
||||
end;
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
Method: TCanvas.SetHandle
|
||||
Params: NewHandle - the new device context
|
||||
@ -1472,6 +1495,7 @@ begin
|
||||
FHandle := NewHandle;
|
||||
if FHandle <> 0 then
|
||||
begin
|
||||
RealizeAntialiasing;
|
||||
Include(FState, csHandleValid);
|
||||
end;
|
||||
//DebugLn('[TCanvas.SetHandle] END Self=',DbgS(Self),' Handle=',DbgS(FHandle,8));
|
||||
@ -1540,6 +1564,7 @@ begin
|
||||
CreateHandle;
|
||||
if FHandle = 0 then
|
||||
raise EInvalidOperation.Create(rsCanvasDoesNotAllowDrawing);
|
||||
RealizeAntialiasing;
|
||||
Include(FState, csHandleValid);
|
||||
end;
|
||||
if csFontValid in Needed then CreateFont;
|
||||
|
||||
@ -71,3 +71,7 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TWidgetSet.DCSetAntialiasing(CanvasHandle: HDC; AEnabled: Boolean);
|
||||
begin
|
||||
end;
|
||||
|
||||
|
||||
@ -105,6 +105,7 @@ type
|
||||
function DCGetPixel(CanvasHandle: HDC; X, Y: integer): TGraphicsColor; virtual; abstract;
|
||||
procedure DCSetPixel(CanvasHandle: HDC; X, Y: integer; AColor: TGraphicsColor); virtual; abstract;
|
||||
procedure DCRedraw(CanvasHandle: HDC); virtual; abstract;
|
||||
procedure DCSetAntialiasing(CanvasHandle: HDC; AEnabled: Boolean); virtual;
|
||||
procedure SetDesigning(AComponent: TComponent); virtual; abstract;
|
||||
|
||||
function InitHintFont(HintFont: TObject): Boolean; virtual;
|
||||
|
||||
@ -105,6 +105,7 @@ type
|
||||
function DCGetPixel(CanvasHandle: HDC; X, Y: integer): TGraphicsColor; override;
|
||||
procedure DCSetPixel(CanvasHandle: HDC; X, Y: integer; AColor: TGraphicsColor); override;
|
||||
procedure DCRedraw(CanvasHandle: HDC); override;
|
||||
procedure DCSetAntialiasing(CanvasHandle: HDC; AEnabled: Boolean); override;
|
||||
procedure SetDesigning(AComponent: TComponent); override;
|
||||
|
||||
function InitHintFont(HintFont: TObject): Boolean; override;
|
||||
|
||||
@ -415,6 +415,14 @@ begin
|
||||
// TODO: implement me
|
||||
end;
|
||||
|
||||
procedure TQtWidgetSet.DCSetAntialiasing(CanvasHandle: HDC; AEnabled: Boolean);
|
||||
var
|
||||
DC: TQtDeviceContext absolute CanvasHandle;
|
||||
begin
|
||||
if IsValidDC(CanvasHandle) then
|
||||
DC.setRenderHint(QPainterAntialiasing, AEnabled);
|
||||
end;
|
||||
|
||||
procedure TQtWidgetSet.SetDesigning(AComponent: TComponent);
|
||||
begin
|
||||
|
||||
|
||||
@ -336,6 +336,7 @@ type
|
||||
procedure getBrushOrigin(retval: PPoint);
|
||||
function getClipping: Boolean;
|
||||
function getCompositionMode: QPainterCompositionMode;
|
||||
procedure setCompositionMode(mode: QPainterCompositionMode);
|
||||
procedure getPenPos(retval: PPoint);
|
||||
function getWorldMatrix: QMatrixH;
|
||||
procedure setBrushOrigin(x, y: Integer);
|
||||
@ -352,7 +353,6 @@ type
|
||||
function SetBkMode(BkMode: Integer): Integer;
|
||||
function getDeviceSize: TPoint;
|
||||
function getRegionType(ARegion: QRegionH): integer;
|
||||
procedure setCompositionMode(mode: QPainterCompositionMode);
|
||||
function getClipRegion: TQtRegion;
|
||||
procedure setClipping(const AValue: Boolean);
|
||||
procedure setClipRegion(ARegion: QRegionH; AOperation: QtClipOperation = QtReplaceClip);
|
||||
@ -360,6 +360,7 @@ type
|
||||
procedure drawImage(targetRect: PRect; image: QImageH; sourceRect: PRect;
|
||||
mask: QImageH; maskRect: PRect; flags: QtImageConversionFlags = QtAutoColor);
|
||||
procedure rotate(a: Double);
|
||||
procedure setRenderHint(AHint: QPainterRenderHint; AValue: Boolean);
|
||||
procedure save;
|
||||
procedure restore;
|
||||
procedure translate(dx: Double; dy: Double);
|
||||
@ -2582,6 +2583,11 @@ begin
|
||||
QPainter_rotate(Widget, a);
|
||||
end;
|
||||
|
||||
procedure TQtDeviceContext.setRenderHint(AHint: QPainterRenderHint; AValue: Boolean);
|
||||
begin
|
||||
QPainter_setRenderHint(Widget, AHint, AValue);
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
Function: TQtDeviceContext.save
|
||||
Params: None
|
||||
|
||||
Loading…
Reference in New Issue
Block a user