IDE: ComponentList, ComponentPalette: High-DPI

git-svn-id: trunk@54291 -
This commit is contained in:
ondrej 2017-02-27 10:02:12 +00:00
parent e408c18e8e
commit df06ce604d
3 changed files with 70 additions and 44 deletions

View File

@ -1,7 +1,7 @@
object ComponentListForm: TComponentListForm
Left = 560
Left = 467
Height = 467
Top = 216
Top = 200
Width = 300
Caption = 'Components'
ClientHeight = 467
@ -43,7 +43,7 @@ object ComponentListForm: TComponentListForm
Top = 2
Width = 288
Align = alClient
DefaultItemHeight = 26
DefaultItemHeight = 24
Images = imListPalette
Indent = 25
ReadOnly = True
@ -56,32 +56,32 @@ object ComponentListForm: TComponentListForm
OnDblClick = ComponentsDblClick
OnKeyPress = TreeKeyPress
OnSelectionChanged = ListTreeSelectionChanged
Options = [tvoHideSelection, tvoKeepCollapsedNodes, tvoReadOnly, tvoRowSelect, tvoToolTips]
Options = [tvoAutoItemHeight, tvoHideSelection, tvoKeepCollapsedNodes, tvoReadOnly, tvoRowSelect, tvoToolTips]
end
end
end
object TabSheetPaletteTree: TTabSheet
Caption = 'Palette'
ClientHeight = 361
ClientWidth = 296
ClientHeight = 369
ClientWidth = 292
object pnPaletteTree: TPanel
Left = 0
Height = 375
Height = 369
Top = 0
Width = 296
Width = 292
Align = alClient
BevelOuter = bvNone
BorderWidth = 5
ClientHeight = 375
ClientWidth = 296
ClientHeight = 369
ClientWidth = 292
TabOrder = 0
object PalletteTree: TTreeView
Left = 5
Height = 365
Height = 359
Top = 5
Width = 286
Width = 282
Align = alClient
DefaultItemHeight = 26
DefaultItemHeight = 24
Images = imListPalette
PopupMenu = pmCollapseExpand
ReadOnly = True
@ -93,32 +93,32 @@ object ComponentListForm: TComponentListForm
OnDblClick = ComponentsDblClick
OnKeyPress = TreeKeyPress
OnSelectionChanged = ListTreeSelectionChanged
Options = [tvoHideSelection, tvoKeepCollapsedNodes, tvoReadOnly, tvoRightClickSelect, tvoRowSelect, tvoShowButtons, tvoShowRoot, tvoToolTips]
Options = [tvoAutoItemHeight, tvoHideSelection, tvoKeepCollapsedNodes, tvoReadOnly, tvoRightClickSelect, tvoRowSelect, tvoShowButtons, tvoShowRoot, tvoToolTips]
end
end
end
object TabSheetInheritance: TTabSheet
Caption = 'Inheritance'
ClientHeight = 361
ClientWidth = 296
ClientHeight = 369
ClientWidth = 292
object Panel6: TPanel
Left = 0
Height = 375
Height = 369
Top = 0
Width = 296
Width = 292
Align = alClient
BevelOuter = bvNone
BorderWidth = 5
ClientHeight = 375
ClientWidth = 296
ClientHeight = 369
ClientWidth = 292
TabOrder = 0
object InheritanceTree: TTreeView
Left = 5
Height = 365
Height = 359
Top = 5
Width = 286
Width = 282
Align = alClient
DefaultItemHeight = 26
DefaultItemHeight = 24
Images = imListPalette
Indent = 20
PopupMenu = pmCollapseExpand
@ -130,7 +130,7 @@ object ComponentListForm: TComponentListForm
OnDblClick = ComponentsDblClick
OnKeyPress = TreeKeyPress
OnSelectionChanged = ListTreeSelectionChanged
Options = [tvoHideSelection, tvoKeepCollapsedNodes, tvoReadOnly, tvoRightClickSelect, tvoRowSelect, tvoShowButtons, tvoShowLines, tvoShowRoot, tvoToolTips]
Options = [tvoAutoItemHeight, tvoHideSelection, tvoKeepCollapsedNodes, tvoReadOnly, tvoRightClickSelect, tvoRowSelect, tvoShowButtons, tvoShowLines, tvoShowRoot, tvoToolTips]
end
end
end
@ -212,13 +212,13 @@ object ComponentListForm: TComponentListForm
object imListPalette: TImageList
Height = 24
Width = 24
left = 56
top = 112
Left = 56
Top = 112
end
object pmCollapseExpand: TPopupMenu
OnPopup = pmCollapseExpandPopup
left = 160
top = 112
Left = 160
Top = 112
object miExpand: TMenuItem
Caption = 'Expand'
OnClick = miExpandClick
@ -242,14 +242,14 @@ object ComponentListForm: TComponentListForm
object imInheritance: TImageList
Height = 24
Width = 24
left = 56
top = 168
Left = 56
Top = 168
end
object tmDeselect: TTimer
Enabled = False
Interval = 100
OnTimer = tmDeselectTimer
left = 155
top = 172
Left = 155
Top = 172
end
end

