You've already forked lazarus-ccr
Patch by Theo for checkbox drawing and xp button style
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@86 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
225
components/virtualtreeview/lazbridge.pas
Normal file
225
components/virtualtreeview/lazbridge.pas
Normal file
@ -0,0 +1,225 @@
|
|||||||
|
unit lazbridge;
|
||||||
|
|
||||||
|
{ *************************************************************************** }
|
||||||
|
{ Copyright (c) 2007 Theo Lustenberger }
|
||||||
|
{ }
|
||||||
|
{ This software is provided "as-is". This software comes without warranty }
|
||||||
|
{ or garantee, explicit or implied. Use this software at your own risk. }
|
||||||
|
{ The author will not be liable for any damage to equipment, data, or }
|
||||||
|
{ information that may result while using this software. }
|
||||||
|
{ }
|
||||||
|
{ By using this software, you agree to the conditions stated above. }
|
||||||
|
{ *************************************************************************** }
|
||||||
|
|
||||||
|
{$MODE objfpc}{$H+}
|
||||||
|
|
||||||
|
{$DEFINE VER_VTV} //Version for VTV.
|
||||||
|
|
||||||
|
interface
|
||||||
|
|
||||||
|
uses Classes, SysUtils, Graphics, GraphType, InterfaceBase, LCLType,
|
||||||
|
IntfGraphics, FPimage, LCLIntf, ExtDlgs, FileUtil, ExtCtrls,
|
||||||
|
opbitmap {$IFNDEF VER_VTV} , opbitmapformats {$ENDIF};
|
||||||
|
|
||||||
|
|
||||||
|
type
|
||||||
|
|
||||||
|
{ TMyIntfImage }
|
||||||
|
|
||||||
|
TMyIntfImage = class(TLazIntfImage)
|
||||||
|
public
|
||||||
|
procedure CreateBitmapLateMask(var Bitmap, MaskBitmap: HBitmap;
|
||||||
|
AlwaysCreateMask: boolean; const RawImage: TRawImage);
|
||||||
|
end;
|
||||||
|
|
||||||
|
{ TOPOpenDialog }
|
||||||
|
|
||||||
|
{$IFNDEF VER_VTV}
|
||||||
|
TOPOpenDialog = class(TOpenPictureDialog)
|
||||||
|
private
|
||||||
|
FPreviewFilename: string;
|
||||||
|
protected
|
||||||
|
procedure UpdatePreview; override;
|
||||||
|
function Execute: boolean; override;
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
{ TLazOPPicture }
|
||||||
|
|
||||||
|
TLazOPPicture=class(TOPPicture)
|
||||||
|
private
|
||||||
|
fImage:TImage;
|
||||||
|
fUpdateImageSize:Boolean;
|
||||||
|
public
|
||||||
|
constructor Create(Image:TImage);
|
||||||
|
procedure DrawImage;
|
||||||
|
property UpdateImageSize:Boolean read fUpdateImageSize write fUpdateImageSize;
|
||||||
|
end;
|
||||||
|
{$ENDIF}
|
||||||
|
|
||||||
|
procedure AssignBitmapToOpBitmap(Bitmap: TBitmap; OpBitmap: TOpBitmap);
|
||||||
|
procedure AssignOpBitmapToBitmap(SourceBitmap: TOpBitmap; Bitmap: TBitmap; PreserveFormat: boolean = true);
|
||||||
|
procedure AssignOpBitmapToCanvas(OpBitmap: TOpBitmap; aCanvas: Graphics.TCanvas; X, Y: integer);
|
||||||
|
|
||||||
|
implementation
|
||||||
|
|
||||||
|
procedure AssignBitmapToOpBitmap(Bitmap: TBitmap; OpBitmap: TOpBitmap);
|
||||||
|
var int: TLazIntfImage;
|
||||||
|
i: integer;
|
||||||
|
x, y: integer;
|
||||||
|
begin
|
||||||
|
int := Bitmap.CreateIntfImage;
|
||||||
|
OpBitmap.Width := int.Width;
|
||||||
|
OpBitmap.Height := int.Height;
|
||||||
|
OpBitmap.Pixelformat := PixelFormatFromBPP(Int.DataDescription.BitsPerPixel);
|
||||||
|
for y := 0 to OpBitmap.Height - 1 do
|
||||||
|
for x := 0 to OpBitmap.Width - 1 do
|
||||||
|
OpBitmap.Pixels[X, Y] := Int.TColors[X, Y];
|
||||||
|
if Bitmap.Transparent then
|
||||||
|
OpBitmap.TransparentColor := Bitmap.TransparentColor;
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
procedure AssignOpBitmapToBitmap(SourceBitmap: TOpBitmap; Bitmap: TBitmap; PreserveFormat: boolean = true);
|
||||||
|
var int: TMyIntfImage;
|
||||||
|
var bmph, mbmph: HBitmap;
|
||||||
|
x, y: integer;
|
||||||
|
pmask: PByte;
|
||||||
|
rawi: TRawImage;
|
||||||
|
OPBitmap: TOpBitmap;
|
||||||
|
begin
|
||||||
|
if PreserveFormat then
|
||||||
|
begin
|
||||||
|
OpBitmap := TOPBitmap.create;
|
||||||
|
OpBitmap.Assign(SourceBitmap);
|
||||||
|
end else OpBitmap := SourceBitmap;
|
||||||
|
|
||||||
|
Int := TMyIntfImage.Create(0, 0);
|
||||||
|
Int.AutoCreateMask := false;
|
||||||
|
Int.GetDescriptionFromDevice(0);
|
||||||
|
Int.Width := OpBitmap.Width;
|
||||||
|
Int.Height := OpBitmap.Height;
|
||||||
|
OpBitmap.Pixelformat := PixelFormatFromBPP(Int.DataDescription.BitsPerPixel);
|
||||||
|
for y := 0 to OpBitmap.Height - 1 do
|
||||||
|
for x := 0 to OpBitmap.Width - 1 do
|
||||||
|
Int.TColors[X, Y] := OpBitmap.Pixels[X, Y];
|
||||||
|
|
||||||
|
if OPBitmap.Transparent then
|
||||||
|
begin
|
||||||
|
int.GetRawImage(Rawi);
|
||||||
|
rawi.MaskSize := OpBitmap.GetTransparentMask(0, pmask,
|
||||||
|
Rawi.Description.AlphaBitOrder = riboReversedBits,
|
||||||
|
Rawi.Description.AlphaLineEnd = rileWordBoundary);
|
||||||
|
rawi.Mask := pmask;
|
||||||
|
{ writeln(RawImageDescriptionAsString(@Rawi));
|
||||||
|
writeln('bwid: ',OpBitmap.Width, ' bhei: ',OpBitmap.Height,' rmsiz:',Rawi.MaskSize); }
|
||||||
|
Int.CreateBitmapLateMask(bmph, mbmph, false, rawi);
|
||||||
|
end else
|
||||||
|
begin
|
||||||
|
Int.CreateBitmap(bmph, mbmph, false);
|
||||||
|
end;
|
||||||
|
Bitmap.Free;
|
||||||
|
Bitmap := TBitmap.Create;
|
||||||
|
Bitmap.Handle := bmph;
|
||||||
|
Bitmap.MaskHandle := mbmph;
|
||||||
|
Int.free;
|
||||||
|
if PreserveFormat then OPBitmap.free;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure AssignOpBitmapToCanvas(OpBitmap: TOpBitmap; aCanvas: Graphics.TCanvas; X, Y: integer);
|
||||||
|
var Bmp: TBitmap;
|
||||||
|
begin
|
||||||
|
Bmp := TBitmap.create;
|
||||||
|
AssignOpBitmapToBitmap(OpBitmap, Bmp);
|
||||||
|
aCanvas.Draw(X, Y, bmp);
|
||||||
|
Bmp.free;
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
{$IFNDEF VER_VTV}
|
||||||
|
|
||||||
|
{ TOPOpenDialog }
|
||||||
|
|
||||||
|
procedure TOPOpenDialog.UpdatePreview;
|
||||||
|
var
|
||||||
|
CurFilename: string;
|
||||||
|
FileIsValid: boolean;
|
||||||
|
OP: TOPPicture;
|
||||||
|
LBPP: Integer;
|
||||||
|
begin
|
||||||
|
CurFilename := FileName;
|
||||||
|
if CurFilename = FPreviewFilename then exit;
|
||||||
|
|
||||||
|
FPreviewFilename := CurFilename;
|
||||||
|
FileIsValid := FileExists(FPreviewFilename)
|
||||||
|
and (not DirPathExists(FPreviewFilename))
|
||||||
|
and FileIsReadable(FPreviewFilename);
|
||||||
|
if FileIsValid then
|
||||||
|
try
|
||||||
|
OP := TOPPicture.create;
|
||||||
|
try
|
||||||
|
OP.LoadFromFile(FPreviewFilename);
|
||||||
|
LBPP := OP.Bitmap.BPP;
|
||||||
|
OP.Bitmap.Transparent := false;
|
||||||
|
AssignOpBitmapToBitmap(Op.Bitmap, ImageCtrl.Picture.Bitmap, false);
|
||||||
|
PictureGroupBox.Caption := Format('(%dx%d BPP:%d)',
|
||||||
|
[ImageCtrl.Picture.Width, ImageCtrl.Picture.Height, LBPP]);
|
||||||
|
finally
|
||||||
|
OP.free;
|
||||||
|
end;
|
||||||
|
except
|
||||||
|
FileIsValid := False;
|
||||||
|
end;
|
||||||
|
if not FileIsValid then
|
||||||
|
ClearPreview;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TOPOpenDialog.Execute: boolean;
|
||||||
|
begin
|
||||||
|
Filter := OPGLoadFilters;
|
||||||
|
result := inherited Execute;
|
||||||
|
end;
|
||||||
|
|
||||||
|
{$ENDIF}
|
||||||
|
|
||||||
|
|
||||||
|
{ TMyIntfImage }
|
||||||
|
|
||||||
|
procedure TMyIntfImage.CreateBitmapLateMask(var Bitmap, MaskBitmap: HBitmap;
|
||||||
|
AlwaysCreateMask: boolean; const RawImage: TRawImage);
|
||||||
|
var
|
||||||
|
ARawImage: TRawImage;
|
||||||
|
begin
|
||||||
|
GetRawImage(ARawImage);
|
||||||
|
ARawImage.Mask := RawImage.Mask;
|
||||||
|
ARawImage.MaskSize := RawImage.MaskSize;
|
||||||
|
if not CreateBitmapFromRawImage(ARawImage, Bitmap, MaskBitmap, AlwaysCreateMask)
|
||||||
|
then
|
||||||
|
raise FPImageException.Create('Failed to create bitmaps');
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
{$IFNDEF VER_VTV}
|
||||||
|
|
||||||
|
{ TLazOPPicture }
|
||||||
|
|
||||||
|
constructor TLazOPPicture.Create(Image: TImage);
|
||||||
|
begin
|
||||||
|
inherited Create;
|
||||||
|
fImage:=Image;
|
||||||
|
fUpdateImageSize:=true;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TLazOPPicture.DrawImage;
|
||||||
|
begin
|
||||||
|
if fImage<>nil then
|
||||||
|
begin
|
||||||
|
if fUpdateImageSize then fImage.SetBounds(0,0,Bitmap.Width,Bitmap.Height);
|
||||||
|
AssignOpBitmapToBitmap(Bitmap, fImage.Picture.Bitmap);
|
||||||
|
fImage.invalidate;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
{$ENDIF}
|
||||||
|
|
||||||
|
end.
|
2898
components/virtualtreeview/opbitmap.pas
Normal file
2898
components/virtualtreeview/opbitmap.pas
Normal file
File diff suppressed because it is too large
Load Diff
@ -70,7 +70,7 @@ interface
|
|||||||
{.$define UseLocalMemoryManager}
|
{.$define UseLocalMemoryManager}
|
||||||
|
|
||||||
uses
|
uses
|
||||||
LCLProc, LCLType, Types, LMessages, LCLIntf, SysUtils, Classes, Graphics, Controls, Forms, ImgList, {ActiveX,} StdCtrls, Menus, Printers,
|
LCLProc, LCLType, Types, LMessages, LCLIntf, SysUtils, Classes, opbitmap, lazbridge, Graphics, Controls, Forms, ImgList, {ActiveX,} StdCtrls, Menus, Printers,
|
||||||
LResources, GraphType, CustomTimer,
|
LResources, GraphType, CustomTimer,
|
||||||
SyncObjs, // critical sections
|
SyncObjs, // critical sections
|
||||||
CommCtrl // image lists, common controls tree structures
|
CommCtrl // image lists, common controls tree structures
|
||||||
@ -849,7 +849,7 @@ type
|
|||||||
function AdjustHoverColumn(P: TPoint): Boolean;
|
function AdjustHoverColumn(P: TPoint): Boolean;
|
||||||
procedure AdjustPosition(Column: TVirtualTreeColumn; Position: Cardinal);
|
procedure AdjustPosition(Column: TVirtualTreeColumn; Position: Cardinal);
|
||||||
procedure DrawButtonText(DC: HDC; Caption: WideString; Bounds: TRect; Enabled, Hot: Boolean; DrawFormat: Cardinal);
|
procedure DrawButtonText(DC: HDC; Caption: WideString; Bounds: TRect; Enabled, Hot: Boolean; DrawFormat: Cardinal);
|
||||||
procedure DrawXPButton(DC: HDC; ButtonR: TRect; DrawSplitter, Down, Hover: Boolean);
|
procedure DrawXPButton(Canvas: TCanvas; ButtonR: TRect; DrawSplitter, Down, Hover, HoverOnTop: Boolean);
|
||||||
procedure FixPositions;
|
procedure FixPositions;
|
||||||
function GetColumnAndBounds(P: TPoint; var ColumnLeft, ColumnRight: Integer; Relative: Boolean = True): Integer;
|
function GetColumnAndBounds(P: TPoint; var ColumnLeft, ColumnRight: Integer; Relative: Boolean = True): Integer;
|
||||||
function GetOwner: TPersistent; override;
|
function GetOwner: TPersistent; override;
|
||||||
@ -3166,7 +3166,7 @@ procedure DrawTextW(Canvas: TCanvas; lpString: PWideChar; var lpRect: TRect; uFo
|
|||||||
var Style:TTextStyle;
|
var Style:TTextStyle;
|
||||||
begin
|
begin
|
||||||
{$ifndef WINCE}
|
{$ifndef WINCE}
|
||||||
{$ifdef LINUX}
|
{$ifdef LCLGTK}
|
||||||
Style.Layout:=tlCenter;
|
Style.Layout:=tlCenter;
|
||||||
Canvas.TextRect(lpRect,lpRect.Left,lpRect.Top,lpString,Style); // theo 24.2.2007 Gibt sonst Striche auf GTK1
|
Canvas.TextRect(lpRect,lpRect.Left,lpRect.Top,lpString,Style); // theo 24.2.2007 Gibt sonst Striche auf GTK1
|
||||||
{$else}
|
{$else}
|
||||||
@ -3733,6 +3733,7 @@ var
|
|||||||
Dest: TRect;
|
Dest: TRect;
|
||||||
//Small (???) hack while a solution does not come
|
//Small (???) hack while a solution does not come
|
||||||
Stream: TMemoryStream;
|
Stream: TMemoryStream;
|
||||||
|
TempOPB, SourceOPB:TCanvasOPBitmap;
|
||||||
begin
|
begin
|
||||||
Watcher.Enter;
|
Watcher.Enter;
|
||||||
try
|
try
|
||||||
@ -3761,22 +3762,23 @@ begin
|
|||||||
|
|
||||||
MaskColor := clFuchsia;//Images.Canvas.Pixels[0, 0]; // this is usually clFuchsia
|
MaskColor := clFuchsia;//Images.Canvas.Pixels[0, 0]; // this is usually clFuchsia
|
||||||
Dest := Rect(0, 0, IL.Width, IL.Height);
|
Dest := Rect(0, 0, IL.Width, IL.Height);
|
||||||
for I := 0 to (Images.Width div Images.Height) - 1 do
|
|
||||||
|
SourceOPB:=TCanvasOPBitmap.create; //theo 25.2.07
|
||||||
|
AssignBitmapToOpBitmap(Images,SourceOPB);
|
||||||
|
for I := 0 to (Images.Width div Images.Height) - 1 do
|
||||||
begin
|
begin
|
||||||
Source := Rect(I * IL.Width, 0, (I + 1) * IL.Width, IL.Height);
|
Source := Rect(I * IL.Width, 0, (I + 1) * IL.Width, IL.Height);
|
||||||
OneImage:= TBitmap.Create;
|
TempOPB:=TCanvasOPBitmap.create;
|
||||||
OneImage.Width:=IL.Height;
|
TempOPB.Width:=IL.Height;
|
||||||
OneImage.Height:=IL.Width;
|
TempOPB.Height:=IL.Width;
|
||||||
OneImage.Canvas.CopyRect(Dest, Images.Canvas, Source);
|
TempOPB.Canvas.CopyRect(Dest, SourceOPB.Canvas, Source);
|
||||||
//somehow SaveToStream - LoadFromStream restores the tranparency lost in CopyRect
|
TempOPB.TransparentColor:=MaskColor;
|
||||||
OneImage.SaveToStream(Stream);
|
|
||||||
OneImage.Free;
|
|
||||||
AnotherImage:=TBitmap.Create;
|
AnotherImage:=TBitmap.Create;
|
||||||
Stream.Position:=0;
|
AssignOpBitmapToBitmap(TempOPB,AnotherImage);
|
||||||
AnotherImage.LoadFromStream(Stream);
|
TempOPB.free;
|
||||||
Stream.Size:=0;
|
|
||||||
IL.AddDirect(AnotherImage, nil);
|
IL.AddDirect(AnotherImage, nil);
|
||||||
end;
|
end;
|
||||||
|
SourceOPB.free;
|
||||||
finally
|
finally
|
||||||
Images.Free;
|
Images.Free;
|
||||||
//OneImage.Free;
|
//OneImage.Free;
|
||||||
@ -3876,8 +3878,8 @@ var
|
|||||||
begin
|
begin
|
||||||
|
|
||||||
{$IFDEF LINUX} //theo 24.2.2007
|
{$IFDEF LINUX} //theo 24.2.2007
|
||||||
Width:=14;
|
Width:=16;
|
||||||
Height:=14; {$message warn'nur um die exception zu verhindern. Werte nicht getestet'}
|
Height:=16; {$message warn'nur um die exception zu verhindern. Werte nicht getestet'}
|
||||||
{$ELSE}
|
{$ELSE}
|
||||||
Width := GetSystemMetrics(SM_CXMENUCHECK) + 3;
|
Width := GetSystemMetrics(SM_CXMENUCHECK) + 3;
|
||||||
Height := GetSystemMetrics(SM_CYMENUCHECK) + 3;
|
Height := GetSystemMetrics(SM_CYMENUCHECK) + 3;
|
||||||
@ -7124,138 +7126,85 @@ const
|
|||||||
XPDownMiddleLineColor = $B8C2C1; // Down state border color.
|
XPDownMiddleLineColor = $B8C2C1; // Down state border color.
|
||||||
XPDownInnerLineColor = $C9D1D0; // Down state border color.
|
XPDownInnerLineColor = $C9D1D0; // Down state border color.
|
||||||
|
|
||||||
procedure TVirtualTreeColumns.DrawXPButton(DC: HDC; ButtonR: TRect; DrawSplitter, Down, Hover: Boolean);
|
procedure TVirtualTreeColumns.DrawXPButton(Canvas: TCanvas; ButtonR: TRect; DrawSplitter, Down, Hover, HoverOnTop: Boolean);
|
||||||
|
|
||||||
// Helper procedure to draw an Windows XP like header button.
|
|
||||||
|
|
||||||
var
|
var
|
||||||
PaintBrush: HBRUSH;
|
SavBrColor, SavPnColor, PenColor: TColor;
|
||||||
Pen,
|
dRed, dGreen, dBlue: integer;
|
||||||
OldPen: HPEN;
|
Y, dY: integer;
|
||||||
PenColor,
|
|
||||||
FillColor: COLORREF;
|
|
||||||
dRed, dGreen, dBlue: Single;
|
|
||||||
Width,
|
|
||||||
XPos: Integer;
|
|
||||||
|
|
||||||
begin
|
begin
|
||||||
{ if Down then
|
|
||||||
FillColor := XPMainHeaderColorDown
|
SavBrColor:=Canvas.Brush.Color;
|
||||||
|
SavPnColor:=Canvas.Pen.Color;
|
||||||
|
if Down then
|
||||||
|
Canvas.Brush.Color := XPMainHeaderColorDown
|
||||||
|
else if Hover then
|
||||||
|
Canvas.Brush.Color := XPMainHeaderColorHover
|
||||||
else
|
else
|
||||||
if Hover then
|
Canvas.Brush.Color := XPMainHeaderColorUp;
|
||||||
FillColor := XPMainHeaderColorHover
|
Canvas.FillRect(ButtonR);
|
||||||
else
|
Canvas.Brush.Color:=SavBrColor;
|
||||||
FillColor := XPMainHeaderColorUp;
|
|
||||||
PaintBrush := CreateSolidBrush(FillColor);
|
|
||||||
FillRect(DC, ButtonR, PaintBrush);
|
|
||||||
DeleteObject(PaintBrush);
|
|
||||||
|
|
||||||
if DrawSplitter and not (Down or Hover) then
|
if DrawSplitter and not (Down or Hover) then
|
||||||
begin
|
begin
|
||||||
// One solid pen for the dark line...
|
Canvas.Pen.Color:=XPDarkSplitBarColor;
|
||||||
Pen := CreatePen(PS_SOLID, 1, XPDarkSplitBarColor);
|
Canvas.MoveTo(ButtonR.Right - 2, ButtonR.Top + 3);
|
||||||
OldPen := SelectObject(DC, Pen);
|
Canvas.LineTo(ButtonR.Right - 2, ButtonR.Bottom - 5);
|
||||||
MoveToEx(DC, ButtonR.Right - 2, ButtonR.Top + 3, nil);
|
Canvas.Pen.Color:=XPLightSplitBarColor;
|
||||||
LineTo(DC, ButtonR.Right - 2, ButtonR.Bottom - 5);
|
Canvas.MoveTo(ButtonR.Right - 1, ButtonR.Top + 3);
|
||||||
// ... and one solid pen for the light line.
|
Canvas.LineTo(ButtonR.Right - 1, ButtonR.Bottom - 5);
|
||||||
Pen := CreatePen(PS_SOLID, 1, XPLightSplitBarColor);
|
|
||||||
DeleteObject(SelectObject(DC, Pen));
|
|
||||||
MoveToEx(DC, ButtonR.Right - 1, ButtonR.Top + 3, nil);
|
|
||||||
LineTo(DC, ButtonR.Right - 1, ButtonR.Bottom - 5);
|
|
||||||
SelectObject(DC, OldPen);
|
|
||||||
DeleteObject(Pen);
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
if Down then
|
if Down then begin
|
||||||
begin
|
Canvas.Pen.Color:=XPDownOuterLineColor;
|
||||||
// Down state. Three lines to draw.
|
Canvas.MoveTo(ButtonR.Left, ButtonR.Top);
|
||||||
// First one is the outer line, drawn at left, bottom and right.
|
Canvas.LineTo(ButtonR.Left, ButtonR.Bottom - 1);
|
||||||
Pen := CreatePen(PS_SOLID, 1, XPDownOuterLineColor);
|
Canvas.LineTo(ButtonR.Right - 1, ButtonR.Bottom - 1);
|
||||||
OldPen := SelectObject(DC, Pen);
|
Canvas.LineTo(ButtonR.Right - 1, ButtonR.Top - 1);
|
||||||
MoveToEx(DC, ButtonR.Left, ButtonR.Top, nil);
|
|
||||||
LineTo(DC, ButtonR.Left, ButtonR.Bottom - 1);
|
|
||||||
LineTo(DC, ButtonR.Right - 1, ButtonR.Bottom - 1);
|
|
||||||
LineTo(DC, ButtonR.Right - 1, ButtonR.Top - 1);
|
|
||||||
|
|
||||||
// Second one is the middle line, which is a bit lighter.
|
Canvas.Pen.Color:=XPDownMiddleLineColor;
|
||||||
Pen := CreatePen(PS_SOLID, 1, XPDownMiddleLineColor);
|
Canvas.MoveTo(ButtonR.Left + 1, ButtonR.Bottom - 2);
|
||||||
DeleteObject(SelectObject(DC, Pen));
|
Canvas.LineTo(ButtonR.Left + 1, ButtonR.Top);
|
||||||
MoveToEx(DC, ButtonR.Left + 1, ButtonR.Bottom - 2, nil);
|
Canvas.LineTo(ButtonR.Right - 1, ButtonR.Top);
|
||||||
LineTo(DC, ButtonR.Left + 1, ButtonR.Top);
|
|
||||||
LineTo(DC, ButtonR.Right - 1, ButtonR.Top);
|
|
||||||
|
|
||||||
// Third line is the inner line, which is even lighter than the middle line.
|
Canvas.Pen.Color:=XPDownInnerLineColor;
|
||||||
Pen := CreatePen(PS_SOLID, 1, XPDownInnerLineColor);
|
Canvas.MoveTo(ButtonR.Left + 2, ButtonR.Bottom - 2);
|
||||||
DeleteObject(SelectObject(DC, Pen));
|
Canvas.LineTo(ButtonR.Left + 2, ButtonR.Top + 1);
|
||||||
MoveToEx(DC, ButtonR.Left + 2, ButtonR.Bottom - 2, nil);
|
Canvas.LineTo(ButtonR.Right - 1, ButtonR.Top + 1);
|
||||||
LineTo(DC, ButtonR.Left + 2, ButtonR.Top + 1);
|
|
||||||
LineTo(DC, ButtonR.Right - 1, ButtonR.Top + 1);
|
|
||||||
|
|
||||||
// Housekeeping:
|
|
||||||
SelectObject(DC, OldPen);
|
|
||||||
DeleteObject(Pen);
|
|
||||||
end
|
end
|
||||||
else
|
else if Hover then begin
|
||||||
if Hover then
|
//DrawXPHover(Canvas, ButtonR, HoverOnTop);
|
||||||
begin
|
end
|
||||||
// Hover state. There are three lines at the bottom border, but they are rendered in a way which
|
else begin
|
||||||
// requires expensive construction.
|
if HoverOnTop then begin
|
||||||
Width := ButtonR.Right - ButtonR.Left;
|
Y:=ButtonR.Top;
|
||||||
if Width <= 32 then
|
dY:=1;
|
||||||
begin
|
|
||||||
ImageList_DrawEx(UtilityImages.Handle, 8, DC, ButtonR.Right - 16, ButtonR.Bottom - 3, 16, 3, CLR_NONE, CLR_NONE,
|
|
||||||
ILD_NORMAL);
|
|
||||||
ImageList_DrawEx(UtilityImages.Handle, 6, DC, ButtonR.Left, ButtonR.Bottom - 3, Width div 2, 3, CLR_NONE,
|
|
||||||
CLR_NONE, ILD_NORMAL);
|
|
||||||
end
|
|
||||||
else
|
|
||||||
begin
|
|
||||||
ImageList_DrawEx(UtilityImages.Handle, 6, DC, ButtonR.Left, ButtonR.Bottom - 3, 16, 3, CLR_NONE, CLR_NONE,
|
|
||||||
ILD_NORMAL);
|
|
||||||
// Replicate inner part as many times as need to fill up the button rectangle.
|
|
||||||
XPos := ButtonR.Left + 16;
|
|
||||||
repeat
|
|
||||||
ImageList_DrawEx(UtilityImages.Handle, 7, DC, XPos, ButtonR.Bottom - 3, 16, 3, CLR_NONE, CLR_NONE, ILD_NORMAL);
|
|
||||||
Inc(XPos, 16);
|
|
||||||
until XPos + 16 >= ButtonR.Right;
|
|
||||||
ImageList_DrawEx(UtilityImages.Handle, 8, DC, ButtonR.Right - 16, ButtonR.Bottom - 3, 16, 3, CLR_NONE, CLR_NONE,
|
|
||||||
ILD_NORMAL);
|
|
||||||
end;
|
|
||||||
end
|
end
|
||||||
else
|
else begin
|
||||||
begin
|
Y:=ButtonR.Bottom-1;
|
||||||
// There is a three line gradient near the bottom border which transforms from the button color to a dark,
|
dY:=-1;
|
||||||
// clBtnFace like color (here XPDarkGradientColor).
|
end;
|
||||||
PenColor := XPMainHeaderColorUp;
|
PenColor := XPMainHeaderColorUp;
|
||||||
dRed := ((PenColor and $FF) - (XPDarkGradientColor and $FF)) / 3;
|
dRed := ((PenColor and $FF) - (XPDarkGradientColor and $FF)) div 3;
|
||||||
dGreen := (((PenColor shr 8) and $FF) - ((XPDarkGradientColor shr 8) and $FF)) / 3;
|
dGreen := (((PenColor shr 8) and $FF) - ((XPDarkGradientColor shr 8) and $FF)) div 3;
|
||||||
dBlue := (((PenColor shr 16) and $FF) - ((XPDarkGradientColor shr 16) and $FF)) / 3;
|
dBlue := (((PenColor shr 16) and $FF) - ((XPDarkGradientColor shr 16) and $FF)) div 3;
|
||||||
|
|
||||||
// First line:
|
PenColor := PenColor - Lo(dRed) - Lo(dGreen) shl 8 - Lo(dBlue) shl 16;
|
||||||
PenColor := PenColor - Round(dRed) - Round(dGreen) shl 8 - Round(dBlue) shl 16;
|
Canvas.Pen.Color:=PenColor;
|
||||||
Pen := CreatePen(PS_SOLID, 1, PenColor);
|
Canvas.MoveTo(ButtonR.Left, Y + 2*dY);
|
||||||
OldPen := SelectObject(DC, Pen);
|
Canvas.LineTo(ButtonR.Right, Y + 2*dY);
|
||||||
MoveToEx(DC, ButtonR.Left, ButtonR.Bottom - 3, nil);
|
|
||||||
LineTo(DC, ButtonR.Right, ButtonR.Bottom - 3);
|
|
||||||
|
|
||||||
// Second line:
|
Canvas.Pen.Color := PenColor - Lo(dRed) - Lo(dGreen) shl 8 - Lo(dBlue) shl 16;
|
||||||
PenColor := PenColor - Round(dRed) - Round(dGreen) shl 8 - Round(dBlue) shl 16;
|
Canvas.MoveTo(ButtonR.Left, Y + dY);
|
||||||
Pen := CreatePen(PS_SOLID, 1, PenColor);
|
Canvas.LineTo(ButtonR.Right, Y + dY);
|
||||||
DeleteObject(SelectObject(DC, Pen));
|
|
||||||
MoveToEx(DC, ButtonR.Left, ButtonR.Bottom - 2, nil);
|
|
||||||
LineTo(DC, ButtonR.Right, ButtonR.Bottom - 2);
|
|
||||||
|
|
||||||
// Third line:
|
Canvas.Pen.Color := XPDarkGradientColor;
|
||||||
Pen := CreatePen(PS_SOLID, 1, XPDarkGradientColor);
|
Canvas.MoveTo(ButtonR.Left, Y);
|
||||||
DeleteObject(SelectObject(DC, Pen));
|
Canvas.LineTo(ButtonR.Right, Y);
|
||||||
MoveToEx(DC, ButtonR.Left, ButtonR.Bottom - 1, nil);
|
end;
|
||||||
LineTo(DC, ButtonR.Right, ButtonR.Bottom - 1);
|
Canvas.Pen.Color:=SavPnColor;
|
||||||
|
|
||||||
// Housekeeping:
|
|
||||||
DeleteObject(SelectObject(DC, OldPen));
|
|
||||||
end; }
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
procedure TVirtualTreeColumns.FixPositions;
|
procedure TVirtualTreeColumns.FixPositions;
|
||||||
@ -8047,7 +7996,8 @@ begin
|
|||||||
else
|
else
|
||||||
{$endif ThemeSupport}
|
{$endif ThemeSupport}
|
||||||
if FHeader.Style = hsXPStyle then
|
if FHeader.Style = hsXPStyle then
|
||||||
DrawXPButton(Handle, Run, False, False, False)
|
// DrawXPButton(Handle, Run, False, False, False)
|
||||||
|
DrawXPButton(PaintInfo.TargetCanvas, Run, False, False, False, False)
|
||||||
else
|
else
|
||||||
begin
|
begin
|
||||||
Brush.Color := FHeader.FBackground;
|
Brush.Color := FHeader.FBackground;
|
||||||
@ -8133,7 +8083,8 @@ begin
|
|||||||
{$endif ThemeSupport}
|
{$endif ThemeSupport}
|
||||||
begin
|
begin
|
||||||
if FHeader.Style = hsXPStyle then
|
if FHeader.Style = hsXPStyle then
|
||||||
DrawXPButton(Handle, PaintRectangle, RightBorderFlag <> 0, IsDownIndex, IsHoverIndex)
|
// DrawXPButton(Handle, PaintRectangle, RightBorderFlag <> 0, IsDownIndex, IsHoverIndex)
|
||||||
|
DrawXPButton(PaintInfo.TargetCanvas, PaintRectangle, RightBorderFlag <> 0, IsDownIndex, IsHoverIndex, False)
|
||||||
else
|
else
|
||||||
if IsDownIndex then
|
if IsDownIndex then
|
||||||
DrawEdge(Handle, PaintRectangle, PressedButtonStyle, PressedButtonFlags)
|
DrawEdge(Handle, PaintRectangle, PressedButtonStyle, PressedButtonFlags)
|
||||||
|
Reference in New Issue
Block a user