css_value.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., 51 Franklin Street, Fifth Floor, 00019 * Boston, MA 02110-1301, USA. 00020 * 00021 * This file includes excerpts from the Document Object Model (DOM) 00022 * Level 2 Specification (Style) 00023 * http://www.w3.org/TR/DOM-Level-2-Style/ 00024 * Copyright © 2000 W3C® (MIT, INRIA, Keio), All Rights Reserved. 00025 * 00026 */ 00027 #ifndef _CSS_css_value_h_ 00028 #define _CSS_css_value_h_ 00029 00030 #include <dom/dom_string.h> 00031 00032 #include <tqcolor.h> 00033 00034 #include <kdemacros.h> 00035 00036 namespace DOM { 00037 00038 class CSSStyleDeclarationImpl; 00039 class CSSRule; 00040 class CSSValue; 00041 00060 class KHTML_EXPORT CSSStyleDeclaration 00061 { 00062 public: 00063 CSSStyleDeclaration(); 00064 CSSStyleDeclaration(const CSSStyleDeclaration &other); 00065 CSSStyleDeclaration(CSSStyleDeclarationImpl *impl); 00066 public: 00067 00068 CSSStyleDeclaration & operator = (const CSSStyleDeclaration &other); 00069 00070 ~CSSStyleDeclaration(); 00071 00079 DOM::DOMString cssText() const; 00080 00092 void setCssText( const DOM::DOMString & ); 00093 00099 unsigned long length() const; 00100 00105 CSSRule parentRule() const; 00106 00120 DOM::DOMString getPropertyValue ( const DOM::DOMString &propertyName ) const; 00121 DOM::DOMString getPropertyValue ( const DOM::DOMString &propertyName ); 00122 00142 CSSValue getPropertyCSSValue ( const DOM::DOMString &propertyName ) const; 00143 CSSValue getPropertyCSSValue ( const DOM::DOMString &propertyName ); 00144 00163 DOM::DOMString removeProperty ( const DOM::DOMString &propertyName ); 00164 00179 DOM::DOMString getPropertyPriority ( const DOM::DOMString &propertyName ) const; 00180 DOM::DOMString getPropertyPriority ( const DOM::DOMString &propertyName ); 00181 00206 void setProperty ( const DOM::DOMString &propertyName, const DOM::DOMString &value, const DOM::DOMString &priority ); 00207 00221 DOM::DOMString item ( unsigned long index ) const; 00222 DOM::DOMString item ( unsigned long index ); 00223 00228 CSSStyleDeclarationImpl *handle() const; 00229 bool isNull() const; 00230 00231 protected: 00232 CSSStyleDeclarationImpl *impl; 00233 }; 00234 00235 00236 class CSSValueImpl; 00237 00243 class KHTML_EXPORT CSSValue 00244 { 00245 public: 00246 CSSValue(); 00247 CSSValue(const CSSValue &other); 00248 CSSValue(CSSValueImpl *impl); 00249 public: 00250 00251 CSSValue & operator = (const CSSValue &other); 00252 00253 ~CSSValue(); 00261 enum UnitTypes { 00262 CSS_INHERIT = 0, 00263 CSS_PRIMITIVE_VALUE = 1, 00264 CSS_VALUE_LIST = 2, 00265 CSS_CUSTOM = 3, 00266 CSS_INITIAL = 4 00267 }; 00268 00273 DOM::DOMString cssText() const; 00274 00286 void setCssText( const DOM::DOMString & ); 00287 00292 unsigned short cssValueType() const; 00293 00298 bool isCSSValueList() const; 00299 bool isCSSPrimitiveValue() const; 00300 CSSValueImpl *handle() const; 00301 bool isNull() const; 00302 00303 protected: 00304 CSSValueImpl *impl; 00305 }; 00306 00307 00308 class CSSValueListImpl; 00309 class CSSValue; 00310 00316 class KHTML_EXPORT CSSValueList : public CSSValue 00317 { 00318 public: 00319 CSSValueList(); 00320 CSSValueList(const CSSValueList &other); 00321 CSSValueList(const CSSValue &other); 00322 CSSValueList(CSSValueListImpl *impl); 00323 public: 00324 00325 CSSValueList & operator = (const CSSValueList &other); 00326 CSSValueList & operator = (const CSSValue &other); 00327 00328 ~CSSValueList(); 00329 00336 unsigned long length() const; 00337 00350 CSSValue item ( unsigned long index ); 00351 00352 protected: 00353 CSSValueListImpl *vimpl; 00354 }; 00355 00356 00357 class CSSPrimitiveValueImpl; 00358 class Counter; 00359 class RGBColor; 00360 class Rect; 00361 00373 class KHTML_EXPORT CSSPrimitiveValue : public CSSValue 00374 { 00375 public: 00376 CSSPrimitiveValue(); 00377 CSSPrimitiveValue(const CSSPrimitiveValue &other); 00378 CSSPrimitiveValue(const CSSValue &other); 00379 CSSPrimitiveValue(CSSPrimitiveValueImpl *impl); 00380 public: 00381 00382 CSSPrimitiveValue & operator = (const CSSPrimitiveValue &other); 00383 CSSPrimitiveValue & operator = (const CSSValue &other); 00384 00385 ~CSSPrimitiveValue(); 00390 enum UnitTypes { 00391 CSS_UNKNOWN = 0, 00392 CSS_NUMBER = 1, 00393 CSS_PERCENTAGE = 2, 00394 CSS_EMS = 3, 00395 CSS_EXS = 4, 00396 CSS_PX = 5, 00397 CSS_CM = 6, 00398 CSS_MM = 7, 00399 CSS_IN = 8, 00400 CSS_PT = 9, 00401 CSS_PC = 10, 00402 CSS_DEG = 11, 00403 CSS_RAD = 12, 00404 CSS_GRAD = 13, 00405 CSS_MS = 14, 00406 CSS_S = 15, 00407 CSS_HZ = 16, 00408 CSS_KHZ = 17, 00409 CSS_DIMENSION = 18, 00410 CSS_STRING = 19, 00411 CSS_URI = 20, 00412 CSS_IDENT = 21, 00413 CSS_ATTR = 22, 00414 CSS_COUNTER = 23, 00415 CSS_RECT = 24, 00416 CSS_RGBCOLOR = 25, 00417 CSS_PAIR = 100, // We envision this being exposed as a means of getting computed style values for pairs 00418 CSS_HTML_RELATIVE = 255 00419 }; 00420 00426 unsigned short primitiveType() const; 00427 00456 void setFloatValue ( unsigned short unitType, float floatValue ); 00457 00483 // ### KDE 4: make this const! 00484 float getFloatValue ( unsigned short unitType ); 00485 00511 void setStringValue ( unsigned short stringType, const DOM::DOMString &stringValue ); 00512 00528 // ### KDE4: make this const! 00529 DOM::DOMString getStringValue ( ); 00530 00544 // ### KDE4: make this const! 00545 Counter getCounterValue ( ); 00546 00560 // ### KDE4: make this const! 00561 Rect getRectValue ( ); 00562 00577 // ### KDE4: make this const! 00578 RGBColor getRGBColorValue ( ); 00579 }; 00580 00581 00582 00591 class KHTML_EXPORT RGBColor 00592 { 00593 public: 00594 RGBColor(); 00598 RGBColor(const TQColor& c) { m_color = c.rgb(); } 00599 RGBColor(QRgb color); 00600 00601 RGBColor(const RGBColor &other); 00602 RGBColor & operator = (const RGBColor &other); 00603 00604 ~RGBColor(); 00605 00610 CSSPrimitiveValue red() const; 00611 00616 CSSPrimitiveValue green() const; 00617 00622 CSSPrimitiveValue blue() const; 00623 00627 QRgb color() const { return m_color; } 00628 protected: 00629 QRgb m_color; 00630 }; 00631 00632 class RectImpl; 00633 00642 class KHTML_EXPORT Rect 00643 { 00644 friend class CSSPrimitiveValue; 00645 public: 00646 Rect(); 00647 Rect(const Rect &other); 00648 00649 Rect & operator = (const Rect &other); 00650 00651 ~Rect(); 00652 00657 CSSPrimitiveValue top() const; 00658 00663 CSSPrimitiveValue right() const; 00664 00669 CSSPrimitiveValue bottom() const; 00670 00675 CSSPrimitiveValue left() const; 00676 00681 RectImpl *handle() const; 00682 bool isNull() const; 00683 00684 protected: 00685 RectImpl *impl; 00686 Rect(RectImpl *i); 00687 }; 00688 00689 class CounterImpl; 00690 00699 class KHTML_EXPORT Counter 00700 { 00701 friend class CSSPrimitiveValue; 00702 public: 00703 Counter(); 00704 Counter(const Counter &other); 00705 public: 00706 00707 Counter & operator = (const Counter &other); 00708 00709 ~Counter(); 00710 00715 DOM::DOMString identifier() const; 00716 00721 DOM::DOMString listStyle() const; 00722 00727 DOM::DOMString separator() const; 00728 00733 CounterImpl *handle() const; 00734 bool isNull() const; 00735 00736 protected: 00737 CounterImpl *impl; 00738 Counter(CounterImpl *i); 00739 }; 00740 00741 00742 } // namespace 00743 00744 00745 #endif