File indexing completed on 2024-06-16 05:24:55

0001 /*
0002     This file is part of the Okteta Kasten module, made within the KDE community.
0003 
0004     SPDX-FileCopyrightText: 2003, 2008 Friedrich W. H. Kossebau <kossebau@kde.org>
0005 
0006     SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
0007 */
0008 
0009 #ifndef KASTEN_ABSTRACTCOLUMNFRAMERENDERER_HPP
0010 #define KASTEN_ABSTRACTCOLUMNFRAMERENDERER_HPP
0011 
0012 // lib
0013 #include "abstractframerenderer.hpp"
0014 // Okteta gui
0015 #include <Okteta/PixelMetrics>
0016 #include <Okteta/Line>
0017 // Okteta core
0018 #include <Okteta/AddressRange>
0019 // Std
0020 #include <memory>
0021 
0022 namespace Okteta {
0023 class AbstractColumnRenderer;
0024 }
0025 
0026 /** class to render columns with the same lineheight for all lines
0027  *
0028  * lines are only completely rendered, so contentHeight <= framesCount*height
0029  * @author Friedrich W. H. Kossebau
0030  */
0031 
0032 class AbstractColumnFrameRenderer : public AbstractFrameRenderer
0033 {
0034 public:
0035     AbstractColumnFrameRenderer();
0036     ~AbstractColumnFrameRenderer() override;
0037 
0038 public: // AbstractFrameRenderer API
0039 //     virtual int height() const;
0040 //     virtual int width() const;
0041     void renderFrame(QPainter* painter, int frameIndex) override;
0042 
0043 public: // data-wise sizes
0044     /** returns the number of all lines */
0045     Okteta::LineSize noOfLines() const;
0046     /** returns number of fully visible lines, at least 1 (as needed by page down/up)
0047      * doesn't care about the total height being smaller than the display height
0048      */
0049     Okteta::LineSize noOfLinesPerFrame() const;
0050 
0051 public: // pixel-wise sizes
0052     /** returns the height of each line */
0053     Okteta::PixelY lineHeight() const;
0054     /** returns the width of all visible columns together */
0055     Okteta::PixelX columnsWidth() const;
0056     /** returns the height of all lines together */
0057     Okteta::PixelY columnsHeight() const;
0058 
0059 public:
0060     /**  */
0061     void setColumnsPos(Okteta::PixelX x, Okteta::PixelY y);
0062 
0063 protected: // our API
0064     /** draws area without columns in columns coordinates */
0065     virtual void drawEmptyArea(QPainter* painter, int cx, int cy, int cw, int ch);
0066 
0067 protected:
0068     /** sets height of all lines and propagates this information to all columns
0069      * doesn't update the content size
0070      * @param NewLineHeight height in pixels
0071      */
0072     virtual void setLineHeight(Okteta::PixelY NewLineHeight);
0073     /** sets the number of lines
0074      * doesn't update the content size
0075      * @param NewNoOfLines new number of lines to display
0076      */
0077     virtual void setNoOfLines(Okteta::LineSize NewNoOfLines);
0078 
0079 protected:
0080     /** takes ownership of column renderer */
0081     void addColumn(Okteta::AbstractColumnRenderer* column);
0082     void removeColumn(Okteta::AbstractColumnRenderer* column);
0083 
0084 protected: // recalculations
0085     /** recalculates the positions of the columns and the total width */
0086     void updateWidths();
0087 
0088 private:
0089     const std::unique_ptr<class AbstractColumnFrameRendererPrivate> d;
0090 };
0091 
0092 #endif