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 // c.lenz 9oct99 Begun
38 #ifndef __MediaNodePanel_H__
39 #define __MediaNodePanel_H__
42 #include "DiagramBox.h"
44 #include "MediaJack.h"
51 #include "IStateArchivable.h"
53 #include "cortex_defs.h"
54 __BEGIN_CORTEX_NAMESPACE
56 int compareID(const void *lValue
, const void *rValue
);
61 class MediaNodePanel
: public DiagramBox
,
63 public IStateArchivable
65 typedef DiagramBox _inherited
;
67 public: // *** constants
69 // [e.moon 26oct99] moved definitions to MediaNodePanel.cpp
70 static float M_DEFAULT_WIDTH
;
71 static float M_DEFAULT_HEIGHT
;
72 static float M_LABEL_H_MARGIN
;
73 static float M_LABEL_V_MARGIN
;
74 static float M_BODY_H_MARGIN
;
75 static float M_BODY_V_MARGIN
;
77 public: // *** accessors
81 public: // *** ctor/dtor
87 virtual ~MediaNodePanel();
89 public: // *** derived from DiagramItem
91 virtual void attachedToDiagram();
93 virtual void detachedFromDiagram();
95 virtual void DrawBox();
97 virtual void MouseDown(
102 virtual void MouseOver(
106 virtual void MessageDropped(
110 virtual void selected();
112 virtual void deselected();
114 public: // *** derived from BHandler
116 virtual void MessageReceived(
119 public: // *** updating
121 // is called by the MediaRoutingView when the layout
122 // (i.e. icon size, orientation, default sizes) have
127 // query the NodeManager for all free inputs & outputs
128 // and add a MediaJack instance for each; (connected
129 // inputs are added when the connection is reported or
133 // completely update the list of free input/output jacks
134 void updateIOJacks();
136 // arrange the MediaJacks in order of their IDs, resize
137 // the panel if more space is needed
138 void arrangeIOJacks();
140 // display popup-menu at the given point
141 void showContextMenu(
144 public: // *** sorting methods
146 // used for sorting the panels by media_node_id
147 friend int compareID(
151 public: // *** IStateArchivable
153 status_t
importState(
154 const BMessage
* archive
); //nyi
156 status_t
exportState(
157 BMessage
* archive
) const; //nyi
159 private: // *** internal operations
161 // fetch node name (shortening as necessary to fit)
162 // and update label placement
163 void _prepareLabel();
165 // update the offscreen bitmap
166 void _updateBitmap();
178 // a pointer to the panel's offscreen bitmap
183 BString m_label
; // truncated
185 BString m_fullLabel
; // not truncated
187 bool m_labelTruncated
;
189 BPoint m_labelOffset
;
195 // cached position in the "other" layout
196 BPoint m_alternatePosition
;
198 bool m_mouseOverLabel
;
201 static const BPoint s_invalidPosition
;
204 __END_CORTEX_NAMESPACE
205 #endif /* __MediaNodePanel_H__ */