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__ 17 18 19 #include <ListItem.h> 20 #include <MediaAddOn.h> 21 22 23 struct dormant_node_info; 24 25 class MediaIcons; 26 class MediaWindow; 27 28 class AudioMixerListItem; 29 class DeviceListItem; 30 class MidiListItem; 31 class NodeListItem; 32 33 34 class MediaListItem : public BListItem { 35 public: 36 MediaListItem(); 37 38 virtual void AlterWindow(MediaWindow* window) = 0; 39 40 enum media_type { 41 AUDIO_TYPE, 42 VIDEO_TYPE 43 }; 44 45 virtual void Update(BView* owner, const BFont* font); 46 virtual void DrawItem(BView* owner, BRect frame, 47 bool complete = false); 48 49 virtual const char* Label() = 0; 50 51 52 static MediaIcons* Icons() {return sIcons;} 53 static void SetIcons(MediaIcons* icons) {sIcons = icons;} 54 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; 60 }; 61 62 virtual void Accept(Visitor& visitor) = 0; 63 64 // use the visitor pattern for comparison, 65 // -1 : < item; 0 : == item; 1 : > item 66 virtual int CompareWith(MediaListItem* item) = 0; 67 68 static int Compare(const void* itemOne, 69 const void* itemTwo); 70 71 protected: 72 struct Renderer; 73 74 virtual void SetRenderParameters(Renderer& renderer) = 0; 75 76 private: 77 78 static MediaIcons* sIcons; 79 }; 80 81 82 class NodeListItem : public MediaListItem { 83 public: 84 NodeListItem(const dormant_node_info* node, 85 media_type type); 86 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;} 92 93 virtual void AlterWindow(MediaWindow* window); 94 95 virtual const char* Label(); 96 media_type Type() {return fMediaType;} 97 98 virtual void Accept(MediaListItem::Visitor& visitor); 99 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); 106 107 int result; 108 // -1 : < item; 0 : == item; 1 : > item 109 private: 110 NodeListItem* fTarget; 111 }; 112 113 // -1 : < item; 0 : == item; 1 : > item 114 virtual int CompareWith(MediaListItem* item); 115 116 private: 117 118 virtual void SetRenderParameters(Renderer& renderer); 119 120 const dormant_node_info* fNodeInfo; 121 122 media_type fMediaType; 123 bool fIsDefaultInput; 124 bool fIsDefaultOutput; 125 }; 126 127 128 class DeviceListItem : public MediaListItem { 129 public: 130 DeviceListItem(const char* title, 131 MediaListItem::media_type type); 132 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); 137 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); 144 145 int result; 146 // -1 : < item; 0 : == item; 1 : > item 147 private: 148 DeviceListItem* fTarget; 149 }; 150 151 // -1 : < item; 0 : == item; 1 : > item 152 virtual int CompareWith(MediaListItem* item); 153 154 private: 155 virtual void SetRenderParameters(Renderer& renderer); 156 157 const char* fTitle; 158 media_type fMediaType; 159 }; 160 161 162 class AudioMixerListItem : public MediaListItem { 163 public: 164 AudioMixerListItem(const char* title); 165 166 167 virtual const char* Label() {return fTitle;} 168 virtual void AlterWindow(MediaWindow* window); 169 virtual void Accept(MediaListItem::Visitor& visitor); 170 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); 177 178 int result; 179 // -1 : < item; 0 : == item; 1 : > item 180 private: 181 AudioMixerListItem* fTarget; 182 }; 183 184 // -1 : < item; 0 : == item; 1 : > item 185 virtual int CompareWith(MediaListItem* item); 186 187 private: 188 virtual void SetRenderParameters(Renderer& renderer); 189 190 const char* fTitle; 191 }; 192 193 194 class MidiListItem : public MediaListItem { 195 public: 196 MidiListItem(const char* title); 197 198 virtual void AlterWindow(MediaWindow* window); 199 200 virtual const char* Label(); 201 202 virtual void Accept(MediaListItem::Visitor& visitor); 203 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); 210 211 int result; 212 // -1 : < item; 0 : == item; 1 : > item 213 private: 214 MidiListItem* fTarget; 215 }; 216 217 // -1 : < item; 0 : == item; 1 : > item 218 virtual int CompareWith(MediaListItem* item); 219 220 private: 221 222 virtual void SetRenderParameters(Renderer& renderer); 223 224 const char* fTitle; 225 }; 226 #endif /* __MEDIALISTITEM_H__ */ 227