2010-06-21 Jonathan Chambers <joncham@gmail.com>
[mcs.git] / class / Mono.WebBrowser / Mono.WebBrowser / IWebBrowser.cs
blob01f1dc8b4cb3c946e09c07a0937b26750462a0b2
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:
8 //
9 // The above copyright notice and this permission notice shall be
10 // included in all copies or substantial portions of the Software.
11 //
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.
22 // Authors:
23 // Andreia Gaita (avidigal@novell.com)
26 using System;
27 using System.Text;
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
37 /// <summary>
38 /// Initialize a browser instance.
39 /// </summary>
40 /// <param name="handle">
41 /// A <see cref="IntPtr"/> to the native window handle of the widget
42 /// where the browser engine will draw
43 /// </param>
44 /// <param name="width">
45 /// A <see cref="System.Int32"/>. Initial width
46 /// </param>
47 /// <param name="height">
48 /// A <see cref="System.Int32"/>. Initial height
49 /// </param>
50 /// <returns>
51 /// A <see cref="System.Boolean"/>
52 /// </returns>
53 bool Load (IntPtr handle, int width, int height);
54 void Shutdown ();
55 void FocusIn (FocusOption focus);
56 void FocusOut ();
57 void Activate ();
58 void Deactivate ();
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;}
72 /// <value>
73 /// Object exposing navigation methods like Go, Back, etc.
74 /// </value>
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
107 None = 0,
108 Proxy = 1,
109 Full = 2
112 public enum FocusOption
114 None = 0,
115 FocusFirstElement = 1,
116 FocusLastElement = 2
119 [Flags]
120 public enum DialogButtonFlags
122 BUTTON_POS_0 = 1,
123 BUTTON_POS_1 = 256,
124 BUTTON_POS_2 = 65536,
125 BUTTON_TITLE_OK = 1,
126 BUTTON_TITLE_CANCEL = 2,
127 BUTTON_TITLE_YES = 3,
128 BUTTON_TITLE_NO = 4,
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
142 Alert = 1,
143 AlertCheck = 2,
144 Confirm = 3,
145 ConfirmEx = 4,
146 ConfirmCheck = 5,
147 Prompt = 6,
148 PromptUsernamePassword = 7,
149 PromptPassword = 8,
150 Select = 9
153 public enum Platform
155 Unknown = 0,
156 Winforms = 1,
157 Gtk = 2
160 public enum SecurityLevel {
161 Insecure= 1,
162 Mixed = 2,
163 Secure = 3
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)
174 : base ()
176 this.isModal = isModal;
178 #endregion // Public Constructors
180 #region Public Instance Properties
181 public bool IsModal
183 get { return this.isModal; }
185 #endregion // Public Instance Properties
187 #endregion
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;
196 private string text;
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
211 /// <summary>
212 /// void (STDCALL *OnAlert) (const PRUnichar * title, const PRUnichar * text);
213 /// </summary>
214 /// <param name="title"></param>
215 /// <param name="text"></param>
216 public AlertEventArgs ()
217 : base ()
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; }
233 public string Text {
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 {
274 get {
275 if (returnValue is bool)
276 return (bool) returnValue;
277 return false;
279 set { returnValue = value; }
282 public int IntReturn {
283 get {
284 if (returnValue is int)
285 return (int) returnValue;
286 return -1;
288 set { returnValue = value; }
291 public string StringReturn {
292 get {
293 if (returnValue is string)
294 return (string) returnValue;
295 return String.Empty;
297 set { returnValue = value; }
300 #endregion
302 #endregion
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; }
315 private int status;
316 public int Status {
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 {
348 private string uri;
349 public string Uri {
350 get {return uri;}
352 private string frameName;
353 public string FrameName {
354 get {return frameName;}
356 public LoadStartedEventArgs (string uri, string frameName) {
357 this.uri = uri;
358 this.frameName = frameName;
361 public delegate void LoadCommitedEventHandler (object sender, LoadCommitedEventArgs e);
362 public class LoadCommitedEventArgs : EventArgs {
363 private string uri;
364 public string Uri {
365 get {return uri;}
367 public LoadCommitedEventArgs (string uri) {
368 this.uri = uri;
372 public delegate void LoadFinishedEventHandler (object sender, LoadFinishedEventArgs e);
373 public class LoadFinishedEventArgs : EventArgs {
374 private string uri;
375 public string Uri {
376 get {return uri;}
378 public LoadFinishedEventArgs (string uri) {
379 this.uri = 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)
394 this.state = state;
398 public delegate void ContextMenuEventHandler (object sender, ContextMenuEventArgs e);
399 public class ContextMenuEventArgs : EventArgs
401 private int x;
402 private int y;
404 public int X {
405 get { return x; }
407 public int Y {
408 get { return y; }
411 public ContextMenuEventArgs (int x, int y)
413 this.x = x;
414 this.y = y;
418 public delegate void NavigationRequestedEventHandler (object sender, NavigationRequestedEventArgs e);
419 public class NavigationRequestedEventArgs : System.ComponentModel.CancelEventArgs {
420 private string uri;
421 public string Uri {
422 get {return uri;}
424 public NavigationRequestedEventArgs (string uri) {
425 this.uri = uri;
428 #endregion