2 * Copyright (c) 1999-2000, Eric Moon.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
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.
35 #include "MediaJack.h"
37 #include "MediaRoutingDefs.h"
38 #include "MediaRoutingView.h"
39 #include "MediaWire.h"
41 #include "InfoWindowManager.h"
43 #include "cortex_ui.h"
44 #include "MediaString.h"
46 #include "TipManager.h"
49 #include <Application.h>
53 #include <PopUpMenu.h>
55 __USE_CORTEX_NAMESPACE
58 #define D_METHOD(x) //PRINT (x)
59 #define D_DRAW(x) //PRINT (x)
60 #define D_MOUSE(x) //PRINT (x)
62 // -------------------------------------------------------- //
64 // -------------------------------------------------------- //
66 float MediaJack::M_DEFAULT_WIDTH
= 5.0;
67 float MediaJack::M_DEFAULT_HEIGHT
= 10.0;
68 const float MediaJack::M_DEFAULT_GAP
= 5.0;
69 const int32
MediaJack::M_MAX_ABBR_LENGTH
= 3;
71 // -------------------------------------------------------- //
73 // -------------------------------------------------------- //
77 : DiagramEndPoint(BRect(0.0, 0.0, M_DEFAULT_WIDTH
, M_DEFAULT_HEIGHT
)),
80 m_index(input
.destination
.id
),
82 m_source(input
.source
),
83 m_destination(input
.destination
),
84 m_format(input
.format
),
88 D_METHOD(("MediaJack::MediaJack()\n"));
89 makeSelectable(false);
92 _updateAbbreviation();
97 : DiagramEndPoint(BRect(0.0, 0.0, M_DEFAULT_WIDTH
, M_DEFAULT_HEIGHT
)),
100 m_index(output
.source
.id
),
102 m_source(output
.source
),
103 m_destination(output
.destination
),
104 m_format(output
.format
),
105 m_label(output
.name
),
108 D_METHOD(("MediaJack::MediaJack()\n"));
109 makeSelectable(false);
112 _updateAbbreviation();
115 MediaJack::~MediaJack()
117 D_METHOD(("MediaJack::~MediaJack()\n"));
121 // -------------------------------------------------------- //
123 // -------------------------------------------------------- //
125 status_t
MediaJack::getInput(
126 media_input
*input
) const
128 D_METHOD(("MediaJack::getInput()\n"));
131 input
->node
= m_node
;
132 input
->source
= m_source
;
133 input
->destination
= m_destination
;
134 input
->format
= m_format
;
135 strlcpy(input
->name
, m_label
.String(), B_MEDIA_NAME_LENGTH
);
141 status_t
MediaJack::getOutput(
142 media_output
*output
) const
144 D_METHOD(("MediaJack::getOutput()\n"));
147 output
->node
= m_node
;
148 output
->source
= m_source
;
149 output
->destination
= m_destination
;
150 output
->format
= m_format
;
151 strlcpy(output
->name
, m_label
.String(), B_MEDIA_NAME_LENGTH
);
157 // -------------------------------------------------------- //
158 // *** derived from DiagramEndPoint (public)
159 // -------------------------------------------------------- //
161 void MediaJack::attachedToDiagram()
163 D_METHOD(("MediaJack::attachedToDiagram()\n"));
167 void MediaJack::detachedFromDiagram()
169 D_METHOD(("MediaJack::detachedFromDiagram()\n"));
171 // make sure we're no longer displaying a tooltip
172 TipManager
*tips
= TipManager::Instance();
173 tips
->hideTip(view()->ConvertToScreen(Frame()));
176 void MediaJack::drawEndPoint()
178 D_DRAW(("MediaJack::drawEndPoint()\n"));
182 view()->DrawBitmap(m_bitmap
, Frame().LeftTop());
186 BPoint
MediaJack::connectionPoint() const
188 D_METHOD(("MediaJack::connectionPoint()\n"));
190 switch (dynamic_cast<MediaRoutingView
*>(view())->getLayout())
192 case MediaRoutingView::M_ICON_VIEW
:
196 return BPoint(Frame().left
- 1.0, Frame().top
+ Frame().Height() / 2.0);
200 return BPoint(Frame().right
+ 1.0, Frame().top
+ Frame().Height() / 2.0);
204 case MediaRoutingView::M_MINI_ICON_VIEW
:
208 return BPoint(Frame().left
+ Frame().Width() / 2.0, Frame().top
- 1.0);
212 return BPoint(Frame().left
+ Frame().Width() / 2.0, Frame().bottom
+ 1.0);
217 return BPoint(-1.0, -1.0);
220 bool MediaJack::connectionRequested(
221 DiagramEndPoint
*which
)
223 D_METHOD(("MediaJack::connectionRequested()\n"));
225 MediaJack
*otherJack
= dynamic_cast<MediaJack
*>(which
);
226 if (otherJack
&& (otherJack
->m_jackType
!= m_jackType
) && !isConnected())
233 void MediaJack::MouseDown(
238 D_MOUSE(("MediaJack::MouseOver()\n"));
240 // if connected, redirect to the wire
243 dynamic_cast<MediaWire
*>(wire())->MouseDown(point
, buttons
, clicks
);
247 // else we handle the mouse event ourselves
250 case B_SECONDARY_MOUSE_BUTTON
:
252 showContextMenu(point
);
257 DiagramEndPoint::MouseDown(point
, buttons
, clicks
);
262 void MediaJack::MouseOver(
266 D_MOUSE(("MediaJack::MouseOver()\n"));
271 be_app
->SetCursor(M_CABLE_CURSOR
);
272 TipManager
*tips
= TipManager::Instance();
273 BString tipText
= m_label
.String();
274 tipText
<< " (" << MediaString::getStringFor(m_format
.type
) << ")";
275 tips
->showTip(tipText
.String(),view()->ConvertToScreen(Frame()),
276 TipManager::LEFT_OFFSET_FROM_POINTER
, BPoint(12.0, 8.0));
281 if (!view()->isWireTracking())
283 be_app
->SetCursor(B_HAND_CURSOR
);
290 void MediaJack::MessageDragged(
293 const BMessage
*message
)
295 D_MOUSE(("MediaJack::MessageDragged()\n"));
300 be_app
->SetCursor(M_CABLE_CURSOR
);
305 if (!view()->isWireTracking())
307 be_app
->SetCursor(B_HAND_CURSOR
);
312 DiagramEndPoint::MessageDragged(point
, transit
, message
);
315 void MediaJack::selected()
317 D_METHOD(("MediaJack::selected()\n"));
319 view()->Invalidate(Frame());
322 void MediaJack::deselected()
324 D_METHOD(("MediaJack::deselected()\n"));
326 view()->Invalidate(Frame());
329 void MediaJack::connected()
331 D_METHOD(("MediaJack::connected()\n"));
333 view()->Invalidate(Frame());
336 void MediaJack::disconnected()
338 D_METHOD(("MediaJack::disconnected()\n"));
340 view()->Invalidate(Frame());
343 // -------------------------------------------------------- //
344 // *** operations (public)
345 // -------------------------------------------------------- //
347 void MediaJack::layoutChanged(
350 D_METHOD(("MediaJack::layoutChanged\n"));
351 resizeTo(M_DEFAULT_WIDTH
, M_DEFAULT_HEIGHT
);
355 void MediaJack::setPosition(
357 float leftTopBoundary
,
358 float rightBottomBoundary
,
359 BRegion
*updateRegion
)
361 D_METHOD(("MediaJack::setPosition\n"));
362 switch (dynamic_cast<MediaRoutingView
*>(view())->getLayout())
364 case MediaRoutingView::M_ICON_VIEW
:
368 moveTo(BPoint(leftTopBoundary
, offset
), updateRegion
);
372 moveTo(BPoint(rightBottomBoundary
- Frame().Width(), offset
), updateRegion
);
376 case MediaRoutingView::M_MINI_ICON_VIEW
:
380 moveTo(BPoint(offset
, leftTopBoundary
), updateRegion
);
384 moveTo(BPoint(offset
, rightBottomBoundary
- Frame().Height()), updateRegion
);
391 // -------------------------------------------------------- //
392 // *** internal methods (private)
393 // -------------------------------------------------------- //
395 void MediaJack::_updateBitmap()
397 D_METHOD(("MediaJack::_updateBitmap()\n"));
403 BBitmap
*tempBitmap
= new BBitmap(Frame().OffsetToCopy(0.0, 0.0), B_CMAP8
, true);
406 BView
*tempView
= new BView(tempBitmap
->Bounds(), "", B_FOLLOW_NONE
, 0);
407 tempBitmap
->AddChild(tempView
);
408 tempView
->SetOrigin(0.0, 0.0);
410 MediaRoutingView
* mediaView
= dynamic_cast<MediaRoutingView
*>(view());
411 int32 layout
= mediaView
? mediaView
->getLayout() : MediaRoutingView::M_ICON_VIEW
;
413 _drawInto(tempView
, tempView
->Bounds(), layout
);
416 tempBitmap
->RemoveChild(tempView
);
419 tempBitmap
->Unlock();
420 m_bitmap
= new BBitmap(tempBitmap
);
424 void MediaJack::_drawInto(
429 D_METHOD(("MediaJack::_drawInto()\n"));
431 bool selected
= isConnecting() || isSelected();
434 case MediaRoutingView::M_ICON_VIEW
:
443 target
->SetLowColor(M_GRAY_COLOR
);
445 target
->FillRect(r
, B_SOLID_LOW
);
447 // draw connection point
449 p
.Set(0.0, Frame().Height() / 2.0 - 2.0);
450 target
->BeginLineArray(4);
452 target
->AddLine(r
.LeftTop(),
455 target
->AddLine(r
.LeftTop() + BPoint(1.0, 0.0),
456 p
+ BPoint(1.0, 0.0),
458 target
->AddLine(p
+ BPoint(0.0, 5.0),
461 target
->AddLine(p
+ BPoint(1.0, 5.0),
462 r
.LeftBottom() + BPoint(1.0, 0.0),
465 target
->EndLineArray();
467 if (isConnected() || isConnecting())
469 target
->BeginLineArray(11);
471 target
->AddLine(p
, p
, M_DARK_GRAY_COLOR
);
472 target
->AddLine(p
+ BPoint(0.0, 4.0), p
+ BPoint(0.0, 4.0), M_DARK_GRAY_COLOR
);
473 target
->AddLine(p
+ BPoint(1.0, 0.0), p
+ BPoint(4.0, 0.0), M_DARK_GRAY_COLOR
);
474 target
->AddLine(p
+ BPoint(1.0, 4.0), p
+ BPoint(4.0, 4.0), M_LIGHT_GRAY_COLOR
);
475 target
->AddLine(p
+ BPoint(4.0, 1.0), p
+ BPoint(4.0, 3.0), M_LIGHT_GRAY_COLOR
);
476 target
->AddLine(p
+ BPoint(0.0, 1.0), p
+ BPoint(2.0, 1.0), selected
? M_BLUE_COLOR
: M_DARK_GRAY_COLOR
);
477 target
->AddLine(p
+ BPoint(3.0, 1.0), p
+ BPoint(3.0, 1.0), M_MED_GRAY_COLOR
);
478 target
->AddLine(p
+ BPoint(0.0, 2.0), p
+ BPoint(2.0, 2.0), selected
? M_LIGHT_BLUE_COLOR
: M_LIGHT_GRAY_COLOR
);
479 target
->AddLine(p
+ BPoint(3.0, 2.0), p
+ BPoint(3.0, 2.0), selected
? M_BLUE_COLOR
: M_DARK_GRAY_COLOR
);
480 target
->AddLine(p
+ BPoint(0.0, 3.0), p
+ BPoint(2.0, 3.0), selected
? M_BLUE_COLOR
: M_DARK_GRAY_COLOR
);
481 target
->AddLine(p
+ BPoint(3.0, 3.0), p
+ BPoint(3.0, 3.0), M_MED_GRAY_COLOR
);
483 target
->EndLineArray();
487 target
->BeginLineArray(7);
489 target
->AddLine(p
, p
+ BPoint(0.0, 4.0), M_DARK_GRAY_COLOR
);
490 target
->AddLine(p
+ BPoint(1.0, 0.0), p
+ BPoint(4.0, 0.0), M_DARK_GRAY_COLOR
);
491 target
->AddLine(p
+ BPoint(1.0, 4.0), p
+ BPoint(4.0, 4.0), M_LIGHT_GRAY_COLOR
);
492 target
->AddLine(p
+ BPoint(4.0, 1.0), p
+ BPoint(4.0, 3.0), M_LIGHT_GRAY_COLOR
);
493 target
->AddLine(p
+ BPoint(1.0, 1.0), p
+ BPoint(3.0, 1.0), M_MED_GRAY_COLOR
);
494 target
->AddLine(p
+ BPoint(1.0, 2.0), p
+ BPoint(3.0, 2.0), M_MED_GRAY_COLOR
);
495 target
->AddLine(p
+ BPoint(1.0, 3.0), p
+ BPoint(3.0, 3.0), M_MED_GRAY_COLOR
);
497 target
->EndLineArray();
500 // draw abbreviation string
501 BFont
font(be_plain_font
);
503 font
.SetSize(font
.Size() - 2.0);
506 p
.y
= (Frame().Height() / 2.0) + (fh
.ascent
/ 2.0);
507 target
->SetFont(&font
);
508 target
->SetDrawingMode(B_OP_OVER
);
509 target
->SetHighColor((isConnected() || isConnecting()) ?
512 target
->DrawString(m_abbreviation
.String(), p
);
521 target
->SetLowColor(M_GRAY_COLOR
);
523 target
->FillRect(r
, B_SOLID_LOW
);
525 // draw connection point
527 p
.Set(targetRect
.right
- 4.0, Frame().Height() / 2.0 - 2.0);
528 target
->BeginLineArray(4);
530 target
->AddLine(r
.RightTop(),
531 p
+ BPoint(4.0, 0.0),
533 target
->AddLine(r
.RightTop() + BPoint(-1.0, 0.0),
534 p
+ BPoint(3.0, 0.0),
536 target
->AddLine(p
+ BPoint(4.0, 5.0),
539 target
->AddLine(p
+ BPoint(3.0, 5.0),
540 r
.RightBottom() + BPoint(-1.0, 0.0),
543 target
->EndLineArray();
545 if (isConnected() || isConnecting())
547 target
->BeginLineArray(11);
548 target
->AddLine(p
+ BPoint(4.0, 0.0), p
+ BPoint(4.0, 0.0), M_DARK_GRAY_COLOR
);
549 target
->AddLine(p
+ BPoint(4.0, 4.0), p
+ BPoint(4.0, 4.0), M_DARK_GRAY_COLOR
);
550 target
->AddLine(p
, p
+ BPoint(3.0, 0.0), M_DARK_GRAY_COLOR
);
551 target
->AddLine(p
+ BPoint(0.0, 1.0), p
+ BPoint(0.0, 3.0), M_DARK_GRAY_COLOR
);
552 target
->AddLine(p
+ BPoint(0.0, 4.0), p
+ BPoint(3.0, 4.0), M_LIGHT_GRAY_COLOR
);
553 target
->AddLine(p
+ BPoint(1.0, 1.0), p
+ BPoint(1.0, 1.0), M_MED_GRAY_COLOR
);
554 target
->AddLine(p
+ BPoint(2.0, 1.0), p
+ BPoint(4.0, 1.0), selected
? M_BLUE_COLOR
: M_DARK_GRAY_COLOR
);
555 target
->AddLine(p
+ BPoint(1.0, 2.0), p
+ BPoint(1.0, 2.0), selected
? M_BLUE_COLOR
: M_DARK_GRAY_COLOR
);
556 target
->AddLine(p
+ BPoint(2.0, 2.0), p
+ BPoint(4.0, 2.0), selected
? M_LIGHT_BLUE_COLOR
: M_LIGHT_GRAY_COLOR
);
557 target
->AddLine(p
+ BPoint(1.0, 3.0), p
+ BPoint(1.0, 3.0), M_MED_GRAY_COLOR
);
558 target
->AddLine(p
+ BPoint(2.0, 3.0), p
+ BPoint(4.0, 3.0), selected
? M_BLUE_COLOR
: M_DARK_GRAY_COLOR
);
559 target
->EndLineArray();
563 target
->BeginLineArray(7);
564 target
->AddLine(p
+ BPoint(4.0, 0.0), p
+ BPoint(4.0, 4.0), M_DARK_GRAY_COLOR
);
565 target
->AddLine(p
, p
+ BPoint(3.0, 0.0), M_DARK_GRAY_COLOR
);
566 target
->AddLine(p
+ BPoint(0.0, 1.0), p
+ BPoint(0.0, 3.0), M_DARK_GRAY_COLOR
);
567 target
->AddLine(p
+ BPoint(0.0, 4.0), p
+ BPoint(3.0, 4.0), M_LIGHT_GRAY_COLOR
);
568 target
->AddLine(p
+ BPoint(1.0, 1.0), p
+ BPoint(3.0, 1.0), M_MED_GRAY_COLOR
);
569 target
->AddLine(p
+ BPoint(1.0, 2.0), p
+ BPoint(3.0, 2.0), M_MED_GRAY_COLOR
);
570 target
->AddLine(p
+ BPoint(1.0, 3.0), p
+ BPoint(3.0, 3.0), M_MED_GRAY_COLOR
);
571 target
->EndLineArray();
574 // draw abbreviation string
575 BFont
font(be_plain_font
);
577 font
.SetSize(font
.Size() - 2.0);
579 p
.x
-= font
.StringWidth(m_abbreviation
.String()) + 2.0;
580 p
.y
= (Frame().Height() / 2.0) + (fh
.ascent
/ 2.0);
581 target
->SetFont(&font
);
582 target
->SetDrawingMode(B_OP_OVER
);
583 target
->SetHighColor((isConnected() || isConnecting()) ?
586 target
->DrawString(m_abbreviation
.String(), p
);
590 case MediaRoutingView::M_MINI_ICON_VIEW
:
599 target
->SetLowColor(M_GRAY_COLOR
);
601 target
->FillRect(r
, B_SOLID_LOW
);
603 // draw connection point
605 p
.Set(Frame().Width() / 2.0 - 2.0, 0.0);
606 target
->BeginLineArray(4);
608 target
->AddLine(r
.LeftTop(),
611 target
->AddLine(r
.LeftTop() + BPoint(0.0, 1.0),
612 p
+ BPoint(0.0, 1.0),
614 target
->AddLine(p
+ BPoint(5.0, 0.0),
617 target
->AddLine(p
+ BPoint(5.0, 1.0),
618 r
.RightTop() + BPoint(0.0, 1.0),
621 target
->EndLineArray();
622 if (isConnected() || isConnecting())
624 target
->BeginLineArray(11);
625 target
->AddLine(p
, p
, M_DARK_GRAY_COLOR
);
626 target
->AddLine(p
+ BPoint(4.0, 0.0), p
+ BPoint(4.0, 0.0), M_DARK_GRAY_COLOR
);
627 target
->AddLine(p
+ BPoint(0.0, 1.0), p
+ BPoint(0.0, 4.0), M_DARK_GRAY_COLOR
);
628 target
->AddLine(p
+ BPoint(4.0, 1.0), p
+ BPoint(4.0, 4.0), M_LIGHT_GRAY_COLOR
);
629 target
->AddLine(p
+ BPoint(1.0, 4.0), p
+ BPoint(3.0, 4.0), M_LIGHT_GRAY_COLOR
);
630 target
->AddLine(p
+ BPoint(1.0, 0.0), p
+ BPoint(1.0, 2.0), selected
? M_BLUE_COLOR
: M_DARK_GRAY_COLOR
);
631 target
->AddLine(p
+ BPoint(1.0, 3.0), p
+ BPoint(1.0, 3.0), M_MED_GRAY_COLOR
);
632 target
->AddLine(p
+ BPoint(2.0, 0.0), p
+ BPoint(2.0, 2.0), selected
? M_LIGHT_BLUE_COLOR
: M_LIGHT_GRAY_COLOR
);
633 target
->AddLine(p
+ BPoint(2.0, 3.0), p
+ BPoint(2.0, 3.0), selected
? M_BLUE_COLOR
: M_DARK_GRAY_COLOR
);
634 target
->AddLine(p
+ BPoint(3.0, 0.0), p
+ BPoint(3.0, 2.0), selected
? M_BLUE_COLOR
: M_DARK_GRAY_COLOR
);
635 target
->AddLine(p
+ BPoint(3.0, 3.0), p
+ BPoint(3.0, 3.0), M_MED_GRAY_COLOR
);
636 target
->EndLineArray();
640 target
->BeginLineArray(7);
641 target
->AddLine(p
, p
+ BPoint(4.0, 0.0), M_DARK_GRAY_COLOR
);
642 target
->AddLine(p
+ BPoint(0.0, 1.0), p
+ BPoint(0.0, 4.0), M_DARK_GRAY_COLOR
);
643 target
->AddLine(p
+ BPoint(4.0, 1.0), p
+ BPoint(4.0, 4.0), M_LIGHT_GRAY_COLOR
);
644 target
->AddLine(p
+ BPoint(1.0, 4.0), p
+ BPoint(3.0, 4.0), M_LIGHT_GRAY_COLOR
);
645 target
->AddLine(p
+ BPoint(1.0, 1.0), p
+ BPoint(1.0, 3.0), M_MED_GRAY_COLOR
);
646 target
->AddLine(p
+ BPoint(2.0, 1.0), p
+ BPoint(2.0, 3.0), M_MED_GRAY_COLOR
);
647 target
->AddLine(p
+ BPoint(3.0, 1.0), p
+ BPoint(3.0, 3.0), M_MED_GRAY_COLOR
);
648 target
->EndLineArray();
653 BRect r
= targetRect
;
658 target
->SetLowColor(M_GRAY_COLOR
);
660 target
->FillRect(r
, B_SOLID_LOW
);
662 // draw connection point
664 p
.Set(Frame().Width() / 2.0 - 2.0, targetRect
.bottom
- 4.0);
665 target
->BeginLineArray(4);
667 target
->AddLine(r
.LeftBottom(),
668 p
+ BPoint(0.0, 4.0),
670 target
->AddLine(r
.LeftBottom() + BPoint(0.0, -1.0),
671 p
+ BPoint(0.0, 3.0),
673 target
->AddLine(p
+ BPoint(5.0, 4.0),
676 target
->AddLine(p
+ BPoint(5.0, 3.0),
677 r
.RightBottom() + BPoint(0.0, -1.0),
680 target
->EndLineArray();
681 if (isConnected() || isConnecting())
683 target
->BeginLineArray(11);
684 target
->AddLine(p
+ BPoint(0.0, 4.0), p
+ BPoint(0.0, 4.0), M_DARK_GRAY_COLOR
);
685 target
->AddLine(p
+ BPoint(4.0, 4.0), p
+ BPoint(4.0, 4.0), M_DARK_GRAY_COLOR
);
686 target
->AddLine(p
, p
+ BPoint(0.0, 3.0), M_DARK_GRAY_COLOR
);
687 target
->AddLine(p
+ BPoint(1.0, 0.0), p
+ BPoint(3.0, 0.0), M_DARK_GRAY_COLOR
);
688 target
->AddLine(p
+ BPoint(4.0, 0.0), p
+ BPoint(4.0, 3.0), M_LIGHT_GRAY_COLOR
);
689 target
->AddLine(p
+ BPoint(1.0, 1.0), p
+ BPoint(1.0, 1.0), M_MED_GRAY_COLOR
);
690 target
->AddLine(p
+ BPoint(1.0, 2.0), p
+ BPoint(1.0, 4.0), selected
? M_BLUE_COLOR
: M_DARK_GRAY_COLOR
);
691 target
->AddLine(p
+ BPoint(2.0, 1.0), p
+ BPoint(2.0, 1.0), selected
? M_BLUE_COLOR
: M_DARK_GRAY_COLOR
);
692 target
->AddLine(p
+ BPoint(2.0, 2.0), p
+ BPoint(2.0, 4.0), selected
? M_LIGHT_BLUE_COLOR
: M_LIGHT_GRAY_COLOR
);
693 target
->AddLine(p
+ BPoint(3.0, 1.0), p
+ BPoint(3.0, 1.0), M_MED_GRAY_COLOR
);
694 target
->AddLine(p
+ BPoint(3.0, 2.0), p
+ BPoint(3.0, 4.0), selected
? M_BLUE_COLOR
: M_DARK_GRAY_COLOR
);
695 target
->EndLineArray();
699 target
->BeginLineArray(7);
700 target
->AddLine(p
+ BPoint(0.0, 4.0), p
+ BPoint(4.0, 4.0), M_DARK_GRAY_COLOR
);
701 target
->AddLine(p
, p
+ BPoint(0.0, 3.0), M_DARK_GRAY_COLOR
);
702 target
->AddLine(p
+ BPoint(1.0, 0.0), p
+ BPoint(3.0, 0.0), M_DARK_GRAY_COLOR
);
703 target
->AddLine(p
+ BPoint(4.0, 0.0), p
+ BPoint(4.0, 3.0), M_LIGHT_GRAY_COLOR
);
704 target
->AddLine(p
+ BPoint(1.0, 1.0), p
+ BPoint(1.0, 3.0), M_MED_GRAY_COLOR
);
705 target
->AddLine(p
+ BPoint(2.0, 1.0), p
+ BPoint(2.0, 3.0), M_MED_GRAY_COLOR
);
706 target
->AddLine(p
+ BPoint(3.0, 1.0), p
+ BPoint(3.0, 3.0), M_MED_GRAY_COLOR
);
707 target
->EndLineArray();
715 void MediaJack::_updateAbbreviation()
717 D_METHOD(("MediaJack::_updateAbbreviation()\n"));
721 m_abbreviation
+= m_label
[0];
722 offset
= m_label
.FindFirst(" ") + 1;
723 if ((offset
> 1) && (offset
< m_label
.CountChars() - 1))
724 m_abbreviation
+= m_label
[offset
];
726 m_abbreviation
+= m_label
[1];
727 offset
= m_label
.CountChars() - 1;
728 m_abbreviation
+= m_label
[offset
];
731 // -------------------------------------------------------- //
732 // *** internal operations (protected)
733 // -------------------------------------------------------- //
735 void MediaJack::showContextMenu(
738 D_METHOD(("MediaJack::showContextMenu()\n"));
740 BPopUpMenu
*menu
= new BPopUpMenu("MediaJack PopUp", false, false, B_ITEMS_IN_COLUMN
);
741 menu
->SetFont(be_plain_font
);
744 // add the "Get Info" item
749 BMessage
*message
= new BMessage(InfoWindowManager::M_INFO_WINDOW_REQUESTED
);
750 message
->AddData("input", B_RAW_TYPE
,
751 reinterpret_cast<const void *>(&input
), sizeof(input
));
752 menu
->AddItem(item
= new BMenuItem("Get info", message
));
758 BMessage
*message
= new BMessage(InfoWindowManager::M_INFO_WINDOW_REQUESTED
);
759 message
->AddData("output", B_RAW_TYPE
,
760 reinterpret_cast<const void *>(&output
), sizeof(output
));
761 menu
->AddItem(item
= new BMenuItem("Get info", message
));
764 menu
->SetTargetForItems(view());
765 view()->ConvertToScreen(&point
);
766 point
-= BPoint(1.0, 1.0);
767 menu
->Go(point
, true, true, true);
770 // -------------------------------------------------------- //
771 // *** sorting methods (friend)
772 // -------------------------------------------------------- //
774 int __CORTEX_NAMESPACE__
compareTypeAndID(
779 const MediaJack
*lJack
= *(reinterpret_cast<MediaJack
* const*>(reinterpret_cast<void * const*>(lValue
)));
780 const MediaJack
*rJack
= *(reinterpret_cast<MediaJack
* const*>(reinterpret_cast<void * const*>(rValue
)));
783 if (lJack
->m_jackType
< rJack
->m_jackType
)
787 if (lJack
->m_jackType
== rJack
->m_jackType
)
789 if (lJack
->m_index
< rJack
->m_index
)
798 else if (lJack
->m_jackType
> rJack
->m_jackType
)
806 // END -- LiveNodeView.cpp --