[541] | 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:
|
---|
| 17 | THIS SOFTWARE IS PROVIDED TO YOU "AS IS" WITHOUT WARRANTY OF ANY KIND,
|
---|
| 18 | EITHER EXPRESSED OR IMPLIED INCLUDING BUT NOT LIMITED TO THE APPLIED
|
---|
| 19 | WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
|
---|
| 20 | YOU ASSUME THE ENTIRE RISK AS TO THE ACCURACY AND THE USE OF THE SOFTWARE
|
---|
| 21 | AND ALL OTHER RISK ARISING OUT OF THE USE OR PERFORMANCE OF THIS SOFTWARE
|
---|
| 22 | AND DOCUMENTATION. BSALSA PRODUCTIONS DOES NOT WARRANT THAT THE SOFTWARE IS ERROR-FREE
|
---|
| 23 | OR WILL OPERATE WITHOUT INTERRUPTION. THE SOFTWARE IS NOT DESIGNED, INTENDED
|
---|
| 24 | OR LICENSED FOR USE IN HAZARDOUS ENVIRONMENTS REQUIRING FAIL-SAFE CONTROLS,
|
---|
| 25 | INCLUDING WITHOUT LIMITATION, THE DESIGN, CONSTRUCTION, MAINTENANCE OR
|
---|
| 26 | OPERATION OF NUCLEAR FACILITIES, AIRCRAFT NAVIGATION OR COMMUNICATION SYSTEMS,
|
---|
| 27 | AIR TRAFFIC CONTROL, AND LIFE SUPPORT OR WEAPONS SYSTEMS. BSALSA PRODUCTIONS SPECIFICALLY
|
---|
| 28 | DISCLAIMS ANY EXPRESS OR IMPLIED WARRANTY OF FITNESS FOR SUCH PURPOSE.
|
---|
| 29 |
|
---|
| 30 | You may use, change or modify the component under 3 conditions:
|
---|
| 31 | 1. In your website, add a link to "http://www.bsalsa.com"
|
---|
| 32 | 2. In your application, add credits to "Embedded Web Browser"
|
---|
| 33 | 3. Mail me (bsalsa@gmail.com) any code change in the unit
|
---|
| 34 | for the benefit of the other users.
|
---|
| 35 | 4. 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 |
|
---|
| 39 | unit EwbEditors;
|
---|
| 40 |
|
---|
| 41 | interface
|
---|
| 42 |
|
---|
| 43 | {$I EWB.inc}
|
---|
| 44 |
|
---|
| 45 | uses
|
---|
| 46 | {$IFDEF DELPHI6_UP}DesignEditors, DesignIntf, StrEdit{$ELSE}DsgnIntf{$ENDIF}
|
---|
| 47 | , Classes;
|
---|
| 48 |
|
---|
| 49 | type
|
---|
| 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 |
|
---|
| 109 | implementation
|
---|
| 110 |
|
---|
| 111 | uses
|
---|
| 112 | Browse4Folder, TypInfo, ShellApi, Windows, Dialogs, SysUtils, IEConst, Forms, shlobj;
|
---|
| 113 |
|
---|
| 114 | //--Verb Delphi menu------------------------------------------------------------
|
---|
| 115 |
|
---|
| 116 | procedure TEwbCompEditor.ExecuteVerb(Idx: integer);
|
---|
| 117 | begin
|
---|
| 118 | case Idx of
|
---|
| 119 | 0: ShellExecute(0, 'open', SITE_ADDRESS, nil, nil, SW_SHOW);
|
---|
| 120 | end;
|
---|
| 121 | end;
|
---|
| 122 |
|
---|
| 123 | function TEwbCompEditor.GetVerb(Idx: Integer): string;
|
---|
| 124 | begin
|
---|
| 125 | case Idx of
|
---|
| 126 | 0: Result := 'Support: ' + SITE_ADDRESS;
|
---|
| 127 | 1: Result := 'Package Version:' + VER_NUM;
|
---|
| 128 | end;
|
---|
| 129 | end;
|
---|
| 130 |
|
---|
| 131 | function TEwbCompEditor.GetVerbCount: integer;
|
---|
| 132 | begin
|
---|
| 133 | Result := 2;
|
---|
| 134 | end;
|
---|
| 135 |
|
---|
| 136 | //---BuildIn Save Dialog for the components-------------------------------------
|
---|
| 137 |
|
---|
| 138 | procedure TSaveFileDLG.Edit;
|
---|
| 139 | var
|
---|
| 140 | SD: TSaveDialog;
|
---|
| 141 | begin
|
---|
| 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;
|
---|
| 157 | end;
|
---|
| 158 |
|
---|
| 159 | function TSaveFileDLG.GetAttributes: TPropertyAttributes;
|
---|
| 160 | begin
|
---|
| 161 | Result := [paDialog, paRevertable];
|
---|
| 162 | end;
|
---|
| 163 |
|
---|
| 164 | procedure TSaveHtmlDLG.Edit;
|
---|
| 165 | var
|
---|
| 166 | SD: TSaveDialog;
|
---|
| 167 | begin
|
---|
| 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;
|
---|
| 183 | end;
|
---|
| 184 |
|
---|
| 185 | function TSaveHtmlDLG.GetAttributes: TPropertyAttributes;
|
---|
| 186 | begin
|
---|
| 187 | Result := [paDialog, paRevertable];
|
---|
| 188 | end;
|
---|
| 189 |
|
---|
| 190 | procedure TSaveTextDLG.Edit;
|
---|
| 191 | var
|
---|
| 192 | SD: TSaveDialog;
|
---|
| 193 | begin
|
---|
| 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;
|
---|
| 209 | end;
|
---|
| 210 |
|
---|
| 211 | function TSaveTextDLG.GetAttributes: TPropertyAttributes;
|
---|
| 212 | begin
|
---|
| 213 | Result := [paDialog, paRevertable];
|
---|
| 214 | end;
|
---|
| 215 |
|
---|
| 216 | //---BuildIn Open Dialog for the components-------------------------------------
|
---|
| 217 |
|
---|
| 218 | procedure TOpenFileDLG.Edit;
|
---|
| 219 | var
|
---|
| 220 | OD: TOpenDialog;
|
---|
| 221 | begin
|
---|
| 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;
|
---|
| 237 | end;
|
---|
| 238 |
|
---|
| 239 | function TOpenFileDLG.GetAttributes: TPropertyAttributes;
|
---|
| 240 | begin
|
---|
| 241 | Result := [paDialog, paRevertable];
|
---|
| 242 | end;
|
---|
| 243 |
|
---|
| 244 | procedure TOpenHtmlDLG.Edit;
|
---|
| 245 | var
|
---|
| 246 | OD: TOpenDialog;
|
---|
| 247 | begin
|
---|
| 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;
|
---|
| 263 | end;
|
---|
| 264 |
|
---|
| 265 | function TOpenHtmlDLG.GetAttributes: TPropertyAttributes;
|
---|
| 266 | begin
|
---|
| 267 | Result := [paDialog, paRevertable];
|
---|
| 268 | end;
|
---|
| 269 |
|
---|
| 270 | //---Browse For Folder----------------------------------------------------------
|
---|
| 271 |
|
---|
| 272 | function TBrowse4FolderDLG.GetAttributes: TPropertyAttributes;
|
---|
| 273 | begin
|
---|
| 274 | Result := [paDialog, paRevertable];
|
---|
| 275 | end;
|
---|
| 276 |
|
---|
| 277 | procedure TBrowse4FolderDLG.Edit;
|
---|
| 278 | var
|
---|
| 279 | BD: TBrowse4Folder;
|
---|
| 280 | begin
|
---|
| 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;
|
---|
| 293 | end;
|
---|
| 294 |
|
---|
| 295 | procedure TBFFEditor.ExecuteVerb(Idx: integer);
|
---|
| 296 | var
|
---|
| 297 | BD: TBrowse4Folder;
|
---|
| 298 | begin
|
---|
| 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;
|
---|
| 314 | end;
|
---|
| 315 |
|
---|
| 316 | function TBFFEditor.GetVerb(Idx: Integer): string;
|
---|
| 317 | begin
|
---|
| 318 | case Idx of
|
---|
| 319 | 0: Result := 'Support: ' + SITE_ADDRESS;
|
---|
| 320 | 1: Result := 'Package Version:' + VER_NUM;
|
---|
| 321 | end;
|
---|
| 322 | end;
|
---|
| 323 |
|
---|
| 324 | function TBFFEditor.GetVerbCount: integer;
|
---|
| 325 | begin
|
---|
| 326 | Result := 2;
|
---|
| 327 | end;
|
---|
| 328 | {$IFDEF DELPHI6_UP}
|
---|
| 329 | { TMultiStringProperty }
|
---|
| 330 |
|
---|
| 331 | function TMultiStringProperty.GetStrings: TStrings;
|
---|
| 332 | begin
|
---|
| 333 | if fStrings = nil then fStrings := TStringList.Create;
|
---|
| 334 | fStrings.Text := GetStrValue;
|
---|
| 335 | Result := fStrings;
|
---|
| 336 | end;
|
---|
| 337 |
|
---|
| 338 | procedure TMultiStringProperty.SetStrings(const Value: TStrings);
|
---|
| 339 | begin
|
---|
| 340 | SetStrValue(Value.Text);
|
---|
| 341 | end;
|
---|
| 342 | {$ENDIF}
|
---|
| 343 |
|
---|
| 344 | end.
|
---|