Corrected patch by Theo
fixes checkboximage issues. git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@100 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
parent
c1e34e90a8
commit
13200829e9
@ -22,6 +22,231 @@ uses Classes, SysUtils, Graphics, GraphType, InterfaceBase, LCLType,
|
||||
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 else OPBitmap.Transparent:=false;
|
||||
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,
|
||||
TOPRawImageLineEnd(Rawi.Description.AlphaLineEnd));
|
||||
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.
|
||||
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 }
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -31,13 +31,13 @@ unit VirtualTrees;
|
||||
// For full document history see help file.
|
||||
//
|
||||
// Credits for their valuable assistance and code donations go to:
|
||||
// Freddy Ertl, Marian Aldenhövel, Thomas Bogenrieder, Jim Kuenemann, Werner Lehmann, Jens Treichler,
|
||||
// Paul Gallagher (IBO tree), Ondrej Kelle, Ronaldo Melo Ferraz, Heri Bender, Roland Bedürftig (BCB)
|
||||
// Freddy Ertl, Marian Aldenh<EFBFBD>el, Thomas Bogenrieder, Jim Kuenemann, Werner Lehmann, Jens Treichler,
|
||||
// Paul Gallagher (IBO tree), Ondrej Kelle, Ronaldo Melo Ferraz, Heri Bender, Roland Bedrftig (BCB)
|
||||
// Anthony Mills, Alexander Egorushkin (BCB), Mathias Torell (BCB), Frank van den Bergh, Vadim Sedulin, Peter Evans,
|
||||
// Milan Vandrovec (BCB), Steve Moss (system check images), Joe White, David Clark (local node memory manager),
|
||||
// Anders Thomsen, Igor Afanasyev, Eugene Programmer
|
||||
// Beta testers:
|
||||
// Freddy Ertl, Hans-Jürgen Schnorrenberg, Werner Lehmann, Jim Kueneman, Vadim Sedulin, Moritz Franckenstein,
|
||||
// Freddy Ertl, Hans-Jrgen Schnorrenberg, Werner Lehmann, Jim Kueneman, Vadim Sedulin, Moritz Franckenstein,
|
||||
// Wim van der Vegt, Franc v/d Westelaken
|
||||
// Indirect contribution (via publicly accessible work of those persons):
|
||||
// Alex Denissov, Hiroyuki Hori (MMXAsm expert)
|
||||
@ -70,7 +70,7 @@ interface
|
||||
{.$define UseLocalMemoryManager}
|
||||
|
||||
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,
|
||||
SyncObjs, // critical sections
|
||||
CommCtrl // image lists, common controls tree structures
|
||||
@ -849,7 +849,7 @@ type
|
||||
function AdjustHoverColumn(P: TPoint): Boolean;
|
||||
procedure AdjustPosition(Column: TVirtualTreeColumn; Position: 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;
|
||||
function GetColumnAndBounds(P: TPoint; var ColumnLeft, ColumnRight: Integer; Relative: Boolean = True): Integer;
|
||||
function GetOwner: TPersistent; override;
|
||||
@ -2441,7 +2441,7 @@ const
|
||||
|
||||
// Do not modify the copyright in any way! Usage of this unit is prohibited without the copyright notice
|
||||
// in the compiled binary file.
|
||||
Copyright: string = 'Virtual Treeview © 1999, 2003 Mike Lischke';
|
||||
Copyright: string = 'Virtual Treeview 1999, 2003 Mike Lischke';
|
||||
|
||||
type // streaming support
|
||||
TMagicID = array[0..5] of WideChar;
|
||||
@ -3166,7 +3166,7 @@ procedure DrawTextW(Canvas: TCanvas; lpString: PWideChar; var lpRect: TRect; uFo
|
||||
var Style:TTextStyle;
|
||||
begin
|
||||
{$ifndef WINCE}
|
||||
{$ifdef LINUX}
|
||||
{$ifdef LCLgtk}
|
||||
Style.Layout:=tlCenter;
|
||||
Canvas.TextRect(lpRect,lpRect.Left,lpRect.Top,lpString,Style); // theo 24.2.2007 Gibt sonst Striche auf GTK1
|
||||
{$else}
|
||||
@ -3733,6 +3733,7 @@ var
|
||||
Dest: TRect;
|
||||
//Small (???) hack while a solution does not come
|
||||
Stream: TMemoryStream;
|
||||
TempOPB, SourceOPB:TCanvasOPBitmap;
|
||||
begin
|
||||
Watcher.Enter;
|
||||
try
|
||||
@ -3761,6 +3762,25 @@ begin
|
||||
|
||||
MaskColor := clFuchsia;//Images.Canvas.Pixels[0, 0]; // this is usually clFuchsia
|
||||
Dest := Rect(0, 0, IL.Width, IL.Height);
|
||||
|
||||
SourceOPB:=TCanvasOPBitmap.create; //theo 25.2.07
|
||||
AssignBitmapToOpBitmap(Images,SourceOPB);
|
||||
for I := 0 to (Images.Width div Images.Height) - 1 do
|
||||
begin
|
||||
Source := Rect(I * IL.Width, 0, (I + 1) * IL.Width, IL.Height);
|
||||
TempOPB:=TCanvasOPBitmap.create;
|
||||
TempOPB.Width:=IL.Height;
|
||||
TempOPB.Height:=IL.Width;
|
||||
TempOPB.Canvas.CopyRect(Dest, SourceOPB.Canvas, Source);
|
||||
TempOPB.TransparentColor:=MaskColor;
|
||||
AnotherImage:=TBitmap.Create;
|
||||
AssignOpBitmapToBitmap(TempOPB,AnotherImage);
|
||||
TempOPB.free;
|
||||
IL.AddDirect(AnotherImage, nil);
|
||||
end;
|
||||
SourceOPB.free;
|
||||
|
||||
{
|
||||
for I := 0 to (Images.Width div Images.Height) - 1 do
|
||||
begin
|
||||
Source := Rect(I * IL.Width, 0, (I + 1) * IL.Width, IL.Height);
|
||||
@ -3777,6 +3797,7 @@ begin
|
||||
Stream.Size:=0;
|
||||
IL.AddDirect(AnotherImage, nil);
|
||||
end;
|
||||
}
|
||||
finally
|
||||
Images.Free;
|
||||
//OneImage.Free;
|
||||
@ -3876,8 +3897,8 @@ var
|
||||
begin
|
||||
|
||||
{$IFDEF LINUX} //theo 24.2.2007
|
||||
Width:=14;
|
||||
Height:=14; {$message warn'nur um die exception zu verhindern. Werte nicht getestet'}
|
||||
Width:=16;
|
||||
Height:=16; {$message warn'nur um die exception zu verhindern. Werte nicht getestet'}
|
||||
{$ELSE}
|
||||
Width := GetSystemMetrics(SM_CXMENUCHECK) + 3;
|
||||
Height := GetSystemMetrics(SM_CYMENUCHECK) + 3;
|
||||
@ -5725,8 +5746,6 @@ begin
|
||||
Result := 0;
|
||||
end;
|
||||
|
||||
|
||||
|
||||
procedure TVTDragImage.RecaptureBackground(Tree: TBaseVirtualTree; R: TRect; VisibleRegion: HRGN;
|
||||
CaptureNCArea, ReshowDragImage: Boolean);
|
||||
|
||||
@ -7124,138 +7143,87 @@ const
|
||||
XPDownMiddleLineColor = $B8C2C1; // Down state border color.
|
||||
XPDownInnerLineColor = $C9D1D0; // Down state border color.
|
||||
|
||||
procedure TVirtualTreeColumns.DrawXPButton(DC: HDC; ButtonR: TRect; DrawSplitter, Down, Hover: Boolean);
|
||||
|
||||
// Helper procedure to draw an Windows XP like header button.
|
||||
|
||||
//theo 25.2.07
|
||||
procedure TVirtualTreeColumns.DrawXPButton(Canvas: TCanvas; ButtonR: TRect; DrawSplitter, Down, Hover, HoverOnTop: Boolean);
|
||||
var
|
||||
PaintBrush: HBRUSH;
|
||||
Pen,
|
||||
OldPen: HPEN;
|
||||
PenColor,
|
||||
FillColor: COLORREF;
|
||||
dRed, dGreen, dBlue: Single;
|
||||
Width,
|
||||
XPos: Integer;
|
||||
|
||||
SavBrColor, SavPnColor, PenColor: TColor;
|
||||
dRed, dGreen, dBlue: integer;
|
||||
Y, dY: integer;
|
||||
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
|
||||
if Hover then
|
||||
FillColor := XPMainHeaderColorHover
|
||||
else
|
||||
FillColor := XPMainHeaderColorUp;
|
||||
PaintBrush := CreateSolidBrush(FillColor);
|
||||
FillRect(DC, ButtonR, PaintBrush);
|
||||
DeleteObject(PaintBrush);
|
||||
Canvas.Brush.Color := XPMainHeaderColorUp;
|
||||
Canvas.FillRect(ButtonR);
|
||||
Canvas.Brush.Color:=SavBrColor;
|
||||
|
||||
if DrawSplitter and not (Down or Hover) then
|
||||
begin
|
||||
// One solid pen for the dark line...
|
||||
Pen := CreatePen(PS_SOLID, 1, XPDarkSplitBarColor);
|
||||
OldPen := SelectObject(DC, Pen);
|
||||
MoveToEx(DC, ButtonR.Right - 2, ButtonR.Top + 3, nil);
|
||||
LineTo(DC, ButtonR.Right - 2, ButtonR.Bottom - 5);
|
||||
// ... and one solid pen for the light line.
|
||||
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);
|
||||
Canvas.Pen.Color:=XPDarkSplitBarColor;
|
||||
Canvas.MoveTo(ButtonR.Right - 2, ButtonR.Top + 3);
|
||||
Canvas.LineTo(ButtonR.Right - 2, ButtonR.Bottom - 5);
|
||||
Canvas.Pen.Color:=XPLightSplitBarColor;
|
||||
Canvas.MoveTo(ButtonR.Right - 1, ButtonR.Top + 3);
|
||||
Canvas.LineTo(ButtonR.Right - 1, ButtonR.Bottom - 5);
|
||||
end;
|
||||
|
||||
if Down then
|
||||
begin
|
||||
// Down state. Three lines to draw.
|
||||
// First one is the outer line, drawn at left, bottom and right.
|
||||
Pen := CreatePen(PS_SOLID, 1, XPDownOuterLineColor);
|
||||
OldPen := SelectObject(DC, Pen);
|
||||
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);
|
||||
if Down then begin
|
||||
Canvas.Pen.Color:=XPDownOuterLineColor;
|
||||
Canvas.MoveTo(ButtonR.Left, ButtonR.Top);
|
||||
Canvas.LineTo(ButtonR.Left, ButtonR.Bottom - 1);
|
||||
Canvas.LineTo(ButtonR.Right - 1, ButtonR.Bottom - 1);
|
||||
Canvas.LineTo(ButtonR.Right - 1, ButtonR.Top - 1);
|
||||
|
||||
// Second one is the middle line, which is a bit lighter.
|
||||
Pen := CreatePen(PS_SOLID, 1, XPDownMiddleLineColor);
|
||||
DeleteObject(SelectObject(DC, Pen));
|
||||
MoveToEx(DC, ButtonR.Left + 1, ButtonR.Bottom - 2, nil);
|
||||
LineTo(DC, ButtonR.Left + 1, ButtonR.Top);
|
||||
LineTo(DC, ButtonR.Right - 1, ButtonR.Top);
|
||||
Canvas.Pen.Color:=XPDownMiddleLineColor;
|
||||
Canvas.MoveTo(ButtonR.Left + 1, ButtonR.Bottom - 2);
|
||||
Canvas.LineTo(ButtonR.Left + 1, ButtonR.Top);
|
||||
Canvas.LineTo(ButtonR.Right - 1, ButtonR.Top);
|
||||
|
||||
// Third line is the inner line, which is even lighter than the middle line.
|
||||
Pen := CreatePen(PS_SOLID, 1, XPDownInnerLineColor);
|
||||
DeleteObject(SelectObject(DC, Pen));
|
||||
MoveToEx(DC, ButtonR.Left + 2, ButtonR.Bottom - 2, nil);
|
||||
LineTo(DC, ButtonR.Left + 2, ButtonR.Top + 1);
|
||||
LineTo(DC, ButtonR.Right - 1, ButtonR.Top + 1);
|
||||
|
||||
// Housekeeping:
|
||||
SelectObject(DC, OldPen);
|
||||
DeleteObject(Pen);
|
||||
Canvas.Pen.Color:=XPDownInnerLineColor;
|
||||
Canvas.MoveTo(ButtonR.Left + 2, ButtonR.Bottom - 2);
|
||||
Canvas.LineTo(ButtonR.Left + 2, ButtonR.Top + 1);
|
||||
Canvas.LineTo(ButtonR.Right - 1, ButtonR.Top + 1);
|
||||
end
|
||||
else
|
||||
if Hover then
|
||||
begin
|
||||
// Hover state. There are three lines at the bottom border, but they are rendered in a way which
|
||||
// requires expensive construction.
|
||||
Width := ButtonR.Right - ButtonR.Left;
|
||||
if Width <= 32 then
|
||||
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;
|
||||
else if Hover then begin
|
||||
//DrawXPHover(Canvas, ButtonR, HoverOnTop);
|
||||
end
|
||||
else begin
|
||||
if HoverOnTop then begin
|
||||
Y:=ButtonR.Top;
|
||||
dY:=1;
|
||||
end
|
||||
else
|
||||
begin
|
||||
// There is a three line gradient near the bottom border which transforms from the button color to a dark,
|
||||
// clBtnFace like color (here XPDarkGradientColor).
|
||||
PenColor := XPMainHeaderColorUp;
|
||||
dRed := ((PenColor and $FF) - (XPDarkGradientColor and $FF)) / 3;
|
||||
dGreen := (((PenColor shr 8) and $FF) - ((XPDarkGradientColor shr 8) and $FF)) / 3;
|
||||
dBlue := (((PenColor shr 16) and $FF) - ((XPDarkGradientColor shr 16) and $FF)) / 3;
|
||||
else begin
|
||||
Y:=ButtonR.Bottom-1;
|
||||
dY:=-1;
|
||||
end;
|
||||
PenColor := XPMainHeaderColorUp;
|
||||
dRed := ((PenColor and $FF) - (XPDarkGradientColor and $FF)) div 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)) div 3;
|
||||
|
||||
// First line:
|
||||
PenColor := PenColor - Round(dRed) - Round(dGreen) shl 8 - Round(dBlue) shl 16;
|
||||
Pen := CreatePen(PS_SOLID, 1, PenColor);
|
||||
OldPen := SelectObject(DC, Pen);
|
||||
MoveToEx(DC, ButtonR.Left, ButtonR.Bottom - 3, nil);
|
||||
LineTo(DC, ButtonR.Right, ButtonR.Bottom - 3);
|
||||
PenColor := PenColor - Lo(dRed) - Lo(dGreen) shl 8 - Lo(dBlue) shl 16;
|
||||
Canvas.Pen.Color:=PenColor;
|
||||
Canvas.MoveTo(ButtonR.Left, Y + 2*dY);
|
||||
Canvas.LineTo(ButtonR.Right, Y + 2*dY);
|
||||
|
||||
// Second line:
|
||||
PenColor := PenColor - Round(dRed) - Round(dGreen) shl 8 - Round(dBlue) shl 16;
|
||||
Pen := CreatePen(PS_SOLID, 1, PenColor);
|
||||
DeleteObject(SelectObject(DC, Pen));
|
||||
MoveToEx(DC, ButtonR.Left, ButtonR.Bottom - 2, nil);
|
||||
LineTo(DC, ButtonR.Right, ButtonR.Bottom - 2);
|
||||
Canvas.Pen.Color := PenColor - Lo(dRed) - Lo(dGreen) shl 8 - Lo(dBlue) shl 16;
|
||||
Canvas.MoveTo(ButtonR.Left, Y + dY);
|
||||
Canvas.LineTo(ButtonR.Right, Y + dY);
|
||||
|
||||
// Third line:
|
||||
Pen := CreatePen(PS_SOLID, 1, XPDarkGradientColor);
|
||||
DeleteObject(SelectObject(DC, Pen));
|
||||
MoveToEx(DC, ButtonR.Left, ButtonR.Bottom - 1, nil);
|
||||
LineTo(DC, ButtonR.Right, ButtonR.Bottom - 1);
|
||||
|
||||
// Housekeeping:
|
||||
DeleteObject(SelectObject(DC, OldPen));
|
||||
end; }
|
||||
Canvas.Pen.Color := XPDarkGradientColor;
|
||||
Canvas.MoveTo(ButtonR.Left, Y);
|
||||
Canvas.LineTo(ButtonR.Right, Y);
|
||||
end;
|
||||
Canvas.Pen.Color:=SavPnColor;
|
||||
end;
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
procedure TVirtualTreeColumns.FixPositions;
|
||||
@ -8047,7 +8015,7 @@ begin
|
||||
else
|
||||
{$endif ThemeSupport}
|
||||
if FHeader.Style = hsXPStyle then
|
||||
DrawXPButton(Handle, Run, False, False, False)
|
||||
DrawXPButton(PaintInfo.TargetCanvas, Run, False, False, False, False)
|
||||
else
|
||||
begin
|
||||
Brush.Color := FHeader.FBackground;
|
||||
@ -8133,7 +8101,7 @@ begin
|
||||
{$endif ThemeSupport}
|
||||
begin
|
||||
if FHeader.Style = hsXPStyle then
|
||||
DrawXPButton(Handle, PaintRectangle, RightBorderFlag <> 0, IsDownIndex, IsHoverIndex)
|
||||
DrawXPButton(PaintInfo.TargetCanvas, PaintRectangle, RightBorderFlag <> 0, IsDownIndex, IsHoverIndex, False)
|
||||
else
|
||||
if IsDownIndex then
|
||||
DrawEdge(Handle, PaintRectangle, PressedButtonStyle, PressedButtonFlags)
|
||||
|
Loading…
Reference in New Issue
Block a user