#ifndef _KJS_WINDOW_H_
#define _KJS_WINDOW_H_
#include <qobject.h>
#include <qguardedptr.h>
#include <qmap.h>
#include <qptrlist.h>
#include "kjs_binding.h"
class QTimer;
class KHTMLView;
class KHTMLPart;
namespace KJS {
class WindowFunc;
class WindowQObject;
class Location;
class History;
class FrameArray;
class JSEventListener;
class Screen : public ObjectImp {
public:
Screen(ExecState *exec);
enum {
Height, Width, ColorDepth, PixelDepth, AvailLeft, AvailTop, AvailHeight,
AvailWidth
};
virtual Value get(ExecState *exec, const Identifier &propertyName) const;
Value getValueProperty(ExecState *exec, int token) const;
private:
KHTMLView *view;
virtual const ClassInfo* classInfo() const { return &info; }
static const ClassInfo info;
};
class Window : public ObjectImp {
friend QGuardedPtr<KHTMLPart> getInstance();
friend class Location;
friend class WindowFunc;
friend class WindowQObject;
friend class ScheduledAction;
public:
Window(KHTMLPart *p);
public:
~Window();
static Value retrieve(KHTMLPart *p);
static Window *retrieveWindow(KHTMLPart *p);
static Window *retrieveActive(ExecState *exec);
QGuardedPtr<KHTMLPart> part() const { return m_part; }
virtual void mark();
virtual bool hasProperty(ExecState *exec, const Identifier &p) const;
virtual Value get(ExecState *exec, const Identifier &propertyName) const;
virtual void put(ExecState *exec, const Identifier &propertyName, const Value &value, int attr = None);
virtual bool toBoolean(ExecState *exec) const;
int installTimeout(const UString &handler, int t, bool singleShot);
void clearTimeout(int timerId);
#ifdef APPLE_CHANGES
bool hasTimeouts();
QMap<int, ScheduledAction*> *pauseTimeouts(const void *key);
void resumeTimeouts(QMap<int, ScheduledAction*>*sa, const void *key);
#endif
void scheduleClose();
bool isSafeScript(ExecState *exec) const;
Location *location() const;
JSEventListener *getJSEventListener(const Value &val, bool html = false);
void clear( ExecState *exec );
virtual UString toString(ExecState *exec) const;
void setCurrentEvent( DOM::Event *evt );
QPtrList<JSEventListener> jsEventListeners;
virtual const ClassInfo* classInfo() const { return &info; }
static const ClassInfo info;
enum { Closed, Crypto, DefaultStatus, Status, Document, Node, EventCtor, Range,
NodeFilter, DOMException, CSSRule, Frames, _History, Event, InnerHeight,
InnerWidth, Length, _Location, Name, _Navigator, _Konqueror, ClientInformation,
OffscreenBuffering, Opener, OuterHeight, OuterWidth, PageXOffset, PageYOffset,
Parent, Personalbar, ScreenX, ScreenY, Scrollbars, Scroll, ScrollBy,
ScreenTop, ScreenLeft,
ScrollTo, ScrollX, ScrollY, MoveBy, MoveTo, ResizeBy, ResizeTo, Self, _Window, Top, _Screen,
Image, Option, Alert, Confirm, Prompt, Open, SetTimeout, ClearTimeout,
Focus, GetSelection, Blur, Close, SetInterval, ClearInterval, CaptureEvents,
ReleaseEvents, AddEventListener, RemoveEventListener, Onabort, Onblur,
Onchange, Onclick, Ondblclick, Ondragdrop, Onerror, Onfocus,
Onkeydown, Onkeypress, Onkeyup, Onload, Onmousedown, Onmousemove,
Onmouseout, Onmouseover, Onmouseup, Onmove, Onreset, Onresize,
Onselect, Onsubmit, Onunload };
protected:
Value getListener(ExecState *exec, int eventId) const;
void setListener(ExecState *exec, int eventId, Value func);
private:
void updateLayout() const;
QGuardedPtr<KHTMLPart> m_part;
Screen *screen;
History *history;
FrameArray *frames;
Location *loc;
WindowQObject *winq;
DOM::Event *m_evt;
};
class ScheduledAction {
public:
ScheduledAction(Object _func, List _args, bool _singleShot);
ScheduledAction(const QString &_code, bool _singleShot);
~ScheduledAction();
void execute(Window *window);
Object func;
List args;
QString code;
bool isFunction;
bool singleShot;
};
class WindowQObject : public QObject {
Q_OBJECT
public:
WindowQObject(Window *w);
~WindowQObject();
int installTimeout(const UString &handler, int t, bool singleShot);
int installTimeout(const Value &func, List args, int t, bool singleShot);
void clearTimeout(int timerId, bool delAction = true);
#ifdef APPLE_CHANGES
bool hasTimeouts();
QMap<int, ScheduledAction*> *WindowQObject::pauseTimeouts(const void *key);
void WindowQObject::resumeTimeouts(QMap<int, ScheduledAction*> *sa, const void *key);
#endif
public slots:
void timeoutClose();
protected slots:
void parentDestroyed();
protected:
void timerEvent(QTimerEvent *e);
private:
Window *parent;
KHTMLPart *part; QMap<int, ScheduledAction*> scheduledActions;
};
class Location : public ObjectImp {
public:
~Location();
virtual Value get(ExecState *exec, const Identifier &propertyName) const;
virtual void put(ExecState *exec, const Identifier &propertyName, const Value &value, int attr = None);
virtual Value toPrimitive(ExecState *exec, Type preferred) const;
virtual UString toString(ExecState *exec) const;
enum { Hash, Href, Hostname, Host, Pathname, Port, Protocol, Search, EqualEqual,
Replace, Reload, ToString };
KHTMLPart *part() const { return m_part; }
virtual const ClassInfo* classInfo() const { return &info; }
static const ClassInfo info;
private:
friend class Window;
Location(KHTMLPart *p);
QGuardedPtr<KHTMLPart> m_part;
};
#ifdef Q_WS_QWS
class Konqueror : public ObjectImp {
friend class KonquerorFunc;
public:
Konqueror(KHTMLPart *p) : part(p) { }
virtual Value get(ExecState *exec, const Identifier &propertyName) const;
virtual bool hasProperty(ExecState *exec, const Identifier &p) const;
virtual UString toString(ExecState *exec) const;
virtual const ClassInfo* classInfo() const { return &info; }
static const ClassInfo info;
private:
KHTMLPart *part;
};
#endif
};
#endif