- add qDrawPlainRect, qDrawShadeRect to TQtDeviceContext
- improve Frame3D (not finished) and FrameRect

git-svn-id: trunk@13676 -
This commit is contained in:
paul 2008-01-09 03:35:30 +00:00
parent 9df9006406
commit a4c149115d
2 changed files with 55 additions and 22 deletions

View File

@ -180,8 +180,10 @@ type
private
public
Widget: QBrushH;
constructor Create(CreateHandle: Boolean; Const AShared: Boolean = False); virtual;
constructor Create(CreateHandle: Boolean; const AShared: Boolean = False); virtual;
destructor Destroy; override;
function getColor: PQColor;
procedure setColor(AColor: PQColor);
procedure setStyle(style: QtBrushStyle);
procedure setTexture(pixmap: QPixmapH);
procedure setTextureImage(image: QImageH);
@ -275,6 +277,12 @@ type
procedure CorrectCoordinates(var ARect: TRect);
public
{ Qt functions }
procedure qDrawPlainRect(x, y, w, h: integer; AColor: PQColor = nil;
lineWidth: Integer = 1; FillBrush: QBrushH = nil);
procedure qDrawShadeRect(x, y, w, h: integer; Palette: QPaletteH = nil; Sunken: Boolean = False;
lineWidth: Integer = 1; midLineWidth: Integer = 0; FillBrush: QBrushH = nil);
procedure drawPoint(x1: Integer; y1: Integer);
procedure drawRect(x1: Integer; y1: Integer; w: Integer; h: Integer);
procedure drawRoundRect(x, y, w, h, rx, ry: Integer);
@ -1107,6 +1115,16 @@ begin
inherited Destroy;
end;
function TQtBrush.getColor: PQColor;
begin
Result := QBrush_Color(Widget);
end;
procedure TQtBrush.setColor(AColor: PQColor);
begin
QBrush_setColor(Widget, AColor);
end;
{------------------------------------------------------------------------------
Function: TQtBrush.setStyle
Params: None
@ -1506,6 +1524,22 @@ begin
if ARect.Bottom > MaxBottom then ARect.Bottom := MaxBottom;}
end;
procedure TQtDeviceContext.qDrawPlainRect(x, y, w, h: integer; AColor: PQColor = nil;
lineWidth: Integer = 1; FillBrush: QBrushH = nil);
begin
if AColor = nil then
AColor := BackgroundBrush.getColor;
q_DrawPlainRect(Widget, x, y, w, h, AColor, lineWidth, FillBrush);
end;
procedure TQtDeviceContext.qDrawShadeRect(x, y, w, h: integer; Palette: QPaletteH = nil; Sunken: Boolean = False;
lineWidth: Integer = 1; midLineWidth: Integer = 0; FillBrush: QBrushH = nil);
begin
if Palette = nil then
Palette := QWidget_palette(Parent);
q_DrawShadeRect(Widget, x, y, w, h, Palette, Sunken, lineWidth, midLineWidth, FillBrush);
end;
{------------------------------------------------------------------------------
Function: TQtDeviceContext.CreateDCData
Params: None
@ -1950,21 +1984,15 @@ end;
function TQtDeviceContext.SetBkColor(Color: TcolorRef): TColorRef;
var
ABrush: QBrushH;
NColor: TQColor;
begin
{$ifdef VerboseQt}
Write('TQtDeviceContext.setBKColor() ');
{$endif}
result := CLR_INVALID;
ABrush := BackgroundBrush.Widget;
if ABrush<>nil then
begin
NColor := QBrush_Color(aBrush)^;
TQColorToColorRef(NColor, Result);
ColorRefToTQColor(ColorToRGB(Color), NColor);
QBrush_setColor(ABrush, @NColor);
end;
NColor := BackgroundBrush.getColor^;
TQColorToColorRef(NColor, Result);
ColorRefToTQColor(ColorToRGB(Color), NColor);
BackgroundBrush.setColor(@NColor);
end;
function TQtDeviceContext.SetBkMode(BkMode: Integer): Integer;

View File

@ -1658,7 +1658,6 @@ end;
function TQtWidgetSet.Frame3d(DC : HDC; var ARect : TRect;
const FrameWidth : integer; const Style : TBevelCut) : boolean;
var
StyleOption: QStyleOptionFrameV2H;
QtDC: TQtDeviceContext;
begin
@ -1669,17 +1668,23 @@ begin
Result := False;
if not IsValidDC(DC) then exit;
QtDC := TQtDeviceContext(DC);
StyleOption := QStyleOptionFrameV2_create;
try
QStyleOption_setRect(StyleOption, @ARect);
QStyle_drawPrimitive(QApplication_style, QStylePE_Frame,StyleOption, QtDC.Widget, QtDC.Parent);
InflateRect(ARect, -1, -1);
Result := True;
finally
QStyleOptionFrameV2_destroy(StyleOption);
// todo: use qDrawWinPanel
case Style of
bvNone: ;
bvLowered: QtDC.qDrawShadeRect(ARect.Left, ARect.Top,
ARect.Right - ARect.Left, ARect.Bottom - ARect.Top, nil, False, FrameWidth);
bvRaised: QtDC.qDrawShadeRect(ARect.Left, ARect.Top,
ARect.Right - ARect.Left, ARect.Bottom - ARect.Top, nil, True, FrameWidth);
bvSpace: QtDC.qDrawPlainRect(ARect.Left, ARect.Top,
ARect.Right - ARect.Left, ARect.Bottom - ARect.Top, nil, FrameWidth);
end;
if Style <> bvNone then
InflateRect(ARect, -FrameWidth, -FrameWidth);
Result := True;
end;
{------------------------------------------------------------------------------
@ -1694,7 +1699,7 @@ begin
if not IsValidDC(DC) then Exit;
TQtDeviceContext(DC).drawRect(ARect.Left, ARect.Top,
TQtDeviceContext(DC).qDrawPLainRect(ARect.Left, ARect.Top,
ARect.Right - ARect.Left, ARect.Bottom - ARect.Top);
Result := 1;