1 // MediaJack.h 2 // c.lenz 10oct99 3 // 4 // * PURPOSE 5 // DiagramEndPoint derived class implementing the drawing 6 // code and 7 // 8 // HISTORY 9 // 10 11 #ifndef __MediaJack_H__ 12 #define __MediaJack_H__ 13 14 #include "DiagramEndPoint.h" 15 16 // Media Kit 17 #include <MediaDefs.h> 18 #include <MediaNode.h> 19 // Support Kit 20 #include <String.h> 21 22 class BBitmap; 23 24 #include "cortex_defs.h" 25 __BEGIN_CORTEX_NAMESPACE 26 27 class MediaJack : public DiagramEndPoint 28 { 29 30 public: // *** jack types 31 32 enum jack_t 33 { 34 M_INPUT, 35 M_OUTPUT 36 }; 37 38 public: // *** constants 39 40 // [e.moon 26oct99] moved definitions to MediaJack.cpp 41 static float M_DEFAULT_WIDTH; 42 static float M_DEFAULT_HEIGHT; 43 static const float M_DEFAULT_GAP; 44 static const int32 M_MAX_ABBR_LENGTH; 45 46 public: // *** ctor/dtor 47 48 // Constructor for input jacks 49 MediaJack( 50 media_input input); 51 52 // Constructor for output jacks 53 MediaJack( 54 media_output output); 55 56 virtual ~MediaJack(); 57 58 public: // *** accessors 59 60 // returns the full name of the input/output 61 BString name() const 62 { return m_label; } 63 64 // return true if this is an input jack 65 bool isInput() const 66 { return (m_jackType == M_INPUT); } 67 68 // copies the media_input struct into input; returns 69 // B_ERROR if this isn't an input jack 70 status_t getInput( 71 media_input *input) const; 72 73 // return true if this is an output jack 74 bool isOutput() const 75 { return (m_jackType == M_OUTPUT); } 76 77 // copies the media_output struct into input; returns 78 // B_ERROR if this isn't an input jack 79 status_t getOutput( 80 media_output *output) const; 81 82 public: // *** derived from DiagramEndPoint/Item 83 84 // is called by the parent DiagramBox after adding endpoint 85 virtual void attachedToDiagram(); 86 87 // is called by the parent DiagramBox just before the endpoint 88 // will be removed 89 virtual void detachedFromDiagram(); 90 91 // the actual drawing code 92 virtual void drawEndPoint(); 93 94 // returns the coordinate at which a connected MediaWire is 95 // supposed to start/end 96 virtual BPoint connectionPoint() const; 97 98 // hook called by the base class; just verifies if the jack 99 // type isn't equal, i.e. not connecting an input to an input 100 virtual bool connectionRequested( 101 DiagramEndPoint *which); 102 103 // displays the context menu for right-clicks 104 virtual void mouseDown( 105 BPoint point, 106 uint32 buttons, 107 uint32 clicks); 108 109 // changes the mouse cursor and prepares a tooltip 110 virtual void mouseOver( 111 BPoint point, 112 uint32 transit); 113 114 // changes the mouse cursor 115 virtual void messageDragged( 116 BPoint point, 117 uint32 transit, 118 const BMessage *message); 119 120 // updates the offscreen bitmap 121 virtual void selected(); 122 123 // updates the offscreen bitmap 124 virtual void deselected(); 125 126 // updates the offscreen bitmap 127 virtual void connected(); 128 129 // updates the offscreen bitmap 130 virtual void disconnected(); 131 132 public: // *** operations 133 134 // updates the jacks bitmap 135 void layoutChanged( 136 int32 layout); 137 138 // special function to be called by the parent MediaNodePanel 139 // for simple positioning; this method only needs to know the 140 // vertical offset of the jack and the left/right frame coords 141 // of the panel 142 void setPosition( 143 float verticalOffset, 144 float leftBoundary, 145 float rightBoundary, 146 BRegion *updateRegion = 0); 147 148 protected: // *** operations 149 150 // display a popup-menu at given point 151 void showContextMenu( 152 BPoint point); 153 154 private: // *** internal methods 155 156 // update the offscreen bitmap 157 void _updateBitmap(); 158 159 // draw jack into the specified target view 160 void _drawInto( 161 BView *target, 162 BRect frame, 163 int32 layout); 164 165 // make/update an abbreviation for the jacks name 166 void _updateAbbreviation(); 167 168 public: // *** sorting methods 169 170 // used for sorting; will put input jacks before output jacks 171 // and inside those sort by index 172 friend int compareTypeAndID( 173 const void *lValue, 174 const void *rValue); 175 176 private: // *** data 177 178 int32 m_jackType; 179 BBitmap *m_bitmap; 180 int32 m_index; 181 media_node m_node; 182 media_source m_source; 183 media_destination m_destination; 184 media_format m_format; 185 BString m_label; 186 BString m_abbreviation; 187 }; 188 189 __END_CORTEX_NAMESPACE 190 #endif /* __MediaJack_H__ */ 191