khtml_part.h Source File (khtml Library)

| # khtml Library API Documentation
Overview | Class Hierarchy | Classes | Classes (annotated) | Members | Source Files

# khtml_part.h

    00001 // -*- c-basic-offset: 2 -*-
    00002 /* This file is part of the KDE project
    00003  *
    00004  * Copyright (C) 1998, 1999 Torben Weis <weis@kde.org>
    00005  *                     1999-2001 Lars Knoll <knoll@kde.org>
    00006  *                     1999-2001 Antti Koivisto <koivisto@kde.org>
    00007  *                     2000-2001 Simon Hausmann <hausmann@kde.org>
    00008  *                     2000-2001 Dirk Mueller <mueller@kde.org>
    00009  *                     2000 Stefan Schimanski <1Stein@gmx.de>
    00010  *
    00011  * This library is free software; you can redistribute it and/or
    00012  * modify it under the terms of the GNU Library General Public
    00013  * License as published by the Free Software Foundation; either
    00014  * version 2 of the License, or (at your option) any later version.
    00015  *
    00016  * This library is distributed in the hope that it will be useful,
    00017  * but WITHOUT ANY WARRANTY; without even the implied warranty of
    00018  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    00019  * Library General Public License for more details.
    00020  *
    00021  * You should have received a copy of the GNU Library General Public License
    00022  * along with this library; see the file COPYING.LIB.  If not, write to
    00023  * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    00024  * Boston, MA 02111-1307, USA.
    00025  */
    00026 #ifndef __khtml_part_h__
    00027 #define __khtml_part_h__
    00028
    00029 #include "dom/html_document.h"
    00030 #include "dom/dom2_range.h"
    00031
    00032 #include <kparts/part.h>
    00033 #include <kparts/browserextension.h>
    00034
    00035 #include <qregexp.h>
    00036
    00037 class KHTMLPartPrivate;
    00038 class KHTMLPartBrowserExtension;
    00039 class KJSProxy;
    00040 class KHTMLView;
    00041 class KHTMLSettings;
    00042 class KJavaAppletContext;
    00043
    00044 namespace DOM
    00045 {
    00046   class HTMLDocument;
    00047   class HTMLDocumentImpl;
    00048   class DocumentImpl;
    00049   class HTMLTitleElementImpl;
    00050   class HTMLElementImpl;
    00051   class HTMLFrameElementImpl;
    00052   class HTMLIFrameElementImpl;
    00053   class HTMLObjectElementImpl;
    00054   class HTMLFormElementImpl;
    00055   class HTMLAnchorElementImpl;
    00056   class HTMLMetaElementImpl;
    00057   class NodeImpl;
    00058   class Node;
    00059   class HTMLEventListener;
    00060   class EventListener;
    00061 }
    00062
    00063 namespace khtml
    00064 {
    00065   class DocLoader;
    00066   class RenderPart;
    00067   class RenderPartObject;
    00068   struct ChildFrame;
    00069   class MouseEvent;
    00070   class MousePressEvent;
    00071   class MouseDoubleClickEvent;
    00072   class MouseMoveEvent;
    00073   class MouseReleaseEvent;
    00074   class DrawContentsEvent;
    00075   class CachedObject;
    00076   class RenderWidget;
    00077   class CSSStyleSelector;
    00078   class HTMLTokenizer;
    00079 }
    00080
    00081 namespace KJS {
    00082     class Window;
    00083     class WindowFunc;
    00084     class JSEventListener;
    00085     class DOMDocument;
    00086 }
    00087
    00088 namespace KParts
    00089 {
    00090   class PartManager;
    00091   class LiveConnectExtension;
    00092 }
    00093
    00145 class KHTMLPart : public KParts::ReadOnlyPart
    00146 {
    00147   Q_OBJECT
    00148   friend class KHTMLView;
    00149   friend class DOM::HTMLTitleElementImpl;
    00150   friend class DOM::HTMLFrameElementImpl;
    00151   friend class DOM::HTMLIFrameElementImpl;
    00152   friend class DOM::HTMLObjectElementImpl;
    00153   friend class DOM::HTMLAnchorElementImpl;
    00154   friend class DOM::HTMLMetaElementImpl;
    00155   friend class DOM::NodeImpl;
    00156   friend class KHTMLRun;
    00157   friend class DOM::HTMLFormElementImpl;
    00158   friend class khtml::RenderPartObject;
    00159   friend class KJS::Window;
    00160   friend class KJS::WindowFunc;
    00161   friend class KJS::JSEventListener;
    00162   friend class KJS::DOMDocument;
    00163   friend class KJSProxy;
    00164   friend class KHTMLPartBrowserExtension;
    00165   friend class DOM::DocumentImpl;
    00166   friend class DOM::HTMLDocumentImpl;
    00167   friend class KHTMLPartBrowserHostExtension;
    00168   friend class khtml::HTMLTokenizer;
    00169   friend class XMLTokenizer;
    00170   friend class khtml::RenderWidget;
    00171   friend class khtml::CSSStyleSelector;
    00172   friend class KHTMLPartIface;
    00173   friend class KHTMLPartFunction;
    00174
    00175   Q_PROPERTY( bool javaScriptEnabled READ jScriptEnabled WRITE setJScriptEnabled )
    00176   Q_PROPERTY( bool javaEnabled READ javaEnabled WRITE setJavaEnabled )
    00177   Q_PROPERTY( bool autoloadImages READ autoloadImages WRITE setAutoloadImages )
    00178   Q_PROPERTY( bool dndEnabled READ dndEnabled WRITE setDNDEnabled )
    00179   Q_PROPERTY( bool pluginsEnabled READ pluginsEnabled WRITE setPluginsEnabled )
    00180   Q_PROPERTY( bool onlyLocalReferences READ onlyLocalReferences WRITE setOnlyLocalReferences )
    00181   Q_PROPERTY( QCString dcopObjectId READ dcopObjectId )
    00182
    00183 public:
    00184   enum GUIProfile { DefaultGUI, BrowserViewGUI /* ... */ };
    00185
    00198   KHTMLPart( QWidget *parentWidget = 0, const char *widgetname = 0,
    00199              QObject *parent = 0, const char *name = 0, GUIProfile prof = DefaultGUI );
    00200
    00201   KHTMLPart( KHTMLView *view, QObject *parent = 0, const char *name = 0, GUIProfile prof = DefaultGUI );
    00202
    00206   virtual ~KHTMLPart();
    00207
    00213   virtual bool openURL( const KURL &url );
    00214
    00218   virtual bool closeURL();
    00219
    00226   virtual void showError(KIO::Job* job);
    00227
    00231   DOM::HTMLDocument htmlDocument() const;
    00232
    00236   DOM::Document document() const;
    00237
    00241   DOM::Node activeNode() const;
    00242
    00246   KParts::BrowserExtension *browserExtension() const;
    00247   KParts::LiveConnectExtension *liveConnectExtension( const khtml::RenderPart *) const;
    00251   KHTMLView *view() const;
    00252
    00259   void setJScriptEnabled( bool enable );
    00260
    00265   bool jScriptEnabled() const;
    00266
    00270   void setMetaRefreshEnabled( bool enable );
    00271
    00275   bool metaRefreshEnabled() const;
    00276
    00284   QVariant executeScript( const QString &script );
    00288   QVariant executeScript( const DOM::Node &n, const QString &script );
    00289
    00294   void setDNDEnabled( bool b );
    00298   bool dndEnabled() const;
    00299
    00306   void setJavaEnabled( bool enable );
    00307
    00311   bool javaEnabled() const;
    00312
    00316   KJavaAppletContext *javaContext();
    00317
    00322   KJavaAppletContext *createJavaContext();
    00323
    00327   void setPluginsEnabled( bool enable );
    00328
    00332   bool pluginsEnabled() const;
    00333
    00340   void setAutoloadImages( bool enable );
    00347   bool autoloadImages() const;
    00348
    00356   void setOnlyLocalReferences(bool enable);
    00357
    00361   bool onlyLocalReferences() const;
    00362
    00363 #ifndef KDE_NO_COMPAT
    00364   void enableJScript(bool e) { setJScriptEnabled(e); }
    00365   void enableJava(bool e) { setJavaEnabled(e); }
    00366   void enablePlugins(bool e) { setPluginsEnabled(e); }
    00367   void autoloadImages(bool e) { setAutoloadImages(e); }
    00368   void enableMetaRefresh(bool e) { setMetaRefreshEnabled(e); }
    00369   bool setCharset( const QString &, bool ) { return true; }
    00370
    00371   KURL baseURL() const;
    00372   QString baseTarget() const;
    00373 #endif
    00374
    00378   KURL backgroundURL() const;
    00379
    00383   void scheduleRedirection( int delay, const QString &url, bool lockHistory = true );
    00384
    00407   virtual void begin( const KURL &url = KURL(), int xOffset = 0, int yOffset = 0 );
    00408
    00429   virtual void write( const char *str, int len = -1 );
    00430
    00438   virtual void write( const QString &str );
    00439
    00443   virtual void end();
    00444
    00445   /*
    00446    * Prints the current HTML page layed out for the printer.
    00447    *
    00448    * (not implemented at the moment)
    00449    */
    00450   //    void print(QPainter *, int pageHeight, int pageWidth);
    00451
    00455   void paint(QPainter *, const QRect &, int = 0, bool * = 0);
    00456
    00463   bool setEncoding( const QString &name, bool override = false );
    00464
    00470   QString encoding() const;
    00471
    00479   void setUserStyleSheet(const KURL &url);
    00480
    00488   void setUserStyleSheet(const QString &styleSheet);
    00489
    00490 public:
    00491
    00497   void setStandardFont( const QString &name );
    00498
    00505   void setFixedFont( const QString &name );
    00506
    00514   bool gotoAnchor( const QString &name );
    00515
    00519   void setURLCursor( const QCursor &c );
    00520
    00524   QCursor urlCursor() const;
    00525
    00529   void findTextBegin();
    00530
    00535   bool findTextNext( const QString &str, bool forward, bool caseSensitive, bool isRegExp );
    00536
    00547   void setZoomFactor(int percent);
    00548
    00552   int zoomFactor() const;
    00553
    00557   virtual QString selectedText() const;
    00558
    00562   DOM::Range selection() const;
    00563
    00567   void setSelection( const DOM::Range & );
    00568
    00577   bool hasSelection() const;
    00578
    00582   void selectAll();
    00583
    00589   void show();
    00590
    00596   void hide();
    00597
    00602   KParts::PartManager *partManager();
    00603
    00611   virtual void saveState( QDataStream &stream );
    00621   virtual void restoreState( QDataStream &stream );
    00622
    00626   DOM::Node nodeUnderMouse() const;
    00627
    00631   const KHTMLSettings *settings() const;
    00632
    00639   KHTMLPart *parentPart();
    00640
    00646   QStringList frameNames() const;
    00647
    00648   QPtrList<KParts::ReadOnlyPart> frames() const;
    00649
    00653   KHTMLPart *findFrame( const QString &f );
    00654
    00660   KParts::ReadOnlyPart *currentFrame() const;
    00661
    00668   bool frameExists( const QString &frameName );
    00669
    00670
    00676   void setJSStatusBarText( const QString &text );
    00677
    00683   void setJSDefaultStatusBarText( const QString &text );
    00684
    00690   QString jsStatusBarText() const;
    00691
    00697   QString jsDefaultStatusBarText() const;
    00698
    00702   QString referrer() const;
    00703
    00707   QString pageReferrer() const;
    00708
    00712   QString lastModified() const;
    00713
    00717   void preloadStyleSheet(const QString &url, const QString &stylesheet);
    00718
    00722   void preloadScript(const QString &url, const QString &script);
    00723
    00727   bool restored() const;
    00728
    00729 signals:
    00733   void onURL( const QString &url );
    00734
    00738   void popupMenu(const QString &url, const QPoint &point);
    00739
    00743   void selectionChanged();
    00744
    00752   void nodeActivated(const DOM::Node &);
    00753
    00756   void docCreated();
    00757
    00758 protected:
    00759
    00764   KURL completeURL( const QString &url );
    00765
    00772   void htmlError(int errorCode, const QString& text, const KURL& reqUrl);
    00773
    00774   virtual void customEvent( QCustomEvent *event );
    00775
    00779   virtual void khtmlMousePressEvent( khtml::MousePressEvent *event );
    00783   virtual void khtmlMouseDoubleClickEvent( khtml::MouseDoubleClickEvent * );
    00787   virtual void khtmlMouseMoveEvent( khtml::MouseMoveEvent *event );
    00791   virtual void khtmlMouseReleaseEvent( khtml::MouseReleaseEvent *event );
    00795   virtual void khtmlDrawContentsEvent( khtml::DrawContentsEvent * );
    00796
    00800   virtual void guiActivateEvent( KParts::GUIActivateEvent *event );
    00801
    00805   virtual bool openFile();
    00806
    00807   virtual void urlSelected( const QString &url, int button, int state,
    00808                             const QString &_target, KParts::URLArgs args = KParts::URLArgs());
    00809
    00818   virtual KParts::ReadOnlyPart *createPart( QWidget *parentWidget, const char *widgetName,
    00819                                             QObject *parent, const char *name,
    00820                                             const QString &mimetype, QString &serviceName,
    00821                                             QStringList &serviceTypes, const QStringList &params);
    00822
    00823   // This is for RenderPartObject. We want to ask the 'download plugin?'
    00824   // question only once per mimetype
    00825   bool pluginPageQuestionAsked(const QString& mimetype) const;
    00826   void setPluginPageQuestionAsked(const QString& mimetype);
    00827
    00828 public slots:
    00829
    00839   void setActiveNode(const DOM::Node &node);
    00840
    00844   void stopAnimations();
    00845
    00846   QCString dcopObjectId() const;
    00847
    00848 private slots:
    00849
    00853   void reparseConfiguration();
    00854
    00858   void slotData( KIO::Job*, const QByteArray &data );
    00862   void slotInfoMessage( KIO::Job*, const QString& msg );
    00866   void slotRestoreData( const QByteArray &data );
    00870   void slotFinished( KIO::Job* );
    00874   void slotFinishedParsing();
    00878   void slotRedirect();
    00882   void slotRedirection(KIO::Job*, const KURL&);
    00886   void slotDebugDOMTree();
    00890   void slotDebugRenderTree();
    00894   virtual void slotViewDocumentSource();
    00898   virtual void slotViewFrameSource();
    00902   void slotViewPageInfo();
    00906   virtual void slotSaveBackground();
    00910   virtual void slotSaveDocument();
    00914   virtual void slotSaveFrame();
    00918   virtual void slotSecurity();
    00922   virtual void slotSetEncoding();
    00923
    00927   virtual void slotUseStylesheet();
    00928
    00929   virtual void slotFind();
    00930   virtual void slotFindDone(); // ### remove me
    00931   virtual void slotFindDialogDestroyed();
    00932   void slotFindNext();
    00933
    00934   void slotIncZoom();
    00935   void slotDecZoom();
    00936
    00937   void slotLoadImages();
    00938
    00942   void submitFormAgain();
    00943
    00947   void updateActions();
    00951   void slotPartRemoved( KParts::Part *part );
    00955   void slotActiveFrameChanged( KParts::Part *part );
    00959   void slotChildStarted( KIO::Job *job );
    00963   void slotChildCompleted();
    00967   void slotChildCompleted( bool );
    00971   void slotParentCompleted();
    00975   void slotChildURLRequest( const KURL &url, const KParts::URLArgs &args );
    00979   void slotChildDocCreated();
    00980
    00981   void slotLoaderRequestStarted( khtml::DocLoader*, khtml::CachedObject* obj);
    00982   void slotLoaderRequestDone( khtml::DocLoader*, khtml::CachedObject *obj );
    00983   void checkCompleted();
    00984
    00988   void slotShowDocument( const QString &url, const QString &target );
    00989
    00993   void slotAutoScroll();
    00994
    00995   void slotPrintFrame();
    00996
    00997   void slotSelectAll();
    00998
    01002   void slotProgressUpdate();
    01003
    01004   /*
    01005    * @internal
    01006    */
    01007   void slotJobPercent(KIO::Job*, unsigned long);
    01008
    01009   /*
    01010    * @internal
    01011    */
    01012   void slotJobDone(KIO::Job*);
    01013
    01014   /*
    01015    * @internal
    01016    */
    01017   void slotJobSpeed(KIO::Job*, unsigned long);
    01018
    01022   void slotClearSelection();
    01023
    01027   void slotZoomView( int );
    01028
    01032   void slotHighlight( const QString &, int index, int length );
    01033
    01034 private:
    01035
    01036   enum StatusBarPriority { BarDefaultText, BarHoverText, BarOverrideText };
    01037   void setStatusBarText( const QString& text, StatusBarPriority p);
    01038
    01042   bool restoreURL( const KURL &url );
    01043
    01047   void emitSelectionChanged();
    01048
    01052   bool openURLInFrame( const KURL &url, const KParts::URLArgs &urlArgs );
    01053
    01054   void startAutoScroll();
    01055   void stopAutoScroll();
    01056   void overURL( const QString &url, const QString &target, bool shiftPressed = false );
    01057
    01061   bool processObjectRequest( khtml::ChildFrame *child, const KURL &url, const QString &mimetype );
    01062
    01066   void submitForm( const char *action, const QString &url, const QByteArray &formData,
    01067                    const QString &target, const QString& contentType = QString::null,
    01068                    const QString& boundary = QString::null );
    01069
    01073   void popupMenu( const QString &url );
    01074
    01075   void init( KHTMLView *view, GUIProfile prof );
    01076
    01077   void clear();
    01078
    01079   bool scheduleScript( const DOM::Node &n, const QString& script);
    01080
    01081   QVariant executeScheduledScript();
    01082
    01083   bool requestFrame( khtml::RenderPart *frame, const QString &url, const QString &frameName,
    01084                      const QStringList &args = QStringList(), bool isIFrame = false );
    01085
    01093   QString requestFrameName();
    01094
    01095   bool requestObject( khtml::RenderPart *frame, const QString &url, const QString &serviceType,
    01096                       const QStringList &args = QStringList() );
    01097
    01098   bool requestObject( khtml::ChildFrame *child, const KURL &url, const KParts::URLArgs &args = KParts::URLArgs() );
    01099
    01100   DOM::EventListener *createHTMLEventListener( QString code );
    01101
    01102   DOM::HTMLDocumentImpl *docImpl() const;
    01103   DOM::DocumentImpl *xmlDocImpl() const;
    01104   khtml::ChildFrame *frame( const QObject *obj );
    01105
    01106   khtml::ChildFrame *recursiveFrameRequest( const KURL &url, const KParts::URLArgs &args, bool callParent = true );
    01107
    01108   bool checkLinkSecurity(const KURL &linkURL,const QString &message = QString::null, const QString &button = QString::null);
    01109   QVariant executeScript(QString filename, int baseLine, const DOM::Node &n, const QString &script);
    01110
    01111   KJSProxy *jScript();
    01112
    01113   KHTMLPart *opener();
    01114   long cacheId() const;
    01115   void setOpener(KHTMLPart *_opener);
    01116   bool openedByJS();
    01117   void setOpenedByJS(bool _openedByJS);
    01118
    01119   void checkEmitLoadEvent();
    01120   void emitLoadEvent();
    01121
    01122   bool initFindNode( bool selection, bool reverse );
    01123   void findText();
    01124   void findTextNext();
    01125   void extendSelection( DOM::NodeImpl* node, long offset, DOM::Node& selectionNode, long& selectionOffset, bool right, bool paragraph );
    01126
    01127   KHTMLPartPrivate *d;
    01128   friend class KHTMLPartPrivate;
    01129 };
    01130
    01131
    01132 #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:08 2004 by doxygen 1.3.4 written by Dimitri van Heesch, © 1997-2001