diff options
author | George Hazan <george.hazan@gmail.com> | 2014-01-16 14:01:25 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2014-01-16 14:01:25 +0000 |
commit | a39c5799008f43603593198980f9dae818f11cc3 (patch) | |
tree | f19575afc7e6bbe81e1ae804b94e05ce1cb2f184 /src | |
parent | e5ea3aa43eddf6ec4bfb86e7c39e6898e21c6490 (diff) |
- StdChat specific icons management moved back to StdChat;
- fix for chat custom menus;
git-svn-id: http://svn.miranda-ng.org/main/trunk@7680 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'src')
-rw-r--r-- | src/core/stdchat/src/chat.h | 9 | ||||
-rw-r--r-- | src/core/stdchat/src/log.cpp | 8 | ||||
-rw-r--r-- | src/core/stdchat/src/main.cpp | 26 | ||||
-rw-r--r-- | src/core/stdchat/src/window.cpp | 8 | ||||
-rw-r--r-- | src/modules/chat/chat_svc.cpp | 12 | ||||
-rw-r--r-- | src/modules/chat/manager.cpp | 78 |
6 files changed, 58 insertions, 83 deletions
diff --git a/src/core/stdchat/src/chat.h b/src/core/stdchat/src/chat.h index 9f7e9cba7a..c8433da7ef 100644 --- a/src/core/stdchat/src/chat.h +++ b/src/core/stdchat/src/chat.h @@ -79,7 +79,12 @@ struct TABLIST TABLIST *next;
};
-struct MODULEINFO : public GCModuleInfoBase {};
+struct MODULEINFO : public GCModuleInfoBase
+{
+ int OnlineIconIndex;
+ int OfflineIconIndex;
+};
+
struct SESSION_INFO : public GCSessionInfoBase {};
struct LOGSTREAMDATA : public GCLogStreamDataBase {};
@@ -95,6 +100,7 @@ extern GlobalLogSettings g_Settings; extern SESSION_INFO g_TabSession;
extern TABLIST *g_TabList;
extern HMENU g_hMenu;
+extern HIMAGELIST hIconsList;
extern HINSTANCE g_hInst;
extern BOOL SmileyAddInstalled, PopupInstalled;
@@ -145,7 +151,6 @@ INT_PTR CALLBACK DlgProcColorToolWindow(HWND hwndDlg, UINT msg, WPARAM wParam, L // log.c
void Log_StreamInEvent(HWND hwndDlg, LOGINFO* lin, SESSION_INFO *si, BOOL bRedraw, BOOL bPhaseTwo);
void ValidateFilename (TCHAR * filename);
-TCHAR* MakeTimeStamp(TCHAR* pszStamp, time_t time);
char* Log_CreateRtfHeader(MODULEINFO * mi);
// window.c
diff --git a/src/core/stdchat/src/log.cpp b/src/core/stdchat/src/log.cpp index 1942fe9a3f..10b6f8097e 100644 --- a/src/core/stdchat/src/log.cpp +++ b/src/core/stdchat/src/log.cpp @@ -23,14 +23,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // The code for streaming the text is to a large extent copied from
// the srmm module and then modified to fit the chat module.
-TCHAR* MakeTimeStamp( TCHAR* pszStamp, time_t time)
-{
- static TCHAR szTime[30];
- if ( !_tcsftime(szTime, SIZEOF(szTime)-1, pszStamp, localtime(&time)))
- _tcsncpy(szTime, TranslateT("<invalid>"), SIZEOF(szTime));
- return szTime;
-}
-
static DWORD CALLBACK Log_StreamCallback(DWORD_PTR dwCookie, LPBYTE pbBuff, LONG cb, LONG * pcb)
{
LOGSTREAMDATA *lstrdat = (LOGSTREAMDATA *) dwCookie;
diff --git a/src/core/stdchat/src/main.cpp b/src/core/stdchat/src/main.cpp index eb345b53ab..18e16c34cd 100644 --- a/src/core/stdchat/src/main.cpp +++ b/src/core/stdchat/src/main.cpp @@ -31,6 +31,7 @@ HINSTANCE g_hInst; int hLangpack;
BOOL SmileyAddInstalled = FALSE, PopupInstalled = FALSE;
+HIMAGELIST hIconsList;
GlobalLogSettings g_Settings;
@@ -69,9 +70,23 @@ extern "C" __declspec(dllexport) const MUUID MirandaInterfaces[] = {MIID_CHAT, M int OnShutdown(WPARAM, LPARAM)
{
TabM_RemoveAll();
+ ImageList_Destroy(hIconsList);
return 0;
}
+static void OnCreateModule(MODULEINFO *mi)
+{
+ mi->OnlineIconIndex = ImageList_AddIcon(hIconsList, LoadSkinnedProtoIcon(mi->pszModule, ID_STATUS_ONLINE));
+ mi->hOnlineIcon = ImageList_GetIcon(hIconsList, mi->OnlineIconIndex, ILD_TRANSPARENT);
+ mi->hOnlineTalkIcon = ImageList_GetIcon(hIconsList, mi->OnlineIconIndex, ILD_TRANSPARENT | INDEXTOOVERLAYMASK(1));
+ ImageList_AddIcon(hIconsList, mi->hOnlineTalkIcon);
+
+ mi->OfflineIconIndex = ImageList_AddIcon(hIconsList, LoadSkinnedProtoIcon(mi->pszModule, ID_STATUS_OFFLINE));
+ mi->hOfflineIcon = ImageList_GetIcon(hIconsList, mi->OfflineIconIndex, ILD_TRANSPARENT);
+ mi->hOfflineTalkIcon = ImageList_GetIcon(hIconsList, mi->OfflineIconIndex, ILD_TRANSPARENT | INDEXTOOVERLAYMASK(1));
+ ImageList_AddIcon(hIconsList, mi->hOfflineTalkIcon);
+}
+
static void OnAddLog(SESSION_INFO *si, int isOk)
{
if (isOk && si->hWnd) {
@@ -327,13 +342,10 @@ void LoadIcons(void) LoadLogIcons();
- pci->hImageList = ImageList_Create(GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), ILC_COLOR32 | ILC_MASK, 0, 3);
- pci->hIconsList = ImageList_Create(GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), ILC_COLOR32 | ILC_MASK, 0, 100);
- ImageList_AddIcon(pci->hIconsList, LoadSkinnedIcon(SKINICON_EVENT_MESSAGE));
- ImageList_AddIcon(pci->hIconsList, LoadIconEx("overlay", FALSE));
- ImageList_SetOverlayImage(pci->hIconsList, 1, 1);
- ImageList_AddIcon(pci->hImageList, (HICON)LoadImage(g_hInst, MAKEINTRESOURCE(IDI_BLANK), IMAGE_ICON, 0, 0, 0));
- ImageList_AddIcon(pci->hImageList, (HICON)LoadImage(g_hInst, MAKEINTRESOURCE(IDI_BLANK), IMAGE_ICON, 0, 0, 0));
+ hIconsList = ImageList_Create(GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), ILC_COLOR32 | ILC_MASK, 0, 100);
+ ImageList_AddIcon(hIconsList, LoadSkinnedIcon(SKINICON_EVENT_MESSAGE));
+ ImageList_AddIcon(hIconsList, LoadIconEx("overlay", FALSE));
+ ImageList_SetOverlayImage(hIconsList, 1, 1);
}
/////////////////////////////////////////////////////////////////////////////////////////
diff --git a/src/core/stdchat/src/window.cpp b/src/core/stdchat/src/window.cpp index b0bdffc27a..181dfa24e2 100644 --- a/src/core/stdchat/src/window.cpp +++ b/src/core/stdchat/src/window.cpp @@ -872,9 +872,10 @@ static LRESULT CALLBACK TabSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, LPAR s = (SESSION_INFO*)tc.lParam;
if (s) {
BOOL bOnline = db_get_w(s->hContact, s->pszModule, "Status", ID_STATUS_OFFLINE) == ID_STATUS_ONLINE ? TRUE : FALSE;
+ MODULEINFO *mi = pci->MM_FindModule(s->pszModule);
bDragging = TRUE;
iBeginIndex = i;
- ImageList_BeginDrag(pci->hIconsList, bOnline ? (pci->MM_FindModule(s->pszModule))->OnlineIconIndex : (pci->MM_FindModule(s->pszModule))->OfflineIconIndex, 8, 8);
+ ImageList_BeginDrag(hIconsList, bOnline ? mi->OnlineIconIndex : mi->OfflineIconIndex, 8, 8);
ImageList_DragEnter(hwnd, tci.pt.x, tci.pt.y);
SetCapture(hwnd);
}
@@ -1150,13 +1151,10 @@ INT_PTR CALLBACK RoomWndProc(HWND hwndDlg,UINT uMsg,WPARAM wParam,LPARAM lParam) SendDlgItemMessage(hwndDlg, IDC_LOG, EM_LIMITTEXT, (WPARAM)sizeof(TCHAR)* 0x7FFFFFFF, 0);
SendDlgItemMessage(hwndDlg, IDC_LOG, EM_SETOLECALLBACK, 0, (LPARAM)& reOleCallback);
- // RichUtil_SubClass(GetDlgItem(hwndDlg, IDC_MESSAGE));
- // RichUtil_SubClass(GetDlgItem(hwndDlg, IDC_LOG));
-
si->hwndStatus = CreateWindowEx(0, STATUSCLASSNAME, NULL, WS_CHILD | WS_VISIBLE | SBARS_SIZEGRIP | SBT_TOOLTIPS, 0, 0, 0, 0, hwndDlg, NULL, g_hInst, NULL);
SendMessage(si->hwndStatus, SB_SETMINHEIGHT, GetSystemMetrics(SM_CYSMICON), 0);
TabCtrl_SetMinTabWidth(GetDlgItem(hwndDlg, IDC_TAB), 80);
- TabCtrl_SetImageList(GetDlgItem(hwndDlg, IDC_TAB), pci->hIconsList);
+ TabCtrl_SetImageList(GetDlgItem(hwndDlg, IDC_TAB), hIconsList);
// enable tooltips
si->iOldItemID = -1;
diff --git a/src/modules/chat/chat_svc.cpp b/src/modules/chat/chat_svc.cpp index 4e8f9b114f..a89d70cc3e 100644 --- a/src/modules/chat/chat_svc.cpp +++ b/src/modules/chat/chat_svc.cpp @@ -153,18 +153,6 @@ static INT_PTR Service_Register(WPARAM wParam, LPARAM lParam) memcpy(mi->crColors, gcr->pColors, sizeof(COLORREF)* gcr->nColors);
}
- mi->OnlineIconIndex = ImageList_AddIcon(ci.hIconsList, LoadSkinnedProtoIcon(gcr->pszModule, ID_STATUS_ONLINE));
- mi->hOnlineIcon = ImageList_GetIcon(ci.hIconsList, mi->OnlineIconIndex, ILD_TRANSPARENT);
-
- mi->hOnlineTalkIcon = ImageList_GetIcon(ci.hIconsList, mi->OnlineIconIndex, ILD_TRANSPARENT | INDEXTOOVERLAYMASK(1));
- ImageList_AddIcon(ci.hIconsList, mi->hOnlineTalkIcon);
-
- mi->OfflineIconIndex = ImageList_AddIcon(ci.hIconsList, LoadSkinnedProtoIcon(gcr->pszModule, ID_STATUS_OFFLINE));
- mi->hOfflineIcon = ImageList_GetIcon(ci.hIconsList, mi->OfflineIconIndex, ILD_TRANSPARENT);
-
- mi->hOfflineTalkIcon = ImageList_GetIcon(ci.hIconsList, mi->OfflineIconIndex, ILD_TRANSPARENT | INDEXTOOVERLAYMASK(1));
- ImageList_AddIcon(ci.hIconsList, mi->hOfflineTalkIcon);
-
mi->pszHeader = Log_CreateRtfHeader(mi);
CheckColorsInModule((char*)gcr->pszModule);
diff --git a/src/modules/chat/manager.cpp b/src/modules/chat/manager.cpp index d2f50ba864..488b038a7d 100644 --- a/src/modules/chat/manager.cpp +++ b/src/modules/chat/manager.cpp @@ -385,7 +385,6 @@ static USERINFO* SM_GetUserFromIndex(const TCHAR *pszID, const char *pszModule, return NULL;
}
-
STATUSINFO* SM_AddStatus(const TCHAR *pszID, const char *pszModule, const TCHAR *pszStatus)
{
if (!pszID || !pszModule)
@@ -847,55 +846,40 @@ static char* SM_GetUsers(SESSION_INFO *si) static MODULEINFO* MM_AddModule(const char *pszModule)
{
- if (!pszModule)
+ if (pszModule == NULL)
return NULL;
- if (!ci.MM_FindModule(pszModule)) {
- MODULEINFO *node = (MODULEINFO*)mir_alloc(sizeof(MODULEINFO));
- ZeroMemory(node, sizeof(MODULEINFO));
- node->pszModule = (char*)mir_alloc(lstrlenA(pszModule) + 1);
- lstrcpyA(node->pszModule, pszModule);
+ if (ci.MM_FindModule(pszModule))
+ return NULL;
- if (m_ModList == NULL) // list is empty
- {
- m_ModList = node;
- node->next = NULL;
- }
- else {
- node->next = m_ModList;
- m_ModList = node;
- }
- return node;
+ MODULEINFO *node = (MODULEINFO*)mir_calloc(ci.cbModuleInfo);
+ replaceStr(node->pszModule, pszModule);
+ if (ci.OnCreateModule)
+ ci.OnCreateModule(node);
+
+ if (m_ModList == NULL) { // list is empty
+ m_ModList = node;
+ node->next = NULL;
}
- return FALSE;
+ else {
+ node->next = m_ModList;
+ m_ModList = node;
+ }
+ return node;
}
static void MM_IconsChanged(void)
{
- ImageList_ReplaceIcon(ci.hIconsList, 0, LoadSkinnedIcon(SKINICON_EVENT_MESSAGE));
- ImageList_ReplaceIcon(ci.hIconsList, 1, LoadIconEx("overlay", FALSE));
-
MODULEINFO *pTemp = m_ModList;
while (pTemp != NULL) {
- pTemp->OnlineIconIndex = ImageList_ReplaceIcon(ci.hIconsList, pTemp->OnlineIconIndex, LoadSkinnedProtoIcon(pTemp->pszModule, ID_STATUS_ONLINE));
- pTemp->OfflineIconIndex = ImageList_ReplaceIcon(ci.hIconsList, pTemp->OfflineIconIndex, LoadSkinnedProtoIcon(pTemp->pszModule, ID_STATUS_OFFLINE));
-
- if (pTemp->hOfflineIcon)
- DestroyIcon(pTemp->hOfflineIcon);
- if (pTemp->hOnlineIcon)
- DestroyIcon(pTemp->hOnlineIcon);
- if (pTemp->hOnlineTalkIcon)
- DestroyIcon(pTemp->hOnlineTalkIcon);
- if (pTemp->hOfflineTalkIcon)
- DestroyIcon(pTemp->hOfflineTalkIcon);
- pTemp->hOfflineIcon = ImageList_GetIcon(ci.hIconsList, pTemp->OfflineIconIndex, ILD_TRANSPARENT);
- pTemp->hOnlineIcon = ImageList_GetIcon(ci.hIconsList, pTemp->OnlineIconIndex, ILD_TRANSPARENT);
-
- pTemp->hOnlineTalkIcon = ImageList_GetIcon(ci.hIconsList, pTemp->OnlineIconIndex, ILD_TRANSPARENT | INDEXTOOVERLAYMASK(1));
- ImageList_ReplaceIcon(ci.hIconsList, pTemp->OnlineIconIndex + 1, pTemp->hOnlineTalkIcon);
-
- pTemp->hOfflineTalkIcon = ImageList_GetIcon(ci.hIconsList, pTemp->OfflineIconIndex, ILD_TRANSPARENT | INDEXTOOVERLAYMASK(1));
- ImageList_ReplaceIcon(ci.hIconsList, pTemp->OfflineIconIndex + 1, pTemp->hOfflineTalkIcon);
+ Safe_DestroyIcon(pTemp->hOnlineIcon);
+ Safe_DestroyIcon(pTemp->hOfflineIcon);
+ Safe_DestroyIcon(pTemp->hOnlineTalkIcon);
+ Safe_DestroyIcon(pTemp->hOfflineTalkIcon);
+
+ if (ci.OnCreateModule) // recreate icons
+ ci.OnCreateModule(pTemp);
+
pTemp = pTemp->next;
}
}
@@ -945,14 +929,10 @@ static BOOL MM_RemoveAll(void) mir_free(m_ModList->pszHeader);
mir_free(m_ModList->crColors);
- if (m_ModList->hOfflineIcon)
- DestroyIcon(m_ModList->hOfflineIcon);
- if (m_ModList->hOnlineIcon)
- DestroyIcon(m_ModList->hOnlineIcon);
- if (m_ModList->hOnlineTalkIcon)
- DestroyIcon(m_ModList->hOnlineTalkIcon);
- if (m_ModList->hOfflineTalkIcon)
- DestroyIcon(m_ModList->hOfflineTalkIcon);
+ Safe_DestroyIcon(m_ModList->hOnlineIcon);
+ Safe_DestroyIcon(m_ModList->hOfflineIcon);
+ Safe_DestroyIcon(m_ModList->hOnlineTalkIcon);
+ Safe_DestroyIcon(m_ModList->hOfflineTalkIcon);
mir_free(m_ModList);
m_ModList = pLast;
@@ -1482,7 +1462,7 @@ INT_PTR SvcGetChatManager(WPARAM, LPARAM lParam) {
LoadChatModule();
- memset(PBYTE(&ci) + offsetof(CHAT_MANAGER, OnSessionDblClick), 0, sizeof(CHAT_MANAGER) - offsetof(CHAT_MANAGER, OnSessionDblClick));
+ memset(PBYTE(&ci) + offsetof(CHAT_MANAGER, OnCreateModule), 0, sizeof(CHAT_MANAGER)-offsetof(CHAT_MANAGER, OnCreateModule));
ci.pSettings = (GlobalLogSettingsBase*)lParam;
OptionsInit();
return (INT_PTR)&ci;
|