00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033 #ifndef _BERKELIUM_WINDOW_DELEGATE_HPP_
00034 #define _BERKELIUM_WINDOW_DELEGATE_HPP_
00035
00036 #include "berkelium/WeakString.hpp"
00037 #include "berkelium/Rect.hpp"
00038 #include "berkelium/ScriptVariant.hpp"
00039 #include "berkelium/Window.hpp"
00040
00041 namespace Berkelium {
00042
00043 class WindowImpl;
00044 class Widget;
00045 class Window;
00046 class Cursor;
00047
00051 struct ContextMenuEventArgs {
00052 enum MediaType {
00053 MediaTypeNone,
00054 MediaTypeImage,
00055 MediaTypeVideo,
00056 MediaTypeAudio,
00057 };
00058 enum EditFlags {
00059 CanDoNone = 0x0,
00060 CanUndo = 0x1,
00061 CanRedo = 0x2,
00062 CanCut = 0x4,
00063 CanCopy = 0x8,
00064 CanPaste = 0x10,
00065 CanDelete = 0x20,
00066 CanSelectAll = 0x40,
00067 };
00068
00069 MediaType mediaType;
00070
00071 int mouseX, mouseY;
00072
00073 URLString linkUrl, srcUrl, pageUrl, frameUrl;
00074 WideString selectedText;
00075
00076 bool isEditable;
00077
00078 int editFlags;
00079 };
00080
00081 enum ScriptAlertType {
00082 JavascriptAlert = 0,
00083 JavascriptConfirm = 1,
00084 JavascriptPrompt = 2
00085 };
00086
00087 enum FileChooserType {
00088 FileOpen = 0,
00089 FileOpenMultiple = 1,
00090 FileOpenFolder = 2,
00091 FileSaveAs = 3
00092 };
00093
00097 class BERKELIUM_EXPORT WindowDelegate {
00098 public:
00103 virtual ~WindowDelegate() {}
00104
00113 virtual void onAddressBarChanged(Window *win, URLString newURL) {}
00121 virtual void onStartLoading(Window *win, URLString newURL) {}
00127 virtual void onLoad(Window *win) {}
00133 virtual void onCrashedWorker(Window *win) {}
00141 virtual void onCrashedPlugin(Window *win, WideString pluginName) {}
00151 virtual void onProvisionalLoadError(Window *win, URLString url,
00152 int errorCode, bool isMainFrame) {}
00161 virtual void onConsoleMessage(Window *win, WideString message,
00162 WideString sourceId, int line_no) {}
00175 virtual void onScriptAlert(Window *win, WideString message,
00176 WideString defaultValue, URLString url,
00177 int flags, bool &success, WideString &value) {}
00186 virtual void freeLastScriptAlert(WideString lastValue) {}
00199 virtual void onNavigationRequested(Window *win, URLString newUrl,
00200 URLString referrer, bool isNewWindow,
00201 bool &cancelDefaultAction) {
00202
00203 if (isNewWindow) cancelDefaultAction = true;
00204 }
00215 virtual void onLoadingStateChanged(Window *win, bool isLoading) {}
00224 virtual void onTitleChanged(Window *win, WideString title) {}
00232 virtual void onTooltipChanged(Window *win, WideString text) {}
00233
00240 virtual void onCrashed(Window *win) {}
00247 virtual void onUnresponsive(Window *win) {}
00253 virtual void onResponsive(Window *win) {}
00254
00267 virtual void onExternalHost(
00268 Window *win,
00269 WideString message,
00270 URLString origin,
00271 URLString target) {}
00272
00284 virtual void onCreatedWindow(Window *win, Window *newWindow,
00285 const Rect &initialRect) {}
00286
00305 virtual void onPaint(
00306 Window *win,
00307 const unsigned char *sourceBuffer,
00308 const Rect &sourceBufferRect,
00309 size_t numCopyRects,
00310 const Rect *copyRects,
00311 int dx, int dy,
00312 const Rect &scrollRect) {}
00313
00322 virtual void onWidgetCreated(Window *win, Widget *newWidget, int zIndex) {}
00330 virtual void onWidgetDestroyed(Window *win, Widget *wid) {}
00331
00340 virtual void onWidgetResize(
00341 Window *win,
00342 Widget *wid,
00343 int newWidth,
00344 int newHeight) {}
00345
00356 virtual void onWidgetMove(
00357 Window *win,
00358 Widget *wid,
00359 int newX,
00360 int newY) {}
00361
00376 virtual void onWidgetPaint(
00377 Window *win,
00378 Widget *wid,
00379 const unsigned char *sourceBuffer,
00380 const Rect &sourceBufferRect,
00381 size_t numCopyRects,
00382 const Rect *copyRects,
00383 int dx, int dy,
00384 const Rect &scrollRect) {}
00385
00393 virtual void onCursorUpdated(Window *win, const Cursor& newCursor) {}
00394
00402 virtual void onShowContextMenu(Window *win,
00403 const ContextMenuEventArgs& args) {}
00404
00415 virtual void onJavascriptCallback(Window *win, void* replyMsg, URLString origin, WideString funcName, Script::Variant *args, size_t numArgs) {
00416 if (replyMsg) {
00417 win->synchronousScriptReturn(replyMsg, Script::Variant());
00418 }
00419 }
00420
00427 virtual void onRunFileChooser(Window *win, int mode, WideString title, FileString defaultFile) {
00428 win->filesSelected(NULL);
00429 }
00430
00443 virtual void onResizeRequested(
00444 Window *win,
00445 int x,
00446 int y,
00447 int newWidth,
00448 int newHeight) {
00449 }
00450
00451
00452
00453
00454
00455
00456
00457
00458
00459
00460
00461
00462 };
00463
00464 }
00465
00466 #endif