1a0795c6fSMarcus Overhagen // MediaNodePanel.h 2a0795c6fSMarcus Overhagen // c.lenz 9oct99 3a0795c6fSMarcus Overhagen // 4a0795c6fSMarcus Overhagen // HISTORY 5a0795c6fSMarcus Overhagen // c.lenz 9oct99 Begun 6a0795c6fSMarcus Overhagen 7a0795c6fSMarcus Overhagen #ifndef __MediaNodePanel_H__ 8a0795c6fSMarcus Overhagen #define __MediaNodePanel_H__ 9a0795c6fSMarcus Overhagen 10a0795c6fSMarcus Overhagen // DiagramView 11a0795c6fSMarcus Overhagen #include "DiagramBox.h" 12a0795c6fSMarcus Overhagen // MediaRoutingView 13a0795c6fSMarcus Overhagen #include "MediaJack.h" 14a0795c6fSMarcus Overhagen 15a0795c6fSMarcus Overhagen // STL 16a0795c6fSMarcus Overhagen #include <vector> 17a0795c6fSMarcus Overhagen // Support Kit 18a0795c6fSMarcus Overhagen #include <String.h> 19a0795c6fSMarcus Overhagen 20a0795c6fSMarcus Overhagen #include "IStateArchivable.h" 21a0795c6fSMarcus Overhagen 22a0795c6fSMarcus Overhagen #include "cortex_defs.h" 23a0795c6fSMarcus Overhagen __BEGIN_CORTEX_NAMESPACE 24a0795c6fSMarcus Overhagen 25eb9b1980SIngo Weinhold int compareID(const void *lValue, const void *rValue); 26eb9b1980SIngo Weinhold 27a0795c6fSMarcus Overhagen class MediaIcon; 28a0795c6fSMarcus Overhagen class NodeRef; 29a0795c6fSMarcus Overhagen 30a0795c6fSMarcus Overhagen class MediaNodePanel : public DiagramBox, 31a0795c6fSMarcus Overhagen public BHandler, 32a0795c6fSMarcus Overhagen public IStateArchivable 33a0795c6fSMarcus Overhagen { 34a0795c6fSMarcus Overhagen typedef DiagramBox _inherited; 35a0795c6fSMarcus Overhagen 36a0795c6fSMarcus Overhagen public: // *** constants 37a0795c6fSMarcus Overhagen 38a0795c6fSMarcus Overhagen // [e.moon 26oct99] moved definitions to MediaNodePanel.cpp 39a0795c6fSMarcus Overhagen static float M_DEFAULT_WIDTH; 40a0795c6fSMarcus Overhagen static float M_DEFAULT_HEIGHT; 41a0795c6fSMarcus Overhagen static float M_LABEL_H_MARGIN; 42a0795c6fSMarcus Overhagen static float M_LABEL_V_MARGIN; 43a0795c6fSMarcus Overhagen static float M_BODY_H_MARGIN; 44a0795c6fSMarcus Overhagen static float M_BODY_V_MARGIN; 45a0795c6fSMarcus Overhagen 46a0795c6fSMarcus Overhagen public: // *** accessors 47a0795c6fSMarcus Overhagen 48a0795c6fSMarcus Overhagen NodeRef* const ref; 49a0795c6fSMarcus Overhagen 50a0795c6fSMarcus Overhagen public: // *** ctor/dtor 51a0795c6fSMarcus Overhagen 52a0795c6fSMarcus Overhagen MediaNodePanel( 53a0795c6fSMarcus Overhagen BPoint position, 54a0795c6fSMarcus Overhagen NodeRef *nodeRef); 55a0795c6fSMarcus Overhagen 56a0795c6fSMarcus Overhagen virtual ~MediaNodePanel(); 57a0795c6fSMarcus Overhagen 58a0795c6fSMarcus Overhagen public: // *** derived from DiagramItem 59a0795c6fSMarcus Overhagen 60a0795c6fSMarcus Overhagen virtual void attachedToDiagram(); 61a0795c6fSMarcus Overhagen 62a0795c6fSMarcus Overhagen virtual void detachedFromDiagram(); 63a0795c6fSMarcus Overhagen 64*5680c33eSIngo Weinhold virtual void DrawBox(); 65a0795c6fSMarcus Overhagen 66*5680c33eSIngo Weinhold virtual void MouseDown( 67a0795c6fSMarcus Overhagen BPoint point, 68a0795c6fSMarcus Overhagen uint32 buttons, 69a0795c6fSMarcus Overhagen uint32 clicks); 70a0795c6fSMarcus Overhagen 71*5680c33eSIngo Weinhold virtual void MouseOver( 72a0795c6fSMarcus Overhagen BPoint point, 73a0795c6fSMarcus Overhagen uint32 transit); 74a0795c6fSMarcus Overhagen 75*5680c33eSIngo Weinhold virtual void MessageDropped( 76a0795c6fSMarcus Overhagen BPoint point, 77a0795c6fSMarcus Overhagen BMessage *message); 78a0795c6fSMarcus Overhagen 79a0795c6fSMarcus Overhagen virtual void selected(); 80a0795c6fSMarcus Overhagen 81a0795c6fSMarcus Overhagen virtual void deselected(); 82a0795c6fSMarcus Overhagen 83a0795c6fSMarcus Overhagen public: // *** derived from BHandler 84a0795c6fSMarcus Overhagen 85a0795c6fSMarcus Overhagen virtual void MessageReceived( 86a0795c6fSMarcus Overhagen BMessage *message); 87a0795c6fSMarcus Overhagen 88a0795c6fSMarcus Overhagen public: // *** updating 89a0795c6fSMarcus Overhagen 90a0795c6fSMarcus Overhagen // is called by the MediaRoutingView when the layout 91a0795c6fSMarcus Overhagen // (i.e. icon size, orientation, default sizes) have 92a0795c6fSMarcus Overhagen // changed 93a0795c6fSMarcus Overhagen void layoutChanged( 94a0795c6fSMarcus Overhagen int32 layout); 95a0795c6fSMarcus Overhagen 96a0795c6fSMarcus Overhagen // query the NodeManager for all free inputs & outputs 97a0795c6fSMarcus Overhagen // and add a MediaJack instance for each; (connected 98a0795c6fSMarcus Overhagen // inputs are added when the connection is reported or 99a0795c6fSMarcus Overhagen // queried) 100a0795c6fSMarcus Overhagen void populateInit(); 101a0795c6fSMarcus Overhagen 102a0795c6fSMarcus Overhagen // completely update the list of free input/output jacks 103a0795c6fSMarcus Overhagen void updateIOJacks(); 104a0795c6fSMarcus Overhagen 105a0795c6fSMarcus Overhagen // arrange the MediaJacks in order of their IDs, resize 106a0795c6fSMarcus Overhagen // the panel if more space is needed 107a0795c6fSMarcus Overhagen void arrangeIOJacks(); 108a0795c6fSMarcus Overhagen 109a0795c6fSMarcus Overhagen // display popup-menu at the given point 110a0795c6fSMarcus Overhagen void showContextMenu( 111a0795c6fSMarcus Overhagen BPoint point); 112a0795c6fSMarcus Overhagen 113a0795c6fSMarcus Overhagen public: // *** sorting methods 114a0795c6fSMarcus Overhagen 115a0795c6fSMarcus Overhagen // used for sorting the panels by media_node_id 116a0795c6fSMarcus Overhagen friend int compareID( 117a0795c6fSMarcus Overhagen const void *lValue, 118a0795c6fSMarcus Overhagen const void *rValue); 119a0795c6fSMarcus Overhagen 120a0795c6fSMarcus Overhagen public: // *** IStateArchivable 121a0795c6fSMarcus Overhagen 122a0795c6fSMarcus Overhagen status_t importState( 123a0795c6fSMarcus Overhagen const BMessage* archive); //nyi 124a0795c6fSMarcus Overhagen 125a0795c6fSMarcus Overhagen status_t exportState( 126a0795c6fSMarcus Overhagen BMessage* archive) const; //nyi 127a0795c6fSMarcus Overhagen 128a0795c6fSMarcus Overhagen private: // *** internal operations 129a0795c6fSMarcus Overhagen 130a0795c6fSMarcus Overhagen // fetch node name (shortening as necessary to fit) 131a0795c6fSMarcus Overhagen // and update label placement 132a0795c6fSMarcus Overhagen void _prepareLabel(); 133a0795c6fSMarcus Overhagen 134a0795c6fSMarcus Overhagen // update the offscreen bitmap 135a0795c6fSMarcus Overhagen void _updateBitmap(); 136a0795c6fSMarcus Overhagen 137a0795c6fSMarcus Overhagen void _drawInto( 138a0795c6fSMarcus Overhagen BView *target, 139a0795c6fSMarcus Overhagen BRect targetRect, 140a0795c6fSMarcus Overhagen int32 layout); 141a0795c6fSMarcus Overhagen 142a0795c6fSMarcus Overhagen void _updateIcon( 143a0795c6fSMarcus Overhagen int32 layout); 144a0795c6fSMarcus Overhagen 145a0795c6fSMarcus Overhagen private: // *** data 146a0795c6fSMarcus Overhagen 147a0795c6fSMarcus Overhagen // a pointer to the panel's offscreen bitmap 148a0795c6fSMarcus Overhagen BBitmap *m_bitmap; 149a0795c6fSMarcus Overhagen 150a0795c6fSMarcus Overhagen BBitmap *m_icon; 151a0795c6fSMarcus Overhagen 152a0795c6fSMarcus Overhagen BString m_label; // truncated 153a0795c6fSMarcus Overhagen 154a0795c6fSMarcus Overhagen BString m_fullLabel; // not truncated 155a0795c6fSMarcus Overhagen 156a0795c6fSMarcus Overhagen bool m_labelTruncated; 157a0795c6fSMarcus Overhagen 158a0795c6fSMarcus Overhagen BPoint m_labelOffset; 159a0795c6fSMarcus Overhagen 160a0795c6fSMarcus Overhagen BRect m_labelRect; 161a0795c6fSMarcus Overhagen 162a0795c6fSMarcus Overhagen BRect m_bodyRect; 163a0795c6fSMarcus Overhagen 164a0795c6fSMarcus Overhagen // cached position in the "other" layout 165a0795c6fSMarcus Overhagen BPoint m_alternatePosition; 166a0795c6fSMarcus Overhagen 167a0795c6fSMarcus Overhagen bool m_mouseOverLabel; 168a0795c6fSMarcus Overhagen 169a0795c6fSMarcus Overhagen // [e.moon 7dec99] 170a0795c6fSMarcus Overhagen static const BPoint s_invalidPosition; 171a0795c6fSMarcus Overhagen }; 172a0795c6fSMarcus Overhagen 173a0795c6fSMarcus Overhagen __END_CORTEX_NAMESPACE 174a0795c6fSMarcus Overhagen #endif /* __MediaNodePanel_H__ */ 175