source: cprs/branches/tmg-cprs/CPRS-Chart/TMG_Extra/HTMLEdit/EwbActns.pas@ 1677

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

TMG Ver 1.1 Added HTML Support, better demographics editing

File size: 4.8 KB
Line 
1//*************************************************************
2// EwbActns *
3// *
4// Freeware unit *
5// For Delphi *
6// by *
7// Serge Voloshenyuk *
8// Developing Team: *
9// Serge Voloshenyuk (SergeV@bsalsa.com) *
10// Eran Bodankin (bsalsa) -(bsalsa@gmail.com) *
11// *
12// Documentation and updated versions: *
13// *
14// http://www.bsalsa.com *
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/ 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 for the benefit
34 of the other users.
354. Please, consider donation in our web site!
36{*******************************************************************************}
37//$Id: EwbActns.pas,v 1.1.2.1 2006/11/29 22:13:00 sergev Exp $
38
39unit EwbActns;
40
41{$I EWB.inc}
42
43interface
44
45uses
46 Classes, ActnList, EwbCore;
47
48type
49 TEwbAction = class(TCustomAction)
50 private
51 FControl: TEwbCore;
52 procedure SetControl(Value: TEwbCore);
53 protected
54 function GetControl(Target: TObject): TEwbCore; virtual;
55 procedure Notification(AComponent: TComponent; Operation: TOperation); override;
56 public
57 destructor Destroy; override;
58 function HandlesTarget(Target: TObject): Boolean; override;
59 property Control: TEwbCore read FControl write SetControl;
60 end;
61
62 TEwbLinkAction = class(TEwbAction)
63 private
64 FURL: WideString;
65 procedure setURL(const Value: WideString);
66 public
67 procedure ExecuteTarget(Target: TObject); override;
68 constructor Create(AOwner: TComponent); override;
69 published
70 property URL: WideString read FURL write setURL;
71 property Caption;
72 property HelpContext;
73{$IFDEF DELPHI6_UP}
74 property HelpKeyword;
75 property HelpType;
76 property SecondaryShortCuts;
77{$ENDIF}
78 property Hint;
79 property ImageIndex;
80 property ShortCut;
81 property Visible;
82 property OnExecute;
83 property OnHint;
84 property OnUpdate;
85 end;
86
87implementation
88
89{ TEwbAction }
90
91destructor TEwbAction.Destroy;
92begin
93 if FControl <> nil then
94 FControl.RemoveFreeNotification(Self);
95 inherited;
96end;
97
98function TEwbAction.GetControl(Target: TObject): TEwbCore;
99begin
100 Result := Target as TEwbCore;
101end;
102
103function TEwbAction.HandlesTarget(Target: TObject): Boolean;
104begin
105 Result := ((Control <> nil) and (Target = Control) or
106 (Control = nil) and (Target is TEwbCore))
107 { and TEwbCore(Target).Focused}; //FIXME
108end;
109
110procedure TEwbAction.Notification(AComponent: TComponent;
111 Operation: TOperation);
112begin
113 inherited Notification(AComponent, Operation);
114 if (Operation = opRemove) and (AComponent = Control) then Control := nil;
115end;
116
117procedure TEwbAction.SetControl(Value: TEwbCore);
118begin
119 if Value <> FControl then
120 begin
121 FControl := Value;
122 if Value <> nil then Value.FreeNotification(Self);
123 end;
124end;
125
126{ TEwbLinkAction }
127
128constructor TEwbLinkAction.Create(AOwner: TComponent);
129begin
130 inherited;
131 Enabled := False;
132end;
133
134procedure TEwbLinkAction.ExecuteTarget(Target: TObject);
135begin
136 GetControl(Target).Navigate(Self.URL);
137end;
138
139procedure TEwbLinkAction.setURL(const Value: WideString);
140begin
141 FURL := Value;
142 Enabled := FURL <> '';
143end;
144
145end.
Note: See TracBrowser for help on using the repository browser.