mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-06-27 01:48:32 +02:00
Implements text rotation on Qt widgetset.
git-svn-id: trunk@10198 -
This commit is contained in:
parent
79c42a0c12
commit
cdfcfafb10
@ -74,6 +74,7 @@ type
|
|||||||
private
|
private
|
||||||
public
|
public
|
||||||
Widget: QFontH;
|
Widget: QFontH;
|
||||||
|
Angle: Integer;
|
||||||
public
|
public
|
||||||
constructor Create(CreateHandle: Boolean); virtual;
|
constructor Create(CreateHandle: Boolean); virtual;
|
||||||
destructor Destroy; override;
|
destructor Destroy; override;
|
||||||
@ -189,6 +190,10 @@ type
|
|||||||
function region: TQtRegion;
|
function region: TQtRegion;
|
||||||
procedure setRegion(region: TQtRegion);
|
procedure setRegion(region: TQtRegion);
|
||||||
procedure drawImage(targetRect: PRect; image: QImageH; sourceRect: PRect; flags: QtImageConversionFlags = QtAutoColor);
|
procedure drawImage(targetRect: PRect; image: QImageH; sourceRect: PRect; flags: QtImageConversionFlags = QtAutoColor);
|
||||||
|
procedure rotate(a: Double);
|
||||||
|
procedure save;
|
||||||
|
procedure restore;
|
||||||
|
procedure translate(dx: Double; dy: Double);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ TQtPixmap }
|
{ TQtPixmap }
|
||||||
@ -767,15 +772,23 @@ var
|
|||||||
QtFontMetrics: TQtFontMetrics;
|
QtFontMetrics: TQtFontMetrics;
|
||||||
begin
|
begin
|
||||||
{$ifdef VerboseQt}
|
{$ifdef VerboseQt}
|
||||||
WriteLn('TQtDeviceContext.drawText TargetX: ', (Origin.X + X), ' TargetY: ', (Origin.Y + Y));
|
Write('TQtDeviceContext.drawText TargetX: ', (Origin.X + X), ' TargetY: ', (Origin.Y + Y));
|
||||||
{$endif}
|
{$endif}
|
||||||
|
|
||||||
QtFontMetrics := TQtFontMetrics.Create(Font.Widget);
|
QtFontMetrics := TQtFontMetrics.Create(Font.Widget);
|
||||||
try
|
try
|
||||||
QPainter_drawText(Widget, Origin.X + x, Origin.Y + y + QtFontMetrics.height, s);
|
Save;
|
||||||
|
|
||||||
|
translate(Origin.X + x, Origin.Y + y + QtFontMetrics.height);
|
||||||
|
|
||||||
|
Rotate(-0.1 * vFont.Angle);
|
||||||
|
|
||||||
|
QPainter_drawText(Widget, 0, 0, s);
|
||||||
|
|
||||||
|
Restore;
|
||||||
|
|
||||||
{$ifdef VerboseQt}
|
{$ifdef VerboseQt}
|
||||||
WriteLn(' Font metrics height: ', QtFontMetrics.height);
|
WriteLn(' Font metrics height: ', QtFontMetrics.height, ' Angle: ', Round(0.1 * vFont.Angle));
|
||||||
{$endif}
|
{$endif}
|
||||||
finally
|
finally
|
||||||
QtFontMetrics.Free;
|
QtFontMetrics.Free;
|
||||||
@ -858,7 +871,11 @@ end;
|
|||||||
procedure TQtDeviceContext.setFont(f: TQtFont);
|
procedure TQtDeviceContext.setFont(f: TQtFont);
|
||||||
begin
|
begin
|
||||||
if (f.Widget <> nil) and (Widget <> nil) and (Parent <> nil) then
|
if (f.Widget <> nil) and (Widget <> nil) and (Parent <> nil) then
|
||||||
QPainter_setFont(Widget, QFontH(f.Widget));
|
begin
|
||||||
|
QPainter_setFont(Widget, QFontH(f.Widget));
|
||||||
|
|
||||||
|
vFont.Angle := f.Angle;
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{------------------------------------------------------------------------------
|
{------------------------------------------------------------------------------
|
||||||
@ -944,6 +961,54 @@ begin
|
|||||||
QPainter_drawImage(Widget, PRect(@LocalRect), image, sourceRect, flags);
|
QPainter_drawImage(Widget, PRect(@LocalRect), image, sourceRect, flags);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
{------------------------------------------------------------------------------
|
||||||
|
Function: TQtDeviceContext.rotate
|
||||||
|
Params: None
|
||||||
|
Returns: Nothing
|
||||||
|
|
||||||
|
Rotates the coordinate system
|
||||||
|
------------------------------------------------------------------------------}
|
||||||
|
procedure TQtDeviceContext.rotate(a: Double);
|
||||||
|
begin
|
||||||
|
QPainter_rotate(Widget, a);
|
||||||
|
end;
|
||||||
|
|
||||||
|
{------------------------------------------------------------------------------
|
||||||
|
Function: TQtDeviceContext.save
|
||||||
|
Params: None
|
||||||
|
Returns: Nothing
|
||||||
|
|
||||||
|
Saves the state of the canvas
|
||||||
|
------------------------------------------------------------------------------}
|
||||||
|
procedure TQtDeviceContext.save;
|
||||||
|
begin
|
||||||
|
QPainter_save(Widget);
|
||||||
|
end;
|
||||||
|
|
||||||
|
{------------------------------------------------------------------------------
|
||||||
|
Function: TQtDeviceContext.restore
|
||||||
|
Params: None
|
||||||
|
Returns: Nothing
|
||||||
|
|
||||||
|
Restores the state of the canvas
|
||||||
|
------------------------------------------------------------------------------}
|
||||||
|
procedure TQtDeviceContext.restore;
|
||||||
|
begin
|
||||||
|
QPainter_restore(Widget);
|
||||||
|
end;
|
||||||
|
|
||||||
|
{------------------------------------------------------------------------------
|
||||||
|
Function: TQtDeviceContext.translate
|
||||||
|
Params: None
|
||||||
|
Returns: Nothing
|
||||||
|
|
||||||
|
Tranlates the coordinate system
|
||||||
|
------------------------------------------------------------------------------}
|
||||||
|
procedure TQtDeviceContext.translate(dx: Double; dy: Double);
|
||||||
|
begin
|
||||||
|
QPainter_translate(Widget, dx, dy);
|
||||||
|
end;
|
||||||
|
|
||||||
{ TQtPixmap }
|
{ TQtPixmap }
|
||||||
|
|
||||||
constructor TQtPixmap.Create(p1: PSize);
|
constructor TQtPixmap.Create(p1: PSize);
|
||||||
|
@ -289,7 +289,9 @@ begin
|
|||||||
FW_HEAVY : QtFont.setWeight(87);
|
FW_HEAVY : QtFont.setWeight(87);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
// LogFont.lfOrientation: Longint;
|
QtFont.Angle := LogFont.lfEscapement;
|
||||||
|
|
||||||
|
//LogFont.lfOrientation;
|
||||||
|
|
||||||
QtFont.setItalic(LogFont.lfItalic = High(Byte));
|
QtFont.setItalic(LogFont.lfItalic = High(Byte));
|
||||||
QtFont.setUnderline(LogFont.lfUnderline = High(Byte));
|
QtFont.setUnderline(LogFont.lfUnderline = High(Byte));
|
||||||
|
Loading…
Reference in New Issue
Block a user