1 // Permission is hereby granted, free of charge, to any person obtaining
2 // a copy of this software and associated documentation files (the
3 // "Software"), to deal in the Software without restriction, including
4 // without limitation the rights to use, copy, modify, merge, publish,
5 // distribute, sublicense, and/or sell copies of the Software, and to
6 // permit persons to whom the Software is furnished to do so, subject to
7 // the following conditions:
9 // The above copyright notice and this permission notice shall be
10 // included in all copies or substantial portions of the Software.
12 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
13 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
14 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
15 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
16 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
17 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
18 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20 // Copyright (c) 2007, 2008 Novell, Inc.
23 // Andreia Gaita (avidigal@novell.com)
28 using System
.Runtime
.InteropServices
;
29 using System
.Collections
;
30 using System
.Collections
.Specialized
;
31 using Mono
.WebBrowser
.DOM
;
33 namespace Mono
.WebBrowser
35 public interface IWebBrowser
38 /// Initialize a browser instance.
40 /// <param name="handle">
41 /// A <see cref="IntPtr"/> to the native window handle of the widget
42 /// where the browser engine will draw
44 /// <param name="width">
45 /// A <see cref="System.Int32"/>. Initial width
47 /// <param name="height">
48 /// A <see cref="System.Int32"/>. Initial height
51 /// A <see cref="System.Boolean"/>
53 bool Load (IntPtr handle
, int width
, int height
);
55 void FocusIn (FocusOption focus
);
59 void Resize (int width
, int height
);
61 void Render (byte[] data
);
62 void Render (string html
);
63 void Render (string html
, string uri
, string contentType
);
65 void ExecuteScript (string script
);
67 bool Initialized { get; }
68 IWindow Window { get; }
69 IDocument Document { get; }
70 bool Offline {get; set;}
73 /// Object exposing navigation methods like Go, Back, etc.
75 INavigation Navigation { get; }
77 event NodeEventHandler KeyDown
;
78 event NodeEventHandler KeyPress
;
79 event NodeEventHandler KeyUp
;
80 event NodeEventHandler MouseClick
;
81 event NodeEventHandler MouseDoubleClick
;
82 event NodeEventHandler MouseDown
;
83 event NodeEventHandler MouseEnter
;
84 event NodeEventHandler MouseLeave
;
85 event NodeEventHandler MouseMove
;
86 event NodeEventHandler MouseUp
;
87 event EventHandler Focus
;
88 event CreateNewWindowEventHandler CreateNewWindow
;
90 event AlertEventHandler Alert
;
92 event LoadStartedEventHandler LoadStarted
;
93 event LoadCommitedEventHandler LoadCommited
;
94 event ProgressChangedEventHandler ProgressChanged
;
95 event LoadFinishedEventHandler LoadFinished
;
97 event StatusChangedEventHandler StatusChanged
;
98 event SecurityChangedEventHandler SecurityChanged
;
100 event ContextMenuEventHandler ContextMenuShown
;
102 event NavigationRequestedEventHandler NavigationRequested
;
105 public enum ReloadOption
: uint
112 public enum FocusOption
115 FocusFirstElement
= 1,
120 public enum DialogButtonFlags
124 BUTTON_POS_2
= 65536,
126 BUTTON_TITLE_CANCEL
= 2,
127 BUTTON_TITLE_YES
= 3,
129 BUTTON_TITLE_SAVE
= 5,
130 BUTTON_TITLE_DONT_SAVE
= 6,
131 BUTTON_TITLE_REVERT
= 7,
132 BUTTON_TITLE_IS_STRING
= 127,
133 BUTTON_POS_0_DEFAULT
= 0,
134 BUTTON_POS_1_DEFAULT
= 16777216,
135 BUTTON_POS_2_DEFAULT
= 33554432,
136 BUTTON_DELAY_ENABLE
= 67108864,
137 STD_OK_CANCEL_BUTTONS
= 513
140 public enum DialogType
148 PromptUsernamePassword
= 7,
160 public enum SecurityLevel
{
166 #region Window Events
167 public delegate bool CreateNewWindowEventHandler (object sender
, CreateNewWindowEventArgs e
);
168 public class CreateNewWindowEventArgs
: EventArgs
170 private bool isModal
;
172 #region Public Constructors
173 public CreateNewWindowEventArgs (bool isModal
)
176 this.isModal
= isModal
;
178 #endregion // Public Constructors
180 #region Public Instance Properties
183 get { return this.isModal; }
185 #endregion // Public Instance Properties
189 #region Script events
191 public delegate void AlertEventHandler (object sender
, AlertEventArgs e
);
192 public class AlertEventArgs
: EventArgs
194 private DialogType type
;
195 private string title
;
197 private string text2
;
199 private string username
;
200 private string password
;
201 private string checkMsg
;
202 private bool checkState
;
203 private DialogButtonFlags dialogButtons
;
205 private StringCollection buttons
;
206 private StringCollection options
;
208 private object returnValue
;
210 #region Public Constructors
212 /// void (STDCALL *OnAlert) (const PRUnichar * title, const PRUnichar * text);
214 /// <param name="title"></param>
215 /// <param name="text"></param>
216 public AlertEventArgs ()
222 #endregion // Public Constructors
224 #region Public Instance Properties
225 public DialogType Type
{
226 get { return this.type; }
227 set { this.type = value; }
229 public string Title
{
230 get { return this.title; }
231 set { this.title = value; }
234 get { return this.text; }
235 set { this.text = value; }
237 public string Text2
{
238 get { return this.text2; }
239 set { this.text2 = value; }
241 public string CheckMessage
243 get { return this.checkMsg; }
244 set { this.checkMsg = value; }
246 public bool CheckState
{
247 get { return this.checkState; }
248 set { this.checkState = value; }
250 public DialogButtonFlags DialogButtons
{
251 get { return this.dialogButtons; }
252 set { this.dialogButtons = value; }
254 public StringCollection Buttons
{
255 get { return buttons; }
256 set { buttons = value; }
258 public StringCollection Options
{
259 get { return options; }
260 set { options = value; }
263 public string Username
{
264 get { return username; }
265 set { username = value; }
268 public string Password
{
269 get { return password; }
270 set { password = value; }
273 public bool BoolReturn
{
275 if (returnValue
is bool)
276 return (bool) returnValue
;
279 set { returnValue = value; }
282 public int IntReturn
{
284 if (returnValue
is int)
285 return (int) returnValue
;
288 set { returnValue = value; }
291 public string StringReturn
{
293 if (returnValue
is string)
294 return (string) returnValue
;
297 set { returnValue = value; }
304 #region Loading events
306 public delegate void StatusChangedEventHandler (object sender
, StatusChangedEventArgs e
);
307 public class StatusChangedEventArgs
: EventArgs
309 private string message
;
310 public string Message
{
311 get { return message; }
312 set { message = value; }
317 get { return status; }
318 set { status = value; }
321 public StatusChangedEventArgs (string message
, int status
)
323 this.message
= message
;
324 this.status
= status
;
328 public delegate void ProgressChangedEventHandler (object sender
, ProgressChangedEventArgs e
);
329 public class ProgressChangedEventArgs
: EventArgs
331 private int progress
;
332 public int Progress
{
333 get { return progress; }
335 private int maxProgress
;
336 public int MaxProgress
{
337 get { return maxProgress; }
340 public ProgressChangedEventArgs (int progress
, int maxProgress
) {
341 this.progress
= progress
;
342 this.maxProgress
= maxProgress
;
346 public delegate void LoadStartedEventHandler (object sender
, LoadStartedEventArgs e
);
347 public class LoadStartedEventArgs
: System
.ComponentModel
.CancelEventArgs
{
352 private string frameName
;
353 public string FrameName
{
354 get {return frameName;}
356 public LoadStartedEventArgs (string uri
, string frameName
) {
358 this.frameName
= frameName
;
361 public delegate void LoadCommitedEventHandler (object sender
, LoadCommitedEventArgs e
);
362 public class LoadCommitedEventArgs
: EventArgs
{
367 public LoadCommitedEventArgs (string uri
) {
372 public delegate void LoadFinishedEventHandler (object sender
, LoadFinishedEventArgs e
);
373 public class LoadFinishedEventArgs
: EventArgs
{
378 public LoadFinishedEventArgs (string uri
) {
383 public delegate void SecurityChangedEventHandler (object sender
, SecurityChangedEventArgs e
);
384 public class SecurityChangedEventArgs
: EventArgs
386 private SecurityLevel state
;
387 public SecurityLevel State
{
388 get { return state; }
389 set { state = value; }
392 public SecurityChangedEventArgs (SecurityLevel state
)
398 public delegate void ContextMenuEventHandler (object sender
, ContextMenuEventArgs e
);
399 public class ContextMenuEventArgs
: EventArgs
411 public ContextMenuEventArgs (int x
, int y
)
418 public delegate void NavigationRequestedEventHandler (object sender
, NavigationRequestedEventArgs e
);
419 public class NavigationRequestedEventArgs
: System
.ComponentModel
.CancelEventArgs
{
424 public NavigationRequestedEventArgs (string uri
) {