Awesomium::WebView Class Reference

#include <WebView.h>

List of all members.

Public Member Functions

void destroy ()
void setListener (WebViewListener *listener)
WebViewListenergetListener ()
void loadURL (const std::string &url, const std::wstring &frameName=L"", const std::string &username="", const std::string &password="")
void loadHTML (const std::string &html, const std::wstring &frameName=L"")
void loadFile (const std::string &file, const std::wstring &frameName=L"")
void goToHistoryOffset (int offset)
void executeJavascript (const std::string &javascript, const std::wstring &frameName=L"")
Awesomium::FutureJSValue executeJavascriptWithResult (const std::string &javascript, const std::wstring &frameName=L"")
void setProperty (const std::string &name, const JSValue &value)
void setCallback (const std::string &name)
bool isDirty ()
void render (unsigned char *destination, int destRowSpan, int destDepth, Awesomium::Rect *renderedRect=0)
void injectMouseMove (int x, int y)
void injectMouseDown (Awesomium::MouseButton button)
void injectMouseUp (Awesomium::MouseButton button)
void injectMouseWheel (int scrollAmount)
void cut ()
void copy ()
void paste ()
void selectAll ()
void deselectAll ()
void getContentAsText (std::wstring &result, int maxChars)
void zoomIn ()
void zoomOut ()
void resetZoom ()
void resize (int width, int height)
void unfocus ()
void focus ()
void setTransparent (bool isTransparent)

Protected Member Functions

 WebView (int width, int height, bool isTransparent, bool enableAsyncRendering, int maxAsyncRenderPerSec, base::Thread *coreThread)
void startup ()
void setDirty (bool val=true)
void setAsyncDirty (bool val=true)
void setFinishRender ()
void setFinishShutdown ()
void setFinishGetContentText ()
void setFinishResize ()
void resolveJSValueFuture (int requestID, Awesomium::JSValue *result)
void handleFutureJSValueCallback (const Awesomium::JSArguments &args)
void nullifyFutureJSValueCallbacks ()
void handleCheckKeyboardFocus (bool isFocused)

Protected Attributes

base::Thread * coreThread
WebViewProxy * viewProxy
WebViewWaitState * waitState
WebViewListenerlistener
LockImpl * dirtinessLock
bool dirtiness
bool isKeyboardFocused
LockImpl * jsValueFutureMapLock
std::map< int,
JSValueFutureImpl * > 
jsValueFutureMap
const bool enableAsyncRendering

Friends

class WebCore
class ::WebViewProxy
class ::FutureValueCallback
class ::CheckKeyboardFocusCallback


Detailed Description

A WebView is essentially a single instance of a web-browser (created via the WebCore singleton) that you can interact with (via input injection, javascript, etc.) and render to an off-screen buffer.

Member Function Documentation

void Awesomium::WebView::copy (  ) 

Invokes a 'copy' action using the system clipboard.

void Awesomium::WebView::cut (  ) 

Invokes a 'cut' action using the system clipboard.

void Awesomium::WebView::deselectAll (  ) 

De-selects all items on the current page.

void Awesomium::WebView::destroy (  ) 

Explicitly destroys this WebView instance. If you neglect to call this, the WebCore singleton will automatically destroy all lingering WebView instances at shutdown.

Note:
This should NEVER be called directly from one of the notifications of WebViewListener.

void Awesomium::WebView::executeJavascript ( const std::string &  javascript,
const std::wstring &  frameName = L"" 
)

Executes a string of Javascript in the context of the current page asynchronously.

Parameters:
javascript The string of Javascript to execute.
frameName Optional, the name of the frame to execute in; leave this blank to execute in the main frame.

Awesomium::FutureJSValue Awesomium::WebView::executeJavascriptWithResult ( const std::string &  javascript,
const std::wstring &  frameName = L"" 
)

Executes a string of Javascript in the context of the current page asynchronously with a result.

Parameters:
javascript The string of Javascript to execute.
frameName Optional, the name of the frame to execute in; leave this blank to execute in the main frame.
Returns:
Returns a 'FutureJSValue' which is basically an 'IOU' for the future JSValue result. You can obtain the actual result via FutureJSValue::get later.

void Awesomium::WebView::focus (  ) 

Notifies the current page that is has gained focus.

void Awesomium::WebView::getContentAsText ( std::wstring &  result,
int  maxChars 
)

Retrieves the content of the current page as plain text.

Parameters:
result The wide string to store the retrieved text in.
maxChars The maximum number of characters to retrieve.
Note:
Warning: The performance of this function depends upon the number of retrieved characters and the complexity of the page.

Awesomium::WebViewListener * Awesomium::WebView::getListener (  ) 

Retrieves the current WebViewListener.

Returns:
If a WebViewListener is registered, returns a pointer to the instance, otherwise returns 0.

void Awesomium::WebView::goToHistoryOffset ( int  offset  ) 

Navigates back/forward in history via a relative offset.

Note:
For example, to go back one page: myView->goToHistoryOffset(-1); Or, to go forward one page: myView->goToHistoryOffset(1);
Parameters:
offset The relative offset in history to navigate to.

