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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
|
#include "stdafx.h"
/////////////////////////////////////////////////////////////////////////////////////////
// Global functions
static int CB_InitDefaultButtons(WPARAM, LPARAM)
{
BBButton bbd = {};
bbd.bbbFlags = BBBF_ISIMBUTTON | BBBF_ISARROWBUTTON | BBBF_CREATEBYID;
bbd.dwButtonID = IDC_PROTOCOL;
bbd.dwDefPos = 10;
bbd.hIcon = Skin_GetIconHandle(SKINICON_OTHER_CONNECTING);
bbd.pszModuleName = "Tabsrmm";
bbd.pwszTooltip = LPGENW("Protocol button");
g_plugin.addButton(&bbd);
bbd.dwButtonID = IDC_NAME;
bbd.dwDefPos = 20;
bbd.hIcon = Skin_GetIconHandle(SKINICON_OTHER_USERDETAILS);
bbd.pwszTooltip = LPGENW("Info button");
g_plugin.addButton(&bbd);
bbd.bbbFlags = BBBF_ISIMBUTTON | BBBF_ISCHATBUTTON | BBBF_ISPUSHBUTTON | BBBF_CANBEHIDDEN | BBBF_CREATEBYID | BBBF_NOREADONLY;
bbd.dwButtonID = IDC_SRMM_BOLD;
bbd.dwDefPos = 40;
bbd.hIcon = g_plugin.getIconHandle(IDI_FONTBOLD);
bbd.pwszTooltip = LPGENW("Bold text");
g_plugin.addButton(&bbd);
bbd.dwButtonID = IDC_SRMM_ITALICS;
bbd.dwDefPos = 50;
bbd.hIcon = g_plugin.getIconHandle(IDI_FONTITALIC);
bbd.pwszTooltip = LPGENW("Italic text");
g_plugin.addButton(&bbd);
bbd.dwButtonID = IDC_SRMM_UNDERLINE;
bbd.dwDefPos = 60;
bbd.hIcon = g_plugin.getIconHandle(IDI_FONTUNDERLINE);
bbd.pwszTooltip = LPGENW("Underlined text");
g_plugin.addButton(&bbd);
bbd.dwButtonID = IDC_SRMM_STRIKEOUT;
bbd.dwDefPos = 70;
bbd.hIcon = g_plugin.getIconHandle(IDI_STRIKEOUT);
bbd.pwszTooltip = LPGENW("Strikethrough text");
g_plugin.addButton(&bbd);
bbd.bbbFlags = BBBF_ISIMBUTTON | BBBF_ISCHATBUTTON | BBBF_ISRSIDEBUTTON | BBBF_ISARROWBUTTON | BBBF_CREATEBYID | BBBF_NOREADONLY;
bbd.dwButtonID = IDOK;
bbd.dwDefPos = 10;
bbd.hIcon = g_plugin.getIconHandle(IDI_SEND);
bbd.pwszTooltip = LPGENW("Send message\nClick dropdown arrow for sending options");
g_plugin.addButton(&bbd);
bbd.bbbFlags = BBBF_ISIMBUTTON | BBBF_ISCHATBUTTON | BBBF_ISRSIDEBUTTON | BBBF_CREATEBYID;
bbd.dwButtonID = IDC_CLOSE;
bbd.dwDefPos = 20;
bbd.hIcon = g_plugin.getIconHandle(IDI_CLOSEMSGDLG);
bbd.pwszTooltip = LPGENW("Close session");
g_plugin.addButton(&bbd);
bbd.bbbFlags = BBBF_ISIMBUTTON | BBBF_ISRSIDEBUTTON | BBBF_CREATEBYID | BBBF_NOREADONLY;
bbd.dwButtonID = IDC_QUOTE;
bbd.dwDefPos = 30;
bbd.hIcon = g_plugin.getIconHandle(IDI_QUOTE);
bbd.pwszTooltip = LPGENW("Quote last message OR selected text");
g_plugin.addButton(&bbd);
bbd.dwButtonID = IDC_TIME;
bbd.dwDefPos = 40;
bbd.hIcon = g_plugin.getIconHandle(IDI_MSGLOGOPT);
bbd.pwszTooltip = LPGENW("Message log options");
g_plugin.addButton(&bbd);
bbd.bbbFlags = BBBF_ISIMBUTTON | BBBF_ISCHATBUTTON | BBBF_ISRSIDEBUTTON | BBBF_CREATEBYID;
bbd.dwButtonID = IDC_SRMM_HISTORY;
bbd.dwDefPos = 50;
bbd.hIcon = Skin_GetIconHandle(SKINICON_OTHER_HISTORY);
bbd.pwszTooltip = LPGENW("View user's history");
g_plugin.addButton(&bbd);
// chat buttons
bbd.bbbFlags = BBBF_ISCHATBUTTON | BBBF_ISSEPARATOR;
bbd.dwButtonID = 1;
bbd.pszModuleName = "tb_splitter";
bbd.dwDefPos = 35;
bbd.hIcon = nullptr;
bbd.pwszTooltip = nullptr;
g_plugin.addButton(&bbd);
bbd.dwButtonID = 2;
bbd.dwDefPos = 22;
g_plugin.addButton(&bbd);
bbd.dwButtonID = 3;
bbd.dwDefPos = 71;
g_plugin.addButton(&bbd);
bbd.bbbFlags = BBBF_ISCHATBUTTON | BBBF_ISPUSHBUTTON | BBBF_CREATEBYID | BBBF_NOREADONLY;
bbd.dwButtonID = IDC_SRMM_COLOR;
bbd.pszModuleName = "Tabsrmm";
bbd.dwDefPos = 80;
bbd.hIcon = g_plugin.getIconHandle(IDI_FONTCOLOR);
bbd.pwszTooltip = LPGENW("Select a foreground color for the text (Ctrl+K)");
g_plugin.addButton(&bbd);
bbd.dwButtonID = IDC_SRMM_BKGCOLOR;
bbd.dwDefPos = 81;
bbd.hIcon = g_plugin.getIconHandle(IDI_BKGCOLOR);
bbd.pwszTooltip = LPGENW("Select a background color for the text (Ctrl+L)");
g_plugin.addButton(&bbd);
bbd.bbbFlags = BBBF_ISCHATBUTTON | BBBF_ISRSIDEBUTTON | BBBF_CREATEBYID;
bbd.dwButtonID = IDC_SRMM_SHOWNICKLIST;
bbd.dwDefPos = 22;
bbd.hIcon = g_plugin.getIconHandle(IDI_SHOWNICKLIST);
bbd.pwszTooltip = LPGENW("Show/hide the nick list (Ctrl+N)");
g_plugin.addButton(&bbd);
bbd.dwButtonID = IDC_SRMM_FILTER;
bbd.dwDefPos = 24;
bbd.hIcon = g_plugin.getIconHandle(IDI_FILTER2);
bbd.pwszTooltip = LPGENW("Enable/disable the event filter (Ctrl+F)");
g_plugin.addButton(&bbd);
bbd.dwButtonID = IDC_SRMM_CHANMGR;
bbd.dwDefPos = 33;
bbd.hIcon = g_plugin.getIconHandle(IDI_TOPICBUT);
bbd.pwszTooltip = LPGENW("Control this room (Ctrl+O)");
g_plugin.addButton(&bbd);
return 0;
}
void CMsgDialog::BB_InitDlgButtons()
{
uint8_t gap = DPISCALEX_S(Srmm_GetButtonGap());
RECT rcSplitter;
GetWindowRect(GetDlgItem(m_hwnd, IDC_SPLITTERY), &rcSplitter);
POINT ptSplitter = { 0, rcSplitter.top };
ScreenToClient(m_hwnd, &ptSplitter);
RECT rect;
GetClientRect(m_hwnd, &rect);
m_bbLSideWidth = m_bbRSideWidth = 0;
CustomButtonData *cbd;
for (int i = 0; cbd = Srmm_GetNthButton(i); i++) {
HWND hwndButton = GetDlgItem(m_hwnd, cbd->m_dwButtonCID);
if (hwndButton == nullptr)
continue;
if (!cbd->m_bHidden) {
if (cbd->m_bRSided)
m_bbRSideWidth += cbd->m_iButtonWidth + gap;
else
m_bbLSideWidth += cbd->m_iButtonWidth + gap;
}
if (!cbd->m_bHidden && !cbd->m_bCanBeHidden)
m_iButtonBarReallyNeeds += cbd->m_iButtonWidth + gap;
if (cbd->m_bSeparator)
continue;
CustomizeButton(hwndButton);
if (cbd->m_dwArrowCID)
SendMessage(hwndButton, BUTTONSETARROW, (cbd->m_dwButtonCID == IDOK) ? IDC_SENDMENU : cbd->m_dwArrowCID, 0);
SendMessage(hwndButton, BUTTONSETASTHEMEDBTN, CSkin::IsThemed(), 0);
SendMessage(hwndButton, BUTTONSETCONTAINER, (LPARAM)m_pContainer, 0);
SendMessage(hwndButton, BUTTONSETASTOOLBARBUTTON, TRUE, 0);
}
}
void CMsgDialog::BB_RedrawButtons()
{
Srmm_RedrawToolbarIcons(m_hwnd);
HWND hwndToggleSideBar = GetDlgItem(m_hwnd, IDC_TOGGLESIDEBAR);
if (hwndToggleSideBar && IsWindow(hwndToggleSideBar))
InvalidateRect(hwndToggleSideBar, nullptr, TRUE);
}
void CMsgDialog::BB_RefreshTheme()
{
CustomButtonData *cbd;
for (int i = 0; cbd = Srmm_GetNthButton(i); i++)
SendDlgItemMessage(m_hwnd, cbd->m_dwButtonCID, WM_THEMECHANGED, 0, 0);
}
BOOL CMsgDialog::BB_SetButtonsPos()
{
if (!m_hwnd || !IsWindowVisible(m_hwnd))
return 0;
uint8_t gap = DPISCALEX_S(Srmm_GetButtonGap());
bool showToolbar = !m_pContainer->cfg.flags.m_bHideToolbar;
bool bBottomToolbar = m_pContainer->cfg.flags.m_bBottomToolbar;
HWND hwndToggleSideBar = GetDlgItem(m_hwnd, IDC_TOGGLESIDEBAR);
ShowWindow(hwndToggleSideBar, (showToolbar && m_pContainer->m_pSideBar->isActive()) ? SW_SHOW : SW_HIDE);
HDWP hdwp = BeginDeferWindowPos(Srmm_GetButtonCount() + 1);
RECT rcSplitter;
GetWindowRect(GetDlgItem(m_hwnd, IDC_SPLITTERY), &rcSplitter);
POINT ptSplitter = { 0, rcSplitter.top };
ScreenToClient(m_hwnd, &ptSplitter);
RECT rect;
GetClientRect(m_hwnd, &rect);
int splitterY = (!bBottomToolbar) ? ptSplitter.y - DPISCALEY_S(2) : rect.bottom;
int tempL = m_bbLSideWidth, tempR = m_bbRSideWidth;
int lwidth = 0, rwidth = 0;
int iOff = DPISCALEY_S(22);
int foravatar = 0;
if ((rect.bottom - ptSplitter.y - (rcSplitter.bottom - rcSplitter.top) /*- DPISCALEY(2)*/ - (bBottomToolbar ? DPISCALEY_S(24) : 0) < m_pic.cy - DPISCALEY_S(2)) && m_bShowAvatar && !PluginConfig.m_bAlwaysFullToolbarWidth)
foravatar = m_pic.cx + gap;
if (m_pContainer->cfg.flags.m_bSideBar && (m_pContainer->m_pSideBar->getFlags() & CSideBar::SIDEBARORIENTATION_LEFT)) {
if (nullptr != hwndToggleSideBar) /* Wine fix. */
hdwp = DeferWindowPos(hdwp, hwndToggleSideBar, nullptr, 4, 2 + splitterY - iOff, 0, 0, SWP_NOZORDER | SWP_NOSIZE);
lwidth += 10;
tempL -= 10;
}
CustomButtonData *cbd;
for (int i = 0; cbd = Srmm_GetNthButton(i); i++) {
if (cbd->m_bRSided || !BB_IsDisplayed(cbd)) // filter only left & displayed buttons
continue;
HWND hwndButton = GetDlgItem(m_hwnd, cbd->m_dwButtonCID);
if (hwndButton == nullptr)
continue;
bool bAutoHidden = mapHidden[cbd];
int iCmd = SW_SHOW;
if (showToolbar) {
if (!cbd->m_bSeparator && !IsWindowEnabled(hwndButton) && !bAutoHidden)
tempL -= cbd->m_iButtonWidth + gap;
if (cbd->m_bCanBeHidden && !cbd->m_bHidden) {
if (!bAutoHidden) {
if (tempL + tempR > (rect.right - foravatar) && (cbd->m_bSeparator || IsWindowVisible(hwndButton))) {
iCmd = SW_HIDE;
bAutoHidden = true;
tempL -= cbd->m_iButtonWidth + gap;
}
}
else bAutoHidden = false;
}
}
else iCmd = SW_HIDE;
ShowWindow(hwndButton, iCmd);
hdwp = DeferWindowPos(hdwp, hwndButton, nullptr, lwidth, splitterY - iOff, 0, 0, SWP_NOZORDER | SWP_NOSIZE);
if (IsWindowVisible(hwndButton) || (cbd->m_bSeparator && !(bAutoHidden || cbd->m_bHidden)))
lwidth += cbd->m_iButtonWidth + gap;
mapHidden[cbd] = bAutoHidden;
}
if (m_pContainer->cfg.flags.m_bSideBar && (m_pContainer->m_pSideBar->getFlags() & CSideBar::SIDEBARORIENTATION_RIGHT)) {
if (nullptr != hwndToggleSideBar) /* Wine fix. */
hdwp = DeferWindowPos(hdwp, hwndToggleSideBar, nullptr, rect.right - foravatar - 10, 2 + splitterY - iOff, 0, 0, SWP_NOZORDER | SWP_NOSIZE);
rwidth += 12;
tempR -= 12;
}
for (int i = 0; cbd = Srmm_GetNthButton(i); i++) {
if (!cbd->m_bRSided || !BB_IsDisplayed(cbd)) // filter only right & displayed buttons
continue;
HWND hwndButton = GetDlgItem(m_hwnd, cbd->m_dwButtonCID);
if (hwndButton == nullptr)
continue;
bool bAutoHidden = mapHidden[cbd];
int iCmd = SW_SHOW;
if (showToolbar) {
if (!cbd->m_bSeparator && !IsWindowVisible(hwndButton) && !IsWindowEnabled(hwndButton) && !bAutoHidden)
tempR -= cbd->m_iButtonWidth + gap;
if (cbd->m_bCanBeHidden && !cbd->m_bHidden) {
if (!bAutoHidden) {
if (tempL + tempR > (rect.right - foravatar) && (cbd->m_bSeparator || IsWindowVisible(hwndButton))) {
iCmd = SW_HIDE;
bAutoHidden = true;
tempR -= cbd->m_iButtonWidth + gap;
}
}
else bAutoHidden = false;
}
}
else iCmd = SW_HIDE;
ShowWindow(hwndButton, iCmd);
if (IsWindowVisible(hwndButton) || (cbd->m_bSeparator && !(bAutoHidden || cbd->m_bHidden)))
rwidth += cbd->m_iButtonWidth + gap;
hdwp = DeferWindowPos(hdwp, hwndButton, nullptr, rect.right - foravatar - rwidth + gap, splitterY - iOff, 0, 0, SWP_NOZORDER | SWP_NOSIZE);
mapHidden[cbd] = bAutoHidden;
}
return EndDeferWindowPos(hdwp);
}
void CMsgDialog::CB_DestroyAllButtons()
{
CustomButtonData *cbd;
for (int i = 0; cbd = Srmm_GetNthButton(i); i++) {
HWND hwndButton = GetDlgItem(m_hwnd, cbd->m_dwButtonCID);
if (hwndButton)
DestroyWindow(hwndButton);
}
}
void CMsgDialog::CB_DestroyButton(uint32_t dwButtonCID, uint32_t dwFlags)
{
HWND hwndButton = GetDlgItem(m_hwnd, dwButtonCID);
if (hwndButton == nullptr)
return;
RECT rc = { 0 };
GetClientRect(hwndButton, &rc);
if (dwFlags & BBBF_ISRSIDEBUTTON)
m_bbRSideWidth -= rc.right;
else
m_bbLSideWidth -= rc.right;
DestroyWindow(hwndButton);
BB_SetButtonsPos();
}
void CMsgDialog::CB_ChangeButton(CustomButtonData *cbd)
{
HWND hwndButton = GetDlgItem(m_hwnd, cbd->m_dwButtonCID);
if (hwndButton == nullptr)
return;
if (cbd->m_hIcon)
SendMessage(hwndButton, BM_SETIMAGE, IMAGE_ICON, (LPARAM)IcoLib_GetIconByHandle(cbd->m_hIcon));
if (cbd->m_pwszTooltip)
SendMessage(hwndButton, BUTTONADDTOOLTIP, (WPARAM)LPARAM(TranslateW_LP(cbd->m_pwszTooltip, cbd->m_pPlugin)), BATF_UNICODE);
SendMessage(hwndButton, BUTTONSETCONTAINER, (LPARAM)m_pContainer, 0);
SetWindowTextA(hwndButton, cbd->m_pszModuleName);
}
/////////////////////////////////////////////////////////////////////////////////////////
// Module init procedure
void CB_InitCustomButtons()
{
HookTemporaryEvent(ME_MSG_TOOLBARLOADED, CB_InitDefaultButtons);
}
|