lazcontrols: TCustomLvlGraphControl: use theme

git-svn-id: trunk@46889 -
This commit is contained in:
mattias 2014-11-19 16:33:36 +00:00
parent 09f76fa935
commit 5bca3443b2

View File

@ -18,7 +18,7 @@ uses
Classes, SysUtils, types, math, typinfo, Classes, SysUtils, types, math, typinfo,
FPimage, FPCanvas, FPimage, FPCanvas,
AvgLvlTree, LazLoggerBase, LMessages, LCLType, LResources, AvgLvlTree, LazLoggerBase, LMessages, LCLType, LResources,
GraphType, GraphMath, Graphics, Controls, ImgList, LCLIntf, Forms; GraphType, GraphMath, Graphics, Controls, ImgList, LCLIntf, Forms, Themes;
type type
TLazCtrlPalette = array of TFPColor; TLazCtrlPalette = array of TFPColor;
@ -409,7 +409,8 @@ type
lgcNeedInvalidate, lgcNeedInvalidate,
lgcNeedAutoLayout, lgcNeedAutoLayout,
lgcIgnoreGraphInvalidate, lgcIgnoreGraphInvalidate,
lgcUpdatingScrollBars lgcUpdatingScrollBars,
lgcFocusedPainting
); );
TLvlGraphControlFlags = set of TLvlGraphControlFlag; TLvlGraphControlFlags = set of TLvlGraphControlFlag;
@ -2035,6 +2036,8 @@ var
p: TPoint; p: TPoint;
x: Integer; x: Integer;
y: Integer; y: Integer;
Details: TThemedElementDetails;
NodeRect: TRect;
begin begin
Canvas.Font.Height:=round(single(TxtH)*NodeStyle.CaptionScale+0.5); Canvas.Font.Height:=round(single(TxtH)*NodeStyle.CaptionScale+0.5);
for i:=0 to Graph.LevelCount-1 do begin for i:=0 to Graph.LevelCount-1 do begin
@ -2056,15 +2059,22 @@ begin
//debugln(['TCustomLvlGraphControl.Paint ',Node.Caption,' DrawPosition=',Node.DrawPosition,' DrawSize=',Node.DrawSize,' TxtH=',TxtH,' TxtW=',TxtW,' p=',dbgs(p),' Selected=',Node.Selected]); //debugln(['TCustomLvlGraphControl.Paint ',Node.Caption,' DrawPosition=',Node.DrawPosition,' DrawSize=',Node.DrawSize,' TxtH=',TxtH,' TxtW=',TxtW,' p=',dbgs(p),' Selected=',Node.Selected]);
x:=p.x-ScrollLeft; x:=p.x-ScrollLeft;
y:=p.y-ScrollTop; y:=p.y-ScrollTop;
Node.FDrawnCaptionRect:=Rect(x,y,x+TxtW,y+TxtH); NodeRect:=Bounds(x,y,TxtW,TxtH);
Node.FDrawnCaptionRect:=NodeRect;
if Node.Selected then begin if Node.Selected then begin
Canvas.Brush.Style:=bsSolid; if lgcFocusedPainting in FFlags then
Canvas.Brush.Color:=clHighlight; Details := ThemeServices.GetElementDetails(ttItemSelected)
else
Details := ThemeServices.GetElementDetails(ttItemSelectedNotFocus);
ThemeServices.DrawElement(Canvas.Handle, Details, NodeRect, nil);
end else begin end else begin
Canvas.Brush.Style:=bsClear; Details := ThemeServices.GetElementDetails(ttItemNormal);
Canvas.Brush.Color:=clNone; //Canvas.Brush.Style:=bsClear;
//Canvas.Brush.Color:=clNone;
end; end;
Canvas.TextOut(x,y,Node.Caption); ThemeServices.DrawText(Canvas, Details, Node.Caption, NodeRect,
DT_CENTER or DT_VCENTER or DT_SINGLELINE or DT_NOPREFIX, 0)
//Canvas.TextOut(x,y,Node.Caption);
end; end;
end; end;
end; end;
@ -2460,6 +2470,8 @@ begin
Canvas.Font.Assign(Font); Canvas.Font.Assign(Font);
Include(FFlags,lgcFocusedPainting);
if (lgoAutoLayout in FOptions) if (lgoAutoLayout in FOptions)
and (lgcNeedAutoLayout in FFlags) then begin and (lgcNeedAutoLayout in FFlags) then begin
Include(FFlags,lgcIgnoreGraphInvalidate); Include(FFlags,lgcIgnoreGraphInvalidate);