1 // ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
3 // Copyright (c) 2003, OpenBeOS
5 // This software is part of the OpenBeOS distribution and is covered
6 // by the OpenBeOS license.
9 // File: MediaListItem.h
10 // Author: Sikosis, Jérôme Duval
11 // Description: Media Preferences
12 // Created : June 25, 2003
14 // ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
15 #ifndef __MEDIALISTITEM_H__
16 #define __MEDIALISTITEM_H__
20 #include <MediaAddOn.h>
23 struct dormant_node_info
;
28 class AudioMixerListItem
;
34 class MediaListItem
: public BListItem
{
38 virtual void AlterWindow(MediaWindow
* window
) = 0;
45 virtual void Update(BView
* owner
, const BFont
* font
);
46 virtual void DrawItem(BView
* owner
, BRect frame
,
47 bool complete
= false);
49 virtual const char* Label() = 0;
52 static MediaIcons
* Icons() {return sIcons
;}
53 static void SetIcons(MediaIcons
* icons
) {sIcons
= icons
;}
56 virtual void Visit(AudioMixerListItem
* item
) = 0;
57 virtual void Visit(DeviceListItem
* item
) = 0;
58 virtual void Visit(NodeListItem
* item
) = 0;
59 virtual void Visit(MidiListItem
* item
) = 0;
62 virtual void Accept(Visitor
& visitor
) = 0;
64 // use the visitor pattern for comparison,
65 // -1 : < item; 0 : == item; 1 : > item
66 virtual int CompareWith(MediaListItem
* item
) = 0;
68 static int Compare(const void* itemOne
,
74 virtual void SetRenderParameters(Renderer
& renderer
) = 0;
78 static MediaIcons
* sIcons
;
82 class NodeListItem
: public MediaListItem
{
84 NodeListItem(const dormant_node_info
* node
,
87 void SetMediaType(MediaListItem::media_type type
);
88 void SetDefaultOutput(bool isDefault
);
89 bool IsDefaultOutput() {return fIsDefaultOutput
;}
90 void SetDefaultInput(bool isDefault
);
91 bool IsDefaultInput() {return fIsDefaultInput
;}
93 virtual void AlterWindow(MediaWindow
* window
);
95 virtual const char* Label();
96 media_type
Type() {return fMediaType
;}
98 virtual void Accept(MediaListItem::Visitor
& visitor
);
100 struct Comparator
: public MediaListItem::Visitor
{
101 Comparator(NodeListItem
* compareOthersTo
);
102 virtual void Visit(NodeListItem
* item
);
103 virtual void Visit(DeviceListItem
* item
);
104 virtual void Visit(AudioMixerListItem
* item
);
105 virtual void Visit(MidiListItem
* item
);
108 // -1 : < item; 0 : == item; 1 : > item
110 NodeListItem
* fTarget
;
113 // -1 : < item; 0 : == item; 1 : > item
114 virtual int CompareWith(MediaListItem
* item
);
118 virtual void SetRenderParameters(Renderer
& renderer
);
120 const dormant_node_info
* fNodeInfo
;
122 media_type fMediaType
;
123 bool fIsDefaultInput
;
124 bool fIsDefaultOutput
;
128 class DeviceListItem
: public MediaListItem
{
130 DeviceListItem(const char* title
,
131 MediaListItem::media_type type
);
133 MediaListItem::media_type
Type() {return fMediaType
;}
134 virtual const char* Label() {return fTitle
;}
135 virtual void AlterWindow(MediaWindow
* window
);
136 virtual void Accept(MediaListItem::Visitor
& visitor
);
138 struct Comparator
: public MediaListItem::Visitor
{
139 Comparator(DeviceListItem
* compareOthersTo
);
140 virtual void Visit(NodeListItem
* item
);
141 virtual void Visit(DeviceListItem
* item
);
142 virtual void Visit(AudioMixerListItem
* item
);
143 virtual void Visit(MidiListItem
* item
);
146 // -1 : < item; 0 : == item; 1 : > item
148 DeviceListItem
* fTarget
;
151 // -1 : < item; 0 : == item; 1 : > item
152 virtual int CompareWith(MediaListItem
* item
);
155 virtual void SetRenderParameters(Renderer
& renderer
);
158 media_type fMediaType
;
162 class AudioMixerListItem
: public MediaListItem
{
164 AudioMixerListItem(const char* title
);
167 virtual const char* Label() {return fTitle
;}
168 virtual void AlterWindow(MediaWindow
* window
);
169 virtual void Accept(MediaListItem::Visitor
& visitor
);
171 struct Comparator
: public MediaListItem::Visitor
{
172 Comparator(AudioMixerListItem
* compareOthersTo
);
173 virtual void Visit(NodeListItem
* item
);
174 virtual void Visit(DeviceListItem
* item
);
175 virtual void Visit(AudioMixerListItem
* item
);
176 virtual void Visit(MidiListItem
* item
);
179 // -1 : < item; 0 : == item; 1 : > item
181 AudioMixerListItem
* fTarget
;
184 // -1 : < item; 0 : == item; 1 : > item
185 virtual int CompareWith(MediaListItem
* item
);
188 virtual void SetRenderParameters(Renderer
& renderer
);
194 class MidiListItem
: public MediaListItem
{
196 MidiListItem(const char* title
);
198 virtual void AlterWindow(MediaWindow
* window
);
200 virtual const char* Label();
202 virtual void Accept(MediaListItem::Visitor
& visitor
);
204 struct Comparator
: public MediaListItem::Visitor
{
205 Comparator(MidiListItem
* compareOthersTo
);
206 virtual void Visit(NodeListItem
* item
);
207 virtual void Visit(DeviceListItem
* item
);
208 virtual void Visit(AudioMixerListItem
* item
);
209 virtual void Visit(MidiListItem
* item
);
212 // -1 : < item; 0 : == item; 1 : > item
214 MidiListItem
* fTarget
;
217 // -1 : < item; 0 : == item; 1 : > item
218 virtual int CompareWith(MediaListItem
* item
);
222 virtual void SetRenderParameters(Renderer
& renderer
);
226 #endif /* __MEDIALISTITEM_H__ */