summaryrefslogtreecommitdiff
path: root/plugins/SmileyAdd
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2016-03-01 16:45:43 +0000
committerGeorge Hazan <george.hazan@gmail.com>2016-03-01 16:45:43 +0000
commitd5675b1834031fd7c99baa6d948fb550594fcd3a (patch)
tree1977ac3eb1162f8db55c2a7d74981cca39187a83 /plugins/SmileyAdd
parent88167d8a0f7f0e3b8fbad7c8204732995bd265be (diff)
- smileys rewritten to support true frame delays;
- code cleaning; - version bump git-svn-id: http://svn.miranda-ng.org/main/trunk@16383 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/SmileyAdd')
-rw-r--r--plugins/SmileyAdd/src/AniSmileyObject.cpp127
-rw-r--r--plugins/SmileyAdd/src/SmileyBase.h3
-rw-r--r--plugins/SmileyAdd/src/customsmiley.cpp26
-rw-r--r--plugins/SmileyAdd/src/dlgboxsubclass.cpp87
-rw-r--r--plugins/SmileyAdd/src/imagecache.cpp8
-rw-r--r--plugins/SmileyAdd/src/main.cpp1
-rw-r--r--plugins/SmileyAdd/src/smileys.cpp122
-rw-r--r--plugins/SmileyAdd/src/smileys.h11
-rw-r--r--plugins/SmileyAdd/src/stdafx.h3
-rw-r--r--plugins/SmileyAdd/src/version.h18
10 files changed, 202 insertions, 204 deletions
diff --git a/plugins/SmileyAdd/src/AniSmileyObject.cpp b/plugins/SmileyAdd/src/AniSmileyObject.cpp
index f86c092464..31d954e573 100644
--- a/plugins/SmileyAdd/src/AniSmileyObject.cpp
+++ b/plugins/SmileyAdd/src/AniSmileyObject.cpp
@@ -20,24 +20,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
class CAniSmileyObject;
-static int CompareAniSmiley(const CAniSmileyObject* p1, const CAniSmileyObject* p2)
-{
- return (int)((char*)p2 - (char*)p1);
-}
-
-static LIST<CAniSmileyObject> regAniSmileys(10, CompareAniSmiley);
-
-static UINT_PTR timerId;
-static void CALLBACK timerProc(HWND, UINT, UINT_PTR, DWORD);
-
-static void CALLBACK sttMainThreadCallback(PVOID)
-{
- if (timerId == 0xffffffff)
- timerId = SetTimer(NULL, 0, 100, (TIMERPROC)timerProc);
-}
-
-
-class CAniSmileyObject : public ISmileyBase
+class CAniSmileyObject : public ISmileyBase, public MZeroedObject
{
private:
typedef enum { animStdOle, animDrctRichEd, animHpp } AnimType;
@@ -49,7 +32,6 @@ private:
SmileyType *m_sml;
ImageBase *m_img;
- unsigned m_nFramePosition;
long m_counter;
unsigned m_richFlags;
@@ -59,64 +41,43 @@ private:
bool m_allowAni;
public:
- CAniSmileyObject(SmileyType* sml, COLORREF clr, bool ishpp)
+ CAniSmileyObject(SmileyType *sml, COLORREF clr, bool ishpp)
{
- m_allowAni = false;
m_animtype = ishpp ? animHpp : animStdOle;
m_bkg = clr;
-
- m_rectOrig.x = 0;
- m_rectOrig.y = 0;
- m_rectExt.cx = 0;
- m_rectExt.cy = 0;
-
- m_richFlags = 0;
- m_lastObjNum = 0;
-
m_sml = sml;
- m_img = NULL;
- m_nFramePosition = 0;
- m_counter = 0;
}
- ~CAniSmileyObject(void)
+ ~CAniSmileyObject()
{
UnloadSmiley();
}
- void LoadSmiley(void)
+ void LoadSmiley()
{
if (m_img != NULL) return;
m_img = m_sml->CreateCachedImage();
if (m_img && m_img->IsAnimated() && opt.AnimateDlg) {
- m_nFramePosition = 0;
- m_img->SelectFrame(m_nFramePosition);
+ m_img->SelectFrame(0);
long frtm = m_img->GetFrameDelay();
m_counter = frtm / 10 + ((frtm % 10) >= 5);
- regAniSmileys.insert(this);
- if (timerId == 0) {
- timerId = 0xffffffff;
- CallFunctionAsync(sttMainThreadCallback, NULL);
- }
+ m_sml->AddObject(this);
}
- else m_nFramePosition = m_sml->GetStaticFrame();
}
- void UnloadSmiley(void)
+ void UnloadSmiley()
{
- regAniSmileys.remove(this);
+ m_sml->RemoveObject(this);
- if (timerId && (timerId + 1) && regAniSmileys.getCount() == 0) {
- KillTimer(NULL, timerId);
- timerId = 0;
+ if (m_img) {
+ m_img->Release();
+ m_img = NULL;
}
- if (m_img) m_img->Release();
- m_img = NULL;
}
- void GetDrawingProp(void)
+ void GetDrawingProp()
{
if (m_hwnd == NULL) return;
@@ -190,7 +151,7 @@ public:
DeleteDC(hdcMem);
}
- void DrawOnRichEdit(void)
+ void DrawOnRichEdit()
{
HDC hdc = GetDC(m_hwnd);
if (RectVisible(hdc, &m_orect)) {
@@ -217,7 +178,7 @@ public:
ReleaseDC(m_hwnd, hdc);
}
- void DrawOnHPP(void)
+ void DrawOnHPP()
{
FVCNDATA_NMHDR nmh = { 0 };
nmh.code = NM_FIREVIEWCHANGE;
@@ -260,35 +221,34 @@ public:
}
}
- void ProcessTimerTick(void)
+ virtual void Draw()
{
- if (m_visible && m_img && --m_counter <= 0) {
- m_nFramePosition = m_img->SelectNextFrame(m_nFramePosition);
- long frtm = m_img->GetFrameDelay();
- m_counter = frtm / 10 + ((frtm % 10) >= 5);
+ if (!m_visible || !m_img)
+ return;
- switch (m_animtype) {
- case animStdOle:
- if (m_allowAni) SendOnViewChange();
- else {
- m_visible = false;
- UnloadSmiley();
- }
+ switch (m_animtype) {
+ case animStdOle:
+ if (!m_allowAni) {
+ m_visible = false;
+ UnloadSmiley();
+ }
+ else {
+ SendOnViewChange();
m_allowAni = false;
- break;
+ }
+ break;
- case animDrctRichEd:
- DrawOnRichEdit();
- break;
+ case animDrctRichEd:
+ DrawOnRichEdit();
+ break;
- case animHpp:
- DrawOnHPP();
- break;
- }
+ case animHpp:
+ DrawOnHPP();
+ break;
}
}
- void SetPosition(HWND hwnd, LPCRECT lpRect)
+ virtual void SetPosition(HWND hwnd, LPCRECT lpRect)
{
ISmileyBase::SetPosition(hwnd, lpRect);
@@ -383,7 +343,7 @@ public:
return S_OK;
}
- STDMETHOD(SetExtent)(DWORD dwDrawAspect, SIZEL* psizel)
+ STDMETHOD(SetExtent)(DWORD dwDrawAspect, SIZEL *psizel)
{
HRESULT hr = ISmileyBase::SetExtent(dwDrawAspect, psizel);
if (hr == S_OK) m_rectExt = m_sizeExtent;
@@ -398,20 +358,3 @@ ISmileyBase* CreateAniSmileyObject(SmileyType* sml, COLORREF clr, bool ishpp)
CAniSmileyObject *obj = new CAniSmileyObject(sml, clr, ishpp);
return obj;
}
-
-static void CALLBACK timerProc(HWND, UINT, UINT_PTR, DWORD)
-{
- for (int i = 0; i < regAniSmileys.getCount(); i++)
- regAniSmileys[i]->ProcessTimerTick();
-}
-
-void DestroyAniSmileys(void)
-{
- if (timerId && (timerId + 1)) {
- KillTimer(NULL, timerId);
- timerId = 0;
- }
-
- for (int i = 0; i < regAniSmileys.getCount(); i++)
- delete regAniSmileys[i];
-}
diff --git a/plugins/SmileyAdd/src/SmileyBase.h b/plugins/SmileyAdd/src/SmileyBase.h
index 1e1c224d18..06621a0310 100644
--- a/plugins/SmileyAdd/src/SmileyBase.h
+++ b/plugins/SmileyAdd/src/SmileyBase.h
@@ -60,6 +60,7 @@ public:
bool QueryHitPointSpecial(int x, int y, HWND hwnd, TCHAR** smltxt);
void SetHint(TCHAR* smltxt);
+ virtual void Draw() PURE;
virtual void SetPosition(HWND hwnd, LPCRECT lpRect);
//
@@ -114,7 +115,7 @@ public:
// ITooltipData members
//
STDMETHOD(SetTooltip)(BSTR bstrHint);
- STDMETHOD(GetTooltip)(BSTR * bstrHint);
+ STDMETHOD(GetTooltip)(BSTR *bstrHint);
};
int CheckForTip(int x, int y, HWND hwnd, TCHAR** smltxt);
diff --git a/plugins/SmileyAdd/src/customsmiley.cpp b/plugins/SmileyAdd/src/customsmiley.cpp
index 32a6f7ff25..3e1413509e 100644
--- a/plugins/SmileyAdd/src/customsmiley.cpp
+++ b/plugins/SmileyAdd/src/customsmiley.cpp
@@ -20,7 +20,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
SmileyPackCListType g_SmileyPackCStore;
-
bool SmileyPackCListType::AddSmileyPack(MCONTACT hContact, TCHAR* dir)
{
bool res = true;
@@ -37,11 +36,10 @@ bool SmileyPackCListType::AddSmileyPack(MCONTACT hContact, TCHAR* dir)
return res;
}
-
bool SmileyPackCListType::AddSmiley(MCONTACT hContact, TCHAR* path)
{
SmileyPackCType *smpack = GetSmileyPack(hContact);
- if (smpack == NULL) {
+ if (smpack == NULL) {
smpack = new SmileyPackCType;
smpack->SetId(hContact);
@@ -63,7 +61,7 @@ SmileyPackCType* SmileyPackCListType::GetSmileyPack(MCONTACT id)
SmileyCType::SmileyCType(const CMString& fullpath, const TCHAR* filepath)
{
- LoadFromResource(fullpath, 0);
+ LoadFromResource(fullpath, 0);
CreateTriggerText(T2A_SM(filepath));
}
@@ -91,7 +89,6 @@ bool SmileyCType::CreateTriggerText(char* text)
return true;
}
-
//
// SmileyPackCType
//
@@ -118,45 +115,42 @@ bool SmileyPackCType::LoadSmileyDir(TCHAR* dir)
m_SmileyList.insert(smlc);
}
}
- }
- while( _tfindnext( hFile, &c_file ) == 0 );
- _findclose( hFile );
+ } while (_tfindnext(hFile, &c_file) == 0);
+ _findclose(hFile);
AddTriggersToSmileyLookup();
return true;
}
return false;
}
-
bool SmileyPackCType::LoadSmiley(TCHAR* path)
{
CMString dirs = path;
int slash = dirs.ReverseFind('\\');
int dot = dirs.ReverseFind('.');
- CMString name = dirs.Mid(slash+1, dot - slash - 1);
+ CMString name = dirs.Mid(slash + 1, dot - slash - 1);
- for (int i=0; i < m_SmileyList.getCount(); i++)
+ for (int i = 0; i < m_SmileyList.getCount(); i++)
if (m_SmileyList[i].GetTriggerText() == name) {
m_SmileyList[i].LoadFromResource(dirs, 0);
- return true;
+ return true;
}
m_SmileyList.insert(new SmileyCType(dirs, (TCHAR*)name.c_str()));
CMString empty;
m_SmileyLookup.insert(new SmileyLookup(
- m_SmileyList[m_SmileyList.getCount()-1].GetTriggerText(), false, m_SmileyList.getCount()-1, empty));
+ m_SmileyList[m_SmileyList.getCount() - 1].GetTriggerText(), false, m_SmileyList.getCount() - 1, empty));
return true;
}
-
void SmileyPackCType::AddTriggersToSmileyLookup(void)
{
CMString empty;
- for (int dist=0; dist<m_SmileyList.getCount(); dist++) {
- SmileyLookup *dats = new SmileyLookup(m_SmileyList[dist].GetTriggerText(), false, dist, empty);
+ for (int dist = 0; dist < m_SmileyList.getCount(); dist++) {
+ SmileyLookup *dats = new SmileyLookup(m_SmileyList[dist].GetTriggerText(), false, dist, empty);
m_SmileyLookup.insert(dats);
}
}
diff --git a/plugins/SmileyAdd/src/dlgboxsubclass.cpp b/plugins/SmileyAdd/src/dlgboxsubclass.cpp
index 40fa8166b1..2bbee5dd06 100644
--- a/plugins/SmileyAdd/src/dlgboxsubclass.cpp
+++ b/plugins/SmileyAdd/src/dlgboxsubclass.cpp
@@ -22,12 +22,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
//***************************************************//
// DISCLAIMER!!!
// we are not supposed to use this object, so be aware
-typedef struct NewMessageWindowLParam
+typedef struct NewMessageWindowLParam
{
MCONTACT hContact;
int isSend;
const char *szInitialText;
-}
+}
msgData;
// this is an undocumented object!!!!!!!
// subject to change in miranda versions...!!!!!!
@@ -40,9 +40,9 @@ static HANDLE g_hHookMsgWnd = NULL;
static LRESULT CALLBACK MessageDlgSubclass(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
+// type definitions
-//type definitions
-class MsgWndData
+class MsgWndData
{
public:
HWND hwnd;
@@ -85,9 +85,9 @@ public:
MsgWndData(const MsgWndData &dsb)
{
- *this = dsb;
- dsb.hSmlBmp = NULL;
- dsb.hSmlIco = NULL;
+ *this = dsb;
+ dsb.hSmlBmp = NULL;
+ dsb.hSmlIco = NULL;
dsb.hSmlButton = NULL;
}
@@ -135,8 +135,8 @@ public:
}
ScreenToClient(GetParent(LButton), &pt);
- rect.bottom += pt.y - rect.top;
- rect.right += pt.x - rect.left;
+ rect.bottom += pt.y - rect.top;
+ rect.right += pt.x - rect.left;
rect.top = pt.y;
rect.left = pt.x;
@@ -151,24 +151,24 @@ public:
GetClassName(hwndDlg, szClassName, _countof(szClassName));
if (mir_tstrcmp(szClassName, _T("#32770")))
- return false;
+ return false;
if ((REdit = GetDlgItem(hwndDlg, MI_IDC_LOG)) != NULL) {
GetClassName(REdit, szClassName, _countof(szClassName));
- if (mir_tstrcmp(szClassName, _T("RichEdit20A")) != 0 &&
- mir_tstrcmp(szClassName, _T("RichEdit20W")) != 0 &&
- mir_tstrcmp(szClassName, _T("RICHEDIT50W")) != 0)
- return false;
+ if (mir_tstrcmp(szClassName, _T("RichEdit20A")) != 0 &&
+ mir_tstrcmp(szClassName, _T("RichEdit20W")) != 0 &&
+ mir_tstrcmp(szClassName, _T("RICHEDIT50W")) != 0)
+ return false;
}
- else return false;
+ else return false;
if ((MEdit = GetDlgItem(hwndDlg, MI_IDC_MESSAGE)) != NULL) {
GetClassName(MEdit, szClassName, _countof(szClassName));
- if (mir_tstrcmp(szClassName, _T("Edit")) != 0 &&
- mir_tstrcmp(szClassName, _T("RichEdit20A")) != 0 &&
- mir_tstrcmp(szClassName, _T("RichEdit20W")) != 0 &&
- mir_tstrcmp(szClassName, _T("RICHEDIT50W")) != 0)
- return false;
+ if (mir_tstrcmp(szClassName, _T("Edit")) != 0 &&
+ mir_tstrcmp(szClassName, _T("RichEdit20A")) != 0 &&
+ mir_tstrcmp(szClassName, _T("RichEdit20W")) != 0 &&
+ mir_tstrcmp(szClassName, _T("RICHEDIT50W")) != 0)
+ return false;
}
else return false;
@@ -177,9 +177,9 @@ public:
if ((LButton = GetDlgItem(hwndDlg, MI_IDC_ADD)) == NULL)
return false;
- if (GetDlgItem(hwndDlg, MI_IDC_NAME) == NULL)
+ if (GetDlgItem(hwndDlg, MI_IDC_NAME) == NULL)
return false;
- if ((MOK = GetDlgItem(hwndDlg, IDOK)) == NULL)
+ if ((MOK = GetDlgItem(hwndDlg, IDOK)) == NULL)
return false;
return true;
@@ -195,10 +195,10 @@ public:
bool showButtonLine;
if (IsOldSrmm()) {
- isSplit = db_get_b(NULL,"SRMsg","Split", TRUE) != 0;
+ isSplit = db_get_b(NULL, "SRMsg", "Split", TRUE) != 0;
doSmileyReplace = (isSplit || !isSend);
- doSmileyButton &= isSplit || isSend;
+ doSmileyButton &= isSplit || isSend;
showButtonLine = db_get_b(NULL, "SRMsg", "ShowButtonLine", TRUE) != 0;
}
else {
@@ -211,7 +211,7 @@ public:
if (ProtocolName[0] != 0) {
INT_PTR cap = CallProtoService(ProtocolName, PS_GETCAPS, PFLAGNUM_1, 0);
- doSmileyButton &= ((cap & (PF1_IMSEND | PF1_CHAT)) != 0);
+ doSmileyButton &= ((cap & (PF1_IMSEND | PF1_CHAT)) != 0);
doSmileyReplace &= ((cap & (PF1_IMRECV | PF1_CHAT)) != 0);
}
@@ -223,13 +223,13 @@ public:
WS_EX_LEFT | WS_EX_NOPARENTNOTIFY | WS_EX_TOPMOST,
MIRANDABUTTONCLASS,
_T("S"),
- WS_CHILD|WS_VISIBLE|WS_TABSTOP, // window style
+ WS_CHILD | WS_VISIBLE | WS_TABSTOP, // window style
rect.left, // horizontal position of window
rect.top, // vertical position of window
rect.bottom - rect.top + 1, // window width
rect.bottom - rect.top + 1, // window height
GetParent(LButton), // handle to parent or owner window
- (HMENU) IDC_SMLBUTTON, // menu handle or child identifier
+ (HMENU)IDC_SMLBUTTON, // menu handle or child identifier
NULL, // handle to application instance
NULL); // window-creation data
@@ -240,7 +240,7 @@ public:
SendMessage(hSmlButton, BM_SETIMAGE, IMAGE_BITMAP, (LPARAM)hSmlBmp);
}
else {
- hSmlIco = GetDefaultIcon();
+ hSmlIco = GetDefaultIcon();
SendMessage(hSmlButton, BM_SETIMAGE, IMAGE_ICON, (LPARAM)hSmlIco);
}
@@ -266,7 +266,7 @@ bool IsOldSrmm(void)
int UpdateSrmmDlg(WPARAM wParam, LPARAM /* lParam */)
{
WaitForSingleObject(g_hMutex, 2000);
- for (int i=0; i < g_MsgWndList.getCount(); ++i) {
+ for (int i = 0; i < g_MsgWndList.getCount(); ++i) {
if (wParam == 0 || g_MsgWndList[i]->hContact == wParam) {
SendMessage(g_MsgWndList[i]->hwnd, WM_SETREDRAW, FALSE, 0);
SendMessage(g_MsgWndList[i]->hwnd, DM_OPTIONSAPPLIED, 0, 0);
@@ -276,7 +276,7 @@ int UpdateSrmmDlg(WPARAM wParam, LPARAM /* lParam */)
ReleaseMutex(g_hMutex);
return 0;
-}
+}
//find the dialog info in the stored list
@@ -306,7 +306,7 @@ static void MsgWndDetect(HWND hwndDlg, MCONTACT hContact, msgData* datm)
char *protonam = GetContactProto(DecodeMetaContact(dat.hContact));
if (protonam) {
strncpy(dat.ProtocolName, protonam, sizeof(dat.ProtocolName));
- dat.ProtocolName[sizeof(dat.ProtocolName)-1] = 0;
+ dat.ProtocolName[sizeof(dat.ProtocolName) - 1] = 0;
}
WaitForSingleObject(g_hMutex, 2000);
@@ -316,7 +316,7 @@ static void MsgWndDetect(HWND hwndDlg, MCONTACT hContact, msgData* datm)
msgwnd = new MsgWndData(dat);
g_MsgWndList.insert(msgwnd);
}
- else
+ else
msgwnd = NULL;
ReleaseMutex(g_hMutex);
@@ -337,7 +337,7 @@ static LRESULT CALLBACK MessageDlgSubclass(HWND hwnd, UINT uMsg, WPARAM wParam,
if (dat == NULL)
return 0;
- switch(uMsg) {
+ switch (uMsg) {
case DM_OPTIONSAPPLIED:
dat->clear();
dat->CreateSmileyButton();
@@ -349,21 +349,21 @@ static LRESULT CALLBACK MessageDlgSubclass(HWND hwnd, UINT uMsg, WPARAM wParam,
GETTEXTLENGTHEX gtl;
gtl.codepage = 1200;
gtl.flags = GTL_PRECISE | GTL_NUMCHARS;
- dat->idxLastChar = (int)SendMessage(dat->REdit, EM_GETTEXTLENGTHEX, (WPARAM) &gtl, 0);
+ dat->idxLastChar = (int)SendMessage(dat->REdit, EM_GETTEXTLENGTHEX, (WPARAM)&gtl, 0);
}
break;
}
- LRESULT result = mir_callNextSubclass(hwnd, MessageDlgSubclass, uMsg, wParam, lParam);
+ LRESULT result = mir_callNextSubclass(hwnd, MessageDlgSubclass, uMsg, wParam, lParam);
if (!opt.PluginSupportEnabled)
return result;
- switch(uMsg) {
+ switch (uMsg) {
case WM_DESTROY:
WaitForSingleObject(g_hMutex, 2000);
{
int ind = g_MsgWndList.getIndex((MsgWndData*)&hwnd);
- if ( ind != -1 ) {
+ if (ind != -1) {
delete g_MsgWndList[ind];
g_MsgWndList.remove(ind);
}
@@ -374,7 +374,7 @@ static LRESULT CALLBACK MessageDlgSubclass(HWND hwnd, UINT uMsg, WPARAM wParam,
case WM_SIZE:
if (dat->doSmileyButton) {
RECT rect = dat->CalcSmileyButtonPos();
- SetWindowPos(dat->hSmlButton, NULL, rect.left, rect.top,
+ SetWindowPos(dat->hSmlButton, NULL, rect.left, rect.top,
0, 0, SWP_NOZORDER | SWP_NOSIZE | SWP_NOACTIVATE);
}
break;
@@ -430,7 +430,7 @@ static LRESULT CALLBACK MessageDlgSubclass(HWND hwnd, UINT uMsg, WPARAM wParam,
if (LOWORD(wParam) == MI_IDC_ADD && HIWORD(wParam) == BN_CLICKED && dat->doSmileyButton) {
RECT rect = dat->CalcSmileyButtonPos();
- SetWindowPos(dat->hSmlButton, NULL, rect.left, rect.top,
+ SetWindowPos(dat->hSmlButton, NULL, rect.left, rect.top,
0, 0, SWP_NOZORDER | SWP_NOSIZE | SWP_NOACTIVATE);
}
break;
@@ -442,7 +442,7 @@ static LRESULT CALLBACK MessageDlgSubclass(HWND hwnd, UINT uMsg, WPARAM wParam,
static int MsgDlgHook(WPARAM, LPARAM lParam)
{
const MessageWindowEventData *wndEvtData = (MessageWindowEventData*)lParam;
- switch(wndEvtData->uType) {
+ switch (wndEvtData->uType) {
case MSG_WINDOW_EVT_OPENING:
MsgWndDetect(wndEvtData->hwndWindow, wndEvtData->hContact, NULL);
if (wndEvtData->cbSize >= sizeof(MessageWindowEventData)) {
@@ -483,7 +483,7 @@ static LRESULT CALLBACK MsgDlgHookProcPre(int code, WPARAM wParam, LPARAM lParam
{
const CWPSTRUCT *msg = (CWPSTRUCT*)lParam;
- if (code == HC_ACTION && msg->message == WM_INITDIALOG)
+ if (code == HC_ACTION && msg->message == WM_INITDIALOG)
MsgWndDetect(msg->hwnd, NULL, (msgData*)msg->lParam);
return CallNextHookEx(g_hMessageHookPre, code, wParam, lParam);
@@ -493,12 +493,11 @@ static LRESULT CALLBACK MsgDlgHookProcPre(int code, WPARAM wParam, LPARAM lParam
void InstallDialogBoxHook(void)
{
g_hMutex = CreateMutex(NULL, FALSE, NULL);
-
g_hHookMsgWnd = HookEvent(ME_MSG_WINDOWEVENT, MsgDlgHook);
// Hook message API
if (g_hHookMsgWnd == NULL)
- g_hMessageHookPre = SetWindowsHookEx(WH_CALLWNDPROC, MsgDlgHookProcPre,
+ g_hMessageHookPre = SetWindowsHookEx(WH_CALLWNDPROC, MsgDlgHookProcPre,
NULL, GetCurrentThreadId());
}
@@ -509,7 +508,7 @@ void RemoveDialogBoxHook(void)
if (g_hMessageHookPre) UnhookWindowsHookEx(g_hMessageHookPre);
WaitForSingleObject(g_hMutex, 2000);
- for (int i=0; i<g_MsgWndList.getCount(); i++)
+ for (int i = 0; i < g_MsgWndList.getCount(); i++)
delete g_MsgWndList[i];
g_MsgWndList.destroy();
ReleaseMutex(g_hMutex);
diff --git a/plugins/SmileyAdd/src/imagecache.cpp b/plugins/SmileyAdd/src/imagecache.cpp
index 567a1b4d4f..c90d355e5f 100644
--- a/plugins/SmileyAdd/src/imagecache.cpp
+++ b/plugins/SmileyAdd/src/imagecache.cpp
@@ -38,12 +38,12 @@ static void CALLBACK timerProc(HWND, UINT, UINT_PTR, DWORD)
lastdllname.Empty();
}
- for (int i=g_imagecache.getCount()-1; i >= 0; i--)
+ for (int i = g_imagecache.getCount() - 1; i >= 0; i--)
g_imagecache[i].ProcessTimerTick(ts);
if (g_imagecache.getCount() == 0) {
g_imagecache.destroy();
- if (timerId && (timerId+1) && lastmodule == NULL) {
+ if (timerId && (timerId + 1) && lastmodule == NULL) {
KillTimer(NULL, timerId);
timerId = 0;
}
@@ -383,7 +383,7 @@ void ImageType::DrawInternal(HDC hdc, int x, int y, int sizeX, int sizeY)
ReleaseMutex(g_hMutexIm);
}
-int ImageType::GetFrameDelay(void) const
+int ImageType::GetFrameDelay(void) const
{
return ((long*)m_pPropertyItem->value)[m_nCurrentFrame];
}
@@ -543,7 +543,7 @@ ImageBase* AddCacheImage(const CMString& file, int index)
if (ind == -1)
return NULL;
- CMString ext = file.Mid(ind+1);
+ CMString ext = file.Mid(ind + 1);
ext.MakeLower();
if (ext == _T("dll") || ext == _T("exe"))
img = opt.HQScaling ? (ImageBase*)new ImageType(id, file, index, icoDll) : (ImageBase*)new IconType(id, file, index, icoDll);
diff --git a/plugins/SmileyAdd/src/main.cpp b/plugins/SmileyAdd/src/main.cpp
index 1036129569..1c59ae7597 100644
--- a/plugins/SmileyAdd/src/main.cpp
+++ b/plugins/SmileyAdd/src/main.cpp
@@ -131,7 +131,6 @@ extern "C" __declspec(dllexport) int Unload(void)
DestroyHookableEvent(hEvent1);
RichEditData_Destroy();
- DestroyAniSmileys();
g_SmileyCategories.ClearAll();
g_SmileyPackCStore.ClearAndFreeAll();
diff --git a/plugins/SmileyAdd/src/smileys.cpp b/plugins/SmileyAdd/src/smileys.cpp
index 20af44c112..8aafb54843 100644
--- a/plugins/SmileyAdd/src/smileys.cpp
+++ b/plugins/SmileyAdd/src/smileys.cpp
@@ -23,11 +23,35 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
SmileyPackListType g_SmileyPacks;
SmileyCategoryListType g_SmileyCategories;
+static HWND hwndHidden = NULL;
+
+static void CALLBACK timerProc(HWND, UINT, UINT_PTR param, DWORD)
+{
+ SmileyType *pType = (SmileyType*)param;
+ pType->MoveToNextFrame();
+}
+
+// these two functions must be called from the main thread
+static void CALLBACK sttStartTimer(PVOID obj)
+{
+ if (hwndHidden == NULL)
+ hwndHidden = CreateWindowEx(0, _T("STATIC"), NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL);
+
+ SmileyType *pType = (SmileyType*)obj;
+ pType->SetFrameDelay();
+}
+
+static void CALLBACK sttStopTimer(PVOID obj)
+{
+ KillTimer(hwndHidden, (DWORD_PTR)obj);
+}
+
//
// SmileyType
//
-SmileyType::SmileyType(void)
+SmileyType::SmileyType(void) :
+ m_arSmileys(10, PtrKeySortT)
{
m_SmileyIcon = NULL;
m_xepimg = NULL;
@@ -39,19 +63,65 @@ SmileyType::SmileyType(void)
SmileyType::~SmileyType()
{
- if (m_xepimg) m_xepimg->Release();
- m_xepimg = NULL;
+ if (m_xepimg) {
+ m_xepimg->Release();
+ m_xepimg = NULL;
+ }
- if (m_SmileyIcon != NULL) DestroyIcon(m_SmileyIcon);
- m_SmileyIcon = NULL;
+ if (m_SmileyIcon != NULL) {
+ DestroyIcon(m_SmileyIcon);
+ m_SmileyIcon = NULL;
+ }
}
+void SmileyType::AddObject(ISmileyBase *pObject)
+{
+ if (m_arSmileys.getCount() == 0) {
+ if (m_xepimg == NULL)
+ m_xepimg = AddCacheImage(m_filepath, m_index);
+ CallFunctionAsync(sttStartTimer, this);
+ }
+
+ m_arSmileys.insert(pObject);
+}
+
+void SmileyType::RemoveObject(ISmileyBase *pObject)
+{
+ int idx = m_arSmileys.getIndex(pObject);
+ if (idx == -1)
+ return;
+
+ m_arSmileys.remove(idx);
+ if (m_arSmileys.getCount() == 0)
+ CallFunctionAsync(sttStopTimer, this);
+}
+
+void SmileyType::SetFrameDelay()
+{
+ int iFrameDelay = (m_xepimg == NULL) ? 0 : m_xepimg->GetFrameDelay();
+ if (iFrameDelay <= 0)
+ KillTimer(hwndHidden, (DWORD_PTR)this);
+ else
+ SetTimer(hwndHidden, (DWORD_PTR)this, iFrameDelay*10, timerProc);
+}
+
+void SmileyType::MoveToNextFrame()
+{
+ m_index = m_xepimg->SelectNextFrame(m_index);
+
+ for (int i = 0; i < m_arSmileys.getCount(); i++)
+ m_arSmileys[i]->Draw();
+
+ SetFrameDelay(); // reset timer
+}
HICON SmileyType::GetIcon(void)
{
if (m_SmileyIcon == NULL) {
- ImageBase* img = CreateCachedImage();
- if (!img) return NULL;
+ ImageBase *img = CreateCachedImage();
+ if (!img)
+ return NULL;
+
img->SelectFrame(m_index);
m_SmileyIcon = img->GetIcon();
img->Release();
@@ -59,38 +129,33 @@ HICON SmileyType::GetIcon(void)
return m_SmileyIcon;
}
-
HICON SmileyType::GetIconDup(void)
{
- ImageBase* img = CreateCachedImage();
+ ImageBase *img = CreateCachedImage();
img->SelectFrame(m_index);
HICON hIcon = img->GetIcon();
img->Release();
return hIcon;
}
-
-bool SmileyType::LoadFromImage(IStream* pStream)
+bool SmileyType::LoadFromImage(IStream *pStream)
{
- if (m_xepimg) m_xepimg->Release();
+ if (m_xepimg)
+ m_xepimg->Release();
CMString name;
m_xepimg = new ImageType(0, name, pStream);
-
return true;
}
-
-bool SmileyType::LoadFromResource(const CMString& file, const int index)
+bool SmileyType::LoadFromResource(const CMString &file, const int index)
{
m_index = index;
m_filepath = file;
-
return true;
}
-
-void SmileyType::GetSize(SIZE& size)
+void SmileyType::GetSize(SIZE &size)
{
if (m_size.cy == 0) {
ImageBase* img = CreateCachedImage();
@@ -102,7 +167,6 @@ void SmileyType::GetSize(SIZE& size)
size = m_size;
}
-
ImageBase* SmileyType::CreateCachedImage(void)
{
if (m_xepimg) {
@@ -112,14 +176,12 @@ ImageBase* SmileyType::CreateCachedImage(void)
return AddCacheImage(m_filepath, m_index);
}
-
void SmileyType::SetImList(HIMAGELIST hImLst, long i)
{
if (m_xepimg) m_xepimg->Release();
m_xepimg = new ImageListItemType(0, hImLst, i);
}
-
HBITMAP SmileyType::GetBitmap(COLORREF bkgClr, int sizeX, int sizeY)
{
ImageBase* img = CreateCachedImage();
@@ -131,7 +193,6 @@ HBITMAP SmileyType::GetBitmap(COLORREF bkgClr, int sizeX, int sizeY)
return hBmp;
}
-
//
// SmileyPackType
//
@@ -147,23 +208,18 @@ SmileyType* SmileyPackType::GetSmiley(unsigned index)
return (index < (unsigned)m_SmileyList.getCount()) ? &m_SmileyList[index] : NULL;
}
-
static DWORD_PTR ConvertServiceParam(MCONTACT hContact, const TCHAR *param)
{
- DWORD_PTR ret;
if (param == NULL)
- ret = 0;
- else if (mir_tstrcmpi(_T("hContact"), param) == 0)
- ret = (DWORD_PTR)hContact;
- else if (_istdigit(*param))
- ret = _ttoi(param);
- else
- ret = (DWORD_PTR)param;
+ return 0;
+ if (mir_tstrcmpi(_T("hContact"), param) == 0)
+ return hContact;
+ if (_istdigit(*param))
+ return _ttoi(param);
- return ret;
+ return (DWORD_PTR)param;
}
-
void SmileyType::CallSmileyService(MCONTACT hContact)
{
_TPattern *srvsplit = _TPattern::compile(_T("(.*)\\|(.*)\\|(.*)"));
diff --git a/plugins/SmileyAdd/src/smileys.h b/plugins/SmileyAdd/src/smileys.h
index a72de44491..298b0ae036 100644
--- a/plugins/SmileyAdd/src/smileys.h
+++ b/plugins/SmileyAdd/src/smileys.h
@@ -31,6 +31,8 @@ const unsigned SoundSmiley = 16;
class SmileyType
{
+ LIST<ISmileyBase> m_arSmileys;
+
protected:
unsigned m_flags;
int m_index;
@@ -51,7 +53,7 @@ public:
CMString m_ToolText;
CMString m_InsertText;
- SmileyType(void);
+ SmileyType();
~SmileyType();
const CMString& GetTriggerText(void) const { return m_TriggerText; }
@@ -71,12 +73,17 @@ public:
ImageBase* CreateCachedImage(void);
void GetSize(SIZE& size);
- int GetStaticFrame(void) const { return m_index; }
HICON GetIcon(void);
HICON GetIconDup(void);
HBITMAP GetBitmap(COLORREF bkgClr, int sizeX, int sizeY);
+ void SetFrameDelay(void);
+ void MoveToNextFrame(void);
+
+ void AddObject(ISmileyBase *pObject);
+ void RemoveObject(ISmileyBase *pObject);
+
void CallSmileyService(MCONTACT hContact);
void SetHidden(bool hid) { SetFlagsBit(HiddenSmiley, hid); }
diff --git a/plugins/SmileyAdd/src/stdafx.h b/plugins/SmileyAdd/src/stdafx.h
index c968264936..79677a8c68 100644
--- a/plugins/SmileyAdd/src/stdafx.h
+++ b/plugins/SmileyAdd/src/stdafx.h
@@ -77,13 +77,13 @@ typedef WCMatcher _TMatcher;
#include "resource.h"
#include "version.h"
#include "imagecache.h"
+#include "SmileyBase.h"
#include "smileys.h"
#include "customsmiley.h"
#include "services.h"
#include "options.h"
#include "download.h"
#include "anim.h"
-#include "SmileyBase.h"
#include "smileyroutines.h"
#include "smltool.h"
@@ -185,7 +185,6 @@ void ProcessAllInputAreas(bool restoreText);
void RichEditData_Destroy(void);
void CloseSmileys(void);
-void DestroyAniSmileys(void);
void UrlDecode(char* str);
diff --git a/plugins/SmileyAdd/src/version.h b/plugins/SmileyAdd/src/version.h
index 9703dfe0d5..83482d4025 100644
--- a/plugins/SmileyAdd/src/version.h
+++ b/plugins/SmileyAdd/src/version.h
@@ -1,14 +1,14 @@
#define __MAJOR_VERSION 0
#define __MINOR_VERSION 2
-#define __RELEASE_NUM 3
-#define __BUILD_NUM 18
+#define __RELEASE_NUM 4
+#define __BUILD_NUM 1
#include <stdver.h>
-#define __PLUGIN_NAME "SmileyAdd"
-#define __FILENAME "SmileyAdd.dll"
-#define __DESCRIPTION "Smiley support for Miranda NG."
-#define __AUTHOR "Peacow, nightwish, bid, borkra"
-#define __AUTHOREMAIL "borkra@miranda-im.org"
-#define __AUTHORWEB "http://miranda-ng.org/p/SmileyAdd/"
-#define __COPYRIGHT "© 2012-16 Miranda NG Team, 2004-12 Boris Krasnovskiy, portions by Rein-Peter de Boer"
+#define __PLUGIN_NAME "SmileyAdd"
+#define __FILENAME "SmileyAdd.dll"
+#define __DESCRIPTION "Smiley support for Miranda NG."
+#define __AUTHOR "Peacow, nightwish, bid, borkra"
+#define __AUTHOREMAIL "borkra@miranda-im.org"
+#define __AUTHORWEB "http://miranda-ng.org/p/SmileyAdd/"
+#define __COPYRIGHT "© 2012-16 Miranda NG Team, 2004-12 Boris Krasnovskiy, portions by Rein-Peter de Boer"