IdeIntf: Show icons in ActionlistEditor in native size. Fix offset in ImageIndexPropertyEditor. Issue #35810.

git-svn-id: trunk@62815 -
This commit is contained in:
juha 2020-03-28 11:21:40 +00:00
parent d5e5203170
commit 5a2520082e
2 changed files with 26 additions and 24 deletions

View File

@ -27,7 +27,7 @@ uses
Classes, SysUtils, contnrs, Classes, SysUtils, contnrs,
// LCL // LCL
LCLType, LCLProc, Forms, Controls, Dialogs, ExtCtrls, StdCtrls, LCLType, LCLProc, Forms, Controls, Dialogs, ExtCtrls, StdCtrls,
Graphics, Menus, ComCtrls, DBActns, StdActns, ActnList, Graphics, Menus, ComCtrls, DBActns, StdActns, ActnList, ImgList,
// IDEIntf // IDEIntf
ObjInspStrConsts, ComponentEditors, PropEdits, PropEditUtils, IDEWindowIntf, ObjInspStrConsts, ComponentEditors, PropEdits, PropEditUtils, IDEWindowIntf,
IDEImagesIntf; IDEImagesIntf;
@ -756,14 +756,17 @@ end;
procedure TActionListEditor.lstActionNameDrawItem(Control: TWinControl; procedure TActionListEditor.lstActionNameDrawItem(Control: TWinControl;
Index: Integer; ARect: TRect; State: TOwnerDrawState); Index: Integer; ARect: TRect; State: TOwnerDrawState);
var var
lb: TListBox;
ACanvas: TCanvas; ACanvas: TCanvas;
R: TRect; R: TRect;
dh, dth: Integer; dh: Integer;
Imgs: TCustomImageList;
AAction: TCustomAction; AAction: TCustomAction;
S: String; S: String;
begin begin
if FActionList=nil then exit;; if FActionList=nil then exit;
ACanvas := TListBox(Control).Canvas; lb := TListBox(Control);
ACanvas := lb.Canvas;
if odSelected in State then if odSelected in State then
begin begin
ACanvas.Brush.Color := clHighlight; ACanvas.Brush.Color := clHighlight;
@ -773,27 +776,21 @@ begin
ACanvas.Brush.Color := clWindow; ACanvas.Brush.Color := clWindow;
ACanvas.Font.Color := clWindowText; ACanvas.Font.Color := clWindowText;
end; end;
S := TListBox(Control).Items[Index];
R := ARect; R := ARect;
dh := R.Bottom - R.Top; dh := R.Bottom - R.Top;
ACanvas.FillRect(R); ACanvas.FillRect(R);
inc(R.Left, 2); inc(R.Left, 2);
if (TListBox(Control).Items.Objects[Index] is TCustomAction) Imgs := FActionList.Images;
and (FActionList.Images <> nil) then begin if (lb.Items.Objects[Index] is TCustomAction) and Assigned(Imgs) then
AAction := TListBox(Control).Items.Objects[Index] as TCustomAction; begin
AAction := TCustomAction(lb.Items.Objects[Index]);
R.Right := R.Left + dh; R.Right := R.Left + dh;
if AAction.ImageIndex <> -1 then if AAction.ImageIndex <> -1 then
begin Imgs.Draw(ACanvas, R.Left, R.Top + (dh-Imgs.Height) div 2, AAction.ImageIndex);
dth := FActionList.Images.Height;
if dth > dh then
FActionList.Images.StretchDraw(ACanvas, AAction.ImageIndex, Rect(R.Left, R.Top + 1, R.Left + dh - 2, R.Bottom - 1))
else
FActionList.Images.Draw(ACanvas, R.Left, R.Top + (dh -dth) div 2, AAction.ImageIndex);
end;
Inc(R.Left, dh + 2); Inc(R.Left, dh + 2);
end; end;
dth := Canvas.TextHeight(S); S := lb.Items[Index];
ACanvas.TextOut(R.Left, R.Top + (dh - dth) div 2, S); ACanvas.TextOut(R.Left, R.Top + (dh-Canvas.TextHeight(S)) div 2, S);
if odFocused in State then if odFocused in State then
ACanvas.DrawFocusRect(ARect); ACanvas.DrawFocusRect(ARect);
end; end;
@ -906,7 +903,12 @@ begin
if FActionList = AActionList then exit; if FActionList = AActionList then exit;
if FActionList<>nil then RemoveFreeNotification(FActionList); if FActionList<>nil then RemoveFreeNotification(FActionList);
FActionList := AActionList; FActionList := AActionList;
if FActionList<>nil then FreeNotification(FActionList); if FActionList<>nil then
begin
FreeNotification(FActionList);
if FActionList.Images<>nil then
lstActionName.ItemHeight := FActionList.Images.Height;
end;
FillCategories; FillCategories;
//FillActionByCategory(-1); //FillActionByCategory(-1);
end; end;

View File

@ -759,27 +759,27 @@ procedure TImageIndexPropertyEditor.ListDrawValue(const CurValue: ansistring;
var var
Images: TCustomImageList; Images: TCustomImageList;
R: TRect; R: TRect;
OldColor: TColor; dh: Integer;
begin begin
if GetDefaultOrdValue <> NoDefaultValue then if GetDefaultOrdValue <> NoDefaultValue then
Dec(Index); Dec(Index);
Images := GetImageList; Images := GetImageList;
R := ARect; R := ARect;
dh := R.Bottom - R.Top; // Rect height.
if Assigned(Images) then if Assigned(Images) then
begin begin
if (pedsInComboList in AState) and not (pedsInEdit in AState) then if (pedsInComboList in AState) and not (pedsInEdit in AState) then
begin begin
OldColor := ACanvas.Brush.Color;
if pedsSelected in AState then if pedsSelected in AState then
ACanvas.Brush.Color := clHighlight ACanvas.Brush.Color := clHighlight
else else
ACanvas.Brush.Color := clWhite; ACanvas.Brush.Color := clWhite;
ACanvas.FillRect(R); ACanvas.FillRect(R);
ACanvas.Brush.Color := OldColor;
end; end;
Images.Draw(ACanvas, R.Left + 1, R.Top + 1, Index);
Images.Draw(ACanvas, R.Left + 1, R.Top + 1, Index, True); Inc(R.Left, Images.Width + 2);
R.Left := R.Left + Images.Width + 2; // The numeric value in list goes too low without an adjustment. Why?
Dec(R.Top, (dh - ACanvas.TextHeight(CurValue)) div 2);
end; end;
inherited ListDrawValue(CurValue, Index, ACanvas, R, AState); inherited ListDrawValue(CurValue, Index, ACanvas, R, AState);
end; end;