externhelp: added macrofy button

git-svn-id: trunk@23787 -
This commit is contained in:
mattias 2010-02-25 10:31:25 +00:00
parent 38ee724ecd
commit ffbb6937ae
2 changed files with 107 additions and 46 deletions

View File

@ -64,7 +64,7 @@ inherited ExternHelpGeneralOptsFrame: TExternHelpGeneralOptsFrame
Left = 171
Height = 18
Top = 20
Width = 70
Width = 75
BorderSpacing.Left = 6
BorderSpacing.Top = 20
Caption = 'NameLabel'
@ -77,7 +77,7 @@ inherited ExternHelpGeneralOptsFrame: TExternHelpGeneralOptsFrame
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
Left = 171
Height = 22
Height = 27
Top = 38
Width = 260
Anchors = [akTop, akLeft, akRight]
@ -93,8 +93,8 @@ inherited ExternHelpGeneralOptsFrame: TExternHelpGeneralOptsFrame
AnchorSideTop.Side = asrBottom
Left = 171
Height = 18
Top = 75
Width = 89
Top = 80
Width = 96
BorderSpacing.Top = 15
Caption = 'FilenameLabel'
ParentColor = False
@ -103,11 +103,12 @@ inherited ExternHelpGeneralOptsFrame: TExternHelpGeneralOptsFrame
AnchorSideLeft.Control = FilenameLabel
AnchorSideTop.Control = FilenameLabel
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = FileBrowseSpeedButton
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
Left = 171
Height = 22
Top = 93
Width = 237
Height = 27
Top = 98
Width = 266
Anchors = [akTop, akLeft, akRight]
OnEditingDone = FilenameEditEditingDone
TabOrder = 2
@ -115,12 +116,12 @@ inherited ExternHelpGeneralOptsFrame: TExternHelpGeneralOptsFrame
end
object URLLabel: TLabel[7]
AnchorSideLeft.Control = NameLabel
AnchorSideTop.Control = FilenameEdit
AnchorSideTop.Control = FileBrowseButton
AnchorSideTop.Side = asrBottom
Left = 171
Height = 18
Top = 130
Width = 58
Top = 169
Width = 62
BorderSpacing.Top = 15
Caption = 'URLLabel'
ParentColor = False
@ -132,8 +133,8 @@ inherited ExternHelpGeneralOptsFrame: TExternHelpGeneralOptsFrame
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
Left = 171
Height = 22
Top = 148
Height = 27
Top = 187
Width = 260
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Right = 6
@ -141,39 +142,22 @@ inherited ExternHelpGeneralOptsFrame: TExternHelpGeneralOptsFrame
TabOrder = 3
Text = 'URLEdit'
end
object FileBrowseSpeedButton: TSpeedButton[9]
AnchorSideTop.Control = FilenameEdit
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = FilenameEdit
AnchorSideBottom.Side = asrBottom
Left = 408
Height = 22
Top = 93
Width = 23
Anchors = [akTop, akRight]
BorderSpacing.Right = 6
Color = clBtnFace
NumGlyphs = 0
ShowHint = True
ParentShowHint = False
end
object HelpBitBtn: TBitBtn[10]
object HelpBitBtn: TBitBtn[9]
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom
Left = 341
Height = 20
Top = 300
Width = 90
Left = 346
Height = 29
Top = 291
Width = 85
Anchors = [akRight, akBottom]
AutoSize = True
BorderSpacing.Around = 6
Caption = 'HelpBitBtn'
TabOrder = 4
end
object Splitter1: TSplitter[11]
object Splitter1: TSplitter[10]
AnchorSideTop.Control = ItemsTreeView
AnchorSideBottom.Control = ItemsTreeView
AnchorSideBottom.Side = asrBottom
@ -184,28 +168,60 @@ inherited ExternHelpGeneralOptsFrame: TExternHelpGeneralOptsFrame
Align = alNone
Anchors = [akTop, akLeft, akBottom]
end
object StoreLabel: TLabel[12]
object StoreLabel: TLabel[11]
AnchorSideLeft.Control = NameLabel
AnchorSideTop.Control = URLEdit
AnchorSideTop.Side = asrBottom
Left = 171
Height = 18
Top = 185
Width = 68
Top = 229
Width = 70
BorderSpacing.Top = 15
Caption = 'StoreLabel'
ParentColor = False
end
object StoreComboBox: TComboBox[13]
object StoreComboBox: TComboBox[12]
AnchorSideLeft.Control = StoreLabel
AnchorSideTop.Control = StoreLabel
AnchorSideTop.Side = asrBottom
Left = 171
Height = 21
Top = 203
Height = 29
Top = 247
Width = 157
ItemHeight = 0
TabOrder = 6
Text = 'StoreComboBox'
end
object FileBrowseButton: TButton[13]
AnchorSideLeft.Control = FilenameEdit
AnchorSideTop.Control = FilenameEdit
AnchorSideTop.Side = asrBottom
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = FilenameEdit
AnchorSideBottom.Side = asrBottom
Left = 171
Height = 29
Top = 125
Width = 60
AutoSize = True
BorderSpacing.Right = 6
Caption = 'Browse'
ParentShowHint = False
ShowHint = True
TabOrder = 7
end
object FileMacrofyButton: TButton[14]
AnchorSideLeft.Control = FileBrowseButton
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = FilenameEdit
AnchorSideTop.Side = asrBottom
Left = 237
Height = 29
Top = 125
Width = 131
AutoSize = True
Caption = 'FileMacrofyButton'
OnClick = FileMacrofyButtonClick
TabOrder = 8
end
end

