From bfc3350f00652fcf3c34a2c93a4820c7b62e09bc Mon Sep 17 00:00:00 2001 From: zeljko Date: Fri, 17 Sep 2010 06:33:19 +0000 Subject: [PATCH] Qt: implemented GetBkColor(). part of #14792 git-svn-id: trunk@27390 - --- lcl/interfaces/qt/qtobjects.pas | 18 ++++++++++++++---- lcl/interfaces/qt/qtwinapi.inc | 12 +++++++++++- lcl/interfaces/qt/qtwinapih.inc | 1 + 3 files changed, 26 insertions(+), 5 deletions(-) diff --git a/lcl/interfaces/qt/qtobjects.pas b/lcl/interfaces/qt/qtobjects.pas index 1d761ab320..624d3a7069 100644 --- a/lcl/interfaces/qt/qtobjects.pas +++ b/lcl/interfaces/qt/qtobjects.pas @@ -403,9 +403,10 @@ type function brush: TQtBrush; procedure setBrush(ABrush: TQtBrush); function BackgroundBrush: TQtBrush; + function GetBkColor: TColorRef; function pen: TQtPen; function setPen(APen: TQtPen): TQtPen; - function SetBkColor(Color: TcolorRef): TColorRef; + function SetBkColor(Color: TColorRef): TColorRef; function SetBkMode(BkMode: Integer): Integer; function getDepth: integer; function getDeviceSize: TPoint; @@ -2744,6 +2745,16 @@ begin result := vBackGroundBrush; end; +function TQtDeviceContext.GetBkColor: TColorRef; +var + TheBrush: QBrushH; + TheColor: TQColor; +begin + TheBrush := QPainter_background(Widget); + TheColor := QBrush_color(TheBrush)^; + TQColorToColorRef(TheColor, Result); +end; + {------------------------------------------------------------------------------ Function: TQtDeviceContext.pen Params: None @@ -2824,15 +2835,14 @@ begin Result := FClipboard; end; -function TQtDeviceContext.SetBkColor(Color: TcolorRef): TColorRef; +function TQtDeviceContext.SetBkColor(Color: TColorRef): TColorRef; var NColor: TQColor; begin {$ifdef VerboseQt} Write('TQtDeviceContext.setBKColor() '); {$endif} - NColor := BackgroundBrush.getColor^; - TQColorToColorRef(NColor, Result); + Result := GetBkColor; ColorRefToTQColor(ColorToRGB(Color), NColor); BackgroundBrush.setColor(@NColor); end; diff --git a/lcl/interfaces/qt/qtwinapi.inc b/lcl/interfaces/qt/qtwinapi.inc index 70326e9f65..82e6fa8dbb 100644 --- a/lcl/interfaces/qt/qtwinapi.inc +++ b/lcl/interfaces/qt/qtwinapi.inc @@ -1913,6 +1913,16 @@ begin end; end; +function TQtWidgetSet.GetBkColor(DC: HDC): TColorRef; +var + QtDC: TQtDeviceContext; +begin + Result := CLR_INVALID; + if not IsValidDC(DC) then Exit; + QtDC := TQtDeviceContext(DC); + Result := QtDC.GetBkColor; +end; + function TQtWidgetSet.GetCapture: HWND; var w: QWidgetH; @@ -4699,7 +4709,7 @@ begin Exit; end; - result := TQtDeviceContext(DC).SetBkColor(Color); + Result := TQtDeviceContext(DC).SetBkColor(Color); end; {------------------------------------------------------------------------------ diff --git a/lcl/interfaces/qt/qtwinapih.inc b/lcl/interfaces/qt/qtwinapih.inc index 0959e1a680..0961efc438 100644 --- a/lcl/interfaces/qt/qtwinapih.inc +++ b/lcl/interfaces/qt/qtwinapih.inc @@ -93,6 +93,7 @@ function FrameRect(DC: HDC; const ARect: TRect; hBr: HBRUSH): Integer; override; function GetActiveWindow : HWND; override; function GetBitmapBits(Bitmap: HBITMAP; Count: Longint; Bits: Pointer): Longint; override; +function GetBkColor(DC: HDC): TColorRef; override; function GetCapture: HWND; override; function GetCaretPos(var lpPoint: TPoint): Boolean; override; function GetCaretRespondToFocus(handle: HWND; var ShowHideOnFocus: boolean): Boolean; override;