xref: /haiku/src/apps/cortex/MediaRoutingView/MediaWire.h (revision 19ae20e67e91fc09cc9fc5c0e60e21e24e7a53eb)
1 /*
2  * Copyright (c) 1999-2000, Eric Moon.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  *
9  * 1. Redistributions of source code must retain the above copyright
10  *    notice, this list of conditions, and the following disclaimer.
11  *
12  * 2. Redistributions in binary form must reproduce the above copyright
13  *    notice, this list of conditions, and the following disclaimer in the
14  *    documentation and/or other materials provided with the distribution.
15  *
16  * 3. The name of the author may not be used to endorse or promote products
17  *    derived from this software without specific prior written permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR
20  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
21  * OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
23  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
26  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
27  * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29  */
30 
31 
32 // MediaWire.h
33 // c.lenz 10oct99
34 //
35 // HISTORY
36 //
37 
38 #ifndef __MediaWire_H__
39 #define __MediaWire_H__
40 
41 // DiagramView
42 #include "DiagramWire.h"
43 // NodeManager
44 #include "Connection.h"
45 
46 #include "cortex_defs.h"
47 __BEGIN_CORTEX_NAMESPACE
48 
49 class MediaJack;
50 
51 class MediaWire :
52 	public		DiagramWire {
53 	typedef		DiagramWire _inherited;
54 
55 public:					// *** constans
56 
57 	// [e.moon 26oct99] moved definition to MediaWire.cpp
58 	static const float		M_WIRE_OFFSET;
59 
60 public:					// *** ctor/dtor
61 
62 	// input and output jack are set connected by this constructor
63 	// so be careful to only pass in valid pointers
64 						MediaWire(
65 							Connection connection,
66 							MediaJack *outputJack,
67 							MediaJack *inputJack);
68 
69 	// special constructor used only in drag&drop sessions for
70 	// temporary visual indication of the connection process
71 	// the isStartPoint specifies if the given EndPoint is
72 	// supposed to be treated as start or end point
73 						MediaWire(
74 							MediaJack *jack,
75 							bool isStartPoint);
76 
77 	virtual				~MediaWire();
78 
79 public:					// *** accessors
80 
81 	Connection			connection;
82 
83 public:					// *** derived from DiagramWire/Item
84 
85 	// init the cached points and the frame rect
86 	virtual void		attachedToDiagram();
87 
88 	// make sure no tooltip is being displayed for this wire
89 	// +++ DOES NOT WORK (yet)
90 	virtual void		detachedFromDiagram();
91 
92 	// calculates and returns the frame rectangle of the wire
93 	virtual BRect		Frame() const;
94 
95 	// returns a value > 0.5 for points pretty much close to the
96 	// wire
97 	virtual float		howCloseTo(
98 							BPoint point) const;
99 
100 	// does the actual drawing
101 	virtual void		drawWire();
102 
103 	// displays the context-menu for right-clicks
104 	virtual void		MouseDown(
105 							BPoint point,
106 							uint32 buttons,
107 							uint32 clicks);
108 
109 	// changes the mouse cursor and starts a tooltip
110 	virtual void		MouseOver(
111 							BPoint point,
112 							uint32 transit);
113 
114 	// also selects and invalidates the jacks connected by
115 	// this wire
116 	virtual void		selected();
117 
118 	// also deselectes and invalidates the jacks connected
119 	// by this wire
120 	virtual void		deselected();
121 
122 	// updates the cached start & end points and the frame rect
123 	virtual void		endPointMoved(
124 							DiagramEndPoint *which = 0);
125 
126 protected:					// *** operations
127 
128 	// display a popup-menu at given point
129 	void				showContextMenu(
130 							BPoint point);
131 
132 private:					// *** data members
133 
134 	BPoint				m_startPoint;
135 
136 	BPoint				m_endPoint;
137 
138 	BPoint				m_startOffset;
139 
140 	BPoint				m_endOffset;
141 
142 	BRect				m_frame;
143 };
144 
145 __END_CORTEX_NAMESPACE
146 #endif /* __MediaWire_H__ */
147