xref: /haiku/src/apps/cortex/MediaRoutingView/MediaWire.h (revision 0e50eab75e25d0d82090e22dbff766dfaa6f5e86)
1 // MediaWire.h
2 // c.lenz 10oct99
3 //
4 // HISTORY
5 //
6 
7 #ifndef __MediaWire_H__
8 #define __MediaWire_H__
9 
10 // DiagramView
11 #include "DiagramWire.h"
12 // NodeManager
13 #include "Connection.h"
14 
15 #include "cortex_defs.h"
16 __BEGIN_CORTEX_NAMESPACE
17 
18 class MediaJack;
19 
20 class MediaWire :
21 	public		DiagramWire {
22 	typedef		DiagramWire _inherited;
23 
24 public:					// *** constans
25 
26 	// [e.moon 26oct99] moved definition to MediaWire.cpp
27 	static const float		M_WIRE_OFFSET;
28 
29 public:					// *** ctor/dtor
30 
31 	// input and output jack are set connected by this constructor
32 	// so be careful to only pass in valid pointers
33 						MediaWire(
34 							Connection connection,
35 							MediaJack *outputJack,
36 							MediaJack *inputJack);
37 
38 	// special constructor used only in drag&drop sessions for
39 	// temporary visual indication of the connection process
40 	// the isStartPoint specifies if the given EndPoint is
41 	// supposed to be treated as start or end point
42 						MediaWire(
43 							MediaJack *jack,
44 							bool isStartPoint);
45 
46 	virtual				~MediaWire();
47 
48 public:					// *** accessors
49 
50 	Connection			connection;
51 
52 public:					// *** derived from DiagramWire/Item
53 
54 	// init the cached points and the frame rect
55 	virtual void		attachedToDiagram();
56 
57 	// make sure no tooltip is being displayed for this wire
58 	// +++ DOES NOT WORK (yet)
59 	virtual void		detachedFromDiagram();
60 
61 	// calculates and returns the frame rectangle of the wire
62 	virtual BRect		frame() const;
63 
64 	// returns a value > 0.5 for points pretty much close to the
65 	// wire
66 	virtual float		howCloseTo(
67 							BPoint point) const;
68 
69 	// does the actual drawing
70 	virtual void		drawWire();
71 
72 	// displays the context-menu for right-clicks
73 	virtual void		mouseDown(
74 							BPoint point,
75 							uint32 buttons,
76 							uint32 clicks);
77 
78 	// changes the mouse cursor and starts a tooltip
79 	virtual void		mouseOver(
80 							BPoint point,
81 							uint32 transit);
82 
83 	// also selects and invalidates the jacks connected by
84 	// this wire
85 	virtual void		selected();
86 
87 	// also deselectes and invalidates the jacks connected
88 	// by this wire
89 	virtual void		deselected();
90 
91 	// updates the cached start & end points and the frame rect
92 	virtual void		endPointMoved(
93 							DiagramEndPoint *which = 0);
94 
95 protected:					// *** operations
96 
97 	// display a popup-menu at given point
98 	void				showContextMenu(
99 							BPoint point);
100 
101 private:					// *** data members
102 
103 	BPoint				m_startPoint;
104 
105 	BPoint				m_endPoint;
106 
107 	BPoint				m_startOffset;
108 
109 	BPoint				m_endOffset;
110 
111 	BRect				m_frame;
112 };
113 
114 __END_CORTEX_NAMESPACE
115 #endif /* __MediaWire_H__ */
116