5 virtual GUID get_guid()
const = 0;
7 virtual const void * get_data()
const = 0;
9 virtual t_size get_data_size()
const = 0;
17 return g_create(
id, data.get_ptr(), data.get_size());
26 return g_create(get_guid(), get_data(), get_data_size());
37 void reset() {_m_stream.reset();}
40 ui_element_config::ptr subelement(
t_size size);
41 ui_element_config::ptr subelement(
const GUID &
id,
t_size dataSize);
56 _m_stream.m_buffer.set_size(0);
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);
74 stream >> guid >> size;
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 } };
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 } };
103 if (p_guid == ui_color_text) {
104 return COLOR_WINDOWTEXT;
105 }
else if (p_guid == ui_color_background) {
107 }
else if (p_guid == ui_color_highlight) {
108 return COLOR_HOTLIGHT;
109 }
else if (p_guid == ui_color_selection) {
110 return COLOR_HIGHLIGHT;
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;
151 virtual bool is_edit_mode_enabled() = 0;
195 if (m_receiver != NULL) m_receiver->on_min_max_info_change();
200 if (m_receiver != NULL)
return m_receiver->query_color(p_what,p_out);
205 if (m_receiver)
return m_receiver->request_activation(p_item);
210 if (m_receiver)
return m_receiver->is_edit_mode_enabled();
214 if (m_receiver) m_receiver->request_replace(p_item);
218 if (m_receiver)
return m_receiver->query_font_ex(p_what);
225 if (m_receiver)
return m_receiver->is_elem_visible(elem);
229 if (m_receiver)
return m_receiver->host_notify(source, what, param1, param2, param2size);
252 if (m_callback.is_valid()) {
253 m_callback->orphan();
254 m_callback.release();
259 ui_element_instance_callback_release();
274 virtual HWND get_wnd() = 0;
277 virtual void set_configuration(ui_element_config::ptr data) = 0;
279 virtual ui_element_config::ptr get_configuration() = 0;
282 virtual GUID get_guid() = 0;
284 virtual GUID get_subclass() = 0;
293 if (p_subclass == get_subclass()) {p_out = get_focus_priority();
return true;}
298 if (p_subclass == get_subclass()) {set_default_focus();
return true;}
305 MINMAXINFO temp = {};
306 temp.ptMaxTrackSize.x = 1024*1024;
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;
332 const HWND thisWnd = this->get_wnd();
333 if (thisWnd != NULL) ::SetFocus(thisWnd);
346 virtual t_size get_count() = 0;
348 virtual ui_element_config::ptr get_item(
t_size p_index) = 0;
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;
370 virtual GUID get_guid() = 0;
373 virtual GUID get_subclass() = 0;
382 virtual ui_element_config::ptr get_default_configuration() = 0;
392 virtual ui_element_config::ptr
import(ui_element_config::ptr cfg) {
return NULL;}
409 FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(
ui_element);
417 KFlagSupportsBump = 1 << 0,
420 KFlagHavePopupCommand = 1 << 1,
422 KFlagHaveFullscreen = 1 << 2,
424 KFlagPopupCommandHidden = 1 << 3,
426 KFlagsVisualisation = KFlagHavePopupCommand | KFlagHaveFullscreen,
431 virtual bool bump() = 0;
458 virtual void on_close() = 0;
459 virtual void on_destroy() = 0;
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;
478 virtual void set_window_title(
const char * title) = 0;
479 virtual void allow_element_specified_title(
bool allow) = 0;
485 virtual void copy(ui_element_config::ptr cfg) = 0;
488 virtual bool is_paste_available() = 0;
489 virtual bool paste(ui_element_config::ptr & out) = 0;
496 virtual HWND spawn_scratchbox(HWND parent,ui_element_config::ptr cfg) = 0;
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;
508 virtual void spawn_host_simple(HWND parent, ui_element::ptr elem,
bool fullScreenMode) = 0;
511 spawn_host_simple(parent, service_by_guid<ui_element>(elem), fullScreenMode);
514 virtual void toggle_fullscreen(ui_element::ptr elem, HWND parent) = 0;
517 toggle_fullscreen(service_by_guid<ui_element>(elem), parent);
525 virtual void add(HWND wnd) = 0;
526 virtual void remove(HWND wnd) = 0;
527 virtual bool is_registered(HWND wnd) = 0;
533 static const GUID ui_element_notify_colors_changed = { 0xeedda994, 0xe3d2, 0x441a, { 0xbe, 0x47, 0xa1, 0x63, 0x5b, 0x71, 0xab, 0x60 } };
534 static const GUID ui_element_notify_font_changed = { 0x7a6964a8, 0xc797, 0x4737, { 0x90, 0x55, 0x7d, 0x84, 0xe7, 0x3d, 0x63, 0x6e } };
535 static const GUID ui_element_notify_edit_mode_changed = { 0xf72f00af, 0xec76, 0x4251, { 0xb2, 0x67, 0x89, 0x4c, 0x52, 0x5f, 0x18, 0xc6 } };
538 static const GUID ui_element_notify_visibility_changed = { 0x313c22b9, 0x287a, 0x4804, { 0x8e, 0x6c, 0xff, 0xef, 0x4, 0x10, 0xcd, 0xea } };
541 static const GUID ui_element_notify_get_element_labels = { 0x4850a2cb, 0x6cfc, 0x4d74, { 0x9a, 0x6d, 0xc, 0x7b, 0x29, 0x16, 0x5e, 0x69 } };
545 static const GUID ui_element_host_notify_set_elem_label = { 0x24598cb7, 0x9c5c, 0x488e, { 0xba, 0xff, 0xd, 0x2f, 0x11, 0x93, 0xe4, 0xf2 } };
546 static const GUID ui_element_host_notify_get_dialog_texture = { 0xbb98eb99, 0x7b07, 0x42f3, { 0x8c, 0xd1, 0x12, 0xa2, 0xc2, 0x23, 0xb5, 0xbc } };
547 static const GUID ui_element_host_notify_is_border_needed = { 0x2974f554, 0x2f31, 0x49c5, { 0xab, 0x4, 0x76, 0x4a, 0xf7, 0x94, 0x7c, 0x4f } };
553 virtual void set_area_label(
const RECT & rc,
const char * name) = 0;
554 virtual void set_visible_element(ui_element_instance::ptr item) = 0;
563 static const GUID ui_element_subclass_playlist_renderers = { 0x3c4c68a0, 0xfc5, 0x400a, { 0xa3, 0x4a, 0x2e, 0x3a, 0xae, 0x6e, 0x90, 0x76 } };
564 static const GUID ui_element_subclass_media_library_viewers = { 0x58455355, 0x289d, 0x459c, { 0x8f, 0x8a, 0xe1, 0x49, 0x6, 0xfc, 0x14, 0x56 } };
565 static const GUID ui_element_subclass_containers = { 0x72dc5954, 0x1f26, 0x41be, { 0xae, 0xf2, 0x92, 0x9d, 0x25, 0xb5, 0x8d, 0xcf } };
566 static const GUID ui_element_subclass_selection_information = { 0x68084e43, 0x7359, 0x46a5, { 0xb6, 0x84, 0x3c, 0xd7, 0x57, 0xf6, 0xde, 0xfd } };
567 static const GUID ui_element_subclass_playback_visualisation = { 0x1f3c62f2, 0x8bb5, 0x4700, { 0x9e, 0x82, 0x8c, 0x48, 0x22, 0xf0, 0x18, 0x35 } };
568 static const GUID ui_element_subclass_playback_information = { 0x84859f2d, 0xbb9c, 0x4e70, { 0x9d, 0x4, 0x14, 0x71, 0xb5, 0x63, 0x1f, 0x7f } };
569 static const GUID ui_element_subclass_utility = { 0xffa4f4fc, 0xc169, 0x4766, { 0x9c, 0x94, 0xfa, 0xef, 0xae, 0xb2, 0x7e, 0xf } };
574 #define ReplaceUIElementCommand "Replace UI Element..." 575 #define ReplaceUIElementDescription "Replaces this UI Element with another one." 577 #define CopyUIElementCommand "Copy UI Element" 578 #define CopyUIElementDescription "Copies this UI Element to Windows Clipboard." 580 #define PasteUIElementCommand "Paste UI Element" 581 #define PasteUIElementDescription "Replaces this UI Element with Windows Clipboard content." 583 #define CutUIElementCommand "Cut UI Element" 584 #define CutUIElementDescription "Copies this UI Element to Windows Clipboard and replaces it with an empty UI Element." 586 #define AddNewUIElementCommand "Add New UI Element..." 587 #define AddNewUIElementDescription "Replaces the selected empty space with a new UI Element." 592 template<
typename TImpl,
typename TInterface = ui_element>
class ui_element_impl :
public TInterface {
597 ui_element_instance::ptr
instantiate(HWND parent,ui_element_config::ptr cfg,ui_element_instance_callback::ptr callback) {
598 PFC_ASSERT( cfg->get_guid() == get_guid() );
600 item->initialize_window(parent);
617 static TInstance
const &
instanceGlobals() {
return *
reinterpret_cast<const TInstance*
>(NULL);}
const ui_element_config::ptr m_data
stream_writer_buffer_simple _m_stream
void set_default_focus_fallback()
Helper.
static const GUID ui_element_subclass_utility
void toggle_fullscreen(const GUID &elem, HWND parent)
Configuration of a UI element.
static const GUID ui_font_playlists
virtual double get_focus_priority()
Returns element's focus priority.
static const GUID ui_color_background
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.
virtual bool query_color(const GUID &p_what, t_ui_color &p_out)
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 ...
Template implementing reference-counting features of service_base. Intended for dynamic instantiation...
virtual void set_default_focus()
Elements that host other elements should pass the call to the child with the highest priority...
Interface to enumerate and possibly alter children of a container element. Obtained from ui_element::...
ui_element_instance_impl_helper(ui_element_config::ptr cfg, ui_element_instance_callback::ptr callback)
T min_t(const T &item1, const T &item2)
virtual bool get_popup_specs(SIZE &defSize, pfc::string_base &title)
Relevant only when KFlagHavePopupCommand is set.
static const GUID ui_font_default
static const GUID ui_color_selection
ui_element_config_builder()
static const GUID ui_font_lists
static const GUID ui_font_statusbar
abort_callback_dummy _m_abort
ui_element_config::ptr get_default_configuration()
void on_min_max_info_change()
Special service_impl_t replacement for service classes that also implement ATL/WTL windows...
virtual bool is_edit_mode_enabled()
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.
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...
ui_element_min_max_info()
virtual void edit_mode_context_menu_command(const POINT &p_point, bool p_fromkeyboard, unsigned p_id, unsigned p_id_base)
static const GUID ui_element_notify_edit_mode_changed
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...
ui_element_instance_callback_receiver()
static const GUID ui_element_host_notify_get_dialog_texture
For use with static_api_ptr_t<>
ui_element_instance_callback_receiver t_self
void spawn_host_simple(HWND parent, const GUID &elem, bool fullScreenMode)
ui_element_instance_callback implementation helper.
virtual bool is_user_addable()
Override this to return false when your element is for internal use only and should not be user-addab...
t_size get_remaining() const
virtual void request_replace(service_ptr_t< class ui_element_instance > p_item)
ui_element_instance_callback_impl(t_receiver *p_receiver)
void copy(ui_element_instance_ptr p_instance)
void get_name(pfc::string_base &out)
FB2K_STREAM_READER_OVERLOAD(ui_element_config::ptr)
static const GUID ui_element_host_notify_is_border_needed
bool ui_element_subclass_description(const GUID &id, pfc::string_base &out)
static service_ptr_t< ui_element_config > g_create(const GUID &id, t_source const &data)
static const GUID ui_element_notify_font_changed
abort_callback_dummy _m_abort
~ui_element_notify_get_element_labels_callback()
bool is_elem_visible(service_ptr_t< class ui_element_instance > elem)
virtual t_size host_notify(ui_element_instance *source, const GUID &what, t_size param1, const void *param2, t_size param2size)
virtual bool is_elem_visible(service_ptr_t< ui_element_instance > elem)
Extended interface for a UI element implementation.
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...
static const GUID ui_color_text
service_ptr_t< ui_element_instance > ui_element_instance_ptr
FB2K_STREAM_WRITER_OVERLOAD(ui_element_config::ptr)
virtual bool edit_mode_context_menu_test(const POINT &p_point, bool p_fromkeyboard)
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.
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...
ui_element_instance_callback_ptr ui_element_instance_callback_get_ptr()
static int ui_color_to_sys_color_index(const GUID &p_guid)
string8_fastalloc string_formatter
For use with static_api_ptr_t<>
static TInstance const & instanceGlobals()
stream_reader_memblock_ref _m_stream
service_ptr_t< ui_element_instance_callback > ui_element_instance_callback_ptr
static const GUID ui_element_subclass_selection_information
ui_element_min_max_info operator|(const ui_element_min_max_info &p_other) const
static const GUID ui_element_subclass_playback_information
virtual GUID get_menu_command_id()
Override to use another GUID for our menu command. Relevant only when KFlagHavePopupCommand is set...
static const GUID ui_element_subclass_containers
Entrypoint interface for each UI element implementation.
static const GUID ui_element_subclass_media_library_viewers
Base class for all service classes. Provides interfaces for reference counter and querying for differ...
Instance of a UI element.
ui_element_notify_get_element_labels_callback()
virtual bool edit_mode_context_menu_get_focus_point(POINT &p_point)
static const GUID ui_element_subclass_playlist_renderers
t_size notify(ui_element_instance *source, const GUID &what, t_size param1, const void *param2, t_size param2size)
Callback class passed by a UI element host to a UI element instance, allowing each UI element instanc...
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...
const ui_element_min_max_info & operator|=(const ui_element_min_max_info &p_other)
static const GUID ui_element_subclass_playback_visualisation
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.
ui_element_children_enumerator_ptr enumerate_children(ui_element_config::ptr cfg)
ui_element_config_parser(ui_element_config::ptr in)
virtual t_ui_font query_font_ex(const GUID &)
ui_element_instance_callback_impl< t_self > t_callback
Autopointer class to be used with all services. Manages reference counter calls behind-the-scenes.
virtual bool get_focus_priority_subclass(double &p_out, const GUID &p_subclass)
Overridden by containers only.
static const GUID ui_font_console
void ui_element_instance_callback_release()
virtual void on_min_max_info_change()
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...
ui_element_instance_impl_helper TInstance
virtual bool edit_mode_context_menu_get_description(unsigned p_id, unsigned p_id_base, pfc::string_base &p_out)
~ui_element_instance_callback_receiver()
service_ptr_t< t_callback > m_callback
ui_element_instance::ptr instantiate(HWND parent, ui_element_config::ptr cfg, ui_element_instance_callback::ptr callback)
service_ptr_t< ui_element_config > clone() const
service_ptr_t< ui_element_children_enumerator > ui_element_children_enumerator_ptr
static const GUID ui_font_tabs
void on_alt_pressed(bool p_state)
Deprecated, does nothing.
ui_element_config::ptr finish(const GUID &id)
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...
t_ui_font query_font()
Deprecated - use query_font_ex. Equivalent to query_font_ex(ui_font_default).
This is free and unencumbered software released into the public domain Anyone is free to copy
T max_t(const T &item1, const T &item2)
virtual bool request_activation(service_ptr_t< class ui_element_instance > p_item)
virtual bool set_default_focus_subclass(const GUID &p_subclass)
Overridden by containers only.
ui_element_instance_callback implementation helper.
virtual bool get_description(pfc::string_base &p_out)
Retrieves a human-readable description of the element.
bool get_description(pfc::string_base &out)
bool is_edit_mode_enabled()
Queries whether "edit mode" is enabled. Most of UI element editing functionality should be locked whe...
static service_ptr_t< ui_element_config > g_create_empty(const GUID &id=pfc::guid_null)
virtual bool get_menu_command_description(pfc::string_base &out)
Override to use another description for our menu command. Relevant only when KFlagHavePopupCommand is...
virtual void edit_mode_context_menu_build(const POINT &p_point, bool p_fromkeyboard, HMENU p_menu, unsigned p_id_base)
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...
static const GUID ui_color_highlight
static service_ptr_t< ui_element_config > g_create(const GUID &id, const void *data, t_size size)
Helper.