File indexing completed on 2024-04-28 15:24:03
0001 /* 0002 * This file is part of the DOM implementation for KDE. 0003 * 0004 * Copyright (C) 1999-2003 Lars Knoll (knoll@kde.org) 0005 * (C) 1999 Antti Koivisto (koivisto@kde.org) 0006 * 0007 * This library is free software; you can redistribute it and/or 0008 * modify it under the terms of the GNU Library General Public 0009 * License as published by the Free Software Foundation; either 0010 * version 2 of the License, or (at your option) any later version. 0011 * 0012 * This library is distributed in the hope that it will be useful, 0013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0015 * Library General Public License for more details. 0016 * 0017 * You should have received a copy of the GNU Library General Public License 0018 * along with this library; see the file COPYING.LIB. If not, write to 0019 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 0020 * Boston, MA 02110-1301, USA. 0021 * 0022 */ 0023 #ifndef RENDER_IMAGE_H 0024 #define RENDER_IMAGE_H 0025 0026 #include "html/dtd.h" 0027 #include "html/html_elementimpl.h" 0028 #include "rendering/render_replaced.h" 0029 #include "dom/dom_string.h" 0030 0031 #include <QMap> 0032 #include <QPixmap> 0033 0034 namespace khtmlImLoad 0035 { 0036 class ImagePainter; 0037 } 0038 0039 namespace khtml 0040 { 0041 0042 class CachedObject; 0043 0044 class RenderImage : public RenderReplaced 0045 { 0046 public: 0047 RenderImage(DOM::NodeImpl *_element); 0048 virtual ~RenderImage(); 0049 0050 const char *renderName() const override 0051 { 0052 return "RenderImage"; 0053 } 0054 void paint(PaintInfo &i, int tx, int ty) override; 0055 0056 void layout() override; 0057 0058 void updatePixmap(const QRect &, CachedImage *) override; 0059 0060 // don't even think about making these methods virtual! 0061 //QPixmap pixmap() const; 0062 DOM::HTMLElementImpl *element() const 0063 { 0064 return static_cast<DOM::HTMLElementImpl *>(RenderObject::element()); 0065 } 0066 0067 bool complete() const; 0068 0069 CachedObject *contentObject() 0070 { 0071 return m_cachedImage; 0072 } 0073 void setContentObject(CachedObject *); 0074 0075 // hook to keep RendeObject::m_inline() up to date 0076 void setStyle(RenderStyle *style) override; 0077 void updateFromElement() override; 0078 0079 bool nodeAtPoint(NodeInfo &info, int x, int y, int tx, int ty, HitTestAction hitTestAction, bool inside) override; 0080 0081 bool isWidthSpecified() const; 0082 bool isHeightSpecified() const; 0083 0084 short calcAspectRatioWidth() const; 0085 int calcAspectRatioHeight() const; 0086 0087 short calcReplacedWidth() const override; 0088 int calcReplacedHeight() const override; 0089 0090 SelectionState selectionState() const override 0091 { 0092 return KDE_CAST_BF_ENUM(SelectionState, m_selectionState); 0093 } 0094 void setSelectionState(SelectionState s) override 0095 { 0096 m_selectionState = s; 0097 } 0098 #if 0 0099 virtual void caretPos(int offset, int flags, int &_x, int &_y, int &width, int &height) const; 0100 #endif 0101 0102 private: 0103 void updateImage(CachedImage *new_image); 0104 /* 0105 * Cache for images that need resizing 0106 */ 0107 //QPixmap resizeCache; 0108 0109 // text to display as long as the image isn't available 0110 DOM::DOMString alt; 0111 0112 CachedImage *m_cachedImage; 0113 khtmlImLoad::ImagePainter *m_imagePainter; 0114 0115 bool berrorPic : 1; 0116 bool bUnfinishedImageFrame : 1; 0117 KDE_BF_ENUM(SelectionState) m_selectionState : 3; // FIXME: don't forget to enlarge this as the enum grows 0118 }; 0119 0120 } //namespace 0121 0122 #endif