|
1
|
1 #include "stdafx.h"
|
|
|
2 #include "AutoComplete.h"
|
|
|
3 #include <ShlGuid.h> // CLSID_AutoComplete
|
|
|
4 #include "../helpers/COM_utils.h"
|
|
|
5 #include "../helpers/dropdown_helper.h"
|
|
|
6 #include <libPPUI/CEnumString.h>
|
|
|
7
|
|
|
8 using PP::CEnumString;
|
|
|
9
|
|
|
10 namespace {
|
|
|
11 class CACList_History : public CEnumString {
|
|
|
12 public:
|
|
|
13 CACList_History(cfg_dropdown_history_mt * var) : m_var(var) { Reset(); }
|
|
|
14 typedef ImplementCOMRefCounter<CACList_History> TImpl;
|
|
|
15
|
|
|
16 HRESULT STDMETHODCALLTYPE Reset() {
|
|
|
17 /*if (core_api::assert_main_thread())*/ {
|
|
|
18 ResetStrings();
|
|
|
19 pfc::string8 state; m_var->get_state(state);
|
|
|
20 for (const char * walk = state;;) {
|
|
|
21 const char * next = strchr(walk, cfg_dropdown_history_mt::separator);
|
|
|
22 t_size len = (next != NULL) ? next - walk : ~0;
|
|
|
23 AddStringU(walk, len);
|
|
|
24 if (next == NULL) break;
|
|
|
25 walk = next + 1;
|
|
|
26 }
|
|
|
27 }
|
|
|
28 return __super::Reset();
|
|
|
29 }
|
|
|
30
|
|
|
31 HRESULT STDMETHODCALLTYPE Clone(IEnumString **ppenum) {
|
|
|
32 *ppenum = new TImpl(*this); return S_OK;
|
|
|
33 }
|
|
|
34
|
|
|
35 private:
|
|
|
36 cfg_dropdown_history_mt * const m_var;
|
|
|
37 };
|
|
|
38 }
|
|
|
39
|
|
|
40 HRESULT InitializeDropdownAC(HWND comboBox, cfg_dropdown_history_mt & var, const char * initVal) {
|
|
|
41 var.on_init(comboBox, initVal);
|
|
|
42 COMBOBOXINFO ci = {}; ci.cbSize = sizeof(ci);
|
|
|
43 if (!GetComboBoxInfo(comboBox, &ci)) {
|
|
|
44 PFC_ASSERT(!"Should not get here - GetComboBoxInfo fail!");
|
|
|
45 return E_FAIL;
|
|
|
46 }
|
|
|
47 pfc::com_ptr_t<IUnknown> acl = new CACList_History::TImpl(&var);
|
|
|
48 return InitializeSimpleAC(ci.hwndItem, acl.get_ptr(), ACO_AUTOAPPEND|ACO_AUTOSUGGEST);
|
|
|
49 }
|