foobar2000 SDK  2015-08-03
ui.h
Go to the documentation of this file.
1 #ifndef _WINDOWS
2 #error PORTME
3 #endif
4 
7 class NOVTABLE user_interface : public service_base {
8 public:
11  typedef BOOL (WINAPI * HookProc_t)(HWND wnd,UINT msg,WPARAM wp,LPARAM lp,LRESULT * ret);
12 
14  virtual const char * get_name()=0;
16  virtual HWND init(HookProc_t hook)=0;
18  virtual void shutdown()=0;
20  virtual void activate()=0;
22  virtual void hide()=0;
24  virtual bool is_visible() = 0;
26  virtual GUID get_guid() = 0;
27 
29  virtual void override_statusbar_text(const char * p_text) = 0;
31  virtual void revert_statusbar_text() = 0;
32 
34  virtual void show_now_playing() = 0;
35 
36  static bool g_find(service_ptr_t<user_interface> & p_out,const GUID & p_guid);
37 
38  FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(user_interface);
39 };
40 
41 template<typename T>
43 
47 class NOVTABLE ui_status_text_override : public service_base
48 {
49 public:
51  virtual void override_text(const char * p_message) = 0;
53  virtual void revert_text() = 0;
54 
55  FB2K_MAKE_SERVICE_INTERFACE(ui_status_text_override,service_base);
56 };
57 
60 class NOVTABLE ui_control : public service_base {
61 public:
63  virtual bool is_visible()=0;
65  virtual void activate()=0;
67  virtual void hide()=0;
69  virtual HICON get_main_icon()=0;
71  virtual HICON load_main_icon(unsigned width,unsigned height) = 0;
72 
74  virtual void show_preferences(const GUID & p_page) = 0;
75 
79  virtual bool override_status_text_create(service_ptr_t<ui_status_text_override> & p_out) = 0;
80 
81  FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(ui_control);
82 };
83 
86 class NOVTABLE ui_drop_item_callback : public service_base {
87 public:
89  virtual bool on_drop(interface IDataObject * pDataObject) = 0;
92  virtual bool is_accepted_type(interface IDataObject * pDataObject, DWORD * p_effect)=0;
93 
95  static bool g_on_drop(interface IDataObject * pDataObject);
97  static bool g_is_accepted_type(interface IDataObject * pDataObject, DWORD * p_effect);
98 
99  FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(ui_drop_item_callback);
100 };
101 
102 template<class T>
104 
105 
107 
122 class NOVTABLE ui_selection_holder : public service_base {
123 public:
125  virtual void set_selection(metadb_handle_list_cref data) = 0;
130  virtual void set_playlist_selection_tracking() = 0;
135  virtual void set_playlist_tracking() = 0;
136 
139  virtual void set_selection_ex(metadb_handle_list_cref data, const GUID & type) = 0;
140 
141  FB2K_MAKE_SERVICE_INTERFACE(ui_selection_holder,service_base);
142 };
143 
144 class NOVTABLE ui_selection_manager : public service_base {
145 public:
147  virtual void get_selection(metadb_handle_list_ref p_selection) = 0;
149  virtual void register_callback(ui_selection_callback * p_callback) = 0;
151  virtual void unregister_callback(ui_selection_callback * p_callback) = 0;
152 
153  virtual ui_selection_holder::ptr acquire() = 0;
154 
156  virtual GUID get_selection_type() = 0;
157 
158  FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(ui_selection_manager);
159 };
160 
163  FB2K_MAKE_SERVICE_INTERFACE(ui_selection_manager_v2, ui_selection_manager)
164 public:
165  enum { flag_no_now_playing = 1 };
166  virtual void get_selection(metadb_handle_list_ref out, t_uint32 flags) = 0;
167  virtual GUID get_selection_type(t_uint32 flags) = 0;
168  virtual void register_callback(ui_selection_callback * callback, t_uint32 flags) = 0;
169 };
170 
172 public:
173  virtual void on_selection_changed(metadb_handle_list_cref p_selection) = 0;
174 protected:
177 };
178 
181 protected:
182  ui_selection_callback_impl_base(bool activate = true) : m_active() {ui_selection_callback_activate(activate);}
183  ~ui_selection_callback_impl_base() {ui_selection_callback_activate(false);}
184 
185  void ui_selection_callback_activate(bool state = true) {
186  if (state != m_active) {
187  m_active = state;
189  if (state) api->register_callback(this);
190  else api->unregister_callback(this);
191  }
192  }
193 
194  //avoid pure virtual function calls in rare cases - provide a dummy implementation
196 
197  PFC_CLASS_NOT_COPYABLE_EX(ui_selection_callback_impl_base);
198 private:
199  bool m_active;
200 };
201 
204 template<unsigned flags>
206 protected:
207  enum {
208  ui_selection_flags = flags
209  };
210  ui_selection_callback_impl_base_ex(bool activate = true) : m_active() {ui_selection_callback_activate(activate);}
211  ~ui_selection_callback_impl_base_ex() {ui_selection_callback_activate(false);}
212 
213  void ui_selection_callback_activate(bool state = true) {
214  if (state != m_active) {
215  m_active = state;
217  if (state) api->register_callback(this, flags);
218  else api->unregister_callback(this);
219  }
220  }
221 
222  //avoid pure virtual function calls in rare cases - provide a dummy implementation
224 
226 private:
227  bool m_active;
228 };
Definition: pfc.h:71
ui_selection_callback()
Definition: ui.h:175
typedef BOOL(WINAPI *pPowerSetRequest_t)(__in HANDLE PowerRequest
void ui_selection_callback_activate(bool state=true)
Definition: ui.h:185
void on_selection_changed(metadb_handle_list_cref p_selection)
Definition: ui.h:195
Interface class allowing you to override UI statusbar text. There may be multiple callers trying to o...
Definition: ui.h:47
~ui_selection_callback()
Definition: ui.h:176
Entrypoint service for user interface modules. Implement when registering an UI module. Do not call existing implementations; only core enumerates / dispatches calls. To control UI behaviors from other components, use ui_control API. Use user_interface_factory_t<> to register, e.g static user_interface_factory_t<myclass> g_myclass_factory;.
Definition: ui.h:7
void on_selection_changed(metadb_handle_list_cref p_selection)
Definition: ui.h:223
ui_selection_callback_impl_base(bool activate=true)
Definition: ui.h:182
Write interface and reference counter for the shared selection. The ui_selection_manager stores the s...
Definition: ui.h:122
void ui_selection_callback_activate(bool state=true)
Definition: ui.h:213
ui_selection_callback_impl_base_ex(bool activate=true)
Definition: ui.h:210
Base class for all service classes. Provides interfaces for reference counter and querying for differ...
Definition: service.h:333
Serivce providing various UI-related commands. Implemented by core; do not reimplement. Instantiation: use static_api_ptr_t<ui_control>.
Definition: ui.h:60
Autopointer class to be used with all services. Manages reference counter calls behind-the-scenes.
Definition: service.h:55
ui_selection_callback implementation helper with autoregistration - do not instantiate statically ...
Definition: ui.h:180
Helper template used to easily access core services. Usage: static_api_ptr_t<myclass> api; api->doso...
Definition: service.h:533
uint32_t t_uint32
Definition: int_types.h:5
Service called from the UI when some object is dropped into the UI. Usable for modifying drag&drop be...
Definition: ui.h:86