You've already forked lazarus-ccr
* Fix possible infinite loop in TJvXPBarItem.GetDisplayName
* Draw image from image list directly instead of using a temp bitmap git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@1041 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -101,7 +101,7 @@ type
|
|||||||
Collapsing: Boolean) of object;
|
Collapsing: Boolean) of object;
|
||||||
|
|
||||||
TJvXPBarOnDrawItemEvent = procedure(Sender: TObject; ACanvas: TCanvas;
|
TJvXPBarOnDrawItemEvent = procedure(Sender: TObject; ACanvas: TCanvas;
|
||||||
Rect: TRect; State: TJvXPDrawState; Item: TJvXPBarItem; Bitmap: TBitmap) of object;
|
Rect: TRect; State: TJvXPDrawState; Item: TJvXPBarItem) of object;
|
||||||
TJvXPBarOwnerDrawEvent = procedure(Sender: TObject; ACanvas: TCanvas; var ARect: TRect) of object;
|
TJvXPBarOwnerDrawEvent = procedure(Sender: TObject; ACanvas: TCanvas; var ARect: TRect) of object;
|
||||||
|
|
||||||
TJvXPBarOnItemClickEvent = procedure(Sender: TObject; Item: TJvXPBarItem) of object;
|
TJvXPBarOnItemClickEvent = procedure(Sender: TObject; Item: TJvXPBarItem) of object;
|
||||||
@ -183,7 +183,7 @@ type
|
|||||||
procedure ActionChange(Sender: TObject; CheckDefaults: Boolean); dynamic;
|
procedure ActionChange(Sender: TObject; CheckDefaults: Boolean); dynamic;
|
||||||
|
|
||||||
procedure DrawItem(AWinXPBar: TJvXPCustomWinXPBar; ACanvas: TCanvas;
|
procedure DrawItem(AWinXPBar: TJvXPCustomWinXPBar; ACanvas: TCanvas;
|
||||||
Rect: TRect; State: TJvXPDrawState; ShowItemFrame: Boolean; Bitmap: TBitmap); virtual;
|
Rect: TRect; State: TJvXPDrawState; ShowItemFrame: Boolean); virtual;
|
||||||
property ActionLink: TJvXPBarItemActionLink read FActionLink write FActionLink;
|
property ActionLink: TJvXPBarItemActionLink read FActionLink write FActionLink;
|
||||||
public
|
public
|
||||||
constructor Create(ACollection: TCollection); override;
|
constructor Create(ACollection: TCollection); override;
|
||||||
@ -502,6 +502,7 @@ type
|
|||||||
property Align;
|
property Align;
|
||||||
property Anchors;
|
property Anchors;
|
||||||
//property AutoSize;
|
//property AutoSize;
|
||||||
|
property BorderSpacing;
|
||||||
property Constraints;
|
property Constraints;
|
||||||
property DragCursor;
|
property DragCursor;
|
||||||
property DragKind;
|
property DragKind;
|
||||||
@ -719,18 +720,14 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
function TJvXPBarItem.GetDisplayName: string;
|
function TJvXPBarItem.GetDisplayName: string;
|
||||||
var
|
|
||||||
_DisplayName, ItemName: string;
|
|
||||||
begin
|
begin
|
||||||
_DisplayName := FCaption;
|
Result := FCaption;
|
||||||
if _DisplayName = '' then
|
if Result = '' then
|
||||||
_DisplayName := RsUntitled;
|
Result := RsUntitled;
|
||||||
ItemName := FName;
|
if FName <> '' then
|
||||||
if ItemName <> '' then
|
Result := Result + ' [' + FName + ']';
|
||||||
DisplayName := DisplayName + ' [' + ItemName + ']';
|
|
||||||
if not FVisible then
|
if not FVisible then
|
||||||
_DisplayName := _DisplayName + '*';
|
Result := Result + '*';
|
||||||
Result := _DisplayName;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TJvXPBarItem.GetImages: TCustomImageList;
|
function TJvXPBarItem.GetImages: TCustomImageList;
|
||||||
@ -773,14 +770,13 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TJvXPBarItem.DrawItem(AWinXPBar: TJvXPCustomWinXPBar; ACanvas: TCanvas;
|
procedure TJvXPBarItem.DrawItem(AWinXPBar: TJvXPCustomWinXPBar; ACanvas: TCanvas;
|
||||||
Rect: TRect; State: TJvXPDrawState; ShowItemFrame: Boolean; Bitmap: TBitmap);
|
Rect: TRect; State: TJvXPDrawState; ShowItemFrame: Boolean);
|
||||||
var
|
var
|
||||||
ItemCaption: TCaption;
|
ItemCaption: TCaption;
|
||||||
HasImages: Boolean;
|
WorkImages: TCustomImageList;
|
||||||
LBar: TJvXPCustomWinXPBar;
|
LBar: TJvXPCustomWinXPBar;
|
||||||
begin
|
begin
|
||||||
LBar := (AWinXPBar as TJvXPCustomWinXPBar);
|
LBar := (AWinXPBar as TJvXPCustomWinXPBar);
|
||||||
HasImages := Self.Images <> nil;
|
|
||||||
with ACanvas do
|
with ACanvas do
|
||||||
begin
|
begin
|
||||||
Font.Assign(LBar.Font);
|
Font.Assign(LBar.Font);
|
||||||
@ -829,13 +825,12 @@ begin
|
|||||||
else
|
else
|
||||||
FillRect(Rect);
|
FillRect(Rect);
|
||||||
end;
|
end;
|
||||||
if HasImages then
|
WorkImages := Self.Images;
|
||||||
|
if WorkImages <> nil then
|
||||||
begin
|
begin
|
||||||
if (Self.ImageIndex <> -1) then
|
if (Self.ImageIndex <> -1) then
|
||||||
Self.Images.Draw(ACanvas, Rect.Left + 1,
|
WorkImages.Draw(ACanvas, Rect.Left + 1,
|
||||||
Rect.Top + (LBar.FItemHeight - Bitmap.Height) div 2, Self.ImageIndex);
|
Rect.Top + (LBar.FItemHeight - WorkImages.Height) div 2, Self.ImageIndex);
|
||||||
//Original:
|
|
||||||
//Draw(Rect.Left + 1, Rect.Top + (LBar.FItemHeight - Bitmap.Height) div 2, Bitmap);
|
|
||||||
Inc(Rect.Left, Self.Images.Width + 4);
|
Inc(Rect.Left, Self.Images.Width + 4);
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
@ -1909,30 +1904,18 @@ end;
|
|||||||
|
|
||||||
procedure TJvXPCustomWinXPBar.DoDrawItem(const Index: Integer; State: TJvXPDrawState);
|
procedure TJvXPCustomWinXPBar.DoDrawItem(const Index: Integer; State: TJvXPDrawState);
|
||||||
var
|
var
|
||||||
Bitmap: TBitmap;
|
|
||||||
ItemRect: TRect;
|
ItemRect: TRect;
|
||||||
HasImages: Boolean;
|
|
||||||
begin
|
begin
|
||||||
Bitmap := TBitmap.Create;
|
|
||||||
with Canvas do
|
with Canvas do
|
||||||
try
|
|
||||||
Bitmap.Assign(nil);
|
|
||||||
ItemRect := GetItemRect(Index);
|
|
||||||
HasImages := FVisibleItems[Index].Images <> nil;
|
|
||||||
if HasImages then
|
|
||||||
begin
|
begin
|
||||||
FVisibleItems[Index].Images.GetBitmap(FVisibleItems[Index].ImageIndex, Bitmap);
|
ItemRect := GetItemRect(Index);
|
||||||
end;
|
|
||||||
Bitmap.Transparent := True;
|
|
||||||
if OwnerDraw then
|
if OwnerDraw then
|
||||||
begin
|
begin
|
||||||
if Assigned(FOnDrawItem) then
|
if Assigned(FOnDrawItem) then
|
||||||
FOnDrawItem(Self, Canvas, ItemRect, State, FVisibleItems[Index], Bitmap);
|
FOnDrawItem(Self, Canvas, ItemRect, State, FVisibleItems[Index]);
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
FVisibleItems[Index].DrawItem(Self, Canvas, ItemRect, State, ShowItemFrame, Bitmap);
|
FVisibleItems[Index].DrawItem(Self, Canvas, ItemRect, State, ShowItemFrame);
|
||||||
finally
|
|
||||||
Bitmap.Free;
|
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user