comparison foosdk/sdk/foobar2000/helpers/dropdown_helper.h @ 1:20d02a178406 default tip

*: check in everything else yay
author Paper <paper@tflc.us>
date Mon, 05 Jan 2026 02:15:46 -0500
parents
children
comparison
equal deleted inserted replaced
0:e9bb126753e7 1:20d02a178406
1 #pragma once
2
3 #include "../SDK/cfg_var.h"
4
5 class _cfg_dropdown_history_base
6 {
7 const unsigned m_max;
8 void build_list(pfc::ptr_list_t<char> & out);
9 void parse_list(const pfc::ptr_list_t<char> & src);
10 public:
11 enum {separator = '\n'};
12
13 _cfg_dropdown_history_base(const GUID & varid, unsigned p_max = 10, const char * initial = "") : m_max(p_max), m_state(varid, initial) {}
14 #ifdef FOOBAR2000_DESKTOP_WINDOWS
15 void on_init(HWND ctrl, const char * initVal) {
16 add_item(initVal); setup_dropdown(ctrl); uSetWindowText(ctrl, initVal);
17 }
18 void setup_dropdown(HWND wnd);
19 void setup_dropdown_set_value(HWND wnd);
20 void setup_dropdown(HWND wnd,UINT id) {setup_dropdown(GetDlgItem(wnd,id));}
21 bool on_context(HWND wnd,LPARAM coords); //returns true when the content has changed
22 bool add_item(const char * item, HWND combobox); //immediately adds the item to the combobox
23 #endif
24 bool add_item(const char * item); //returns true when the content has changed, false when not (the item was already on the list)
25 bool is_empty();
26
27 void set_state(const char* val) { m_state = val; }
28 void get_state(pfc::string_base& out) { out = m_state.get(); }
29 private:
30 cfg_string m_state;
31 };
32
33 typedef _cfg_dropdown_history_base cfg_dropdown_history;
34 typedef _cfg_dropdown_history_base cfg_dropdown_history_mt;
35
36 #ifdef FOOBAR2000_DESKTOP_WINDOWS
37 // ATL-compatible message map entry macro for installing dropdown list context menus.
38 #define DROPDOWN_HISTORY_HANDLER(ctrlID,var) \
39 if(uMsg == WM_CONTEXTMENU) { \
40 const HWND source = (HWND) wParam; \
41 if (source != NULL && source == CWindow(hWnd).GetDlgItem(ctrlID)) { \
42 var.on_context(source,lParam); \
43 lResult = 0; \
44 return TRUE; \
45 } \
46 }
47
48 #endif // FOOBAR2000_DESKTOP_WINDOWS