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