vfs: check userland buffers before reading them.
[haiku.git] / src / preferences / media / MediaListItem.h
blob5aa050bee965290181494745848ec7558845c689
1 // ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
2 //
3 // Copyright (c) 2003, OpenBeOS
4 //
5 // This software is part of the OpenBeOS distribution and is covered
6 // by the MIT License.
7 //
8 //
9 // File: MediaListItem.h
10 // Author: Sikosis, Jérôme Duval
11 // Description: Media Preferences
12 // Created : June 25, 2003
13 //
14 // ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
15 #ifndef __MEDIALISTITEM_H__
16 #define __MEDIALISTITEM_H__
19 #include <ListItem.h>
20 #include <MediaAddOn.h>
23 struct dormant_node_info;
25 class MediaIcons;
26 class MediaWindow;
28 class AudioMixerListItem;
29 class DeviceListItem;
30 class MidiListItem;
31 class NodeListItem;
34 class MediaListItem : public BListItem {
35 public:
36 MediaListItem();
38 virtual void AlterWindow(MediaWindow* window) = 0;
40 enum media_type {
41 AUDIO_TYPE,
42 VIDEO_TYPE
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;}
55 struct Visitor {
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,
69 const void* itemTwo);
71 protected:
72 struct Renderer;
74 virtual void SetRenderParameters(Renderer& renderer) = 0;
76 private:
78 static MediaIcons* sIcons;
82 class NodeListItem : public MediaListItem {
83 public:
84 NodeListItem(const dormant_node_info* node,
85 media_type type);
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);
107 int result;
108 // -1 : < item; 0 : == item; 1 : > item
109 private:
110 NodeListItem* fTarget;
113 // -1 : < item; 0 : == item; 1 : > item
114 virtual int CompareWith(MediaListItem* item);
116 private:
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 {
129 public:
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);
145 int result;
146 // -1 : < item; 0 : == item; 1 : > item
147 private:
148 DeviceListItem* fTarget;
151 // -1 : < item; 0 : == item; 1 : > item
152 virtual int CompareWith(MediaListItem* item);
154 private:
155 virtual void SetRenderParameters(Renderer& renderer);
157 const char* fTitle;
158 media_type fMediaType;
162 class AudioMixerListItem : public MediaListItem {
163 public:
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);
178 int result;
179 // -1 : < item; 0 : == item; 1 : > item
180 private:
181 AudioMixerListItem* fTarget;
184 // -1 : < item; 0 : == item; 1 : > item
185 virtual int CompareWith(MediaListItem* item);
187 private:
188 virtual void SetRenderParameters(Renderer& renderer);
190 const char* fTitle;
194 class MidiListItem : public MediaListItem {
195 public:
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);
211 int result;
212 // -1 : < item; 0 : == item; 1 : > item
213 private:
214 MidiListItem* fTarget;
217 // -1 : < item; 0 : == item; 1 : > item
218 virtual int CompareWith(MediaListItem* item);
220 private:
222 virtual void SetRenderParameters(Renderer& renderer);
224 const char* fTitle;
226 #endif /* __MEDIALISTITEM_H__ */