include/berkelium/Window.hpp
Go to the documentation of this file.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_HPP_
00034 #define _BERKELIUM_WINDOW_HPP_
00035
00036 #include <vector>
00037
00038 #include "berkelium/WeakString.hpp"
00039
00040 namespace Berkelium {
00041
00042 class Widget;
00043 class WindowDelegate;
00044 class Context;
00045
00046 namespace Script{
00047 class Variant;
00048 }
00049
00050 enum KeyModifier {
00051 SHIFT_MOD = 1 << 0,
00052 CONTROL_MOD = 1 << 1,
00053 ALT_MOD = 1 << 2,
00054 META_MOD = 1 << 3,
00055 KEYPAD_KEY = 1 << 4,
00056 AUTOREPEAT_KEY = 1 << 5,
00057 SYSTEM_KEY = 1 << 6
00058 };
00059
00068 class BERKELIUM_EXPORT Window {
00069 protected:
00070 typedef std::vector<Widget*> WidgetList;
00071
00072 public:
00073 typedef WidgetList::const_iterator BackToFrontIter;
00074 typedef WidgetList::const_reverse_iterator FrontToBackIter;
00075
00076 protected:
00080 Window ();
00084 Window (const Context*otherContext);
00085
00086 public:
00093 static Window* create (const Context * context);
00094
00097 void destroy();
00098
00102 virtual ~Window();
00103
00108 virtual Widget* getWidget() const=0;
00109
00111 inline Context *getContext() const {
00112 return mContext;
00113 }
00114
00120 void setDelegate(WindowDelegate *delegate) {
00121 mDelegate = delegate;
00122 }
00123
00127 BackToFrontIter backIter() const {
00128 return mWidgets.begin();
00129 }
00130
00132 BackToFrontIter backEnd() const {
00133 return mWidgets.end();
00134 }
00135
00139 FrontToBackIter frontIter() const {
00140 return mWidgets.rbegin();
00141 }
00142
00144 FrontToBackIter frontEnd() const {
00145 return mWidgets.rend();
00146 }
00147
00156 Widget *getWidgetAtPoint(int xPos, int yPos, bool returnRootIfOutside=false) const;
00157
00161 virtual int getId() const = 0;
00162
00169 virtual void setTransparent(bool istrans)=0;
00170
00173 virtual void focus()=0;
00174
00177 virtual void unfocus()=0;
00178
00183 virtual void mouseMoved(int xPos, int yPos)=0;
00191 virtual void mouseButton(unsigned int buttonID, bool down, int clickCount=1)=0;
00196 virtual void mouseWheel(int xScroll, int yScroll)=0;
00197
00202 virtual void textEvent(const wchar_t *evt, size_t evtLength)=0;
00203
00211 virtual void keyEvent(bool pressed, int mods, int vk_code, int scancode)=0;
00212
00213
00219 virtual void resize(int width, int height)=0;
00220
00225 virtual void adjustZoom (int mode)=0;
00226
00232 virtual void executeJavascript (WideString javascript) = 0;
00233
00241 virtual void insertCSS (WideString css, WideString elementId) = 0;
00242
00247 virtual bool navigateTo(URLString url)=0;
00248
00256 inline bool navigateTo(const char *url, size_t url_length) {
00257 return navigateTo(URLString::point_to(url,url_length));
00258 }
00259
00261 virtual void refresh() = 0;
00262
00264 virtual void stop() = 0;
00265
00267 virtual void goBack() = 0;
00268
00270 virtual void goForward() = 0;
00271
00273 virtual bool canGoBack() const = 0;
00274
00276 virtual bool canGoForward() const = 0;
00277
00279 virtual void cut()=0;
00280
00282 virtual void copy()=0;
00283
00287 virtual void paste()=0;
00288
00290 virtual void undo()=0;
00291
00293 virtual void redo()=0;
00294
00296 virtual void del()=0;
00297
00299 virtual void selectAll()=0;
00300
00304 virtual void filesSelected(FileString *files)=0;
00305
00313 virtual void synchronousScriptReturn(void *handle, const Script::Variant &result)=0;
00314
00316 virtual void bind(WideString lvalue, const Script::Variant &rvalue)=0;
00317
00319 virtual void addBindOnStartLoading(WideString lvalue, const Script::Variant &rvalue)=0;
00320
00322 virtual void addEvalOnStartLoading(WideString script)=0;
00323
00325 virtual void clearStartLoading()=0;
00326
00327 protected:
00328 void appendWidget(Widget *wid) {
00329 mWidgets.push_back(wid);
00330 }
00331 void removeWidget(Widget *wid) {
00332 for (WidgetList::iterator it = mWidgets.begin();
00333 it != backEnd();
00334 ++it)
00335 {
00336 if (*it == wid) {
00337 mWidgets.erase(it);
00338 return;
00339 }
00340 }
00341 }
00342
00343 protected:
00344 Context *mContext;
00345 WindowDelegate *mDelegate;
00346
00347 WidgetList mWidgets;
00348 };
00349
00350 }
00351
00352 #endif