source: cprs/branches/tmg-cprs/CPRS-Chart/TMG_Extra/HTMLEdit/EwbEditors.pas@ 1742

Last change on this file since 1742 was 541, checked in by Kevin Toppenberg, 15 years ago

TMG Ver 1.1 Added HTML Support, better demographics editing

File size: 9.0 KB
Line 
1//**************************************************************
2// *
3// Ewb_Editors *
4// For Delphi *
5// *
6// For Delphi 5, 6, 7, 2005, 2006 *
7// by *
8// bsalsa - Eran Bodankin - bsalsa@gmail.com *
9// *
10// *
11// Updated versions: *
12// http://www.bsalsa.com *
13//**************************************************************
14
15{*******************************************************************************}
16{LICENSE:
17THIS SOFTWARE IS PROVIDED TO YOU "AS IS" WITHOUT WARRANTY OF ANY KIND,
18EITHER EXPRESSED OR IMPLIED INCLUDING BUT NOT LIMITED TO THE APPLIED
19WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
20YOU ASSUME THE ENTIRE RISK AS TO THE ACCURACY AND THE USE OF THE SOFTWARE
21AND ALL OTHER RISK ARISING OUT OF THE USE OR PERFORMANCE OF THIS SOFTWARE
22AND DOCUMENTATION. BSALSA PRODUCTIONS DOES NOT WARRANT THAT THE SOFTWARE IS ERROR-FREE
23OR WILL OPERATE WITHOUT INTERRUPTION. THE SOFTWARE IS NOT DESIGNED, INTENDED
24OR LICENSED FOR USE IN HAZARDOUS ENVIRONMENTS REQUIRING FAIL-SAFE CONTROLS,
25INCLUDING WITHOUT LIMITATION, THE DESIGN, CONSTRUCTION, MAINTENANCE OR
26OPERATION OF NUCLEAR FACILITIES, AIRCRAFT NAVIGATION OR COMMUNICATION SYSTEMS,
27AIR TRAFFIC CONTROL, AND LIFE SUPPORT OR WEAPONS SYSTEMS. BSALSA PRODUCTIONS SPECIFICALLY
28DISCLAIMS ANY EXPRESS OR IMPLIED WARRANTY OF FITNESS FOR SUCH PURPOSE.
29
30You may use, change or modify the component under 3 conditions:
311. In your website, add a link to "http://www.bsalsa.com"
322. In your application, add credits to "Embedded Web Browser"
333. Mail me (bsalsa@gmail.com) any code change in the unit
34 for the benefit of the other users.
354. Please consider donation in our web site!
36{*******************************************************************************}
37//$Id: EwbEditors.pas,v 1.3.2.1 2006/12/10 18:43:49 sergev Exp $
38
39unit EwbEditors;
40
41interface
42
43{$I EWB.inc}
44
45uses
46{$IFDEF DELPHI6_UP}DesignEditors, DesignIntf, StrEdit{$ELSE}DsgnIntf{$ENDIF}
47 , Classes;
48
49type
50 TEwbCompEditor = class(TComponentEditor)
51 public
52 procedure ExecuteVerb(Idx: integer); override;
53 function GetVerb(Idx: integer): string; override;
54 function GetVerbCount: integer; override;
55 end;
56
57 TBFFEditor = class(TComponentEditor)
58 public
59 procedure ExecuteVerb(Idx: integer); override;
60 function GetVerb(Idx: integer): string; override;
61 function GetVerbCount: integer; override;
62 end;
63
64 TSaveFileDLG = class(TStringProperty)
65 public
66 procedure Edit; override;
67 function GetAttributes: TPropertyAttributes; override;
68 end;
69
70 TSaveTextDLG = class(TStringProperty)
71 public
72 procedure Edit; override;
73 function GetAttributes: TPropertyAttributes; override;
74 end;
75
76 TSaveHtmlDLG = class(TStringProperty)
77 public
78 procedure Edit; override;
79 function GetAttributes: TPropertyAttributes; override;
80 end;
81
82 TOpenFileDLG = class(TStringProperty)
83 public
84 procedure Edit; override;
85 function GetAttributes: TPropertyAttributes; override;
86 end;
87
88 TOpenHtmlDLG = class(TStringProperty)
89 public
90 procedure Edit; override;
91 function GetAttributes: TPropertyAttributes; override;
92 end;
93
94 TBrowse4FolderDLG = class(TStringProperty)
95 public
96 procedure Edit; override;
97 function GetAttributes: TPropertyAttributes; override;
98 end;
99{$IFDEF DELPHI6_UP}
100 TMultiStringProperty = class(TStringListProperty)
101 private
102 fStrings: TStringList;
103 protected
104 function GetStrings: TStrings; override;
105 procedure SetStrings(const Value: TStrings); override;
106 end;
107{$ENDIF}
108
109implementation
110
111uses
112 Browse4Folder, TypInfo, ShellApi, Windows, Dialogs, SysUtils, IEConst, Forms, shlobj;
113
114//--Verb Delphi menu------------------------------------------------------------
115
116procedure TEwbCompEditor.ExecuteVerb(Idx: integer);
117begin
118 case Idx of
119 0: ShellExecute(0, 'open', SITE_ADDRESS, nil, nil, SW_SHOW);
120 end;
121end;
122
123function TEwbCompEditor.GetVerb(Idx: Integer): string;
124begin
125 case Idx of
126 0: Result := 'Support: ' + SITE_ADDRESS;
127 1: Result := 'Package Version:' + VER_NUM;
128 end;
129end;
130
131function TEwbCompEditor.GetVerbCount: integer;
132begin
133 Result := 2;
134end;
135
136//---BuildIn Save Dialog for the components-------------------------------------
137
138procedure TSaveFileDLG.Edit;
139var
140 SD: TSaveDialog;
141begin
142 SD := TSaveDialog.Create(Application);
143 try
144 with SD do
145 begin
146 Filename := GetValue();
147 InitialDir := ExtractFilePath(FileName);
148 Filter := '*.*';
149 HelpContext := 0;
150 Options := Options + [ofShowHelp, ofEnableSizing];
151 if Execute then
152 SetValue(FileName);
153 end;
154 finally
155 SD.Free;
156 end;
157end;
158
159function TSaveFileDLG.GetAttributes: TPropertyAttributes;
160begin
161 Result := [paDialog, paRevertable];
162end;
163
164procedure TSaveHtmlDLG.Edit;
165var
166 SD: TSaveDialog;
167begin
168 SD := TSaveDialog.Create(Application);
169 try
170 with SD do
171 begin
172 Filename := GetValue();
173 InitialDir := ExtractFilePath(FileName);
174 Filter := 'Html files|*.html|Htm files|*.htm';
175 HelpContext := 0;
176 Options := Options + [ofShowHelp, ofEnableSizing];
177 if Execute then
178 SetValue(FileName);
179 end;
180 finally
181 SD.Free;
182 end;
183end;
184
185function TSaveHtmlDLG.GetAttributes: TPropertyAttributes;
186begin
187 Result := [paDialog, paRevertable];
188end;
189
190procedure TSaveTextDLG.Edit;
191var
192 SD: TSaveDialog;
193begin
194 SD := TSaveDialog.Create(Application);
195 try
196 with SD do
197 begin
198 Filename := GetValue();
199 InitialDir := ExtractFilePath(FileName);
200 Filter := 'Text files|*.txt|Word files|*.doc';
201 HelpContext := 0;
202 Options := Options + [ofShowHelp, ofEnableSizing];
203 if Execute then
204 SetValue(FileName);
205 end;
206 finally
207 SD.Free;
208 end;
209end;
210
211function TSaveTextDLG.GetAttributes: TPropertyAttributes;
212begin
213 Result := [paDialog, paRevertable];
214end;
215
216//---BuildIn Open Dialog for the components-------------------------------------
217
218procedure TOpenFileDLG.Edit;
219var
220 OD: TOpenDialog;
221begin
222 OD := TOpenDialog.Create(Application);
223 try
224 with OD do
225 begin
226 Filename := GetValue();
227 InitialDir := ExtractFilePath(FileName);
228 Filter := '*.*';
229 HelpContext := 0;
230 Options := Options + [ofShowHelp, ofEnableSizing];
231 if Execute then
232 SetValue(FileName);
233 end;
234 finally
235 OD.Free;
236 end;
237end;
238
239function TOpenFileDLG.GetAttributes: TPropertyAttributes;
240begin
241 Result := [paDialog, paRevertable];
242end;
243
244procedure TOpenHtmlDLG.Edit;
245var
246 OD: TOpenDialog;
247begin
248 OD := TOpenDialog.Create(Application);
249 try
250 with OD do
251 begin
252 Filename := GetValue();
253 InitialDir := ExtractFilePath(FileName);
254 Filter := 'Html files|*.html|Htm files|*.htm';
255 HelpContext := 0;
256 Options := Options + [ofShowHelp, ofEnableSizing];
257 if Execute then
258 SetValue(FileName);
259 end;
260 finally
261 OD.Free;
262 end;
263end;
264
265function TOpenHtmlDLG.GetAttributes: TPropertyAttributes;
266begin
267 Result := [paDialog, paRevertable];
268end;
269
270//---Browse For Folder----------------------------------------------------------
271
272function TBrowse4FolderDLG.GetAttributes: TPropertyAttributes;
273begin
274 Result := [paDialog, paRevertable];
275end;
276
277procedure TBrowse4FolderDLG.Edit;
278var
279 BD: TBrowse4Folder;
280begin
281 BD := TBrowse4Folder.Create(Application);
282 try
283 with BD do
284 begin
285 Filename := GetValue();
286 InitialDir := ExtractFilePath(FileName);
287 if Execute then
288 SetValue(FileName);
289 end;
290 finally
291 BD.Free;
292 end;
293end;
294
295procedure TBFFEditor.ExecuteVerb(Idx: integer);
296var
297 BD: TBrowse4Folder;
298begin
299 case Idx of
300 0:
301 begin
302 BD := TBrowse4Folder.Create(Application);
303 try
304 with BD do
305 begin
306 InitialDir := ExtractFilePath(FileName);
307 Execute;
308 end;
309 finally
310 BD.Free;
311 end;
312 end;
313 end;
314end;
315
316function TBFFEditor.GetVerb(Idx: Integer): string;
317begin
318 case Idx of
319 0: Result := 'Support: ' + SITE_ADDRESS;
320 1: Result := 'Package Version:' + VER_NUM;
321 end;
322end;
323
324function TBFFEditor.GetVerbCount: integer;
325begin
326 Result := 2;
327end;
328{$IFDEF DELPHI6_UP}
329{ TMultiStringProperty }
330
331function TMultiStringProperty.GetStrings: TStrings;
332begin
333 if fStrings = nil then fStrings := TStringList.Create;
334 fStrings.Text := GetStrValue;
335 Result := fStrings;
336end;
337
338procedure TMultiStringProperty.SetStrings(const Value: TStrings);
339begin
340 SetStrValue(Value.Text);
341end;
342{$ENDIF}
343
344end.
Note: See TracBrowser for help on using the repository browser.