1 // ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ 2 // 3 // Copyright (c) 2003, OpenBeOS 4 // 5 // This software is part of the OpenBeOS distribution and is covered 6 // by the OpenBeOS 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 NodeListItem; 31 32 33 class MediaListItem : public BListItem { 34 public: 35 MediaListItem(); 36 37 virtual void AlterWindow(MediaWindow* window) = 0; 38 39 enum media_type { 40 AUDIO_TYPE, 41 VIDEO_TYPE 42 }; 43 44 virtual void Update(BView* owner, const BFont* font); 45 virtual void DrawItem(BView* owner, BRect frame, 46 bool complete = false); 47 48 virtual const char* Label() = 0; 49 50 51 static MediaIcons* Icons() {return sIcons;} 52 static void SetIcons(MediaIcons* icons) {sIcons = icons;} 53 54 struct Visitor { 55 virtual void Visit(AudioMixerListItem* item) = 0; 56 virtual void Visit(DeviceListItem* item) = 0; 57 virtual void Visit(NodeListItem* item) = 0; 58 }; 59 60 virtual void Accept(Visitor& visitor) = 0; 61 62 // use the visitor pattern for comparison, 63 // -1 : < item; 0 : == item; 1 : > item 64 virtual int CompareWith(MediaListItem* item) = 0; 65 66 static int Compare(const void* itemOne, 67 const void* itemTwo); 68 69 protected: 70 struct Renderer; 71 72 virtual void SetRenderParameters(Renderer& renderer) = 0; 73 74 private: 75 76 static MediaIcons* sIcons; 77 }; 78 79 80 class NodeListItem : public MediaListItem { 81 public: 82 NodeListItem(const dormant_node_info* node, 83 media_type type); 84 85 void SetMediaType(MediaListItem::media_type type); 86 void SetDefaultOutput(bool isDefault); 87 bool IsDefaultOutput() {return fIsDefaultOutput;} 88 void SetDefaultInput(bool isDefault); 89 bool IsDefaultInput() {return fIsDefaultInput;} 90 91 virtual void AlterWindow(MediaWindow* window); 92 93 virtual const char* Label(); 94 media_type Type() {return fMediaType;} 95 96 virtual void Accept(MediaListItem::Visitor& visitor); 97 98 struct Comparator : public MediaListItem::Visitor { 99 Comparator(NodeListItem* compareOthersTo); 100 virtual void Visit(NodeListItem* item); 101 virtual void Visit(DeviceListItem* item); 102 virtual void Visit(AudioMixerListItem* item); 103 104 int result; 105 // -1 : < item; 0 : == item; 1 : > item 106 private: 107 NodeListItem* fTarget; 108 }; 109 110 // -1 : < item; 0 : == item; 1 : > item 111 virtual int CompareWith(MediaListItem* item); 112 113 private: 114 115 virtual void SetRenderParameters(Renderer& renderer); 116 117 const dormant_node_info* fNodeInfo; 118 119 media_type fMediaType; 120 bool fIsDefaultInput; 121 bool fIsDefaultOutput; 122 }; 123 124 125 class DeviceListItem : public MediaListItem { 126 public: 127 DeviceListItem(const char* title, 128 MediaListItem::media_type type); 129 130 MediaListItem::media_type Type() {return fMediaType;} 131 virtual const char* Label() {return fTitle;} 132 virtual void AlterWindow(MediaWindow* window); 133 virtual void Accept(MediaListItem::Visitor& visitor); 134 135 struct Comparator : public MediaListItem::Visitor { 136 Comparator(DeviceListItem* compareOthersTo); 137 virtual void Visit(NodeListItem* item); 138 virtual void Visit(DeviceListItem* item); 139 virtual void Visit(AudioMixerListItem* item); 140 141 int result; 142 // -1 : < item; 0 : == item; 1 : > item 143 private: 144 DeviceListItem* fTarget; 145 }; 146 147 // -1 : < item; 0 : == item; 1 : > item 148 virtual int CompareWith(MediaListItem* item); 149 150 private: 151 virtual void SetRenderParameters(Renderer& renderer); 152 153 const char* fTitle; 154 media_type fMediaType; 155 }; 156 157 158 class AudioMixerListItem : public MediaListItem { 159 public: 160 AudioMixerListItem(const char* title); 161 162 163 virtual const char* Label() {return fTitle;} 164 virtual void AlterWindow(MediaWindow* window); 165 virtual void Accept(MediaListItem::Visitor& visitor); 166 167 struct Comparator : public MediaListItem::Visitor { 168 Comparator(AudioMixerListItem* compareOthersTo); 169 virtual void Visit(NodeListItem* item); 170 virtual void Visit(DeviceListItem* item); 171 virtual void Visit(AudioMixerListItem* item); 172 173 int result; 174 // -1 : < item; 0 : == item; 1 : > item 175 private: 176 AudioMixerListItem* fTarget; 177 }; 178 179 // -1 : < item; 0 : == item; 1 : > item 180 virtual int CompareWith(MediaListItem* item); 181 182 private: 183 virtual void SetRenderParameters(Renderer& renderer); 184 185 const char* fTitle; 186 }; 187 188 #endif /* __MEDIALISTITEM_H__ */ 189