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 // TODO: refactor and remove this: 49 virtual dormant_node_info* NodeInfo() = 0; 50 51 virtual const char* Label() = 0; 52 53 54 static MediaIcons* Icons() {return sIcons;} 55 static void SetIcons(MediaIcons* icons) {sIcons = icons;} 56 57 static int Compare(const void* itemOne, 58 const void* itemTwo); 59 60 // use double dispatch for comparison, 61 // returning item->CompareWith(this) * -1 62 // -1 : < item; 0 : == item; 1 : > item 63 virtual int CompareWith(MediaListItem* item) = 0; 64 virtual int CompareWith(NodeListItem* item) = 0; 65 virtual int CompareWith(DeviceListItem* item) = 0; 66 virtual int CompareWith(AudioMixerListItem* item) = 0; 67 68 protected: 69 struct Renderer; 70 71 virtual void SetRenderParameters(Renderer& renderer) = 0; 72 73 private: 74 75 static MediaIcons* sIcons; 76 }; 77 78 79 class NodeListItem : public MediaListItem { 80 public: 81 NodeListItem(dormant_node_info* node, 82 media_type type); 83 84 void SetMediaType(MediaListItem::media_type type); 85 void SetDefaultOutput(bool isDefault); 86 bool IsDefaultOutput() {return fIsDefaultOutput;} 87 void SetDefaultInput(bool isDefault); 88 bool IsDefaultInput() {return fIsDefaultInput;} 89 90 virtual void AlterWindow(MediaWindow* window); 91 92 // TODO: refactor and remove this: 93 virtual dormant_node_info* NodeInfo(){return fNodeInfo;} 94 95 virtual const char* Label(); 96 media_type Type() {return fMediaType;} 97 98 virtual int CompareWith(MediaListItem* item); 99 100 // -1 : < item; 0 : == item; 1 : > item 101 virtual int CompareWith(NodeListItem* item); 102 virtual int CompareWith(DeviceListItem* item); 103 virtual int CompareWith(AudioMixerListItem* item); 104 105 private: 106 107 virtual void SetRenderParameters(Renderer& renderer); 108 109 dormant_node_info* fNodeInfo; 110 bool fIsAudioMixer; 111 media_type fMediaType; 112 bool fIsDefaultInput; 113 bool fIsDefaultOutput; 114 }; 115 116 117 class DeviceListItem : public MediaListItem { 118 public: 119 DeviceListItem(const char* title, 120 MediaListItem::media_type type); 121 122 MediaListItem::media_type Type() {return fMediaType;} 123 124 // TODO: refactor and remove this: 125 virtual dormant_node_info* NodeInfo(){return NULL;} 126 virtual const char* Label() {return fTitle;} 127 128 virtual void AlterWindow(MediaWindow* window); 129 130 virtual int CompareWith(MediaListItem* item); 131 132 // -1 : < item; 0 : == item; 1 : > item 133 virtual int CompareWith(NodeListItem* item); 134 virtual int CompareWith(DeviceListItem* item); 135 virtual int CompareWith(AudioMixerListItem* item); 136 137 private: 138 virtual void SetRenderParameters(Renderer& renderer); 139 140 const char* fTitle; 141 media_type fMediaType; 142 }; 143 144 145 class AudioMixerListItem : public MediaListItem { 146 public: 147 AudioMixerListItem(const char* title); 148 149 // TODO: refactor and remove this: 150 virtual dormant_node_info* NodeInfo(){return NULL;} 151 152 virtual const char* Label() {return fTitle;} 153 154 virtual void AlterWindow(MediaWindow* window); 155 156 virtual int CompareWith(MediaListItem* item); 157 158 // -1 : < item; 0 : == item; 1 : > item 159 virtual int CompareWith(NodeListItem* item); 160 virtual int CompareWith(DeviceListItem* item); 161 virtual int CompareWith(AudioMixerListItem* item); 162 163 private: 164 virtual void SetRenderParameters(Renderer& renderer); 165 166 const char* fTitle; 167 }; 168 169 #endif /* __MEDIALISTITEM_H__ */ 170