1 /* 2 * Copyright (c) 1999-2000, Eric Moon. 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 9 * 1. Redistributions of source code must retain the above copyright 10 * notice, this list of conditions, and the following disclaimer. 11 * 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. 15 * 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. 18 * 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. 29 */ 30 31 32 // LiveNodeInfoView.cpp 33 34 #include "LiveNodeInfoView.h" 35 // InfoView 36 #include "InfoWindowManager.h" 37 // NodeManager 38 #include "NodeGroup.h" 39 #include "NodeRef.h" 40 // Support 41 #include "MediaIcon.h" 42 #include "MediaString.h" 43 44 // Locale Kit 45 #undef B_CATALOG 46 #define B_CATALOG (&sCatalog) 47 #include <Catalog.h> 48 49 // Media Kit 50 #include <MediaNode.h> 51 52 // Interface Kit 53 #include <Window.h> 54 55 #undef B_TRANSLATION_CONTEXT 56 #define B_TRANSLATION_CONTEXT "LiveNodeInfoView" 57 58 __USE_CORTEX_NAMESPACE 59 60 #include <Debug.h> 61 #define D_METHOD(x) //PRINT (x) 62 #define D_MESSAGE(x) //PRINT (x) 63 64 static BCatalog sCatalog("x-vnd.Cortex.InfoView"); 65 66 // -------------------------------------------------------- // 67 // *** ctor/dtor (public) 68 // -------------------------------------------------------- // 69 70 LiveNodeInfoView::LiveNodeInfoView( 71 const NodeRef *ref) 72 : InfoView(ref->name(), B_TRANSLATE("Live media node"), 73 new MediaIcon(ref->nodeInfo(), B_LARGE_ICON)), 74 m_nodeID(ref->id()) 75 { 76 D_METHOD(("LiveNodeInfoView::LiveNodeInfoView()\n")); 77 78 // adjust view properties 79 setSideBarWidth(be_plain_font->StringWidth(B_TRANSLATE("Run mode")) + 2 * InfoView::M_H_MARGIN); 80 81 // add "Node ID" field 82 BString s; 83 s << ref->id(); 84 addField(B_TRANSLATE("Node ID"), s); 85 86 // add "Port" field 87 s = ""; 88 s << ref->node().port; 89 port_info portInfo; 90 if (get_port_info(ref->node().port, &portInfo) == B_OK) 91 { 92 s << " (" << portInfo.name << ")"; 93 } 94 addField(B_TRANSLATE("Port"), s); 95 96 // add separator field 97 addField("", ""); 98 99 // add "Kinds" field 100 addField(B_TRANSLATE("Kinds"), MediaString::getStringFor(static_cast<node_kind>(ref->kind()))); 101 102 // add "Run Mode" field 103 BMediaNode::run_mode runMode = static_cast<BMediaNode::run_mode>(ref->runMode()); 104 if (runMode < 1) 105 { 106 NodeGroup *group = ref->group(); 107 if (group) 108 { 109 runMode = group->runMode(); 110 } 111 } 112 addField(B_TRANSLATE("Run mode"), MediaString::getStringFor(runMode)); 113 114 // add "Latency" field 115 bigtime_t latency; 116 if (ref->totalLatency(&latency) == B_OK) 117 { 118 s = ""; 119 if (latency > 0) 120 { 121 s << static_cast<float>(latency) / 1000.0f << " ms"; 122 } 123 else 124 { 125 s = "?"; 126 } 127 addField(B_TRANSLATE("Latency"), s); 128 } 129 } 130 131 LiveNodeInfoView::~LiveNodeInfoView() { 132 D_METHOD(("LiveNodeInfoView::~LiveNodeInfoView()\n")); 133 134 } 135 136 // -------------------------------------------------------- // 137 // *** BView implementation (public) 138 // -------------------------------------------------------- // 139 140 void LiveNodeInfoView::DetachedFromWindow() { 141 D_METHOD(("LiveNodeInfoView::DetachedFromWindow()\n")); 142 143 InfoWindowManager *manager = InfoWindowManager::Instance(); 144 if (manager) { 145 BMessage message(InfoWindowManager::M_LIVE_NODE_WINDOW_CLOSED); 146 message.AddInt32("nodeID", m_nodeID); 147 manager->PostMessage(&message); 148 } 149 } 150 151 // END -- LiveNodeInfoView.cpp -- 152