summaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2019-06-27 14:22:39 +0300
committerGeorge Hazan <ghazan@miranda.im>2019-06-27 14:22:39 +0300
commit0f4542cbcbb9dfb24f97fbe16bb29d7c00ccb787 (patch)
tree46dd64cbeceb902fd63384c4eade6e07eec98513 /src/core
parent0e7a2216d980e86bea9eee10941e4b414bb231fc (diff)
StdPopup:
- obsolete ANSI code cleaning; - code formatting
Diffstat (limited to 'src/core')
-rw-r--r--src/core/stdpopup/src/icons.cpp2
-rw-r--r--src/core/stdpopup/src/message_pump.cpp12
-rw-r--r--src/core/stdpopup/src/message_pump.h12
-rw-r--r--src/core/stdpopup/src/options.cpp129
-rw-r--r--src/core/stdpopup/src/options.h12
-rw-r--r--src/core/stdpopup/src/popwin.cpp133
-rw-r--r--src/core/stdpopup/src/popwin.h6
-rw-r--r--src/core/stdpopup/src/services.cpp102
-rw-r--r--src/core/stdpopup/src/stdafx.h2
-rw-r--r--src/core/stdpopup/src/yapp.cpp11
-rw-r--r--src/core/stdpopup/src/yapp_history.cpp40
-rw-r--r--src/core/stdpopup/src/yapp_history.h67
-rw-r--r--src/core/stdpopup/src/yapp_history_dlg.cpp16
13 files changed, 260 insertions, 284 deletions
diff --git a/src/core/stdpopup/src/icons.cpp b/src/core/stdpopup/src/icons.cpp
index 129d00c181..60ada65a13 100644
--- a/src/core/stdpopup/src/icons.cpp
+++ b/src/core/stdpopup/src/icons.cpp
@@ -18,5 +18,5 @@ static IconItem iconList2[] =
void InitIcons()
{
g_plugin.registerIcon(SECT_TOLBAR, iconList1);
- g_plugin.registerIcon(SECT_POPUP, iconList2);
+ g_plugin.registerIcon(SECT_POPUP, iconList2);
}
diff --git a/src/core/stdpopup/src/message_pump.cpp b/src/core/stdpopup/src/message_pump.cpp
index 8b609eafc9..e93ab0094a 100644
--- a/src/core/stdpopup/src/message_pump.cpp
+++ b/src/core/stdpopup/src/message_pump.cpp
@@ -9,7 +9,7 @@ HANDLE hMPEvent;
#define MAX_POPUPS 100
-unsigned __stdcall MessagePumpThread(void* param)
+unsigned __stdcall MessagePumpThread(void *param)
{
if (param)
SetEvent((HANDLE)param);
@@ -18,7 +18,7 @@ unsigned __stdcall MessagePumpThread(void* param)
while (GetMessage(&hwndMsg, nullptr, 0, 0) > 0 && !bShutdown) {
if (hwndMsg.hwnd != nullptr && IsDialogMessage(hwndMsg.hwnd, &hwndMsg)) /* Wine fix. */
continue;
- switch(hwndMsg.message) {
+ switch (hwndMsg.message) {
case MUM_CREATEPOPUP:
{
bool enabled = true;
@@ -28,7 +28,7 @@ unsigned __stdcall MessagePumpThread(void* param)
if ((options.disable_full_screen && IsFullScreen()) || IsWorkstationLocked())
enabled = false;
- PopupData *pd = (PopupData*)hwndMsg.lParam;
+ PopupData *pd = (PopupData *)hwndMsg.lParam;
if (enabled && num_popups < MAX_POPUPS) {
HWND hwnd = CreateWindowEx(WS_EX_TOOLWINDOW | WS_EX_TOPMOST, POP_WIN_CLASS, L"Popup", WS_POPUP, 0, 0, 0, 0, nullptr, nullptr, g_plugin.getInst(), (LPVOID)hwndMsg.lParam);
num_popups++;
@@ -36,8 +36,8 @@ unsigned __stdcall MessagePumpThread(void* param)
SendMessage(hwnd, PUM_SETNOTIFYH, hwndMsg.wParam, 0);
}
else if (pd) {
- mir_free(pd->pwzTitle);
- mir_free(pd->pwzText);
+ mir_free(pd->pwszTitle);
+ mir_free(pd->pwszText);
mir_free(pd);
}
}
@@ -93,7 +93,7 @@ void InitMessagePump()
popup_win_class.lpfnWndProc = PopupWindowProc;
popup_win_class.hInstance = g_plugin.getInst();
popup_win_class.lpszClassName = POP_WIN_CLASS;
- popup_win_class.hCursor = LoadCursor(nullptr, IDC_ARROW);
+ popup_win_class.hCursor = LoadCursor(nullptr, IDC_ARROW);
RegisterClass(&popup_win_class);
InitServices();
diff --git a/src/core/stdpopup/src/message_pump.h b/src/core/stdpopup/src/message_pump.h
index e58d039850..c72a3eb47a 100644
--- a/src/core/stdpopup/src/message_pump.h
+++ b/src/core/stdpopup/src/message_pump.h
@@ -17,16 +17,8 @@ struct PopupData
int flags; // OR of PDF_* flags below
MCONTACT hContact;
HICON hIcon;
- union {
- char *pszTitle;
- wchar_t *ptzTitle;
- wchar_t *pwzTitle;
- };
- union {
- char *pszText;
- wchar_t *ptzText;
- wchar_t *pwzText;
- };
+ wchar_t *pwszTitle;
+ wchar_t *pwszText;
COLORREF colorBack; // if colorBack and colorText are equal, defaults will be used
COLORREF colorText;
WNDPROC windowProc; // optional custom window procedure
diff --git a/src/core/stdpopup/src/options.cpp b/src/core/stdpopup/src/options.cpp
index 1bb5d199f1..d8f10fe511 100644
--- a/src/core/stdpopup/src/options.cpp
+++ b/src/core/stdpopup/src/options.cpp
@@ -4,7 +4,8 @@ Options options;
HICON hPopupIcon = nullptr;
-void LoadModuleDependentOptions() {
+void LoadModuleDependentOptions()
+{
if (ServiceExists(MS_AV_DRAWAVATAR))
options.av_layout = (PopupAvLayout)g_plugin.getByte("AVLayout", PAV_RIGHT);
else
@@ -18,22 +19,22 @@ void LoadModuleDependentOptions() {
void LoadOptions()
{
options.default_timeout = g_plugin.getDword("DefaultTimeout", 7);
- options.win_width = g_plugin.getDword("WinWidth", 220);
- options.win_max_height = g_plugin.getDword("WinMaxHeight", 400);
- options.location = (PopupLocation)g_plugin.getByte("Location", (BYTE)PL_BOTTOMRIGHT);
- options.opacity = g_plugin.getByte("Opacity", 75);
- options.border = g_plugin.getByte("Border", 1) == 1;
- options.round = g_plugin.getByte("RoundCorners", 1) == 1;
- options.av_round = g_plugin.getByte("AvatarRoundCorners", 1) == 1;
- options.animate = g_plugin.getByte("Animate", 0);
- options.trans_bg = g_plugin.getByte("TransparentBg", 0) == 1;
+ options.win_width = g_plugin.getDword("WinWidth", 220);
+ options.win_max_height = g_plugin.getDword("WinMaxHeight", 400);
+ options.location = (PopupLocation)g_plugin.getByte("Location", (BYTE)PL_BOTTOMRIGHT);
+ options.opacity = g_plugin.getByte("Opacity", 75);
+ options.border = g_plugin.getByte("Border", 1) == 1;
+ options.round = g_plugin.getByte("RoundCorners", 1) == 1;
+ options.av_round = g_plugin.getByte("AvatarRoundCorners", 1) == 1;
+ options.animate = g_plugin.getByte("Animate", 0);
+ options.trans_bg = g_plugin.getByte("TransparentBg", 0) == 1;
options.use_mim_monitor = g_plugin.getByte("UseMimMonitor", 1) == 1;
- options.right_icon = g_plugin.getByte("RightIcon", 0) == 1;
- options.av_layout = PAV_NONE; // corrected in LoadModuleDependentOptions function above
- options.av_size = g_plugin.getDword("AVSize", 40); //tweety
- options.text_indent = g_plugin.getDword("TextIndent", 22);
- options.global_hover = g_plugin.getByte("GlobalHover", 1) == 1;
- options.time_layout = (PopupTimeLayout)g_plugin.getByte("TimeLayout", PT_RIGHT);
+ options.right_icon = g_plugin.getByte("RightIcon", 0) == 1;
+ options.av_layout = PAV_NONE; // corrected in LoadModuleDependentOptions function above
+ options.av_size = g_plugin.getDword("AVSize", 40); //tweety
+ options.text_indent = g_plugin.getDword("TextIndent", 22);
+ options.global_hover = g_plugin.getByte("GlobalHover", 1) == 1;
+ options.time_layout = (PopupTimeLayout)g_plugin.getByte("TimeLayout", PT_RIGHT);
char buff[128];
for (int i = 0; i < 10; i++) {
@@ -83,20 +84,20 @@ void SaveOptions()
void ShowExamplePopups()
{
- PopupData pd = {sizeof(PopupData)};
+ PopupData pd = { sizeof(PopupData) };
pd.hIcon = hPopupIcon;
- pd.flags = PDF_TCHAR;
+ pd.flags = PDF_UNICODE;
- pd.ptzTitle = TranslateT("Example");
- pd.ptzText = TranslateT("The quick brown fox jumped over the lazy dog.");
+ pd.pwszTitle = TranslateT("Example");
+ pd.pwszText = TranslateT("The quick brown fox jumped over the lazy dog.");
ShowPopup(pd);
- pd.ptzTitle = TranslateT("Example With a Long Title");
- pd.ptzText = TranslateT("The quick brown fox jumped over the lazy dog.");
+ pd.pwszTitle = TranslateT("Example With a Long Title");
+ pd.pwszText = TranslateT("The quick brown fox jumped over the lazy dog.");
ShowPopup(pd);
- pd.ptzTitle = TranslateT("Example");
- pd.ptzText = TranslateT("Thequickbrownfoxjumpedoverthelazydog.");
+ pd.pwszTitle = TranslateT("Example");
+ pd.pwszText = TranslateT("Thequickbrownfoxjumpedoverthelazydog.");
ShowPopup(pd);
for (auto &hContact : Contacts()) {
@@ -104,7 +105,7 @@ void ShowExamplePopups()
AVATARCACHEENTRY *ace = (AVATARCACHEENTRY *)CallService(MS_AV_GETAVATARBITMAP, hContact, 0);
if (ace && (ace->dwFlags & AVS_BITMAP_VALID)) {
pd.hContact = hContact;
- pd.ptzText = TranslateT("An avatar.");
+ pd.pwszText = TranslateT("An avatar.");
ShowPopup(pd);
break;
}
@@ -114,9 +115,9 @@ void ShowExamplePopups()
static INT_PTR CALLBACK DlgProcOpts1(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
- switch ( msg ) {
+ switch (msg) {
case WM_INITDIALOG:
- TranslateDialogDefault( hwndDlg );
+ TranslateDialogDefault(hwndDlg);
SendDlgItemMessage(hwndDlg, IDC_CMB_PLACEMENT, CB_ADDSTRING, 0, (LPARAM)TranslateT("Bottom right"));
SendDlgItemMessage(hwndDlg, IDC_CMB_PLACEMENT, CB_ADDSTRING, 0, (LPARAM)TranslateT("Bottom left"));
@@ -157,9 +158,9 @@ static INT_PTR CALLBACK DlgProcOpts1(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR
HWND hwndList = GetDlgItem(hwndDlg, IDC_LST_STATUS);
ListView_DeleteAllItems(hwndList);
- SendMessage(hwndList,LVM_SETEXTENDEDLISTVIEWSTYLE, 0,LVS_EX_FULLROWSELECT | LVS_EX_CHECKBOXES);
+ SendMessage(hwndList, LVM_SETEXTENDEDLISTVIEWSTYLE, 0, LVS_EX_FULLROWSELECT | LVS_EX_CHECKBOXES);
- LVCOLUMN lvc = {0};
+ LVCOLUMN lvc = { 0 };
// Initialize the LVCOLUMN structure.
// The mask specifies that the format, width, text, and
// subitem members of the structure are valid.
@@ -167,11 +168,11 @@ static INT_PTR CALLBACK DlgProcOpts1(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR
lvc.fmt = LVCFMT_LEFT;
lvc.iSubItem = 0;
- lvc.pszText = TranslateT("Status");
+ lvc.pszText = TranslateT("Status");
lvc.cx = 200; // width of column in pixels
ListView_InsertColumn(hwndList, 0, &lvc);
- LVITEM lvI = {0};
+ LVITEM lvI = { 0 };
// Some code to create the list-view control.
// Initialize LVITEM members that are common to all
@@ -210,17 +211,17 @@ static INT_PTR CALLBACK DlgProcOpts1(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR
CheckDlgButton(hwndDlg, IDC_RAD_TIMEOUT, BST_CHECKED);
SetDlgItemInt(hwndDlg, IDC_ED_TIMEOUT, options.default_timeout, FALSE);
}
-
+
if (options.right_icon)
CheckDlgButton(hwndDlg, IDC_RAD_RIGHTICON, BST_CHECKED);
else
CheckDlgButton(hwndDlg, IDC_RAD_LEFTICON, BST_CHECKED);
if (ServiceExists(MS_AV_DRAWAVATAR)) {
- switch(options.av_layout) {
- case PAV_NONE: CheckDlgButton(hwndDlg, IDC_RAD_NOAV, BST_CHECKED); break;
- case PAV_RIGHT: CheckDlgButton(hwndDlg, IDC_RAD_RIGHTAV, BST_CHECKED); break;
- case PAV_LEFT: CheckDlgButton(hwndDlg, IDC_RAD_LEFTAV, BST_CHECKED); break;
+ switch (options.av_layout) {
+ case PAV_NONE: CheckDlgButton(hwndDlg, IDC_RAD_NOAV, BST_CHECKED); break;
+ case PAV_RIGHT: CheckDlgButton(hwndDlg, IDC_RAD_RIGHTAV, BST_CHECKED); break;
+ case PAV_LEFT: CheckDlgButton(hwndDlg, IDC_RAD_LEFTAV, BST_CHECKED); break;
}
}
else {
@@ -238,11 +239,11 @@ static INT_PTR CALLBACK DlgProcOpts1(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR
SetDlgItemInt(hwndDlg, IDC_ED_SBWIDTH, options.sb_width, FALSE);
SetDlgItemInt(hwndDlg, IDC_ED_PADDING, options.padding, FALSE);
- switch(options.location) {
- case PL_BOTTOMRIGHT: CheckDlgButton(hwndDlg, IDC_RAD_BOTTOMRIGHT, BST_CHECKED); break;
- case PL_BOTTOMLEFT: CheckDlgButton(hwndDlg, IDC_RAD_BOTTOMLEFT, BST_CHECKED); break;
- case PL_TOPRIGHT: CheckDlgButton(hwndDlg, IDC_RAD_TOPRIGHT, BST_CHECKED); break;
- case PL_TOPLEFT: CheckDlgButton(hwndDlg, IDC_RAD_TOPLEFT, BST_CHECKED); break;
+ switch (options.location) {
+ case PL_BOTTOMRIGHT: CheckDlgButton(hwndDlg, IDC_RAD_BOTTOMRIGHT, BST_CHECKED); break;
+ case PL_BOTTOMLEFT: CheckDlgButton(hwndDlg, IDC_RAD_BOTTOMLEFT, BST_CHECKED); break;
+ case PL_TOPRIGHT: CheckDlgButton(hwndDlg, IDC_RAD_TOPRIGHT, BST_CHECKED); break;
+ case PL_TOPLEFT: CheckDlgButton(hwndDlg, IDC_RAD_TOPLEFT, BST_CHECKED); break;
}
SetDlgItemInt(hwndDlg, IDC_ED_TRANS, options.opacity, FALSE);
@@ -259,16 +260,16 @@ static INT_PTR CALLBACK DlgProcOpts1(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR
return FALSE;
case WM_COMMAND:
- if ( HIWORD(wParam) == CBN_SELCHANGE)
+ if (HIWORD(wParam) == CBN_SELCHANGE)
SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
- else if ( HIWORD(wParam) == EN_CHANGE && (HWND)lParam == GetFocus())
+ else if (HIWORD(wParam) == EN_CHANGE && (HWND)lParam == GetFocus())
SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
- else if ( HIWORD(wParam) == BN_CLICKED ) {
+ else if (HIWORD(wParam) == BN_CLICKED) {
if (LOWORD(wParam) == IDC_BTN_PREVIEW)
ShowExamplePopups();
else {
HWND hw = GetDlgItem(hwndDlg, IDC_ED_TIMEOUT);
- switch( LOWORD(wParam)) {
+ switch (LOWORD(wParam)) {
case IDC_RAD_NOTIMEOUT:
EnableWindow(hw, IsDlgButtonChecked(hwndDlg, IDC_RAD_TIMEOUT));
break;
@@ -282,16 +283,16 @@ static INT_PTR CALLBACK DlgProcOpts1(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR
break;
case WM_NOTIFY:
- if (IsWindowVisible(hwndDlg) && ((LPNMHDR) lParam)->hwndFrom == GetDlgItem(hwndDlg, IDC_LST_STATUS)) {
- switch (((LPNMHDR) lParam)->code) {
+ if (IsWindowVisible(hwndDlg) && ((LPNMHDR)lParam)->hwndFrom == GetDlgItem(hwndDlg, IDC_LST_STATUS)) {
+ switch (((LPNMHDR)lParam)->code) {
case LVN_ITEMCHANGED:
NMLISTVIEW *nmlv = (NMLISTVIEW *)lParam;
if ((nmlv->uNewState ^ nmlv->uOldState) & LVIS_STATEIMAGEMASK)
- SendMessage( GetParent( hwndDlg ), PSM_CHANGED, 0, 0);
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
break;
}
}
- else if (((LPNMHDR)lParam)->code == (unsigned)PSN_APPLY ) {
+ else if (((LPNMHDR)lParam)->code == (unsigned)PSN_APPLY) {
BOOL trans;
int new_val;
if (IsDlgButtonChecked(hwndDlg, IDC_RAD_NOTIMEOUT))
@@ -327,8 +328,8 @@ static INT_PTR CALLBACK DlgProcOpts1(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR
new_val = GetDlgItemInt(hwndDlg, IDC_ED_TRANS, &trans, FALSE);
if (trans) options.opacity = new_val;
options.border = IsDlgButtonChecked(hwndDlg, IDC_CHK_BORDER) && IsWindowEnabled(GetDlgItem(hwndDlg, IDC_CHK_BORDER)) ? true : false;
- options.round = IsDlgButtonChecked(hwndDlg, IDC_CHK_ROUNDCORNERS) && IsWindowEnabled(GetDlgItem(hwndDlg, IDC_CHK_ROUNDCORNERS)) ? true : false;
- options.av_round = IsDlgButtonChecked(hwndDlg, IDC_CHK_ROUNDCORNERSAV) && IsWindowEnabled(GetDlgItem(hwndDlg, IDC_CHK_ROUNDCORNERSAV)) ? true : false;
+ options.round = IsDlgButtonChecked(hwndDlg, IDC_CHK_ROUNDCORNERS) && IsWindowEnabled(GetDlgItem(hwndDlg, IDC_CHK_ROUNDCORNERS)) ? true : false;
+ options.av_round = IsDlgButtonChecked(hwndDlg, IDC_CHK_ROUNDCORNERSAV) && IsWindowEnabled(GetDlgItem(hwndDlg, IDC_CHK_ROUNDCORNERSAV)) ? true : false;
options.animate = SendDlgItemMessage(hwndDlg, IDC_CMB_ANIMATE, CB_GETCURSEL, 0, 0);
options.trans_bg = IsDlgButtonChecked(hwndDlg, IDC_CHK_TRANSBG) ? true : false;
options.global_hover = IsDlgButtonChecked(hwndDlg, IDC_CHK_GLOBALHOVER) ? true : false;
@@ -351,9 +352,9 @@ LIST<POPUPCLASS> arNewClasses(3);
static INT_PTR CALLBACK DlgProcOptsClasses(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
- switch ( msg ) {
+ switch (msg) {
case WM_INITDIALOG:
- TranslateDialogDefault( hwndDlg );
+ TranslateDialogDefault(hwndDlg);
arNewClasses = arClasses;
{
@@ -371,7 +372,7 @@ static INT_PTR CALLBACK DlgProcOptsClasses(HWND hwndDlg, UINT msg, WPARAM wParam
return FALSE;
case WM_COMMAND:
- if ( LOWORD(wParam) == IDC_LST_CLASSES && HIWORD(wParam) == LBN_SELCHANGE) {
+ if (LOWORD(wParam) == IDC_LST_CLASSES && HIWORD(wParam) == LBN_SELCHANGE) {
int index = SendDlgItemMessage(hwndDlg, IDC_LST_CLASSES, LB_GETCURSEL, 0, 0);
EnableWindow(GetDlgItem(hwndDlg, IDC_BTN_PREVIEW), index != -1);
EnableWindow(GetDlgItem(hwndDlg, IDC_COL_TEXT), index != -1);
@@ -387,7 +388,7 @@ static INT_PTR CALLBACK DlgProcOptsClasses(HWND hwndDlg, UINT msg, WPARAM wParam
EnableWindow(GetDlgItem(hwndDlg, IDC_ED_TIMEOUT), index != -1 && IsDlgButtonChecked(hwndDlg, IDC_CHK_TIMEOUT));
return TRUE;
}
- if ( HIWORD(wParam) == EN_CHANGE && (HWND)lParam == GetFocus()) {
+ if (HIWORD(wParam) == EN_CHANGE && (HWND)lParam == GetFocus()) {
int index = SendDlgItemMessage(hwndDlg, IDC_LST_CLASSES, LB_GETCURSEL, 0, 0);
if (index != -1) {
int i = SendDlgItemMessage(hwndDlg, IDC_LST_CLASSES, LB_GETITEMDATA, index, 0);
@@ -402,8 +403,8 @@ static INT_PTR CALLBACK DlgProcOptsClasses(HWND hwndDlg, UINT msg, WPARAM wParam
int index = SendDlgItemMessage(hwndDlg, IDC_LST_CLASSES, LB_GETCURSEL, 0, 0);
if (index != -1) {
int i = SendDlgItemMessage(hwndDlg, IDC_LST_CLASSES, LB_GETITEMDATA, index, 0);
- switch(LOWORD(wParam)) {
- case IDC_CHK_TIMEOUT:
+ switch (LOWORD(wParam)) {
+ case IDC_CHK_TIMEOUT:
{
BOOL isChecked = IsDlgButtonChecked(hwndDlg, IDC_CHK_TIMEOUT);
EnableWindow(GetDlgItem(hwndDlg, IDC_ED_TIMEOUT), isChecked);
@@ -411,35 +412,35 @@ static INT_PTR CALLBACK DlgProcOptsClasses(HWND hwndDlg, UINT msg, WPARAM wParam
else arNewClasses[i]->iSeconds = -1;
SetDlgItemInt(hwndDlg, IDC_ED_TIMEOUT, arNewClasses[i]->iSeconds, TRUE);
}
- SendMessage( GetParent( hwndDlg ), PSM_CHANGED, 0, 0);
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
break;
case IDC_COL_TEXT:
arNewClasses[i]->colorText = SendDlgItemMessage(hwndDlg, IDC_COL_TEXT, CPM_GETCOLOUR, 0, 0);
- SendMessage( GetParent( hwndDlg ), PSM_CHANGED, 0, 0);
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
break;
case IDC_COL_BG:
arNewClasses[i]->colorBack = SendDlgItemMessage(hwndDlg, IDC_COL_BG, CPM_GETCOLOUR, 0, 0);
- SendMessage( GetParent( hwndDlg ), PSM_CHANGED, 0, 0);
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
break;
case IDC_BTN_PREVIEW:
if (arNewClasses[i]->flags & PCF_UNICODE) {
POPUPCLASS pc = *arNewClasses[i];
pc.PluginWindowProc = nullptr;
- POPUPDATACLASS d = {sizeof(d), pc.pszName};
+ POPUPDATACLASS d = { sizeof(d), pc.pszName };
d.szTitle.w = L"Preview";
d.szText.w = L"The quick brown fox jumps over the lazy dog.";
- CallService(MS_POPUP_ADDPOPUPCLASS, (WPARAM)&pc, (LPARAM)&d);
+ CallService(MS_POPUP_ADDPOPUPCLASS, (WPARAM)& pc, (LPARAM)& d);
}
else {
POPUPCLASS pc = *arNewClasses[i];
pc.PluginWindowProc = nullptr;
- POPUPDATACLASS d = {sizeof(d), pc.pszName};
+ POPUPDATACLASS d = { sizeof(d), pc.pszName };
d.szTitle.a = "Preview";
d.szText.a = "The quick brown fox jumps over the lazy dog.";
- CallService(MS_POPUP_ADDPOPUPCLASS, (WPARAM)&pc, (LPARAM)&d);
+ CallService(MS_POPUP_ADDPOPUPCLASS, (WPARAM)& pc, (LPARAM)& d);
}
break;
}
diff --git a/src/core/stdpopup/src/options.h b/src/core/stdpopup/src/options.h
index 9269b65779..53fb82dbd7 100644
--- a/src/core/stdpopup/src/options.h
+++ b/src/core/stdpopup/src/options.h
@@ -1,10 +1,12 @@
#ifndef _OPTIONS_INC
#define _OPTIONS_INC
-typedef enum {PL_BOTTOMRIGHT=0, PL_BOTTOMLEFT=1, PL_TOPRIGHT=2, PL_TOPLEFT=3} PopupLocation;
-typedef enum {PAV_NONE=0, PAV_LEFT=1, PAV_RIGHT=2} PopupAvLayout;
-typedef enum {PT_NONE=0, PT_LEFT=1, PT_RIGHT=2, PT_WITHAV=3} PopupTimeLayout;
-typedef struct {
+typedef enum { PL_BOTTOMRIGHT = 0, PL_BOTTOMLEFT = 1, PL_TOPRIGHT = 2, PL_TOPLEFT = 3 } PopupLocation;
+typedef enum { PAV_NONE = 0, PAV_LEFT = 1, PAV_RIGHT = 2 } PopupAvLayout;
+typedef enum { PT_NONE = 0, PT_LEFT = 1, PT_RIGHT = 2, PT_WITHAV = 3 } PopupTimeLayout;
+
+struct Options
+{
int win_width, win_max_height, av_size; //tweety
int default_timeout;
PopupLocation location;
@@ -24,7 +26,7 @@ typedef struct {
bool drop_shadow;
int sb_width;
int padding, av_padding;
-} Options;
+};
extern Options options;
diff --git a/src/core/stdpopup/src/popwin.cpp b/src/core/stdpopup/src/popwin.cpp
index ec16f78e7e..aeaaa150f8 100644
--- a/src/core/stdpopup/src/popwin.cpp
+++ b/src/core/stdpopup/src/popwin.cpp
@@ -6,7 +6,8 @@
DWORD pop_start_x, pop_start_y;
int global_mouse_in = 0;
-void trimW(wchar_t *str) {
+void trimW(wchar_t *str)
+{
int len = (int)mir_wstrlen(str), pos;
// trim whitespace (e.g. from OTR detection)
for (pos = len - 1; pos >= 0; pos--) {
@@ -19,7 +20,8 @@ void trimW(wchar_t *str) {
if (str[pos] == L'\t') str[pos] = L' ';
}
-struct HWNDStackNode {
+struct HWNDStackNode
+{
HWND hwnd;
struct HWNDStackNode *next;
};
@@ -27,13 +29,13 @@ struct HWNDStackNode {
HWNDStackNode *hwnd_stack_top = nullptr;
int stack_size = 0;
-void RepositionWindows() {
- HWNDStackNode *current;
+void RepositionWindows()
+{
+ HWNDStackNode *current;
int x = pop_start_x, y;
int height;
- if (options.animate == ANIMATE_HORZ)
- {
+ if (options.animate == ANIMATE_HORZ) {
if (options.location == PL_BOTTOMRIGHT || options.location == PL_TOPRIGHT)
x -= options.win_width + 1;
if (options.location == PL_BOTTOMLEFT || options.location == PL_TOPLEFT)
@@ -47,9 +49,8 @@ void RepositionWindows() {
y = pop_start_y;
current = hwnd_stack_top;
- while (current)
- {
- SendMessage(current->hwnd, PUM_GETHEIGHT, (WPARAM)&height, 0);
+ while (current) {
+ SendMessage(current->hwnd, PUM_GETHEIGHT, (WPARAM)& height, 0);
// Если окна размещать у нижнего края, то координата текущего окна меньше на его высоту.
if (options.location == PL_BOTTOMLEFT || options.location == PL_BOTTOMRIGHT)
@@ -67,7 +68,8 @@ void RepositionWindows() {
}
}
-void AddWindowToStack(HWND hwnd) {
+void AddWindowToStack(HWND hwnd)
+{
HWNDStackNode *new_node = (HWNDStackNode *)mir_alloc(sizeof(HWNDStackNode));
new_node->hwnd = hwnd;
@@ -137,7 +139,7 @@ void AddWindowToStack(HWND hwnd) {
void RemoveWindowFromStack(HWND hwnd)
{
HWNDStackNode *current = hwnd_stack_top, *prev = nullptr;
- while(current) {
+ while (current) {
if (current->hwnd == hwnd) {
if (prev)
prev->next = current->next;
@@ -148,8 +150,8 @@ void RemoveWindowFromStack(HWND hwnd)
stack_size--;
break;
}
-
- prev = current;
+
+ prev = current;
current = current->next;
}
@@ -162,7 +164,7 @@ void RemoveWindowFromStack(HWND hwnd)
void BroadcastMessage(UINT msg, WPARAM wParam, LPARAM lParam)
{
HWNDStackNode *current = hwnd_stack_top;
- while(current) {
+ while (current) {
SendMessage(current->hwnd, msg, wParam, lParam);
current = current->next;
}
@@ -172,7 +174,7 @@ void DeinitWindowStack()
{
HWNDStackNode *current = hwnd_stack_top;
hwnd_stack_top = nullptr;
- while(current) {
+ while (current) {
HWNDStackNode *pNext = current->next;
DestroyWindow(current->hwnd);
current = pNext;
@@ -200,7 +202,7 @@ LRESULT CALLBACK PopupWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lPa
PopupData *pd = nullptr;
if (pwd) pd = pwd->pd;
- switch(uMsg) {
+ switch (uMsg) {
case WM_CREATE:
{
CREATESTRUCT *cs = (CREATESTRUCT *)lParam;
@@ -209,8 +211,8 @@ LRESULT CALLBACK PopupWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lPa
pwd->pd = pd;
pwd->hNotify = nullptr;
- trimW(pwd->pd->pwzTitle);
- trimW(pwd->pd->pwzText);
+ trimW(pwd->pd->pwszTitle);
+ trimW(pwd->pd->pwszText);
pwd->is_round = options.round;
pwd->av_is_round = options.av_round;
@@ -232,7 +234,7 @@ LRESULT CALLBACK PopupWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lPa
pwd->underlineBrush = CreateSolidBrush(colTitleUnderline);
}
- if (options.border) pwd->bPen = (HPEN)CreatePen(PS_SOLID, 1, colBorder);
+ if (options.border) pwd->bPen = (HPEN)CreatePen(PS_SOLID, 1, colBorder);
else pwd->bPen = CreatePen(PS_SOLID, 1, pwd->custom_col ? pd->colorBack : colBg);
SYSTEMTIME st;
@@ -264,7 +266,7 @@ LRESULT CALLBACK PopupWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lPa
#endif
#ifdef LWA_ALPHA
- SetLayeredWindowAttributes(hwnd, RGB(0,0,0), (int)(options.opacity / 100.0 * 255), LWA_ALPHA);
+ SetLayeredWindowAttributes(hwnd, RGB(0, 0, 0), (int)(options.opacity / 100.0 * 255), LWA_ALPHA);
if (options.trans_bg) {
COLORREF bg;
if (pd->colorBack == pd->colorText)
@@ -307,7 +309,7 @@ LRESULT CALLBACK PopupWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lPa
}
return TRUE;
}
-
+
if (wParam == ID_MOVETIMER) {
RECT r;
GetWindowRect(hwnd, &r);
@@ -315,7 +317,7 @@ LRESULT CALLBACK PopupWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lPa
if (r.left == pwd->new_x && r.top == pwd->new_y) {
KillTimer(hwnd, ID_MOVETIMER);
return TRUE;
- }
+ }
int adj_x = (pwd->new_x - r.left) / 4, adj_y = (pwd->new_y - r.top) / 4;
if (adj_x == 0) adj_x = (pwd->new_x - r.left);
if (adj_y == 0) adj_y = (pwd->new_y - r.top);
@@ -333,9 +335,9 @@ LRESULT CALLBACK PopupWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lPa
case WM_ERASEBKGND:
{
- HDC hdc = (HDC) wParam;
+ HDC hdc = (HDC)wParam;
RECT r, r_bar;
- GetClientRect(hwnd, &r);
+ GetClientRect(hwnd, &r);
// bg
FillRect(hdc, &r, pwd->bkBrush);
@@ -352,10 +354,10 @@ LRESULT CALLBACK PopupWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lPa
int h = 0;
if (options.round) {
int v;
- int w=14;
- h=(r.right-r.left)>(w*2)?w:(r.right-r.left);
- v=(r.bottom-r.top)>(w*2)?w:(r.bottom-r.top);
- h=(h<v)?h:v;
+ int w = 14;
+ h = (r.right - r.left) > (w * 2) ? w : (r.right - r.left);
+ v = (r.bottom - r.top) > (w * 2) ? w : (r.bottom - r.top);
+ h = (h < v) ? h : v;
}
RoundRect(hdc, 0, 0, (r.right - r.left), (r.bottom - r.top), h, h);
@@ -445,7 +447,7 @@ LRESULT CALLBACK PopupWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lPa
if (pwd->custom_col) SetTextColor(ps.hdc, pd->colorText);
else SetTextColor(ps.hdc, colTime);
if (hFontTime) SelectObject(hdc, (HGDIOBJ)hFontTime);
- switch(options.time_layout) {
+ switch (options.time_layout) {
case PT_LEFT:
ttr.left = textxmin; ttr.right = ttr.left + pwd->time_width;
textxmin += pwd->time_width + options.padding;
@@ -468,7 +470,7 @@ LRESULT CALLBACK PopupWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lPa
if (pwd->custom_col) SetTextColor(ps.hdc, pd->colorText);
else SetTextColor(ps.hdc, colFirstLine);
- wchar_t *title = mir_wstrdup(pd->pwzTitle);
+ wchar_t *title = mir_wstrdup(pd->pwszTitle);
DrawText(ps.hdc, title, -1, &tr, DT_VCENTER | DT_LEFT | DT_END_ELLIPSIS | DT_SINGLELINE | DT_NOPREFIX);
mir_free(title);
@@ -476,12 +478,12 @@ LRESULT CALLBACK PopupWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lPa
RECT tur;
tur.left = r.left + options.sb_width + options.padding;
tur.right = r.right - options.padding;
- tur.top = tr.bottom + options.padding/2;
+ tur.top = tr.bottom + options.padding / 2;
tur.bottom = tur.top + 1;
FillRect(ps.hdc, &tur, pwd->underlineBrush);
// second line(s)
- if (pd->pwzText[0]) {
+ if (pd->pwszText[0]) {
if (hFontSecondLine) SelectObject(ps.hdc, (HGDIOBJ)hFontSecondLine);
if (!pwd->custom_col)
SetTextColor(ps.hdc, colSecondLine);
@@ -490,7 +492,7 @@ LRESULT CALLBACK PopupWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lPa
if (options.av_layout != PAV_NONE && options.time_layout == PT_WITHAV && pwd->time_height <= pwd->tb_height && !pwd->have_av)
GetClientRect(hwnd, &r);
- wchar_t *text = mir_wstrdup(pd->pwzText);
+ wchar_t *text = mir_wstrdup(pd->pwszText);
tr.left = r.left + options.padding + options.text_indent; tr.right = r.right - options.padding; tr.top = tr.bottom + options.padding; tr.bottom = r.bottom - options.padding;
DrawText(ps.hdc, text, -1, &tr, DT_NOPREFIX | DT_WORDBREAK | DT_EXTERNALLEADING | DT_TOP | DT_LEFT | DT_WORD_ELLIPSIS);
mir_free(text);
@@ -500,10 +502,10 @@ LRESULT CALLBACK PopupWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lPa
}
return 0;
- case WM_DESTROY:
+ case WM_DESTROY:
if (pwd->mouse_in) global_mouse_in--;
- ShowWindow(hwnd, SW_HIDE);
+ ShowWindow(hwnd, SW_HIDE);
DeleteObject(pwd->bkBrush);
DeleteObject(pwd->bPen);
@@ -518,8 +520,8 @@ LRESULT CALLBACK PopupWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lPa
if (pd) {
pd->SetIcon(nullptr);
- mir_free(pd->pwzTitle);
- mir_free(pd->pwzText);
+ mir_free(pd->pwszTitle);
+ mir_free(pd->pwszText);
mir_free(pd);
}
mir_free(pwd); pwd = nullptr; pd = nullptr;
@@ -533,12 +535,12 @@ LRESULT CALLBACK PopupWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lPa
RECT r;
int w = 11;
- GetWindowRect(hwnd,&r);
- int h = (r.right-r.left) > (w*2)?w:(r.right-r.left);
- int v = (r.bottom-r.top) > (w*2)?w:(r.bottom-r.top);
- h=(h<v)?h:v;
- hRgn1=CreateRoundRectRgn(0,0,(r.right-r.left) + 1,(r.bottom-r.top) + 1,h,h);
- SetWindowRgn(hwnd,hRgn1,FALSE);
+ GetWindowRect(hwnd, &r);
+ int h = (r.right - r.left) > (w * 2) ? w : (r.right - r.left);
+ int v = (r.bottom - r.top) > (w * 2) ? w : (r.bottom - r.top);
+ h = (h < v) ? h : v;
+ hRgn1 = CreateRoundRectRgn(0, 0, (r.right - r.left) + 1, (r.bottom - r.top) + 1, h, h);
+ SetWindowRgn(hwnd, hRgn1, FALSE);
}
return TRUE;
@@ -551,7 +553,7 @@ LRESULT CALLBACK PopupWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lPa
}
else {
SetWindowPos(hwnd, nullptr, (int)wParam, (int)lParam, 0, 0, SWP_NOZORDER | SWP_NOSIZE | SWP_NOACTIVATE);
- if (!IsWindowVisible(hwnd)) {
+ if (!IsWindowVisible(hwnd)) {
ShowWindow(hwnd, SW_SHOWNOACTIVATE);
UpdateWindow(hwnd);
}
@@ -559,14 +561,14 @@ LRESULT CALLBACK PopupWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lPa
return TRUE;
case PUM_SETTEXT:
- replaceStrW(pd->ptzText, (wchar_t*)lParam);
+ replaceStrW(pd->pwszText, (wchar_t *)lParam);
InvalidateRect(hwnd, nullptr, TRUE);
RepositionWindows();
return TRUE;
case PUM_GETCONTACT:
{
- MCONTACT *phContact = (MCONTACT*)wParam;
+ MCONTACT *phContact = (MCONTACT *)wParam;
*phContact = pd->hContact;
if (lParam)
SetEvent((HANDLE)lParam);
@@ -575,7 +577,7 @@ LRESULT CALLBACK PopupWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lPa
case PUM_GETHEIGHT:
{
- int *pHeight = (int*)wParam;
+ int *pHeight = (int *)wParam;
HDC hdc = GetDC(hwnd);
SIZE size;
HFONT hOldFont = (HFONT)GetCurrentObject(hdc, OBJ_FONT);
@@ -591,7 +593,7 @@ LRESULT CALLBACK PopupWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lPa
// titlebar height
if (hFontFirstLine) SelectObject(hdc, (HGDIOBJ)hFontFirstLine);
- wchar_t *title = mir_wstrdup(pd->pwzTitle);
+ wchar_t *title = mir_wstrdup(pd->pwszTitle);
GetTextExtentPoint32(hdc, title, (int)mir_wstrlen(title), &size);
mir_free(title);
pwd->tb_height = size.cy;
@@ -607,29 +609,30 @@ LRESULT CALLBACK PopupWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lPa
if (ace->bmHeight >= ace->bmWidth) {
pwd->real_av_height = options.av_size;
pwd->real_av_width = options.av_size * ace->bmWidth / ace->bmHeight;
- } else {
+ }
+ else {
pwd->real_av_height = options.av_size * ace->bmHeight / ace->bmWidth;
pwd->real_av_width = options.av_size;
}
pwd->have_av = true;
- pwd->av_height = pwd->real_av_height;
+ pwd->av_height = pwd->real_av_height;
}
}
// text height
- if (pd->pwzText[0]) {
+ if (pd->pwszText[0]) {
RECT r;
- r.left = r.top = 0;
+ r.left = r.top = 0;
r.right = options.win_width - 2 * options.padding - options.text_indent;
if (pwd->have_av && options.time_layout == PT_WITHAV)
- r.right -= (max(options.av_size, pwd->time_width) + options.padding);
+ r.right -= (max(options.av_size, pwd->time_width) + options.padding);
else if (pwd->have_av)
- r.right -= (options.av_size + options.padding);
+ r.right -= (options.av_size + options.padding);
else if (options.av_layout != PAV_NONE && options.time_layout == PT_WITHAV && pwd->time_height >= pwd->tb_height)
r.right -= pwd->time_width + options.padding;
if (hFontSecondLine) SelectObject(hdc, (HGDIOBJ)hFontSecondLine);
- wchar_t *text = mir_wstrdup(pd->pwzText);
+ wchar_t *text = mir_wstrdup(pd->pwszText);
DrawText(hdc, text, -1, &r, DT_CALCRECT | DT_NOPREFIX | DT_WORDBREAK | DT_EXTERNALLEADING | DT_TOP | DT_LEFT | DT_WORD_ELLIPSIS);
pwd->text_height = r.bottom;
mir_free(text);
@@ -638,9 +641,9 @@ LRESULT CALLBACK PopupWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lPa
SelectObject(hdc, hOldFont);
ReleaseDC(hwnd, hdc);
- if (options.time_layout == PT_WITHAV && options.av_layout != PAV_NONE)
+ if (options.time_layout == PT_WITHAV && options.av_layout != PAV_NONE)
*pHeight = max(pwd->tb_height + pwd->text_height + 3 * options.padding, pwd->av_height + pwd->time_height + options.padding + 2 * options.av_padding);
- else
+ else
*pHeight = max(pwd->tb_height + pwd->text_height + 3 * options.padding, pwd->av_height + 2 * options.av_padding);
if (*pHeight > options.win_max_height) *pHeight = options.win_max_height;
@@ -667,8 +670,8 @@ LRESULT CALLBACK PopupWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lPa
{
KillTimer(hwnd, ID_CLOSETIMER);
if (pd) {
- mir_free(pd->pwzTitle);
- mir_free(pd->pwzText);
+ mir_free(pd->pwszTitle);
+ mir_free(pd->pwszText);
mir_free(pd);
}
pwd->pd = pd = (PopupData *)lParam;
@@ -699,12 +702,12 @@ LRESULT CALLBACK PopupWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lPa
pd->hIcon = (HICON)MNotifyGetDWord(pwd->hNotify, NFOPT_ICON, 0);
const wchar_t *swzName = MNotifyGetWString(pwd->hNotify, NFOPT_TITLEW, nullptr);
- mir_free(pd->pwzTitle);
- pd->pwzTitle = mir_wstrdup(swzName);
+ mir_free(pd->pwszTitle);
+ pd->pwszTitle = mir_wstrdup(swzName);
const wchar_t *swzText = MNotifyGetWString(pwd->hNotify, NFOPT_TEXTW, nullptr);
- mir_free(pd->pwzText);
- pd->pwzText = mir_wstrdup(swzText);
+ mir_free(pd->pwszText);
+ pd->pwszText = mir_wstrdup(swzText);
InvalidateRect(hwnd, nullptr, TRUE);
RepositionWindows();
@@ -723,13 +726,13 @@ LRESULT CALLBACK PopupWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lPa
if (pd && pd->windowProc)
return CallWindowProc(pd->windowProc, hwnd, uMsg, wParam, lParam);
-
+
// provide a way to close popups, if no PluginWindowProc is provided
if (uMsg == WM_CONTEXTMENU) {
SendMessage(hwnd, UM_DESTROYPOPUP, 0, 0);
return TRUE;
}
-
+
return DefWindowProc(hwnd, uMsg, wParam, lParam);
}
diff --git a/src/core/stdpopup/src/popwin.h b/src/core/stdpopup/src/popwin.h
index 007ea57695..fe60d64737 100644
--- a/src/core/stdpopup/src/popwin.h
+++ b/src/core/stdpopup/src/popwin.h
@@ -15,9 +15,9 @@
#define PUM_KILLNOTIFY (WM_USER + 0x031)
#define PUM_UPDATENOTIFY (WM_USER + 0x032)
-#define ANIMATE_NO 0
-#define ANIMATE_HORZ 1
-#define ANIMATE_VERT 2
+#define ANIMATE_NO 0
+#define ANIMATE_HORZ 1
+#define ANIMATE_VERT 2
void DeinitWindowStack();
diff --git a/src/core/stdpopup/src/services.cpp b/src/core/stdpopup/src/services.cpp
index 9274a36455..8e90c9da1b 100644
--- a/src/core/stdpopup/src/services.cpp
+++ b/src/core/stdpopup/src/services.cpp
@@ -12,8 +12,8 @@ void StripBBCodesInPlace(wchar_t *text)
int read = 0, write = 0;
int len = (int)mir_wstrlen(text);
- while(read <= len) { // copy terminating null too
- while(read <= len && text[read] != L'[') {
+ while (read <= len) { // copy terminating null too
+ while (read <= len && text[read] != L'[') {
if (text[read] != text[write]) text[write] = text[read];
read++; write++;
}
@@ -24,14 +24,16 @@ void StripBBCodesInPlace(wchar_t *text)
else if (len - read >= 4 && (_wcsnicmp(text + read, L"[/b]", 4) == 0 || _wcsnicmp(text + read, L"[/i]", 4) == 0))
read += 4;
else if (len - read >= 6 && (_wcsnicmp(text + read, L"[color", 6) == 0)) {
- while(read < len && text[read] != L']') read++;
+ while (read < len && text[read] != L']') read++;
read++;// skip the ']'
- } else if (len - read >= 8 && (_wcsnicmp(text + read, L"[/color]", 8) == 0))
+ }
+ else if (len - read >= 8 && (_wcsnicmp(text + read, L"[/color]", 8) == 0))
read += 8;
else if (len - read >= 5 && (_wcsnicmp(text + read, L"[size", 5) == 0)) {
- while(read < len && text[read] != L']') read++;
+ while (read < len && text[read] != L']') read++;
read++;// skip the ']'
- } else if (len - read >= 7 && (_wcsnicmp(text + read, L"[/size]", 7) == 0))
+ }
+ else if (len - read >= 7 && (_wcsnicmp(text + read, L"[/size]", 7) == 0))
read += 7;
else {
if (text[read] != text[write]) text[write] = text[read];
@@ -46,16 +48,16 @@ static INT_PTR CreatePopup(WPARAM wParam, LPARAM)
return -1;
POPUPDATA *pd_in = (POPUPDATA *)wParam;
- if ( NotifyEventHooks(hEventNotify, (WPARAM)pd_in->lchContact, (LPARAM)pd_in->PluginWindowProc))
+ if (NotifyEventHooks(hEventNotify, (WPARAM)pd_in->lchContact, (LPARAM)pd_in->PluginWindowProc))
return 0;
PopupData *pd_out = (PopupData *)mir_calloc(sizeof(PopupData));
pd_out->cbSize = sizeof(PopupData);
pd_out->flags = PDF_UNICODE;
- pd_out->pwzTitle = mir_a2u(pd_in->lpzContactName);
- pd_out->pwzText = mir_a2u(pd_in->lpzText);
- StripBBCodesInPlace(pd_out->pwzTitle);
- StripBBCodesInPlace(pd_out->pwzText);
+ pd_out->pwszTitle = mir_a2u(pd_in->lpzContactName);
+ pd_out->pwszText = mir_a2u(pd_in->lpzText);
+ StripBBCodesInPlace(pd_out->pwszTitle);
+ StripBBCodesInPlace(pd_out->pwszText);
pd_out->hContact = pd_in->lchContact;
pd_out->SetIcon(pd_in->lchIcon);
@@ -69,10 +71,10 @@ static INT_PTR CreatePopup(WPARAM wParam, LPARAM)
pd_out->opaque = pd_in->PluginData;
pd_out->timeout = pd_in->iSeconds;
- lstPopupHistory.Add(pd_out->pwzTitle, pd_out->pwzText, time(0));
+ lstPopupHistory.Add(pd_out->pwszTitle, pd_out->pwszText, time(0));
if (!Popup_Enabled()) {
- mir_free(pd_out->pwzTitle);
- mir_free(pd_out->pwzText);
+ mir_free(pd_out->pwszTitle);
+ mir_free(pd_out->pwszText);
mir_free(pd_out);
return -1;
}
@@ -87,16 +89,16 @@ static INT_PTR CreatePopupW(WPARAM wParam, LPARAM)
return -1;
POPUPDATAW *pd_in = (POPUPDATAW *)wParam;
- if ( NotifyEventHooks(hEventNotify, (WPARAM)pd_in->lchContact, (LPARAM)pd_in->PluginWindowProc))
+ if (NotifyEventHooks(hEventNotify, (WPARAM)pd_in->lchContact, (LPARAM)pd_in->PluginWindowProc))
return 0;
PopupData *pd_out = (PopupData *)mir_calloc(sizeof(PopupData));
pd_out->cbSize = sizeof(PopupData);
pd_out->flags = PDF_UNICODE;
- pd_out->pwzTitle = mir_wstrdup(pd_in->lpwzContactName);
- pd_out->pwzText = mir_wstrdup(pd_in->lpwzText);
- StripBBCodesInPlace(pd_out->pwzTitle);
- StripBBCodesInPlace(pd_out->pwzText);
+ pd_out->pwszTitle = mir_wstrdup(pd_in->lpwzContactName);
+ pd_out->pwszText = mir_wstrdup(pd_in->lpwzText);
+ StripBBCodesInPlace(pd_out->pwszTitle);
+ StripBBCodesInPlace(pd_out->pwszText);
pd_out->hContact = pd_in->lchContact;
pd_out->SetIcon(pd_in->lchIcon);
@@ -110,10 +112,10 @@ static INT_PTR CreatePopupW(WPARAM wParam, LPARAM)
pd_out->opaque = pd_in->PluginData;
pd_out->timeout = pd_in->iSeconds;
- lstPopupHistory.Add(pd_out->pwzTitle, pd_out->pwzText, time(0));
+ lstPopupHistory.Add(pd_out->pwszTitle, pd_out->pwszText, time(0));
if (!Popup_Enabled()) {
- mir_free(pd_out->pwzTitle);
- mir_free(pd_out->pwzText);
+ mir_free(pd_out->pwszTitle);
+ mir_free(pd_out->pwszText);
mir_free(pd_out);
return -1;
}
@@ -133,27 +135,20 @@ static INT_PTR ChangeTextW(WPARAM wParam, LPARAM lParam)
return 0;
}
-void ShowPopup(PopupData &pd_in)
+void ShowPopup(PopupData &pd_in)
{
PopupData *pd_out = (PopupData *)mir_alloc(sizeof(PopupData));
*pd_out = pd_in;
- if (pd_in.flags & PDF_UNICODE) {
- pd_out->pwzTitle = mir_wstrdup(pd_in.pwzTitle);
- pd_out->pwzText = mir_wstrdup(pd_in.pwzText);
- }
- else {
- pd_out->flags |= PDF_UNICODE;
- pd_out->pwzTitle = mir_a2u(pd_in.pszTitle);
- pd_out->pwzText = mir_a2u(pd_in.pszText);
- }
- StripBBCodesInPlace(pd_out->pwzTitle);
- StripBBCodesInPlace(pd_out->pwzText);
+ pd_out->pwszTitle = mir_wstrdup(pd_in.pwszTitle);
+ pd_out->pwszText = mir_wstrdup(pd_in.pwszText);
+ StripBBCodesInPlace(pd_out->pwszTitle);
+ StripBBCodesInPlace(pd_out->pwszText);
- lstPopupHistory.Add(pd_out->pwzTitle, pd_out->pwzText, time(0));
+ lstPopupHistory.Add(pd_out->pwszTitle, pd_out->pwszText, time(0));
if (!Popup_Enabled()) {
- mir_free(pd_out->pwzTitle);
- mir_free(pd_out->pwzText);
+ mir_free(pd_out->pwszTitle);
+ mir_free(pd_out->pwszText);
mir_free(pd_out);
}
else PostMPMessage(MUM_CREATEPOPUP, 0, (LPARAM)pd_out);
@@ -228,10 +223,10 @@ static INT_PTR PopupChangeW(WPARAM wParam, LPARAM lParam)
pd_out.cbSize = sizeof(PopupData);
pd_out.flags = PDF_UNICODE;
- pd_out.pwzTitle = mir_wstrdup(pd_in->lpwzContactName);
- pd_out.pwzText = mir_wstrdup(pd_in->lpwzText);
- StripBBCodesInPlace(pd_out.pwzTitle);
- StripBBCodesInPlace(pd_out.pwzText);
+ pd_out.pwszTitle = mir_wstrdup(pd_in->lpwzContactName);
+ pd_out.pwszText = mir_wstrdup(pd_in->lpwzText);
+ StripBBCodesInPlace(pd_out.pwszTitle);
+ StripBBCodesInPlace(pd_out.pwszText);
pd_out.hContact = pd_in->lchContact;
pd_out.SetIcon(pd_in->lchIcon);
@@ -245,9 +240,9 @@ static INT_PTR PopupChangeW(WPARAM wParam, LPARAM lParam)
pd_out.opaque = pd_in->PluginData;
pd_out.timeout = pd_in->iSeconds;
- lstPopupHistory.Add(pd_out.pwzTitle, pd_out.pwzText, time(0));
SendMessage(hwndPop, PUM_CHANGE, 0, (LPARAM)&pd_out);
+ lstPopupHistory.Add(pd_out.pwszTitle, pd_out.pwszText, time(0));
}
return 0;
}
@@ -297,7 +292,7 @@ LIST<POPUPCLASS> arClasses(3, PtrKeySortT);
static INT_PTR RegisterPopupClass(WPARAM, LPARAM lParam)
{
- POPUPCLASS *pc = (POPUPCLASS*)mir_alloc( sizeof(POPUPCLASS));
+ POPUPCLASS *pc = (POPUPCLASS *)mir_alloc(sizeof(POPUPCLASS));
memcpy(pc, (PVOID)lParam, sizeof(POPUPCLASS));
pc->pszName = mir_strdup(pc->pszName);
@@ -305,7 +300,7 @@ static INT_PTR RegisterPopupClass(WPARAM, LPARAM lParam)
pc->pszDescription.w = mir_wstrdup(pc->pszDescription.w);
else
pc->pszDescription.a = mir_strdup(pc->pszDescription.a);
-
+
char setting[256];
mir_snprintf(setting, "%s/Timeout", pc->pszName);
pc->iSeconds = g_plugin.getWord(setting, pc->iSeconds);
@@ -328,7 +323,7 @@ static void FreePopupClass(POPUPCLASS *pc)
static INT_PTR UnregisterPopupClass(WPARAM, LPARAM lParam)
{
- POPUPCLASS *pc = (POPUPCLASS*)lParam;
+ POPUPCLASS *pc = (POPUPCLASS *)lParam;
if (pc == nullptr)
return 1;
if (arClasses.find(pc) == nullptr)
@@ -360,17 +355,24 @@ static INT_PTR CreateClassPopup(WPARAM wParam, LPARAM lParam)
return 0;
PopupData ppd = { sizeof(PopupData) };
- if (pc->flags & PCF_UNICODE) ppd.flags |= PDF_UNICODE;
+ ppd.flags |= PDF_UNICODE;
ppd.colorBack = pc->colorBack;
ppd.colorText = pc->colorText;
ppd.SetIcon(pc->hIcon);
ppd.timeout = pc->iSeconds;
ppd.windowProc = pc->PluginWindowProc;
-
ppd.hContact = pdc->hContact;
ppd.opaque = pdc->PluginData;
- ppd.pszTitle = (char *)pdc->szTitle.a;
- ppd.pszText = (char *)pdc->szText.a;
+
+ ptrW tmpText, tmpTitle;
+ if (pc->flags & PCF_UNICODE) {
+ ppd.pwszTitle = (wchar_t *)pdc->szTitle.w;
+ ppd.pwszText = (wchar_t *)pdc->szText.w;
+ }
+ else {
+ tmpText = mir_a2u(pdc->szText.a); ppd.pwszText = tmpText;
+ tmpTitle = mir_a2u(pdc->szTitle.a); ppd.pwszTitle = tmpTitle;
+ }
ShowPopup(ppd);
}
@@ -384,7 +386,7 @@ INT_PTR Popup_DeletePopup(WPARAM, LPARAM lParam)
//////////////////////////////////////////////////////////////////////////////
-void InitServices()
+void InitServices()
{
hEventNotify = CreateHookableEvent(ME_POPUP_FILTER);
diff --git a/src/core/stdpopup/src/stdafx.h b/src/core/stdpopup/src/stdafx.h
index 6cb4378305..bd39b6d852 100644
--- a/src/core/stdpopup/src/stdafx.h
+++ b/src/core/stdpopup/src/stdafx.h
@@ -74,6 +74,4 @@ typedef int (CALLBACK *PFNLVCOMPARE)(LPARAM, LPARAM, LPARAM);
#define PDF_UNICODE 0x0001
#define PDF_ICOLIB 0x0002
-#define PDF_TCHAR PDF_UNICODE
-
void ShowPopup(PopupData &pd_in);
diff --git a/src/core/stdpopup/src/yapp.cpp b/src/core/stdpopup/src/yapp.cpp
index 4408cf5aef..ad0074fd94 100644
--- a/src/core/stdpopup/src/yapp.cpp
+++ b/src/core/stdpopup/src/yapp.cpp
@@ -16,8 +16,8 @@ ColourIDW colour_id_bg = {}, colour_id_border = {}, colour_id_sidebar = {}, colo
COLORREF colBg = GetSysColor(COLOR_3DSHADOW);
HFONT hFontFirstLine = nullptr, hFontSecondLine = nullptr, hFontTime = nullptr;
-COLORREF colFirstLine = RGB(255, 0, 0), colSecondLine = 0, colTime = RGB(0, 0, 255), colBorder = RGB(0, 0, 0),
- colSidebar = RGB(128, 128, 128), colTitleUnderline = GetSysColor(COLOR_3DSHADOW);
+COLORREF colFirstLine = RGB(255, 0, 0), colSecondLine = 0, colTime = RGB(0, 0, 255), colBorder = RGB(0, 0, 0),
+colSidebar = RGB(128, 128, 128), colTitleUnderline = GetSysColor(COLOR_3DSHADOW);
// toptoolbar button
HANDLE hTTButton;
@@ -43,7 +43,8 @@ PLUGININFOEX pluginInfoEx =
CMPlugin::CMPlugin() :
PLUGIN<CMPlugin>(MODULENAME, pluginInfoEx)
-{}
+{
+}
/////////////////////////////////////////////////////////////////////////////////////////
@@ -168,7 +169,7 @@ static void InitMenuItems(void)
SET_UID(mi, 0x92c386ae, 0x6e81, 0x452d, 0xb5, 0x71, 0x87, 0x46, 0xe9, 0x2, 0x66, 0xe9);
mi.hIcolibItem = IcoLib_GetIcon(ICO_HISTORY, 0);
- mi.pszService= MS_POPUP_SHOWHISTORY;
+ mi.pszService = MS_POPUP_SHOWHISTORY;
mi.name.w = LPGENW("Popup history");
hMenuItemHistory = Menu_AddMainMenuItem(&mi);
@@ -189,7 +190,7 @@ static int ModulesLoaded(WPARAM, LPARAM)
HookEvent(ME_FONT_RELOAD, ReloadFont);
HookEvent(ME_TTB_MODULELOADED, TTBLoaded);
- LoadModuleDependentOptions();
+ LoadModuleDependentOptions();
if (GetModuleHandle(L"neweventnotify"))
ignore_gpd_passed_addy = true;
diff --git a/src/core/stdpopup/src/yapp_history.cpp b/src/core/stdpopup/src/yapp_history.cpp
index fb881cf1c1..26b78a0fc1 100644
--- a/src/core/stdpopup/src/yapp_history.cpp
+++ b/src/core/stdpopup/src/yapp_history.cpp
@@ -4,7 +4,7 @@ PopupHistoryList::PopupHistoryList(int renderer)
{
this->renderer = renderer;
size = HISTORY_SIZE; //fixed size (at least for now)
- historyData = (PopupHistoryData *) malloc(size * sizeof(PopupHistoryData)); //alloc space for data
+ historyData = (PopupHistoryData *)malloc(size * sizeof(PopupHistoryData)); //alloc space for data
count = 0;
}
@@ -17,17 +17,15 @@ PopupHistoryList::~PopupHistoryList()
void PopupHistoryList::Clear()
{
for (int i = 0; i < count; i++)
- {
DeleteData(i);
- }
+
count = 0;
}
void PopupHistoryList::RemoveItem(int index)
{
DeleteData(index); //free the mem for that particular item
- for (int i = index + 1; i < count; i++)
- {
+ for (int i = index + 1; i < count; i++) {
historyData[i - 1] = historyData[i]; //shift all items to the left
}
}
@@ -35,18 +33,15 @@ void PopupHistoryList::RemoveItem(int index)
void PopupHistoryList::DeleteData(int index)
{
PopupHistoryData *item = &historyData[index];
- mir_free(item->titleT);
- mir_free(item->messageT);
- item->timestamp = 0; //invalidate item
- item->title = nullptr;
- item->message = nullptr;
+ replaceStrW(item->titleW, nullptr);
+ replaceStrW(item->messageW, nullptr);
+ item->timestamp = 0; // invalidate item
item->flags = 0;
}
void PopupHistoryList::AddItem(PopupHistoryData item)
{
- if (count >= size)
- {
+ if (count >= size) {
RemoveItem(0); //remove first element - the oldest
count--; //it will be inc'ed later
}
@@ -54,31 +49,20 @@ void PopupHistoryList::AddItem(PopupHistoryData item)
RefreshPopupHistory(hHistoryWindow, GetRenderer());
}
-void PopupHistoryList::Add(char *title, char *message, time_t timestamp)
-{
- PopupHistoryData item = {0}; //create a history item
- item.timestamp = timestamp;
- item.title = mir_strdup(title);
- item.message = mir_strdup(message);
- AddItem(item); //add it (flags = 0)
-}
-
void PopupHistoryList::Add(wchar_t *title, wchar_t *message, time_t timestamp)
{
- PopupHistoryData item = {0}; //create an unicode history item
+ PopupHistoryData item = { 0 }; //create an unicode history item
item.flags = PHDF_UNICODE; //mark it as unicode
item.timestamp = timestamp;
- item.titleT = mir_wstrdup(title);
- item.messageT = mir_wstrdup(message);
+ item.titleW = mir_wstrdup(title);
+ item.messageW = mir_wstrdup(message);
AddItem(item); //add it
}
-PopupHistoryData *PopupHistoryList::Get(int index)
+PopupHistoryData* PopupHistoryList::Get(int index)
{
if ((index < 0) || (index >= count)) //a bit of sanity check
- {
return nullptr;
- }
-
+
return &historyData[index];
}
diff --git a/src/core/stdpopup/src/yapp_history.h b/src/core/stdpopup/src/yapp_history.h
index ff13d28b34..89c7957166 100644
--- a/src/core/stdpopup/src/yapp_history.h
+++ b/src/core/stdpopup/src/yapp_history.h
@@ -34,47 +34,40 @@
#define RENDER_HISTORYPP 0x00001
#define RENDER_IEVIEW 0x00002
-struct PopupHistoryData{
+struct PopupHistoryData
+{
DWORD flags; //PHDF_* flags
- union{
- char *message;
- wchar_t *messageW;
- wchar_t *messageT;
- };
- union{
- char *title;
- wchar_t *titleW;
- wchar_t *titleT;
- };
+ wchar_t *messageW;
+ wchar_t *titleW;
time_t timestamp;
};
-class PopupHistoryList{
- private:
- PopupHistoryData *historyData; //historyData[0] - oldest, historyData[size - 1] - newest
- int count;
- int size;
- int renderer;
-
- void DeleteData(int index);
- void AddItem(PopupHistoryData item); //adds a PopupHistoryData item
- void RemoveItem(int index);
-
- public:
- PopupHistoryList(int renderer = RENDER_DEFAULT);
- ~PopupHistoryList();
-
- int GetRenderer() { return renderer; }
- void SetRenderer(int newRenderer) { renderer = newRenderer; }
-
- void Add(char *title, char *message, time_t timestamp);
- void Add(wchar_t *title, wchar_t *message, time_t timestamp);
-
- PopupHistoryData *Get(int index);
-
- void Clear();
- int Count() { return count; }
- int Size() { return size; }
+class PopupHistoryList
+{
+private:
+ PopupHistoryData *historyData; //historyData[0] - oldest, historyData[size - 1] - newest
+ int count;
+ int size;
+ int renderer;
+
+ void DeleteData(int index);
+ void AddItem(PopupHistoryData item); //adds a PopupHistoryData item
+ void RemoveItem(int index);
+
+public:
+ PopupHistoryList(int renderer = RENDER_DEFAULT);
+ ~PopupHistoryList();
+
+ int GetRenderer() { return renderer; }
+ void SetRenderer(int newRenderer) { renderer = newRenderer; }
+
+ void Add(wchar_t *title, wchar_t *message, time_t timestamp);
+
+ PopupHistoryData *Get(int index);
+
+ void Clear();
+ int Count() { return count; }
+ int Size() { return size; }
};
/*Shows a history with the last popups.
diff --git a/src/core/stdpopup/src/yapp_history_dlg.cpp b/src/core/stdpopup/src/yapp_history_dlg.cpp
index 8e546af363..8bc36875b0 100644
--- a/src/core/stdpopup/src/yapp_history_dlg.cpp
+++ b/src/core/stdpopup/src/yapp_history_dlg.cpp
@@ -123,11 +123,11 @@ int MatchesFilterCS(const wchar_t *filter, const PopupHistoryData *popupItem) //
if (mir_wstrlen(filter) <= 0) { return 1; } //if no filter is set then the popup item matches the filter
int match = 0;
- match = (wcsstr(popupItem->messageT, filter)) ? 1 : match; //check message part
+ match = (wcsstr(popupItem->messageW, filter)) ? 1 : match; //check message part
if (!match) //check title part of no match has been found
{
- match = (wcsstr(popupItem->titleT, filter)) ? 1 : match;
+ match = (wcsstr(popupItem->titleW, filter)) ? 1 : match;
}
if (!match) //if no match has been found yet try to match the timestamp
@@ -157,12 +157,12 @@ int MatchesFilterCI(const wchar_t *filterS, const PopupHistoryData *popupItem)
ConvertCase(filterI, filterS, BUFFER_SIZE);
- ConvertCase(buffer, popupItem->messageT, BUFFER_SIZE); //check message part
+ ConvertCase(buffer, popupItem->messageW, BUFFER_SIZE); //check message part
match = (wcsstr(buffer, filterI)) ? 1 : match;
if (!match) // check title part of no match has been found
{
- ConvertCase(buffer, popupItem->titleT, BUFFER_SIZE);
+ ConvertCase(buffer, popupItem->titleW, BUFFER_SIZE);
match = (wcsstr(buffer, filterI)) ? 1 : match;
}
@@ -335,8 +335,8 @@ IEVIEWEVENTDATA *CreateAndFillEventData(PopupHistoryData *popupItem)
eventData->iType = IEED_EVENT_MESSAGE;
eventData->dwFlags = IEEDF_UNICODE_NICK | IEEDF_UNICODE_TEXT | IEEDF_UNICODE_TEXT2;
- eventData->pszNickW = popupItem->titleT;
- eventData->pszTextW = popupItem->messageT;
+ eventData->pszNickW = popupItem->titleW;
+ eventData->pszTextW = popupItem->messageW;
eventData->time = (DWORD) popupItem->timestamp;
eventData->next = nullptr;
@@ -419,9 +419,9 @@ void AddEventsDefault(HWND hWnd, int, wchar_t *filter, SIG_MATCHESFILTER Matches
popupItem = lstPopupHistory.Get(i);
if (MatchesFilter(filter, popupItem))
{
- item.pszText = popupItem->titleT;
+ item.pszText = popupItem->titleW;
ListView_InsertItem(hHistoryList, &item);
- ListView_SetItemText(hHistoryList, lIndex, 1, popupItem->messageT);
+ ListView_SetItemText(hHistoryList, lIndex, 1, popupItem->messageW);
myTime = localtime(&popupItem->timestamp);
wcsftime(buffer, 1024, L"%c", myTime);
ListView_SetItemText(hHistoryList, lIndex++, 2, buffer);