1 // ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ 2 // 3 // Copyright (c) 2003, Haiku 4 // 5 // This software is part of the Haiku distribution and is covered 6 // by the MIT License. 7 // 8 // 9 // File: MediaViews.h 10 // Author: Sikosis, Jérôme Duval 11 // Description: Media Preferences 12 // Created : June 25, 2003 13 // 14 // ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ 15 #ifndef __MEDIAVIEWS_H__ 16 #define __MEDIAVIEWS_H__ 17 #include <GroupView.h> 18 #include <MediaAddOn.h> 19 #include <MenuItem.h> 20 21 #include <ObjectList.h> 22 23 24 class BBox; 25 class BButton; 26 class BCheckBox; 27 class BMenu; 28 class BMenuField; 29 class BString; 30 class BStringView; 31 32 class MediaWindow; 33 34 35 const uint32 ML_RESTART_MEDIA_SERVER = 'resr'; 36 const uint32 ML_DEFAULT_CHANNEL_CHANGED = 'chch'; 37 38 39 class NodeMenuItem : public BMenuItem 40 { 41 public: 42 NodeMenuItem(const dormant_node_info* info, 43 BMessage* message, char shortcut = 0, 44 uint32 modifiers = 0); 45 virtual status_t Invoke(BMessage* message = NULL); 46 47 const dormant_node_info* NodeInfo() const {return fInfo;} 48 private: 49 50 const dormant_node_info* fInfo; 51 }; 52 53 54 class ChannelMenuItem : public BMenuItem 55 { 56 public: 57 ChannelMenuItem(media_input* input, 58 BMessage* message, char shortcut = 0, 59 uint32 modifiers = 0); 60 virtual ~ChannelMenuItem(); 61 62 int32 DestinationID(); 63 media_input* Input(); 64 65 virtual status_t Invoke(BMessage* message = NULL); 66 67 private: 68 media_input* fInput; 69 }; 70 71 72 class SettingsView : public BGroupView 73 { 74 public: 75 typedef BObjectList<dormant_node_info> NodeList; 76 77 SettingsView(); 78 void AddInputNodes(NodeList& nodes); 79 void AddOutputNodes(NodeList& nodes); 80 81 virtual void SetDefaultInput(const dormant_node_info* info); 82 virtual void SetDefaultOutput(const dormant_node_info* info); 83 84 virtual void MessageReceived(BMessage* message); 85 virtual void AttachedToWindow(); 86 87 88 protected: 89 90 BMenu* InputMenu() {return fInputMenu;} 91 BMenu* OutputMenu() {return fOutputMenu;} 92 93 BButton* MakeRestartButton(); 94 95 void _EmptyMenu(BMenu* menu); 96 MediaWindow* _MediaWindow() const; 97 98 private: 99 void _PopulateMenu(BMenu* menu, NodeList& nodes, 100 const BMessage& message); 101 NodeMenuItem* _FindNodeItem(BMenu* menu, 102 const dormant_node_info* nodeInfo); 103 void _ClearMenuSelection(BMenu* menu); 104 105 BMenu* fInputMenu; 106 BMenu* fOutputMenu; 107 }; 108 109 110 class AudioSettingsView : public SettingsView 111 { 112 public: 113 AudioSettingsView(); 114 115 void SetDefaultChannel(int32 channelID); 116 117 virtual void SetDefaultInput(const dormant_node_info* info); 118 virtual void SetDefaultOutput(const dormant_node_info* info); 119 120 virtual void MessageReceived(BMessage* message); 121 virtual void AttachedToWindow(); 122 123 private: 124 BMenuField* _MakeChannelMenu(); 125 BCheckBox* _MakeVolumeCheckBox(); 126 void _FillChannelMenu(const dormant_node_info* info); 127 128 void _ShowDeskbarVolumeControl(); 129 void _HideDeskbarVolumeControl(); 130 131 ChannelMenuItem* _ChannelMenuItemAt(int32 index); 132 133 BMenu* fChannelMenu; 134 BCheckBox* fVolumeCheckBox; 135 }; 136 137 138 class VideoSettingsView : public SettingsView 139 { 140 public: 141 VideoSettingsView(); 142 143 virtual void SetDefaultInput(const dormant_node_info* info); 144 virtual void SetDefaultOutput(const dormant_node_info* info); 145 }; 146 147 #endif 148