summaryrefslogtreecommitdiffstats
path: root/src/picitem.h
blob: 959311fed1ee6c039a2df21d7733ee4449d0b768 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
/***************************************************************************
 *   Copyright (C) 2003,2005 by David Saxton                               *
 *   david@bluehaze.org                                                    *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 ***************************************************************************/
 
#ifndef PICITEM_H
#define PICITEM_H

#include "cnitem.h"

#include <tqobject.h>

class MicroSettings;
class FlowCodeDocument;
class PinSettings;

/**
@short Allows visual setting of pin type/state
@author David Saxton
*/
class PinItem : public TQObject, public TQCanvasRectangle
{
	Q_OBJECT
  
public:
	PinItem( FlowCodeDocument* _view, TQPoint position, bool _onLeft, PinSettings *_pinSettings );

	int rtti() const;
	TQRect boundingRect () const;
	void switchState();
	
	TQString id();
	
	/**
	 * Called from ICNDocument when the pin item was dragged
	 */
	void dragged( int dx );
	
	virtual void moveBy ( double dx, double dy );
	
public slots:
	void updateDrawing();

private:
	void initItem();
	void drawShape( TQPainter& p );
	void calcTextRect();
	
	FlowCodeDocument *view; // Pointer to canvas view that the component item is currently on
	bool onLeft;
	PinSettings * m_pinSettings;
	TQRect m_textRect;
	TQFont m_font;
};
typedef TQValueList<PinItem*> PinItemList;


/**
Allows visual editing of inital PIC settings
@author David Saxton
*/
class PicItem : public CNItem
{
	Q_OBJECT
  
	public:
		PicItem( ICNDocument *icnDocument, bool newItem, const char *id, MicroSettings *_microSettings );
		~PicItem();
	
		void drawShape( TQPainter &p );
	
		virtual void buttonStateChanged( const TQString &id, bool state );
		virtual bool isMovable() const { return false; }
	
		static TQString typeString() { return "microitem"; }
		virtual void updateZ( int baseZ );
	
	protected slots:
		void slotMicroSettingsDlgAccepted();
	
	protected:
		void updateVisibility();
		
		MicroSettings *microSettings;
		PinItemList m_pinItemList;
		ICNDocument *p_icnDocument;
		bool m_bExpanded;
		int m_innerHeight;
};

#endif