- restored painting inside groupbox
- fix IntersectClipRect
- fix DrawText (clipping)

git-svn-id: trunk@12188 -
This commit is contained in:
paul 2007-09-27 01:16:33 +00:00
parent 490a35d1a5
commit 13c1fd094c
4 changed files with 32 additions and 30 deletions

View File

@ -1051,7 +1051,8 @@ begin
if Style.SystemFont or Style.Clipping or (not Style.Opaque) then if Style.SystemFont or Style.Clipping or (not Style.Opaque) then
SaveState; SaveState;
if Style.SystemFont then begin if Style.SystemFont then
begin
Options := Options or DT_INTERNAL; Options := Options or DT_INTERNAL;
SelectObject(DC, GetStockObject(DEFAULT_GUI_FONT)); SelectObject(DC, GetStockObject(DEFAULT_GUI_FONT));
end; end;
@ -1063,9 +1064,10 @@ begin
if Style.Layout = tlTop then if Style.Layout = tlTop then
fRect.Top := Y; fRect.Top := Y;
if (Style.Alignment in [taRightJustify,taCenter]) if (Style.Alignment in [taRightJustify,taCenter]) or
or (Style.Layout in [tlCenter,tlBottom]) then begin (Style.Layout in [tlCenter,tlBottom]) then
DrawText(DC,pChar(Text),Length(Text),fRect,DT_CALCRECT or Options); begin
DrawText(DC, pChar(Text), Length(Text), fRect, DT_CALCRECT or Options);
case Style.Alignment of case Style.Alignment of
taRightJustify : OffsetRect(fRect, ARect.Right - fRect.Right, 0); taRightJustify : OffsetRect(fRect, ARect.Right - fRect.Right, 0);
taCenter : OffsetRect(fRect, (ARect.Right - fRect.Right) div 2, 0); taCenter : OffsetRect(fRect, (ARect.Right - fRect.Right) div 2, 0);
@ -1077,27 +1079,27 @@ begin
end; end;
end; end;
if Style.Clipping then begin if Style.Clipping then
begin
IntersectRect(ARect, ARect, fRect); IntersectRect(ARect, ARect, fRect);
with ARect do with ARect do
InterSectClipRect(DC, Left, Top, Right, Bottom); InterSectClipRect(DC, Left, Top, Right, Bottom);
Options := Options or DT_NOCLIP; // no clipping as we are handling it here Options := Options or DT_NOCLIP; // no clipping as we are handling it here
end; end;
if Style.Opaque then begin if Style.Opaque then
FillRect(fRect); FillRect(fRect)
end else begin else
SetBkMode(DC, TRANSPARENT); SetBkMode(DC, TRANSPARENT);
end;
if Style.SystemFont then if Style.SystemFont then
SetTextColor(DC, Font.Color); SetTextColor(DC, Font.Color);
//debugln('TCanvas.TextRect DRAW Text="',Text,'" ',dbgs(fRect)); //debugln('TCanvas.TextRect DRAW Text="',Text,'" ',dbgs(fRect));
DrawText(DC, pChar(Text), Length(Text), fRect, Options); DrawText(DC, pChar(Text), Length(Text), fRect, Options);
if Style.Opaque and (csBrushValid in FState) then begin if Style.Opaque and (csBrushValid in FState) then
if Brush.Style=bsSolid then begin
// restore BKMode if Brush.Style=bsSolid then // restore BKMode
SetBkMode(DC, OPAQUE) SetBkMode(DC, OPAQUE)
end; end;

View File

@ -279,10 +279,11 @@ type
procedure fillRect(x, y, w, h: Integer; ABrush: QBrushH); overload; procedure fillRect(x, y, w, h: Integer; ABrush: QBrushH); overload;
procedure fillRect(x, y, w, h: Integer); overload; procedure fillRect(x, y, w, h: Integer); overload;
procedure setBrushOrigin(x, y: Integer);
procedure getBrushOrigin(retval: PPoint); procedure getBrushOrigin(retval: PPoint);
function getClipping: Boolean; function getClipping: Boolean;
procedure getPenPos(retval: PPoint); procedure getPenPos(retval: PPoint);
function getWorldMatrix: QMatrixH;
procedure setBrushOrigin(x, y: Integer);
procedure setPenPos(x, y: Integer); procedure setPenPos(x, y: Integer);
function font: TQtFont; function font: TQtFont;
@ -1710,6 +1711,11 @@ begin
retval^.y := FPenPos.y; retval^.y := FPenPos.y;
end; end;
function TQtDeviceContext.getWorldMatrix: QMatrixH;
begin
Result := QPainter_worldMatrix(Widget);
end;
procedure TQtDeviceContext.setPenPos(x, y: Integer); procedure TQtDeviceContext.setPenPos(x, y: Integer);
begin begin
FPenPos.X := x; FPenPos.X := x;

