File indexing completed on 2024-04-28 13:38:53

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 DRAWPART_H
0012 #define DRAWPART_H
0013 
0014 #include <item.h>
0015 
0016 class ICNDocument;
0017 class ItemDocument;
0018 class LibraryItem;
0019 class RectangularOverlay;
0020 
0021 /**
0022 @author David Saxton
0023 */
0024 class DrawPart : public Item
0025 {
0026 public:
0027     enum DrawAction {
0028         // Note: values are used for popup menu
0029         da_text = 0,
0030         da_line = 1,
0031         da_arrow = 2,
0032         da_rectangle = 3,
0033         da_ellipse = 4,
0034         da_image = 5
0035     };
0036 
0037     DrawPart(ItemDocument *itemDocument, bool newItem, const char *id);
0038     ~DrawPart() override;
0039 
0040     bool canResize() const override
0041     {
0042         return true;
0043     }
0044 
0045     Variant *createProperty(const QString &id, Variant::Type::Value type) override;
0046 
0047     Qt::PenStyle getDataPenStyle(const QString &id);
0048     Qt::PenCapStyle getDataPenCapStyle(const QString &id);
0049 
0050     void setDataPenStyle(const QString &id, Qt::PenStyle value);
0051     void setDataPenCapStyle(const QString &id, Qt::PenCapStyle value);
0052 
0053     ItemData itemData() const override;
0054     void restoreFromItemData(const ItemData &itemData) override;
0055 
0056     // Convention for following functions: name is i18n'd name of style, id is the english one
0057 
0058     static QString penStyleToID(Qt::PenStyle style);
0059     static Qt::PenStyle idToPenStyle(const QString &id);
0060     static QString penCapStyleToID(Qt::PenCapStyle style);
0061     static Qt::PenCapStyle idToPenCapStyle(const QString &id);
0062 
0063     static QString penStyleToName(Qt::PenStyle style);
0064     static Qt::PenStyle nameToPenStyle(const QString &name);
0065     static QString penCapStyleToName(Qt::PenCapStyle style);
0066     static Qt::PenCapStyle nameToPenCapStyle(const QString &name);
0067 };
0068 
0069 #endif