mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-06-20 17:08:40 +02:00
(Qt): QtWSArrow, draw arrows by qstyle elements.
git-svn-id: trunk@11739 -
This commit is contained in:
parent
f51fb2b0b1
commit
5dfcb11f1e
@ -86,106 +86,27 @@ end;
|
|||||||
procedure TQtWidgetSet.DrawArrow(Arrow: TComponent; Canvas: TPersistent);
|
procedure TQtWidgetSet.DrawArrow(Arrow: TComponent; Canvas: TPersistent);
|
||||||
var
|
var
|
||||||
DC: TQtDeviceContext;
|
DC: TQtDeviceContext;
|
||||||
APoints: Array [0..2] of TPoint;
|
|
||||||
ArrowType: Integer;
|
ArrowType: Integer;
|
||||||
ARect: TRect;
|
Rect: TRect;
|
||||||
Brush: QBrushH;
|
StyleOption: QStyleOptionH;
|
||||||
Pen: QPenH;
|
|
||||||
begin
|
begin
|
||||||
|
|
||||||
DC := TQtDeviceContext(TCanvas(Canvas).Handle);
|
DC := TQtDeviceContext(TCanvas(Canvas).Handle);
|
||||||
|
Rect := TControl(Arrow).ClientRect;
|
||||||
ARect := TControl(Arrow).ClientRect;
|
|
||||||
ArrowType := Ord(TArrow(Arrow).ArrowType);
|
ArrowType := Ord(TArrow(Arrow).ArrowType);
|
||||||
|
|
||||||
case ArrowType of
|
StyleOption := QStyleOption_create(1, 0); //QStyleOptionSO_Default
|
||||||
0:{up}
|
try
|
||||||
begin
|
QStyleOption_initFrom(StyleOption, DC.Parent);
|
||||||
{$ifdef QT_USE_BIG_TARROW}
|
QStyleOption_setRect(StyleOption, @Rect);
|
||||||
APoints[0].X := ARect.Right div 2;
|
case ArrowType of
|
||||||
APoints[0].Y := ARect.Bottom div 3;
|
0: QStyle_drawPrimitive(QApplication_style, QStylePE_IndicatorArrowUp, StyleOption, DC.Widget, DC.Parent);
|
||||||
APoints[1].X := (ARect.Right div 8);
|
1: QStyle_drawPrimitive(QApplication_style, QStylePE_IndicatorArrowDown, StyleOption, DC.Widget, DC.Parent);
|
||||||
APoints[1].Y := ARect.Bottom - (ARect.Bottom div 3);
|
2: QStyle_drawPrimitive(QApplication_style, QStylePE_IndicatorArrowLeft, StyleOption, DC.Widget, DC.Parent);
|
||||||
APoints[2].X := ARect.Right - (ARect.Right div 8);
|
3: QStyle_drawPrimitive(QApplication_style, QStylePE_IndicatorArrowRight, StyleOption, DC.Widget, DC.Parent);
|
||||||
APoints[2].Y := ARect.Bottom - (ARect.Bottom div 3);
|
|
||||||
{$else}
|
|
||||||
APoints[0].X := ARect.Right div 2;
|
|
||||||
APoints[0].Y := ARect.Bottom div 4;
|
|
||||||
APoints[1].X := (ARect.Right div 4);
|
|
||||||
APoints[1].Y := ARect.Bottom - (ARect.Bottom div 4);
|
|
||||||
APoints[2].X := ARect.Right - (ARect.Right div 4);
|
|
||||||
APoints[2].Y := ARect.Bottom - (ARect.Bottom div 4);
|
|
||||||
{$endif}
|
|
||||||
end;
|
|
||||||
1:{down}
|
|
||||||
begin
|
|
||||||
{$ifdef QT_USE_BIG_TARROW}
|
|
||||||
APoints[0].X := ARect.Right div 8;
|
|
||||||
APoints[0].Y := ARect.Bottom div 3;
|
|
||||||
APoints[1].X := ARect.Right - (ARect.Right div 8);
|
|
||||||
APoints[1].Y := (ARect.Bottom div 3);
|
|
||||||
APoints[2].X := ARect.Right div 2;
|
|
||||||
APoints[2].Y := ARect.Bottom - (ARect.Bottom div 3);
|
|
||||||
{$else}
|
|
||||||
APoints[0].X := ARect.Right div 4;
|
|
||||||
APoints[0].Y := ARect.Bottom div 4;
|
|
||||||
APoints[1].X := ARect.Right - (ARect.Right div 4);
|
|
||||||
APoints[1].Y := (ARect.Bottom div 4);
|
|
||||||
APoints[2].X := ARect.Right div 2;
|
|
||||||
APoints[2].Y := ARect.Bottom - (ARect.Bottom div 4);
|
|
||||||
{$endif}
|
|
||||||
end;
|
|
||||||
2:{left}
|
|
||||||
begin
|
|
||||||
{$ifdef QT_USE_BIG_TARROW}
|
|
||||||
APoints[0].X := ARect.Right - (ARect.Right div 3);
|
|
||||||
APoints[0].Y := ARect.Bottom div 8;
|
|
||||||
APoints[1].X := ARect.Right - (ARect.Right div 3);
|
|
||||||
APoints[1].Y := ARect.Bottom - (ARect.Bottom div 8);
|
|
||||||
APoints[2].X := ARect.Right div 3;
|
|
||||||
APoints[2].Y := ARect.Bottom div 2;
|
|
||||||
{$else}
|
|
||||||
APoints[0].X := ARect.Right - (ARect.Right div 4);
|
|
||||||
APoints[0].Y := ARect.Bottom div 4;
|
|
||||||
APoints[1].X := ARect.Right - (ARect.Right div 4);
|
|
||||||
APoints[1].Y := ARect.Bottom - (ARect.Bottom div 4);
|
|
||||||
APoints[2].X := (ARect.Right div 4);
|
|
||||||
APoints[2].Y := ARect.Bottom div 2;
|
|
||||||
{$endif}
|
|
||||||
end;
|
|
||||||
3:{right}
|
|
||||||
begin
|
|
||||||
{$ifdef QT_USE_BIG_TARROW}
|
|
||||||
APoints[0].X := ARect.Right div 3;
|
|
||||||
APoints[0].Y := ARect.Bottom div 8;
|
|
||||||
APoints[1].X := ARect.Right div 3;
|
|
||||||
APoints[1].Y := ARect.Bottom - (ARect.Bottom div 8);
|
|
||||||
APoints[2].X := ARect.Right - (ARect.Right div 3);
|
|
||||||
APoints[2].Y := ARect.Bottom div 2;
|
|
||||||
{$else}
|
|
||||||
APoints[0].X := ARect.Right div 4;
|
|
||||||
APoints[0].Y := ARect.Bottom div 4;
|
|
||||||
APoints[1].X := ARect.Right div 4;
|
|
||||||
APoints[1].Y := ARect.Bottom - (ARect.Bottom div 4);
|
|
||||||
APoints[2].X := ARect.Right - (ARect.Right div 4);
|
|
||||||
APoints[2].Y := ARect.Bottom div 2;
|
|
||||||
{$endif}
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
|
|
||||||
if ArrowType in [0..3] then
|
|
||||||
begin
|
|
||||||
Brush := QBrush_create(QtBlack, QtSolidPattern);
|
|
||||||
Pen := QPen_create(Brush, 1);
|
|
||||||
try
|
|
||||||
QPainter_setBrush(DC.Widget, Brush);
|
|
||||||
QPainter_setPen(DC.Widget, Pen);
|
|
||||||
QPainter_setRenderHint(DC.Widget, QPainterAntialiasing, True);
|
|
||||||
QPainter_drawPolygon(DC.Widget, @APoints, 3, QtWindingFill);
|
|
||||||
finally
|
|
||||||
QPen_destroy(Pen);
|
|
||||||
QBrush_destroy(Brush);
|
|
||||||
end;
|
end;
|
||||||
|
finally
|
||||||
|
QStyleOption_destroy(StyleOption);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
@ -72,30 +72,6 @@ begin
|
|||||||
|
|
||||||
QtArrow := TQtArrow.Create(AWinControl, AParams);
|
QtArrow := TQtArrow.Create(AWinControl, AParams);
|
||||||
|
|
||||||
case TArrow(AWinControl).ShadowType of
|
|
||||||
stNone:QFrame_setFrameShape(QFrameH(QtArrow.Widget), QFrameNoFrame);
|
|
||||||
stIn:
|
|
||||||
begin
|
|
||||||
QFrame_setFrameShape(QFrameH(QtArrow.Widget), QFramePanel);
|
|
||||||
QFrame_setFrameShadow(QFrameH(QtArrow.Widget), QFrameSunken);
|
|
||||||
end;
|
|
||||||
stOut:
|
|
||||||
begin
|
|
||||||
QFrame_setFrameShape(QFrameH(QtArrow.Widget), QFramePanel);
|
|
||||||
QFrame_setFrameShadow(QFrameH(QtArrow.Widget), QFrameRaised);
|
|
||||||
end;
|
|
||||||
stEtchedIn:
|
|
||||||
begin
|
|
||||||
QFrame_setFrameShape(QFrameH(QtArrow.Widget), QFrameBox);
|
|
||||||
QFrame_setFrameShadow(QFrameH(QtArrow.Widget), QFrameSunken);
|
|
||||||
end;
|
|
||||||
stEtchedOut:
|
|
||||||
begin
|
|
||||||
QFrame_setFrameShape(QFrameH(QtArrow.Widget), QFrameBox);
|
|
||||||
QFrame_setFrameShadow(QFrameH(QtArrow.Widget), QFrameRaised);
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
|
|
||||||
QtArrow.ArrowType := Ord(TArrow(AWinControl).ArrowType);
|
QtArrow.ArrowType := Ord(TArrow(AWinControl).ArrowType);
|
||||||
|
|
||||||
QtArrow.AttachEvents;
|
QtArrow.AttachEvents;
|
||||||
@ -119,35 +95,7 @@ var
|
|||||||
begin
|
begin
|
||||||
QtArrow := TQtArrow(AArrow.Handle);
|
QtArrow := TQtArrow(AArrow.Handle);
|
||||||
if Assigned(QtArrow) then
|
if Assigned(QtArrow) then
|
||||||
begin
|
|
||||||
|
|
||||||
case AShadowType of
|
|
||||||
stNone: QFrame_setFrameShape(QFrameH(QtArrow.Widget), QFrameNoFrame);
|
|
||||||
stIn:
|
|
||||||
begin
|
|
||||||
QFrame_setFrameShape(QFrameH(QtArrow.Widget), QFramePanel);
|
|
||||||
QFrame_setFrameShadow(QFrameH(QtArrow.Widget), QFrameSunken);
|
|
||||||
end;
|
|
||||||
stOut:
|
|
||||||
begin
|
|
||||||
QFrame_setFrameShape(QFrameH(QtArrow.Widget), QFramePanel);
|
|
||||||
QFrame_setFrameShadow(QFrameH(QtArrow.Widget), QFrameRaised);
|
|
||||||
end;
|
|
||||||
stEtchedIn:
|
|
||||||
begin
|
|
||||||
QFrame_setFrameShape(QFrameH(QtArrow.Widget), QFrameBox);
|
|
||||||
QFrame_setFrameShadow(QFrameH(QtArrow.Widget), QFrameSunken);
|
|
||||||
end;
|
|
||||||
stEtchedOut:
|
|
||||||
begin
|
|
||||||
QFrame_setFrameShape(QFrameH(QtArrow.Widget), QFrameBox);
|
|
||||||
QFrame_setFrameShadow(QFrameH(QtArrow.Widget), QFrameRaised);
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
|
|
||||||
QtArrow.ArrowType := Ord(AArrowType);
|
QtArrow.ArrowType := Ord(AArrowType);
|
||||||
|
|
||||||
end;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
initialization
|
initialization
|
||||||
|
Loading…
Reference in New Issue
Block a user