void Awesomium::WebView::injectMouseDown ( Awesomium::MouseButton  button  ) 

Injects a mouse-down event.

Parameters:
button The button that was pressed.

void Awesomium::WebView::injectMouseMove ( int  x,
int  y 
)

Injects a mouse-move event in local coordinates.

Parameters:
x The absolute x-coordinate of the mouse (localized to the WebView).
y The absolute y-coordinate of the mouse (localized to the WebView).

void Awesomium::WebView::injectMouseUp ( Awesomium::MouseButton  button  ) 

Injects a mouse-up event.

Parameters:
button The button that was released.

void Awesomium::WebView::injectMouseWheel ( int  scrollAmount  ) 

Injects a mouse-wheel event.

Parameters:
scrollAmount The amount of pixels to scroll by.

bool Awesomium::WebView::isDirty (  ) 

Returns whether or not the current web-view is dirty and needs to be re-rendered.

Returns:
If the web-view is dirty, returns true, otherwise returns false.

void Awesomium::WebView::loadFile ( const std::string &  file,
const std::wstring &  frameName = L"" 
)

Loads a local file into the WebView asynchronously.

Parameters:
file The file to load.
frameName Optional, the name of the frame to load the file in; leave this blank to load in the main frame.
Note:
The file should exist within the base directory (specified via WebCore::setBaseDirectory).

void Awesomium::WebView::loadHTML ( const std::string &  html,
const std::wstring &  frameName = L"" 
)

Loads a string of HTML into the WebView asynchronously.

Parameters:
html The HTML string to load.
frameName Optional, the name of the frame to load the HTML in; leave this blank to load in the main frame.
Note:
The base directory (specified via WebCore::setBaseDirectory) will be used to resolve relative URL's/resources (such as images, links, etc).

void Awesomium::WebView::loadURL ( const std::string &  url,
const std::wstring &  frameName = L"",
const std::string &  username = "",
const std::string &  password = "" 
)

Loads a URL into the WebView asynchronously.

Parameters:
url The URL to load.
frameName Optional, the name of the frame to load the URL in; leave this blank to load in the main frame.
username Optional, if the URL requires authentication, the username to authorize as.
password Optional, if the URL requires authentication, the password to use.

void Awesomium::WebView::paste (  ) 

Invokes a 'paste' action using the system clipboard.

void Awesomium::WebView::render ( unsigned char *  destination,
int  destRowSpan,
int  destDepth,
Awesomium::Rect renderedRect = 0 
)

Renders the WebView to an off-screen buffer.

Parameters:
destination The buffer to render to, its width and height should match the WebView's.
destRowSpan The row-span of the destination buffer (number of bytes per row).
destDepth The depth (bytes per pixel) of the destination buffer. Valid options include 3 (BGR/RGB) or 4 (BGRA/RGBA).
renderedRect Optional (pass 0 to ignore); if asynchronous rendering is not enabled, you can provide a pointer to a Rect to store the dimensions of the rendered area, or rather, the dimensions of the area that actually changed since the last render.

void Awesomium::WebView::resetZoom (  ) 

Resets the zoom level.

void Awesomium::WebView::resize ( int  width,
int  height 
)

Resizes this WebView to certain dimensions.

Parameters:
width The width to resize to.
height The height to resize to.

void Awesomium::WebView::selectAll (  ) 

Selects all items on the current page.

void Awesomium::WebView::setCallback ( const std::string &  name  ) 

Registers a global 'Client' callback that can be invoked via Javascript from within all pages loaded into this view. You will need to register a WebViewListener (WebView::setListener) to receieve notification of callbacks (WebViewListener::onCallback).

Parameters:
name The name of the callback. You can invoke the callback in Javascript as: Client.your_name_here(arg1, arg2, ...);
Note:
In the future, it won't be necessary to register the callback name in advance.

void Awesomium::WebView::setListener ( Awesomium::WebViewListener listener  ) 

Registers a WebViewListener to call upon various events (such as load completions, callbacks, title receptions, cursor changes, etc).

Parameters:
listener The WebViewListener to register. Or, you can pass '0' to undo any current registrations.

void Awesomium::WebView::setProperty ( const std::string &  name,
const JSValue value 
)

Sets a global 'Client' property that can be accessed via Javascript from within all pages loaded into this web-view.

Parameters:
name The name of the property.
value The javascript-value of the property.
Note:
You can access all properties you set via the 'Client' object using Javascript. For example, if you set the property with a name of 'color' and a value of 'blue', you could access this from the page using Javascript: document.write("The color is " + Client.color);

void Awesomium::WebView::setTransparent ( bool  isTransparent  ) 

Sets whether or not pages should be rendered with a transparent background-color.

Parameters:
isTransparent Whether or not to force the background-color as transparent.

void Awesomium::WebView::unfocus (  ) 

Notifies the current page that it has lost focus.

void Awesomium::WebView::zoomIn (  ) 

Zooms into the page, enlarging by 20%.

void Awesomium::WebView::zoomOut (  ) 

Zooms out of the page, reducing by 20%.


The documentation for this class was generated from the following files:

Generated on Sun May 17 16:44:15 2009 for Awesomium by  doxygen 1.5.8