repository_infos: Enable automatic updates on the main Haiku repostiory.
[haiku.git] / src / apps / cortex / MediaRoutingView / MediaNodePanel.h
blob30c2f6c93887cb1cf4259c4f52309fcd99bcfd17
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 // MediaNodePanel.h
33 // c.lenz 9oct99
35 // HISTORY
36 // c.lenz 9oct99 Begun
38 #ifndef __MediaNodePanel_H__
39 #define __MediaNodePanel_H__
41 // DiagramView
42 #include "DiagramBox.h"
43 // MediaRoutingView
44 #include "MediaJack.h"
46 // STL
47 #include <vector>
48 // Support Kit
49 #include <String.h>
51 #include "IStateArchivable.h"
53 #include "cortex_defs.h"
54 __BEGIN_CORTEX_NAMESPACE
56 int compareID(const void *lValue, const void *rValue);
58 class MediaIcon;
59 class NodeRef;
61 class MediaNodePanel : public DiagramBox,
62 public BHandler,
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
79 NodeRef* const ref;
81 public: // *** ctor/dtor
83 MediaNodePanel(
84 BPoint position,
85 NodeRef *nodeRef);
87 virtual ~MediaNodePanel();
89 public: // *** derived from DiagramItem
91 virtual void attachedToDiagram();
93 virtual void detachedFromDiagram();
95 virtual void DrawBox();
97 virtual void MouseDown(
98 BPoint point,
99 uint32 buttons,
100 uint32 clicks);
102 virtual void MouseOver(
103 BPoint point,
104 uint32 transit);
106 virtual void MessageDropped(
107 BPoint point,
108 BMessage *message);
110 virtual void selected();
112 virtual void deselected();
114 public: // *** derived from BHandler
116 virtual void MessageReceived(
117 BMessage *message);
119 public: // *** updating
121 // is called by the MediaRoutingView when the layout
122 // (i.e. icon size, orientation, default sizes) have
123 // changed
124 void layoutChanged(
125 int32 layout);
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
130 // queried)
131 void populateInit();
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(
142 BPoint point);
144 public: // *** sorting methods
146 // used for sorting the panels by media_node_id
147 friend int compareID(
148 const void *lValue,
149 const void *rValue);
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();
168 void _drawInto(
169 BView *target,
170 BRect targetRect,
171 int32 layout);
173 void _updateIcon(
174 int32 layout);
176 private: // *** data
178 // a pointer to the panel's offscreen bitmap
179 BBitmap *m_bitmap;
181 BBitmap *m_icon;
183 BString m_label; // truncated
185 BString m_fullLabel; // not truncated
187 bool m_labelTruncated;
189 BPoint m_labelOffset;
191 BRect m_labelRect;
193 BRect m_bodyRect;
195 // cached position in the "other" layout
196 BPoint m_alternatePosition;
198 bool m_mouseOverLabel;
200 // [e.moon 7dec99]
201 static const BPoint s_invalidPosition;
204 __END_CORTEX_NAMESPACE
205 #endif /* __MediaNodePanel_H__ */