khtml Library API Documentation

css_stylesheetimpl.h

00001 /* 00002 * This file is part of the DOM implementation for KDE. 00003 * 00004 * (C) 1999-2003 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_stylesheetimpl.h,v 1.28 2003/05/17 22:12:57 mueller Exp $ 00022 */ 00023 #ifndef _CSS_css_stylesheetimpl_h_ 00024 #define _CSS_css_stylesheetimpl_h_ 00025 00026 #include <qvaluelist.h> 00027 #include <qptrlist.h> 00028 00029 #include "dom/dom_string.h" 00030 #include "css/css_base.h" 00031 #include "misc/loader_client.h" 00032 #include "xml/dom_docimpl.h" 00033 00034 namespace khtml { 00035 class CachedCSSStyleSheet; 00036 class DocLoader; 00037 } 00038 00039 namespace DOM { 00040 00041 class StyleSheet; 00042 class CSSStyleSheet; 00043 class MediaListImpl; 00044 class CSSRuleImpl; 00045 class CSSRuleList; 00046 class CSSStyleRuleImpl; 00047 class CSSValueImpl; 00048 class NodeImpl; 00049 class DocumentImpl; 00050 00051 class StyleSheetImpl : public StyleListImpl 00052 { 00053 public: 00054 StyleSheetImpl(DOM::NodeImpl *ownerNode, DOM::DOMString href = DOMString()); 00055 StyleSheetImpl(StyleSheetImpl *parentSheet, DOM::DOMString href = DOMString()); 00056 StyleSheetImpl(StyleBaseImpl *owner, DOM::DOMString href = DOMString()); 00057 StyleSheetImpl(khtml::CachedCSSStyleSheet *cached, DOM::DOMString href = DOMString()); 00058 virtual ~StyleSheetImpl(); 00059 00060 virtual bool isStyleSheet() const { return true; } 00061 00062 virtual DOM::DOMString type() const { return DOMString(); } 00063 00064 bool disabled() const { return m_disabled; } 00065 void setDisabled( bool disabled ) { m_disabled = disabled; } 00066 00067 DOM::NodeImpl *ownerNode() const { return m_parentNode; } 00068 StyleSheetImpl *parentStyleSheet() const; 00069 DOM::DOMString href() const { return m_strHref; } 00070 DOM::DOMString title() const { return m_strTitle; } 00071 MediaListImpl *media() const { return m_media; } 00072 void setMedia( MediaListImpl *media ); 00073 00074 protected: 00075 DOM::NodeImpl *m_parentNode; 00076 DOM::DOMString m_strHref; 00077 DOM::DOMString m_strTitle; 00078 MediaListImpl *m_media; 00079 bool m_disabled; 00080 }; 00081 00082 class CSSStyleSheetImpl : public StyleSheetImpl 00083 { 00084 public: 00085 CSSStyleSheetImpl(DOM::NodeImpl *parentNode, DOM::DOMString href = DOMString(), bool _implicit = false); 00086 CSSStyleSheetImpl(CSSStyleSheetImpl *parentSheet, DOM::DOMString href = DOMString()); 00087 CSSStyleSheetImpl(CSSRuleImpl *ownerRule, DOM::DOMString href = DOMString()); 00088 // clone from a cached version of the sheet 00089 CSSStyleSheetImpl(DOM::NodeImpl *parentNode, CSSStyleSheetImpl *orig); 00090 CSSStyleSheetImpl(CSSRuleImpl *ownerRule, CSSStyleSheetImpl *orig); 00091 00092 virtual bool isCSSStyleSheet() const { return true; } 00093 00094 virtual DOM::DOMString type() const { return "text/css"; } 00095 00096 CSSRuleImpl *ownerRule() const; 00097 CSSRuleList cssRules(); 00098 unsigned long insertRule ( const DOM::DOMString &rule, unsigned long index, int &exceptioncode ); 00099 void deleteRule ( unsigned long index, int &exceptioncode ); 00100 00101 virtual bool parseString( const DOMString &string, bool strict = true ); 00102 00103 bool isLoading() const; 00104 void setNonCSSHints(); 00105 00106 virtual void checkLoaded() const; 00107 00108 // ### remove? (clients should use sheet->doc()->docLoader()) 00109 khtml::DocLoader *docLoader() const 00110 { return m_doc ? m_doc->docLoader() : 0; } 00111 00112 DocumentImpl *doc() const { return m_doc; } 00113 bool implicit() const { return m_implicit; } 00114 protected: 00115 DocumentImpl *m_doc; 00116 bool m_implicit; 00117 }; 00118 00119 // ---------------------------------------------------------------------------- 00120 00121 class StyleSheetListImpl : public khtml::Shared<StyleSheetListImpl> 00122 { 00123 public: 00124 StyleSheetListImpl() {} 00125 ~StyleSheetListImpl(); 00126 00127 // the following two ignore implicit stylesheets 00128 unsigned long length() const; 00129 StyleSheetImpl *item ( unsigned long index ); 00130 00131 void add(StyleSheetImpl* s); 00132 void remove(StyleSheetImpl* s); 00133 00134 QPtrList<StyleSheetImpl> styleSheets; 00135 }; 00136 00137 // ---------------------------------------------------------------------------- 00138 00139 class MediaListImpl : public StyleBaseImpl 00140 { 00141 public: 00142 MediaListImpl() 00143 : StyleBaseImpl( 0 ) {} 00144 MediaListImpl( CSSStyleSheetImpl *parentSheet ) 00145 : StyleBaseImpl(parentSheet) {} 00146 MediaListImpl( CSSStyleSheetImpl *parentSheet, 00147 const DOM::DOMString &media ); 00148 MediaListImpl( CSSRuleImpl *parentRule, const DOM::DOMString &media ); 00149 00150 virtual bool isMediaList() const { return true; } 00151 00152 CSSStyleSheetImpl *parentStyleSheet() const; 00153 CSSRuleImpl *parentRule() const; 00154 unsigned long length() const { return m_lstMedia.count(); } 00155 DOM::DOMString item ( unsigned long index ) const { return m_lstMedia[index]; } 00156 void deleteMedium ( const DOM::DOMString &oldMedium ); 00157 void appendMedium ( const DOM::DOMString &newMedium ) { m_lstMedia.append(newMedium); } 00158 00159 DOM::DOMString mediaText() const; 00160 void setMediaText(const DOM::DOMString &value); 00161 00170 bool contains( const DOM::DOMString &medium ) const; 00171 00172 protected: 00173 QValueList<DOM::DOMString> m_lstMedia; 00174 }; 00175 00176 00177 } // namespace 00178 00179 #endif 00180
KDE Logo
This file is part of the documentation for khtml Library Version 3.2.3.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Fri Aug 20 09:50:26 2004 by doxygen 1.3.7 written by Dimitri van Heesch, © 1997-2003