File indexing completed on 2024-09-01 05:24:36
0001 /*************************************************************************** 0002 * Copyright (C) 2003,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 PICITEM_H 0012 #define PICITEM_H 0013 0014 #include "cnitem.h" 0015 0016 #include <QObject> 0017 0018 class MicroSettings; 0019 class FlowCodeDocument; 0020 class PinSettings; 0021 0022 /** 0023 @short Allows visual setting of pin type/state 0024 @author David Saxton 0025 */ 0026 class PinItem : /*public QObject, */ public KtlQCanvasRectangle 0027 { 0028 Q_OBJECT 0029 public: 0030 PinItem(FlowCodeDocument *_view, QPoint position, bool _onLeft, PinSettings *_pinSettings); 0031 0032 QRect boundingRect() const override; 0033 void switchState(); 0034 0035 QString id(); 0036 0037 /** 0038 * Called from ICNDocument when the pin item was dragged 0039 */ 0040 void dragged(int dx); 0041 0042 void moveBy(double dx, double dy) override; 0043 0044 public slots: 0045 void updateDrawing(); 0046 0047 private: 0048 void initItem(); 0049 void drawShape(QPainter &p) override; 0050 void calcTextRect(); 0051 0052 FlowCodeDocument *view; // Pointer to canvas view that the component item is currently on 0053 bool onLeft; 0054 PinSettings *m_pinSettings; 0055 QRect m_textRect; 0056 QFont m_font; 0057 }; 0058 typedef QList<PinItem *> PinItemList; 0059 0060 /** 0061 Allows visual editing of inital PIC settings 0062 @author David Saxton 0063 */ 0064 class PicItem : public CNItem 0065 { 0066 Q_OBJECT 0067 public: 0068 PicItem(ICNDocument *icnDocument, bool newItem, const char *id, MicroSettings *_microSettings); 0069 ~PicItem() override; 0070 0071 void drawShape(QPainter &p) override; 0072 0073 void buttonStateChanged(const QString &id, bool state) override; 0074 bool isMovable() const override 0075 { 0076 return false; 0077 } 0078 0079 static QString typeString() 0080 { 0081 return "microitem"; 0082 } 0083 void updateZ(int baseZ) override; 0084 0085 bool mousePressEvent(const EventInfo &info) override; 0086 bool mouseReleaseEvent(const EventInfo &info) override; 0087 bool mouseMoveEvent(const EventInfo &info) override; 0088 0089 protected slots: 0090 void slotMicroSettingsDlgAccepted(); 0091 0092 protected: 0093 void updateVisibility(); 0094 0095 MicroSettings *microSettings; 0096 PinItemList m_pinItemList; 0097 ICNDocument *p_icnDocument; 0098 bool m_bExpanded; 0099 int m_innerHeight; 0100 0101 private: 0102 QPoint m_pos; 0103 int m_dx; 0104 bool m_pressed; 0105 bool m_dragged; 0106 }; 0107 0108 #endif