2 * Copyright (c) 1999-2000, Eric Moon.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions, and the following disclaimer.
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.
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.
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.
36 // DiagramEndPoint derived class implementing the drawing
42 #ifndef __MediaJack_H__
43 #define __MediaJack_H__
45 #include "DiagramEndPoint.h"
48 #include <MediaDefs.h>
49 #include <MediaNode.h>
55 #include "cortex_defs.h"
56 __BEGIN_CORTEX_NAMESPACE
58 int compareTypeAndID(const void *lValue
, const void *rValue
);
60 class MediaJack
: public DiagramEndPoint
63 public: // *** jack types
71 public: // *** constants
73 // [e.moon 26oct99] moved definitions to MediaJack.cpp
74 static float M_DEFAULT_WIDTH
;
75 static float M_DEFAULT_HEIGHT
;
76 static const float M_DEFAULT_GAP
;
77 static const int32 M_MAX_ABBR_LENGTH
;
79 public: // *** ctor/dtor
81 // Constructor for input jacks
85 // Constructor for output jacks
91 public: // *** accessors
93 // returns the full name of the input/output
97 // return true if this is an input jack
99 { return (m_jackType
== M_INPUT
); }
101 // copies the media_input struct into input; returns
102 // B_ERROR if this isn't an input jack
104 media_input
*input
) const;
106 // return true if this is an output jack
107 bool isOutput() const
108 { return (m_jackType
== M_OUTPUT
); }
110 // copies the media_output struct into input; returns
111 // B_ERROR if this isn't an input jack
113 media_output
*output
) const;
115 public: // *** derived from DiagramEndPoint/Item
117 // is called by the parent DiagramBox after adding endpoint
118 virtual void attachedToDiagram();
120 // is called by the parent DiagramBox just before the endpoint
122 virtual void detachedFromDiagram();
124 // the actual drawing code
125 virtual void drawEndPoint();
127 // returns the coordinate at which a connected MediaWire is
128 // supposed to start/end
129 virtual BPoint
connectionPoint() const;
131 // hook called by the base class; just verifies if the jack
132 // type isn't equal, i.e. not connecting an input to an input
133 virtual bool connectionRequested(
134 DiagramEndPoint
*which
);
136 // displays the context menu for right-clicks
137 virtual void MouseDown(
142 // changes the mouse cursor and prepares a tooltip
143 virtual void MouseOver(
147 // changes the mouse cursor
148 virtual void MessageDragged(
151 const BMessage
*message
);
153 // updates the offscreen bitmap
154 virtual void selected();
156 // updates the offscreen bitmap
157 virtual void deselected();
159 // updates the offscreen bitmap
160 virtual void connected();
162 // updates the offscreen bitmap
163 virtual void disconnected();
165 public: // *** operations
167 // updates the jacks bitmap
171 // special function to be called by the parent MediaNodePanel
172 // for simple positioning; this method only needs to know the
173 // vertical offset of the jack and the left/right frame coords
176 float verticalOffset
,
179 BRegion
*updateRegion
= 0);
181 protected: // *** operations
183 // display a popup-menu at given point
184 void showContextMenu(
187 private: // *** internal methods
189 // update the offscreen bitmap
190 void _updateBitmap();
192 // draw jack into the specified target view
198 // make/update an abbreviation for the jacks name
199 void _updateAbbreviation();
201 public: // *** sorting methods
203 // used for sorting; will put input jacks before output jacks
204 // and inside those sort by index
205 friend int compareTypeAndID(
215 media_source m_source
;
216 media_destination m_destination
;
217 media_format m_format
;
219 BString m_abbreviation
;
222 __END_CORTEX_NAMESPACE
223 #endif /* __MediaJack_H__ */