From 5dfcb11f1e45fb12ca1bda65d085235e7c863625 Mon Sep 17 00:00:00 2001 From: zeljko Date: Sat, 4 Aug 2007 14:55:43 +0000 Subject: [PATCH] (Qt): QtWSArrow, draw arrows by qstyle elements. git-svn-id: trunk@11739 - --- lcl/interfaces/qt/qtlclintf.inc | 107 +++++--------------------------- lcl/interfaces/qt/qtwsarrow.pp | 52 ---------------- 2 files changed, 14 insertions(+), 145 deletions(-) diff --git a/lcl/interfaces/qt/qtlclintf.inc b/lcl/interfaces/qt/qtlclintf.inc index 85810dbecf..1478bbc14f 100644 --- a/lcl/interfaces/qt/qtlclintf.inc +++ b/lcl/interfaces/qt/qtlclintf.inc @@ -86,106 +86,27 @@ end; procedure TQtWidgetSet.DrawArrow(Arrow: TComponent; Canvas: TPersistent); var DC: TQtDeviceContext; - APoints: Array [0..2] of TPoint; ArrowType: Integer; - ARect: TRect; - Brush: QBrushH; - Pen: QPenH; + Rect: TRect; + StyleOption: QStyleOptionH; begin DC := TQtDeviceContext(TCanvas(Canvas).Handle); - - ARect := TControl(Arrow).ClientRect; + Rect := TControl(Arrow).ClientRect; ArrowType := Ord(TArrow(Arrow).ArrowType); - case ArrowType of - 0:{up} - begin - {$ifdef QT_USE_BIG_TARROW} - APoints[0].X := ARect.Right div 2; - APoints[0].Y := ARect.Bottom div 3; - APoints[1].X := (ARect.Right div 8); - APoints[1].Y := ARect.Bottom - (ARect.Bottom div 3); - APoints[2].X := ARect.Right - (ARect.Right div 8); - 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); + StyleOption := QStyleOption_create(1, 0); //QStyleOptionSO_Default + try + QStyleOption_initFrom(StyleOption, DC.Parent); + QStyleOption_setRect(StyleOption, @Rect); + case ArrowType of + 0: QStyle_drawPrimitive(QApplication_style, QStylePE_IndicatorArrowUp, StyleOption, DC.Widget, DC.Parent); + 1: QStyle_drawPrimitive(QApplication_style, QStylePE_IndicatorArrowDown, StyleOption, DC.Widget, DC.Parent); + 2: QStyle_drawPrimitive(QApplication_style, QStylePE_IndicatorArrowLeft, StyleOption, DC.Widget, DC.Parent); + 3: QStyle_drawPrimitive(QApplication_style, QStylePE_IndicatorArrowRight, StyleOption, DC.Widget, DC.Parent); end; + finally + QStyleOption_destroy(StyleOption); end; end; diff --git a/lcl/interfaces/qt/qtwsarrow.pp b/lcl/interfaces/qt/qtwsarrow.pp index 8c264099dd..4c39f9c9cf 100644 --- a/lcl/interfaces/qt/qtwsarrow.pp +++ b/lcl/interfaces/qt/qtwsarrow.pp @@ -72,30 +72,6 @@ begin 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.AttachEvents; @@ -119,35 +95,7 @@ var begin QtArrow := TQtArrow(AArrow.Handle); 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); - - end; end; initialization