View File

@ -55,6 +55,10 @@ resourcestring
ehrsDeleteItem = 'Delete item';
ehrsBrowseForPath = 'Browse for path';
ehrsGeneral = 'General';
ehrsBrowse = 'Browse';
ehrsMacrofy = 'Macrofy';
ehrsReplaceCommonDirectoriesWithMacros = 'Replace common directories with '
+'macros';
type
@ -130,7 +134,7 @@ type
function Save: TModalResult; virtual;
function GetFullFilename: string;
function IsEqual(Src: TExternHelpOptions): boolean;
procedure Assign(Src: TExternHelpOptions);
procedure Assign(Src: TExternHelpOptions); reintroduce;
procedure IncreaseChangeStep;
property Filename: string read FFilename write SetFilename;
property ChangeStep: integer read FChangeStep;
@ -143,8 +147,9 @@ type
TExternHelpGeneralOptsFrame = class(TAbstractIDEOptionsEditor)
AddSpeedButton: TSpeedButton;
FileMacrofyButton: TButton;
DeleteSpeedButton: TSpeedButton;
FileBrowseSpeedButton: TSpeedButton;
FileBrowseButton: TButton;
FilenameEdit: TEdit;
FilenameLabel: TLabel;
HelpBitBtn: TBitBtn;
@ -158,6 +163,7 @@ type
URLLabel: TLabel;
procedure AddSpeedButtonClick(Sender: TObject);
procedure DeleteSpeedButtonClick(Sender: TObject);
procedure FileMacrofyButtonClick(Sender: TObject);
procedure FilenameEditEditingDone(Sender: TObject);
procedure ItemsTreeViewEdited(Sender: TObject; Node: TTreeNode;
var S: string);
@ -176,6 +182,7 @@ type
function FindTVNode(NodeText: string): TTreeNode;
function CreateUniqueName(Prefix: string): string;
procedure FillStoreInCombobox;
function Macrofy(Filename: string): string;
public
constructor Create(TheOwner: TComponent); override;
destructor Destroy; override;
@ -388,7 +395,7 @@ begin
TVNode:=ItemsTreeView.Selected;
if (TVNode=nil) or (not (TObject(TVNode.Data) is TExternHelpItem)) then exit;
Item:=TExternHelpItem(TVNode.Data);
s:=Trim(s);
s:=TrimFilename(s);
if s<>Item.Filename then begin
Filename:=s;
DoDirSeparators(Filename);
@ -451,6 +458,11 @@ begin
Item.Free;
end;
procedure TExternHelpGeneralOptsFrame.FileMacrofyButtonClick(Sender: TObject);
begin
end;
procedure TExternHelpGeneralOptsFrame.ItemsTreeViewEditing(Sender: TObject;
Node: TTreeNode; var AllowEdit: Boolean);
begin
@ -597,6 +609,36 @@ begin
end;
end;
function TExternHelpGeneralOptsFrame.Macrofy(Filename: string): string;
procedure CheckPath(PathMacro: string; var s: string);
var
Value: String;
begin
Value:=PathMacro;
if (not IDEMacros.SubstituteMacros(Value)) or (Value='')
or (Value[1]='$') then
exit;
Value:=ChompPathDelim(Value);
if CompareFilenames(s,Value)=0 then begin
// whole filename is the macro path
s:=PathMacro;
exit;
end;
Value:=AppendPathDelim(Value);
if CompareFilenames(copy(s,1,length(Value)),Value)=0 then begin
// filename is a file in the macro path
s:=Value+copy(s,length(Value)+1,length(s));
exit;
end;
end;
begin
Result:=Filename;
CheckPath('$(FPCSrcDir)',Result);
CheckPath('$(LazarusDir)',Result);
end;
constructor TExternHelpGeneralOptsFrame.Create(TheOwner: TComponent);
begin
inherited Create(TheOwner);
@ -635,7 +677,10 @@ begin
HelpBitBtn.Caption:=ehrsHelp;
AddSpeedButton.Hint:=ehrsAddNewItem;
DeleteSpeedButton.Hint:=ehrsDeleteItem;
FileBrowseSpeedButton.Hint:=ehrsBrowseForPath;
FileBrowseButton.Caption:=ehrsBrowse;
FileBrowseButton.Hint:=ehrsBrowseForPath;
FileMacrofyButton.Caption:=ehrsMacrofy;
FileMacrofyButton.Hint:=ehrsReplaceCommonDirectoriesWithMacros;
end;
class function TExternHelpGeneralOptsFrame.SupportedOptionsClass: TAbstractIDEOptionsClass;