196
190
Include(FState, csBrushValid);
197
191
// do not use color for hatched brushes. windows cannot draw hatches when SetBkColor is called
198
192
if ([Brush.Style] * HatchBrushes) = [] then
199
SetBkColor(FHandle, Brush.GetColor);
193
SetBkColor(FHandle, TColorRef(Brush.GetColor));
200
194
if Brush.Style = bsSolid then
201
195
SetBkMode(FHandle, OPAQUE)
262
256
if (OldHandle <> HFONT(Font.Reference.Handle)) and (FSavedFontHandle = 0) then
263
257
FSavedFontHandle := OldHandle;
264
258
Include(FState, csFontValid);
265
SetTextColor(FHandle, Font.GetColor);
259
SetTextColor(FHandle, TColorRef(Font.GetColor));
268
262
{------------------------------------------------------------------------------
697
691
{------------------------------------------------------------------------------
692
Method: TCanvas.BrushCopy
693
Params: ADestRect, ABitmap, ASourceRect, ATransparentColor
696
Makes a stretch draw operation while substituting a color of the source bitmap
697
with the color of the brush of the canvas
698
------------------------------------------------------------------------------}
699
procedure TCanvas.BrushCopy(ADestRect: TRect; ABitmap: TBitmap; ASourceRect: TRect;
700
ATransparentColor: TColor);
702
lIntfImage: TLazIntfImage;
703
lTransparentColor, lBrushColor, lPixelColor: TFPColor;
704
lPaintedBitmap: TBitmap;
706
lDestWidth, lDestHeight, lSrcWidth, lSrcHeight: Integer;
708
// Preparation of data
709
lDestWidth := ADestRect.Right - ADestRect.Left;
710
lDestHeight := ADestRect.Bottom - ADestRect.Top;
711
lSrcWidth := ASourceRect.Right - ASourceRect.Left;
712
lSrcHeight := ASourceRect.Bottom - ASourceRect.Top;
713
lTransparentColor := TColorToFPColor(ColorToRGB(ATransparentColor));
714
lBrushColor := TColorToFPColor(ColorToRGB(Brush.Color));
716
lPaintedBitmap := TBitmap.Create;
717
lIntfImage := TLazIntfImage.Create(0, 0);
719
// First copy the source rectangle to another bitmap
720
// So that we don't have to iterate in pixels which wont be used changing the color
721
lPaintedBitmap.Width := lSrcWidth;
722
lPaintedBitmap.Height := lSrcHeight;
723
lPaintedBitmap.Canvas.Draw(-ASourceRect.Left, -ASourceRect.Top, ABitmap);
725
// Next copy the bitmap to a intfimage to be able to make the color change
726
lIntfImage.LoadFromBitmap(lPaintedBitmap.Handle, 0);
727
for x := 0 to lSrcWidth-1 do
728
for y := 0 to lSrcHeight-1 do
730
lPixelColor := lIntfImage.Colors[x, y];
731
if (lPixelColor.red = lTransparentColor.red) and
732
(lPixelColor.green = lTransparentColor.green) and
733
(lPixelColor.blue = lTransparentColor.blue) then
734
lIntfImage.Colors[x, y] := lBrushColor;
737
// Now obtain a bitmap with the new image
738
lPaintedBitmap.LoadFromIntfImage(lIntfImage);
740
// And stretch draw it
741
Self.StretchDraw(ADestRect, lPaintedBitmap);
748
{------------------------------------------------------------------------------
698
749
Method: TCanvas.RadialPie
699
750
Params: x1, y1, x2, y2, StartAngle16Deg, EndAngle16Deg: Integer
973
1024
{------------------------------------------------------------------------------
1025
Method: TCanvas.Frame3D
1027
Returns: the inflated rectangle (the inner rectangle without the frame)
1029
------------------------------------------------------------------------------}
1030
procedure TCanvas.Frame3D(var ARect: TRect; TopColor, BottomColor: TColor;
1031
const FrameWidth: integer);
1035
if ARect.Bottom-ARect.Top > ARect.Right-ARect.Left
1037
W := ARect.Right-ARect.Left+1
1039
W := ARect.Bottom-ARect.Top+1;
1041
if FrameWidth > W then
1048
Pen.Color := TopColor;
1049
MoveTo(ARect.Left, ARect.Bottom-1);
1050
LineTo(ARect.Left, ARect.Top);
1051
LineTo(ARect.Right-1, ARect.Top);
1052
Pen.Color := BottomColor;
1053
LineTo(ARect.Right-1, ARect.Bottom-1);
1054
LineTo(ARect.Left, ARect.Bottom-1);
1063
{------------------------------------------------------------------------------
974
1064
procedure TCanvas.Frame(const ARect: TRect);
976
1066
Drawing the border of a rectangle with the current pen
977
1067
------------------------------------------------------------------------------}
978
1068
procedure TCanvas.Frame(const ARect: TRect);
1070
OldBrushStyle: TFPBrushStyle;
981
1073
RequiredState([csHandleValid, csPenValid]);
982
LCLIntf.Frame(FHandle, ARect);
1074
OldBrushStyle := Brush.Style;
1075
Brush.Style := bsClear;
1077
Brush.Style := OldBrushStyle;
1132
1227
tlCenter : Options := Options or DT_VCENTER;
1133
1228
tlBottom : Options := Options or DT_BOTTOM;
1135
if Style.WordBreak then
1230
if Style.EndEllipsis then
1231
Options := Options or DT_END_ELLIPSIS;
1232
if Style.WordBreak then begin
1136
1233
Options := Options or DT_WORDBREAK;
1234
if Style.EndEllipsis then
1235
Options := Options and not DT_END_ELLIPSIS;
1138
1238
if Style.SingleLine then
1139
1239
Options := Options or DT_SINGLELINE;
1200
1300
SetBkMode(DC, TRANSPARENT);
1202
1302
if Style.SystemFont then
1203
SetTextColor(DC, Font.GetColor);
1303
SetTextColor(DC, TColorRef(Font.GetColor));
1205
1305
//debugln('TCanvas.TextRect DRAW Text="',Text,'" ',dbgs(fRect));
1206
1306
DrawText(DC, pChar(Text), Length(Text), fRect, Options);
1647
1747
{------------------------------------------------------------------------------
1748
Function: TCanvas.TextFitInfo
1749
Params: Text: The text in consideration
1750
MaxWidth: The size, the major input
1751
Returns: The number of characters which will fit into MaxWidth
1753
Returns how many characters will fit in a specified width
1754
------------------------------------------------------------------------------}
1755
function TCanvas.TextFitInfo(const Text: string; MaxWidth: Integer): Integer;
1759
LCLIntf.GetTextExtentExPoint(Self.Handle, PChar(Text), Length(Text),
1760
MaxWidth, @Result, nil, lSize);
1763
{------------------------------------------------------------------------------
1648
1764
Function: TCanvas.TextHeight
1649
1765
Params: Text: The text to measure
1650
1766
Returns: A handle to the GUI object