foobar2000 SDK  2015-01-14
ui_element.h
Go to the documentation of this file.
1 class NOVTABLE ui_element_config : public service_base {
3 public:
5  virtual GUID get_guid() const = 0;
7  virtual const void * get_data() const = 0;
9  virtual t_size get_data_size() const = 0;
10 
11 
13  static service_ptr_t<ui_element_config> g_create(const GUID& id, const void * data, t_size size);
14 
15  template<typename t_source> static service_ptr_t<ui_element_config> g_create(const GUID& id, t_source const & data) {
17  return g_create(id, data.get_ptr(), data.get_size());
18  }
19 
20  static service_ptr_t<ui_element_config> g_create_empty(const GUID & id = pfc::guid_null) {return g_create(id,NULL,0);}
21 
22  static service_ptr_t<ui_element_config> g_create(const GUID & id, stream_reader * in, t_size bytes, abort_callback & abort);
23  static service_ptr_t<ui_element_config> g_create(stream_reader * in, t_size bytes, abort_callback & abort);
24  static service_ptr_t<ui_element_config> g_create(const void * data, t_size size);
26  return g_create(get_guid(), get_data(), get_data_size());
27  }
28 
29  FB2K_MAKE_SERVICE_INTERFACE(ui_element_config,service_base);
30 };
31 
34 public:
35  ui_element_config_parser(ui_element_config::ptr in) : m_data(in), _m_stream(in->get_data(),in->get_data_size()), stream_reader_formatter(_m_stream,_m_abort) {}
36 
37  void reset() {_m_stream.reset();}
39 
40  ui_element_config::ptr subelement(t_size size);
41  ui_element_config::ptr subelement(const GUID & id, t_size dataSize);
42 private:
43  const ui_element_config::ptr m_data;
46 };
47 
50 public:
52  ui_element_config::ptr finish(const GUID & id) {
54  }
55  void reset() {
57  }
58 private:
61 };
62 
63 
64 FB2K_STREAM_WRITER_OVERLOAD(ui_element_config::ptr) {
65  stream << value->get_guid();
66  t_size size = value->get_data_size();
67  stream << pfc::downcast_guarded<t_uint32>(size);
68  stream.write_raw(value->get_data(),size);
69  return stream;
70 }
71 FB2K_STREAM_READER_OVERLOAD(ui_element_config::ptr) {
72  GUID guid;
73  t_uint32 size;
74  stream >> guid >> size;
75  value = ui_element_config::g_create(guid,&stream.m_stream,size,stream.m_abort);
76  return stream;
77 }
78 
79 
80 
81 
82 typedef COLORREF t_ui_color;
83 typedef HFONT t_ui_font;
84 typedef HICON t_ui_icon;
85 
86 static const GUID ui_color_text = { 0x5dd38be7, 0xff8a, 0x416f, { 0x88, 0x2d, 0xa4, 0x8e, 0x31, 0x87, 0x85, 0xb2 } };
87 static const GUID ui_color_background = { 0x16fc40c1, 0x1cba, 0x4385, { 0x93, 0x3b, 0xe9, 0x32, 0x7f, 0x6e, 0x35, 0x1f } };
88 static const GUID ui_color_highlight = { 0xd2f98042, 0x3e6a, 0x423a, { 0xb8, 0x66, 0x65, 0x1, 0xfe, 0xa9, 0x75, 0x93 } };
89 static const GUID ui_color_selection = { 0xebe1a36b, 0x7e0a, 0x469a, { 0x8e, 0xc5, 0xcf, 0x3, 0x12, 0x90, 0x40, 0xb5 } };
90 
91 static const GUID ui_font_default = { 0x9ef02cef, 0xe58a, 0x4f99, { 0x9f, 0xe3, 0x85, 0x39, 0xb, 0xed, 0xc5, 0xe0 } };
92 static const GUID ui_font_tabs = { 0x65ffd7ac, 0x71ce, 0x495c, { 0xa5, 0x99, 0x48, 0x5b, 0xbf, 0x7a, 0x4, 0x7b } };
93 static const GUID ui_font_lists = { 0xa86198b3, 0xb5d8, 0x40cf, { 0xac, 0x19, 0xf9, 0xda, 0xc, 0xb5, 0xd4, 0x24 } };
94 static const GUID ui_font_playlists = { 0xd85b7b7e, 0xbf83, 0x41ed, { 0x88, 0xce, 0x1, 0x99, 0x31, 0x94, 0x3e, 0x2f } };
95 static const GUID ui_font_statusbar = { 0xc7fd555b, 0xbd15, 0x4f74, { 0x93, 0xe, 0xba, 0x55, 0x52, 0x9d, 0xd9, 0x71 } };
96 static const GUID ui_font_console = { 0xb08c619d, 0xd3d1, 0x4089, { 0x93, 0xb2, 0xd5, 0xb, 0x87, 0x2d, 0x1a, 0x25 } };
97 
98 
99 
100 
102 static int ui_color_to_sys_color_index(const GUID & p_guid) {
103  if (p_guid == ui_color_text) {
104  return COLOR_WINDOWTEXT;
105  } else if (p_guid == ui_color_background) {
106  return COLOR_WINDOW;
107  } else if (p_guid == ui_color_highlight) {
108  return COLOR_HOTLIGHT;
109  } else if (p_guid == ui_color_selection) {
110  return COLOR_HIGHLIGHT;
111  } else {
112  return -1;
113  }
114 }
115 
116 
120 
122  m_min_width = pfc::max_t(m_min_width,p_other.m_min_width);
123  m_min_height = pfc::max_t(m_min_height,p_other.m_min_height);
124  m_max_width = pfc::min_t(m_max_width,p_other.m_max_width);
125  m_max_height = pfc::min_t(m_max_height,p_other.m_max_height);
126  return *this;
127  }
129  ui_element_min_max_info ret(*this);
130  ret |= p_other;
131  return ret;
132  }
133 
134 };
135 
139  FB2K_MAKE_SERVICE_INTERFACE(ui_element_instance_callback,service_base);
140 public:
141  virtual void on_min_max_info_change() = 0;
143  virtual void on_alt_pressed(bool p_state) = 0;
145  virtual bool query_color(const GUID & p_what,t_ui_color & p_out) = 0;
148  virtual bool request_activation(service_ptr_t<class ui_element_instance> p_item) = 0;
149 
151  virtual bool is_edit_mode_enabled() = 0;
152 
155  virtual void request_replace(service_ptr_t<class ui_element_instance> p_item) = 0;
156 
158  t_ui_font query_font() {return query_font_ex(ui_font_default);}
159 
161  virtual t_ui_font query_font_ex(const GUID & p_what) = 0;
162 
164  t_ui_color query_std_color(const GUID & p_what);
165 
166  bool is_elem_visible_(service_ptr_t<class ui_element_instance> elem);
167 
168  t_size notify_(ui_element_instance * source, const GUID & what, t_size param1, const void * param2, t_size param2size);
169  bool set_elem_label(ui_element_instance * source, const char * label);
170  t_uint32 get_dialog_texture(ui_element_instance * source);
171  bool is_border_needed(ui_element_instance * source);
172 };
173 
174 
177 public:
178  virtual bool is_elem_visible(service_ptr_t<class ui_element_instance> elem) = 0;
179 };
180 
183 public:
185  virtual t_size notify(ui_element_instance * source, const GUID & what, t_size param1, const void * param2, t_size param2size) = 0;
186 };
187 
189 
191 template<typename t_receiver> class ui_element_instance_callback_impl : public ui_element_instance_callback_v3 {
192 public:
193  ui_element_instance_callback_impl(t_receiver * p_receiver) : m_receiver(p_receiver) {}
195  if (m_receiver != NULL) m_receiver->on_min_max_info_change();
196  }
197  void on_alt_pressed(bool p_state) {}
198 
199  bool query_color(const GUID & p_what,t_ui_color & p_out) {
200  if (m_receiver != NULL) return m_receiver->query_color(p_what,p_out);
201  else return false;
202  }
203 
205  if (m_receiver) return m_receiver->request_activation(p_item);
206  else return false;
207  }
208 
210  if (m_receiver) return m_receiver->is_edit_mode_enabled();
211  else return false;
212  }
214  if (m_receiver) m_receiver->request_replace(p_item);
215  }
216 
217  t_ui_font query_font_ex(const GUID & p_what) {
218  if (m_receiver) return m_receiver->query_font_ex(p_what);
219  else return NULL;
220  }
221 
222  void orphan() {m_receiver = NULL;}
223 
225  if (m_receiver) return m_receiver->is_elem_visible(elem);
226  else return false;
227  }
228  t_size notify(ui_element_instance * source, const GUID & what, t_size param1, const void * param2, t_size param2size) {
229  if (m_receiver) return m_receiver->host_notify(source, what, param1, param2, param2size);
230  else return 0;
231  }
232 private:
233  t_receiver * m_receiver;
234 };
235 
238 public:
239  virtual void on_min_max_info_change() {}
240  virtual bool query_color(const GUID & p_what,t_ui_color & p_out) {return false;}
242  virtual bool is_edit_mode_enabled() {return false;}
244  virtual t_ui_font query_font_ex(const GUID&) {return NULL;}
245  virtual bool is_elem_visible(service_ptr_t<ui_element_instance> elem) {return true;}
246  virtual t_size host_notify(ui_element_instance * source, const GUID & what, t_size param1, const void * param2, t_size param2size) {return 0;}
248  if (m_callback.is_empty()) m_callback = new service_impl_t<t_callback>(this);
249  return m_callback;
250  }
252  if (m_callback.is_valid()) {
253  m_callback->orphan();
254  m_callback.release();
255  }
256  }
257 protected:
260  }
262 
263 private:
267 };
268 
270 class NOVTABLE ui_element_instance : public service_base {
271 public:
274  virtual HWND get_wnd() = 0;
275 
277  virtual void set_configuration(ui_element_config::ptr data) = 0;
279  virtual ui_element_config::ptr get_configuration() = 0;
280 
282  virtual GUID get_guid() = 0;
284  virtual GUID get_subclass() = 0;
285 
287  virtual double get_focus_priority() {return 0;}
289  virtual void set_default_focus() {set_default_focus_fallback();}
290 
292  virtual bool get_focus_priority_subclass(double & p_out,const GUID & p_subclass) {
293  if (p_subclass == get_subclass()) {p_out = get_focus_priority(); return true;}
294  else {return false;}
295  }
297  virtual bool set_default_focus_subclass(const GUID & p_subclass) {
298  if (p_subclass == get_subclass()) {set_default_focus(); return true;}
299  else {return false;}
300  }
301 
305  MINMAXINFO temp = {};
306  temp.ptMaxTrackSize.x = 1024*1024;//arbitrary huge number
307  temp.ptMaxTrackSize.y = 1024*1024;
308  SendMessage(get_wnd(),WM_GETMINMAXINFO,0,(LPARAM)&temp);
309  if (temp.ptMinTrackSize.x >= 0) ret.m_min_width = temp.ptMinTrackSize.x;
310  if (temp.ptMaxTrackSize.x > 0) ret.m_max_width = temp.ptMaxTrackSize.x;
311  if (temp.ptMinTrackSize.y >= 0) ret.m_min_height = temp.ptMinTrackSize.y;
312  if (temp.ptMaxTrackSize.y > 0) ret.m_max_height = temp.ptMaxTrackSize.y;
313  return ret;
314  }
315 
317  virtual void notify(const GUID & p_what, t_size p_param1, const void * p_param2, t_size p_param2size) {}
318 
321  virtual bool edit_mode_context_menu_test(const POINT & p_point,bool p_fromkeyboard) {return false;}
322  virtual void edit_mode_context_menu_build(const POINT & p_point,bool p_fromkeyboard,HMENU p_menu,unsigned p_id_base) {}
323  virtual void edit_mode_context_menu_command(const POINT & p_point,bool p_fromkeyboard,unsigned p_id,unsigned p_id_base) {}
325  virtual bool edit_mode_context_menu_get_focus_point(POINT & p_point) {return false;}
326 
327  virtual bool edit_mode_context_menu_get_description(unsigned p_id,unsigned p_id_base,pfc::string_base & p_out) {return false;}
328 
329 
332  const HWND thisWnd = this->get_wnd();
333  if (thisWnd != NULL) ::SetFocus(thisWnd);
334  }
335 
336  FB2K_MAKE_SERVICE_INTERFACE(ui_element_instance,service_base);
337 };
338 
340 
341 
344 public:
346  virtual t_size get_count() = 0;
348  virtual ui_element_config::ptr get_item(t_size p_index) = 0;
349 
351  virtual bool can_set_count() = 0;
353  virtual void set_count(t_size count) = 0;
355  virtual void set_item(t_size p_index,ui_element_config::ptr cfg) = 0;
357  virtual ui_element_config::ptr commit() = 0;
358 
359  FB2K_MAKE_SERVICE_INTERFACE(ui_element_children_enumerator,service_base);
360 };
361 
362 
364 
365 
367 class NOVTABLE ui_element : public service_base {
368 public:
370  virtual GUID get_guid() = 0;
371 
373  virtual GUID get_subclass() = 0;
374 
376  virtual void get_name(pfc::string_base & p_out) = 0;
377 
379  virtual ui_element_instance_ptr instantiate(HWND p_parent,ui_element_config::ptr cfg,ui_element_instance_callback_ptr p_callback) = 0;
380 
382  virtual ui_element_config::ptr get_default_configuration() = 0;
383 
386  virtual ui_element_children_enumerator_ptr enumerate_children(ui_element_config::ptr cfg) = 0;
387 
388 
392  virtual ui_element_config::ptr import(ui_element_config::ptr cfg) {return NULL;}
393 
395  virtual bool is_user_addable() {return true;}
396 
398  virtual t_ui_icon get_icon() {return NULL;}
399 
401  virtual bool get_description(pfc::string_base & p_out) {return false;}
402 
404  virtual bool get_element_group(pfc::string_base & p_out);
405 
406  static bool g_find(service_ptr_t<ui_element> & out, const GUID & id);
407  static bool g_get_name(pfc::string_base & p_out,const GUID & p_guid);
408 
409  FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(ui_element);
410 };
411 
413 class NOVTABLE ui_element_v2 : public ui_element {
414 public:
415  enum {
417  KFlagSupportsBump = 1 << 0,
420  KFlagHavePopupCommand = 1 << 1,
422  KFlagHaveFullscreen = 1 << 2,
423 
424  KFlagPopupCommandHidden = 1 << 3,
425 
426  KFlagsVisualisation = KFlagHavePopupCommand | KFlagHaveFullscreen,
427  };
428  virtual t_uint32 get_flags() = 0;
431  virtual bool bump() = 0;
432 
434  virtual GUID get_menu_command_id() {return get_guid();}
435 
438  pfc::string8 name; get_name(name);
439  out = pfc::string_formatter() << "Activates " << name << " window.";
440  return true;
441  }
442 
444  virtual void get_menu_command_name(pfc::string_base & out) {get_name(out);}
449  virtual bool get_popup_specs(SIZE & defSize, pfc::string_base & title) {return false;}
450 
451 
452  FB2K_MAKE_SERVICE_INTERFACE(ui_element_v2, ui_element)
453 };
454 
456 public:
457  virtual void on_resize(t_uint32 width, t_uint32 height) = 0;
458  virtual void on_close() = 0;
459  virtual void on_destroy() = 0;
460 
461  FB2K_MAKE_SERVICE_INTERFACE(ui_element_popup_host_callback,service_base);
462 };
463 
464 class NOVTABLE ui_element_popup_host : public service_base {
465  FB2K_MAKE_SERVICE_INTERFACE(ui_element_popup_host,service_base);
466 public:
467  virtual ui_element_instance::ptr get_root_elem() = 0;
468  virtual HWND get_wnd() = 0;
469  virtual ui_element_config::ptr get_config() = 0;
470  virtual void set_config(ui_element_config::ptr cfg) = 0;
472  virtual void set_edit_mode(bool state) = 0;
473 };
474 
477 public:
478  virtual void set_window_title(const char * title) = 0;
479  virtual void allow_element_specified_title(bool allow) = 0;
480 };
481 
483 class NOVTABLE ui_element_common_methods : public service_base {
484 public:
485  virtual void copy(ui_element_config::ptr cfg) = 0;
486  virtual void cut(ui_element_instance_ptr & p_instance,HWND p_parent,ui_element_instance_callback_ptr p_callback) = 0;
487  virtual bool paste(ui_element_instance_ptr & p_instance,HWND p_parent,ui_element_instance_callback_ptr p_callback) = 0;
488  virtual bool is_paste_available() = 0;
489  virtual bool paste(ui_element_config::ptr & out) = 0;
490 
491  virtual bool parse_dataobject_check(pfc::com_ptr_t<IDataObject> in, DWORD & dropEffect) = 0;
492  virtual bool parse_dataobject(pfc::com_ptr_t<IDataObject> in,ui_element_config::ptr & out, DWORD & dropEffect) = 0;
493 
494  virtual pfc::com_ptr_t<IDataObject> create_dataobject(ui_element_config::ptr in) = 0;
495 
496  virtual HWND spawn_scratchbox(HWND parent,ui_element_config::ptr cfg) = 0;
497 
498  virtual ui_element_popup_host::ptr spawn_host(HWND parent, ui_element_config::ptr cfg, ui_element_popup_host_callback::ptr callback, ui_element::ptr elem = NULL, DWORD style = WS_POPUPWINDOW|WS_CAPTION|WS_THICKFRAME, DWORD styleEx = WS_EX_CONTROLPARENT) = 0;
499 
500  void copy(ui_element_instance_ptr p_instance) {copy(p_instance->get_configuration());}
501 
502  FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(ui_element_common_methods);
503 };
504 
507 public:
508  virtual void spawn_host_simple(HWND parent, ui_element::ptr elem, bool fullScreenMode) = 0;
509 
510  void spawn_host_simple(HWND parent, const GUID & elem, bool fullScreenMode) {
511  spawn_host_simple(parent, service_by_guid<ui_element>(elem), fullScreenMode);
512  }
513 
514  virtual void toggle_fullscreen(ui_element::ptr elem, HWND parent) = 0;
515 
516  void toggle_fullscreen(const GUID & elem, HWND parent) {
517  toggle_fullscreen(service_by_guid<ui_element>(elem), parent);
518  }
519 
520  FB2K_MAKE_SERVICE_INTERFACE(ui_element_common_methods_v2, ui_element_common_methods);
521 };
522 
524 public:
525  virtual void add(HWND wnd) = 0;
526  virtual void remove(HWND wnd) = 0;
527  virtual bool is_registered(HWND wnd) = 0;
528 
529  FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(ui_element_typable_window_manager)
530 };
531 
532 FOOGUIDDECL const GUID ui_element_instance::class_guid = { 0xb55d4525, 0xddc8, 0x40d7, { 0xb9, 0x19, 0x6d, 0x7c, 0x48, 0x38, 0xf2, 0xdb } };
533 FOOGUIDDECL const GUID ui_element::class_guid = { 0xb52c703, 0x1586, 0x42f7, { 0xa8, 0x4c, 0x70, 0x54, 0xcd, 0xc8, 0x22, 0x55 } };
534 FOOGUIDDECL const GUID ui_element_v2::class_guid = { 0x2e1fe21e, 0x8e0f, 0x43be, { 0x9f, 0xdb, 0xd5, 0xdd, 0xf4, 0xc9, 0xba, 0xba } };
535 FOOGUIDDECL const GUID ui_element_instance_callback::class_guid = { 0xcd3647c6, 0x12d9, 0x4122, { 0xa5, 0x28, 0x4a, 0xba, 0x34, 0x90, 0x89, 0x5c } };
536 FOOGUIDDECL const GUID ui_element_instance_callback_v2::class_guid = { 0x5b11faa3, 0x48ee, 0x41a1, { 0xb7, 0xf9, 0x16, 0x7a, 0xba, 0x6c, 0x60, 0x41 } };
537 FOOGUIDDECL const GUID ui_element_children_enumerator::class_guid = { 0x6c7a3a46, 0xdc54, 0x4499, { 0x98, 0x66, 0xae, 0x3, 0x55, 0xe, 0xf3, 0x1c } };
538 FOOGUIDDECL const GUID ui_element_common_methods::class_guid = { 0xedee8cd9, 0x3072, 0x410e, { 0xb2, 0x66, 0x37, 0x5d, 0x9f, 0x6f, 0xb0, 0x36 } };
539 FOOGUIDDECL const GUID ui_element_common_methods_v2::class_guid = { 0x2dc90e34, 0x38fc, 0x4ad1, { 0x92, 0x80, 0xff, 0x1f, 0xac, 0x14, 0x52, 0xd0 } };
540 FOOGUIDDECL const GUID ui_element_popup_host::class_guid = { 0xfcc381e9, 0xe527, 0x4887, { 0xae, 0x63, 0x27, 0xc0, 0x3f, 0x4, 0xd, 0x1 } };
541 FOOGUIDDECL const GUID ui_element_popup_host_callback::class_guid = { 0x2993a043, 0x2e70, 0x4d8f, { 0x81, 0xb, 0x41, 0x3, 0x37, 0x73, 0x97, 0xcd } };
542 FOOGUIDDECL const GUID ui_element_config::class_guid = { 0xd34bba46, 0x1bad, 0x4547, { 0xba, 0xb4, 0x17, 0xe2, 0x44, 0xd5, 0xeb, 0x94 } };
543 FOOGUIDDECL const GUID ui_element_typable_window_manager::class_guid = { 0xbaa99ee2, 0xf770, 0x4981, { 0x9e, 0x50, 0xf3, 0x4c, 0x5c, 0x6d, 0x98, 0x81 } };
544 FOOGUIDDECL const GUID ui_element_instance_callback_v3::class_guid = { 0x6d15c0c6, 0x90b6, 0x4c7e, { 0xbf, 0x39, 0xe9, 0x39, 0xf2, 0xdf, 0x9b, 0x91 } };
545 FOOGUIDDECL const GUID ui_element_popup_host_v2::class_guid = { 0x8caac11e, 0x52b6, 0x47f7, { 0x97, 0xc9, 0x2c, 0x87, 0xdb, 0xdb, 0x2e, 0x5b } };
546 
547 
549 static const GUID ui_element_notify_colors_changed = { 0xeedda994, 0xe3d2, 0x441a, { 0xbe, 0x47, 0xa1, 0x63, 0x5b, 0x71, 0xab, 0x60 } };
550 static const GUID ui_element_notify_font_changed = { 0x7a6964a8, 0xc797, 0x4737, { 0x90, 0x55, 0x7d, 0x84, 0xe7, 0x3d, 0x63, 0x6e } };
551 static const GUID ui_element_notify_edit_mode_changed = { 0xf72f00af, 0xec76, 0x4251, { 0xb2, 0x67, 0x89, 0x4c, 0x52, 0x5f, 0x18, 0xc6 } };
552 
554 static const GUID ui_element_notify_visibility_changed = { 0x313c22b9, 0x287a, 0x4804, { 0x8e, 0x6c, 0xff, 0xef, 0x4, 0x10, 0xcd, 0xea } };
555 
557 static const GUID ui_element_notify_get_element_labels = { 0x4850a2cb, 0x6cfc, 0x4d74, { 0x9a, 0x6d, 0xc, 0x7b, 0x29, 0x16, 0x5e, 0x69 } };
558 
559 
561 static const GUID ui_element_host_notify_set_elem_label = { 0x24598cb7, 0x9c5c, 0x488e, { 0xba, 0xff, 0xd, 0x2f, 0x11, 0x93, 0xe4, 0xf2 } };
562 static const GUID ui_element_host_notify_get_dialog_texture = { 0xbb98eb99, 0x7b07, 0x42f3, { 0x8c, 0xd1, 0x12, 0xa2, 0xc2, 0x23, 0xb5, 0xbc } };
563 static const GUID ui_element_host_notify_is_border_needed = { 0x2974f554, 0x2f31, 0x49c5, { 0xab, 0x4, 0x76, 0x4a, 0xf7, 0x94, 0x7c, 0x4f } };
564 
565 
566 
568 public:
569  virtual void set_area_label(const RECT & rc, const char * name) = 0;
570  virtual void set_visible_element(ui_element_instance::ptr item) = 0;
571 protected:
574 
576 };
577 
578 
579 static const GUID ui_element_subclass_playlist_renderers = { 0x3c4c68a0, 0xfc5, 0x400a, { 0xa3, 0x4a, 0x2e, 0x3a, 0xae, 0x6e, 0x90, 0x76 } };
580 static const GUID ui_element_subclass_media_library_viewers = { 0x58455355, 0x289d, 0x459c, { 0x8f, 0x8a, 0xe1, 0x49, 0x6, 0xfc, 0x14, 0x56 } };
581 static const GUID ui_element_subclass_containers = { 0x72dc5954, 0x1f26, 0x41be, { 0xae, 0xf2, 0x92, 0x9d, 0x25, 0xb5, 0x8d, 0xcf } };
582 static const GUID ui_element_subclass_selection_information = { 0x68084e43, 0x7359, 0x46a5, { 0xb6, 0x84, 0x3c, 0xd7, 0x57, 0xf6, 0xde, 0xfd } };
583 static const GUID ui_element_subclass_playback_visualisation = { 0x1f3c62f2, 0x8bb5, 0x4700, { 0x9e, 0x82, 0x8c, 0x48, 0x22, 0xf0, 0x18, 0x35 } };
584 static const GUID ui_element_subclass_playback_information = { 0x84859f2d, 0xbb9c, 0x4e70, { 0x9d, 0x4, 0x14, 0x71, 0xb5, 0x63, 0x1f, 0x7f } };
585 static const GUID ui_element_subclass_utility = { 0xffa4f4fc, 0xc169, 0x4766, { 0x9c, 0x94, 0xfa, 0xef, 0xae, 0xb2, 0x7e, 0xf } };
586 
588 
589 
590 #define ReplaceUIElementCommand "Replace UI Element..."
591 #define ReplaceUIElementDescription "Replaces this UI Element with another one."
592 
593 #define CopyUIElementCommand "Copy UI Element"
594 #define CopyUIElementDescription "Copies this UI Element to Windows Clipboard."
595 
596 #define PasteUIElementCommand "Paste UI Element"
597 #define PasteUIElementDescription "Replaces this UI Element with Windows Clipboard content."
598 
599 #define CutUIElementCommand "Cut UI Element"
600 #define CutUIElementDescription "Copies this UI Element to Windows Clipboard and replaces it with an empty UI Element."
601 
602 #define AddNewUIElementCommand "Add New UI Element..."
603 #define AddNewUIElementDescription "Replaces the selected empty space with a new UI Element."
604 
605 
606 
607 
608 template<typename TImpl, typename TInterface = ui_element> class ui_element_impl : public TInterface {
609 public:
610  GUID get_guid() { return TImpl::g_get_guid();}
611  GUID get_subclass() { return TImpl::g_get_subclass();}
612  void get_name(pfc::string_base & out) { TImpl::g_get_name(out); }
613  ui_element_instance::ptr instantiate(HWND parent,ui_element_config::ptr cfg,ui_element_instance_callback::ptr callback) {
614  PFC_ASSERT( cfg->get_guid() == get_guid() );
616  item->initialize_window(parent);
617  return item;
618  }
619  ui_element_config::ptr get_default_configuration() { return TImpl::g_get_default_configuration(); }
620  ui_element_children_enumerator_ptr enumerate_children(ui_element_config::ptr cfg) {return NULL;}
621  bool get_description(pfc::string_base & out) {out = TImpl::g_get_description(); return true;}
622 private:
624  public:
625  ui_element_instance_impl_helper(ui_element_config::ptr cfg, ui_element_instance_callback::ptr callback) : TImpl(cfg,callback) {}
626 
627  GUID get_guid() {return TImpl::g_get_guid();}
628  GUID get_subclass() {return TImpl::g_get_subclass();}
629  HWND get_wnd() {return *this;}
630  };
631 public:
632  typedef ui_element_instance_impl_helper TInstance;
633  static TInstance const & instanceGlobals() {return *reinterpret_cast<const TInstance*>(NULL);}
634 };
GUID get_subclass()
Definition: ui_element.h:611
const ui_element_config::ptr m_data
Definition: ui_element.h:43
stream_writer_buffer_simple _m_stream
Definition: ui_element.h:60
void set_default_focus_fallback()
Helper.
Definition: ui_element.h:331
static const GUID ui_element_subclass_utility
Definition: ui_element.h:585
void toggle_fullscreen(const GUID &elem, HWND parent)
Definition: ui_element.h:516
Configuration of a UI element.
Definition: ui_element.h:2
static const GUID ui_font_playlists
Definition: ui_element.h:94
virtual double get_focus_priority()
Returns element's focus priority.
Definition: ui_element.h:287
static const GUID ui_color_background
Definition: ui_element.h:87
static const GUID ui_element_notify_colors_changed
Dispatched through ui_element_instance::notify() when host changes color settings. Other parameters are not used and should be set to zero.
Definition: ui_element.h:549
virtual bool query_color(const GUID &p_what, t_ui_color &p_out)
Definition: ui_element.h:240
t_ui_font query_font_ex(const GUID &p_what)
Retrieves an user-configurable font to use for specified kind of display. See ui_font_* constant for ...
Definition: ui_element.h:217
Template implementing reference-counting features of service_base. Intended for dynamic instantiation...
Definition: service_impl.h:4
virtual void set_default_focus()
Elements that host other elements should pass the call to the child with the highest priority...
Definition: ui_element.h:289
Interface to enumerate and possibly alter children of a container element. Obtained from ui_element::...
Definition: ui_element.h:343
ui_element_instance_impl_helper(ui_element_config::ptr cfg, ui_element_instance_callback::ptr callback)
Definition: ui_element.h:625
T min_t(const T &item1, const T &item2)
Definition: primitives.h:556
virtual bool get_popup_specs(SIZE &defSize, pfc::string_base &title)
Relevant only when KFlagHavePopupCommand is set.
Definition: ui_element.h:449
static const GUID ui_font_default
Definition: ui_element.h:91
static const GUID ui_color_selection
Definition: ui_element.h:89
Definition: pfc.h:53
FB2K_MAKE_SERVICE_INTERFACE(ui_element_instance_callback, service_base)
static const GUID ui_font_lists
Definition: ui_element.h:93
static const GUID ui_font_statusbar
Definition: ui_element.h:95
abort_callback_dummy _m_abort
Definition: ui_element.h:44
ui_element_config::ptr get_default_configuration()
Definition: ui_element.h:619
Special service_impl_t replacement for service classes that also implement ATL/WTL windows...
Definition: misc.h:307
static const GUID ui_element_host_notify_set_elem_label
Set to ui_element_instance_callback_v3 to set our element's label. Param1 is ignored, param2 is a pointer to a UTF-8 string containing the new label. Return value is 1 if the label is user-visible, 0 if the host does not support displaying overridden labels.
Definition: ui_element.h:561
abort_callback_impl abort_callback_dummy
virtual ui_element_min_max_info get_min_max_info()
Retrieves element's minimum/maximum window size. Default implementation will fall back to WM_GETMINMA...
Definition: ui_element.h:303
virtual void edit_mode_context_menu_command(const POINT &p_point, bool p_fromkeyboard, unsigned p_id, unsigned p_id_base)
Definition: ui_element.h:323
static const GUID ui_element_notify_edit_mode_changed
Definition: ui_element.h:551
virtual void notify(const GUID &p_what, t_size p_param1, const void *p_param2, t_size p_param2size)
Used by host to notify the element about various events. See ui_element_notify_* GUIDs for possible p...
Definition: ui_element.h:317
static const GUID ui_element_host_notify_get_dialog_texture
Definition: ui_element.h:562
For use with static_api_ptr_t<>
Definition: ui_element.h:506
ui_element_instance_callback_receiver t_self
Definition: ui_element.h:264
void spawn_host_simple(HWND parent, const GUID &elem, bool fullScreenMode)
Definition: ui_element.h:510
virtual void get_name(pfc::string_base &p_out)=0
Retrieves a simple human-readable name of the element.
ui_element_instance_callback implementation helper.
Definition: ui_element.h:191
virtual bool is_user_addable()
Override this to return false when your element is for internal use only and should not be user-addab...
Definition: ui_element.h:395
t_size get_remaining() const
Definition: ui_element.h:38
virtual void request_replace(service_ptr_t< class ui_element_instance > p_item)
Definition: ui_element.h:243
ui_element_instance_callback_impl(t_receiver *p_receiver)
Definition: ui_element.h:193
void copy(ui_element_instance_ptr p_instance)
Definition: ui_element.h:500
void get_name(pfc::string_base &out)
Definition: ui_element.h:612
ui_element_config::ptr subelement(t_size size)
Definition: ui_element.cpp:42
FB2K_STREAM_READER_OVERLOAD(ui_element_config::ptr)
Definition: ui_element.h:71
virtual void set_visible_element(ui_element_instance::ptr item)=0
static const GUID ui_element_host_notify_is_border_needed
Definition: ui_element.h:563
bool ui_element_subclass_description(const GUID &id, pfc::string_base &out)
Definition: ui_element.cpp:54
PFC_CLASS_NOT_COPYABLE_EX(ui_element_notify_get_element_labels_callback)
static service_ptr_t< ui_element_config > g_create(const GUID &id, t_source const &data)
Definition: ui_element.h:15
static const GUID ui_element_notify_font_changed
Definition: ui_element.h:550
abort_callback_dummy _m_abort
Definition: ui_element.h:59
bool is_elem_visible(service_ptr_t< class ui_element_instance > elem)
Definition: ui_element.h:224
virtual t_size host_notify(ui_element_instance *source, const GUID &what, t_size param1, const void *param2, t_size param2size)
Definition: ui_element.h:246
COLORREF t_ui_color
Definition: ui_element.h:82
virtual bool is_elem_visible(service_ptr_t< ui_element_instance > elem)
Definition: ui_element.h:245
Extended interface for a UI element implementation.
Definition: ui_element.h:413
bool request_activation(service_ptr_t< class ui_element_instance > p_item)
Tells the host that specified element wants to activate itself as a result of some kind of external u...
Definition: ui_element.h:204
static const GUID ui_color_text
Definition: ui_element.h:86
service_ptr_t< ui_element_instance > ui_element_instance_ptr
Definition: ui_element.h:339
FB2K_STREAM_WRITER_OVERLOAD(ui_element_config::ptr)
Definition: ui_element.h:64
HICON t_ui_icon
Definition: ui_element.h:84
virtual bool edit_mode_context_menu_test(const POINT &p_point, bool p_fromkeyboard)
Definition: ui_element.h:321
Autopointer class to be used with all services. Manages reference counter calls behind-the-scenes. This assumes that the pointers are valid all the time (can't point to null). Mainly intended to be used for scenarios where null pointers are not valid and relevant code should crash ASAP if somebody passes invalid pointers around. You want to use service_ptr_t<> rather than service_nnptr_t<> most of the time.
Definition: service.h:51
void request_replace(service_ptr_t< class ui_element_instance > p_item)
Tells the host that the user has requested the element to be replaced with another one...
Definition: ui_element.h:213
ui_element_instance_callback_ptr ui_element_instance_callback_get_ptr()
Definition: ui_element.h:247
size_t t_size
Definition: int_types.h:48
static int ui_color_to_sys_color_index(const GUID &p_guid)
Definition: ui_element.h:102
string8_fastalloc string_formatter
Definition: string_base.h:614
For use with static_api_ptr_t<>
Definition: ui_element.h:483
static TInstance const & instanceGlobals()
Definition: ui_element.h:633
stream_reader_memblock_ref _m_stream
Definition: ui_element.h:45
virtual void set_area_label(const RECT &rc, const char *name)=0
service_ptr_t< ui_element_instance_callback > ui_element_instance_callback_ptr
Definition: ui_element.h:188
void set_size(t_size p_size)
Definition: array.h:104
static const GUID ui_element_subclass_selection_information
Definition: ui_element.h:582
ui_element_min_max_info operator|(const ui_element_min_max_info &p_other) const
Definition: ui_element.h:128
static const GUID ui_element_subclass_playback_information
Definition: ui_element.h:584
virtual GUID get_menu_command_id()
Override to use another GUID for our menu command. Relevant only when KFlagHavePopupCommand is set...
Definition: ui_element.h:434
static const GUID ui_element_subclass_containers
Definition: ui_element.h:581
Entrypoint interface for each UI element implementation.
Definition: ui_element.h:367
static const GUID ui_element_subclass_media_library_viewers
Definition: ui_element.h:580
Base class for all service classes. Provides interfaces for reference counter and querying for differ...
Definition: service.h:333
Instance of a UI element.
Definition: ui_element.h:270
FB2K_MAKE_SERVICE_INTERFACE(ui_element_instance_callback_v2, ui_element_instance_callback)
virtual bool edit_mode_context_menu_get_focus_point(POINT &p_point)
Definition: ui_element.h:325
virtual GUID get_guid()=0
Retrieves GUID of the element.
static const GUID ui_element_subclass_playlist_renderers
Definition: ui_element.h:579
t_size notify(ui_element_instance *source, const GUID &what, t_size param1, const void *param2, t_size param2size)
Definition: ui_element.h:228
HFONT t_ui_font
Definition: ui_element.h:83
Callback class passed by a UI element host to a UI element instance, allowing each UI element instanc...
Definition: ui_element.h:138
virtual void get_menu_command_name(pfc::string_base &out)
Override to use another name for our menu command. Relevant only when KFlagHavePopupCommand is set...
Definition: ui_element.h:444
const ui_element_min_max_info & operator|=(const ui_element_min_max_info &p_other)
Definition: ui_element.h:121
static const GUID ui_element_subclass_playback_visualisation
Definition: ui_element.h:583
static const GUID ui_element_notify_get_element_labels
Sent to retrieve areas occupied by elements to show overlay labels. Param1 is ignored, param2 is a pointer to ui_element_notify_get_element_labels_callback, param2size is ignored.
Definition: ui_element.h:557
ui_element_children_enumerator_ptr enumerate_children(ui_element_config::ptr cfg)
Definition: ui_element.h:620
ui_element_config_parser(ui_element_config::ptr in)
Definition: ui_element.h:35
virtual t_ui_font query_font_ex(const GUID &)
Definition: ui_element.h:244
ui_element_instance_callback_impl< t_self > t_callback
Definition: ui_element.h:265
Autopointer class to be used with all services. Manages reference counter calls behind-the-scenes.
Definition: service.h:55
virtual bool get_focus_priority_subclass(double &p_out, const GUID &p_subclass)
Overridden by containers only.
Definition: ui_element.h:292
static const GUID ui_font_console
Definition: ui_element.h:96
virtual t_ui_icon get_icon()
Returns an icon to show in available UI element lists, etc. Returns NULL when there is no icon to dis...
Definition: ui_element.h:398
ui_element_instance_impl_helper TInstance
Definition: ui_element.h:632
virtual bool edit_mode_context_menu_get_description(unsigned p_id, unsigned p_id_base, pfc::string_base &p_out)
Definition: ui_element.h:327
service_ptr_t< t_callback > m_callback
Definition: ui_element.h:266
ui_element_instance::ptr instantiate(HWND parent, ui_element_config::ptr cfg, ui_element_instance_callback::ptr callback)
Definition: ui_element.h:613
service_ptr_t< ui_element_config > clone() const
Definition: ui_element.h:25
service_ptr_t< ui_element_children_enumerator > ui_element_children_enumerator_ptr
Definition: ui_element.h:363
static const GUID ui_font_tabs
Definition: ui_element.h:92
FB2K_MAKE_SERVICE_INTERFACE(ui_element_popup_host, service_base)
void on_alt_pressed(bool p_state)
Deprecated, does nothing.
Definition: ui_element.h:197
ui_element_config::ptr finish(const GUID &id)
Definition: ui_element.h:52
bool query_color(const GUID &p_what, t_ui_color &p_out)
Returns true on success, false when the color is undefined and defaults such as global windows settin...
Definition: ui_element.h:199
t_ui_font query_font()
Deprecated - use query_font_ex. Equivalent to query_font_ex(ui_font_default).
Definition: ui_element.h:158
T max_t(const T &item1, const T &item2)
Definition: primitives.h:553
virtual bool request_activation(service_ptr_t< class ui_element_instance > p_item)
Definition: ui_element.h:241
virtual bool set_default_focus_subclass(const GUID &p_subclass)
Overridden by containers only.
Definition: ui_element.h:297
ui_element_instance_callback implementation helper.
Definition: ui_element.h:237
virtual bool get_description(pfc::string_base &p_out)
Retrieves a human-readable description of the element.
Definition: ui_element.h:401
const GUID guid_null
Definition: guid.cpp:171
bool get_description(pfc::string_base &out)
Definition: ui_element.h:621
bool is_edit_mode_enabled()
Queries whether "edit mode" is enabled. Most of UI element editing functionality should be locked whe...
Definition: ui_element.h:209
static service_ptr_t< ui_element_config > g_create_empty(const GUID &id=pfc::guid_null)
Definition: ui_element.h:20
virtual bool get_menu_command_description(pfc::string_base &out)
Override to use another description for our menu command. Relevant only when KFlagHavePopupCommand is...
Definition: ui_element.h:437
virtual void edit_mode_context_menu_build(const POINT &p_point, bool p_fromkeyboard, HMENU p_menu, unsigned p_id_base)
Definition: ui_element.h:322
static const GUID ui_element_notify_visibility_changed
Sent when a portion of the GUI is shown/hidden. First parameter is a bool flag indicating whether you...
Definition: ui_element.h:554
static const GUID ui_color_highlight
Definition: ui_element.h:88
pfc::array_t< t_uint8, pfc::alloc_fast > m_buffer
uint32_t t_uint32
Definition: int_types.h:5
static service_ptr_t< ui_element_config > g_create(const GUID &id, const void *data, t_size size)
Helper.
Definition: ui_element.cpp:25