View File

@ -136,10 +136,10 @@ begin
OKButton.Caption := lisUse;
chbKeepOpen.Caption := lisKeepOpen;
imListPalette.Width := ComponentPaletteImageWidth;
imListPalette.Height := ComponentPaletteImageHeight;
imInheritance.Width := ComponentPaletteImageWidth;
imInheritance.Height := ComponentPaletteImageHeight;
imListPalette.Width := MulDiv(ComponentPaletteImageWidth, TIDEImages.GetScalePercent, 100);
imListPalette.Height := MulDiv(ComponentPaletteImageHeight, TIDEImages.GetScalePercent, 100);
imInheritance.Width := MulDiv(ComponentPaletteImageWidth, TIDEImages.GetScalePercent, 100);
imInheritance.Height := MulDiv(ComponentPaletteImageHeight, TIDEImages.GetScalePercent, 100);
ListTree.Images := imListPalette;
PalletteTree.Images := imListPalette;
@ -323,6 +323,8 @@ var
ClssName: string;
i, Ind: Integer;
CurIcon: TCustomBitmap;
ScaledIcon: TGraphic;
NewScaledIcon: Boolean;
begin
PalList := TStringList.Create;
try
@ -357,8 +359,14 @@ begin
CurIcon := nil;
if Assigned(CurIcon) then
begin
Node.ImageIndex := imInheritance.Add(CurIcon, nil);
Node.SelectedIndex := Node.ImageIndex;
ScaledIcon := TIDEImages.ScaleImage(CurIcon, NewScaledIcon, imInheritance.Width, imInheritance.Height);
try
Node.ImageIndex := imInheritance.Add(ScaledIcon as TCustomBitmap, nil);
Node.SelectedIndex := Node.ImageIndex;
finally
if NewScaledIcon then
ScaledIcon.Free;
end;
end;
end;
FClassList.AddObject(ClssName, Node);
@ -380,6 +388,8 @@ var
APaletteNode: TTreeNode;
i, j: Integer;
CurIcon: TCustomBitmap;
NewScaledIcon: Boolean;
ScaledIcon: TGraphic;
begin
if [csDestroying,csLoading]*ComponentState<>[] then exit;
Screen.Cursor := crHourGlass;
@ -416,10 +426,16 @@ begin
CurIcon := nil;
if Assigned(CurIcon) then
begin
AListNode.ImageIndex := imListPalette.Add(CurIcon, nil);
AListNode.SelectedIndex := AListNode.ImageIndex;
APaletteNode.ImageIndex := AListNode.ImageIndex;
APaletteNode.SelectedIndex := AListNode.ImageIndex;
ScaledIcon := TIDEImages.ScaleImage(CurIcon, NewScaledIcon, imListPalette.Width, imListPalette.Height);
try
AListNode.ImageIndex := imListPalette.Add(ScaledIcon as TCustomBitmap, nil);
AListNode.SelectedIndex := AListNode.ImageIndex;
APaletteNode.ImageIndex := AListNode.ImageIndex;
APaletteNode.SelectedIndex := AListNode.ImageIndex;
finally
if NewScaledIcon then
ScaledIcon.Free;
end;
end;
// Component inheritence item
DoComponentInheritence(Comp);

View File

@ -38,7 +38,7 @@ unit ComponentPalette;
interface
uses
Classes, SysUtils, AVL_Tree, fgl,
Classes, SysUtils, AVL_Tree, fgl, LCLType,
Controls, Forms, Graphics, ComCtrls, Buttons, Menus, ExtCtrls,
LazFileUtils, LazFileCache, PropEdits, LCLProc, MainBase, LazarusIDEStrConsts,
FormEditingIntf, LazIDEIntf, IDEImagesIntf,
@ -422,6 +422,8 @@ var
Btn: TSpeedButton;
CompCN: String; // Component ClassName
i: Integer;
ScaledIcon: TGraphic;
NewScaledIcon: Boolean;
begin
Pal := TComponentPalette(Palette);
CompCN := aComp.ComponentClass.ClassName;
@ -439,7 +441,15 @@ begin
Btn.Name := CompPaletteCompBtnPrefix + aButtonUniqueName + CompCN;
// Left and Top will be set in ReAlignButtons.
Btn.SetBounds(Btn.Left,Btn.Top,aScrollBox.ScaleCoord(ComponentPaletteBtnWidth),aScrollBox.ScaleCoord(ComponentPaletteBtnHeight));
Btn.Glyph.Assign(aComp.Icon);
ScaledIcon := TIDEImages.ScaleImage(aComp.Icon, NewScaledIcon,
MulDiv(ComponentPaletteImageWidth, TIDEImages.GetScalePercent, 100),
MulDiv(ComponentPaletteImageWidth, TIDEImages.GetScalePercent, 100));
try
Btn.Glyph.Assign(ScaledIcon);
finally
if NewScaledIcon then
ScaledIcon.Free;
end;
Btn.GroupIndex := 1;
Btn.Flat := true;
Btn.OnMouseDown := @Pal.ComponentBtnMouseDown;