File indexing completed on 2024-12-01 12:34:07

0001 /*
0002  * This file is part of the HTML rendering engine for KDE.
0003  *
0004  * Copyright (C) 2004,2005 Allan Sandfeld Jensen (kde@carewolf.com)
0005  *
0006  * This library is free software; you can redistribute it and/or
0007  * modify it under the terms of the GNU Library General Public
0008  * License as published by the Free Software Foundation; either
0009  * version 2 of the License, or (at your option) any later version.
0010  *
0011  * This library is distributed in the hope that it will be useful,
0012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
0013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0014  * Library General Public License for more details.
0015  *
0016  * You should have received a copy of the GNU Library General Public License
0017  * along with this library; see the file COPYING.LIB.  If not, write to
0018  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
0019  * Boston, MA 02110-1301, USA.
0020  *
0021  */
0022 #ifndef RENDER_GENERATED_H
0023 #define RENDER_GENERATED_H
0024 
0025 #include "rendering/render_text.h"
0026 #include "rendering/render_box.h"
0027 
0028 namespace DOM
0029 {
0030 class CounterImpl;
0031 }
0032 
0033 namespace khtml
0034 {
0035 class CounterNode;
0036 
0037 // -----------------------------------------------------------------------------
0038 
0039 class RenderCounterBase : public RenderText
0040 {
0041 public:
0042     RenderCounterBase(DOM::NodeImpl *node);
0043 
0044     const char *renderName() const override
0045     {
0046         return "RenderCounterBase";
0047     }
0048 
0049     void layout() override;
0050     void calcMinMaxWidth() override;
0051     bool isCounter() const override
0052     {
0053         return true;
0054     }
0055 
0056     virtual void generateContent() = 0;
0057     void updateContent();
0058 
0059 protected:
0060     QString m_item;
0061     CounterNode *m_counterNode; // Cache of the counternode
0062 };
0063 
0064 // -----------------------------------------------------------------------------
0065 
0066 class RenderCounter : public RenderCounterBase
0067 {
0068 public:
0069     RenderCounter(DOM::NodeImpl *node, const DOM::CounterImpl *counter);
0070     virtual ~RenderCounter() {}
0071 
0072     const char *renderName() const override
0073     {
0074         return "RenderCounter";
0075     }
0076 
0077     void generateContent() override;
0078 
0079 protected:
0080     QString toListStyleType(int value, int total, EListStyleType type);
0081 
0082     const DOM::CounterImpl *m_counter;
0083 };
0084 
0085 // -----------------------------------------------------------------------------
0086 
0087 class RenderQuote : public RenderCounterBase
0088 {
0089 public:
0090     RenderQuote(DOM::NodeImpl *node, EQuoteContent type);
0091     virtual ~RenderQuote() {}
0092 
0093     const char *renderName() const override
0094     {
0095         return "RenderQuote";
0096     }
0097 
0098     bool isQuote() const override
0099     {
0100         return true;
0101     }
0102     virtual int quoteCount() const;
0103 
0104     void generateContent() override;
0105 
0106 protected:
0107     EQuoteContent m_quoteType;
0108 };
0109 
0110 // -----------------------------------------------------------------------------
0111 
0112 // Is actually a special case of renderCounter for non-counted list-styles
0113 // These have traditionally been drawn rather than use Unicode characters
0114 class RenderGlyph : public RenderBox
0115 {
0116 public:
0117     RenderGlyph(DOM::NodeImpl *node, EListStyleType type);
0118     virtual ~RenderGlyph() {}
0119 
0120     const char *renderName() const override
0121     {
0122         return "RenderGlyph";
0123     }
0124 
0125     void paint(PaintInfo &paintInfo, int _tx, int _ty) override;
0126     void calcMinMaxWidth() override;
0127 
0128     void setStyle(RenderStyle *_style) override;
0129 
0130     short lineHeight(bool firstLine) const override;
0131     short baselinePosition(bool firstLine) const override;
0132 
0133     bool isGlyph() const override
0134     {
0135         return true;
0136     }
0137 
0138     void position(InlineBox *box, int /*from*/, int /*len*/, bool /*reverse*/) override
0139     {
0140         setPos(box->xPos(), box->yPos());
0141     }
0142 
0143 protected:
0144     EListStyleType m_type;
0145 };
0146 
0147 } //namespace
0148 
0149 #endif