summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2012-11-25 16:17:46 +0000
committerGeorge Hazan <george.hazan@gmail.com>2012-11-25 16:17:46 +0000
commit1914d6f60f4ad92c0efa45a6559a51421bfcaf1e (patch)
tree3fda8e3ec1de79e6442753aa40645cd98f44dbb1 /plugins
parent6c5f57abce943f3838d2eb002c3646df1da939df (diff)
fix for popups that use icons controlled by icolib
git-svn-id: http://svn.miranda-ng.org/main/trunk@2490 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins')
-rw-r--r--plugins/Popup/src/popup_wnd2.cpp1012
-rw-r--r--plugins/Popup/src/popup_wnd2.h176
-rw-r--r--plugins/WhenWasIt/src/notifiers.cpp6
-rw-r--r--plugins/WhenWasIt/src/notifiers.h5
-rw-r--r--plugins/YAPP/src/common.h13
-rw-r--r--plugins/YAPP/src/popwin.cpp977
-rw-r--r--plugins/YAPP/src/services.cpp117
-rw-r--r--plugins/YAPP/src/yapp.cpp32
8 files changed, 1018 insertions, 1320 deletions
diff --git a/plugins/Popup/src/popup_wnd2.cpp b/plugins/Popup/src/popup_wnd2.cpp
index 6ff98aba12..fff5b4464a 100644
--- a/plugins/Popup/src/popup_wnd2.cpp
+++ b/plugins/Popup/src/popup_wnd2.cpp
@@ -163,57 +163,42 @@ void UnloadPopupWnd2()
PopupWnd2::PopupWnd2(POPUPDATA2 *ppd, POPUPOPTIONS *theCustomOptions, bool renderOnly)
{
- m_signature = POPUP_OBJECT_SIGNARURE;
-
- m_lockCount = 0;
- m_hbmAvatar = NULL;
- m_avatar = NULL;
- m_textType = TT_NONE;
- m_options = theCustomOptions ? theCustomOptions : &PopUpOptions;
- m_lpzSkin = NULL;
- m_customPopup = false;
- m_lpwzTitle = m_lpwzText = NULL;
- m_lpzTitle = m_lpzText = NULL;
- m_mtTitle = m_mtText = NULL;
- m_hfnText = fonts.text;
- m_hfnTitle = fonts.title;
- m_hwnd = m_hwndToolTip = NULL;
- m_bPositioned = m_bIsHovered = /*m_bIdleRequested =*/ m_bWindowCreated = m_bFade = m_bSlide = m_bDestroy = false;
- m_bmp = m_bmpBase = m_bmpAnimate = NULL;
- m_avatarFrameDelay = 0;
- m_hhkAvatarChanged = NULL;
- m_actions = NULL;
- m_actionCount = 0;
- m_bIsPinned = false;
+ m_signature = POPUP_OBJECT_SIGNARURE;
+ m_textType = TT_NONE;
+ m_options = theCustomOptions ? theCustomOptions : &PopUpOptions;
+ m_hfnText = fonts.text;
+ m_hfnTitle = fonts.title;
updateData(ppd);
if (!renderOnly)
startThread();
}
-
PopupWnd2::~PopupWnd2()
{
m_signature = 0;
+ setIcon(NULL);
+
+ mir_free(m_lpzSkin);
+ mir_free(m_lpzTitle);
+ mir_free(m_lpwzTitle);
- if (m_lpzSkin) mir_free(m_lpzSkin);
- if (m_hwnd) SetWindowLongPtr(m_hwnd, GWLP_USERDATA, 0);
+ if (m_hwnd)
+ SetWindowLongPtr(m_hwnd, GWLP_USERDATA, 0);
if (m_bmp) delete m_bmp;
if (m_bmpBase) delete m_bmpBase;
if (m_bmpAnimate) delete m_bmpAnimate;
- mir_free(m_lpzText); mir_free(m_lpzTitle);
- mir_free(m_lpwzText); mir_free(m_lpwzTitle);
if (m_mtText) MText.Destroy(m_mtText);
if (m_mtTitle) MText.Destroy(m_mtTitle);
if (m_avatar) delete m_avatar;
if (m_actions) delete [] m_actions;
}
-void PopupWnd2::startThread()
+void PopupWnd2::startThread()
{
_beginthread(WindowThread, 0, this);
}
-void PopupWnd2::create()
+void PopupWnd2::create()
{
m_hwnd = CreateWindowEx(
WS_EX_TRANSPARENT| // prevents unwanted clicks
@@ -231,15 +216,13 @@ void PopupWnd2::create()
(LPVOID)this);
// Shadows
- if (IsWinVerXPPlus())
- {
+ if (IsWinVerXPPlus()) {
ULONG_PTR style = GetClassLongPtr(m_hwnd, GCL_STYLE);
- if (m_options->DropShadow && !(style & CS_DROPSHADOW)) {
+ if (m_options->DropShadow && !(style & CS_DROPSHADOW))
style |= CS_DROPSHADOW;
- }
- else if (!m_options->DropShadow && (style & CS_DROPSHADOW)) {
+ else if (!m_options->DropShadow && (style & CS_DROPSHADOW))
style &= ~CS_DROPSHADOW;
- }
+
SetClassLongPtr(m_hwnd, GCL_STYLE, style);
}
@@ -254,41 +237,41 @@ void PopupWnd2::create()
update();
}
-void PopupWnd2::updateLayered(BYTE opacity)
+void PopupWnd2::updateLayered(BYTE opacity)
{
if (!m_hwnd) return;
- if (SetWindowLongPtr(m_hwnd, GWL_EXSTYLE, GetWindowLongPtr(m_hwnd, GWL_EXSTYLE) | WS_EX_LAYERED)) {
- RECT rc; GetWindowRect(m_hwnd, &rc);
- POINT ptDst = {rc.left, rc.top};
- POINT ptSrc = {0, 0};
+ if (SetWindowLongPtr(m_hwnd, GWL_EXSTYLE, GetWindowLongPtr(m_hwnd, GWL_EXSTYLE) | WS_EX_LAYERED)) {
+ RECT rc; GetWindowRect(m_hwnd, &rc);
+ POINT ptDst = {rc.left, rc.top};
+ POINT ptSrc = {0, 0};
- BLENDFUNCTION blend;
- blend.BlendOp = AC_SRC_OVER;
- blend.BlendFlags = 0;
- blend.SourceConstantAlpha = opacity; //m_options->UseTransparency ? opacity : 255;
- blend.AlphaFormat = AC_SRC_ALPHA;
+ BLENDFUNCTION blend;
+ blend.BlendOp = AC_SRC_OVER;
+ blend.BlendFlags = 0;
+ blend.SourceConstantAlpha = opacity; //m_options->UseTransparency ? opacity : 255;
+ blend.AlphaFormat = AC_SRC_ALPHA;
- UpdateLayeredWindow(m_hwnd, NULL, &ptDst, &m_sz,
- m_bmpAnimate ? m_bmpAnimate->getDC() : m_bmp->getDC(),
- &ptSrc, 0xffffffff, &blend, ULW_ALPHA);
-
- UpdateWindow(m_hwnd);
- }
+ UpdateLayeredWindow(m_hwnd, NULL, &ptDst, &m_sz,
+ m_bmpAnimate ? m_bmpAnimate->getDC() : m_bmp->getDC(),
+ &ptSrc, 0xffffffff, &blend, ULW_ALPHA);
+ UpdateWindow(m_hwnd);
+ }
}
-SIZE PopupWnd2::measure()
+SIZE PopupWnd2::measure()
{
const PopupSkin *skin = skins.getSkin(m_lpzSkin?m_lpzSkin:m_options->SkinPack);
- if (!skin) return m_sz;
+ if (!skin)
+ return m_sz;
MyBitmap bmpTmp(1,1);
skin->measure(bmpTmp.getDC(), this, m_options->UseMaximumWidth ? m_options->MaximumWidth : SETTING_MAXIMUMWIDTH_MAX, m_options);
return m_sz;
}
-void PopupWnd2::update()
+void PopupWnd2::update()
{
const PopupSkin *skin = skins.getSkin(m_lpzSkin?m_lpzSkin:m_options->SkinPack);
if (!skin) return;
@@ -297,8 +280,7 @@ void PopupWnd2::update()
fixAvatar();
// destroy content bitmap so animate() can reallocate it if needed
- if (m_bmp)
- {
+ if (m_bmp) {
delete m_bmp;
m_bmp = NULL;
}
@@ -330,7 +312,7 @@ void PopupWnd2::update()
animate();
}
-void PopupWnd2::animate()
+void PopupWnd2::animate()
{
const PopupSkin *skin = skins.getSkin(m_lpzSkin?m_lpzSkin:m_options->SkinPack);
if (!skin) return;
@@ -382,7 +364,7 @@ void PopupWnd2::animate()
}
}
-void PopupWnd2::show()
+void PopupWnd2::show()
{
if ((m_options->UseEffect || (m_options->UseAnimations && !m_customPopup)) && m_options->FadeIn)
{
@@ -479,7 +461,7 @@ void PopupWnd2::show()
SetWindowPos(m_hwnd, 0, m_pos.x, m_pos.y, 0, 0, SWP_NOZORDER|SWP_NOSIZE|SWP_NOACTIVATE|SWP_DEFERERASE|SWP_NOSENDCHANGING|SWP_SHOWWINDOW);
}
-void PopupWnd2::hide()
+void PopupWnd2::hide()
{
if ((m_options->UseEffect || (m_options->UseAnimations && !m_customPopup)) && m_options->FadeOut)
{
@@ -589,77 +571,65 @@ bool __forceinline isTextEmpty(WCHAR *text)
return true;
}
-void PopupWnd2::fixDefaults()
+void PopupWnd2::fixDefaults()
{
- if (m_options->UseWinColors)
- {
+ if (m_options->UseWinColors) {
m_clBack = GetSysColor(COLOR_BTNFACE);
m_clText = GetSysColor(COLOR_WINDOWTEXT);
m_clTitle = GetSysColor(COLOR_WINDOWTEXT);
m_clClock = GetSysColor(COLOR_WINDOWTEXT);
- } else
- if ((m_clBack == (COLORREF)NULL) && (m_clText == (COLORREF)NULL))
- {
+ }
+ else if ((m_clBack == (COLORREF)NULL) && (m_clText == (COLORREF)NULL)) {
m_clTitle = fonts.clTitle;
m_clBack = fonts.clBack;
m_clText = fonts.clText;
m_clClock = fonts.clClock;
- } else
- {
- m_clClock = m_clTitle;
}
+ else m_clClock = m_clTitle;
if (!m_iTimeout)
- {
m_iTimeout = m_options->InfiniteDelay ? -1 : m_options->Seconds;
- }
m_hContactPassed = m_hContact;
if (m_hContact)
if (!GetContactProto(m_hContact))
m_hContact = NULL;
- switch (m_textType)
- {
- case TT_ANSI:
- m_bTextEmpty = ::isTextEmpty(m_lpzText);
- break;
-
- case TT_UNICODE:
- m_bTextEmpty = ::isTextEmpty(m_lpwzText);
- break;
-
- default:
- m_bTextEmpty = false;
- break;
+ switch (m_textType) {
+ case TT_ANSI:
+ m_bTextEmpty = ::isTextEmpty(m_lpzText);
+ break;
+
+ case TT_UNICODE:
+ m_bTextEmpty = ::isTextEmpty(m_lpwzText);
+ break;
+
+ default:
+ m_bTextEmpty = false;
+ break;
}
}
-void PopupWnd2::fixAvatar()
+void PopupWnd2::fixAvatar()
{
if (m_avatar && !m_avatar->isValid())
delete m_avatar;
if (m_hbmAvatar)
- {
m_avatar = new SimpleAvatar(m_hbmAvatar, true);
- } else
- {
+ else
m_avatar = PopupAvatar::create(m_hContact);
- }
}
-int PopupWnd2::fixActions(POPUPACTION *theActions, int count)
+int PopupWnd2::fixActions(POPUPACTION *theActions, int count)
{
bool isIm = (m_hContact && (CallProtoService(GetContactProto(m_hContact), PS_GETCAPS, PFLAGNUM_1, 0) & PF1_IM)) ? true : false;
-// bool enableDefault = (isIm || !(PopUpOptions.actions&ACT_DEF_IMONLY)) ? true : false;
bool enableDefaultGen = (m_hContact || !(PopUpOptions.actions&ACT_DEF_NOGLOBAL)) ? true : false;
bool enableDefaultUsr = (isIm || m_hContact && !(PopUpOptions.actions&ACT_DEF_IMONLY)) ? true : false;
bool iconSize = PopUpOptions.actions&ACT_LARGE ? TRUE : FALSE;
- if (PopUpOptions.actions&ACT_ENABLE)
- {
+ if (PopUpOptions.actions & ACT_ENABLE) {
if (enableDefaultUsr && isIm && IsActionEnabled("General/Quick reply")) ++m_actionCount;
if (enableDefaultUsr && isIm && IsActionEnabled("General/Send message")) ++m_actionCount;
if (enableDefaultUsr && IsActionEnabled("General/User details")) ++m_actionCount;
@@ -671,8 +641,7 @@ int PopupWnd2::fixActions(POPUPACTION *theActions, int count)
int iAction = fixActions(theActions, count, m_actionCount);
- if (enableDefaultUsr && isIm && IsActionEnabled("General/Quick reply"))
- {
+ if (enableDefaultUsr && isIm && IsActionEnabled("General/Quick reply")) {
m_actions[iAction].actionA.cbSize = sizeof(POPUPACTION);
m_actions[iAction].actionA.lchIcon = IcoLib_GetIcon(ICO_ACT_REPLY,iconSize);
lstrcpyA(m_actions[iAction].actionA.lpzTitle, "General/Quick reply");
@@ -680,8 +649,8 @@ int PopupWnd2::fixActions(POPUPACTION *theActions, int count)
m_actions[iAction].actionA.lParam = ACT_DEF_REPLY;
++iAction;
}
- if (enableDefaultUsr && isIm && IsActionEnabled("General/Send message"))
- {
+
+ if (enableDefaultUsr && isIm && IsActionEnabled("General/Send message")) {
m_actions[iAction].actionA.cbSize = sizeof(POPUPACTION);
m_actions[iAction].actionA.lchIcon = IcoLib_GetIcon(ICO_ACT_MESS,iconSize);
lstrcpyA(m_actions[iAction].actionA.lpzTitle, "General/Send message");
@@ -689,8 +658,8 @@ int PopupWnd2::fixActions(POPUPACTION *theActions, int count)
m_actions[iAction].actionA.lParam = ACT_DEF_MESSAGE;
++iAction;
}
- if (enableDefaultUsr && IsActionEnabled("General/User details"))
- {
+
+ if (enableDefaultUsr && IsActionEnabled("General/User details")) {
m_actions[iAction].actionA.cbSize = sizeof(POPUPACTION);
m_actions[iAction].actionA.lchIcon = IcoLib_GetIcon(ICO_ACT_INFO,iconSize);
lstrcpyA(m_actions[iAction].actionA.lpzTitle, "General/User details");
@@ -698,8 +667,8 @@ int PopupWnd2::fixActions(POPUPACTION *theActions, int count)
m_actions[iAction].actionA.lParam = ACT_DEF_DETAILS;
++iAction;
}
- if (enableDefaultUsr && IsActionEnabled("General/Contact menu"))
- {
+
+ if (enableDefaultUsr && IsActionEnabled("General/Contact menu")) {
m_actions[iAction].actionA.cbSize = sizeof(POPUPACTION);
m_actions[iAction].actionA.lchIcon = IcoLib_GetIcon(ICO_ACT_MENU,iconSize);
lstrcpyA(m_actions[iAction].actionA.lpzTitle, "General/Contact menu");
@@ -707,8 +676,8 @@ int PopupWnd2::fixActions(POPUPACTION *theActions, int count)
m_actions[iAction].actionA.lParam = ACT_DEF_MENU;
++iAction;
}
- if (enableDefaultUsr && DBGetContactSettingByte(m_hContact, "CList", "NotOnList", 0) && IsActionEnabled("General/Add permanently"))
- {
+
+ if (enableDefaultUsr && DBGetContactSettingByte(m_hContact, "CList", "NotOnList", 0) && IsActionEnabled("General/Add permanently")) {
m_actions[iAction].actionA.cbSize = sizeof(POPUPACTION);
m_actions[iAction].actionA.lchIcon = IcoLib_GetIcon(ICO_ACT_ADD,iconSize);
lstrcpyA(m_actions[iAction].actionA.lpzTitle, "General/Add permanently");
@@ -716,8 +685,8 @@ int PopupWnd2::fixActions(POPUPACTION *theActions, int count)
m_actions[iAction].actionA.lParam = ACT_DEF_ADD;
++iAction;
}
- if (enableDefaultGen && (m_iTimeout != -1) && IsActionEnabled("General/Pin popup"))
- {
+
+ if (enableDefaultGen && (m_iTimeout != -1) && IsActionEnabled("General/Pin popup")) {
m_actions[iAction].actionA.cbSize = sizeof(POPUPACTION);
m_actions[iAction].actionA.lchIcon = m_bIsPinned ? IcoLib_GetIcon(ICO_ACT_PINNED,iconSize) : IcoLib_GetIcon(ICO_ACT_PIN,iconSize);
lstrcpyA(m_actions[iAction].actionA.lpzTitle, "General/Pin popup");
@@ -725,8 +694,8 @@ int PopupWnd2::fixActions(POPUPACTION *theActions, int count)
m_actions[iAction].actionA.lParam = ACT_DEF_PIN;
++iAction;
}
- if (enableDefaultGen && IsActionEnabled("General/Dismiss popup"))
- {
+
+ if (enableDefaultGen && IsActionEnabled("General/Dismiss popup")) {
m_actions[iAction].actionA.cbSize = sizeof(POPUPACTION);
m_actions[iAction].actionA.lchIcon = IcoLib_GetIcon(ICO_ACT_CLOSE,iconSize);
lstrcpyA(m_actions[iAction].actionA.lpzTitle, "General/Dismiss popup");
@@ -734,8 +703,8 @@ int PopupWnd2::fixActions(POPUPACTION *theActions, int count)
m_actions[iAction].actionA.lParam = ACT_DEF_DISMISS;
++iAction;
}
- if (enableDefaultGen && IsActionEnabled("General/Copy to clipboard"))
- {
+
+ if (enableDefaultGen && IsActionEnabled("General/Copy to clipboard")) {
m_actions[iAction].actionA.cbSize = sizeof(POPUPACTION);
m_actions[iAction].actionA.lchIcon = IcoLib_GetIcon(ICO_ACT_COPY,iconSize);
lstrcpyA(m_actions[iAction].actionA.lpzTitle, "General/Copy to clipboard");
@@ -748,7 +717,7 @@ int PopupWnd2::fixActions(POPUPACTION *theActions, int count)
return m_actionCount;
}
-int PopupWnd2::fixActions(POPUPACTION *theActions, int count, int additional)
+int PopupWnd2::fixActions(POPUPACTION *theActions, int count, int additional)
{
m_actionCount = 0;
if (m_actions) delete [] m_actions;
@@ -774,7 +743,22 @@ int PopupWnd2::fixActions(POPUPACTION *theActions, int count, int additional)
return iAction;
}
-void PopupWnd2::updateData(POPUPDATA *ppd)
+void PopupWnd2::setIcon(HICON hNewIcon)
+{
+ if (m_bIcoLib) {
+ Skin_ReleaseIcon(m_hIcon);
+ m_bIcoLib = false;
+ }
+
+ m_hIcon = hNewIcon;
+
+ if ( CallService(MS_SKIN2_ISMANAGEDICON, (WPARAM)m_hIcon, 0)) {
+ CallService(MS_SKIN2_ADDREFICON, (WPARAM)m_hIcon, 0);
+ m_bIcoLib = true;
+ }
+}
+
+void PopupWnd2::updateData(POPUPDATA *ppd)
{
m_hContact = ppd->lchContact;
@@ -784,13 +768,12 @@ void PopupWnd2::updateData(POPUPDATA *ppd)
mir_free(m_lpzText); mir_free(m_lpzTitle);
mir_free(m_lpwzText); mir_free(m_lpwzTitle);
- if (m_textType == TT_NONE) m_textType = TT_ANSI;
- m_lpzTitle = mir_strdup(ppd->lpzContactName);
- m_lpzText = mir_strdup(ppd->lpzText);
- m_lpwzTitle = m_lpwzText = NULL;
-// mtTitle = mtText = NULL;
- // hfnTitle, hfnText;
- m_hIcon = ppd->lchIcon;
+ if (m_textType == TT_NONE)
+ m_textType = TT_ANSI;
+ m_lpzTitle = mir_strdup(ppd->lpzContactName);
+ m_lpzText = mir_strdup(ppd->lpzText);
+ m_lpwzTitle = m_lpwzText = NULL;
+ setIcon(ppd->lchIcon);
m_PluginData = ppd->PluginData;
m_PluginWindowProc = ppd->PluginWindowProc;
@@ -804,23 +787,21 @@ void PopupWnd2::updateData(POPUPDATA *ppd)
if (m_textType == TT_MTEXT) buildMText();
}
-void PopupWnd2::updateData(POPUPDATAEX_V2 *ppd)
+void PopupWnd2::updateData(POPUPDATAEX_V2 *ppd)
{
m_hContact = ppd->lchContact;
m_clBack = ppd->colorBack;
- m_clClock = m_clTitle = m_clText = ppd->colorText;
- m_iTimeout = ppd->iSeconds ? ppd->iSeconds : m_options->Seconds;
+ m_clClock = m_clTitle = m_clText = ppd->colorText;
+ m_iTimeout = ppd->iSeconds ? ppd->iSeconds : m_options->Seconds;
if (m_textType == TT_NONE) m_textType = TT_ANSI;
mir_free(m_lpzText); mir_free(m_lpzTitle);
mir_free(m_lpwzText); mir_free(m_lpwzTitle);
- m_lpzTitle = mir_strdup(ppd->lpzContactName);
- m_lpzText = mir_strdup(ppd->lpzText);
- m_lpwzTitle = m_lpwzText = NULL;
-// mtTitle = mtText = NULL;
- // hfnTitle, hfnText;
- m_hIcon = ppd->lchIcon;
+ m_lpzTitle = mir_strdup(ppd->lpzContactName);
+ m_lpzText = mir_strdup(ppd->lpzText);
+ m_lpwzTitle = m_lpwzText = NULL;
+ setIcon(ppd->lchIcon);
m_hNotification = ppd->hNotification;
m_PluginData = ppd->PluginData;
@@ -836,7 +817,7 @@ void PopupWnd2::updateData(POPUPDATAEX_V2 *ppd)
if (m_textType == TT_MTEXT) buildMText();
}
-void PopupWnd2::updateData(POPUPDATAW_V2 *ppd)
+void PopupWnd2::updateData(POPUPDATAW_V2 *ppd)
{
m_hContact = ppd->lchContact;
@@ -847,15 +828,13 @@ void PopupWnd2::updateData(POPUPDATAW_V2 *ppd)
if (m_textType == TT_NONE) m_textType = TT_UNICODE;
mir_free(m_lpzText); mir_free(m_lpzTitle);
mir_free(m_lpwzText); mir_free(m_lpwzTitle);
- m_lpzTitle = m_lpzText = NULL;
- m_lpwzTitle = mir_wstrdup(ppd->lpwzContactName);
- m_lpwzText = mir_wstrdup(ppd->lpwzText);
-// mtTitle = mtText = NULL;
- // hfnTitle, hfnText;
- m_hIcon = ppd->lchIcon;
- m_hNotification = ppd->hNotification;
-
- m_PluginData = ppd->PluginData;
+ m_lpzTitle = m_lpzText = NULL;
+ m_lpwzTitle = mir_wstrdup(ppd->lpwzContactName);
+ m_lpwzText = mir_wstrdup(ppd->lpwzText);
+ setIcon(ppd->lchIcon);
+ m_hNotification = ppd->hNotification;
+
+ m_PluginData = ppd->PluginData;
m_PluginWindowProc = ppd->PluginWindowProc;
if (m_options->DisplayTime)
@@ -868,7 +847,7 @@ void PopupWnd2::updateData(POPUPDATAW_V2 *ppd)
if (m_textType == TT_MTEXT) buildMText();
}
-void PopupWnd2::updateData(POPUPDATA2 *ppd)
+void PopupWnd2::updateData(POPUPDATA2 *ppd)
{
m_hContact = ppd->lchContact;
@@ -878,22 +857,21 @@ void PopupWnd2::updateData(POPUPDATA2 *ppd)
mir_free(m_lpzText); mir_free(m_lpzTitle);
mir_free(m_lpwzText); mir_free(m_lpwzTitle);
- if (ppd->flags&PU2_UNICODE)
- {
+ if (ppd->flags & PU2_UNICODE) {
if (m_textType == TT_NONE) m_textType = TT_UNICODE;
- m_lpzTitle = m_lpzText = NULL;
- m_lpwzTitle = mir_wstrdup(ppd->lpwzTitle);
- m_lpwzText = mir_wstrdup(ppd->lpwzText);
- m_lpzTitle = m_lpzText = NULL;
- } else
- {
+ m_lpzTitle = m_lpzText = NULL;
+ m_lpwzTitle = mir_wstrdup(ppd->lpwzTitle);
+ m_lpwzText = mir_wstrdup(ppd->lpwzText);
+ m_lpzTitle = m_lpzText = NULL;
+ }
+ else {
if (m_textType == TT_NONE) m_textType = TT_ANSI;
- m_lpzTitle = mir_strdup(ppd->lpzTitle);
- m_lpzText = mir_strdup(ppd->lpzText);
- m_lpwzTitle = m_lpwzText = NULL;
+ m_lpzTitle = mir_strdup(ppd->lpzTitle);
+ m_lpzText = mir_strdup(ppd->lpzText);
+ m_lpwzTitle = m_lpwzText = NULL;
}
- m_hIcon = ppd->lchIcon;
+ setIcon(ppd->lchIcon);
m_hNotification = ppd->lchNotification;
m_PluginData = ppd->PluginData;
@@ -925,7 +903,7 @@ void PopupWnd2::updateData(POPUPDATA2 *ppd)
if (m_textType == TT_MTEXT) buildMText();
}
-void PopupWnd2::buildMText()
+void PopupWnd2::buildMText()
{
if (!(htuText && htuTitle && PopUpOptions.UseMText))
return;
@@ -962,7 +940,7 @@ void PopupWnd2::buildMText()
}
}
-void PopupWnd2::updateText(char *text)
+void PopupWnd2::updateText(char *text)
{
if (m_lpzText)
{
@@ -974,7 +952,7 @@ void PopupWnd2::updateText(char *text)
m_bTextEmpty = ::isTextEmpty(m_lpzText);
}
-void PopupWnd2::updateText(WCHAR *text)
+void PopupWnd2::updateText(WCHAR *text)
{
if (m_lpwzText)
{
@@ -986,7 +964,7 @@ void PopupWnd2::updateText(WCHAR *text)
m_bTextEmpty = ::isTextEmpty(m_lpwzText);
}
-void PopupWnd2::updateTitle(char *title)
+void PopupWnd2::updateTitle(char *title)
{
if (m_lpzTitle)
{
@@ -997,7 +975,7 @@ void PopupWnd2::updateTitle(char *title)
}
}
-void PopupWnd2::updateTitle(WCHAR *title)
+void PopupWnd2::updateTitle(WCHAR *title)
{
if (m_lpwzTitle)
{
@@ -1008,7 +986,7 @@ void PopupWnd2::updateTitle(WCHAR *title)
}
}
-void PopupWnd2::updateTimer()
+void PopupWnd2::updateTimer()
{
KillTimer(m_hwnd, POPUP_TIMER);
if (m_iTimeout > 0)
@@ -1180,179 +1158,164 @@ LRESULT CALLBACK ReplyEditWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM
}
if (oldWndProc)
- {
-
return CallWindowProcW(oldWndProc, hwnd, message, wParam, lParam);
- }
-
return DefWindowProc(hwnd, message, wParam, lParam);
}
LRESULT CALLBACK PopupWnd2::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
{
- switch (message)
- {
- case WM_CREATE:
- {
-// show();
- return DefWindowProc(m_hwnd, message, wParam, lParam);
- break;
- }
+ switch (message) {
+ case WM_CREATE:
+ return DefWindowProc(m_hwnd, message, wParam, lParam);
- case UM_INITPOPUP:
- {
- if (!m_customPopup) PopupThreadAddWindow(this);
- if (m_iTimeout > 0) SetTimer(m_hwnd, POPUP_TIMER, m_iTimeout*1000, 0);
- if (m_hContact && !m_hbmAvatar && PopUpOptions.EnableAvatarUpdates)
- m_hhkAvatarChanged = HookEventMessage(ME_AV_AVATARCHANGED, m_hwnd, UM_AVATARCHANGED);
- if (m_avatar->activeFrameDelay() > 0) SetTimer(m_hwnd, AVATAR_TIMER, m_avatar->activeFrameDelay(), 0);
+ case UM_INITPOPUP:
+ if (!m_customPopup) PopupThreadAddWindow(this);
+ if (m_iTimeout > 0) SetTimer(m_hwnd, POPUP_TIMER, m_iTimeout*1000, 0);
+ if (m_hContact && !m_hbmAvatar && PopUpOptions.EnableAvatarUpdates)
+ m_hhkAvatarChanged = HookEventMessage(ME_AV_AVATARCHANGED, m_hwnd, UM_AVATARCHANGED);
+ if (m_avatar->activeFrameDelay() > 0) SetTimer(m_hwnd, AVATAR_TIMER, m_avatar->activeFrameDelay(), 0);
- // prevent unwanted clicks, but allow wanted :)
- GetCursorPos(&m_ptPrevCursor);
- SetTimer(m_hwnd, CURSOR_TIMER, 500, NULL);
+ // prevent unwanted clicks, but allow wanted :)
+ GetCursorPos(&m_ptPrevCursor);
+ SetTimer(m_hwnd, CURSOR_TIMER, 500, NULL);
- break;
- }
+ break;
- case UM_POPUPSHOW:
+ case UM_POPUPSHOW:
{
POINT pt; pt.x = wParam; pt.y = lParam;
setPosition(pt);
show();
- break;
}
+ break;
- case UM_AVATARCHANGED:
+ case UM_AVATARCHANGED:
+ if ((HANDLE)wParam == m_hContact)
{
- if ((HANDLE)wParam == m_hContact)
- {
- m_avatar->invalidate();
- update();
- if (m_avatar->activeFrameDelay() > 0) SetTimer(m_hwnd, AVATAR_TIMER, m_avatar->activeFrameDelay(), 0);
- }
- break;
+ m_avatar->invalidate();
+ update();
+ if (m_avatar->activeFrameDelay() > 0) SetTimer(m_hwnd, AVATAR_TIMER, m_avatar->activeFrameDelay(), 0);
}
+ break;
- case UM_POPUPACTION:
- {
- if (wParam != 0) break;
- switch (lParam)
- {
- case ACT_DEF_MESSAGE:
- CallServiceSync(MS_MSG_SENDMESSAGE, (WPARAM)m_hContact, 0);
- if (!(PopUpOptions.actions&ACT_DEF_KEEPWND))
- PUDeletePopUp(m_hwnd);
- break;
+ case UM_POPUPACTION:
+ if (wParam != 0) break;
+ switch (lParam) {
+ case ACT_DEF_MESSAGE:
+ CallServiceSync(MS_MSG_SENDMESSAGE, (WPARAM)m_hContact, 0);
+ if (!(PopUpOptions.actions&ACT_DEF_KEEPWND))
+ PUDeletePopUp(m_hwnd);
+ break;
- case ACT_DEF_REPLY:
- {
- if (!m_customPopup) PopupThreadLock();
- //RECT rc = renderInfo.textRect;
- //MapWindowPoints(hwnd, NULL, (LPPOINT)&rc, 2);
- RECT rc; GetWindowRect(m_hwnd, &rc);
+ case ACT_DEF_REPLY:
+ {
+ if (!m_customPopup) PopupThreadLock();
+ //RECT rc = renderInfo.textRect;
+ //MapWindowPoints(hwnd, NULL, (LPPOINT)&rc, 2);
+ RECT rc; GetWindowRect(m_hwnd, &rc);
- HWND hwndEditBox = CreateWindowExW(WS_EX_TOOLWINDOW|WS_EX_TOPMOST,
+ HWND hwndEditBox = CreateWindowExW(WS_EX_TOOLWINDOW|WS_EX_TOPMOST,
g_wndClass.cPopupEditBox ? L"PopupEditBox" : L"EDIT",
NULL,
WS_BORDER|WS_POPUP|WS_VISIBLE|ES_AUTOVSCROLL|ES_LEFT|ES_MULTILINE|ES_NOHIDESEL|ES_WANTRETURN,
rc.left, rc.top, rc.right-rc.left, rc.bottom-rc.top, NULL, NULL, hInst, NULL);
- ReplyEditData *dat = (ReplyEditData *)mir_alloc(sizeof(ReplyEditData));
- dat->oldWndProc = (WNDPROC)GetWindowLongPtr(hwndEditBox, (LONG_PTR)GWLP_WNDPROC);
- dat->hwndPopup = m_hwnd;
- dat->hContact = m_hContact;
- if(IsWindowUnicode(hwndEditBox)) {
+ ReplyEditData *dat = (ReplyEditData *)mir_alloc(sizeof(ReplyEditData));
+ dat->oldWndProc = (WNDPROC)GetWindowLongPtr(hwndEditBox, (LONG_PTR)GWLP_WNDPROC);
+ dat->hwndPopup = m_hwnd;
+ dat->hContact = m_hContact;
+ if(IsWindowUnicode(hwndEditBox)) {
- SendMessageW(hwndEditBox, WM_SETFONT, (WPARAM)fonts.text, TRUE);
-
- SetWindowLongPtrW(hwndEditBox, GWLP_USERDATA, (LONG_PTR)dat);
- SetWindowLongPtrW(hwndEditBox, GWLP_WNDPROC, (LONG_PTR)ReplyEditWndProc);
- }
- else {
- SendMessageA(hwndEditBox, WM_SETFONT, (WPARAM)fonts.text, TRUE);
- SetWindowLongPtrA(hwndEditBox, GWLP_USERDATA, (LONG_PTR)dat);
- SetWindowLongPtrA(hwndEditBox, GWLP_WNDPROC, (LONG_PTR)ReplyEditWndProc);
- }
- SetFocus(hwndEditBox);
- break;
- }
+ SendMessageW(hwndEditBox, WM_SETFONT, (WPARAM)fonts.text, TRUE);
- case ACT_DEF_DETAILS:
- CallServiceSync(MS_USERINFO_SHOWDIALOG, (WPARAM)m_hContact, 0);
- if (!(PopUpOptions.actions&ACT_DEF_KEEPWND))
- PUDeletePopUp(m_hwnd);
- break;
- case ACT_DEF_MENU:
- {
- lock();
- PostMessage(ghwndMenuHost, UM_SHOWMENU, (WPARAM)m_hwnd, (LPARAM)m_hContact);
- break;
+ SetWindowLongPtrW(hwndEditBox, GWLP_USERDATA, (LONG_PTR)dat);
+ SetWindowLongPtrW(hwndEditBox, GWLP_WNDPROC, (LONG_PTR)ReplyEditWndProc);
}
- case ACT_DEF_ADD:
- {
- ADDCONTACTSTRUCT acs = {0};
- acs.handle = m_hContact;
- acs.handleType = HANDLE_CONTACT;
- acs.szProto = 0;
- CallServiceSync(MS_ADDCONTACT_SHOW, NULL, (LPARAM)&acs);
- if (!(PopUpOptions.actions&ACT_DEF_KEEPWND))
- PUDeletePopUp(m_hwnd);
- break;
+ else {
+ SendMessageA(hwndEditBox, WM_SETFONT, (WPARAM)fonts.text, TRUE);
+ SetWindowLongPtrA(hwndEditBox, GWLP_USERDATA, (LONG_PTR)dat);
+ SetWindowLongPtrA(hwndEditBox, GWLP_WNDPROC, (LONG_PTR)ReplyEditWndProc);
}
- case ACT_DEF_PIN:
+ SetFocus(hwndEditBox);
+ break;
+ }
+
+ case ACT_DEF_DETAILS:
+ CallServiceSync(MS_USERINFO_SHOWDIALOG, (WPARAM)m_hContact, 0);
+ if (!(PopUpOptions.actions&ACT_DEF_KEEPWND))
+ PUDeletePopUp(m_hwnd);
+ break;
+
+ case ACT_DEF_MENU:
+ lock();
+ PostMessage(ghwndMenuHost, UM_SHOWMENU, (WPARAM)m_hwnd, (LPARAM)m_hContact);
+ break;
+
+ case ACT_DEF_ADD:
+ {
+ ADDCONTACTSTRUCT acs = {0};
+ acs.handle = m_hContact;
+ acs.handleType = HANDLE_CONTACT;
+ acs.szProto = 0;
+ CallServiceSync(MS_ADDCONTACT_SHOW, NULL, (LPARAM)&acs);
+ if (!(PopUpOptions.actions&ACT_DEF_KEEPWND))
+ PUDeletePopUp(m_hwnd);
+ }
+ break;
+
+ case ACT_DEF_PIN:
+ if (m_bIsPinned)
+ SetTimer(m_hwnd, POPUP_TIMER, m_iTimeout*1000, NULL);
+ else
+ KillTimer(m_hwnd, POPUP_TIMER);
+
+ m_bIsPinned = !m_bIsPinned;
+ {
+ bool iconSize = PopUpOptions.actions&ACT_LARGE ? TRUE : FALSE;
+ PUModifyActionIcon(m_hwnd, wParam, lParam, m_bIsPinned ? IcoLib_GetIcon(ICO_ACT_PINNED,iconSize) : IcoLib_GetIcon(ICO_ACT_PIN,iconSize));
+ }
+ break;
+
+ case ACT_DEF_DISMISS:
+ PUDeletePopUp(m_hwnd);
+ break;
+
+ case ACT_DEF_COPY:
+ {
+ #define CF_TCHAR CF_UNICODETEXT
+
+ HGLOBAL clipbuffer;
+ static TCHAR * buffer, *text;
+ char* sztext;
+ if ((this->m_lpwzText) || (this->m_lpwzTitle))
{
- if (m_bIsPinned)
- {
- SetTimer(m_hwnd, POPUP_TIMER, m_iTimeout*1000, NULL);
- } else
- {
- KillTimer(m_hwnd, POPUP_TIMER);
- }
- m_bIsPinned = !m_bIsPinned;
- bool iconSize = PopUpOptions.actions&ACT_LARGE ? TRUE : FALSE;
- PUModifyActionIcon(m_hwnd, wParam, lParam, m_bIsPinned ? IcoLib_GetIcon(ICO_ACT_PINNED,iconSize) : IcoLib_GetIcon(ICO_ACT_PIN,iconSize));
- break;
+ text = (TCHAR*)mir_alloc((_tcslen(this->m_lpwzText) + _tcslen(this->m_lpwzTitle)+3)*sizeof(TCHAR));
+ mir_sntprintf(text, _tcslen(this->m_lpwzText) + _tcslen(this->m_lpwzTitle)+3, _T("%s\n\n%s"), this->m_lpwzTitle, this->m_lpwzText);
}
- case ACT_DEF_DISMISS:
- PUDeletePopUp(m_hwnd);
- break;
- case ACT_DEF_COPY:
+ else if ((this->m_lpzText) || (this->m_lpzTitle))
{
- #define CF_TCHAR CF_UNICODETEXT
-
- HGLOBAL clipbuffer;
- static TCHAR * buffer, *text;
- char* sztext;
- if ((this->m_lpwzText) || (this->m_lpwzTitle))
- {
- text = (TCHAR*)mir_alloc((_tcslen(this->m_lpwzText) + _tcslen(this->m_lpwzTitle)+3)*sizeof(TCHAR));
- mir_sntprintf(text, _tcslen(this->m_lpwzText) + _tcslen(this->m_lpwzTitle)+3, _T("%s\n\n%s"), this->m_lpwzTitle, this->m_lpwzText);
- }
- else if ((this->m_lpzText) || (this->m_lpzTitle))
- {
- sztext = (char*)mir_alloc((lstrlenA(this->m_lpzText) + lstrlenA(this->m_lpzTitle)+3)*sizeof(char));
- mir_snprintf(sztext, lstrlenA(this->m_lpzText) + lstrlenA(this->m_lpzTitle)+3, "%s\n\n%s", this->m_lpzTitle, this->m_lpzText);
- text = mir_a2t(sztext);
- }
- OpenClipboard(m_hwnd);
- EmptyClipboard();
- clipbuffer = GlobalAlloc(GMEM_MOVEABLE | GMEM_SHARE, (lstrlen(text)+1) * sizeof(TCHAR));
- buffer = (TCHAR *)GlobalLock(clipbuffer);
- lstrcpy(buffer, text);
- GlobalUnlock(clipbuffer);
- SetClipboardData(CF_TCHAR, clipbuffer);
- CloseClipboard();
- if (sztext)
- mir_free(text);
- PUDeletePopUp(m_hwnd);
- break;
+ sztext = (char*)mir_alloc((lstrlenA(this->m_lpzText) + lstrlenA(this->m_lpzTitle)+3)*sizeof(char));
+ mir_snprintf(sztext, lstrlenA(this->m_lpzText) + lstrlenA(this->m_lpzTitle)+3, "%s\n\n%s", this->m_lpzTitle, this->m_lpzText);
+ text = mir_a2t(sztext);
}
+ OpenClipboard(m_hwnd);
+ EmptyClipboard();
+ clipbuffer = GlobalAlloc(GMEM_MOVEABLE | GMEM_SHARE, (lstrlen(text)+1) * sizeof(TCHAR));
+ buffer = (TCHAR *)GlobalLock(clipbuffer);
+ lstrcpy(buffer, text);
+ GlobalUnlock(clipbuffer);
+ SetClipboardData(CF_TCHAR, clipbuffer);
+ CloseClipboard();
+ if (sztext)
+ mir_free(text);
+ PUDeletePopUp(m_hwnd);
+ break;
}
- break;
}
+ break;
- case UM_POPUPMODIFYACTIONICON:
+ case UM_POPUPMODIFYACTIONICON:
{
LPPOPUPACTIONID actionId = (LPPOPUPACTIONID)wParam;
for (int i=0; i < m_actionCount; ++i)
@@ -1363,36 +1326,18 @@ LRESULT CALLBACK PopupWnd2::WindowProc(UINT message, WPARAM wParam, LPARAM lPara
animate();
break;
}
-
- break;
}
+ break;
- case UM_MENUDONE:
+ case UM_MENUDONE:
{
unlock();
if (!(PopUpOptions.actions&ACT_DEF_KEEPWND))
PUDeletePopUp(m_hwnd);
break;
}
-/*
- case WM_WINDOWPOSCHANGED:
- {
- WINDOWPOS *wp = (WINDOWPOS *)lParam;
- if (!bIsHovered)
- {
- RECT rc; SetRect(&rc, wp->x, wp->y, wp->x + wp->cx, wp->y + wp->cy);
- GetCursorPos(&ptPrevCursor);
- if (PtInRect(&rc, ptPrevCursor))
- {
- SetWindowLongPtr(hwnd, GWLP_EXSTYLE, GetWindowLongPtr(hwnd, GWLP_EXSTYLE) | WS_EX_TRANSPARENT);
- SetTimer(hwnd, CURSOR_TIMER, 500, NULL);
- }
- }
- break;
- }
-*/
- case WM_LBUTTONUP:
+ case WM_LBUTTONUP:
{
int i;
for (i = 0; i < m_actionCount; ++i)
@@ -1402,33 +1347,9 @@ LRESULT CALLBACK PopupWnd2::WindowProc(UINT message, WPARAM wParam, LPARAM lPara
break;
}
- if (i == m_actionCount)
- {
+ if (i == m_actionCount) {
if(PopUpOptions.overrideLeft!=false && (m_hContact!=NULL || PopUpOptions.overrideLeft == 5 || PopUpOptions.overrideLeft == 6)) {
switch (PopUpOptions.overrideLeft){
- default:
- case 1:SendMessage(m_hwnd, UM_POPUPACTION,0, ACT_DEF_MESSAGE); break;
- case 2:SendMessage(m_hwnd, UM_POPUPACTION,0, ACT_DEF_REPLY); break;
- case 3:SendMessage(m_hwnd, UM_POPUPACTION,0, ACT_DEF_DETAILS); break;
- case 4:SendMessage(m_hwnd, UM_POPUPACTION,0, ACT_DEF_MENU); break;
- case 5:SendMessage(m_hwnd, UM_POPUPACTION,0, ACT_DEF_DISMISS); break;
- case 6:SendMessage(m_hwnd, UM_POPUPACTION,0, ACT_DEF_PIN); break;
- case 7:SendMessage(m_hwnd, UM_POPUPACTION,0, ACT_DEF_COPY); break;
- }
- }else{
- lock();
- if (!PerformAction(m_hNotification, m_hwnd, message, wParam, lParam))
- SendMessage(m_hwnd, WM_COMMAND, 0, 0);
- unlock();
- }
- }
- break;
- }
-
- case WM_MBUTTONUP:
- {
- if(PopUpOptions.overrideMiddle!=false && (m_hContact!=NULL || PopUpOptions.overrideMiddle == 5 || PopUpOptions.overrideMiddle == 6)) {
- switch (PopUpOptions.overrideMiddle){
default:
case 1:SendMessage(m_hwnd, UM_POPUPACTION,0, ACT_DEF_MESSAGE); break;
case 2:SendMessage(m_hwnd, UM_POPUPACTION,0, ACT_DEF_REPLY); break;
@@ -1437,147 +1358,138 @@ LRESULT CALLBACK PopupWnd2::WindowProc(UINT message, WPARAM wParam, LPARAM lPara
case 5:SendMessage(m_hwnd, UM_POPUPACTION,0, ACT_DEF_DISMISS); break;
case 6:SendMessage(m_hwnd, UM_POPUPACTION,0, ACT_DEF_PIN); break;
case 7:SendMessage(m_hwnd, UM_POPUPACTION,0, ACT_DEF_COPY); break;
+ }
+ }
+ else {
+ lock();
+ if (!PerformAction(m_hNotification, m_hwnd, message, wParam, lParam))
+ SendMessage(m_hwnd, WM_COMMAND, 0, 0);
+ unlock();
}
}
break;
}
- case WM_CONTEXTMENU:
- {
- if(PopUpOptions.overrideRight!=false && (m_hContact!=NULL || PopUpOptions.overrideRight == 5 || PopUpOptions.overrideRight == 6)) {
- switch (PopUpOptions.overrideRight){
- default:
- case 1:SendMessage(m_hwnd, UM_POPUPACTION,0, ACT_DEF_MESSAGE); break;
- case 2:SendMessage(m_hwnd, UM_POPUPACTION,0, ACT_DEF_REPLY); break;
- case 3:SendMessage(m_hwnd, UM_POPUPACTION,0, ACT_DEF_DETAILS); break;
- case 4:SendMessage(m_hwnd, UM_POPUPACTION,0, ACT_DEF_MENU); break;
- case 5:SendMessage(m_hwnd, UM_POPUPACTION,0, ACT_DEF_DISMISS); break;
- case 6:SendMessage(m_hwnd, UM_POPUPACTION,0, ACT_DEF_PIN); break;
- case 7:SendMessage(m_hwnd, UM_POPUPACTION,0, ACT_DEF_COPY); break;
- }
- return TRUE;
- }else{
- lock();
- if (PerformAction(m_hNotification, m_hwnd, message, wParam, lParam))
- {
- unlock();
- return TRUE;
- }
- unlock();
+ case WM_MBUTTONUP:
+ if ( PopUpOptions.overrideMiddle!=false && (m_hContact!=NULL || PopUpOptions.overrideMiddle == 5 || PopUpOptions.overrideMiddle == 6)) {
+ switch (PopUpOptions.overrideMiddle){
+ default:
+ case 1:SendMessage(m_hwnd, UM_POPUPACTION,0, ACT_DEF_MESSAGE); break;
+ case 2:SendMessage(m_hwnd, UM_POPUPACTION,0, ACT_DEF_REPLY); break;
+ case 3:SendMessage(m_hwnd, UM_POPUPACTION,0, ACT_DEF_DETAILS); break;
+ case 4:SendMessage(m_hwnd, UM_POPUPACTION,0, ACT_DEF_MENU); break;
+ case 5:SendMessage(m_hwnd, UM_POPUPACTION,0, ACT_DEF_DISMISS); break;
+ case 6:SendMessage(m_hwnd, UM_POPUPACTION,0, ACT_DEF_PIN); break;
+ case 7:SendMessage(m_hwnd, UM_POPUPACTION,0, ACT_DEF_COPY); break;
}
}
-/*
- case WM_RBUTTONUP:
- {
- SendMessage(hwnd, WM_CONTEXTMENU, 0, 0);
- break;
+ break;
+
+ case WM_CONTEXTMENU:
+ if ( PopUpOptions.overrideRight!=false && (m_hContact!=NULL || PopUpOptions.overrideRight == 5 || PopUpOptions.overrideRight == 6)) {
+ switch (PopUpOptions.overrideRight){
+ default:
+ case 1:SendMessage(m_hwnd, UM_POPUPACTION,0, ACT_DEF_MESSAGE); break;
+ case 2:SendMessage(m_hwnd, UM_POPUPACTION,0, ACT_DEF_REPLY); break;
+ case 3:SendMessage(m_hwnd, UM_POPUPACTION,0, ACT_DEF_DETAILS); break;
+ case 4:SendMessage(m_hwnd, UM_POPUPACTION,0, ACT_DEF_MENU); break;
+ case 5:SendMessage(m_hwnd, UM_POPUPACTION,0, ACT_DEF_DISMISS); break;
+ case 6:SendMessage(m_hwnd, UM_POPUPACTION,0, ACT_DEF_PIN); break;
+ case 7:SendMessage(m_hwnd, UM_POPUPACTION,0, ACT_DEF_COPY); break;
+ }
+ return TRUE;
}
-*/
- case WM_TIMER:
- {
- switch (wParam)
- {
- case POPUP_TIMER:
- {
- KillTimer(m_hwnd, POPUP_TIMER);
- if (!m_customPopup)
- {
- PopupThreadRequestRemoveWindow(this);
- } else
- {
- if (isLocked())
- {
- updateTimer();
- } else
- {
- PostMessage(m_hwnd, WM_CLOSE, 0, 0);
- }
- }
- break;
- }
-
- case AVATAR_TIMER:
- {
- int newDelay = m_avatar->activeFrameDelay();
- animate();
- if ((newDelay <= 0) || (newDelay != m_avatarFrameDelay)) KillTimer(m_hwnd, AVATAR_TIMER);
- if (newDelay > 0) {
- SetTimer(m_hwnd, AVATAR_TIMER, newDelay, 0);
- m_avatarFrameDelay = newDelay;
- }
- break;
- }
-
- case CURSOR_TIMER:
- {
- POINT pt; GetCursorPos(&pt);
- if (abs(pt.x-m_ptPrevCursor.x) + abs(pt.y-m_ptPrevCursor.y) > 4)
- {
- SetWindowLongPtr(m_hwnd, GWL_EXSTYLE, GetWindowLongPtr(m_hwnd, GWL_EXSTYLE) & ~WS_EX_TRANSPARENT);
- KillTimer(m_hwnd, CURSOR_TIMER);
- }
- break;
- }
+ else{
+ lock();
+ if (PerformAction(m_hNotification, m_hwnd, message, wParam, lParam)) {
+ unlock();
+ return TRUE;
}
-
- break;
+ unlock();
}
- case UM_DESTROYPOPUP:
- {
+ case WM_TIMER:
+ switch (wParam) {
+ case POPUP_TIMER:
KillTimer(m_hwnd, POPUP_TIMER);
- KillTimer(m_hwnd, AVATAR_TIMER);
- KillTimer(m_hwnd, CURSOR_TIMER);
- PostMessage(m_hwnd, WM_CLOSE, 0, 0);
+ if (!m_customPopup)
+ PopupThreadRequestRemoveWindow(this);
+ else {
+ if (isLocked())
+ updateTimer();
+ else
+ PostMessage(m_hwnd, WM_CLOSE, 0, 0);
+ }
break;
- }
- case UM_CHANGEPOPUP:
- {
- switch (wParam)
+ case AVATAR_TIMER:
{
- case CPT_TEXT: updateText((char *)lParam); mir_free((void *)lParam); break;
- case CPT_TEXTW: updateText((WCHAR *)lParam); mir_free((void *)lParam); break;
- case CPT_TITLE: updateTitle((char *)lParam); mir_free((void *)lParam); break;
- case CPT_TITLEW: updateTitle((WCHAR *)lParam); mir_free((void *)lParam); break;
- case CPT_DATA: updateData((POPUPDATA *)lParam); mir_free((void *)lParam); break;
- case CPT_DATAEX: updateData((POPUPDATAEX_V2 *)lParam); mir_free((void *)lParam); break;
- case CPT_DATAW: updateData((POPUPDATAW_V2 *)lParam); mir_free((void *)lParam); break;
+ int newDelay = m_avatar->activeFrameDelay();
+ animate();
+ if ((newDelay <= 0) || (newDelay != m_avatarFrameDelay)) KillTimer(m_hwnd, AVATAR_TIMER);
+ if (newDelay > 0) {
+ SetTimer(m_hwnd, AVATAR_TIMER, newDelay, 0);
+ m_avatarFrameDelay = newDelay;
+ }
+ break;
+ }
+
+ case CURSOR_TIMER:
+ {
+ POINT pt; GetCursorPos(&pt);
+ if (abs(pt.x-m_ptPrevCursor.x) + abs(pt.y-m_ptPrevCursor.y) > 4) {
+ SetWindowLongPtr(m_hwnd, GWL_EXSTYLE, GetWindowLongPtr(m_hwnd, GWL_EXSTYLE) & ~WS_EX_TRANSPARENT);
+ KillTimer(m_hwnd, CURSOR_TIMER);
+ }
+ break;
}
- update();
- break;
}
+ break;
+
+ case UM_DESTROYPOPUP:
+ KillTimer(m_hwnd, POPUP_TIMER);
+ KillTimer(m_hwnd, AVATAR_TIMER);
+ KillTimer(m_hwnd, CURSOR_TIMER);
+ PostMessage(m_hwnd, WM_CLOSE, 0, 0);
+ break;
+
+ case UM_CHANGEPOPUP:
+ switch (wParam) {
+ case CPT_TEXT: updateText((char *)lParam); mir_free((void *)lParam); break;
+ case CPT_TEXTW: updateText((WCHAR *)lParam); mir_free((void *)lParam); break;
+ case CPT_TITLE: updateTitle((char *)lParam); mir_free((void *)lParam); break;
+ case CPT_TITLEW: updateTitle((WCHAR *)lParam); mir_free((void *)lParam); break;
+ case CPT_DATA: updateData((POPUPDATA *)lParam); mir_free((void *)lParam); break;
+ case CPT_DATAEX: updateData((POPUPDATAEX_V2 *)lParam); mir_free((void *)lParam); break;
+ case CPT_DATAW: updateData((POPUPDATAW_V2 *)lParam); mir_free((void *)lParam); break;
+ }
+ update();
+ break;
- case UM_CALLMETHOD:
+ case UM_CALLMETHOD:
{
MethodPtr *method_copy = (MethodPtr *)wParam;
(this->*(*method_copy))(lParam);
delete method_copy;
- break;
}
+ break;
- case WM_PAINT:
- {
- if (GetUpdateRect(m_hwnd, 0, FALSE))
- {
- PAINTSTRUCT ps;
- HDC mydc = BeginPaint(m_hwnd, &ps);
- BitBlt(mydc, 0, 0, m_sz.cx, m_sz.cy, m_bmp->getDC(), 0, 0, SRCCOPY);
- EndPaint(m_hwnd, &ps);
- return 0;
- }
- break;
- }
-
- case WM_PRINT:
- case WM_PRINTCLIENT:
- {
- HDC mydc = (HDC)wParam;
+ case WM_PAINT:
+ if (GetUpdateRect(m_hwnd, 0, FALSE)) {
+ PAINTSTRUCT ps;
+ HDC mydc = BeginPaint(m_hwnd, &ps);
BitBlt(mydc, 0, 0, m_sz.cx, m_sz.cy, m_bmp->getDC(), 0, 0, SRCCOPY);
- break;
+ EndPaint(m_hwnd, &ps);
+ return 0;
}
+ break;
- case WM_MOUSEMOVE:
+ case WM_PRINT:
+ case WM_PRINTCLIENT:
+ BitBlt((HDC)wParam, 0, 0, m_sz.cx, m_sz.cy, m_bmp->getDC(), 0, 0, SRCCOPY);
+ break;
+
+ case WM_MOUSEMOVE:
{
const PopupSkin *skin = skins.getSkin(m_lpzSkin?m_lpzSkin:m_options->SkinPack);
if (skin)
@@ -1597,9 +1509,10 @@ LRESULT CALLBACK PopupWnd2::WindowProc(UINT message, WPARAM wParam, LPARAM lPara
updateLayered(255);
m_bIsHovered = true;
- break;
}
- case WM_MOUSELEAVE:
+ break;
+
+ case WM_MOUSELEAVE:
{
const PopupSkin *skin = skins.getSkin(m_lpzSkin?m_lpzSkin:m_options->SkinPack);
if (skin)
@@ -1613,80 +1526,37 @@ LRESULT CALLBACK PopupWnd2::WindowProc(UINT message, WPARAM wParam, LPARAM lPara
if (!m_customPopup) PopupThreadUnlock();
m_bIsHovered = false;
- break;
}
+ break;
- case WM_CLOSE:
- {
- hide();
- return TRUE;
- }
+ case WM_CLOSE:
+ hide();
+ return TRUE;
- case WM_DESTROY:
- {
- if (m_bIsHovered)
- {
- if (!m_customPopup) PopupThreadUnlock();
- m_bIsHovered = false;
- }
- if (m_hhkAvatarChanged)
- PopUp_UnhookEventAsync((WPARAM)m_hwnd, (LPARAM)m_hhkAvatarChanged);
- SendMessage(m_hwnd, UM_FREEPLUGINDATA, 0, 0);
- SetWindowLongPtr(m_hwnd, GWLP_USERDATA, 0);
- m_hwnd = 0;
-
- DestroyWindow(m_hwndToolTip);
-
- if (!m_customPopup)
- {
- // we can't access "this" pointer after followint line!
- PopupThreadRemoveWindow(this);
- } else
- {
- delete this;
- }
-
- PostQuitMessage(0);
- return TRUE;
- }
-/*
- case WM_WINDOWPOSCHANGING:
-// case WM_WINDOWPOSCHANGED:
- {
- WINDOWPOS *wp = (WINDOWPOS *)lParam;
- wp->flags |= SWP_NOACTIVATE; // block focus stealing
-
- if (!(wp->flags & SWP_NOZORDER))
- {
- if ((wp->hwndInsertAfter == HWND_BOTTOM) ||
- (wp->hwndInsertAfter == HWND_NOTOPMOST) ||
- (wp->hwndInsertAfter == HWND_TOP))
- {
- wp->hwndInsertAfter == HWND_TOPMOST;
- } else
- if (wp->hwndInsertAfter != HWND_TOPMOST)
- {
- HWND hwndAbove = GetWindow(wp->hwndInsertAfter, GW_HWNDPREV);
- if (hwndAbove)
- {
- char buf[64];
- GetClassName(hwndAbove, buf, sizeof(buf));
- buf[sizeof(buf)-1] = 0;
-
- if (lstrcmp(buf, POPUP_WNDCLASS))
- wp->hwndInsertAfter == HWND_TOPMOST;
- }
- }
- }
-
- // this allows us to reduce message traffic
- return 0;
+ case WM_DESTROY:
+ if (m_bIsHovered) {
+ if (!m_customPopup) PopupThreadUnlock();
+ m_bIsHovered = false;
}
-*/
+ if (m_hhkAvatarChanged)
+ PopUp_UnhookEventAsync((WPARAM)m_hwnd, (LPARAM)m_hhkAvatarChanged);
+ SendMessage(m_hwnd, UM_FREEPLUGINDATA, 0, 0);
+ SetWindowLongPtr(m_hwnd, GWLP_USERDATA, 0);
+ m_hwnd = 0;
+
+ DestroyWindow(m_hwndToolTip);
+
+ if (!m_customPopup)
+ // we can't access "this" pointer after following line!
+ PopupThreadRemoveWindow(this);
+ else
+ delete this;
+
+ PostQuitMessage(0);
+ return TRUE;
}
- if (m_PluginWindowProc && !closing)
- {
+ if (m_PluginWindowProc && !closing) {
lock();
// some plugins use cdecl instead of stdcall
@@ -1694,100 +1564,6 @@ LRESULT CALLBACK PopupWnd2::WindowProc(UINT message, WPARAM wParam, LPARAM lPara
BOOL result;
result = m_PluginWindowProc(this->m_hwnd, message, wParam, lParam);
-/*
- DWORD esp_in, esp_out, esp_fixed;
- __asm
- {
- push ecx
- mov [esp_in], esp
- push [lParam]
- push [wParam]
- push [message]
- mov ecx, [this]
- push [ecx+hwnd]
- call [ecx+PluginWindowProc]
- mov [result], eax
- mov [esp_out], esp
- cmp esp, [esp_in] ; check it
- jz lbl_stack_fix_end
- pop ecx ; fix stack
- pop ecx
- pop ecx
- pop ecx
-lbl_stack_fix_end: ; end of stack fix hack
- mov [esp_fixed], esp
- pop ecx
- }
-
-#ifndef POPUP_NO_STACK_WARNING
- if (esp_in != esp_out)
- {
- HANDLE hBadModule = 0;
- char szBadModule[64] = {0};
-
- // plugin enumeration from the core
- char exe[MAX_PATH];
- char search[MAX_PATH];
- char *p = 0;
- // get miranda's exe path
- GetModuleFileNameA(NULL, exe, SIZEOF(exe));
- // find the last \ and null it out, this leaves no trailing slash
- p = strrchr(exe, '\\');
- if ( p ) *p=0;
- // create the search filter
- mir_snprintf(search,SIZEOF(search),"%s\\Plugins\\*.dll", exe);
- {
- // FFFN will return filenames for things like dot dll+ or dot dllx
- HANDLE hFind=INVALID_HANDLE_VALUE;
- WIN32_FIND_DATAA ffd;
- hFind = FindFirstFileA(search, &ffd);
- if ( hFind != INVALID_HANDLE_VALUE )
- {
- do
- {
- if ( !(ffd.dwFileAttributes&FILE_ATTRIBUTE_DIRECTORY))
- {
- HMODULE hModule = GetModuleHandleA(ffd.cFileName);
- if (((char *)PluginWindowProc > (char *)hModule) &&
- (((char *)PluginWindowProc - (char *)hModule) < ((char *)PluginWindowProc - (char *)hBadModule)))
- {
- hBadModule = hModule;
- lstrcpynA(szBadModule, ffd.cFileName, sizeof(szBadModule));
- }
- }
- } while ( FindNextFileA(hFind, &ffd));
- FindClose(hFind);
- }
- }
-
-#ifdef POPUP_STACK_WARNING_MSGBOX
- char buf[256];
- mir_snprintf(buf, sizeof(buf),
- "Some plugin passed callback with invalid calling\r\n"
- "convention and caused stack corruption\r\n"
- "Module name: %s\r\n"
- "PluginWindowProc: %x\r\n"
- "ESP Before: %d\r\n"
- "ESP After: %d\r\n"
- "ESP Fixed: %d",
- szBadModule,
- PluginWindowProc,
- esp_in, esp_out, esp_fixed);
-
- MessageBox(NULL, buf, _T("Popup Plus stack check"), MB_ICONSTOP|MB_OK);
-#else
- strcat(exe, "\\popup_stack.log");
- FILE *f = fopen(exe,"a");
- fprintf(f,
- "Module name: %s; PluginWindowProc: 0x%x; ESP Before: %d; ESP After: %d; ESP Fixed: %d\n",
- szBadModule,
- PluginWindowProc,
- esp_in, esp_out, esp_fixed);
- fclose(f);
-#endif // _DEBUG
- }
-#endif // POPUP_NO_STACK_WARNING
-*/
unlock();
return result;
}
@@ -1798,15 +1574,13 @@ lbl_stack_fix_end: ; end of stack fix hack
LRESULT CALLBACK PopupWnd2::WindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
PopupWnd2 *wnd = 0;
- if (message == WM_CREATE)
- {
+ if (message == WM_CREATE) {
LPCREATESTRUCT cs = (LPCREATESTRUCT)lParam;
wnd = (PopupWnd2 *)cs->lpCreateParams;
SetWindowLongPtr(hwnd, GWLP_USERDATA, (LONG_PTR)wnd);
- } else
- {
- wnd = (PopupWnd2 *)GetWindowLongPtr(hwnd, GWLP_USERDATA);
}
+ else wnd = (PopupWnd2 *)GetWindowLongPtr(hwnd, GWLP_USERDATA);
+
if (wnd) return wnd->WindowProc(message, wParam, lParam);
return DefWindowProc(hwnd, message, wParam, lParam);
}
diff --git a/plugins/Popup/src/popup_wnd2.h b/plugins/Popup/src/popup_wnd2.h
index 8c5fd963e3..8716ca75ff 100644
--- a/plugins/Popup/src/popup_wnd2.h
+++ b/plugins/Popup/src/popup_wnd2.h
@@ -39,7 +39,7 @@ class PopupAvatar;
#define POPUP_OBJECT_SIGNARURE 0x0B1A11BE
-class PopupWnd2
+class PopupWnd2 : public MZeroedObject
{
public:
typedef LRESULT (PopupWnd2::*MethodPtr)(LPARAM lParam);
@@ -62,70 +62,63 @@ private:
int m_iTimeout;
// content
- TextType m_textType;
- char *m_lpzTitle, *m_lpzText;
- WCHAR *m_lpwzTitle, *m_lpwzText;
- HANDLE m_mtTitle, m_mtText;
- bool m_bTextEmpty;
- HFONT m_hfnTitle, m_hfnText;
- HICON m_hIcon;
- HBITMAP m_hbmAvatar;
- char m_time[2+1+2+1];
- ActionInfo* m_actions;
- int m_actionCount;
- HANDLE m_hNotification;
+ TextType m_textType;
+ char *m_lpzTitle, *m_lpzText;
+ WCHAR *m_lpwzTitle, *m_lpwzText;
+ HANDLE m_mtTitle, m_mtText;
+ bool m_bTextEmpty, m_bIcoLib;
+ HFONT m_hfnTitle, m_hfnText;
+ HICON m_hIcon;
+ HBITMAP m_hbmAvatar;
+ char m_time[2+1+2+1];
+ ActionInfo* m_actions;
+ int m_actionCount;
+ HANDLE m_hNotification;
// other data
- Formula::Args m_args;
- HANDLE m_hContact, m_hContactPassed;
- WNDPROC m_PluginWindowProc;
- void *m_PluginData;
+ Formula::Args m_args;
+ HANDLE m_hContact, m_hContactPassed;
+ WNDPROC m_PluginWindowProc;
+ void *m_PluginData;
// the window
- LPTSTR m_lpzSkin;
- bool m_customPopup;
- HWND m_hwnd, m_hwndToolTip;
- bool m_bPositioned;
- POINT m_pos;
- SIZE m_sz;
- MyBitmap *m_bmpBase, *m_bmp, *m_bmpAnimate;
- PopupAvatar *m_avatar;
- int m_avatarFrameDelay;
- bool m_bReshapeWindow;
- HANDLE m_hhkAvatarChanged;
- bool m_bIsPinned;
+ LPTSTR m_lpzSkin;
+ bool m_customPopup;
+ HWND m_hwnd, m_hwndToolTip;
+ bool m_bPositioned;
+ POINT m_pos;
+ SIZE m_sz;
+ MyBitmap *m_bmpBase, *m_bmp, *m_bmpAnimate;
+ PopupAvatar*m_avatar;
+ int m_avatarFrameDelay;
+ bool m_bReshapeWindow;
+ HANDLE m_hhkAvatarChanged;
+ bool m_bIsPinned;
// show & hide
-// bool m_bIdleRequested;
- bool m_bFade;
-// DWORD m_dwTmFade0, m_dwTmFade1;
- BYTE m_btAlpha0, m_btAlpha1;
- bool m_bSlide;
-// DWORD m_dwTmSlide0, m_dwTmSlide1;
- POINT m_ptPosition0, m_ptPosition1;
- bool m_bDestroy;
- bool m_bIsHovered;
+ bool m_bFade;
+ BYTE m_btAlpha0, m_btAlpha1;
+ bool m_bSlide;
+ POINT m_ptPosition0, m_ptPosition1;
+ bool m_bDestroy;
+ bool m_bIsHovered;
// prevent unwanted clicks
- POINT m_ptPrevCursor;
+ POINT m_ptPrevCursor;
// system
- POPUPOPTIONS *m_options;
- DWORD m_lockCount;
+ POPUPOPTIONS *m_options;
+ DWORD m_lockCount;
PopupSkin::RenderInfo m_renderInfo;
- void fixDefaults();
- void fixAvatar();
- int fixActions(POPUPACTION *theActions, int count);
- int fixActions(POPUPACTION *theActions, int count, int additional);
+ void fixDefaults();
+ void fixAvatar();
+ int fixActions(POPUPACTION *theActions, int count);
+ int fixActions(POPUPACTION *theActions, int count, int additional);
public:
-// PopupWnd2(POPUPDATA *ppd, POPUPOPTIONS *theCustomOptions=NULL, bool renderOnly=false);
-// PopupWnd2(POPUPDATAEX_V2 *ppd, POPUPOPTIONS *theCustomOptions=NULL, bool renderOnly=false);
-// PopupWnd2(POPUPDATAW_V2 *ppd, POPUPOPTIONS *theCustomOptions=NULL, bool renderOnly=false);
PopupWnd2(POPUPDATA2 *ppd, POPUPOPTIONS *theCustomOptions=NULL, bool renderOnly=false);
-// PopupWnd2(HANDLE hNtf, POPUPOPTIONS *theCustomOptions=NULL, bool renderOnly=false);
~PopupWnd2();
void startThread();
@@ -144,11 +137,12 @@ public:
DWORD unlock() { return m_lockCount = m_lockCount ? m_lockCount-1 : 0; }
bool isLocked() { return m_lockCount != 0; }
+ void setIcon(HICON);
+
void updateData(POPUPDATA *ppd);
void updateData(POPUPDATAEX_V2 *ppd);
void updateData(POPUPDATAW_V2 *ppd);
void updateData(POPUPDATA2 *ppd);
-// void updateData(HANDLE hNtf);
void buildMText();
void updateText(char *text);
void updateText(WCHAR *text);
@@ -157,40 +151,42 @@ public:
void updateTimer();
- MyBitmap *getContent() { return m_bmp; }
-
- COLORREF getTextColor() { return m_clText; }
- COLORREF getTitleColor() { return m_clTitle; }
- COLORREF getClockColor() { return m_clClock; }
- COLORREF getBackColor() { return m_clBack; }
-
- bool isTextEmpty() { return m_bTextEmpty; }
- TextType getTextType() { return m_textType; }
- char *getTextA() { return m_lpzText; }
- WCHAR *getTextW() { return m_lpwzText; }
- HANDLE getTextM() { return m_mtText; }
- char *getTitleA() { return m_lpzTitle; }
- WCHAR *getTitleW() { return m_lpwzTitle; }
- HANDLE getTitleM() { return m_mtTitle; }
-
- int getActionCount() { return m_actionCount; }
- ActionInfo *getActions() { return m_actions; }
-
- char *getTime() { return m_time; }
- HICON getIcon() { return m_hIcon; }
- HANDLE getContact() { return m_hContact; }
- HANDLE getContactPassed() { return m_hContactPassed; }
- int getTimeout() { return m_iTimeout; }
-// HBITMAP getAvatar() { return hbmAvatar; }
- PopupAvatar *getAvatar() { return m_avatar; }
- HWND getHwnd() { return m_hwnd; }
- void *getData() { return m_PluginData; }
-
- Formula::Args *getArgs() { return &m_args; }
- PopupSkin::RenderInfo *getRenderInfo() { return &m_renderInfo; }
-
- SIZE getSize() { return m_sz; }
- void setSize(SIZE sz)
+ MyBitmap *getContent() { return m_bmp; }
+
+ COLORREF getTextColor() { return m_clText; }
+ COLORREF getTitleColor() { return m_clTitle; }
+ COLORREF getClockColor() { return m_clClock; }
+ COLORREF getBackColor() { return m_clBack; }
+
+ bool isTextEmpty() { return m_bTextEmpty; }
+ bool isIcolib() { return m_bIcoLib; }
+ TextType getTextType() { return m_textType; }
+ char *getTextA() { return m_lpzText; }
+ WCHAR *getTextW() { return m_lpwzText; }
+ HANDLE getTextM() { return m_mtText; }
+ char *getTitleA() { return m_lpzTitle; }
+ WCHAR *getTitleW() { return m_lpwzTitle; }
+ HANDLE getTitleM() { return m_mtTitle; }
+
+ int getActionCount() { return m_actionCount; }
+ ActionInfo *getActions() { return m_actions; }
+
+ char *getTime() { return m_time; }
+ HICON getIcon() { return m_hIcon; }
+ HANDLE getContact() { return m_hContact; }
+ HANDLE getContactPassed() { return m_hContactPassed; }
+ int getTimeout() { return m_iTimeout; }
+ HWND getHwnd() { return m_hwnd; }
+ void *getData() { return m_PluginData; }
+
+ PopupAvatar *getAvatar() { return m_avatar; }
+
+ Formula::Args *getArgs() { return &m_args; }
+
+ PopupSkin::RenderInfo *getRenderInfo() { return &m_renderInfo; }
+
+ SIZE getSize() { return m_sz; }
+ void setSize(SIZE sz)
{
this->m_sz = sz;
if (m_hwnd)
@@ -200,20 +196,17 @@ public:
PopupThreadUpdateWindow(this);
}
}
- bool isPositioned() { return m_bPositioned; }
- POINT getPosition() { return m_pos; }
- POINT getRealPosition() { return POINT(); }
+ bool isPositioned() { return m_bPositioned; }
+ POINT getPosition() { return m_pos; }
+ POINT getRealPosition() { return POINT(); }
void setPosition(POINT pt)
{
m_bPositioned = true;
m_pos = pt;
if (m_bSlide)
- {
m_ptPosition1 = pt;
- } else
- {
+ else
SetWindowPos(m_hwnd, 0, pt.x, pt.y, 0, 0, SWP_NOZORDER|SWP_NOSIZE|SWP_NOACTIVATE|SWP_DEFERERASE|SWP_NOSENDCHANGING);
- }
}
// Thread-related methods
@@ -236,7 +229,6 @@ public:
LRESULT m_updateData_POPUPDATAEX_V2(LPARAM arg) { updateData((POPUPDATAEX_V2 *)arg); update(); return 0; }
LRESULT m_updateData_POPUPDATAW_V2(LPARAM arg) { updateData((POPUPDATAW_V2 *)arg); update(); return 0; }
LRESULT m_updateData_POPUPDATA2(LPARAM arg) { updateData((POPUPDATA2 *)arg); update(); return 0; }
-// LRESULT m_updateData_HNOTIFY(LPARAM arg) { updateData((HANDLE)arg); update(); return 0; }
LRESULT m_updateText(LPARAM arg) { updateText((char *)arg); update(); return 0; }
LRESULT m_updateTextW(LPARAM arg) { updateText((WCHAR *)arg); update(); return 0; }
LRESULT m_updateTitle(LPARAM arg) { updateTitle((char *)arg); update(); return 0; }
diff --git a/plugins/WhenWasIt/src/notifiers.cpp b/plugins/WhenWasIt/src/notifiers.cpp
index f05ae5f1eb..6921a19619 100644
--- a/plugins/WhenWasIt/src/notifiers.cpp
+++ b/plugins/WhenWasIt/src/notifiers.cpp
@@ -87,7 +87,7 @@ int PopupNotifyBirthday(HANDLE hContact, int dtb, int age)
POPUPDATAT pd = {0};
FillPopupData(pd, dtb);
pd.lchContact = hContact;
- pd.PluginWindowProc = (WNDPROC) DlgProcPopup;
+ pd.PluginWindowProc = (WNDPROC)DlgProcPopup;
pd.lchIcon = GetDTBIcon(dtb);
_stprintf(pd.lptzContactName, TranslateT("Birthday - %s"), name);
@@ -109,9 +109,9 @@ int PopupNotifyBirthday(HANDLE hContact, int dtb, int age)
_stprintf(pd.lptzText, TranslateT("%s\n%s just turned %d."), text, sex, age);
PUAddPopUpT(&pd);
+
Skin_ReleaseIcon(pd.lchIcon);
free(name);
-
return 0;
}
@@ -132,7 +132,7 @@ int PopupNotifyMissedBirthday(HANDLE hContact, int dab, int age)
POPUPDATAT pd = {0};
FillPopupData(pd, dab);
pd.lchContact = hContact;
- pd.PluginWindowProc = (WNDPROC) DlgProcPopup;
+ pd.PluginWindowProc = (WNDPROC)DlgProcPopup;
pd.lchIcon = GetDTBIcon(dab);
_stprintf(pd.lptzContactName, TranslateT("Birthday - %s"), name);
diff --git a/plugins/WhenWasIt/src/notifiers.h b/plugins/WhenWasIt/src/notifiers.h
index 62f6dd4b4e..344774ce02 100644
--- a/plugins/WhenWasIt/src/notifiers.h
+++ b/plugins/WhenWasIt/src/notifiers.h
@@ -21,11 +21,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#ifndef M_WWI_NOTIFIERS_H
#define M_WWI_NOTIFIERS_H
-
-#define POPUPDATAT POPUPDATAW
-#define PUAddPopUpT PUAddPopUpW
-
-
#define BIRTHDAY_TODAY_SOUND "WWIBirthdayToday"
#define BIRTHDAY_NEAR_SOUND "WWIBirthdayNear"
diff --git a/plugins/YAPP/src/common.h b/plugins/YAPP/src/common.h
index 1b2a52b74b..e8aa204340 100644
--- a/plugins/YAPP/src/common.h
+++ b/plugins/YAPP/src/common.h
@@ -51,6 +51,7 @@
#include <m_fontservice.h>
#include <m_avatars.h>
#include <m_popup.h>
+#include <m_icolib.h>
#include <win2k.h>
#include <m_notify.h>
@@ -79,7 +80,8 @@ typedef int (CALLBACK *PFNLVCOMPARE)(LPARAM, LPARAM, LPARAM);
#endif
-typedef struct {
+struct PopupData
+{
int cbSize;
int flags; // OR of PDF_* flags below
HANDLE hContact;
@@ -99,11 +101,14 @@ typedef struct {
WNDPROC windowProc; // optional custom window procedure
int timeout; // -1 == infinite, 0 == default, otherwise timeout in seconds
void *opaque;
-} PopupData;
-#define PDF_UNICODE 0x0001
+ void SetIcon(HICON);
+};
-#define PDF_TCHAR PDF_UNICODE
+#define PDF_UNICODE 0x0001
+#define PDF_ICOLIB 0x0002
+
+#define PDF_TCHAR PDF_UNICODE
// windowProc messages
#define PM_INIT (WM_USER + 0x0202) // message sent to your windowProc after the window has been initialized
diff --git a/plugins/YAPP/src/popwin.cpp b/plugins/YAPP/src/popwin.cpp
index 59178f328f..a24178f16e 100644
--- a/plugins/YAPP/src/popwin.cpp
+++ b/plugins/YAPP/src/popwin.cpp
@@ -151,7 +151,8 @@ void BroadcastMessage(UINT msg, WPARAM wParam, LPARAM lParam) {
}
}
-struct PopupWindowData {
+struct PopupWindowData
+{
PopupData *pd;
int new_x, new_y;
bool is_round, av_is_round, mouse_in, close_on_leave;
@@ -165,582 +166,534 @@ struct PopupWindowData {
HANDLE hNotify;
};
-LRESULT CALLBACK PopupWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {
+LRESULT CALLBACK PopupWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
+{
PopupWindowData *pwd = (PopupWindowData *)GetWindowLongPtr(hwnd, GWLP_USERDATA);
PopupData *pd = 0;
if (pwd) pd = pwd->pd;
switch(uMsg) {
- case WM_CREATE:
- {
- CREATESTRUCT *cs = (CREATESTRUCT *)lParam;
- pwd = (PopupWindowData *)mir_alloc(sizeof(PopupWindowData));
- pd = (PopupData *)cs->lpCreateParams;
- pwd->pd = pd;
- pwd->hNotify = 0;
-
- trimW(pwd->pd->pwzTitle);
- trimW(pwd->pd->pwzText);
-
- pwd->is_round = options.round;
- pwd->av_is_round = options.av_round;
- pwd->mouse_in = pwd->close_on_leave = false;
- pwd->custom_col = (pd->colorBack != pd->colorText);
-
- pwd->tb_height = pwd->av_height = pwd->text_height = pwd->time_height = pwd->time_width = 0;
- pwd->have_av = false;
-
- if (pwd->custom_col) {
- pwd->bkBrush = CreateSolidBrush(pd->colorBack);
-
- //pwd->barBrush = CreateSolidBrush(pd->colorBack / 2); // make sidebar a dark version of the bg
- //DWORD darkBg = (((pd->colorBack & 0xff0000) >> 1) & 0xff0000) + (((pd->colorBack & 0xff00) >> 1) & 0xff00) + (((pd->colorBack & 0xff) >> 1) & 0xff);
- //DWORD darkBg = (pdColorBack >> 1) & 0x7f7f7f; // equivalent to above :)
-
- DWORD darkBg = pd->colorBack - ((pd->colorBack >> 2) & 0x3f3f3f); // 3/4 of current individual RGB components
- pwd->barBrush = CreateSolidBrush(darkBg); // make sidebar a dark version of the bg
- pwd->underlineBrush = CreateSolidBrush(pd->colorBack); // make sidebar a dark version of the bg
- } else {
- pwd->bkBrush = CreateSolidBrush(colBg);
- pwd->barBrush = CreateSolidBrush(colSidebar);
- pwd->underlineBrush = CreateSolidBrush(colTitleUnderline);
- }
+ case WM_CREATE:
+ {
+ CREATESTRUCT *cs = (CREATESTRUCT *)lParam;
+ pwd = (PopupWindowData *)mir_alloc(sizeof(PopupWindowData));
+ pd = (PopupData *)cs->lpCreateParams;
+ pwd->pd = pd;
+ pwd->hNotify = 0;
+
+ trimW(pwd->pd->pwzTitle);
+ trimW(pwd->pd->pwzText);
+
+ pwd->is_round = options.round;
+ pwd->av_is_round = options.av_round;
+ pwd->mouse_in = pwd->close_on_leave = false;
+ pwd->custom_col = (pd->colorBack != pd->colorText);
+
+ pwd->tb_height = pwd->av_height = pwd->text_height = pwd->time_height = pwd->time_width = 0;
+ pwd->have_av = false;
+
+ if (pwd->custom_col) {
+ pwd->bkBrush = CreateSolidBrush(pd->colorBack);
+ DWORD darkBg = pd->colorBack - ((pd->colorBack >> 2) & 0x3f3f3f); // 3/4 of current individual RGB components
+ pwd->barBrush = CreateSolidBrush(darkBg); // make sidebar a dark version of the bg
+ pwd->underlineBrush = CreateSolidBrush(pd->colorBack); // make sidebar a dark version of the bg
+ }
+ else {
+ pwd->bkBrush = CreateSolidBrush(colBg);
+ pwd->barBrush = CreateSolidBrush(colSidebar);
+ pwd->underlineBrush = CreateSolidBrush(colTitleUnderline);
+ }
+
+ if (options.border) pwd->bPen = (HPEN)CreatePen(PS_SOLID, 1, colBorder);
+ else pwd->bPen = CreatePen(PS_SOLID, 1, pwd->custom_col ? pd->colorBack : colBg);
- 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;
- GetLocalTime(&st);
- GetTimeFormat(LOCALE_USER_DEFAULT, TIME_NOSECONDS, &st, 0, pwd->tbuff, 128);
+ SYSTEMTIME st;
+ GetLocalTime(&st);
+ GetTimeFormat(LOCALE_USER_DEFAULT, TIME_NOSECONDS, &st, 0, pwd->tbuff, 128);
- SetWindowLongPtr(hwnd, GWLP_USERDATA, (LONG_PTR)pwd);
+ SetWindowLongPtr(hwnd, GWLP_USERDATA, (LONG_PTR)pwd);
- if (pd->timeout == -1 || (pd->timeout == 0 && options.default_timeout == -1)) {
- // make a really long timeout - say 7 days? ;)
- SetTimer(hwnd, ID_CLOSETIMER, 7 * 24 * 60 * 60 * 1000, 0);
+ if (pd->timeout == -1 || (pd->timeout == 0 && options.default_timeout == -1)) {
+ // make a really long timeout - say 7 days? ;)
+ SetTimer(hwnd, ID_CLOSETIMER, 7 * 24 * 60 * 60 * 1000, 0);
+ } else {
+ if (pd->timeout == 0) {
+ SetTimer(hwnd, ID_CLOSETIMER, options.default_timeout * 1000, 0);
} else {
- if (pd->timeout == 0) {
- SetTimer(hwnd, ID_CLOSETIMER, options.default_timeout * 1000, 0);
- } else {
- SetTimer(hwnd, ID_CLOSETIMER, pd->timeout * 1000, 0);
- }
+ SetTimer(hwnd, ID_CLOSETIMER, pd->timeout * 1000, 0);
}
-
- AddWindowToStack(hwnd); // this updates our size
}
- // transparency
+ AddWindowToStack(hwnd); // this updates our size
+ }
+
+ // transparency
#ifdef WS_EX_LAYERED
- SetWindowLongPtr(hwnd, GWL_EXSTYLE, GetWindowLongPtr(hwnd, GWL_EXSTYLE) | WS_EX_LAYERED);
+ SetWindowLongPtr(hwnd, GWL_EXSTYLE, GetWindowLongPtr(hwnd, GWL_EXSTYLE) | WS_EX_LAYERED);
#endif
#ifdef CS_DROPSHADOW
- if (options.drop_shadow) {
- SetClassLong(hwnd, GCL_STYLE, CS_DROPSHADOW);
- }
+ if (options.drop_shadow) {
+ SetClassLong(hwnd, GCL_STYLE, CS_DROPSHADOW);
+ }
#endif
#ifdef LWA_ALPHA
- if (MySetLayeredWindowAttributes) {
- MySetLayeredWindowAttributes(hwnd, RGB(0,0,0), (int)(options.opacity / 100.0 * 255), LWA_ALPHA);
- if (options.trans_bg) {
- COLORREF bg;
- if (pd->colorBack == pd->colorText)
- bg = colBg;
- else
- bg = pd->colorBack;
- MySetLayeredWindowAttributes(hwnd, bg, 0, LWA_COLORKEY);
- }
+ if (MySetLayeredWindowAttributes) {
+ MySetLayeredWindowAttributes(hwnd, RGB(0,0,0), (int)(options.opacity / 100.0 * 255), LWA_ALPHA);
+ if (options.trans_bg) {
+ COLORREF bg;
+ if (pd->colorBack == pd->colorText)
+ bg = colBg;
+ else
+ bg = pd->colorBack;
+ MySetLayeredWindowAttributes(hwnd, bg, 0, LWA_COLORKEY);
}
+ }
#endif
- PostMessage(hwnd, PM_INIT, (WPARAM)hwnd, 0);
- return 0;
- case WM_MOUSEMOVE:
- if (pwd && !pwd->mouse_in) {
- pwd->mouse_in = true;
- global_mouse_in++;
- TRACKMOUSEEVENT tme = { sizeof(tme) };
- tme.dwFlags = TME_LEAVE;
- tme.hwndTrack = hwnd;
- TrackMouseEvent(&tme);
- }
- break;
- case WM_MOUSELEAVE:
- if (pwd && pwd->mouse_in) {
- pwd->mouse_in = false;
- global_mouse_in--;
+ PostMessage(hwnd, PM_INIT, (WPARAM)hwnd, 0);
+ return 0;
+ case WM_MOUSEMOVE:
+ if (pwd && !pwd->mouse_in) {
+ pwd->mouse_in = true;
+ global_mouse_in++;
+ TRACKMOUSEEVENT tme = { sizeof(tme) };
+ tme.dwFlags = TME_LEAVE;
+ tme.hwndTrack = hwnd;
+ TrackMouseEvent(&tme);
+ }
+ break;
+ case WM_MOUSELEAVE:
+ if (pwd && pwd->mouse_in) {
+ pwd->mouse_in = false;
+ global_mouse_in--;
+ }
+ return 0;
+ case WM_LBUTTONUP:
+ // fake STN_CLICKED notification
+ SendMessage(hwnd, WM_COMMAND, MAKEWPARAM(0, STN_CLICKED), 0);
+ break;
+ case WM_TIMER:
+ if (wParam == ID_CLOSETIMER) {
+ KillTimer(hwnd, ID_CLOSETIMER);
+ if (pwd->mouse_in || (options.global_hover && global_mouse_in))
+ SetTimer(hwnd, ID_CLOSETIMER, 800, 0); // reset timer if mouse in window - allow another 800 ms
+ else {
+ PostMessage(hwnd, PM_DESTROY, 0, 0);
}
- return 0;
- case WM_LBUTTONUP:
- // fake STN_CLICKED notification
- SendMessage(hwnd, WM_COMMAND, MAKEWPARAM(0, STN_CLICKED), 0);
- break;
- case WM_TIMER:
- if (wParam == ID_CLOSETIMER) {
- KillTimer(hwnd, ID_CLOSETIMER);
- if (pwd->mouse_in || (options.global_hover && global_mouse_in))
- SetTimer(hwnd, ID_CLOSETIMER, 800, 0); // reset timer if mouse in window - allow another 800 ms
- else {
- PostMessage(hwnd, PM_DESTROY, 0, 0);
- }
+ return TRUE;
+ } else if (wParam == ID_MOVETIMER) {
+ RECT r;
+ GetWindowRect(hwnd, &r);
+
+ if (r.left == pwd->new_x && r.top == pwd->new_y) {
+ KillTimer(hwnd, ID_MOVETIMER);
return TRUE;
- } else if (wParam == ID_MOVETIMER) {
- RECT r;
- GetWindowRect(hwnd, &r);
-
- 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);
-
- int x = r.left + adj_x, y = r.top + adj_y;
- //SetWindowPos(hwnd, 0, x, y, 0, 0, SWP_NOZORDER | SWP_NOSIZE | SWP_NOACTIVATE | SWP_NOREDRAW | SWP_NOCOPYBITS);
- SetWindowPos(hwnd, 0, x, y, 0, 0, SWP_NOZORDER | SWP_NOSIZE | SWP_NOACTIVATE);
-
-
- /*
- // clip to monitor bounds (paints badly!)
- //HDC hdc = GetDC(hwnd);
- HMONITOR hMonitor = MonitorFromRect(&r, MONITOR_DEFAULTTONEAREST);
- MONITORINFO mi;
- mi.cbSize = sizeof(mi);
- GetMonitorInfo(hMonitor, &mi);
-
- POINT p[2];
- p[0].x = mi.rcWork.left; p[0].y = mi.rcWork.top; p[1].x = mi.rcWork.right; p[1].y = mi.rcWork.bottom;
- //LPtoDP(hdc, p, 2);
- ScreenToClient(hwnd, &p[0]); ScreenToClient(hwnd, &p[1]);
-
- HRGN hMonRgn = CreateRectRgn(p[0].x, p[0].y, p[1].x, p[1].y);
- //ReleaseDC(hwnd, hdc);
-
- RECT cr; GetClientRect(hwnd, &cr);
- HRGN hWndRgn = CreateRectRgn(cr.left, cr.top, cr.right + 3, cr.bottom + 3);
- CombineRgn(hMonRgn, hMonRgn, hWndRgn, RGN_AND);
-
- // round corners
+ }
+ 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);
+
+ int x = r.left + adj_x, y = r.top + adj_y;
+ SetWindowPos(hwnd, 0, x, y, 0, 0, SWP_NOZORDER | SWP_NOSIZE | SWP_NOACTIVATE);
+
+ if (!IsWindowVisible(hwnd)) {
+ ShowWindow(hwnd, SW_SHOWNOACTIVATE);
+ UpdateWindow(hwnd);
+ }
+ return TRUE;
+ }
+ break;
+ case WM_ERASEBKGND:
+ {
+ HDC hdc = (HDC) wParam;
+ RECT r, r_bar;
+ GetClientRect(hwnd, &r);
+
+ // bg
+ FillRect(hdc, &r, pwd->bkBrush);
+ // sidebar
+ r_bar = r;
+ r_bar.right = r.left + options.sb_width;
+ FillRect(hdc, &r_bar, pwd->barBrush);
+ // border
+ if (options.border) {
+
+ HBRUSH hOldBrush = (HBRUSH)SelectObject(hdc, GetStockObject(NULL_BRUSH));
+ HPEN hOldPen = (HPEN)SelectObject(hdc, pwd->bPen);
+
+ int h = 0;
if (options.round) {
- HRGN hRgn1;
- int v,h, w=10;
+ 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;
- hRgn1=CreateRoundRectRgn(0,0,(r.right-r.left+1),(r.bottom-r.top+1),h,h);
- CombineRgn(hMonRgn, hMonRgn, hRgn1, RGN_AND);
- DeleteObject(hRgn1);
}
+ RoundRect(hdc, 0, 0, (r.right - r.left), (r.bottom - r.top), h, h);
- SetWindowRgn(hwnd, hMonRgn, TRUE);
+ SelectObject(hdc, hOldBrush);
+ SelectObject(hdc, hOldPen);
+ }
- DeleteObject(hWndRgn);
-
- InvalidateRect(hwnd, 0, TRUE);
- */
+ }
+ return TRUE;
+ case WM_PAINT:
+ {
+ RECT r;
+ PAINTSTRUCT ps;
+ BeginPaint(hwnd, &ps);
+ HDC hdc = ps.hdc;
+ GetClientRect(hwnd, &r);
+
+ SetBkMode(hdc, TRANSPARENT);
+
+ // avatar & time if with avatar
+ if (options.av_layout != PAV_NONE && (pwd->have_av || options.time_layout == PT_WITHAV)) {
+ RECT avr;
+ avr.top = options.av_padding;
+
+ if (options.av_layout == PAV_LEFT) {
+ avr.left = r.left + options.av_padding;
+ if (pwd->have_av && options.time_layout == PT_WITHAV) avr.right = avr.left + max(pwd->real_av_width, pwd->time_width);
+ else if (pwd->have_av) avr.right = avr.left + pwd->real_av_width;
+ else avr.right = avr.left + pwd->time_width;
+ r.left = avr.right;
+ } else if (options.av_layout == PAV_RIGHT) {
+ avr.right = r.right - options.av_padding;
+ if (pwd->have_av && options.time_layout == PT_WITHAV) avr.left = avr.right - max(pwd->real_av_width, pwd->time_width);
+ else if (pwd->have_av) avr.left = avr.right - pwd->real_av_width;
+ else avr.left = avr.right - pwd->time_width;
+ r.right = avr.left;
+ }
- if (!IsWindowVisible(hwnd)) {
- ShowWindow(hwnd, SW_SHOWNOACTIVATE);
- UpdateWindow(hwnd);
+ if (options.time_layout == PT_WITHAV) {
+ avr.top = options.padding;
+ avr.bottom = avr.top + pwd->time_height;
+ if (pwd->custom_col) SetTextColor(ps.hdc, pd->colorText);
+ else SetTextColor(ps.hdc, colTime);
+ if (hFontTime) SelectObject(hdc, (HGDIOBJ)hFontTime);
+ DrawText(ps.hdc, pwd->tbuff, (int)_tcslen(pwd->tbuff), &avr, DT_VCENTER | DT_CENTER | DT_LEFT | DT_SINGLELINE | DT_NOPREFIX);
+ avr.top = avr.bottom + options.av_padding;
}
- return TRUE;
- }
- break;
- case WM_ERASEBKGND:
- {
- HDC hdc = (HDC) wParam;
- RECT r, r_bar;
- GetClientRect(hwnd, &r);
-
- // bg
- FillRect(hdc, &r, pwd->bkBrush);
- // sidebar
- r_bar = r;
- r_bar.right = r.left + options.sb_width;
- FillRect(hdc, &r_bar, pwd->barBrush);
- // border
- if (options.border) {
-
- HBRUSH hOldBrush = (HBRUSH)SelectObject(hdc, GetStockObject(NULL_BRUSH));
- HPEN hOldPen = (HPEN)SelectObject(hdc, pwd->bPen);
-
- 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;
- //} else {
- // Rectangle(hdc, r.left, r.top, (r.right - r.left), (r.bottom - r.top));
+
+ if (pwd->have_av) {
+ // correct for wider time
+ if (options.time_layout == PT_WITHAV && pwd->time_width > options.av_size) {
+ avr.left = avr.left + (pwd->time_width - pwd->real_av_width) / 2;
+ avr.right = avr.left + pwd->real_av_width;
}
- RoundRect(hdc, 0, 0, (r.right - r.left), (r.bottom - r.top), h, h);
+ avr.bottom = avr.top + pwd->real_av_height;
- SelectObject(hdc, hOldBrush);
- SelectObject(hdc, hOldPen);
+ AVATARDRAWREQUEST adr = {0};
+ adr.cbSize = sizeof(adr);
+ adr.hContact = pd->hContact;
+ adr.hTargetDC = ps.hdc;
+ adr.rcDraw = avr;
+ adr.dwFlags = (pwd->av_is_round ? AVDRQ_ROUNDEDCORNER : 0);
+ adr.radius = 5; //(pwd->av_is_round ? 5 : 0);
+
+ CallService(MS_AV_DRAWAVATAR, 0, (LPARAM)&adr);
}
+ }
+ // title icon
+ int iconx, textxmin = r.left + options.padding, textxmax = r.right - options.padding;
+ if (pd->hIcon) {
+ if (options.right_icon) {
+ iconx = r.right - (16 + options.padding);
+ textxmax -= 16 + options.padding;
+ } else {
+ iconx = r.left + options.padding;
+ textxmin += 16 + options.padding;
+ }
+ DrawIconEx(ps.hdc, iconx, options.padding + (pwd->tb_height - 16) / 2, pd->hIcon, 16, 16, 0, NULL, DI_NORMAL);
}
- return TRUE;
- case WM_PAINT:
- {
- RECT r;
- //if (GetUpdateRect(hwnd, &r, TRUE)) {
- PAINTSTRUCT ps;
- BeginPaint(hwnd, &ps);
- HDC hdc = ps.hdc;
+
+ // title time
+ if (options.time_layout == PT_LEFT || options.time_layout == PT_RIGHT) {
+ RECT ttr;
+ ttr.top = r.top + options.padding; ttr.bottom = ttr.top + pwd->tb_height;
+ if (pwd->custom_col) SetTextColor(ps.hdc, pd->colorText);
+ else SetTextColor(ps.hdc, colTime);
+ if (hFontTime) SelectObject(hdc, (HGDIOBJ)hFontTime);
+ switch(options.time_layout) {
+ case PT_LEFT:
+ ttr.left = textxmin; ttr.right = ttr.left + pwd->time_width;
+ textxmin += pwd->time_width + options.padding;
+ DrawText(ps.hdc, pwd->tbuff, (int)_tcslen(pwd->tbuff), &ttr, DT_VCENTER | DT_LEFT | DT_SINGLELINE | DT_NOPREFIX);
+ break;
+ case PT_RIGHT:
+ ttr.right = textxmax; ttr.left = ttr.right - pwd->time_width;
+ textxmax -= pwd->time_width + options.padding;
+ DrawText(ps.hdc, pwd->tbuff, (int)_tcslen(pwd->tbuff), &ttr, DT_VCENTER | DT_LEFT | DT_SINGLELINE | DT_NOPREFIX);
+ break;
+ default:
+ break;
+ }
+ }
+
+ if (textxmin < options.sb_width) textxmin = options.sb_width + options.padding / 2;
+
+ // title text
+ if (hFontFirstLine) SelectObject(ps.hdc, (HGDIOBJ)hFontFirstLine);
+ RECT tr;
+ tr.left = r.left + options.padding + options.text_indent; tr.right = textxmax; tr.top = r.top + options.padding; tr.bottom = tr.top + pwd->tb_height;
+
+ if (pwd->custom_col) SetTextColor(ps.hdc, pd->colorText);
+ else SetTextColor(ps.hdc, colFirstLine);
+ TCHAR *title = mir_u2t(pd->pwzTitle);
+ DrawText(ps.hdc, title, (int)_tcslen(title), &tr, DT_VCENTER | DT_LEFT | DT_END_ELLIPSIS | DT_SINGLELINE | DT_NOPREFIX);
+ mir_free(title);
+
+ // title underline
+ 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.bottom = tur.top + 1;
+ FillRect(ps.hdc, &tur, pwd->underlineBrush);
+
+ // second line(s)
+ if (pd->pwzText[0]) {
+ if (hFontSecondLine) SelectObject(ps.hdc, (HGDIOBJ)hFontSecondLine);
+ if (!pwd->custom_col)
+ SetTextColor(ps.hdc, colSecondLine);
+
+ // expand text if no avatar and the time isn't too large
+ if (options.av_layout != PAV_NONE && options.time_layout == PT_WITHAV && pwd->time_height <= pwd->tb_height && !pwd->have_av)
GetClientRect(hwnd, &r);
- // text background
- //if (pwd->custom_col) SetBkColor(ps.hdc, pd->colorBack);
- //else SetBkColor(ps.hdc, colBg);
- SetBkMode(hdc, TRANSPARENT);
-
- // avatar & time if with avatar
- if (options.av_layout != PAV_NONE && (pwd->have_av || options.time_layout == PT_WITHAV)) {
- RECT avr;
- avr.top = options.av_padding;
-
- if (options.av_layout == PAV_LEFT) {
- avr.left = r.left + options.av_padding;
- if (pwd->have_av && options.time_layout == PT_WITHAV) avr.right = avr.left + max(pwd->real_av_width, pwd->time_width);
- else if (pwd->have_av) avr.right = avr.left + pwd->real_av_width;
- else avr.right = avr.left + pwd->time_width;
- r.left = avr.right;
- } else if (options.av_layout == PAV_RIGHT) {
- avr.right = r.right - options.av_padding;
- if (pwd->have_av && options.time_layout == PT_WITHAV) avr.left = avr.right - max(pwd->real_av_width, pwd->time_width);
- else if (pwd->have_av) avr.left = avr.right - pwd->real_av_width;
- else avr.left = avr.right - pwd->time_width;
- r.right = avr.left;
- }
-
- if (options.time_layout == PT_WITHAV) {
- avr.top = options.padding;
- avr.bottom = avr.top + pwd->time_height;
- if (pwd->custom_col) SetTextColor(ps.hdc, pd->colorText);
- else SetTextColor(ps.hdc, colTime);
- if (hFontTime) SelectObject(hdc, (HGDIOBJ)hFontTime);
- DrawText(ps.hdc, pwd->tbuff, (int)_tcslen(pwd->tbuff), &avr, DT_VCENTER | DT_CENTER | DT_LEFT | DT_SINGLELINE | DT_NOPREFIX);
- avr.top = avr.bottom + options.av_padding;
- }
-
- if (pwd->have_av) {
- // correct for wider time
- if (options.time_layout == PT_WITHAV && pwd->time_width > options.av_size) {
- avr.left = avr.left + (pwd->time_width - pwd->real_av_width) / 2;
- avr.right = avr.left + pwd->real_av_width;
- }
- avr.bottom = avr.top + pwd->real_av_height;
-
- AVATARDRAWREQUEST adr = {0};
- adr.cbSize = sizeof(adr);
- adr.hContact = pd->hContact;
- adr.hTargetDC = ps.hdc;
- adr.rcDraw = avr;
- adr.dwFlags = (pwd->av_is_round ? AVDRQ_ROUNDEDCORNER : 0);
- adr.radius = 5; //(pwd->av_is_round ? 5 : 0);
-
- CallService(MS_AV_DRAWAVATAR, 0, (LPARAM)&adr);
- }
- }
-
- // title icon
- int iconx, textxmin = r.left + options.padding, textxmax = r.right - options.padding;
- if (pd->hIcon) {
- if (options.right_icon) {
- iconx = r.right - (16 + options.padding);
- textxmax -= 16 + options.padding;
- } else {
- iconx = r.left + options.padding;
- textxmin += 16 + options.padding;
- }
- DrawIconEx(ps.hdc, iconx, options.padding + (pwd->tb_height - 16) / 2, pd->hIcon, 16, 16, 0, NULL, DI_NORMAL);
- }
+ TCHAR *text = mir_u2t(pd->pwzText);
+ 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, (int)_tcslen(text), &tr, DT_NOPREFIX | DT_WORDBREAK | DT_EXTERNALLEADING | DT_TOP | DT_LEFT | DT_WORD_ELLIPSIS);
+ mir_free(text);
+ }
- // title time
- if (options.time_layout == PT_LEFT || options.time_layout == PT_RIGHT) {
- RECT ttr;
- ttr.top = r.top + options.padding; ttr.bottom = ttr.top + pwd->tb_height;
- if (pwd->custom_col) SetTextColor(ps.hdc, pd->colorText);
- else SetTextColor(ps.hdc, colTime);
- if (hFontTime) SelectObject(hdc, (HGDIOBJ)hFontTime);
- switch(options.time_layout) {
- case PT_LEFT:
- ttr.left = textxmin; ttr.right = ttr.left + pwd->time_width;
- textxmin += pwd->time_width + options.padding;
- DrawText(ps.hdc, pwd->tbuff, (int)_tcslen(pwd->tbuff), &ttr, DT_VCENTER | DT_LEFT | DT_SINGLELINE | DT_NOPREFIX);
- break;
- case PT_RIGHT:
- ttr.right = textxmax; ttr.left = ttr.right - pwd->time_width;
- textxmax -= pwd->time_width + options.padding;
- DrawText(ps.hdc, pwd->tbuff, (int)_tcslen(pwd->tbuff), &ttr, DT_VCENTER | DT_LEFT | DT_SINGLELINE | DT_NOPREFIX);
- break;
- default:
- break;
- }
- }
+ EndPaint(hwnd, &ps);
+ }
+ return 0;
- if (textxmin < options.sb_width) textxmin = options.sb_width + options.padding / 2;
+ case WM_DESTROY:
+ if (pwd->mouse_in) global_mouse_in--;
- // title text
- if (hFontFirstLine) SelectObject(ps.hdc, (HGDIOBJ)hFontFirstLine);
- RECT tr;
- tr.left = r.left + options.padding + options.text_indent; tr.right = textxmax; tr.top = r.top + options.padding; tr.bottom = tr.top + pwd->tb_height;
-
- if (pwd->custom_col) SetTextColor(ps.hdc, pd->colorText);
- else SetTextColor(ps.hdc, colFirstLine);
- TCHAR *title = mir_u2t(pd->pwzTitle);
- DrawText(ps.hdc, title, (int)_tcslen(title), &tr, DT_VCENTER | DT_LEFT | DT_END_ELLIPSIS | DT_SINGLELINE | DT_NOPREFIX);
- mir_free(title);
-
- // title underline
- 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.bottom = tur.top + 1;
- FillRect(ps.hdc, &tur, pwd->underlineBrush);
-
- // second line(s)
- if (pd->pwzText[0]) {
- if (hFontSecondLine) SelectObject(ps.hdc, (HGDIOBJ)hFontSecondLine);
- if (!pwd->custom_col)
- SetTextColor(ps.hdc, colSecondLine);
-
- // expand text if no avatar and the time isn't too large
- if (options.av_layout != PAV_NONE && options.time_layout == PT_WITHAV && pwd->time_height <= pwd->tb_height && !pwd->have_av)
- GetClientRect(hwnd, &r);
-
- TCHAR *text = mir_u2t(pd->pwzText);
- 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, (int)_tcslen(text), &tr, DT_NOPREFIX | DT_WORDBREAK | DT_EXTERNALLEADING | DT_TOP | DT_LEFT | DT_WORD_ELLIPSIS);
- mir_free(text);
- }
+ ShowWindow(hwnd, SW_HIDE);
- EndPaint(hwnd, &ps);
- //}
- }
- return 0;
+ DeleteObject(pwd->bkBrush);
+ DeleteObject(pwd->bPen);
+ DeleteObject(pwd->barBrush);
+ DeleteObject(pwd->underlineBrush);
+ KillTimer(hwnd, ID_MOVETIMER);
+ KillTimer(hwnd, ID_CLOSETIMER);
- case WM_DESTROY:
- if (pwd->mouse_in) global_mouse_in--;
+ RemoveWindowFromStack(hwnd);
- ShowWindow(hwnd, SW_HIDE);
+ SendMessage(hwnd, PM_DIENOTIFY, 0, 0);
- DeleteObject(pwd->bkBrush);
- DeleteObject(pwd->bPen);
- DeleteObject(pwd->barBrush);
- DeleteObject(pwd->underlineBrush);
+ if (pd) {
+ pd->SetIcon(NULL);
+ mir_free(pd->pwzTitle);
+ mir_free(pd->pwzText);
+ mir_free(pd);
+ }
+ mir_free(pwd); pwd = 0; pd = 0;
+ SetWindowLongPtr(hwnd, GWLP_USERDATA, 0);
+ break;
+
+ case PUM_UPDATERGN:
+ // round corners
+ if (pwd->is_round) {
+ HRGN hRgn1;
+ RECT r;
+
+ int v,h;
+ int w=11;
+ GetWindowRect(hwnd,&r);
+ 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;
+ hRgn1=CreateRoundRectRgn(0,0,(r.right-r.left) + 1,(r.bottom-r.top) + 1,h,h);
+ SetWindowRgn(hwnd,hRgn1,FALSE);
+ }
+ return TRUE;
+
+ case PUM_MOVE:
+ if (options.animate) {
KillTimer(hwnd, ID_MOVETIMER);
- KillTimer(hwnd, ID_CLOSETIMER);
+ pwd->new_x = (int)wParam;
+ pwd->new_y = (int)lParam;
+ SetTimer(hwnd, ID_MOVETIMER, 10, 0);
+ } else {
+ SetWindowPos(hwnd, 0, (int)wParam, (int)lParam, 0, 0, SWP_NOZORDER | SWP_NOSIZE | SWP_NOACTIVATE);
+ if (!IsWindowVisible(hwnd)) {
+ ShowWindow(hwnd, SW_SHOWNOACTIVATE);
+ UpdateWindow(hwnd);
+ }
+ }
+ return TRUE;
- RemoveWindowFromStack(hwnd);
+ case PUM_SETTEXT:
+ replaceStrT(pd->ptzText, (TCHAR*)lParam);
+ InvalidateRect(hwnd, 0, TRUE);
+ RepositionWindows();
+ return TRUE;
- SendMessage(hwnd, PM_DIENOTIFY, 0, 0);
+ case PUM_GETCONTACT:
+ {
+ HANDLE *phContact = (HANDLE *)wParam;
+ *phContact = pd->hContact;
+ if (lParam) SetEvent((HANDLE)lParam);
+ }
+ return TRUE;
- if (pd) {
- mir_free(pd->pwzTitle);
- mir_free(pd->pwzText);
- mir_free(pd);
+ case PUM_GETHEIGHT:
+ {
+ int *pHeight = (int *)wParam;
+ HDC hdc = GetDC(hwnd);
+ SIZE size;
+
+ // time_height + width
+ if (options.time_layout != PT_NONE) {
+ SIZE size_t;
+ if (hFontTime) SelectObject(hdc, (HGDIOBJ)hFontTime);
+ GetTextExtentPoint32(hdc, pwd->tbuff, (int)_tcslen(pwd->tbuff), &size_t);
+ pwd->time_height = size_t.cy;
+ pwd->time_width = size_t.cx;
}
- mir_free(pwd); pwd = 0; pd = 0;
- SetWindowLongPtr(hwnd, GWLP_USERDATA, 0);
- break;
- case PUM_UPDATERGN:
- // round corners
- if (pwd->is_round) {
- HRGN hRgn1;
- RECT r;
-
- int v,h;
- int w=11;
- GetWindowRect(hwnd,&r);
- 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;
- hRgn1=CreateRoundRectRgn(0,0,(r.right-r.left) + 1,(r.bottom-r.top) + 1,h,h);
- SetWindowRgn(hwnd,hRgn1,FALSE);
+ // titlebar height
+ if (hFontFirstLine) SelectObject(hdc, (HGDIOBJ)hFontFirstLine);
+ TCHAR *title = mir_u2t(pd->pwzTitle);
+ GetTextExtentPoint32(hdc, title, (int)_tcslen(title), &size);
+ mir_free(title);
+ pwd->tb_height = size.cy;
+ if (options.time_layout == PT_LEFT || options.time_layout == PT_RIGHT) {
+ if (pwd->tb_height < pwd->time_height) pwd->tb_height = pwd->time_height;
}
- return TRUE;
-
- case PUM_MOVE:
- if (options.animate) {
- KillTimer(hwnd, ID_MOVETIMER);
- pwd->new_x = (int)wParam;
- pwd->new_y = (int)lParam;
- SetTimer(hwnd, ID_MOVETIMER, 10, 0);
- } else {
- SetWindowPos(hwnd, 0, (int)wParam, (int)lParam, 0, 0, SWP_NOZORDER | SWP_NOSIZE | SWP_NOACTIVATE);
- if (!IsWindowVisible(hwnd)) {
- ShowWindow(hwnd, SW_SHOWNOACTIVATE);
- UpdateWindow(hwnd);
+ if (pwd->tb_height < 16) pwd->tb_height = 16;
+
+ // avatar height
+ if (options.av_layout != PAV_NONE && ServiceExists(MS_AV_DRAWAVATAR)) {
+ AVATARCACHEENTRY *ace = (AVATARCACHEENTRY *)CallService(MS_AV_GETAVATARBITMAP, (WPARAM)pd->hContact, 0);
+ if (ace && (ace->dwFlags & AVS_BITMAP_VALID) && !(ace->dwFlags & AVS_HIDEONCLIST)) {
+ if (ace->bmHeight >= ace->bmWidth) {
+ pwd->real_av_height = options.av_size;
+ pwd->real_av_width = options.av_size * ace->bmWidth / ace->bmHeight;
+ } 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;
}
}
- return TRUE;
- case PUM_SETTEXT:
- replaceStrT(pd->ptzText, (TCHAR*)lParam);
- InvalidateRect(hwnd, 0, TRUE);
- RepositionWindows();
- return TRUE;
-
- case PUM_GETCONTACT:
- {
- HANDLE *phContact = (HANDLE *)wParam;
- *phContact = pd->hContact;
- if (lParam) SetEvent((HANDLE)lParam);
+ // text height
+ if (pd->pwzText[0]) {
+ RECT r;
+ 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);
+ else if (pwd->have_av)
+ 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);
+ TCHAR *text = mir_u2t(pd->pwzText);
+ DrawText(hdc, text, (int)_tcslen(text), &r, DT_CALCRECT | DT_NOPREFIX | DT_WORDBREAK | DT_EXTERNALLEADING | DT_TOP | DT_LEFT | DT_WORD_ELLIPSIS);
+ pwd->text_height = r.bottom;
+ mir_free(text);
}
- return TRUE;
- case PUM_GETHEIGHT:
- {
- int *pHeight = (int *)wParam;
- HDC hdc = GetDC(hwnd);
- SIZE size;
-
- // time_height + width
- if (options.time_layout != PT_NONE) {
- SIZE size_t;
- if (hFontTime) SelectObject(hdc, (HGDIOBJ)hFontTime);
- GetTextExtentPoint32(hdc, pwd->tbuff, (int)_tcslen(pwd->tbuff), &size_t);
- pwd->time_height = size_t.cy;
- pwd->time_width = size_t.cx;
- }
- // titlebar height
- if (hFontFirstLine) SelectObject(hdc, (HGDIOBJ)hFontFirstLine);
- TCHAR *title = mir_u2t(pd->pwzTitle);
- GetTextExtentPoint32(hdc, title, (int)_tcslen(title), &size);
- mir_free(title);
- pwd->tb_height = size.cy;
- if (options.time_layout == PT_LEFT || options.time_layout == PT_RIGHT) {
- if (pwd->tb_height < pwd->time_height) pwd->tb_height = pwd->time_height;
- }
- if (pwd->tb_height < 16) pwd->tb_height = 16;
-
- // avatar height
- if (options.av_layout != PAV_NONE && ServiceExists(MS_AV_DRAWAVATAR)) {
- AVATARCACHEENTRY *ace = (AVATARCACHEENTRY *)CallService(MS_AV_GETAVATARBITMAP, (WPARAM)pd->hContact, 0);
- if (ace && (ace->dwFlags & AVS_BITMAP_VALID) && !(ace->dwFlags & AVS_HIDEONCLIST)) {
- if (ace->bmHeight >= ace->bmWidth) {
- pwd->real_av_height = options.av_size;
- pwd->real_av_width = options.av_size * ace->bmWidth / ace->bmHeight;
- } 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;
- }
- }
+ ReleaseDC(hwnd, hdc);
- // text height
- if (pd->pwzText[0]) {
- RECT r;
- 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);
- else if (pwd->have_av)
- 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);
- TCHAR *text = mir_u2t(pd->pwzText);
- DrawText(hdc, text, (int)_tcslen(text), &r, DT_CALCRECT | DT_NOPREFIX | DT_WORDBREAK | DT_EXTERNALLEADING | DT_TOP | DT_LEFT | DT_WORD_ELLIPSIS);
- pwd->text_height = r.bottom;
- mir_free(text);
- }
+ 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
+ *pHeight = max(pwd->tb_height + pwd->text_height + 3 * options.padding, pwd->av_height + 2 * options.av_padding);
- ReleaseDC(hwnd, hdc);
+ if (*pHeight > options.win_max_height) *pHeight = options.win_max_height;
- 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
- *pHeight = max(pwd->tb_height + pwd->text_height + 3 * options.padding, pwd->av_height + 2 * options.av_padding);
+ RECT r;
+ GetWindowRect(hwnd, &r);
+ if (r.right - r.left != options.win_width || r.bottom - r.top != *pHeight) {
+ SetWindowPos(hwnd, 0, 0, 0, options.win_width, *pHeight, SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE);
+ SendMessage(hwnd, PUM_UPDATERGN, 0, 0);
+ InvalidateRect(hwnd, 0, TRUE);
+ }
+ }
+ return TRUE;
- if (*pHeight > options.win_max_height) *pHeight = options.win_max_height;
+ case PUM_GETOPAQUE:
+ {
+ void **pData = (void **)wParam;
+ if (pd) *pData = pd->opaque;
+ if (lParam) SetEvent((HANDLE)lParam);
+ }
+ return TRUE;
- RECT r;
- GetWindowRect(hwnd, &r);
- if (r.right - r.left != options.win_width || r.bottom - r.top != *pHeight) {
- SetWindowPos(hwnd, 0, 0, 0, options.win_width, *pHeight, SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE);
- SendMessage(hwnd, PUM_UPDATERGN, 0, 0);
- InvalidateRect(hwnd, 0, TRUE);
- }
- }
- return TRUE;
- case PUM_GETOPAQUE:
- {
- void **pData = (void **)wParam;
- if (pd) *pData = pd->opaque;
- if (lParam) SetEvent((HANDLE)lParam);
+ case PUM_CHANGE:
+ {
+ KillTimer(hwnd, ID_CLOSETIMER);
+ if (pd) {
+ mir_free(pd->pwzTitle);
+ mir_free(pd->pwzText);
+ mir_free(pd);
}
- return TRUE;
- case PUM_CHANGE:
- {
- KillTimer(hwnd, ID_CLOSETIMER);
- if (pd) {
- mir_free(pd->pwzTitle);
- mir_free(pd->pwzText);
- mir_free(pd);
- }
- pwd->pd = pd = (PopupData *)lParam;
+ pwd->pd = pd = (PopupData *)lParam;
- if (pd->timeout != -1) {
- if (pd->timeout == 0) {
- SetTimer(hwnd, ID_CLOSETIMER, 7 * 1000, 0);
- } else {
- SetTimer(hwnd, ID_CLOSETIMER, pd->timeout * 1000, 0);
- }
+ if (pd->timeout != -1) {
+ if (pd->timeout == 0) {
+ SetTimer(hwnd, ID_CLOSETIMER, 7 * 1000, 0);
} else {
- // make a really long timeout - say 7 days? ;)
- SetTimer(hwnd, ID_CLOSETIMER, 7 * 24 * 60 * 60 * 1000, 0);
+ SetTimer(hwnd, ID_CLOSETIMER, pd->timeout * 1000, 0);
}
-
- InvalidateRect(hwnd, 0, TRUE);
- RepositionWindows();
+ } else {
+ // make a really long timeout - say 7 days? ;)
+ SetTimer(hwnd, ID_CLOSETIMER, 7 * 24 * 60 * 60 * 1000, 0);
}
- return TRUE;
- case PUM_SETNOTIFYH:
- pwd->hNotify = (HANDLE)wParam;
- return TRUE;
+ InvalidateRect(hwnd, 0, TRUE);
+ RepositionWindows();
+ }
+ return TRUE;
- case PUM_UPDATENOTIFY:
- if (pwd->hNotify == (HANDLE)wParam) {
- pd->colorBack = MNotifyGetDWord(pwd->hNotify, NFOPT_BACKCOLOR, colBg);
- pd->colorText = MNotifyGetDWord(pwd->hNotify, NFOPT_TEXTCOLOR, colSecondLine);
- pd->timeout = MNotifyGetDWord(pwd->hNotify, NFOPT_TIMEOUT, options.default_timeout);
- pd->hContact = (HANDLE)MNotifyGetDWord(pwd->hNotify, NFOPT_CONTACT, 0);
- pd->hIcon = (HICON)MNotifyGetDWord(pwd->hNotify, NFOPT_ICON, 0);
-
- const wchar_t *swzName = MNotifyGetWString(pwd->hNotify, NFOPT_TITLEW, 0);
- mir_free(pd->pwzTitle);
- pd->pwzTitle = mir_wstrdup(swzName);
+ case PUM_SETNOTIFYH:
+ pwd->hNotify = (HANDLE)wParam;
+ return TRUE;
- const wchar_t *swzText = MNotifyGetWString(pwd->hNotify, NFOPT_TEXTW, 0);
- mir_free(pd->pwzText);
- pd->pwzText = mir_wstrdup(swzText);
+ case PUM_UPDATENOTIFY:
+ if (pwd->hNotify == (HANDLE)wParam) {
+ pd->colorBack = MNotifyGetDWord(pwd->hNotify, NFOPT_BACKCOLOR, colBg);
+ pd->colorText = MNotifyGetDWord(pwd->hNotify, NFOPT_TEXTCOLOR, colSecondLine);
+ pd->timeout = MNotifyGetDWord(pwd->hNotify, NFOPT_TIMEOUT, options.default_timeout);
+ pd->hContact = (HANDLE)MNotifyGetDWord(pwd->hNotify, NFOPT_CONTACT, 0);
+ pd->hIcon = (HICON)MNotifyGetDWord(pwd->hNotify, NFOPT_ICON, 0);
- InvalidateRect(hwnd, 0, TRUE);
- RepositionWindows();
- }
+ const wchar_t *swzName = MNotifyGetWString(pwd->hNotify, NFOPT_TITLEW, 0);
+ mir_free(pd->pwzTitle);
+ pd->pwzTitle = mir_wstrdup(swzName);
- return TRUE;
- case PUM_KILLNOTIFY:
- if (pwd->hNotify != (HANDLE)wParam)
- return TRUE;
- // drop through
+ const wchar_t *swzText = MNotifyGetWString(pwd->hNotify, NFOPT_TEXTW, 0);
+ mir_free(pd->pwzText);
+ pd->pwzText = mir_wstrdup(swzText);
- case PM_DESTROY:
- PostMPMessage(MUM_DELETEPOPUP, 0, (LPARAM)hwnd);
+ InvalidateRect(hwnd, 0, TRUE);
+ RepositionWindows();
+ }
+
+ return TRUE;
+ case PUM_KILLNOTIFY:
+ if (pwd->hNotify != (HANDLE)wParam)
return TRUE;
- }
+ // drop through
+ case PM_DESTROY:
+ PostMPMessage(MUM_DELETEPOPUP, 0, (LPARAM)hwnd);
+ return TRUE;
+ }
if (pd && pd->windowProc)
return CallWindowProc(pd->windowProc, hwnd, uMsg, wParam, lParam);
@@ -754,7 +707,8 @@ LRESULT CALLBACK PopupWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lPa
}
}
-void InitWindowStack() {
+void InitWindowStack()
+{
hUserDll = GetModuleHandle(_T("user32.dll"));
if (hUserDll) {
MySetLayeredWindowAttributes = (BOOL (WINAPI *)(HWND,COLORREF,BYTE,DWORD))GetProcAddress(hUserDll, "SetLayeredWindowAttributes");
@@ -766,7 +720,24 @@ void InitWindowStack() {
}
}
-void DeinitWindowStack() {
+void DeinitWindowStack()
+{
ClearStack();
}
+///////////////////////////////////////////////////////////////////////////////
+
+void PopupData::SetIcon(HICON hNewIcon)
+{
+ if (flags & PDF_ICOLIB) {
+ Skin_ReleaseIcon(hIcon);
+ flags &= ~PDF_ICOLIB;
+ }
+
+ hIcon = hNewIcon;
+
+ if ( CallService(MS_SKIN2_ISMANAGEDICON, (WPARAM)hIcon, 0)) {
+ CallService(MS_SKIN2_ADDREFICON, (WPARAM)hIcon, 0);
+ flags |= PDF_ICOLIB;
+ }
+}
diff --git a/plugins/YAPP/src/services.cpp b/plugins/YAPP/src/services.cpp
index 05c5beab8a..6abbd4bc47 100644
--- a/plugins/YAPP/src/services.cpp
+++ b/plugins/YAPP/src/services.cpp
@@ -5,11 +5,10 @@
#include "resource.h"
#include "yapp_history.h"
-#define NUM_SERVICES 20
-HANDLE hService[NUM_SERVICES];
HANDLE hMenuShowHistory, hMenuToggleOnOff;
-void StripBBCodesInPlace(wchar_t *text) {
+void StripBBCodesInPlace(wchar_t *text)
+{
if (text == 0 || db_get_b(0, MODULE, "StripBBCodes", 1) == 0)
return;
@@ -44,7 +43,8 @@ void StripBBCodesInPlace(wchar_t *text) {
}
}
-INT_PTR OldCreatePopupA(WPARAM wParam, LPARAM lParam) {
+INT_PTR CreatePopupA(WPARAM wParam, LPARAM lParam)
+{
POPUPDATA *pd_in = (POPUPDATA *)wParam;
PopupData *pd_out = (PopupData *)mir_calloc(sizeof(PopupData));
@@ -56,7 +56,7 @@ INT_PTR OldCreatePopupA(WPARAM wParam, LPARAM lParam) {
StripBBCodesInPlace(pd_out->pwzText);
pd_out->hContact = pd_in->lchContact;
- pd_out->hIcon = pd_in->lchIcon;
+ pd_out->SetIcon(pd_in->lchIcon);
if (pd_in->colorBack == 0xffffffff) // that's the old #define for 'skinned bg'
pd_out->colorBack = pd_out->colorText = 0;
else {
@@ -81,7 +81,7 @@ INT_PTR OldCreatePopupA(WPARAM wParam, LPARAM lParam) {
return 0;
}
-INT_PTR OldCreatePopupExA(WPARAM wParam, LPARAM lParam) {
+INT_PTR CreatePopupExA(WPARAM wParam, LPARAM lParam) {
POPUPDATAEX *pd_in = (POPUPDATAEX *)wParam;
PopupData *pd_out = (PopupData *)mir_calloc(sizeof(PopupData));
@@ -94,7 +94,7 @@ INT_PTR OldCreatePopupExA(WPARAM wParam, LPARAM lParam) {
StripBBCodesInPlace(pd_out->pwzText);
pd_out->hContact = pd_in->lchContact;
- pd_out->hIcon = pd_in->lchIcon;
+ pd_out->SetIcon(pd_in->lchIcon);
if (pd_in->colorBack == 0xffffffff) // that's the old #define for 'skinned bg'
pd_out->colorBack = pd_out->colorText = 0;
else {
@@ -118,8 +118,8 @@ INT_PTR OldCreatePopupExA(WPARAM wParam, LPARAM lParam) {
return 0;
}
-INT_PTR OldCreatePopupW(WPARAM wParam, LPARAM lParam) {
-
+INT_PTR CreatePopupW(WPARAM wParam, LPARAM lParam)
+{
POPUPDATAW *pd_in = (POPUPDATAW *)wParam;
PopupData *pd_out = (PopupData *)mir_calloc(sizeof(PopupData));
@@ -131,7 +131,7 @@ INT_PTR OldCreatePopupW(WPARAM wParam, LPARAM lParam) {
StripBBCodesInPlace(pd_out->pwzText);
pd_out->hContact = pd_in->lchContact;
- pd_out->hIcon = pd_in->lchIcon;
+ pd_out->SetIcon(pd_in->lchIcon);
if (pd_in->colorBack == 0xffffffff) // that's the old #define for 'skinned bg'
pd_out->colorBack = pd_out->colorText = 0;
else {
@@ -294,7 +294,7 @@ INT_PTR PopupChangeA(WPARAM wParam, LPARAM lParam) {
StripBBCodesInPlace(pd_out.pwzText);
pd_out.hContact = pd_in->lchContact;
- pd_out.hIcon = pd_in->lchIcon;
+ pd_out.SetIcon(pd_in->lchIcon);
if (pd_in->colorBack == 0xffffffff) // that's the old #define for 'skinned bg'
pd_out.colorBack = pd_out.colorText = 0;
else {
@@ -329,7 +329,7 @@ INT_PTR PopupChangeW(WPARAM wParam, LPARAM lParam) {
StripBBCodesInPlace(pd_out.pwzText);
pd_out.hContact = pd_in->lchContact;
- pd_out.hIcon = pd_in->lchIcon;
+ pd_out.SetIcon(pd_in->lchIcon);
if (pd_in->colorBack == 0xffffffff) // that's the old #define for 'skinned bg'
pd_out.colorBack = pd_out.colorText = 0;
else {
@@ -350,35 +350,30 @@ INT_PTR PopupChangeW(WPARAM wParam, LPARAM lParam) {
}
INT_PTR ShowMessage(WPARAM wParam, LPARAM lParam) {
- if (!db_get_b(0, MODULE, "Enabled", 1)) return 0;
+ if ( !db_get_b(0, MODULE, "Enabled", 1)) return 0;
POPUPDATAT pd = {0};
_tcscpy(pd.lptzContactName, lParam == SM_WARNING ? _T("Warning") : _T("Notification"));
pd.lchIcon = LoadIcon(0, lParam == SM_WARNING ? IDI_WARNING : IDI_INFORMATION);
- TCHAR *buff = mir_a2t((char *)wParam);
- _tcscpy(pd.lptzText, buff); pd.lptzText[MAX_SECONDLINE-1] = 0;
- mir_free(buff);
-
+ _tcsncpy(pd.lptzText, _A2T((char *)wParam), MAX_SECONDLINE); pd.lptzText[MAX_SECONDLINE-1] = 0;
CallService(MS_POPUP_ADDPOPUPT, (WPARAM)&pd, 0);
-
return 0;
}
-INT_PTR ShowMessageW(WPARAM wParam, LPARAM lParam) {
- if (!db_get_b(0, MODULE, "Enabled", 1)) return 0;
+INT_PTR ShowMessageW(WPARAM wParam, LPARAM lParam)
+{
+ if ( !db_get_b(0, MODULE, "Enabled", 1)) return 0;
POPUPDATAW pd = {0};
wcscpy(pd.lpwzContactName, lParam == SM_WARNING ? L"Warning" : L"Notification");
pd.lchIcon = LoadIcon(0, lParam == SM_WARNING ? IDI_WARNING : IDI_INFORMATION);
wcsncpy(pd.lpwzText, (wchar_t *)wParam, MAX_SECONDLINE);
-
CallService(MS_POPUP_ADDPOPUPW, (WPARAM)&pd, 0);
-
return 0;
}
//=====PopUp/ShowHistory
-//extern BOOL CALLBACK DlgProcHistLstOpts(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
+
INT_PTR PopUp_ShowHistory(WPARAM wParam, LPARAM lParam)
{
if (!hHistoryWindow) {
@@ -437,7 +432,7 @@ INT_PTR CreateClassPopup(WPARAM wParam, LPARAM lParam)
if (pc->flags & PCF_UNICODE) pd.flags |= PDF_UNICODE;
pd.colorBack = pc->colorBack;
pd.colorText = pc->colorText;
- pd.hIcon = pc->hIcon;
+ pd.SetIcon(pc->hIcon);
pd.timeout = pc->iSeconds;
pd.windowProc = pc->PluginWindowProc;
@@ -451,43 +446,38 @@ INT_PTR CreateClassPopup(WPARAM wParam, LPARAM lParam)
return 0;
}
-int PrebuildMenu(WPARAM wParam, LPARAM lParam) {
- return 0;
-}
-
-HANDLE hEventBuildMenu;
+//////////////////////////////////////////////////////////////////////////////
void InitServices()
{
- int i = 0;
- hService[i++] = CreateServiceFunction(MS_POPUP_REGISTERCLASS, RegisterPopupClass);
- hService[i++] = CreateServiceFunction(MS_POPUP_ADDPOPUPCLASS, CreateClassPopup);
- hService[i++] = CreateServiceFunction(MS_POPUP_ADDPOPUP, OldCreatePopupA);
- hService[i++] = CreateServiceFunction(MS_POPUP_ADDPOPUPEX, OldCreatePopupExA);
- hService[i++] = CreateServiceFunction(MS_POPUP_ADDPOPUPW, OldCreatePopupW);
- hService[i++] = CreateServiceFunction(MS_POPUP_CHANGETEXTW, ChangeTextW);
- hService[i++] = CreateServiceFunction(MS_POPUP_CHANGETEXT, ChangeTextA);
- hService[i++] = CreateServiceFunction(MS_POPUP_CHANGE, PopupChangeA);
- hService[i++] = CreateServiceFunction(MS_POPUP_CHANGEW, PopupChangeW);
- hService[i++] = CreateServiceFunction(MS_POPUP_GETCONTACT, GetContact);
- hService[i++] = CreateServiceFunction(MS_POPUP_GETPLUGINDATA, GetOpaque);
- hService[i++] = CreateServiceFunction(MS_POPUP_ISSECONDLINESHOWN, IsSecondLineShown);
- hService[i++] = CreateServiceFunction(MS_POPUP_QUERY, PopupQuery);
-
- hService[i++] = CreateServiceFunction(MS_POPUP_SHOWMESSAGE, ShowMessage);
- hService[i++] = CreateServiceFunction(MS_POPUP_SHOWMESSAGE"W", ShowMessageW);
-
- hService[i++] = CreateServiceFunction(MS_POPUP_SHOWHISTORY, PopUp_ShowHistory);
- hService[i++] = CreateServiceFunction("PopUp/ToggleEnabled", TogglePopups);
-
- hService[i++] = CreateServiceFunction("YAPP/RegisterClass", RegisterPopupClass);
- hService[i++] = CreateServiceFunction("YAPP/ClassInstance", CreateClassPopup);
-
- CLISTMENUITEM mi = {0};
-
- mi.cbSize = sizeof(mi);
+ CreateServiceFunction(MS_POPUP_REGISTERCLASS, RegisterPopupClass);
+ CreateServiceFunction(MS_POPUP_ADDPOPUPCLASS, CreateClassPopup);
+ CreateServiceFunction(MS_POPUP_ADDPOPUP, CreatePopupA);
+ CreateServiceFunction(MS_POPUP_ADDPOPUPEX, CreatePopupExA);
+ CreateServiceFunction(MS_POPUP_ADDPOPUPW, CreatePopupW);
+ CreateServiceFunction(MS_POPUP_CHANGETEXTW, ChangeTextW);
+ CreateServiceFunction(MS_POPUP_CHANGETEXT, ChangeTextA);
+ CreateServiceFunction(MS_POPUP_CHANGE, PopupChangeA);
+ CreateServiceFunction(MS_POPUP_CHANGEW, PopupChangeW);
+ CreateServiceFunction(MS_POPUP_GETCONTACT, GetContact);
+ CreateServiceFunction(MS_POPUP_GETPLUGINDATA, GetOpaque);
+ CreateServiceFunction(MS_POPUP_ISSECONDLINESHOWN, IsSecondLineShown);
+ CreateServiceFunction(MS_POPUP_QUERY, PopupQuery);
+
+ CreateServiceFunction(MS_POPUP_SHOWMESSAGE, ShowMessage);
+ CreateServiceFunction(MS_POPUP_SHOWMESSAGE"W", ShowMessageW);
+
+ CreateServiceFunction(MS_POPUP_SHOWHISTORY, PopUp_ShowHistory);
+ CreateServiceFunction("PopUp/ToggleEnabled", TogglePopups);
+
+ CreateServiceFunction("YAPP/RegisterClass", RegisterPopupClass);
+ CreateServiceFunction("YAPP/ClassInstance", CreateClassPopup);
+
+ ////////////////////////////////////////////////////////////////////////////
+ // Menus
+
+ CLISTMENUITEM mi = { sizeof(mi) };
mi.flags = CMIM_ALL;
-
mi.position = 500010000;
mi.pszPopupName = LPGEN("PopUps");
@@ -502,20 +492,13 @@ void InitServices()
mi.pszName = (char*)(db_get_b(0, MODULE, "Enabled", 1) ?
LPGEN("Disable Popups") : LPGEN("Enable Popups"));
hMenuToggleOnOff = Menu_AddMainMenuItem(&mi);
-
- hEventBuildMenu = HookEvent(ME_CLIST_PREBUILDCONTACTMENU, PrebuildMenu);
}
-void DeinitServices() {
- int i;
- for (i = 0; i < num_classes; i++) {
+void DeinitServices()
+{
+ for (int i = 0; i < num_classes; i++) {
mir_free(classes[i].pszName);
mir_free(classes[i].pszDescription);
}
mir_free(classes); num_classes = 0;
-
- UnhookEvent(hEventBuildMenu);
-
- for (i = 0; i < NUM_SERVICES; i++)
- if (hService[i]) DestroyServiceFunction(hService[i]);
}
diff --git a/plugins/YAPP/src/yapp.cpp b/plugins/YAPP/src/yapp.cpp
index 340d223313..985d2b6287 100644
--- a/plugins/YAPP/src/yapp.cpp
+++ b/plugins/YAPP/src/yapp.cpp
@@ -148,8 +148,6 @@ static void InitFonts()
ReloadFont(0, 0);
}
-HANDLE hEventReloadFont = 0;
-
int ModulesLoaded(WPARAM wParam, LPARAM lParam)
{
MNotifyGetLink();
@@ -157,7 +155,7 @@ int ModulesLoaded(WPARAM wParam, LPARAM lParam)
if (ServiceExists(MS_HPP_EG_WINDOW))
lstPopupHistory.SetRenderer(RENDER_HISTORYPP);
- hEventReloadFont = HookEvent(ME_FONT_RELOAD, ReloadFont);
+ HookEvent(ME_FONT_RELOAD, ReloadFont);
LoadModuleDependentOptions();
@@ -167,14 +165,13 @@ int ModulesLoaded(WPARAM wParam, LPARAM lParam)
return 0;
}
-int PreShutdown(WPARAM wParam, LPARAM lParam) {
+int PreShutdown(WPARAM wParam, LPARAM lParam)
+{
DeinitMessagePump();
DeinitNotify();
return 0;
}
-HANDLE hEventPreShutdown, hEventModulesLoaded;
-
extern "C" int YAPP_API Load(void) {
mir_getLP(&pluginInfo);
@@ -184,32 +181,13 @@ extern "C" int YAPP_API Load(void) {
InitNotify();
InitFonts();
- hEventPreShutdown = HookEvent(ME_SYSTEM_PRESHUTDOWN, PreShutdown);
- hEventModulesLoaded = HookEvent(ME_SYSTEM_MODULESLOADED, ModulesLoaded);
-
- /*
- // test popup classes
- PopupClass test = {0};
- test.cbSize = sizeof(test);
- test.flags = PCF_TCHAR;
- test.hIcon = LoadIcon(0, IDI_WARNING);
- test.colorBack = RGB(0, 0, 0);
- test.colorText = RGB(255, 255, 255);
- test.iSeconds = 10;
- test.ptszDescription = TranslateT("Test popup class");
- test.pszName = "popup/testclass";
- CallService(MS_POPUP_REGISTERCLASS, 0, (WPARAM)&test);
- */
-
+ HookEvent(ME_SYSTEM_PRESHUTDOWN, PreShutdown);
+ HookEvent(ME_SYSTEM_MODULESLOADED, ModulesLoaded);
return 0;
}
extern "C" int YAPP_API Unload()
{
- if (hEventReloadFont)
- UnhookEvent(hEventReloadFont);
- UnhookEvent(hEventPreShutdown);
- UnhookEvent(hEventModulesLoaded);
DeinitNotify();
DeleteObject(hFontFirstLine);
DeleteObject(hFontSecondLine);