repository_infos: Enable automatic updates on the main Haiku repostiory.
[haiku.git] / src / apps / cortex / MediaRoutingView / MediaJack.h
blob13d262b876a504c6ff5b4a5c93e82b66c0cd6106
1 /*
2 * Copyright (c) 1999-2000, Eric Moon.
3 * All rights reserved.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
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.
32 // MediaJack.h
33 // c.lenz 10oct99
35 // * PURPOSE
36 // DiagramEndPoint derived class implementing the drawing
37 // code and
39 // HISTORY
42 #ifndef __MediaJack_H__
43 #define __MediaJack_H__
45 #include "DiagramEndPoint.h"
47 // Media Kit
48 #include <MediaDefs.h>
49 #include <MediaNode.h>
50 // Support Kit
51 #include <String.h>
53 class BBitmap;
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
65 enum jack_t
67 M_INPUT,
68 M_OUTPUT
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
82 MediaJack(
83 media_input input);
85 // Constructor for output jacks
86 MediaJack(
87 media_output output);
89 virtual ~MediaJack();
91 public: // *** accessors
93 // returns the full name of the input/output
94 BString name() const
95 { return m_label; }
97 // return true if this is an input jack
98 bool isInput() const
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
103 status_t getInput(
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
112 status_t getOutput(
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
121 // will be removed
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(
138 BPoint point,
139 uint32 buttons,
140 uint32 clicks);
142 // changes the mouse cursor and prepares a tooltip
143 virtual void MouseOver(
144 BPoint point,
145 uint32 transit);
147 // changes the mouse cursor
148 virtual void MessageDragged(
149 BPoint point,
150 uint32 transit,
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
168 void layoutChanged(
169 int32 layout);
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
174 // of the panel
175 void setPosition(
176 float verticalOffset,
177 float leftBoundary,
178 float rightBoundary,
179 BRegion *updateRegion = 0);
181 protected: // *** operations
183 // display a popup-menu at given point
184 void showContextMenu(
185 BPoint point);
187 private: // *** internal methods
189 // update the offscreen bitmap
190 void _updateBitmap();
192 // draw jack into the specified target view
193 void _drawInto(
194 BView *target,
195 BRect frame,
196 int32 layout);
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(
206 const void *lValue,
207 const void *rValue);
209 private: // *** data
211 int32 m_jackType;
212 BBitmap *m_bitmap;
213 int32 m_index;
214 media_node m_node;
215 media_source m_source;
216 media_destination m_destination;
217 media_format m_format;
218 BString m_label;
219 BString m_abbreviation;
222 __END_CORTEX_NAMESPACE
223 #endif /* __MediaJack_H__ */