View File

@ -3552,6 +3552,7 @@ begin
{$ifdef VerboseQt} {$ifdef VerboseQt}
WriteLn('TQtGroupBox.Create '); WriteLn('TQtGroupBox.Create ');
{$endif} {$endif}
FHasPaint := True;
Result := QGroupBox_create(); Result := QGroupBox_create();
FCentralWidget := QWidget_create(Result, 0); FCentralWidget := QWidget_create(Result, 0);
Layout := QVBoxLayout_create(Result); Layout := QVBoxLayout_create(Result);

View File

@ -1187,6 +1187,9 @@ begin
if Flags and DT_NOPREFIX = 0 then if Flags and DT_NOPREFIX = 0 then
F := F or $800;{QTTextShowMnemonic;} F := F or $800;{QTTextShowMnemonic;}
if Flags and DT_NOCLIP = 0 then
F := F or $200; {QtTextDontClip}
QtDC.font.Metrics.BoundingRect(@R, @ARect, F, @WideStr); QtDC.font.Metrics.BoundingRect(@R, @ARect, F, @WideStr);
@ -3153,9 +3156,8 @@ end;
function TQtWidgetSet.IntersectClipRect(dc: hdc; Left, Top, Right, Bottom: Integer): Integer; function TQtWidgetSet.IntersectClipRect(dc: hdc; Left, Top, Right, Bottom: Integer): Integer;
var var
QtDC: TQtDeviceContext absolute dc;
IntersectRgn, Rgn: QRegionH; IntersectRgn, Rgn: QRegionH;
X1,Y1,X2,Y2: Integer;
QtDC: TQtDeviceContext;
begin begin
{$ifdef VerboseQtWinAPI} {$ifdef VerboseQtWinAPI}
WriteLn('***** [WinAPI TQtWidgetSet.IntersectClipRect] '); WriteLn('***** [WinAPI TQtWidgetSet.IntersectClipRect] ');
@ -3163,32 +3165,23 @@ begin
Result := ERROR; Result := ERROR;
if not IsValidDC(DC) then exit; if not IsValidDC(DC) then exit;
QtDC := TQtDeviceContext(DC); IntersectRgn := QRegion_create(Left, Top, Right - Left, Bottom - Top);
X1 := Left;
Y1 := Top;
X2 := Right;
Y2 := Bottom;
QMatrix_map(QPainter_worldMatrix(QtDC.Widget), X1, Y1, @X1, @Y1);
QMatrix_map(QPainter_worldMatrix(QtDC.Widget), X2, Y2, @X2, @Y2);
IntersectRgn := QRegion_create(X1, Y1, X2 - X1, Y2 - Y1);
Rgn := QRegion_create; Rgn := QRegion_create;
try try
if QPainter_hasClipping(QtDC.Widget) then if QtDC.getClipping then
begin begin
QPainter_clipRegion(QtDC.Widget, Rgn); QPainter_clipRegion(QtDC.Widget, Rgn);
if QRegion_isEmpty(Rgn) then if QRegion_isEmpty(Rgn) then
QRegion_unite(Rgn, Rgn, IntersectRgn) QtDC.setClipRegion(IntersectRgn)
else else
QRegion_intersect(Rgn, Rgn, IntersectRgn); QtDC.setClipRegion(IntersectRgn, QtIntersectClip);
end end
else else
begin begin
QtDC.setClipRegion(InterSectRgn); QtDC.setClipRegion(InterSectRgn);
QPainter_clipRegion(QtDC.Widget, Rgn); QPainter_clipRegion(QtDC.Widget, Rgn);
end; end;
QPainter_setClipping(QtDC.Widget, True); QtDC.setClipping(True);
Result := QtDC.GetRegionType(Rgn); Result := QtDC.GetRegionType(Rgn);
finally finally
QRegion_destroy(IntersectRgn); QRegion_destroy(IntersectRgn);