diff options
author | George Hazan <george.hazan@gmail.com> | 2012-06-17 12:44:02 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2012-06-17 12:44:02 +0000 |
commit | f673f034c2fef25e932a12fbd5e2772f90c75e6d (patch) | |
tree | aeaac57c13fd2a23e47e437d804957d67e5413ee /plugins/Clist_mw/cluiservices.cpp | |
parent | bce08282b66209eb482726a7ec6c89083db327ac (diff) |
Clist_mw & Clist_modern renamed
git-svn-id: http://svn.miranda-ng.org/main/trunk@455 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/Clist_mw/cluiservices.cpp')
-rw-r--r-- | plugins/Clist_mw/cluiservices.cpp | 176 |
1 files changed, 176 insertions, 0 deletions
diff --git a/plugins/Clist_mw/cluiservices.cpp b/plugins/Clist_mw/cluiservices.cpp new file mode 100644 index 0000000000..f75fbc9dac --- /dev/null +++ b/plugins/Clist_mw/cluiservices.cpp @@ -0,0 +1,176 @@ +/*
+
+Miranda IM: the free IM client for Microsoft* Windows*
+
+Copyright 2000-2003 Miranda ICQ/IM project,
+all portions of this codebase are copyrighted to the people
+listed in contributors.txt.
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+#include "commonheaders.h"
+#include "m_clc.h"
+#include "m_clui.h"
+
+extern int CreateTimerForConnectingIcon(WPARAM,LPARAM);
+
+void FreeProtocolData( void )
+{
+ //free protocol data
+ int nPanel;
+ int nParts = SendMessage(pcli->hwndStatus,SB_GETPARTS,0,0);
+ for (nPanel = 0;nPanel<nParts;nPanel++)
+ {
+ ProtocolData *PD;
+ PD = (ProtocolData *)SendMessage(pcli->hwndStatus,SB_GETTEXT,(WPARAM)nPanel,(LPARAM)0);
+ if (PD != NULL && !IsBadCodePtr(( FARPROC )PD)) {
+ SendMessage(pcli->hwndStatus,SB_SETTEXT,(WPARAM)nPanel|SBT_OWNERDRAW,(LPARAM)0);
+ if (PD->RealName) mir_free(PD->RealName);
+ if (PD) mir_free(PD);
+} } }
+
+void CluiProtocolStatusChanged(int parStatus, const char* szProto)
+{
+ int protoCount,i;
+ PROTOACCOUNT **accs;
+ int *partWidths,partCount;
+ int borders[3];
+ int flags;
+ int FirstIconOffset;
+
+ if ( pcli->hwndStatus == 0 )
+ return;
+
+ FirstIconOffset = DBGetContactSettingDword(NULL,"CLUI","FirstIconOffset",0);
+
+ ProtoEnumAccounts( &protoCount, &accs );
+ if ( protoCount == 0 )
+ return;
+
+ OutputDebugStringA("CluiProtocolStatusChanged");
+ OutputDebugStringA("\r\n");
+ FreeProtocolData();
+
+ SendMessage(pcli->hwndStatus,SB_GETBORDERS,0,(LPARAM)&borders);
+
+ SendMessage(pcli->hwndStatus,SB_SETBKCOLOR,0,DBGetContactSettingDword(0,"CLUI","SBarBKColor",CLR_DEFAULT));
+ partWidths = (int*)alloca((protoCount+1)*sizeof(int));
+ //partWidths[0] = FirstIconOffset;
+ if (DBGetContactSettingByte(NULL,"CLUI","UseOwnerDrawStatusBar",0)||DBGetContactSettingByte(NULL,"CLUI","EqualSections",1))
+ {
+ RECT rc;
+ int toshow, part;
+
+ SendMessage(pcli->hwndStatus,WM_SIZE,0,0);
+ GetClientRect(pcli->hwndStatus,&rc);
+ rc.right -= borders[0]*2;
+ toshow = 0;
+ for (i = 0;i<protoCount;i++)
+ {
+ if ( !pcli->pfnGetProtocolVisibility( accs[i]->szModuleName ))
+ continue;
+
+ toshow++;
+ }
+
+ if (toshow>0)
+ {
+ for (part = 0,i = 0;i<protoCount;i++)
+ {
+ if ( !pcli->pfnGetProtocolVisibility( accs[i]->szModuleName ))
+ continue;
+
+ partWidths[part] = ((part+1)*(rc.right/toshow))-(borders[2]>>1);
+ //partWidths[part] = 40*part+40;
+ part++;
+ }
+ //partCount = part;
+ }
+ partCount = toshow;
+
+ }
+ else {
+ HDC hdc;
+ SIZE textSize;
+ BYTE showOpts = DBGetContactSettingByte(NULL,"CLUI","SBarShow",5);
+ DWORD extraspace = DBGetContactSettingDword(NULL,"StatusBar","BkExtraSpace",0);
+ DWORD startoffset = DBGetContactSettingDword(NULL,"StatusBar","FirstIconOffset",0);
+ int x;
+
+ hdc = GetDC(pcli->hwndStatus);
+
+ for (partCount = 0,i = 0;i<protoCount;i++) { //count down since built in ones tend to go at the end
+ int ind = pcli->pfnGetAccountIndexByPos(i);
+ if (ind < 0)
+ continue;
+
+ if (!pcli->pfnGetProtocolVisibility(accs[ind]->szModuleName))
+ continue;
+
+ x = 2;
+ if (showOpts & 1) x += GetSystemMetrics(SM_CXSMICON);
+ if (showOpts & 2) {
+ TCHAR szName[64];
+ mir_sntprintf(szName, SIZEOF(szName), _T("%s%s"), accs[ind]->tszAccountName, showOpts&4 ? _T(" ") : _T(""));
+ GetTextExtentPoint32(hdc, szName, (int)_tcslen(szName), &textSize);
+ x += textSize.cx;
+ }
+ if (showOpts & 4) {
+ int status = CallProtoService(accs[ind]->szModuleName, PS_GETSTATUS, 0, 0);
+ TCHAR *szStatus = pcli->pfnGetStatusModeDescription(status, 0);
+ if (!szStatus)
+ szStatus = _T("");
+ GetTextExtentPoint32(hdc, szStatus, (int)_tcslen(szStatus), &textSize);
+ x += textSize.cx;
+ }
+ if (showOpts&6) x += 2;
+ partWidths[partCount] = (partCount?partWidths[partCount-1]:startoffset)+x+extraspace;
+ partCount++;
+ }
+ ReleaseDC(pcli->hwndStatus,hdc);
+ }
+ if (partCount == 0) {
+ SendMessage(pcli->hwndStatus,SB_SIMPLE,TRUE,0);
+ return;
+ }
+ SendMessage(pcli->hwndStatus,SB_SIMPLE,FALSE,0);
+
+ partWidths[partCount-1] = -1;
+
+ SendMessage(pcli->hwndStatus,SB_SETMINHEIGHT,GetSystemMetrics(SM_CYSMICON)+2,0);
+ SendMessage(pcli->hwndStatus,SB_SETPARTS,partCount,(LPARAM)partWidths);
+
+ flags = SBT_OWNERDRAW;
+ if ( !DBGetContactSettingByte(NULL, "CLUI", "SBarBevel", 1))
+ flags |= SBT_NOBORDERS;
+
+ for (partCount = 0, i = 0; i<protoCount; i++) { //count down since built in ones tend to go at the end
+ int ind = pcli->pfnGetAccountIndexByPos(i);
+ if (ind < 0) continue;
+
+ if (!pcli->pfnGetProtocolVisibility(accs[ind]->szModuleName))
+ continue;
+
+ ProtocolData *PD = (ProtocolData*)mir_alloc(sizeof(ProtocolData));
+ PD->RealName = mir_strdup(accs[ind]->szModuleName);
+ PD->protopos = accs[ind]->iOrder;
+
+ SendMessage(pcli->hwndStatus, SB_SETTEXT, partCount++ | flags, (LPARAM)PD);
+ }
+
+ CreateTimerForConnectingIcon(parStatus, (LPARAM)szProto);
+ InvalidateRect(pcli->hwndStatus, NULL, FALSE);
+ return;
+}
|