-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHyperlinkProp.pas
142 lines (115 loc) · 3.62 KB
/
HyperlinkProp.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
unit HyperlinkProp;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, ExtCtrls, Primitives, Menus;
type
THyperlinkProperties = class(TForm)
Panel1: TPanel;
Text: TMemo;
RadioHyperlink: TRadioButton;
RadioPopup: TRadioButton;
TextEditPopupMenu: TPopupMenu;
CutMenuItem: TMenuItem;
CopyMenuItem: TMenuItem;
PasteMenuItem: TMenuItem;
DeleteMenuItem: TMenuItem;
CancelMenuItem: TMenuItem;
CheckHidden: TCheckBox;
procedure TextChange(Sender: TObject);
procedure RadioClick(Sender: TObject);
procedure CutMenuItemClick(Sender: TObject);
procedure CopyMenuItemClick(Sender: TObject);
procedure PasteMenuItemClick(Sender: TObject);
procedure DeleteMenuItemClick(Sender: TObject);
procedure CancelMenuItemClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
procedure ApplyChanges(const lbl:string; compress:boolean; const attrib:TextAttrib);
end;
var
HyperlinkProperties: THyperlinkProperties;
procedure AssignHyperlinkAttribs(attrib:TextAttrib);
implementation
{$R *.dfm}
uses MapObject, LocalizedStrings;
procedure AssignHyperlinkAttribs(attrib:TextAttrib);
var SaveChangeProc:TNotifyEvent;
begin
with HyperlinkProperties do begin
if tatHyperlinkText in attrib.Valid then begin
SaveChangeProc:=Text.OnChange;
Text.OnChange:=nil;
Text.Text := Attrib.HyperlinkText;
Text.OnChange:=SaveChangeProc;
end;
if tatHyperlinkFlags in attrib.Valid then begin
SaveChangeProc:=RadioHyperlink.OnClick;
RadioHyperlink.OnClick:=nil;
RadioPopup.OnClick:=nil;
CheckHidden.OnClick:=nil;
if (hyperExecute in attrib.HyperlinkFlags) then
RadioHyperlink.Checked := true
else
RadioPopup.Checked := true;
CheckHidden.Checked := (hyperHidden in attrib.HyperlinkFlags);
RadioHyperlink.OnClick:=SaveChangeProc;
RadioPopup.OnClick:=SaveChangeProc;
CheckHidden.OnClick:=SaveChangeProc;
end;
end;
end;
procedure THyperlinkProperties.ApplyChanges(const lbl:string; compress:boolean; const attrib:TextAttrib);
var currattrib:TextAttrib;
begin
currattrib:=Map.GetTextAttrib;
// if any hyperlinks are selected, change them.
if currattrib.Valid <> [] then begin
Map.SetUndoPoint(lbl,compress);
Map.SetTextAttrib(Map.CurrentView, attrib);
end;
HyperlinkProperties.ActiveControl:=Text;
end;
procedure THyperlinkProperties.CutMenuItemClick(Sender: TObject);
begin
Text.CutToClipboard;
end;
procedure THyperlinkProperties.CopyMenuItemClick(Sender: TObject);
begin
Text.CopyToClipboard;
end;
procedure THyperlinkProperties.PasteMenuItemClick(Sender: TObject);
begin
Text.PasteFromClipboard;
end;
procedure THyperlinkProperties.DeleteMenuItemClick(Sender: TObject);
begin
SendMessage(Text.Handle, WM_KEYDOWN, VK_DELETE, 0);
SendMessage(Text.Handle, WM_KEYUP, VK_DELETE, 0);
end;
procedure THyperlinkProperties.CancelMenuItemClick(Sender: TObject);
begin
Visible:=false;
end;
procedure THyperlinkProperties.TextChange(Sender: TObject);
var attrib:TextAttrib;
begin
attrib.Valid:=[tatHyperlinkText];
attrib.HyperlinkText:=Text.Text;
ApplyChanges(res_hyperlink_change,true,attrib);
end;
procedure THyperlinkProperties.RadioClick(Sender: TObject);
var attrib:TextAttrib;
begin
attrib.Valid:=[tatHyperlinkFlags];
if (RadioHyperlink.Checked) then
attrib.HyperlinkFlags:=[hyperExecute]
else
attrib.HyperlinkFlags:=[];
if (CheckHidden.Checked) then
attrib.HyperlinkFlags := attrib.HyperlinkFlags + [hyperHidden];
ApplyChanges(res_hyperlink_change,true,attrib);
end;
end.