Berkelium

include/berkelium/WindowDelegate.hpp

Go to the documentation of this file.
00001 /*  Berkelium - Embedded Chromium
00002  *  WindowDelegate.hpp
00003  *
00004  *  Copyright (c) 2009, Patrick Reiter Horn
00005  *  All rights reserved.
00006  *
00007  *  Redistribution and use in source and binary forms, with or without
00008  *  modification, are permitted provided that the following conditions are
00009  *  met:
00010  *  * Redistributions of source code must retain the above copyright
00011  *    notice, this list of conditions and the following disclaimer.
00012  *  * Redistributions in binary form must reproduce the above copyright
00013  *    notice, this list of conditions and the following disclaimer in
00014  *    the documentation and/or other materials provided with the
00015  *    distribution.
00016  *  * Neither the name of Sirikata nor the names of its contributors may
00017  *    be used to endorse or promote products derived from this software
00018  *    without specific prior written permission.
00019  *
00020  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
00021  * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
00022  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
00023  * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
00024  * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00025  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00026  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00027  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
00028  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
00029  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00030  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
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         // Override to permit popup windows only if you support onCreatedWindow.
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    Might want messages for:
00453 - StartDragging(const WebDropData& drop_data,
00454                 WebKit::WebDragOperationsMask allowed_ops);
00455 - UpdateDragCursor(WebKit::WebDragOperation operation);
00456 - TakeFocus(bool reverse)
00457 - Close
00458 - UpdateTargetURL
00459 - UpdateEncoding
00460 **************************/
00461 
00462 };
00463 
00464 }
00465 
00466 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Documentation generated on 22 Nov 2013