forked from Paremo/foo_bbookmark
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcui_bmark.cpp
More file actions
115 lines (77 loc) · 3 KB
/
cui_bmark.cpp
File metadata and controls
115 lines (77 loc) · 3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
#include "stdafx.h"
#include <optional>
#include "bookmark_core.h"
#include "guids.h"
#include "bookmark_list_dialog.h"
using namespace glb;
namespace {
// CUI element class
class cui_bmark : public ui_extension::window {
ui_extension::window_host_ptr m_host;
std::optional<CListCtrlMarkDialog> window;
public:
cui_bmark() = default;
const GUID& get_extension_guid() const final { return guid_cui_bmark; }
void get_name(pfc::string_base& out) const final { out = COMPONENT_NAME_HC; }
void get_category(pfc::string_base& out) const final { out = "Panels"; }
unsigned get_type() const final { return ui_extension::type_panel; }
HWND get_wnd() const override final { return window->get_wnd(); }
bool is_available(const ui_extension::window_host_ptr& p_host) const final {
return !m_host.is_valid() || p_host->get_host_guid() != m_host->get_host_guid();
}
const bool get_is_single_instance() const override final { return true; }
// create or transfer
HWND create_or_transfer_window(HWND wnd_parent,
const ui_extension::window_host_ptr& p_host,
const ui_helpers::window_position_t& p_position) final override {
if (!window || !window->get_wnd()) {
try {
// create dlg
window.emplace(wnd_parent, m_hosted_sorted_dir, m_hosted_colWidths, m_hosted_colActive, m_hosted_last_focus);
}
catch (std::exception& e) {
FB2K_console_formatter()
<< COMPONENT_NAME << " panel failed to initialize: " << e.what();
return nullptr;
}
m_host = p_host;
ShowWindow(window->get_wnd(), SW_HIDE);
SetWindowPos(window->get_wnd(), nullptr, p_position.x, p_position.y, p_position.cx,
p_position.cy, SWP_NOZORDER);
}
else {
// transfer dlg
ShowWindow(window->get_wnd(), SW_HIDE);
SetParent(window->get_wnd(), wnd_parent);
SetWindowPos(window->get_wnd(), nullptr, p_position.x, p_position.y, p_position.cx,
p_position.cy, SWP_NOZORDER);
m_host->relinquish_ownership(window->get_wnd());
m_host = p_host;
}
return window->get_wnd();
}
// set_config
void set_config(stream_reader* p_reader, t_size p_size, abort_callback& p_abort) override {
//window is not created yet
dlg::CListCtrlMarkDialog::set_cui_config(p_reader, p_size, p_abort, m_hosted_sorted_dir, m_hosted_colWidths, m_hosted_colActive, m_hosted_last_focus);
};
// get_config
void get_config(stream_writer* p_writer, abort_callback& p_abort) const override {
stream_writer_formatter<false> writer(*p_writer, p_abort);
window->get_uicfg(&writer, p_abort);
};
void destroy_window() final {
//container_uie_window_v3_t::destroy_windows
window.value().DestroyWindow();
window.reset();
m_host.release();
}
private:
std::array<uint32_t, colcast(dlg::colID::N_COLUMNS)> m_hosted_colWidths;
std::array<bool, colcast(dlg::colID::N_COLUMNS)> m_hosted_colActive;
bool m_hosted_sorted_dir;
uint32_t m_hosted_last_focus;
};
// S T A T I C C U I - E L E M E N T
static service_factory_single_t<cui_bmark> cui_bmark_instance;
}