File indexing completed on 2024-04-21 05:43:21

0001 /***************************************************************************
0002  *   Copyright (C) 2005 by David Saxton                                    *
0003  *   david@bluehaze.org                                                    *
0004  *                                                                         *
0005  *   This program is free software; you can redistribute it and/or modify  *
0006  *   it under the terms of the GNU General Public License as published by  *
0007  *   the Free Software Foundation; either version 2 of the License, or     *
0008  *   (at your option) any later version.                                   *
0009  ***************************************************************************/
0010 
0011 #ifndef SOLIDSHAPE_H
0012 #define SOLIDSHAPE_H
0013 
0014 #include <drawpart.h>
0015 
0016 class RectangularOverlay;
0017 
0018 /**
0019 @short Represents a drawable rectangle on the canvas
0020 @author David Saxton
0021 */
0022 class DPRectangle : public DrawPart
0023 {
0024 public:
0025     DPRectangle(ItemDocument *itemDocument, bool newItem, const char *id = nullptr);
0026     ~DPRectangle() override;
0027 
0028     static Item *construct(ItemDocument *itemDocument, bool newItem, const char *id);
0029     static LibraryItem *libraryItem();
0030 
0031     void setSelected(bool yes) override;
0032 
0033     QSize minimumSize() const override;
0034 
0035 protected:
0036     void drawShape(QPainter &p) override;
0037     void dataChanged() override;
0038     void postResize() override;
0039 
0040     /** Returns the rectangle to draw in, taking into account the line
0041      * width */
0042     QRect drawRect() const;
0043 
0044 private:
0045     RectangularOverlay *m_pRectangularOverlay;
0046 };
0047 
0048 /**
0049 @short Represents a drawable rectangle on the canvas
0050 @author David Saxton
0051 */
0052 class DPEllipse : public DPRectangle
0053 {
0054 public:
0055     DPEllipse(ItemDocument *itemDocument, bool newItem, const char *id = nullptr);
0056     ~DPEllipse() override;
0057 
0058     static Item *construct(ItemDocument *itemDocument, bool newItem, const char *id);
0059     static LibraryItem *libraryItem();
0060 
0061 protected:
0062     void postResize() override;
0063 
0064 private:
0065     void drawShape(QPainter &p) override;
0066 };
0067 
0068 #endif