1*c284bb0fSMatt Madia /* 2*c284bb0fSMatt Madia * Copyright (c) 1999-2000, Eric Moon. 3*c284bb0fSMatt Madia * All rights reserved. 4*c284bb0fSMatt Madia * 5*c284bb0fSMatt Madia * Redistribution and use in source and binary forms, with or without 6*c284bb0fSMatt Madia * modification, are permitted provided that the following conditions 7*c284bb0fSMatt Madia * are met: 8*c284bb0fSMatt Madia * 9*c284bb0fSMatt Madia * 1. Redistributions of source code must retain the above copyright 10*c284bb0fSMatt Madia * notice, this list of conditions, and the following disclaimer. 11*c284bb0fSMatt Madia * 12*c284bb0fSMatt Madia * 2. Redistributions in binary form must reproduce the above copyright 13*c284bb0fSMatt Madia * notice, this list of conditions, and the following disclaimer in the 14*c284bb0fSMatt Madia * documentation and/or other materials provided with the distribution. 15*c284bb0fSMatt Madia * 16*c284bb0fSMatt Madia * 3. The name of the author may not be used to endorse or promote products 17*c284bb0fSMatt Madia * derived from this software without specific prior written permission. 18*c284bb0fSMatt Madia * 19*c284bb0fSMatt Madia * THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR 20*c284bb0fSMatt Madia * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 21*c284bb0fSMatt Madia * OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR 22*c284bb0fSMatt Madia * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 23*c284bb0fSMatt Madia * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24*c284bb0fSMatt Madia * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 25*c284bb0fSMatt Madia * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 26*c284bb0fSMatt Madia * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR 27*c284bb0fSMatt Madia * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28*c284bb0fSMatt Madia * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29*c284bb0fSMatt Madia */ 30*c284bb0fSMatt Madia 31*c284bb0fSMatt Madia 32a0795c6fSMarcus Overhagen // MediaNodePanel.h 33a0795c6fSMarcus Overhagen // c.lenz 9oct99 34a0795c6fSMarcus Overhagen // 35a0795c6fSMarcus Overhagen // HISTORY 36a0795c6fSMarcus Overhagen // c.lenz 9oct99 Begun 37a0795c6fSMarcus Overhagen 38a0795c6fSMarcus Overhagen #ifndef __MediaNodePanel_H__ 39a0795c6fSMarcus Overhagen #define __MediaNodePanel_H__ 40a0795c6fSMarcus Overhagen 41a0795c6fSMarcus Overhagen // DiagramView 42a0795c6fSMarcus Overhagen #include "DiagramBox.h" 43a0795c6fSMarcus Overhagen // MediaRoutingView 44a0795c6fSMarcus Overhagen #include "MediaJack.h" 45a0795c6fSMarcus Overhagen 46a0795c6fSMarcus Overhagen // STL 47a0795c6fSMarcus Overhagen #include <vector> 48a0795c6fSMarcus Overhagen // Support Kit 49a0795c6fSMarcus Overhagen #include <String.h> 50a0795c6fSMarcus Overhagen 51a0795c6fSMarcus Overhagen #include "IStateArchivable.h" 52a0795c6fSMarcus Overhagen 53a0795c6fSMarcus Overhagen #include "cortex_defs.h" 54a0795c6fSMarcus Overhagen __BEGIN_CORTEX_NAMESPACE 55a0795c6fSMarcus Overhagen 56eb9b1980SIngo Weinhold int compareID(const void *lValue, const void *rValue); 57eb9b1980SIngo Weinhold 58a0795c6fSMarcus Overhagen class MediaIcon; 59a0795c6fSMarcus Overhagen class NodeRef; 60a0795c6fSMarcus Overhagen 61a0795c6fSMarcus Overhagen class MediaNodePanel : public DiagramBox, 62a0795c6fSMarcus Overhagen public BHandler, 63a0795c6fSMarcus Overhagen public IStateArchivable 64a0795c6fSMarcus Overhagen { 65a0795c6fSMarcus Overhagen typedef DiagramBox _inherited; 66a0795c6fSMarcus Overhagen 67a0795c6fSMarcus Overhagen public: // *** constants 68a0795c6fSMarcus Overhagen 69a0795c6fSMarcus Overhagen // [e.moon 26oct99] moved definitions to MediaNodePanel.cpp 70a0795c6fSMarcus Overhagen static float M_DEFAULT_WIDTH; 71a0795c6fSMarcus Overhagen static float M_DEFAULT_HEIGHT; 72a0795c6fSMarcus Overhagen static float M_LABEL_H_MARGIN; 73a0795c6fSMarcus Overhagen static float M_LABEL_V_MARGIN; 74a0795c6fSMarcus Overhagen static float M_BODY_H_MARGIN; 75a0795c6fSMarcus Overhagen static float M_BODY_V_MARGIN; 76a0795c6fSMarcus Overhagen 77a0795c6fSMarcus Overhagen public: // *** accessors 78a0795c6fSMarcus Overhagen 79a0795c6fSMarcus Overhagen NodeRef* const ref; 80a0795c6fSMarcus Overhagen 81a0795c6fSMarcus Overhagen public: // *** ctor/dtor 82a0795c6fSMarcus Overhagen 83a0795c6fSMarcus Overhagen MediaNodePanel( 84a0795c6fSMarcus Overhagen BPoint position, 85a0795c6fSMarcus Overhagen NodeRef *nodeRef); 86a0795c6fSMarcus Overhagen 87a0795c6fSMarcus Overhagen virtual ~MediaNodePanel(); 88a0795c6fSMarcus Overhagen 89a0795c6fSMarcus Overhagen public: // *** derived from DiagramItem 90a0795c6fSMarcus Overhagen 91a0795c6fSMarcus Overhagen virtual void attachedToDiagram(); 92a0795c6fSMarcus Overhagen 93a0795c6fSMarcus Overhagen virtual void detachedFromDiagram(); 94a0795c6fSMarcus Overhagen 955680c33eSIngo Weinhold virtual void DrawBox(); 96a0795c6fSMarcus Overhagen 975680c33eSIngo Weinhold virtual void MouseDown( 98a0795c6fSMarcus Overhagen BPoint point, 99a0795c6fSMarcus Overhagen uint32 buttons, 100a0795c6fSMarcus Overhagen uint32 clicks); 101a0795c6fSMarcus Overhagen 1025680c33eSIngo Weinhold virtual void MouseOver( 103a0795c6fSMarcus Overhagen BPoint point, 104a0795c6fSMarcus Overhagen uint32 transit); 105a0795c6fSMarcus Overhagen 1065680c33eSIngo Weinhold virtual void MessageDropped( 107a0795c6fSMarcus Overhagen BPoint point, 108a0795c6fSMarcus Overhagen BMessage *message); 109a0795c6fSMarcus Overhagen 110a0795c6fSMarcus Overhagen virtual void selected(); 111a0795c6fSMarcus Overhagen 112a0795c6fSMarcus Overhagen virtual void deselected(); 113a0795c6fSMarcus Overhagen 114a0795c6fSMarcus Overhagen public: // *** derived from BHandler 115a0795c6fSMarcus Overhagen 116a0795c6fSMarcus Overhagen virtual void MessageReceived( 117a0795c6fSMarcus Overhagen BMessage *message); 118a0795c6fSMarcus Overhagen 119a0795c6fSMarcus Overhagen public: // *** updating 120a0795c6fSMarcus Overhagen 121a0795c6fSMarcus Overhagen // is called by the MediaRoutingView when the layout 122a0795c6fSMarcus Overhagen // (i.e. icon size, orientation, default sizes) have 123a0795c6fSMarcus Overhagen // changed 124a0795c6fSMarcus Overhagen void layoutChanged( 125a0795c6fSMarcus Overhagen int32 layout); 126a0795c6fSMarcus Overhagen 127a0795c6fSMarcus Overhagen // query the NodeManager for all free inputs & outputs 128a0795c6fSMarcus Overhagen // and add a MediaJack instance for each; (connected 129a0795c6fSMarcus Overhagen // inputs are added when the connection is reported or 130a0795c6fSMarcus Overhagen // queried) 131a0795c6fSMarcus Overhagen void populateInit(); 132a0795c6fSMarcus Overhagen 133a0795c6fSMarcus Overhagen // completely update the list of free input/output jacks 134a0795c6fSMarcus Overhagen void updateIOJacks(); 135a0795c6fSMarcus Overhagen 136a0795c6fSMarcus Overhagen // arrange the MediaJacks in order of their IDs, resize 137a0795c6fSMarcus Overhagen // the panel if more space is needed 138a0795c6fSMarcus Overhagen void arrangeIOJacks(); 139a0795c6fSMarcus Overhagen 140a0795c6fSMarcus Overhagen // display popup-menu at the given point 141a0795c6fSMarcus Overhagen void showContextMenu( 142a0795c6fSMarcus Overhagen BPoint point); 143a0795c6fSMarcus Overhagen 144a0795c6fSMarcus Overhagen public: // *** sorting methods 145a0795c6fSMarcus Overhagen 146a0795c6fSMarcus Overhagen // used for sorting the panels by media_node_id 147a0795c6fSMarcus Overhagen friend int compareID( 148a0795c6fSMarcus Overhagen const void *lValue, 149a0795c6fSMarcus Overhagen const void *rValue); 150a0795c6fSMarcus Overhagen 151a0795c6fSMarcus Overhagen public: // *** IStateArchivable 152a0795c6fSMarcus Overhagen 153a0795c6fSMarcus Overhagen status_t importState( 154a0795c6fSMarcus Overhagen const BMessage* archive); //nyi 155a0795c6fSMarcus Overhagen 156a0795c6fSMarcus Overhagen status_t exportState( 157a0795c6fSMarcus Overhagen BMessage* archive) const; //nyi 158a0795c6fSMarcus Overhagen 159a0795c6fSMarcus Overhagen private: // *** internal operations 160a0795c6fSMarcus Overhagen 161a0795c6fSMarcus Overhagen // fetch node name (shortening as necessary to fit) 162a0795c6fSMarcus Overhagen // and update label placement 163a0795c6fSMarcus Overhagen void _prepareLabel(); 164a0795c6fSMarcus Overhagen 165a0795c6fSMarcus Overhagen // update the offscreen bitmap 166a0795c6fSMarcus Overhagen void _updateBitmap(); 167a0795c6fSMarcus Overhagen 168a0795c6fSMarcus Overhagen void _drawInto( 169a0795c6fSMarcus Overhagen BView *target, 170a0795c6fSMarcus Overhagen BRect targetRect, 171a0795c6fSMarcus Overhagen int32 layout); 172a0795c6fSMarcus Overhagen 173a0795c6fSMarcus Overhagen void _updateIcon( 174a0795c6fSMarcus Overhagen int32 layout); 175a0795c6fSMarcus Overhagen 176a0795c6fSMarcus Overhagen private: // *** data 177a0795c6fSMarcus Overhagen 178a0795c6fSMarcus Overhagen // a pointer to the panel's offscreen bitmap 179a0795c6fSMarcus Overhagen BBitmap *m_bitmap; 180a0795c6fSMarcus Overhagen 181a0795c6fSMarcus Overhagen BBitmap *m_icon; 182a0795c6fSMarcus Overhagen 183a0795c6fSMarcus Overhagen BString m_label; // truncated 184a0795c6fSMarcus Overhagen 185a0795c6fSMarcus Overhagen BString m_fullLabel; // not truncated 186a0795c6fSMarcus Overhagen 187a0795c6fSMarcus Overhagen bool m_labelTruncated; 188a0795c6fSMarcus Overhagen 189a0795c6fSMarcus Overhagen BPoint m_labelOffset; 190a0795c6fSMarcus Overhagen 191a0795c6fSMarcus Overhagen BRect m_labelRect; 192a0795c6fSMarcus Overhagen 193a0795c6fSMarcus Overhagen BRect m_bodyRect; 194a0795c6fSMarcus Overhagen 195a0795c6fSMarcus Overhagen // cached position in the "other" layout 196a0795c6fSMarcus Overhagen BPoint m_alternatePosition; 197a0795c6fSMarcus Overhagen 198a0795c6fSMarcus Overhagen bool m_mouseOverLabel; 199a0795c6fSMarcus Overhagen 200a0795c6fSMarcus Overhagen // [e.moon 7dec99] 201a0795c6fSMarcus Overhagen static const BPoint s_invalidPosition; 202a0795c6fSMarcus Overhagen }; 203a0795c6fSMarcus Overhagen 204a0795c6fSMarcus Overhagen __END_CORTEX_NAMESPACE 205a0795c6fSMarcus Overhagen #endif /* __MediaNodePanel_H__ */ 206