# khtml Library API Documentation

Overview | Class Hierarchy | Classes | Classes (annotated) | Members | Source Files

# kjs_window.h

    00001 // -*- c-basic-offset: 2 -*-
    00002 /*
    00003  *  This file is part of the KDE libraries
    00004  *  Copyright (C) 2000 Harri Porten (porten@kde.org)
    00005  *
    00006  *  This library is free software; you can redistribute it and/or
    00007  *  modify it under the terms of the GNU Library General Public
    00008  *  License as published by the Free Software Foundation; either
    00009  *  version 2 of the License, or (at your option) any later version.
    00010  *
    00011  *  This library is distributed in the hope that it will be useful,
    00012  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
    00013  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    00014  *  Library General Public License for more details.
    00015  *
    00016  *  You should have received a copy of the GNU Library General Public
    00017  *  License along with this library; if not, write to the Free Software
    00018  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    00019  */
    00020
    00021 #ifndef _KJS_WINDOW_H_
    00022 #define _KJS_WINDOW_H_
    00023
    00024 #include <qobject.h>
    00025 #include <qguardedptr.h>
    00026 #include <qmap.h>
    00027 #include <qptrlist.h>
    00028
    00029 #include "kjs_binding.h"
    00030
    00031 class QTimer;
    00032 class KHTMLView;
    00033 class KHTMLPart;
    00034
    00035 namespace KJS {
    00036
    00037   class WindowFunc;
    00038   class WindowQObject;
    00039   class Location;
    00040   class History;
    00041   class FrameArray;
    00042   class JSEventListener;
    00043
    00044   class Screen : public ObjectImp {
    00045   public:
    00046     Screen(ExecState *exec);
    00047     enum {
    00048       Height, Width, ColorDepth, PixelDepth, AvailLeft, AvailTop, AvailHeight,
    00049       AvailWidth
    00050     };
    00051     virtual Value get(ExecState *exec, const UString &propertyName) const;
    00052     Value getValueProperty(ExecState *exec, int token) const;
    00053   private:
    00054     KHTMLView *view;
    00055     virtual const ClassInfo* classInfo() const { return &info; }
    00056     static const ClassInfo info;
    00057   };
    00058
    00059   class Window : public ObjectImp {
    00060     friend QGuardedPtr<KHTMLPart> getInstance();
    00061     friend class Location;
    00062     friend class WindowFunc;
    00063     friend class WindowQObject;
    00064     friend class ScheduledAction;
    00065   public:
    00066     Window(KHTMLPart *p);
    00067   public:
    00068     ~Window();
    00074     static Value retrieve(KHTMLPart *p);
    00078     static Window *retrieveWindow(KHTMLPart *p);
    00083     static Window *retrieveActive(ExecState *exec);
    00084     QGuardedPtr<KHTMLPart> part() const { return m_part; }
    00085     virtual void mark();
    00086     virtual bool hasProperty(ExecState *exec, const UString &p) const;
    00087     virtual Value get(ExecState *exec, const UString &propertyName) const;
    00088     virtual void put(ExecState *exec, const UString &propertyName, const Value &value, int attr = None);
    00089     virtual bool toBoolean(ExecState *exec) const;
    00090     int installTimeout(const UString &handler, int t, bool singleShot);
    00091     void clearTimeout(int timerId);
    00092     void scheduleClose();
    00093     void closeNow();
    00094     void delayedGoHistory(int steps);
    00095     void goHistory(int steps);
    00096     void goURL(ExecState* exec, const QString& url, bool lockHistory);
    00097     Value openWindow(ExecState *exec, const List &args);
    00098     void resizeTo(QWidget* tl, int width, int height);
    00099     void afterScriptExecution();
    00100     bool isSafeScript(ExecState *exec) const;
    00101     Location *location() const;
    00102     ObjectImp* frames( ExecState* exec ) const;
    00103     JSEventListener *getJSEventListener(const Value &val, bool html = false);
    00104     void clear( ExecState *exec );
    00105     virtual UString toString(ExecState *exec) const;
    00106
    00107     // Set the current "event" object
    00108     void setCurrentEvent( DOM::Event *evt );
    00109
    00110     QPtrList<JSEventListener> jsEventListeners;
    00111     virtual const ClassInfo* classInfo() const { return &info; }
    00112     static const ClassInfo info;
    00113     enum { Closed, Crypto, DefaultStatus, Status, Document, Node, EventCtor, Range,
    00114            NodeFilter, DOMException, CSSRule, Frames, _History, Event, InnerHeight,
    00115            InnerWidth, Length, _Location, Name, _Navigator, _Konqueror, ClientInformation,
    00116            OffscreenBuffering, Opener, OuterHeight, OuterWidth, PageXOffset, PageYOffset,
    00117            Parent, Personalbar, ScreenX, ScreenY, Scrollbars, Scroll, ScrollBy,
    00118            ScreenTop, ScreenLeft,
    00119            ScrollTo, ScrollX, ScrollY, MoveBy, MoveTo, ResizeBy, ResizeTo, Self, _Window, Top, _Screen,
    00120            Image, Option, Alert, Confirm, Prompt, Open, SetTimeout, ClearTimeout,
    00121            Focus, Blur, Close, SetInterval, ClearInterval, CaptureEvents, ReleaseEvents,
    00122            Print, AddEventListener, RemoveEventListener,
    00123            Onabort, Onblur,
    00124            Onchange, Onclick, Ondblclick, Ondragdrop, Onerror, Onfocus,
    00125            Onkeydown, Onkeypress, Onkeyup, Onload, Onmousedown, Onmousemove,
    00126            Onmouseout, Onmouseover, Onmouseup, Onmove, Onreset, Onresize,
    00127            Onselect, Onsubmit, Onunload };
    00128   protected:
    00129     enum DelayedActionId { NullAction, DelayedClose, DelayedGoHistory };
    00130
    00131     Value getListener(ExecState *exec, int eventId) const;
    00132     void setListener(ExecState *exec, int eventId, Value func);
    00133   private:
    00134     struct DelayedAction;
    00135     friend struct DelayedAction;
    00136
    00137     QGuardedPtr<KHTMLPart> m_part;
    00138     Screen *screen;
    00139     History *history;
    00140     FrameArray *m_frames;
    00141     Location *loc;
    00142     WindowQObject *winq;
    00143     DOM::Event *m_evt;
    00144
    00145     struct DelayedAction {
    00146       DelayedAction() : actionId(NullAction) {} // for QValueList
    00147       DelayedAction( DelayedActionId id, QVariant p = QVariant() ) : actionId(id), param(p) {}
    00148       DelayedActionId actionId;
    00149       QVariant param; // just in case
    00150     };
    00151     QValueList<DelayedAction> m_delayed;
    00152   };
    00153
    00159   class ScheduledAction {
    00160   public:
    00161     ScheduledAction(Object _func, List _args, bool _singleShot);
    00162     ScheduledAction(QString _code, bool _singleShot);
    00163     ~ScheduledAction();
    00164     void execute(Window *window);
    00165
    00166     ObjectImp func;
    00167     List args;
    00168     QString code;
    00169     bool isFunction;
    00170     bool singleShot;
    00171   };
    00172
    00173   class WindowQObject : public QObject {
    00174     Q_OBJECT
    00175   public:
    00176     WindowQObject(Window *w);
    00177     ~WindowQObject();
    00178     int installTimeout(const UString &handler, int t, bool singleShot);
    00179     int installTimeout(const Value &func, List args, int t, bool singleShot);
    00180     void clearTimeout(int timerId, bool delAction = true);
    00181   public slots:
    00182     void timeoutClose();
    00183   protected slots:
    00184     void parentDestroyed();
    00185   protected:
    00186     void timerEvent(QTimerEvent *e);
    00187   private:
    00188     Window *parent;
    00189     KHTMLPart *part;            // not guarded, may be dangling
    00190     QMap<int, ScheduledAction*> scheduledActions;
    00191   };
    00192
    00193   class Location : public ObjectImp {
    00194   public:
    00195     ~Location();
    00196     virtual Value get(ExecState *exec, const UString &propertyName) const;
    00197     virtual void put(ExecState *exec, const UString &propertyName, const Value &value, int attr = None);
    00198     virtual Value toPrimitive(ExecState *exec, Type preferred) const;
    00199     virtual UString toString(ExecState *exec) const;
    00200     enum { Hash, Href, Hostname, Host, Pathname, Port, Protocol, Search, EqualEqual,
    00201            Assign, Replace, Reload, ToString };
    00202     KHTMLPart *part() const { return m_part; }
    00203     virtual const ClassInfo* classInfo() const { return &info; }
    00204     static const ClassInfo info;
    00205   private:
    00206     friend class Window;
    00207     Location(KHTMLPart *p);
    00208     QGuardedPtr<KHTMLPart> m_part;
    00209   };
    00210
    00211 #ifdef Q_WS_QWS
    00212   class Konqueror : public ObjectImp {
    00213     friend class KonquerorFunc;
    00214   public:
    00215     Konqueror(ExecState *, KHTMLPart *p) : part(p) { }
    00216     virtual Value get(ExecState *exec, const UString &propertyName) const;
    00217     virtual bool hasProperty(ExecState *exec, const UString &p) const;
    00218     virtual UString toString(ExecState *exec) const;
    00219     virtual const ClassInfo* classInfo() const { return &info; }
    00220     static const ClassInfo info;
    00221   private:
    00222     KHTMLPart *part;
    00223   };
    00224 #endif
    00225
    00226 } // namespace
    00227
    00228 #endif

This file is part of the documentation for kdelibs Version 3.1.5.
Documentation copyright © 1996-2002 the KDE developers.
Generated on Wed Jan 28 13:34:27 2004 by doxygen 1.3.4 written by Dimitri van Heesch, © 1997-2001