mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-18 12:41:21 +02:00
IDE: Support 3 icons with different resolutions in "New Component" dialog. Improve the GUI.
git-svn-id: trunk@59170 -
This commit is contained in:
parent
571647e302
commit
24f8569925
@ -1551,7 +1551,6 @@ resourcestring
|
|||||||
lisPkgMangThePackageFailedToCompileRemoveItFromTheInstallati = 'The package "%s" '
|
lisPkgMangThePackageFailedToCompileRemoveItFromTheInstallati = 'The package "%s" '
|
||||||
+'failed to compile.%sRemove it from the installation list?';
|
+'failed to compile.%sRemove it from the installation list?';
|
||||||
lisEnvOptDlgTestDirNotFoundMsg = 'Test directory "%s" not found.';
|
lisEnvOptDlgTestDirNotFoundMsg = 'Test directory "%s" not found.';
|
||||||
lisTitleOpenComponentIcon24x24 = 'Choose a component icon 24x24';
|
|
||||||
|
|
||||||
// open-dialog filters
|
// open-dialog filters
|
||||||
dlgFilterAll = 'All files';
|
dlgFilterAll = 'All files';
|
||||||
@ -4531,8 +4530,6 @@ resourcestring
|
|||||||
lisA2PPageNameTooLong = 'Page Name too long';
|
lisA2PPageNameTooLong = 'Page Name too long';
|
||||||
lisA2PThePageNameIsTooLongMax100Chars = 'The page name "%s" is too long (max 100 chars).';
|
lisA2PThePageNameIsTooLongMax100Chars = 'The page name "%s" is too long (max 100 chars).';
|
||||||
lisA2PUnitNameInvalid = 'Unit Name Invalid';
|
lisA2PUnitNameInvalid = 'Unit Name Invalid';
|
||||||
lisA2PTheUnitNameDoesNotCorrespondToTheFilename = 'The unit name "%s" '
|
|
||||||
+'does not correspond to the filename.';
|
|
||||||
lisA2PInvalidClassName = 'Invalid Class Name';
|
lisA2PInvalidClassName = 'Invalid Class Name';
|
||||||
lisA2PTheClassNameIsNotAValidPascalIdentifier = 'The class name "%s" is '
|
lisA2PTheClassNameIsNotAValidPascalIdentifier = 'The class name "%s" is '
|
||||||
+'not a valid Pascal identifier.';
|
+'not a valid Pascal identifier.';
|
||||||
@ -4557,15 +4554,18 @@ resourcestring
|
|||||||
+'%sFor example: 1.0.20.10';
|
+'%sFor example: 1.0.20.10';
|
||||||
lisA2PNewFile = 'New File';
|
lisA2PNewFile = 'New File';
|
||||||
lisA2PAddFiles = 'Add Files';
|
lisA2PAddFiles = 'Add Files';
|
||||||
lisA2PAncestorType = 'Ancestor Type';
|
lisA2PAncestorType = 'Ancestor type';
|
||||||
lisA2PShowAll = 'Show all';
|
lisA2PShowAll = 'Show all';
|
||||||
lisA2PNewClassName = 'New class name:';
|
lisA2PNewClassName = 'New class name:';
|
||||||
lisA2PPalettePage = 'Palette Page:';
|
lisA2PPalettePage = 'Palette page:';
|
||||||
lisA2PUnitFileName2 = 'Unit File Name:';
|
lisA2PDirectoryForUnitFile = 'Directory for unit file:';
|
||||||
lisA2PUnitName = 'Unit Name:';
|
lisA2PUnitName = 'Unit name:';
|
||||||
lisA2PShortenOrExpandFilename = 'Shorten or expand filename';
|
lisA2PShortenOrExpandFilename = 'Shorten or expand filename';
|
||||||
lisA2PSaveFileDialog = 'Save file dialog';
|
lisA2PSaveFileDialog = 'Save file dialog';
|
||||||
lisA2PIconAndSize = 'Icon (maximum 24x24):';
|
lisA2PIcon24x24 = 'Icon 24x24:';
|
||||||
|
lisA2PIcon36x36 = 'Icon 36x36:';
|
||||||
|
lisA2PIcon48x48 = 'Icon 48x48:';
|
||||||
|
|
||||||
lisMoveSelectedUp = 'Move selected item up (Ctrl+Up)';
|
lisMoveSelectedUp = 'Move selected item up (Ctrl+Up)';
|
||||||
lisMoveSelectedDown = 'Move selected item down (Ctrl+Down)';
|
lisMoveSelectedDown = 'Move selected item down (Ctrl+Down)';
|
||||||
|
|
||||||
|
@ -1,23 +1,23 @@
|
|||||||
object AddToPackageDlg: TAddToPackageDlg
|
object AddToPackageDlg: TAddToPackageDlg
|
||||||
Left = 383
|
Left = 383
|
||||||
Height = 263
|
Height = 391
|
||||||
Top = 297
|
Top = 297
|
||||||
Width = 606
|
Width = 696
|
||||||
BorderIcons = [biSystemMenu, biMaximize]
|
BorderIcons = [biSystemMenu, biMaximize]
|
||||||
Caption = 'New component'
|
Caption = 'New component'
|
||||||
ClientHeight = 263
|
ClientHeight = 391
|
||||||
ClientWidth = 606
|
ClientWidth = 696
|
||||||
KeyPreview = True
|
KeyPreview = True
|
||||||
OnClose = AddToPackageDlgClose
|
OnClose = AddToPackageDlgClose
|
||||||
OnCreate = FormCreate
|
OnCreate = FormCreate
|
||||||
OnDestroy = FormDestroy
|
OnDestroy = FormDestroy
|
||||||
Position = poScreenCenter
|
Position = poScreenCenter
|
||||||
LCLVersion = '1.9.0.0'
|
LCLVersion = '2.1.0.0'
|
||||||
object ButtonPanel1: TButtonPanel
|
object ButtonPanel1: TButtonPanel
|
||||||
Left = 6
|
Left = 6
|
||||||
Height = 26
|
Height = 30
|
||||||
Top = 231
|
Top = 355
|
||||||
Width = 594
|
Width = 684
|
||||||
OKButton.Name = 'OKButton'
|
OKButton.Name = 'OKButton'
|
||||||
OKButton.DefaultCaption = True
|
OKButton.DefaultCaption = True
|
||||||
HelpButton.Name = 'HelpButton'
|
HelpButton.Name = 'HelpButton'
|
||||||
@ -33,11 +33,11 @@ object AddToPackageDlg: TAddToPackageDlg
|
|||||||
object AncestorComboBox: TComboBox
|
object AncestorComboBox: TComboBox
|
||||||
AnchorSideLeft.Side = asrBottom
|
AnchorSideLeft.Side = asrBottom
|
||||||
Left = 184
|
Left = 184
|
||||||
Height = 31
|
Height = 33
|
||||||
Top = 6
|
Top = 6
|
||||||
Width = 200
|
Width = 200
|
||||||
BorderSpacing.Top = 6
|
BorderSpacing.Top = 6
|
||||||
ItemHeight = 0
|
ItemHeight = 25
|
||||||
OnChange = AncestorComboBoxChange
|
OnChange = AncestorComboBoxChange
|
||||||
OnCloseUp = AncestorComboBoxCloseUp
|
OnCloseUp = AncestorComboBoxCloseUp
|
||||||
TabOrder = 0
|
TabOrder = 0
|
||||||
@ -50,8 +50,8 @@ object AddToPackageDlg: TAddToPackageDlg
|
|||||||
AnchorSideRight.Control = AncestorComboBox
|
AnchorSideRight.Control = AncestorComboBox
|
||||||
AnchorSideRight.Side = asrBottom
|
AnchorSideRight.Side = asrBottom
|
||||||
Left = 184
|
Left = 184
|
||||||
Height = 25
|
Height = 33
|
||||||
Top = 43
|
Top = 45
|
||||||
Width = 200
|
Width = 200
|
||||||
Anchors = [akTop, akLeft, akRight]
|
Anchors = [akTop, akLeft, akRight]
|
||||||
BorderSpacing.Top = 6
|
BorderSpacing.Top = 6
|
||||||
@ -66,69 +66,70 @@ object AddToPackageDlg: TAddToPackageDlg
|
|||||||
AnchorSideRight.Control = AncestorComboBox
|
AnchorSideRight.Control = AncestorComboBox
|
||||||
AnchorSideRight.Side = asrBottom
|
AnchorSideRight.Side = asrBottom
|
||||||
Left = 184
|
Left = 184
|
||||||
Height = 31
|
Height = 33
|
||||||
Top = 74
|
Top = 84
|
||||||
Width = 200
|
Width = 200
|
||||||
BorderSpacing.Top = 6
|
BorderSpacing.Top = 6
|
||||||
ItemHeight = 0
|
ItemHeight = 25
|
||||||
TabOrder = 3
|
TabOrder = 3
|
||||||
Text = 'PalettePageCombobox'
|
Text = 'PalettePageCombobox'
|
||||||
end
|
end
|
||||||
object ComponentUnitFileEdit: TEdit
|
object UnitDirectoryEdit: TEdit
|
||||||
AnchorSideLeft.Control = AncestorComboBox
|
AnchorSideLeft.Control = AncestorComboBox
|
||||||
AnchorSideTop.Control = PalettePageCombobox
|
AnchorSideTop.Control = UnitNameEdit
|
||||||
AnchorSideTop.Side = asrBottom
|
AnchorSideTop.Side = asrBottom
|
||||||
AnchorSideRight.Control = ComponentUnitFileBrowseButton
|
AnchorSideRight.Control = ComponentUnitFileBrowseButton
|
||||||
Left = 184
|
Left = 184
|
||||||
Height = 25
|
Height = 33
|
||||||
Top = 111
|
Top = 162
|
||||||
Width = 359
|
Width = 442
|
||||||
Anchors = [akTop, akLeft, akRight]
|
Anchors = [akTop, akLeft, akRight]
|
||||||
BorderSpacing.Top = 6
|
BorderSpacing.Top = 6
|
||||||
|
OnChange = UnitDirectoryEditChange
|
||||||
TabOrder = 4
|
TabOrder = 4
|
||||||
Text = 'ComponentUnitFileEdit'
|
Text = 'UnitDirectoryEdit'
|
||||||
end
|
end
|
||||||
object ComponentUnitNameEdit: TEdit
|
object UnitNameEdit: TEdit
|
||||||
AnchorSideLeft.Control = AncestorComboBox
|
AnchorSideLeft.Control = AncestorComboBox
|
||||||
AnchorSideTop.Control = ComponentUnitFileEdit
|
AnchorSideTop.Control = PalettePageCombobox
|
||||||
AnchorSideTop.Side = asrBottom
|
AnchorSideTop.Side = asrBottom
|
||||||
AnchorSideRight.Control = AncestorComboBox
|
AnchorSideRight.Control = AncestorComboBox
|
||||||
AnchorSideRight.Side = asrBottom
|
AnchorSideRight.Side = asrBottom
|
||||||
Left = 184
|
Left = 184
|
||||||
Height = 25
|
Height = 33
|
||||||
Top = 142
|
Top = 123
|
||||||
Width = 200
|
Width = 200
|
||||||
Anchors = [akTop, akLeft, akRight]
|
Anchors = [akTop, akLeft, akRight]
|
||||||
BorderSpacing.Top = 6
|
BorderSpacing.Top = 6
|
||||||
OnChange = ComponentUnitNameEditChange
|
OnChange = UnitNameEditChange
|
||||||
TabOrder = 7
|
TabOrder = 7
|
||||||
Text = 'ComponentUnitNameEdit'
|
Text = 'UnitNameEdit'
|
||||||
end
|
end
|
||||||
object ComponentIconBitBtn: TBitBtn
|
object IconNormBitBtn: TBitBtn
|
||||||
AnchorSideLeft.Control = ComponentUnitNameEdit
|
AnchorSideLeft.Control = AncestorComboBox
|
||||||
AnchorSideTop.Control = ComponentUnitNameEdit
|
AnchorSideTop.Control = UnitFilenameLabel
|
||||||
AnchorSideTop.Side = asrBottom
|
AnchorSideTop.Side = asrBottom
|
||||||
Left = 184
|
Left = 184
|
||||||
Height = 32
|
Height = 32
|
||||||
Top = 173
|
Top = 223
|
||||||
Width = 50
|
Width = 50
|
||||||
BorderSpacing.Top = 6
|
BorderSpacing.Top = 6
|
||||||
Constraints.MinWidth = 50
|
Constraints.MinWidth = 50
|
||||||
GlyphShowMode = gsmAlways
|
GlyphShowMode = gsmAlways
|
||||||
OnClick = ComponentIconBitBtnClick
|
OnClick = IconBitBtnClick
|
||||||
TabOrder = 8
|
TabOrder = 8
|
||||||
end
|
end
|
||||||
object LabelIconInfo: TLabel
|
object IconNormInfoLabel: TLabel
|
||||||
AnchorSideLeft.Control = ComponentIconBitBtn
|
AnchorSideLeft.Control = IconNormBitBtn
|
||||||
AnchorSideLeft.Side = asrBottom
|
AnchorSideLeft.Side = asrBottom
|
||||||
AnchorSideTop.Control = ComponentIconLabel
|
AnchorSideTop.Control = IconNormLabel
|
||||||
AnchorSideTop.Side = asrCenter
|
AnchorSideTop.Side = asrCenter
|
||||||
Left = 240
|
Left = 240
|
||||||
Height = 19
|
Height = 19
|
||||||
Top = 180
|
Top = 230
|
||||||
Width = 6
|
Width = 125
|
||||||
BorderSpacing.Around = 6
|
BorderSpacing.Around = 6
|
||||||
Caption = '?'
|
Caption = 'IconNormInfoLabel'
|
||||||
ParentColor = False
|
ParentColor = False
|
||||||
end
|
end
|
||||||
object AncestorShowAllCheckBox: TCheckBox
|
object AncestorShowAllCheckBox: TCheckBox
|
||||||
@ -137,9 +138,9 @@ object AddToPackageDlg: TAddToPackageDlg
|
|||||||
AnchorSideTop.Control = AncestorComboBox
|
AnchorSideTop.Control = AncestorComboBox
|
||||||
AnchorSideTop.Side = asrCenter
|
AnchorSideTop.Side = asrCenter
|
||||||
Left = 390
|
Left = 390
|
||||||
Height = 21
|
Height = 23
|
||||||
Top = 11
|
Top = 11
|
||||||
Width = 190
|
Width = 199
|
||||||
BorderSpacing.Left = 6
|
BorderSpacing.Left = 6
|
||||||
Caption = 'AncestorShowAllCheckBox'
|
Caption = 'AncestorShowAllCheckBox'
|
||||||
Checked = True
|
Checked = True
|
||||||
@ -149,13 +150,13 @@ object AddToPackageDlg: TAddToPackageDlg
|
|||||||
end
|
end
|
||||||
object ComponentUnitFileBrowseButton: TButton
|
object ComponentUnitFileBrowseButton: TButton
|
||||||
AnchorSideLeft.Side = asrBottom
|
AnchorSideLeft.Side = asrBottom
|
||||||
AnchorSideTop.Control = ComponentUnitFileEdit
|
AnchorSideTop.Control = UnitDirectoryEdit
|
||||||
AnchorSideTop.Side = asrCenter
|
AnchorSideTop.Side = asrCenter
|
||||||
AnchorSideRight.Control = ComponentUnitFileShortenButton
|
AnchorSideRight.Control = ComponentUnitFileShortenButton
|
||||||
Left = 543
|
Left = 626
|
||||||
Height = 25
|
Height = 25
|
||||||
Hint = 'Save file dialog'
|
Hint = 'Save file dialog'
|
||||||
Top = 111
|
Top = 166
|
||||||
Width = 25
|
Width = 25
|
||||||
Anchors = [akTop, akRight]
|
Anchors = [akTop, akRight]
|
||||||
Caption = '...'
|
Caption = '...'
|
||||||
@ -166,14 +167,14 @@ object AddToPackageDlg: TAddToPackageDlg
|
|||||||
end
|
end
|
||||||
object ComponentUnitFileShortenButton: TButton
|
object ComponentUnitFileShortenButton: TButton
|
||||||
AnchorSideLeft.Side = asrBottom
|
AnchorSideLeft.Side = asrBottom
|
||||||
AnchorSideTop.Control = ComponentUnitFileEdit
|
AnchorSideTop.Control = UnitDirectoryEdit
|
||||||
AnchorSideTop.Side = asrCenter
|
AnchorSideTop.Side = asrCenter
|
||||||
AnchorSideRight.Side = asrBottom
|
AnchorSideRight.Side = asrBottom
|
||||||
Left = 568
|
Left = 651
|
||||||
Height = 25
|
Height = 29
|
||||||
Hint = 'Shorten or expand filename'
|
Hint = 'Shorten or expand filename'
|
||||||
Top = 111
|
Top = 164
|
||||||
Width = 22
|
Width = 29
|
||||||
Anchors = [akTop, akRight]
|
Anchors = [akTop, akRight]
|
||||||
AutoSize = True
|
AutoSize = True
|
||||||
BorderSpacing.Right = 6
|
BorderSpacing.Right = 6
|
||||||
@ -183,35 +184,34 @@ object AddToPackageDlg: TAddToPackageDlg
|
|||||||
ShowHint = True
|
ShowHint = True
|
||||||
TabOrder = 6
|
TabOrder = 6
|
||||||
end
|
end
|
||||||
object ComponentIconLabel: TLabel
|
object IconNormLabel: TLabel
|
||||||
AnchorSideLeft.Control = ComponentUnitNameLabel
|
AnchorSideTop.Control = IconNormBitBtn
|
||||||
AnchorSideTop.Control = ComponentIconBitBtn
|
|
||||||
AnchorSideTop.Side = asrCenter
|
AnchorSideTop.Side = asrCenter
|
||||||
Left = 5
|
Left = 5
|
||||||
Height = 19
|
Height = 19
|
||||||
Top = 180
|
Top = 230
|
||||||
Width = 135
|
Width = 99
|
||||||
Caption = 'ComponentIconLabel'
|
Caption = 'IconNormLabel'
|
||||||
ParentColor = False
|
ParentColor = False
|
||||||
end
|
end
|
||||||
object ComponentUnitNameLabel: TLabel
|
object UnitNameLabel: TLabel
|
||||||
AnchorSideTop.Control = ComponentUnitNameEdit
|
AnchorSideTop.Control = UnitNameEdit
|
||||||
AnchorSideTop.Side = asrCenter
|
AnchorSideTop.Side = asrCenter
|
||||||
Left = 5
|
Left = 5
|
||||||
Height = 19
|
Height = 19
|
||||||
Top = 145
|
Top = 130
|
||||||
Width = 173
|
Width = 100
|
||||||
Caption = 'ComponentUnitNameLabel'
|
Caption = 'UnitNameLabel'
|
||||||
ParentColor = False
|
ParentColor = False
|
||||||
end
|
end
|
||||||
object ComponentUnitFileLabel: TLabel
|
object UnitDirectoryLabel: TLabel
|
||||||
AnchorSideTop.Control = ComponentUnitFileEdit
|
AnchorSideTop.Control = UnitDirectoryEdit
|
||||||
AnchorSideTop.Side = asrCenter
|
AnchorSideTop.Side = asrCenter
|
||||||
Left = 5
|
Left = 5
|
||||||
Height = 19
|
Height = 19
|
||||||
Top = 114
|
Top = 169
|
||||||
Width = 155
|
Width = 121
|
||||||
Caption = 'ComponentUnitFileLabel'
|
Caption = 'UnitDirectoryLabel'
|
||||||
ParentColor = False
|
ParentColor = False
|
||||||
end
|
end
|
||||||
object PalettePageLabel: TLabel
|
object PalettePageLabel: TLabel
|
||||||
@ -219,7 +219,7 @@ object AddToPackageDlg: TAddToPackageDlg
|
|||||||
AnchorSideTop.Side = asrCenter
|
AnchorSideTop.Side = asrCenter
|
||||||
Left = 5
|
Left = 5
|
||||||
Height = 19
|
Height = 19
|
||||||
Top = 80
|
Top = 91
|
||||||
Width = 111
|
Width = 111
|
||||||
Caption = 'PalettePageLabel'
|
Caption = 'PalettePageLabel'
|
||||||
ParentColor = False
|
ParentColor = False
|
||||||
@ -229,8 +229,8 @@ object AddToPackageDlg: TAddToPackageDlg
|
|||||||
AnchorSideTop.Side = asrCenter
|
AnchorSideTop.Side = asrCenter
|
||||||
Left = 5
|
Left = 5
|
||||||
Height = 19
|
Height = 19
|
||||||
Top = 46
|
Top = 52
|
||||||
Width = 104
|
Width = 106
|
||||||
Caption = 'ClassNameLabel'
|
Caption = 'ClassNameLabel'
|
||||||
ParentColor = False
|
ParentColor = False
|
||||||
end
|
end
|
||||||
@ -239,9 +239,98 @@ object AddToPackageDlg: TAddToPackageDlg
|
|||||||
AnchorSideTop.Side = asrCenter
|
AnchorSideTop.Side = asrCenter
|
||||||
Left = 5
|
Left = 5
|
||||||
Height = 19
|
Height = 19
|
||||||
Top = 12
|
Top = 13
|
||||||
Width = 120
|
Width = 122
|
||||||
Caption = 'AncestorTypeLabel'
|
Caption = 'AncestorTypeLabel'
|
||||||
ParentColor = False
|
ParentColor = False
|
||||||
end
|
end
|
||||||
|
object Icon150BitBtn: TBitBtn
|
||||||
|
AnchorSideLeft.Control = IconNormBitBtn
|
||||||
|
AnchorSideTop.Control = IconNormBitBtn
|
||||||
|
AnchorSideTop.Side = asrBottom
|
||||||
|
Left = 184
|
||||||
|
Height = 32
|
||||||
|
Top = 261
|
||||||
|
Width = 50
|
||||||
|
BorderSpacing.Top = 6
|
||||||
|
Constraints.MinWidth = 50
|
||||||
|
GlyphShowMode = gsmAlways
|
||||||
|
OnClick = IconBitBtnClick
|
||||||
|
TabOrder = 10
|
||||||
|
end
|
||||||
|
object Icon200BitBtn: TBitBtn
|
||||||
|
AnchorSideLeft.Control = Icon150BitBtn
|
||||||
|
AnchorSideTop.Control = Icon150BitBtn
|
||||||
|
AnchorSideTop.Side = asrBottom
|
||||||
|
Left = 184
|
||||||
|
Height = 32
|
||||||
|
Top = 299
|
||||||
|
Width = 50
|
||||||
|
BorderSpacing.Top = 6
|
||||||
|
Constraints.MinWidth = 50
|
||||||
|
GlyphShowMode = gsmAlways
|
||||||
|
OnClick = IconBitBtnClick
|
||||||
|
TabOrder = 11
|
||||||
|
end
|
||||||
|
object Icon150Label: TLabel
|
||||||
|
AnchorSideLeft.Control = IconNormLabel
|
||||||
|
AnchorSideTop.Control = Icon150BitBtn
|
||||||
|
AnchorSideTop.Side = asrCenter
|
||||||
|
Left = 5
|
||||||
|
Height = 19
|
||||||
|
Top = 268
|
||||||
|
Width = 85
|
||||||
|
Caption = 'Icon150Label'
|
||||||
|
ParentColor = False
|
||||||
|
end
|
||||||
|
object Icon200Label: TLabel
|
||||||
|
AnchorSideLeft.Control = IconNormLabel
|
||||||
|
AnchorSideTop.Control = Icon200BitBtn
|
||||||
|
AnchorSideTop.Side = asrCenter
|
||||||
|
Left = 5
|
||||||
|
Height = 19
|
||||||
|
Top = 306
|
||||||
|
Width = 85
|
||||||
|
Caption = 'Icon200Label'
|
||||||
|
ParentColor = False
|
||||||
|
end
|
||||||
|
object Icon150InfoLabel: TLabel
|
||||||
|
AnchorSideLeft.Control = Icon150BitBtn
|
||||||
|
AnchorSideLeft.Side = asrBottom
|
||||||
|
AnchorSideTop.Control = Icon150BitBtn
|
||||||
|
AnchorSideTop.Side = asrCenter
|
||||||
|
Left = 240
|
||||||
|
Height = 19
|
||||||
|
Top = 268
|
||||||
|
Width = 111
|
||||||
|
BorderSpacing.Around = 6
|
||||||
|
Caption = 'Icon150InfoLabel'
|
||||||
|
ParentColor = False
|
||||||
|
end
|
||||||
|
object Icon200InfoLabel: TLabel
|
||||||
|
AnchorSideLeft.Control = Icon200BitBtn
|
||||||
|
AnchorSideLeft.Side = asrBottom
|
||||||
|
AnchorSideTop.Control = Icon200BitBtn
|
||||||
|
AnchorSideTop.Side = asrCenter
|
||||||
|
Left = 240
|
||||||
|
Height = 19
|
||||||
|
Top = 306
|
||||||
|
Width = 111
|
||||||
|
BorderSpacing.Around = 6
|
||||||
|
Caption = 'Icon200InfoLabel'
|
||||||
|
ParentColor = False
|
||||||
|
end
|
||||||
|
object UnitFilenameLabel: TLabel
|
||||||
|
AnchorSideLeft.Control = UnitDirectoryEdit
|
||||||
|
AnchorSideTop.Control = UnitDirectoryEdit
|
||||||
|
AnchorSideTop.Side = asrBottom
|
||||||
|
Left = 195
|
||||||
|
Height = 19
|
||||||
|
Top = 198
|
||||||
|
Width = 120
|
||||||
|
BorderSpacing.Left = 11
|
||||||
|
BorderSpacing.Top = 3
|
||||||
|
Caption = 'UnitFilenameLabel'
|
||||||
|
ParentColor = False
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
@ -38,7 +38,7 @@ uses
|
|||||||
FileUtil, LazFileUtils,
|
FileUtil, LazFileUtils,
|
||||||
// IDEIntf
|
// IDEIntf
|
||||||
NewItemIntf, PackageIntf, FormEditingIntf, IDEWindowIntf, ComponentReg,
|
NewItemIntf, PackageIntf, FormEditingIntf, IDEWindowIntf, ComponentReg,
|
||||||
IDEDialogs, IDEImagesIntf,
|
IDEDialogs,
|
||||||
// IDE
|
// IDE
|
||||||
LazarusIDEStrConsts, InputHistory, IDEDefs, EnvironmentOpts,
|
LazarusIDEStrConsts, InputHistory, IDEDefs, EnvironmentOpts,
|
||||||
PackageSystem, PackageDefs, ProjPackChecks;
|
PackageSystem, PackageDefs, ProjPackChecks;
|
||||||
@ -59,7 +59,9 @@ type
|
|||||||
FileType: TPkgFileType;
|
FileType: TPkgFileType;
|
||||||
PkgFileFlags: TPkgFileFlags;
|
PkgFileFlags: TPkgFileFlags;
|
||||||
UsedUnitname: string;
|
UsedUnitname: string;
|
||||||
IconFile: string;
|
IconNormFile: string;
|
||||||
|
Icon150File: string;
|
||||||
|
Icon200File: string;
|
||||||
AutoAddLFMFile: boolean;
|
AutoAddLFMFile: boolean;
|
||||||
AutoAddLRSFile: boolean;
|
AutoAddLRSFile: boolean;
|
||||||
NewItem: TNewIDEItemTemplate;
|
NewItem: TNewIDEItemTemplate;
|
||||||
@ -71,6 +73,19 @@ type
|
|||||||
TOnGetUnitRegisterInfo = procedure(Sender: TObject; const AFilename: string;
|
TOnGetUnitRegisterInfo = procedure(Sender: TObject; const AFilename: string;
|
||||||
out TheUnitName: string; out HasRegisterProc: boolean) of object;
|
out TheUnitName: string; out HasRegisterProc: boolean) of object;
|
||||||
|
|
||||||
|
{ TIconGuiStuff }
|
||||||
|
|
||||||
|
TIconGuiStuff = class
|
||||||
|
// Join icon related GUI controls together. Streamlines the code.
|
||||||
|
private
|
||||||
|
Btn: TBitBtn;
|
||||||
|
InfoLabel: TLabel;
|
||||||
|
Title: string;
|
||||||
|
FileName: string;
|
||||||
|
constructor Create(aBtn: TBitBtn; aInfoLabel: TLabel; aTitle: string);
|
||||||
|
procedure LoadIcon(aLazPackage: TLazPackage; aFileName: string);
|
||||||
|
end;
|
||||||
|
|
||||||
{ TAddToPackageDlg }
|
{ TAddToPackageDlg }
|
||||||
|
|
||||||
TAddToPackageDlg = class(TForm)
|
TAddToPackageDlg = class(TForm)
|
||||||
@ -80,15 +95,22 @@ type
|
|||||||
ButtonPanel1: TButtonPanel;
|
ButtonPanel1: TButtonPanel;
|
||||||
ClassNameEdit: TEdit;
|
ClassNameEdit: TEdit;
|
||||||
ClassNameLabel: TLabel;
|
ClassNameLabel: TLabel;
|
||||||
ComponentIconBitBtn: TBitBtn;
|
Icon200Label: TLabel;
|
||||||
ComponentIconLabel: TLabel;
|
IconNormBitBtn: TBitBtn;
|
||||||
|
Icon150BitBtn: TBitBtn;
|
||||||
|
Icon150InfoLabel: TLabel;
|
||||||
|
Icon200InfoLabel: TLabel;
|
||||||
|
IconNormLabel: TLabel;
|
||||||
ComponentUnitFileBrowseButton: TButton;
|
ComponentUnitFileBrowseButton: TButton;
|
||||||
ComponentUnitFileEdit: TEdit;
|
UnitDirectoryEdit: TEdit;
|
||||||
ComponentUnitFileLabel: TLabel;
|
UnitDirectoryLabel: TLabel;
|
||||||
ComponentUnitFileShortenButton: TButton;
|
ComponentUnitFileShortenButton: TButton;
|
||||||
ComponentUnitNameEdit: TEdit;
|
UnitNameEdit: TEdit;
|
||||||
ComponentUnitNameLabel: TLabel;
|
UnitNameLabel: TLabel;
|
||||||
LabelIconInfo: TLabel;
|
Icon200BitBtn: TBitBtn;
|
||||||
|
Icon150Label: TLabel;
|
||||||
|
IconNormInfoLabel: TLabel;
|
||||||
|
UnitFilenameLabel: TLabel;
|
||||||
PalettePageCombobox: TComboBox;
|
PalettePageCombobox: TComboBox;
|
||||||
PalettePageLabel: TLabel;
|
PalettePageLabel: TLabel;
|
||||||
procedure AddToPackageDlgClose(Sender: TObject; var {%H-}CloseAction: TCloseAction);
|
procedure AddToPackageDlgClose(Sender: TObject; var {%H-}CloseAction: TCloseAction);
|
||||||
@ -96,30 +118,32 @@ type
|
|||||||
procedure AncestorComboBoxCloseUp(Sender: TObject);
|
procedure AncestorComboBoxCloseUp(Sender: TObject);
|
||||||
procedure AncestorShowAllCheckBoxClick(Sender: TObject);
|
procedure AncestorShowAllCheckBoxClick(Sender: TObject);
|
||||||
procedure ClassNameEditChange(Sender: TObject);
|
procedure ClassNameEditChange(Sender: TObject);
|
||||||
procedure ComponentIconBitBtnClick(Sender: TObject);
|
procedure IconBitBtnClick(Sender: TObject);
|
||||||
procedure ComponentUnitFileBrowseButtonClick(Sender: TObject);
|
procedure ComponentUnitFileBrowseButtonClick(Sender: TObject);
|
||||||
procedure ComponentUnitFileShortenButtonClick(Sender: TObject);
|
procedure ComponentUnitFileShortenButtonClick(Sender: TObject);
|
||||||
procedure ComponentUnitNameEditChange(Sender: TObject);
|
procedure UnitDirectoryEditChange(Sender: TObject);
|
||||||
|
procedure UnitNameEditChange(Sender: TObject);
|
||||||
procedure FormCreate(Sender: TObject);
|
procedure FormCreate(Sender: TObject);
|
||||||
procedure FormDestroy(Sender: TObject);
|
procedure FormDestroy(Sender: TObject);
|
||||||
procedure NewComponentButtonClick(Sender: TObject);
|
procedure NewComponentButtonClick(Sender: TObject);
|
||||||
private
|
private
|
||||||
fLastNewComponentAncestorType: string;
|
fLastNewAncestorType: string;
|
||||||
fLastNewComponentClassName: string;
|
fLastNewClassName: string;
|
||||||
FLazPackage: TLazPackage;
|
FLazPackage: TLazPackage;
|
||||||
FOnGetIDEFileInfo: TGetIDEFileStateEvent;
|
FOnGetIDEFileInfo: TGetIDEFileStateEvent;
|
||||||
FOnGetUnitRegisterInfo: TOnGetUnitRegisterInfo;
|
FOnGetUnitRegisterInfo: TOnGetUnitRegisterInfo;
|
||||||
fPkgComponents: TAVLTree;// tree of TPkgComponent
|
fPkgComponents: TAVLTree;// tree of TPkgComponent
|
||||||
fPackages: TAVLTree;// tree of TLazPackage or TPackageLink
|
fPackages: TAVLTree;// tree of TLazPackage or TPackageLink
|
||||||
FComponentIconFilename: string;
|
|
||||||
fParams: TAddToPkgResult;
|
fParams: TAddToPkgResult;
|
||||||
|
fIconNormGUI: TIconGuiStuff;
|
||||||
|
fIcon150GUI: TIconGuiStuff;
|
||||||
|
fIcon200GUI: TIconGuiStuff;
|
||||||
|
function GenerateUnitFileName: string;
|
||||||
procedure SetLazPackage(const AValue: TLazPackage);
|
procedure SetLazPackage(const AValue: TLazPackage);
|
||||||
procedure OnIterateComponentClasses(PkgComponent: TPkgComponent);
|
procedure OnIterateComponentClasses(PkgComponent: TPkgComponent);
|
||||||
function CheckNewCompOk: Boolean;
|
function CheckNewCompOk: Boolean;
|
||||||
procedure AutoCompleteNewComponent;
|
procedure AutoCompleteNewComponent;
|
||||||
procedure AutoCompleteNewComponentUnitName;
|
procedure AutoCompleteNewComponentUnitName;
|
||||||
function SwitchRelativeAbsoluteFilename(const Filename: string): string;
|
|
||||||
procedure LoadComponentIcon(AFilename: string);
|
|
||||||
public
|
public
|
||||||
procedure UpdateAvailableAncestorTypes;
|
procedure UpdateAvailableAncestorTypes;
|
||||||
procedure UpdateAvailablePageNames;
|
procedure UpdateAvailablePageNames;
|
||||||
@ -162,6 +186,48 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
{ TIconGuiStuff }
|
||||||
|
|
||||||
|
constructor TIconGuiStuff.Create(aBtn: TBitBtn; aInfoLabel: TLabel; aTitle: string);
|
||||||
|
begin
|
||||||
|
Btn:=aBtn;
|
||||||
|
InfoLabel:=aInfoLabel;
|
||||||
|
Title:=aTitle;
|
||||||
|
// Set button Width and Height. (Is this needed?)
|
||||||
|
Btn.Width:=ComponentPaletteBtnWidth;
|
||||||
|
Btn.Height:=ComponentPaletteBtnHeight;
|
||||||
|
InfoLabel.Caption:='';
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TIconGuiStuff.LoadIcon(aLazPackage: TLazPackage; aFileName: string);
|
||||||
|
var
|
||||||
|
ShortFN: String;
|
||||||
|
Image: TImage;
|
||||||
|
begin
|
||||||
|
Filename:=aFileName;
|
||||||
|
try
|
||||||
|
Image:=TImage.Create(nil);
|
||||||
|
try
|
||||||
|
Image.Picture.LoadFromFile(Filename);
|
||||||
|
Btn.Glyph.Assign(Image.Picture.Graphic);
|
||||||
|
ShortFN:=Filename;
|
||||||
|
aLazPackage.ShortenFilename(ShortFN,true);
|
||||||
|
InfoLabel.Caption:=Format('%s (%dx%d)',[ShortFN, Btn.Glyph.Width, Btn.Glyph.Height]);
|
||||||
|
finally
|
||||||
|
Image.Free;
|
||||||
|
end;
|
||||||
|
except
|
||||||
|
on E: Exception do begin
|
||||||
|
IDEMessageDialog(lisCCOErrorCaption,
|
||||||
|
Format(lisErrorLoadingFile2,[FileName]) + LineEnding + E.Message,
|
||||||
|
mtError, [mbCancel]);
|
||||||
|
Btn.Glyph.Clear;
|
||||||
|
InfoLabel.Caption:=lisNoneClickToChooseOne;
|
||||||
|
FileName:='';
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
{ TAddToPackageDlg }
|
{ TAddToPackageDlg }
|
||||||
|
|
||||||
procedure TAddToPackageDlg.FormCreate(Sender: TObject);
|
procedure TAddToPackageDlg.FormCreate(Sender: TObject);
|
||||||
@ -170,7 +236,7 @@ begin
|
|||||||
fPkgComponents:=TAVLTree.Create(@CompareIDEComponentByClassName);
|
fPkgComponents:=TAVLTree.Create(@CompareIDEComponentByClassName);
|
||||||
fPackages:=TAVLTree.Create(@CompareLazPackageID);
|
fPackages:=TAVLTree.Create(@CompareLazPackageID);
|
||||||
fParams:=TAddToPkgResult.Create;
|
fParams:=TAddToPkgResult.Create;
|
||||||
IDEDialogLayoutList.ApplyLayout(Self,500,260);
|
IDEDialogLayoutList.ApplyLayout(Self,700,390);
|
||||||
// Setup Components
|
// Setup Components
|
||||||
ButtonPanel1.OkButton.Caption:=lisA2PCreateNewComp;
|
ButtonPanel1.OkButton.Caption:=lisA2PCreateNewComp;
|
||||||
ButtonPanel1.OkButton.OnClick:=@NewComponentButtonClick;
|
ButtonPanel1.OkButton.OnClick:=@NewComponentButtonClick;
|
||||||
@ -182,8 +248,9 @@ begin
|
|||||||
ClassNameEdit.Text:='';
|
ClassNameEdit.Text:='';
|
||||||
PalettePageLabel.Caption:=lisA2PPalettePage;
|
PalettePageLabel.Caption:=lisA2PPalettePage;
|
||||||
PalettePageCombobox.Text:='';
|
PalettePageCombobox.Text:='';
|
||||||
ComponentUnitFileLabel.Caption:=lisA2PUnitFileName2;
|
UnitDirectoryLabel.Caption:=lisA2PDirectoryForUnitFile;
|
||||||
ComponentUnitFileEdit.Text:='';
|
UnitDirectoryEdit.Text:='';
|
||||||
|
UnitFilenameLabel.Caption:='';
|
||||||
with ComponentUnitFileBrowseButton do begin
|
with ComponentUnitFileBrowseButton do begin
|
||||||
Caption:='...';
|
Caption:='...';
|
||||||
ShowHint:=true;
|
ShowHint:=true;
|
||||||
@ -194,18 +261,25 @@ begin
|
|||||||
ShowHint:=true;
|
ShowHint:=true;
|
||||||
Hint:=lisA2PShortenOrExpandFilename;
|
Hint:=lisA2PShortenOrExpandFilename;
|
||||||
end;
|
end;
|
||||||
ComponentUnitNameLabel.Caption:=lisA2PUnitName;
|
UnitNameLabel.Caption:=lisA2PUnitName;
|
||||||
ComponentUnitNameEdit.Text:='';
|
UnitNameEdit.Text:='';
|
||||||
ComponentIconLabel.Caption:=lisA2PIconAndSize;
|
IconNormLabel.Caption:=lisA2PIcon24x24;
|
||||||
ComponentIconBitBtn.Width:=ComponentPaletteBtnWidth;
|
Icon150Label.Caption:=lisA2PIcon36x36;
|
||||||
ComponentIconBitBtn.Height:=ComponentPaletteBtnHeight;
|
Icon200Label.Caption:=lisA2PIcon48x48;
|
||||||
|
// Helper objects to join icon related GUI controls together
|
||||||
|
fIconNormGUI:=TIconGuiStuff.Create(IconNormBitBtn, IconNormInfoLabel, lisA2PIcon24x24);
|
||||||
|
fIcon150GUI:=TIconGuiStuff.Create(Icon150BitBtn, Icon150InfoLabel, lisA2PIcon36x36);
|
||||||
|
fIcon200GUI:=TIconGuiStuff.Create(Icon200BitBtn, Icon200InfoLabel, lisA2PIcon48x48);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TAddToPackageDlg.FormDestroy(Sender: TObject);
|
procedure TAddToPackageDlg.FormDestroy(Sender: TObject);
|
||||||
begin
|
begin
|
||||||
FreeAndNil(fPkgComponents);
|
FreeAndNil(fIcon200GUI);
|
||||||
FreeAndNil(fPackages);
|
FreeAndNil(fIcon150GUI);
|
||||||
|
FreeAndNil(fIconNormGUI);
|
||||||
FreeAndNil(fParams);
|
FreeAndNil(fParams);
|
||||||
|
FreeAndNil(fPackages);
|
||||||
|
FreeAndNil(fPkgComponents);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TAddToPackageDlg.AddToPackageDlgClose(Sender: TObject;
|
procedure TAddToPackageDlg.AddToPackageDlgClose(Sender: TObject;
|
||||||
@ -221,7 +295,7 @@ end;
|
|||||||
|
|
||||||
procedure TAddToPackageDlg.AncestorComboBoxCloseUp(Sender: TObject);
|
procedure TAddToPackageDlg.AncestorComboBoxCloseUp(Sender: TObject);
|
||||||
begin
|
begin
|
||||||
if fLastNewComponentAncestorType<>AncestorComboBox.Text then
|
if fLastNewAncestorType<>AncestorComboBox.Text then
|
||||||
AutoCompleteNewComponent;
|
AutoCompleteNewComponent;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -236,15 +310,35 @@ begin
|
|||||||
CheckNewCompOk;
|
CheckNewCompOk;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TAddToPackageDlg.ComponentIconBitBtnClick(Sender: TObject);
|
procedure TAddToPackageDlg.IconBitBtnClick(Sender: TObject);
|
||||||
var
|
var
|
||||||
Dlg: TOpenPictureDialog;
|
Dlg: TOpenPictureDialog;
|
||||||
|
|
||||||
|
function RelatedIconFile(aSuffix: string): string;
|
||||||
|
var
|
||||||
|
Ext: String;
|
||||||
|
begin
|
||||||
|
Ext := ExtractFileExt(Dlg.FileName);
|
||||||
|
Result := ExtractFileNameWithoutExt(Dlg.FileName)+ASuffix+Ext;
|
||||||
|
end;
|
||||||
|
|
||||||
|
var
|
||||||
|
Btn: TBitBtn;
|
||||||
|
IconGUI: TIconGuiStuff;
|
||||||
|
OtherIconFile: string;
|
||||||
begin
|
begin
|
||||||
|
Btn:=Sender as TBitBtn;
|
||||||
Dlg:=TOpenPictureDialog.Create(nil);
|
Dlg:=TOpenPictureDialog.Create(nil);
|
||||||
try
|
try
|
||||||
InputHistories.ApplyFileDialogSettings(Dlg);
|
InputHistories.ApplyFileDialogSettings(Dlg);
|
||||||
Dlg.InitialDir:=LazPackage.GetFileDialogInitialDir(ExtractFilePath(ComponentUnitFileEdit.Text));
|
Dlg.InitialDir:=LazPackage.GetFileDialogInitialDir(UnitDirectoryEdit.Text);
|
||||||
Dlg.Title:=lisTitleOpenComponentIcon24x24;
|
if Btn = IconNormBitBtn then
|
||||||
|
IconGUI:=fIconNormGUI
|
||||||
|
else if Btn = Icon150BitBtn then
|
||||||
|
IconGUI:=fIcon150GUI
|
||||||
|
else if Btn = Icon200BitBtn then
|
||||||
|
IconGUI:=fIcon200GUI;
|
||||||
|
Dlg.Title:=IconGUI.Title;
|
||||||
Dlg.Options:=Dlg.Options+[ofPathMustExist];
|
Dlg.Options:=Dlg.Options+[ofPathMustExist];
|
||||||
Dlg.Filter:=Format('%s|*.png|%s|*.bmp|%s|*.xpm|%s|%s',
|
Dlg.Filter:=Format('%s|*.png|%s|*.bmp|%s|*.xpm|%s|%s',
|
||||||
[dlgFilterImagesPng,
|
[dlgFilterImagesPng,
|
||||||
@ -253,7 +347,18 @@ begin
|
|||||||
dlgFilterAll, GetAllFilesMask]);
|
dlgFilterAll, GetAllFilesMask]);
|
||||||
|
|
||||||
if Dlg.Execute then begin
|
if Dlg.Execute then begin
|
||||||
LoadComponentIcon(Dlg.FileName);
|
IconGUI.LoadIcon(LazPackage, Dlg.FileName);
|
||||||
|
// Load high resolution icons automatically if found.
|
||||||
|
if Btn = IconNormBitBtn then begin
|
||||||
|
// 150%
|
||||||
|
OtherIconFile:=RelatedIconFile('_150');
|
||||||
|
if FileExists(OtherIconFile) then
|
||||||
|
fIcon150GUI.LoadIcon(LazPackage, OtherIconFile);
|
||||||
|
// 200%
|
||||||
|
OtherIconFile:=RelatedIconFile('_200');
|
||||||
|
if FileExists(OtherIconFile) then
|
||||||
|
fIcon200GUI.LoadIcon(LazPackage, OtherIconFile);
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
InputHistories.StoreFileDialogSettings(Dlg);
|
InputHistories.StoreFileDialogSettings(Dlg);
|
||||||
finally
|
finally
|
||||||
@ -263,42 +368,51 @@ end;
|
|||||||
|
|
||||||
procedure TAddToPackageDlg.ComponentUnitFileBrowseButtonClick(Sender: TObject);
|
procedure TAddToPackageDlg.ComponentUnitFileBrowseButtonClick(Sender: TObject);
|
||||||
var
|
var
|
||||||
SaveDialog: TSaveDialog;
|
DirDialog: TSelectDirectoryDialog;
|
||||||
AFilename: string;
|
|
||||||
begin
|
begin
|
||||||
SaveDialog:=TSaveDialog.Create(nil);
|
DirDialog:=TSelectDirectoryDialog.Create(nil);
|
||||||
try
|
try
|
||||||
InputHistories.ApplyFileDialogSettings(SaveDialog);
|
InputHistories.ApplyFileDialogSettings(DirDialog);
|
||||||
SaveDialog.InitialDir := LazPackage.GetFileDialogInitialDir(SaveDialog.InitialDir);
|
DirDialog.InitialDir:=LazPackage.Directory;
|
||||||
SaveDialog.Title := lisSaveAs;
|
DirDialog.Title:=lisA2PDirectoryForUnitFile;
|
||||||
SaveDialog.Options := SaveDialog.Options+[ofPathMustExist];
|
//DirDialog.Options:=DirDialog.Options+[ofPathMustExist];
|
||||||
SaveDialog.Filter := Format('%s|*.pas;*.pp', [dlgFilterPascalFile]);
|
//DirDialog.Filter:=Format('%s|*.pas;*.pp', [dlgFilterPascalFile]);
|
||||||
if SaveDialog.Execute then begin
|
if DirDialog.Execute then begin
|
||||||
AFilename := CleanAndExpandFilename(SaveDialog.Filename);
|
UnitDirectoryEdit.Text:=DirDialog.Filename;
|
||||||
if FilenameIsPascalUnit(AFilename) then begin
|
UnitFilenameLabel.Caption:=AppendPathDelim(UnitDirectoryEdit.Text)+GenerateUnitFileName;
|
||||||
LazPackage.ShortenFilename(AFilename,true);
|
|
||||||
ComponentUnitFileEdit.Text := AFilename;
|
|
||||||
end else begin
|
|
||||||
IDEMessageDialog(lisA2PInvalidFile,
|
|
||||||
lisA2PAPascalUnitMustHaveTheExtensionPPOrPas,
|
|
||||||
mtError,[mbCancel]);
|
|
||||||
end;
|
|
||||||
end;
|
end;
|
||||||
InputHistories.StoreFileDialogSettings(SaveDialog);
|
InputHistories.StoreFileDialogSettings(DirDialog);
|
||||||
finally
|
finally
|
||||||
SaveDialog.Free;
|
DirDialog.Free;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TAddToPackageDlg.ComponentUnitFileShortenButtonClick(Sender: TObject);
|
procedure TAddToPackageDlg.ComponentUnitFileShortenButtonClick(Sender: TObject);
|
||||||
|
var
|
||||||
|
S: string;
|
||||||
begin
|
begin
|
||||||
if ''=ComponentUnitFileEdit.Text then exit;
|
Assert(LazPackage.HasDirectory and FilenameIsAbsolute(LazPackage.Directory),
|
||||||
ComponentUnitFileEdit.Text:=SwitchRelativeAbsoluteFilename(ComponentUnitFileEdit.Text);
|
'Unexpected package directory');
|
||||||
|
S:=UnitDirectoryEdit.Text;
|
||||||
|
if (S='') then
|
||||||
|
S:='.';
|
||||||
|
// Toggle between absolute and relative paths.
|
||||||
|
if FilenameIsAbsolute(S) then
|
||||||
|
UnitDirectoryEdit.Text:=CreateRelativePath(S,LazPackage.Directory,True)
|
||||||
|
else
|
||||||
|
UnitDirectoryEdit.Text:=CreateAbsolutePath(S,LazPackage.Directory);
|
||||||
|
UnitFilenameLabel.Caption:=AppendPathDelim(UnitDirectoryEdit.Text)+GenerateUnitFileName;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TAddToPackageDlg.ComponentUnitNameEditChange(Sender: TObject);
|
procedure TAddToPackageDlg.UnitDirectoryEditChange(Sender: TObject);
|
||||||
|
begin
|
||||||
|
UnitFilenameLabel.Caption:=AppendPathDelim(UnitDirectoryEdit.Text)+GenerateUnitFileName;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TAddToPackageDlg.UnitNameEditChange(Sender: TObject);
|
||||||
begin
|
begin
|
||||||
CheckNewCompOk;
|
CheckNewCompOk;
|
||||||
|
UnitFilenameLabel.Caption:=AppendPathDelim(UnitDirectoryEdit.Text)+GenerateUnitFileName;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TAddToPackageDlg.NewComponentButtonClick(Sender: TObject);
|
procedure TAddToPackageDlg.NewComponentButtonClick(Sender: TObject);
|
||||||
@ -306,6 +420,7 @@ var
|
|||||||
PkgFile: TPkgFile;
|
PkgFile: TPkgFile;
|
||||||
PkgComponent: TPkgComponent;
|
PkgComponent: TPkgComponent;
|
||||||
ARequiredPackage: TLazPackage;
|
ARequiredPackage: TLazPackage;
|
||||||
|
ThePath: String;
|
||||||
begin
|
begin
|
||||||
fParams.Clear;
|
fParams.Clear;
|
||||||
fParams.FileType:=pftUnit;
|
fParams.FileType:=pftUnit;
|
||||||
@ -313,10 +428,21 @@ begin
|
|||||||
fParams.AncestorType:=AncestorComboBox.Text;
|
fParams.AncestorType:=AncestorComboBox.Text;
|
||||||
fParams.NewClassName:=ClassNameEdit.Text;
|
fParams.NewClassName:=ClassNameEdit.Text;
|
||||||
fParams.PageName:=PalettePageCombobox.Text;
|
fParams.PageName:=PalettePageCombobox.Text;
|
||||||
fParams.Unit_Name:=ComponentUnitNameEdit.Text;
|
fParams.Unit_Name:=UnitNameEdit.Text;
|
||||||
fParams.UnitFilename:=ComponentUnitFileEdit.Text;
|
|
||||||
fParams.UsedUnitname:='';
|
fParams.UsedUnitname:='';
|
||||||
fParams.IconFile:=FComponentIconFilename;
|
fParams.IconNormFile:=fIconNormGUI.Filename;
|
||||||
|
fParams.Icon150File:=fIcon150GUI.Filename;
|
||||||
|
fParams.Icon200File:=fIcon200GUI.Filename;
|
||||||
|
|
||||||
|
// prepend path to unit filename
|
||||||
|
ThePath:=UnitDirectoryEdit.Text;
|
||||||
|
if ThePath='' then
|
||||||
|
ThePath:='.';
|
||||||
|
ThePath:=CreateAbsolutePath(ThePath,LazPackage.Directory);
|
||||||
|
if not DirectoryExists(ThePath) then
|
||||||
|
if not ForceDirectories(ThePath) then
|
||||||
|
raise Exception.Create('NewComponentButtonClick: Cannot create directory '+ThePath);
|
||||||
|
fParams.UnitFilename:=AppendPathDelim(ThePath)+GenerateUnitFileName;
|
||||||
|
|
||||||
// check Ancestor Type
|
// check Ancestor Type
|
||||||
if not IsValidIdent(fParams.AncestorType) then begin
|
if not IsValidIdent(fParams.AncestorType) then begin
|
||||||
@ -325,7 +451,6 @@ begin
|
|||||||
mtError,[mbCancel]);
|
mtError,[mbCancel]);
|
||||||
exit;
|
exit;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
// check pagename
|
// check pagename
|
||||||
if length(fParams.PageName)>100 then begin
|
if length(fParams.PageName)>100 then begin
|
||||||
IDEMessageDialog(lisA2PPageNameTooLong,
|
IDEMessageDialog(lisA2PPageNameTooLong,
|
||||||
@ -333,16 +458,6 @@ begin
|
|||||||
mtError,[mbCancel]);
|
mtError,[mbCancel]);
|
||||||
exit;
|
exit;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
// check unitname - filename redundancy
|
|
||||||
if CompareText(fParams.Unit_name,ExtractFileNameOnly(fParams.UnitFilename))<>0
|
|
||||||
then begin
|
|
||||||
IDEMessageDialog(lisA2PUnitNameInvalid,
|
|
||||||
Format(lisA2PTheUnitNameDoesNotCorrespondToTheFilename, [fParams.Unit_Name]),
|
|
||||||
mtError,[mbCancel]);
|
|
||||||
exit;
|
|
||||||
end;
|
|
||||||
|
|
||||||
// check classname
|
// check classname
|
||||||
if not IsValidIdent(fParams.NewClassName) then begin
|
if not IsValidIdent(fParams.NewClassName) then begin
|
||||||
IDEMessageDialog(lisA2PInvalidClassName,
|
IDEMessageDialog(lisA2PInvalidClassName,
|
||||||
@ -350,7 +465,6 @@ begin
|
|||||||
mtError,[mbCancel]);
|
mtError,[mbCancel]);
|
||||||
exit;
|
exit;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
// check classname<>ancestortype
|
// check classname<>ancestortype
|
||||||
if CompareText(fParams.NewClassName,fParams.AncestorType)=0 then begin
|
if CompareText(fParams.NewClassName,fParams.AncestorType)=0 then begin
|
||||||
IDEMessageDialog(lisA2PInvalidCircularDependency,
|
IDEMessageDialog(lisA2PInvalidCircularDependency,
|
||||||
@ -358,7 +472,6 @@ begin
|
|||||||
mtError,[mbCancel]);
|
mtError,[mbCancel]);
|
||||||
exit;
|
exit;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
// check ancestor type is not unitname
|
// check ancestor type is not unitname
|
||||||
PkgFile:=PackageGraph.FindUnit(LazPackage,fParams.AncestorType,true,true);
|
PkgFile:=PackageGraph.FindUnit(LazPackage,fParams.AncestorType,true,true);
|
||||||
if PkgFile<>nil then begin
|
if PkgFile<>nil then begin
|
||||||
@ -369,7 +482,6 @@ begin
|
|||||||
then
|
then
|
||||||
exit;
|
exit;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
// check classname does not interfere with an existing unitname
|
// check classname does not interfere with an existing unitname
|
||||||
PkgFile:=PackageGraph.FindUnit(LazPackage,fParams.NewClassName,true,true);
|
PkgFile:=PackageGraph.FindUnit(LazPackage,fParams.NewClassName,true,true);
|
||||||
if PkgFile<>nil then begin
|
if PkgFile<>nil then begin
|
||||||
@ -380,7 +492,6 @@ begin
|
|||||||
then
|
then
|
||||||
exit;
|
exit;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
// check if classname already exists
|
// check if classname already exists
|
||||||
PkgComponent:=TPkgComponent(IDEComponentPalette.FindComponent(fParams.NewClassname));
|
PkgComponent:=TPkgComponent(IDEComponentPalette.FindComponent(fParams.NewClassname));
|
||||||
if PkgComponent<>nil then begin
|
if PkgComponent<>nil then begin
|
||||||
@ -391,7 +502,6 @@ begin
|
|||||||
then
|
then
|
||||||
exit;
|
exit;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
// check filename
|
// check filename
|
||||||
if not CheckAddingPackageUnit(LazPackage, d2ptNewComponent,
|
if not CheckAddingPackageUnit(LazPackage, d2ptNewComponent,
|
||||||
OnGetIDEFileInfo, fParams.UnitFilename) then exit;
|
OnGetIDEFileInfo, fParams.UnitFilename) then exit;
|
||||||
@ -403,7 +513,7 @@ begin
|
|||||||
ARequiredPackage:=PkgComponent.PkgFile.LazPackage;
|
ARequiredPackage:=PkgComponent.PkgFile.LazPackage;
|
||||||
ARequiredPackage:=TLazPackage(PackageEditingInterface.RedirectPackageDependency(ARequiredPackage));
|
ARequiredPackage:=TLazPackage(PackageEditingInterface.RedirectPackageDependency(ARequiredPackage));
|
||||||
if (LazPackage<>ARequiredPackage)
|
if (LazPackage<>ARequiredPackage)
|
||||||
and (not LazPackage.Requires(PkgComponent.PkgFile.LazPackage))
|
and not LazPackage.Requires(PkgComponent.PkgFile.LazPackage)
|
||||||
then
|
then
|
||||||
fParams.Dependency:=ARequiredPackage.CreateDependencyWithOwner(nil);
|
fParams.Dependency:=ARequiredPackage.CreateDependencyWithOwner(nil);
|
||||||
end;
|
end;
|
||||||
@ -421,7 +531,7 @@ end;
|
|||||||
|
|
||||||
function TAddToPackageDlg.CheckNewCompOk: Boolean;
|
function TAddToPackageDlg.CheckNewCompOk: Boolean;
|
||||||
begin
|
begin
|
||||||
Result:=(AncestorComboBox.Text<>'') and (ClassNameEdit.Text<>'') and (ComponentUnitNameEdit.Text<>'');
|
Result:=(AncestorComboBox.Text<>'') and (ClassNameEdit.Text<>'') and (UnitNameEdit.Text<>'');
|
||||||
ButtonPanel1.OKButton.Enabled:=Result;
|
ButtonPanel1.OKButton.Enabled:=Result;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -431,22 +541,28 @@ begin
|
|||||||
fPkgComponents.Add(PkgComponent);
|
fPkgComponents.Add(PkgComponent);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TAddToPackageDlg.GenerateUnitFileName: string;
|
||||||
|
begin
|
||||||
|
Result:=UnitNameEdit.Text;
|
||||||
|
if Result='' then Exit;
|
||||||
|
if EnvironmentOptions.CharcaseFileAction in [ccfaAsk, ccfaAutoRename] then
|
||||||
|
Result:=LowerCase(Result);
|
||||||
|
// append pascal file extension
|
||||||
|
Result:=Result+PascalExtension[EnvironmentOptions.PascalFileExtension];
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TAddToPackageDlg.AutoCompleteNewComponent;
|
procedure TAddToPackageDlg.AutoCompleteNewComponent;
|
||||||
var
|
var
|
||||||
PkgComponent: TPkgComponent;
|
PkgComponent: TPkgComponent;
|
||||||
begin
|
begin
|
||||||
fLastNewComponentAncestorType:=AncestorComboBox.Text;
|
fLastNewAncestorType:=AncestorComboBox.Text;
|
||||||
if not IsValidIdent(fLastNewComponentAncestorType) then exit;
|
if not IsValidIdent(fLastNewAncestorType) then exit;
|
||||||
PkgComponent:=TPkgComponent(
|
PkgComponent:=TPkgComponent(IDEComponentPalette.FindComponent(fLastNewAncestorType));
|
||||||
IDEComponentPalette.FindComponent(fLastNewComponentAncestorType));
|
|
||||||
|
|
||||||
// create unique classname
|
// create unique classname
|
||||||
if not IsValidIdent(ClassNameEdit.Text) then
|
ClassNameEdit.Text:=IDEComponentPalette.CreateNewClassName(fLastNewAncestorType);
|
||||||
ClassNameEdit.Text:=IDEComponentPalette.CreateNewClassName(
|
|
||||||
fLastNewComponentAncestorType);
|
|
||||||
// choose the same page name
|
// choose the same page name
|
||||||
if (PalettePageCombobox.Text='')
|
if (PkgComponent<>nil) and (PkgComponent.RealPage<>nil) then
|
||||||
and (PkgComponent<>nil) and (PkgComponent.RealPage<>nil) then
|
|
||||||
PalettePageCombobox.Text:=PkgComponent.RealPage.PageName;
|
PalettePageCombobox.Text:=PkgComponent.RealPage.PageName;
|
||||||
// filename
|
// filename
|
||||||
AutoCompleteNewComponentUnitName;
|
AutoCompleteNewComponentUnitName;
|
||||||
@ -461,73 +577,19 @@ var
|
|||||||
begin
|
begin
|
||||||
// check if update needed
|
// check if update needed
|
||||||
CurClassName:=ClassNameEdit.Text;
|
CurClassName:=ClassNameEdit.Text;
|
||||||
if fLastNewComponentClassName=CurClassName then exit;
|
if fLastNewClassName=CurClassName then exit;
|
||||||
fLastNewComponentClassName:=CurClassName;
|
fLastNewClassName:=CurClassName;
|
||||||
|
|
||||||
// check classname
|
// check classname
|
||||||
if not IsValidIdent(CurClassName) then exit;
|
if not IsValidIdent(CurClassName) then exit;
|
||||||
|
|
||||||
// create unitname
|
// create unitname
|
||||||
NewUnitName:=CurClassName;
|
NewUnitName:=CurClassName;
|
||||||
if NewUnitName[1]='T' then
|
if NewUnitName[1]='T' then
|
||||||
NewUnitName:=copy(NewUnitName,2,length(NewUnitName)-1);
|
NewUnitName:=copy(NewUnitName,2,length(NewUnitName)-1);
|
||||||
NewUnitName:=PackageGraph.CreateUniqueUnitName(NewUnitName);
|
NewUnitName:=PackageGraph.CreateUniqueUnitName(NewUnitName);
|
||||||
ComponentUnitNameEdit.Text:=NewUnitName;
|
UnitNameEdit.Text:=NewUnitName;
|
||||||
|
// default directory
|
||||||
// create filename
|
UnitDirectoryEdit.Text:=LazPackage.Directory;
|
||||||
NewFileName:=NewUnitName;
|
UnitFilenameLabel.Caption:=AppendPathDelim(UnitDirectoryEdit.Text)+GenerateUnitFileName;
|
||||||
|
|
||||||
if EnvironmentOptions.CharcaseFileAction in [ccfaAsk, ccfaAutoRename] then
|
|
||||||
NewFileName:=lowercase(NewFileName);
|
|
||||||
|
|
||||||
// append pascal file extension
|
|
||||||
NewFileName:=NewFileName
|
|
||||||
+EnvironmentOpts.PascalExtension[EnvironmentOptions.PascalFileExtension];
|
|
||||||
// prepend path
|
|
||||||
if LazPackage.HasDirectory then
|
|
||||||
NewFileName:=LazPackage.Directory+NewFileName;
|
|
||||||
ComponentUnitFileEdit.Text:=NewFileName;
|
|
||||||
end;
|
|
||||||
|
|
||||||
function TAddToPackageDlg.SwitchRelativeAbsoluteFilename(const Filename: string): string;
|
|
||||||
begin
|
|
||||||
Result:=Filename;
|
|
||||||
if (not LazPackage.HasDirectory)
|
|
||||||
or (not FilenameIsAbsolute(LazPackage.Directory)) then exit;
|
|
||||||
if FilenameIsAbsolute(Filename) then
|
|
||||||
Result:=TrimFilename(CreateRelativePath(Filename,LazPackage.Directory))
|
|
||||||
else
|
|
||||||
Result:=TrimFilename(CreateAbsoluteSearchPath(Filename,LazPackage.Directory));
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TAddToPackageDlg.LoadComponentIcon(AFilename: string);
|
|
||||||
var
|
|
||||||
ShortFilename: String;
|
|
||||||
Image: TImage;
|
|
||||||
begin
|
|
||||||
try
|
|
||||||
Image:=TImage.Create(nil);
|
|
||||||
try
|
|
||||||
Image.Picture.LoadFromFile(AFilename);
|
|
||||||
ComponentIconBitBtn.Glyph.Assign(Image.Picture.Graphic);
|
|
||||||
ShortFilename:=AFilename;
|
|
||||||
LazPackage.ShortenFilename(ShortFilename,true);
|
|
||||||
LabelIconInfo.Caption:= Format('%s (%dx%d)',
|
|
||||||
[ShortFilename, ComponentIconBitBtn.Glyph.Width, ComponentIconBitBtn.Glyph.Height]);
|
|
||||||
FComponentIconFilename:=AFilename;
|
|
||||||
finally
|
|
||||||
Image.Free;
|
|
||||||
end;
|
|
||||||
except
|
|
||||||
on E: Exception do begin
|
|
||||||
IDEMessageDialog(lisCCOErrorCaption,
|
|
||||||
Format(lisErrorLoadingFile2,[AFilename]) + LineEnding + E.Message,
|
|
||||||
mtError, [mbCancel]);
|
|
||||||
ComponentIconBitBtn.Glyph.Clear;
|
|
||||||
FComponentIconFilename:='';
|
|
||||||
LabelIconInfo.Caption:=lisNoneClickToChooseOne;
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TAddToPackageDlg.UpdateAvailableAncestorTypes;
|
procedure TAddToPackageDlg.UpdateAvailableAncestorTypes;
|
||||||
@ -584,7 +646,7 @@ end;
|
|||||||
|
|
||||||
procedure TAddToPkgResult.Clear;
|
procedure TAddToPkgResult.Clear;
|
||||||
begin
|
begin
|
||||||
Dependency:=nil;
|
FreeAndNil(Dependency);
|
||||||
UnitFilename:='';
|
UnitFilename:='';
|
||||||
Unit_Name:='';
|
Unit_Name:='';
|
||||||
AncestorType:='';
|
AncestorType:='';
|
||||||
@ -601,6 +663,7 @@ end;
|
|||||||
destructor TAddToPkgResult.Destroy;
|
destructor TAddToPkgResult.Destroy;
|
||||||
begin
|
begin
|
||||||
FreeThenNil(Next);
|
FreeThenNil(Next);
|
||||||
|
FreeAndNil(Dependency);
|
||||||
inherited Destroy;
|
inherited Destroy;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
@ -2150,8 +2150,7 @@ var
|
|||||||
if (AddParams.Dependency<>nil)
|
if (AddParams.Dependency<>nil)
|
||||||
and (not PkgDependsOn(AddParams.Dependency.PackageName)) then
|
and (not PkgDependsOn(AddParams.Dependency.PackageName)) then
|
||||||
PackageGraph.AddDependencyToPackage(LazPackage,AddParams.Dependency);
|
PackageGraph.AddDependencyToPackage(LazPackage,AddParams.Dependency);
|
||||||
if (AddParams.IconFile<>'')
|
if (AddParams.IconNormFile<>'') and (not PkgDependsOn('LCL')) then
|
||||||
and (not PkgDependsOn('LCL')) then
|
|
||||||
PackageGraph.AddDependencyToPackage(LazPackage,PackageGraph.LCLPackage);
|
PackageGraph.AddDependencyToPackage(LazPackage,PackageGraph.LCLPackage);
|
||||||
PackageEditors.DeleteAmbiguousFiles(LazPackage,AddParams.UnitFilename);
|
PackageEditors.DeleteAmbiguousFiles(LazPackage,AddParams.UnitFilename);
|
||||||
// open file in editor
|
// open file in editor
|
||||||
|
@ -39,6 +39,7 @@ interface
|
|||||||
|
|
||||||
{$I ide.inc}
|
{$I ide.inc}
|
||||||
|
|
||||||
|
{$DEFINE UseLRS}
|
||||||
{off $DEFINE VerbosePkgEditDrag}
|
{off $DEFINE VerbosePkgEditDrag}
|
||||||
|
|
||||||
uses
|
uses
|
||||||
@ -121,7 +122,6 @@ type
|
|||||||
out HasRegisterProc: boolean);
|
out HasRegisterProc: boolean);
|
||||||
function PackageGraphCheckInterPkgFiles(IDEObject: TObject;
|
function PackageGraphCheckInterPkgFiles(IDEObject: TObject;
|
||||||
PkgList: TFPList; out FilesChanged: boolean): boolean;
|
PkgList: TFPList; out FilesChanged: boolean): boolean;
|
||||||
|
|
||||||
// package graph
|
// package graph
|
||||||
function PackageGraphExplorerOpenPackage(Sender: TObject;
|
function PackageGraphExplorerOpenPackage(Sender: TObject;
|
||||||
APackage: TLazPackage): TModalResult;
|
APackage: TLazPackage): TModalResult;
|
||||||
@ -138,7 +138,6 @@ type
|
|||||||
procedure PackageGraphEndUpdate(Sender: TObject; GraphChanged: boolean);
|
procedure PackageGraphEndUpdate(Sender: TObject; GraphChanged: boolean);
|
||||||
procedure PackageGraphFindFPCUnit(const AUnitName, Directory: string;
|
procedure PackageGraphFindFPCUnit(const AUnitName, Directory: string;
|
||||||
var Filename: string);
|
var Filename: string);
|
||||||
|
|
||||||
// menu
|
// menu
|
||||||
procedure MainIDEitmPkgOpenPackageFileClick(Sender: TObject);
|
procedure MainIDEitmPkgOpenPackageFileClick(Sender: TObject);
|
||||||
procedure MainIDEitmPkgPkgGraphClick(Sender: TObject);
|
procedure MainIDEitmPkgPkgGraphClick(Sender: TObject);
|
||||||
@ -177,6 +176,9 @@ type
|
|||||||
private
|
private
|
||||||
// helper functions
|
// helper functions
|
||||||
FLastLazarusSrcDir: string;
|
FLastLazarusSrcDir: string;
|
||||||
|
{$IFDEF UseLRS}
|
||||||
|
FIconLRSSource: string;
|
||||||
|
{$ENDIF}
|
||||||
function DoShowSavePackageAsDialog(APackage: TLazPackage): TModalResult;
|
function DoShowSavePackageAsDialog(APackage: TLazPackage): TModalResult;
|
||||||
function CheckPackageGraphForCompilation(APackage: TLazPackage;
|
function CheckPackageGraphForCompilation(APackage: TLazPackage;
|
||||||
FirstDependency: TPkgDependency;
|
FirstDependency: TPkgDependency;
|
||||||
@ -192,6 +194,7 @@ type
|
|||||||
procedure LoadAutoInstallPackages;
|
procedure LoadAutoInstallPackages;
|
||||||
procedure AddUnitToProjectMainUsesSection(AProject: TProject;
|
procedure AddUnitToProjectMainUsesSection(AProject: TProject;
|
||||||
const AnUnitName, AnUnitInFilename: string);
|
const AnUnitName, AnUnitInFilename: string);
|
||||||
|
procedure AddToIconResource(const aIconFile, aResName: string);
|
||||||
// move files
|
// move files
|
||||||
function CheckDrag(Sender, Source: TObject; X, Y: Integer;
|
function CheckDrag(Sender, Source: TObject; X, Y: Integer;
|
||||||
out SrcFilesEdit, TargetFilesEdit: IFilesEditorInterface;
|
out SrcFilesEdit, TargetFilesEdit: IFilesEditorInterface;
|
||||||
@ -721,6 +724,48 @@ begin
|
|||||||
Result:=DoCreatePackageFpmakefile(APackage,false);
|
Result:=DoCreatePackageFpmakefile(APackage,false);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
{$IFDEF UseLRS}
|
||||||
|
procedure TPkgManager.AddToIconResource(const aIconFile, aResName: string);
|
||||||
|
var
|
||||||
|
BinFileStream: TFileStreamUTF8;
|
||||||
|
ResMemStream: TMemoryStream;
|
||||||
|
BinExt, ResType, S: String;
|
||||||
|
Len: integer;
|
||||||
|
begin
|
||||||
|
try
|
||||||
|
BinFileStream:=TFileStreamUTF8.Create(aIconFile,fmOpenRead);
|
||||||
|
try
|
||||||
|
ResMemStream:=TMemoryStream.Create;
|
||||||
|
try
|
||||||
|
Assert(BinFileStream.Position=0, 'TPkgManager.AddToIconResource: Stream.Position > 0');
|
||||||
|
BinExt:=UpperCase(ExtractFileExt(aIconFile));
|
||||||
|
ResType:=Copy(BinExt,2,length(BinExt)-1);
|
||||||
|
BinaryToLazarusResourceCode(BinFileStream,ResMemStream,aResName,ResType);
|
||||||
|
ResMemStream.Position:=0;
|
||||||
|
Len:=ResMemStream.Size;
|
||||||
|
if Len>0 then begin
|
||||||
|
SetLength(S,Len);
|
||||||
|
ResMemStream.Read(S[1],Len);
|
||||||
|
end;
|
||||||
|
FIconLRSSource:=FIconLRSSource+S;
|
||||||
|
finally
|
||||||
|
ResMemStream.Free;
|
||||||
|
end;
|
||||||
|
finally
|
||||||
|
BinFileStream.Free;
|
||||||
|
end;
|
||||||
|
except
|
||||||
|
on E: Exception do begin
|
||||||
|
MessageDlg(lisCCOErrorCaption,
|
||||||
|
Format(lisErrorLoadingFile2,[aIconFile]) + LineEnding + E.Message,
|
||||||
|
mtError, [mbCancel], 0);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
{$ELSE}
|
||||||
|
ToDo: Use FPC's resource type (.res)
|
||||||
|
{$ENDIF}
|
||||||
|
|
||||||
function TPkgManager.OnPackageEditorCreateFile(Sender: TObject;
|
function TPkgManager.OnPackageEditorCreateFile(Sender: TObject;
|
||||||
Params: TAddToPkgResult): TModalResult;
|
Params: TAddToPkgResult): TModalResult;
|
||||||
var
|
var
|
||||||
@ -729,73 +774,44 @@ var
|
|||||||
NewSource: String;
|
NewSource: String;
|
||||||
UnitDirectives: String;
|
UnitDirectives: String;
|
||||||
IconLRSFilename: String;
|
IconLRSFilename: String;
|
||||||
BinFileStream: TFileStreamUTF8;
|
|
||||||
BinMemStream: TMemoryStream;
|
|
||||||
BinExt: String;
|
|
||||||
ResType: String;
|
|
||||||
ResName: String;
|
ResName: String;
|
||||||
ResMemStream: TMemoryStream;
|
|
||||||
CodeBuf: TCodeBuffer;
|
CodeBuf: TCodeBuffer;
|
||||||
begin
|
begin
|
||||||
Result:=mrCancel;
|
Result:=mrCancel;
|
||||||
|
|
||||||
// create icon resource
|
// create icon resource
|
||||||
IconLRSFilename:='';
|
if Params.IconNormFile<>'' then
|
||||||
if Params.IconFile<>'' then begin
|
begin
|
||||||
IconLRSFilename:=ChangeFileExt(Params.UnitFilename,'')+'_icon.lrs';
|
IconLRSFilename:=ChangeFileExt(Params.UnitFilename,'')+'_icon.lrs';
|
||||||
CodeBuf:=CodeToolBoss.CreateFile(IconLRSFilename);
|
CodeBuf:=CodeToolBoss.CreateFile(IconLRSFilename);
|
||||||
if CodeBuf=nil then begin
|
if CodeBuf=nil then begin
|
||||||
debugln(['Error: (lazarus) [TPkgManager.OnPackageEditorCreateFile] file create failed: ',IconLRSFilename]);
|
debugln(['Error: (lazarus) [TPkgManager.OnPackageEditorCreateFile] file create failed: ',IconLRSFilename]);
|
||||||
exit;
|
exit;
|
||||||
end;
|
end;
|
||||||
try
|
FIconLRSSource:='';
|
||||||
BinFileStream:=TFileStreamUTF8.Create(Params.IconFile,fmOpenRead);
|
ResName:=ExtractFileNameOnly(Params.NewClassName);
|
||||||
try
|
AddToIconResource(Params.IconNormFile, ResName);
|
||||||
BinMemStream:=TMemoryStream.Create;
|
if Params.Icon150File<>'' then
|
||||||
ResMemStream:=TMemoryStream.Create;
|
AddToIconResource(Params.Icon150File, ResName+'_150');
|
||||||
try
|
if Params.Icon200File<>'' then
|
||||||
BinMemStream.CopyFrom(BinFileStream,BinFileStream.Size);
|
AddToIconResource(Params.Icon200File, ResName+'_200');
|
||||||
BinMemStream.Position:=0;
|
CodeBuf.Source:=FIconLRSSource;
|
||||||
BinExt:=uppercase(ExtractFileExt(Params.IconFile));
|
Result:=SaveCodeBuffer(CodeBuf);
|
||||||
ResType:=copy(BinExt,2,length(BinExt)-1);
|
if Result<>mrOk then exit;
|
||||||
ResName:=ExtractFileNameOnly(Params.NewClassName);
|
end
|
||||||
BinaryToLazarusResourceCode(BinMemStream,ResMemStream,ResName,ResType);
|
|
||||||
ResMemStream.Position:=0;
|
|
||||||
CodeBuf.LoadFromStream(ResMemStream);
|
|
||||||
Result:=SaveCodeBuffer(CodeBuf);
|
|
||||||
if Result<>mrOk then exit;
|
|
||||||
finally
|
|
||||||
BinMemStream.Free;
|
|
||||||
ResMemStream.Free;
|
|
||||||
end;
|
|
||||||
finally
|
|
||||||
BinFileStream.Free;
|
|
||||||
end;
|
|
||||||
except
|
|
||||||
on E: Exception do begin
|
|
||||||
MessageDlg(lisCCOErrorCaption,
|
|
||||||
Format(lisErrorLoadingFile2,[Params.IconFile]) + LineEnding + E.Message,
|
|
||||||
mtError, [mbCancel], 0);
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
|
|
||||||
// create sourcecode
|
|
||||||
LE:=LineEnding;
|
|
||||||
if PackageGraph.FindDependencyRecursively(Params.Pkg.FirstRequiredDependency,
|
|
||||||
'LCL')<>nil
|
|
||||||
then
|
|
||||||
UsesLine:='Classes, SysUtils, LResources, Forms, Controls, Graphics, Dialogs'
|
|
||||||
else
|
else
|
||||||
UsesLine:='Classes, SysUtils';
|
IconLRSFilename:='';
|
||||||
if (System.Pos(Params.UsedUnitname,UsesLine)<1)
|
// create sourcecode
|
||||||
and (Params.UsedUnitname<>'') then
|
UsesLine:='Classes, SysUtils';
|
||||||
|
if PackageGraph.FindDependencyRecursively(Params.Pkg.FirstRequiredDependency,'LCL')<>nil
|
||||||
|
then
|
||||||
|
UsesLine:=UsesLine+', LResources, Forms, Controls, Graphics, Dialogs';
|
||||||
|
if (System.Pos(Params.UsedUnitname,UsesLine)<1) and (Params.UsedUnitname<>'') then
|
||||||
UsesLine:=UsesLine+', '+Params.UsedUnitname;
|
UsesLine:=UsesLine+', '+Params.UsedUnitname;
|
||||||
UnitDirectives:='{$mode objfpc}{$H+}';
|
UnitDirectives:='{$mode objfpc}{$H+}';
|
||||||
if Params.Pkg<>nil then
|
if Params.Pkg<>nil then
|
||||||
UnitDirectives:=TFileDescPascalUnit.CompilerOptionsToUnitDirectives(
|
UnitDirectives:=TFileDescPascalUnit.CompilerOptionsToUnitDirectives(
|
||||||
Params.Pkg.CompilerOptions);
|
Params.Pkg.CompilerOptions);
|
||||||
|
LE:=LineEnding;
|
||||||
NewSource:=
|
NewSource:=
|
||||||
'unit '+Params.Unit_Name+';'+LE
|
'unit '+Params.Unit_Name+';'+LE
|
||||||
+LE
|
+LE
|
||||||
|
Loading…
Reference in New Issue
Block a user