khtml Library API Documentation

css_ruleimpl.h

00001 /*
00002  * This file is part of the DOM implementation for KDE.
00003  *
00004  * (C) 1999 Lars Knoll (knoll@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 License
00017  * along with this library; see the file COPYING.LIB.  If not, write to
00018  * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00019  * Boston, MA 02111-1307, USA.
00020  *
00021  * $Id: css_ruleimpl.h,v 1.18 2002/04/11 08:53:07 knoll Exp $
00022  */
00023 #ifndef _CSS_css_ruleimpl_h_
00024 #define _CSS_css_ruleimpl_h_
00025 
00026 #include "dom/dom_string.h"
00027 #include "dom/css_rule.h"
00028 #include "css/cssparser.h"
00029 #include "misc/loader_client.h"
00030 #include "misc/shared.h"
00031 
00032 namespace khtml {
00033     class CachedCSSStyleSheet;
00034 };
00035 
00036 namespace DOM {
00037 
00038 class CSSRule;
00039 class CSSStyleSheet;
00040 class CSSStyleSheetImpl;
00041 class CSSStyleDeclarationImpl;
00042 class MediaListImpl;
00043 
00044 class CSSRuleImpl : public StyleBaseImpl
00045 {
00046 public:
00047     CSSRuleImpl(StyleBaseImpl *parent);
00048 
00049     virtual ~CSSRuleImpl();
00050 
00051     virtual bool isRule() { return true; }
00052 
00053     unsigned short type() const;
00054     CSSStyleSheetImpl *parentStyleSheet() const;
00055     CSSRuleImpl *parentRule() const;
00056 
00057     DOM::DOMString cssText() const;
00058     void setCssText(DOM::DOMString str);
00059     virtual void init() {}
00060 
00061 protected:
00062     CSSRule::RuleType m_type;
00063 };
00064 
00065 
00066 class CSSCharsetRuleImpl : public CSSRuleImpl
00067 {
00068 public:
00069     CSSCharsetRuleImpl(StyleBaseImpl *parent);
00070 
00071     virtual ~CSSCharsetRuleImpl();
00072 
00073     virtual bool isCharsetRule() { return true; }
00074 
00075     DOMString encoding() const { return m_encoding; }
00076     void setEncoding(DOMString _encoding) { m_encoding = _encoding; }
00077 
00078 protected:
00079     DOMString m_encoding;
00080 };
00081 
00082 
00083 class CSSFontFaceRuleImpl : public CSSRuleImpl
00084 {
00085 public:
00086     CSSFontFaceRuleImpl(StyleBaseImpl *parent);
00087 
00088     virtual ~CSSFontFaceRuleImpl();
00089 
00090     CSSStyleDeclarationImpl *style() const;
00091 
00092     virtual bool isFontFaceRule() { return true; }
00093 
00094 protected:
00095     CSSStyleDeclarationImpl *m_style;
00096 };
00097 
00098 
00099 class CSSImportRuleImpl : public khtml::CachedObjectClient, public CSSRuleImpl
00100 {
00101 public:
00102     CSSImportRuleImpl( StyleBaseImpl *parent, const DOM::DOMString &href,
00103                        const DOM::DOMString &media );
00104 
00105     virtual ~CSSImportRuleImpl();
00106 
00107     DOM::DOMString href() const;
00108     MediaListImpl *media() const;
00109     CSSStyleSheetImpl *styleSheet() const;
00110 
00111     virtual bool isImportRule() { return true; }
00112 
00113     // from CachedObjectClient
00114     virtual void setStyleSheet(const DOM::DOMString &url, const DOM::DOMString &sheet);
00115 
00116     bool isLoading();
00117     virtual void init();
00118 
00119 protected:
00120     DOMString m_strHref;
00121     MediaListImpl *m_lstMedia;
00122     CSSStyleSheetImpl *m_styleSheet;
00123     khtml::CachedCSSStyleSheet *m_cachedSheet;
00124     bool m_loading;
00125 };
00126 
00127 
00128 class MediaList;
00129 class CSSRuleList;
00130 
00131 class CSSMediaRuleImpl : public CSSRuleImpl
00132 {
00133 public:
00134     CSSMediaRuleImpl( StyleBaseImpl *parent );
00135     CSSMediaRuleImpl( StyleBaseImpl *parent, const QChar *&curP,
00136                       const QChar * endP, const DOM::DOMString &media );
00137 
00138     virtual ~CSSMediaRuleImpl();
00139 
00140     MediaListImpl *media() const;
00141     CSSRuleListImpl *cssRules();
00142     unsigned long insertRule ( const DOM::DOMString &rule, unsigned long index );
00143     void deleteRule ( unsigned long index );
00144 
00145     virtual bool isMediaRule() { return true; }
00146 protected:
00147     MediaListImpl *m_lstMedia;
00148     CSSRuleListImpl *m_lstCSSRules;
00149 
00150     /* Not part of the DOM */
00151     unsigned long appendRule( CSSRuleImpl *rule );
00152 };
00153 
00154 
00155 class CSSPageRuleImpl : public CSSRuleImpl
00156 {
00157 public:
00158     CSSPageRuleImpl(StyleBaseImpl *parent);
00159 
00160     virtual ~CSSPageRuleImpl();
00161 
00162     CSSStyleDeclarationImpl *style() const;
00163 
00164     virtual bool isPageRule() { return true; }
00165 
00166     DOM::DOMString selectorText() const;
00167     void setSelectorText(DOM::DOMString str);
00168 
00169 protected:
00170     CSSStyleDeclarationImpl *m_style;
00171 };
00172 
00173 
00174 class CSSStyleRuleImpl : public CSSRuleImpl
00175 {
00176 public:
00177     CSSStyleRuleImpl(StyleBaseImpl *parent);
00178 
00179     virtual ~CSSStyleRuleImpl();
00180 
00181     CSSStyleDeclarationImpl *style() const;
00182 
00183     virtual bool isStyleRule() { return true; }
00184 
00185     DOM::DOMString selectorText() const;
00186     void setSelectorText(DOM::DOMString str);
00187 
00188     virtual bool parseString( const DOMString &string, bool = false );
00189 
00190     void setSelector( QPtrList<CSSSelector> *selector);
00191     void setDeclaration( CSSStyleDeclarationImpl *style);
00192 
00193     QPtrList<CSSSelector> *selector() { return m_selector; }
00194     CSSStyleDeclarationImpl *declaration() { return m_style; }
00195 
00196     void setNonCSSHints();
00197 
00198 protected:
00199     CSSStyleDeclarationImpl *m_style;
00200     QPtrList<CSSSelector> *m_selector;
00201 };
00202 
00203 
00204 
00205 class CSSUnknownRuleImpl : public CSSRuleImpl
00206 {
00207 public:
00208     CSSUnknownRuleImpl(StyleBaseImpl *parent);
00209 
00210     ~CSSUnknownRuleImpl();
00211 
00212     virtual bool isUnknownRule() { return true; }
00213 };
00214 
00215 
00216 class CSSRuleListImpl : public khtml::Shared<CSSRuleListImpl>
00217 {
00218 public:
00219     CSSRuleListImpl();
00220     ~CSSRuleListImpl();
00221 
00222     unsigned long length() const;
00223     CSSRuleImpl *item ( unsigned long index );
00224 
00225     /* not part of the DOM */
00226     unsigned long insertRule ( CSSRuleImpl *rule, unsigned long index );
00227     void deleteRule ( unsigned long index );
00228 
00229 protected:
00230     QPtrList<CSSRuleImpl> m_lstCSSRules;
00231 };
00232 
00233 }; // namespace
00234 
00235 #endif
KDE Logo
This file is part of the documentation for kdelibs Version 3.1.0.
Documentation copyright © 1996-2002 the KDE developers.
Generated on Wed Oct 8 12:22:34 2003 by doxygen 1.2.18 written by Dimitri van Heesch, © 1997-2001