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.
32 // DormantNodeInfoView.cpp
34 #include "DormantNodeInfoView.h"
36 #include "InfoWindowManager.h"
38 #include "MediaIcon.h"
39 #include "MediaString.h"
42 #include <MediaAddOn.h>
43 #include <MediaRoster.h>
45 __USE_CORTEX_NAMESPACE
48 #define D_METHOD(x) //PRINT (x)
50 // -------------------------------------------------------- //
51 // *** ctor/dtor (public)
52 // -------------------------------------------------------- //
54 DormantNodeInfoView::DormantNodeInfoView(
55 const dormant_node_info
&info
)
56 : InfoView(info
.name
, "Dormant media node",
57 new MediaIcon(info
, B_LARGE_ICON
)),
58 m_addOnID(info
.addon
),
59 m_flavorID(info
.flavor_id
)
61 D_METHOD(("DormantNodeInfoView::DormantNodeInfoView()\n"));
63 // adjust view properties
64 setSideBarWidth(be_plain_font
->StringWidth(" Output Formats ") + 2 * InfoView::M_H_MARGIN
);
68 // add the "AddOn ID" field
71 addField("AddOn ID", s
);
73 // add the "Flavor ID" field
76 addField("Flavor ID", s
);
78 // add separator field
81 dormant_flavor_info flavorInfo
;
82 BMediaRoster
*roster
= BMediaRoster::Roster();
83 if (roster
&& (roster
->GetDormantFlavorInfoFor(info
, &flavorInfo
) == B_OK
))
85 // add the "Description" field
87 addField("Description", s
);
90 addField("Kinds", MediaString::getStringFor(static_cast<node_kind
>(flavorInfo
.kinds
)));
92 // add "Flavor Flags" field
93 addField("Flavor flags", "?");
95 // add "Max. instances" field
96 if (flavorInfo
.possible_count
> 0)
99 s
<< flavorInfo
.possible_count
;
105 addField("Max. instances", s
);
107 // add "Input Formats" field
108 if (flavorInfo
.in_format_count
> 0)
110 if (flavorInfo
.in_format_count
== 1)
112 addField("Input format", MediaString::getStringFor(flavorInfo
.in_formats
[0], false));
116 addField("Input formats", "");
117 for (int32 i
= 0; i
< flavorInfo
.in_format_count
; i
++)
120 s
<< "(" << i
+ 1 << ")";
121 addField(s
, MediaString::getStringFor(flavorInfo
.in_formats
[i
], false));
126 // add "Output Formats" field
127 if (flavorInfo
.out_format_count
> 0)
129 if (flavorInfo
.out_format_count
== 1)
131 addField("Output format", MediaString::getStringFor(flavorInfo
.out_formats
[0], false));
135 addField("Output formats", "");
136 for (int32 i
= 0; i
< flavorInfo
.out_format_count
; i
++)
139 s
<< "(" << i
+ 1 << ")";
140 addField(s
, MediaString::getStringFor(flavorInfo
.out_formats
[i
], false));
147 DormantNodeInfoView::~DormantNodeInfoView()
149 D_METHOD(("DormantNodeInfoView::~DormantNodeInfoView()\n"));
152 // -------------------------------------------------------- //
153 // *** BView implementation (public)
154 // -------------------------------------------------------- //
156 void DormantNodeInfoView::DetachedFromWindow() {
157 D_METHOD(("DormantNodeInfoView::DetachedFromWindow()\n"));
159 InfoWindowManager
*manager
= InfoWindowManager::Instance();
161 BMessage
message(InfoWindowManager::M_DORMANT_NODE_WINDOW_CLOSED
);
162 message
.AddInt32("addOnID", m_addOnID
);
163 message
.AddInt32("flavorID", m_flavorID
);
164 manager
->PostMessage(&message
);
168 // END -- DormantNodeInfoView.cpp --