Override WindowDelegate methods to intercept events from a render view. More...
#include <WindowDelegate.hpp>
Public Member Functions | |
virtual | ~WindowDelegate () |
Virtual destructor is not necessary--Berkelium will not delete a WindowDelegate. | |
virtual void | onAddressBarChanged (Window *win, URLString newURL) |
The URL associated with this page has changed. | |
virtual void | onStartLoading (Window *win, URLString newURL) |
Indicates whether the main page has started navigating to a new URL. | |
virtual void | onLoad (Window *win) |
A page has loaded without error. | |
virtual void | onCrashedWorker (Window *win) |
A worker has crashed. | |
virtual void | onCrashedPlugin (Window *win, WideString pluginName) |
Plugin with a given name has crashed. | |
virtual void | onProvisionalLoadError (Window *win, URLString url, int errorCode, bool isMainFrame) |
Encountered an error while loading a page, and might not finish loading. | |
virtual void | onConsoleMessage (Window *win, WideString message, WideString sourceId, int line_no) |
Display a javascript message (Maybe an error?) or console.log. | |
virtual void | onScriptAlert (Window *win, WideString message, WideString defaultValue, URLString url, int flags, bool &success, WideString &value) |
Synchronously display an alert box (OK), confirm (OK, CANCEL), or a prompt (Input). | |
virtual void | freeLastScriptAlert (WideString lastValue) |
Frees resources from the most recent onScriptAlert call, if necessary. | |
virtual void | onNavigationRequested (Window *win, URLString newUrl, URLString referrer, bool isNewWindow, bool &cancelDefaultAction) |
A navigation has been requested but not yet started. | |
virtual void | onLoadingStateChanged (Window *win, bool isLoading) |
Notifies if a page is loading. | |
virtual void | onTitleChanged (Window *win, WideString title) |
Window's title has changed. | |
virtual void | onTooltipChanged (Window *win, WideString text) |
Display a tooltip at the mouse cursor position. | |
virtual void | onCrashed (Window *win) |
A renderer instance crashed. | |
virtual void | onUnresponsive (Window *win) |
A renderer instance is hung. | |
virtual void | onResponsive (Window *win) |
Renderer instance is back to normal. | |
virtual void | onExternalHost (Window *win, WideString message, URLString origin, URLString target) |
Javascript has sent an externalHost message to this WindowDelegate. | |
virtual void | onCreatedWindow (Window *win, Window *newWindow, const Rect &initialRect) |
A new window has already been created. | |
virtual void | onPaint (Window *win, const unsigned char *sourceBuffer, const Rect &sourceBufferRect, size_t numCopyRects, const Rect *copyRects, int dx, int dy, const Rect &scrollRect) |
The window is being painted. | |
virtual void | onWidgetCreated (Window *win, Widget *newWidget, int zIndex) |
A widget is a rectangle to display on top of the page, e.g. | |
virtual void | onWidgetDestroyed (Window *win, Widget *wid) |
Called by Widget::destroy(), in its destructor. | |
virtual void | onWidgetResize (Window *win, Widget *wid, int newWidth, int newHeight) |
Widget has changed size, Usually only happens once after creating. | |
virtual void | onWidgetMove (Window *win, Widget *wid, int newX, int newY) |
Widget has moved, Usually only happens once after creating. | |
virtual void | onWidgetPaint (Window *win, Widget *wid, const unsigned char *sourceBuffer, const Rect &sourceBufferRect, size_t numCopyRects, const Rect *copyRects, int dx, int dy, const Rect &scrollRect) |
A widget overlay has been painted. | |
virtual void | onCursorUpdated (Window *win, const Cursor &newCursor) |
Invoked when the Window requests that the mouse cursor be updated. | |
virtual void | onShowContextMenu (Window *win, const ContextMenuEventArgs &args) |
Notification that the user has brought up a context menu. | |
virtual void | onJavascriptCallback (Window *win, void *replyMsg, URLString origin, WideString funcName, Script::Variant *args, size_t numArgs) |
Javascript has called a bound function on this Window. | |
virtual void | onRunFileChooser (Window *win, int mode, WideString title, FileString defaultFile) |
Display a file chooser dialog, if necessary. | |
virtual void | onResizeRequested (Window *win, int x, int y, int newWidth, int newHeight) |
Resize of this Window was requested. |
Override WindowDelegate methods to intercept events from a render view.
virtual Berkelium::WindowDelegate::~WindowDelegate | ( | ) | [inline, virtual] |
Virtual destructor is not necessary--Berkelium will not delete a WindowDelegate.
virtual void Berkelium::WindowDelegate::freeLastScriptAlert | ( | WideString | lastValue | ) | [inline, virtual] |
Frees resources from the most recent onScriptAlert call, if necessary.
Guaranteed to be called within the span of the same update() call, so the WindowDelegate can safely use a variable to hold the string instance while waiting to free it.
lastValue | A value to pass to the appropriate free method. |
virtual void Berkelium::WindowDelegate::onAddressBarChanged | ( | Window * | win, | |
URLString | newURL | |||
) | [inline, virtual] |
The URL associated with this page has changed.
This is similar to onStartLoading, but may also be called if the hash part of the url changes.
win | Window instance that fired this event. | |
newURL | URL to display or store. |
virtual void Berkelium::WindowDelegate::onConsoleMessage | ( | Window * | win, | |
WideString | message, | |||
WideString | sourceId, | |||
int | line_no | |||
) | [inline, virtual] |
Display a javascript message (Maybe an error?) or console.log.
win | Window instance that fired this event. | |
message | String contents of the log message. | |
sourceId | Javascript file or other source sending the message. | |
line_no | Line number, useful for debugging. |
virtual void Berkelium::WindowDelegate::onCrashed | ( | Window * | win | ) | [inline, virtual] |
virtual void Berkelium::WindowDelegate::onCrashedPlugin | ( | Window * | win, | |
WideString | pluginName | |||
) | [inline, virtual] |
Plugin with a given name has crashed.
There's currently no way to restart it, aside from maybe reloading the page that uses it.
win | Window instance that fired this event. | |
pluginName | Name reported by the plugin.. |
virtual void Berkelium::WindowDelegate::onCrashedWorker | ( | Window * | win | ) | [inline, virtual] |
A worker has crashed.
No info is provided yet to the callback.
win | Window instance that fired this event. |
virtual void Berkelium::WindowDelegate::onCreatedWindow | ( | Window * | win, | |
Window * | newWindow, | |||
const Rect & | initialRect | |||
) | [inline, virtual] |
A new window has already been created.
You are now expected to hold onto the instance and be responsible for deleting it.
win | Window instance that fired this event. | |
newWindow | New Berkelium window object to keep track of. You may optionally destroy the window if you don't want it. | |
initialRect | Coordinates and size that the window is requesting. Use them as a recommendataion, but it's fine to call resize(), and x/y coords should be ignored if doing off-screen rendering. |
virtual void Berkelium::WindowDelegate::onCursorUpdated | ( | Window * | win, | |
const Cursor & | newCursor | |||
) | [inline, virtual] |
Invoked when the Window requests that the mouse cursor be updated.
win | Window instance that fired this event. | |
newCursor | Platform-specific cursor handle to pass to the appropriate system API. |
virtual void Berkelium::WindowDelegate::onExternalHost | ( | Window * | win, | |
WideString | message, | |||
URLString | origin, | |||
URLString | target | |||
) | [inline, virtual] |
Javascript has sent an externalHost message to this WindowDelegate.
To send a message from javascript call, for example: window.externalHost.postMessage("message", "urn:uuid:0000-...")
win | Window instance that fired this event. | |
message | Full contents of message sent by javascript. | |
origin | Origin header of page sending the request. Use this if you want to restrict messages to trusted pages. | |
target | A URI Specified by the page. Can be in a custum or urn format if that is useful. |
virtual void Berkelium::WindowDelegate::onJavascriptCallback | ( | Window * | win, | |
void * | replyMsg, | |||
URLString | origin, | |||
WideString | funcName, | |||
Script::Variant * | args, | |||
size_t | numArgs | |||
) | [inline, virtual] |
Javascript has called a bound function on this Window.
Make sure to h
win | Window instance that fired this event. | |
replyMsg | If non-NULL, opaque reply identifier to be passed to synchronousScriptReturn. | |
url | Origin of the sending script. | |
funcName | name of function to call. | |
args | list of variants passed into function. | |
numArgs | number of arguments. |
virtual void Berkelium::WindowDelegate::onLoad | ( | Window * | win | ) | [inline, virtual] |
A page has loaded without error.
win | Window instance that fired this event. |
virtual void Berkelium::WindowDelegate::onLoadingStateChanged | ( | Window * | win, | |
bool | isLoading | |||
) | [inline, virtual] |
Notifies if a page is loading.
This callback is only useful for deciding whether to show a loading indicator, for example a spinning widget or maybe a capital letter being bombarded by meteors.
win | Window instance that fired this event. | |
isLoading | true if loading has started, false if stopped. |
virtual void Berkelium::WindowDelegate::onNavigationRequested | ( | Window * | win, | |
URLString | newUrl, | |||
URLString | referrer, | |||
bool | isNewWindow, | |||
bool & | cancelDefaultAction | |||
) | [inline, virtual] |
A navigation has been requested but not yet started.
I'm not sure yet if this gets called for frames.
win | Window instance that fired this event. | |
newUrl | URL which wants to load. | |
referrer | Page which initiated the request. | |
isNewWindow | The request will result in a popup if not cancelled. If true and not cancelled, expect a onCreatedWindow callback soon. | |
cancelDefaultAction | Put true into this value to cancel. For example, if you don't want a new window, call win->navigate. |
virtual void Berkelium::WindowDelegate::onPaint | ( | Window * | win, | |
const unsigned char * | sourceBuffer, | |||
const Rect & | sourceBufferRect, | |||
size_t | numCopyRects, | |||
const Rect * | copyRects, | |||
int | dx, | |||
int | dy, | |||
const Rect & | scrollRect | |||
) | [inline, virtual] |
The window is being painted.
You need to synchronously copy the buffer into application (video) memory before returning.
win | Window instance that fired this event. | |
sourceBuffer | ARGB buffer with width/height of sourceBufferRect. | |
sourceBufferRect | Rect containing the buffer. | |
numCopyRects | Length of copyRects. | |
copyRects | Array of valid+changed rectangles of sourceBuffer. Anything not in copyRects is usually garbage data. While these must lie within sourceBufferRect to make sense, they are not relative to sourceBufferRect. | |
dx | If non-zero, the area of the page specified by scrollRect has been scrolled horizontally. | |
dy | If non-zero, the area of the page specified by scrollRect has been scrolled vertically. | |
scrollRect | Area of the page to scroll. Only valid if dx&&dy. |
virtual void Berkelium::WindowDelegate::onProvisionalLoadError | ( | Window * | win, | |
URLString | url, | |||
int | errorCode, | |||
bool | isMainFrame | |||
) | [inline, virtual] |
Encountered an error while loading a page, and might not finish loading.
win | Window instance that fired this event. | |
url | URL that encountered the error. | |
errorCode | Some enumeration? errno? net error code? | |
isMainFrame | True if the error happened for the main page, If false, it may have happened in an iframe (or XHR?). |
virtual void Berkelium::WindowDelegate::onResizeRequested | ( | Window * | win, | |
int | x, | |||
int | y, | |||
int | newWidth, | |||
int | newHeight | |||
) | [inline, virtual] |
virtual void Berkelium::WindowDelegate::onResponsive | ( | Window * | win | ) | [inline, virtual] |
Renderer instance is back to normal.
Reset the color and close dialogs.
win | Window instance that fired this event. |
virtual void Berkelium::WindowDelegate::onRunFileChooser | ( | Window * | win, | |
int | mode, | |||
WideString | title, | |||
FileString | defaultFile | |||
) | [inline, virtual] |
Display a file chooser dialog, if necessary.
The value to be returned should go ______.
win | Window instance that fired this event. | |
mode | Type of file chooser expected. See FileChooserType. | |
title | Title for dialog. "Open" or "Save" should be used if empty. | |
defaultFile | Default file to select in dialog. |
virtual void Berkelium::WindowDelegate::onScriptAlert | ( | Window * | win, | |
WideString | message, | |||
WideString | defaultValue, | |||
URLString | url, | |||
int | flags, | |||
bool & | success, | |||
WideString & | value | |||
) | [inline, virtual] |
Synchronously display an alert box (OK), confirm (OK, CANCEL), or a prompt (Input).
If prompt, optionally return a string in value.
win | Window instance that fired this event. | |
message | Alert message | |
defaultValue | What to display in a text field if this is prompt. | |
url | Originator (script? or page?) of the alert box. | |
flags | What type of alert/confirm/prompt. See ScriptAlertType. | |
success | True if the OK button, false if CANCEL. | |
value | Allocated (strdup is easiest) return, default empty/null. |
virtual void Berkelium::WindowDelegate::onShowContextMenu | ( | Window * | win, | |
const ContextMenuEventArgs & | args | |||
) | [inline, virtual] |
Notification that the user has brought up a context menu.
Chrome doesn't specify the exact set of context menu items--implementors are free to choose other menu items to display.
win | Window instance that fired this event. | |
args | Guidelines on what menu items to include or not include. |
virtual void Berkelium::WindowDelegate::onStartLoading | ( | Window * | win, | |
URLString | newURL | |||
) | [inline, virtual] |
Indicates whether the main page has started navigating to a new URL.
win | Window instance that fired this event. | |
newURL | URL of the currently-loading page for the main frame. |
virtual void Berkelium::WindowDelegate::onTitleChanged | ( | Window * | win, | |
WideString | title | |||
) | [inline, virtual] |
Window's title has changed.
This is usually the contents of title, however some pages may dynamically change document.title. Additionally, may be a default title (e.g. a URL) if the page has none.
win | Window instance that fired this event. | |
title | Page title, should be the same as document.title. |
virtual void Berkelium::WindowDelegate::onTooltipChanged | ( | Window * | win, | |
WideString | text | |||
) | [inline, virtual] |
Display a tooltip at the mouse cursor position.
There's no notification for destroying the tooltip afaik
win | Window instance that fired this event. | |
text | Text on the tooltip. |
virtual void Berkelium::WindowDelegate::onUnresponsive | ( | Window * | win | ) | [inline, virtual] |
virtual void Berkelium::WindowDelegate::onWidgetDestroyed | ( | Window * | win, | |
Widget * | wid | |||
) | [inline, virtual] |
Called by Widget::destroy(), in its destructor.
This widget will be removed from the Window's list of widgets when this function returns.
virtual void Berkelium::WindowDelegate::onWidgetMove | ( | Window * | win, | |
Widget * | wid, | |||
int | newX, | |||
int | newY | |||
) | [inline, virtual] |
Widget has moved, Usually only happens once after creating.
While these coordinates may be ignored, the position usually corresponds to some click event or the mouse coordinates.
virtual void Berkelium::WindowDelegate::onWidgetPaint | ( | Window * | win, | |
Widget * | wid, | |||
const unsigned char * | sourceBuffer, | |||
const Rect & | sourceBufferRect, | |||
size_t | numCopyRects, | |||
const Rect * | copyRects, | |||
int | dx, | |||
int | dy, | |||
const Rect & | scrollRect | |||
) | [inline, virtual] |
A widget overlay has been painted.
win | Window instance that fired this event. | |
wid | Widget this event is for | |
sourceBuffer | raw buffer. | |
sourceBufferRect | Rect containing the buffer. | |
numCopyRects | Length of copyRects. | |
copyRects | Array of valid+changed rectangles of sourceBuffer. | |
dx | delta-x scroll | |
dy | delta-y scroll | |
scrollRect | Area of the page to scroll. Only valid if dx&&dy. |