diff options
Diffstat (limited to 'plugins/Clist_modern/src')
-rw-r--r-- | plugins/Clist_modern/src/hdr/modern_commonheaders.h | 2 | ||||
-rw-r--r-- | plugins/Clist_modern/src/hdr/modern_commonprototypes.h | 19 | ||||
-rw-r--r-- | plugins/Clist_modern/src/hdr/modern_skinengine.h | 8 | ||||
-rw-r--r-- | plugins/Clist_modern/src/modern_clistmod.cpp | 36 | ||||
-rw-r--r-- | plugins/Clist_modern/src/modern_clisttray.cpp | 59 | ||||
-rw-r--r-- | plugins/Clist_modern/src/modern_clui.cpp | 198 | ||||
-rw-r--r-- | plugins/Clist_modern/src/modern_gdiplus.cpp | 199 | ||||
-rw-r--r-- | plugins/Clist_modern/src/modern_skineditor.cpp | 119 | ||||
-rw-r--r-- | plugins/Clist_modern/src/modern_skinengine.cpp | 191 | ||||
-rw-r--r-- | plugins/Clist_modern/src/modern_skinopt.cpp | 253 | ||||
-rw-r--r-- | plugins/Clist_modern/src/modern_skinselector.cpp | 9 | ||||
-rw-r--r-- | plugins/Clist_modern/src/modern_tbbutton.cpp | 63 | ||||
-rw-r--r-- | plugins/Clist_modern/src/modern_utils.cpp | 10 |
13 files changed, 493 insertions, 673 deletions
diff --git a/plugins/Clist_modern/src/hdr/modern_commonheaders.h b/plugins/Clist_modern/src/hdr/modern_commonheaders.h index 83bbdbd1dd..480a928935 100644 --- a/plugins/Clist_modern/src/hdr/modern_commonheaders.h +++ b/plugins/Clist_modern/src/hdr/modern_commonheaders.h @@ -223,7 +223,7 @@ extern pfnGetMenuBarInfo fnGetMenuBarInfo; extern SortedList *clistCache;
-HICON LoadSmallIcon(HINSTANCE hInstance, LPCTSTR lpIconName);
+HICON LoadSmallIcon(HINSTANCE hInstance, int idx);
BOOL DestroyIcon_protect(HICON icon);
#ifndef ETDT_ENABLETAB
diff --git a/plugins/Clist_modern/src/hdr/modern_commonprototypes.h b/plugins/Clist_modern/src/hdr/modern_commonprototypes.h index 8e71682180..2040e1be3e 100644 --- a/plugins/Clist_modern/src/hdr/modern_commonprototypes.h +++ b/plugins/Clist_modern/src/hdr/modern_commonprototypes.h @@ -126,7 +126,7 @@ int CLUIUnreadEmailCountChanged(WPARAM wParam,LPARAM lParam); /* GDIPlus */
BOOL GDIPlus_AlphaBlend(HDC hdcDest,int nXOriginDest,int nYOriginDest,int nWidthDest,int nHeightDest,HDC hdcSrc,int nXOriginSrc,int nYOriginSrc,int nWidthSrc,int nHeightSrc, BLENDFUNCTION * blendFunction);
-HBITMAP GDIPlus_LoadGlyphImage(char *szFileName);
+HBITMAP GDIPlus_LoadGlyphImage(const TCHAR *szFileName);
/* EventArea */
void EventArea_ConfigureEventArea();
@@ -155,12 +155,12 @@ BOOL ske_DrawText(HDC hdc, LPCTSTR lpString, int nCount, RECT *lpRect, UINT f BOOL ske_DrawTextA(HDC hdc, char * lpString, int nCount, RECT *lpRect, UINT format);
LPSKINOBJECTDESCRIPTOR ske_FindObjectByName(const char * szName, BYTE objType, SKINOBJECTSLIST* Skin);
HBITMAP ske_GetCurrentWindowImage();
-int ske_GetFullFilename(char * buf, char *file, char * skinfolder,BOOL madeAbsolute);
-int ske_GetSkinFolder(char * szFileName, char * t2);
+int ske_GetFullFilename(TCHAR *buf, const TCHAR *file, TCHAR *skinfolder,BOOL madeAbsolute);
+int ske_GetSkinFolder(TCHAR *szFileName, char * t2);
BOOL ske_ImageList_DrawEx( HIMAGELIST himl,int i,HDC hdcDst,int x,int y,int dx,int dy,COLORREF rgbBk,COLORREF rgbFg,UINT fStyle);
HICON ske_ImageList_GetIcon(HIMAGELIST himl, int i, UINT fStyle);
int ske_JustUpdateWindowImageRect(RECT *rty);
-HBITMAP ske_LoadGlyphImage(char * szFileName);
+HBITMAP ske_LoadGlyphImage(const TCHAR *szFileName);
HRESULT SkinEngineLoadModule();
void ske_LoadSkinFromDB(void);
int ske_LoadSkinFromIniFile(TCHAR*, BOOL);
@@ -205,15 +205,15 @@ int Docking_ProcessWindowMessage(WPARAM wParam,LPARAM lParam); void DrawBackGround(HWND hwnd,HDC mhdc, HBITMAP hBmpBackground, COLORREF bkColour, DWORD backgroundBmpUse );
HRESULT BackgroundsLoadModule();
int BackgroundsUnloadModule();
-BOOL wildcmp(const char * name, const char * mask, BYTE option); //mod_skin_selector.c
-BOOL wildcmpi(char * name, char * mask); //mod_skin_selector.c
-BOOL wildcmpi(WCHAR* name, WCHAR* mask); //mod_skin_selector.c
+BOOL wildcmp(const char *name, const char *mask, BYTE option); //mod_skin_selector.c
+BOOL wildcmpi(const char *name, const char *mask); //mod_skin_selector.c
+BOOL wildcmpi(const WCHAR *name, const WCHAR *mask); //mod_skin_selector.c
INT_PTR CALLBACK DlgSkinEditorOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam); //SkinEditor.c
INT_PTR CALLBACK DlgTmplEditorOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam); //RowTemplate.c
BOOL FindMenuHanleByGlobalID(HMENU hMenu, int globalID, struct _MenuItemHandles * dat); //GenMenu.c
-BOOL MatchMask(char * name, char * mask); //mod_skin_selector.c
+BOOL MatchMask(char *name, char *mask); //mod_skin_selector.c
char* GetContactCachedProtocol(HANDLE hContact); //clistsettings.c
-char* GetParamN(char * string, char * buf, int buflen, BYTE paramN, char Delim, BOOL SkipSpaces); //mod_skin_selector.c
+char* GetParamN(char *string, char *buf, int buflen, BYTE paramN, char Delim, BOOL SkipSpaces); //mod_skin_selector.c
DWORD CompareContacts2_getLMTime(HANDLE u); //contact.c
DWORD mod_CalcHash(const char * a); //mod_skin_selector.c
HICON cliGetIconFromStatusMode(HANDLE hContact, const char *szProto,int status); //clistmod.c
@@ -259,7 +259,6 @@ void InitGdiPlus(); //gd void InitTray(); //clisttray.c
void InvalidateDNCEbyPointer(HANDLE hContact,ClcCacheEntry *pdnce,int SettingType); //clistsettings.c
void ShutdownGdiPlus(); //gdiplus.cpp
-void TextOutWithGDIp(HDC hDestDC, int x, int y, LPCTSTR lpString, int nCount); //gdiplus.cpp
void UninitCustomMenus(); //clistmenus.c
void UnloadAvatarOverlayIcon(); //clc.c
void UnLoadContactListModule(); //clistmod.c
diff --git a/plugins/Clist_modern/src/hdr/modern_skinengine.h b/plugins/Clist_modern/src/hdr/modern_skinengine.h index f9ff072e31..5d7f23f2e5 100644 --- a/plugins/Clist_modern/src/hdr/modern_skinengine.h +++ b/plugins/Clist_modern/src/hdr/modern_skinengine.h @@ -24,7 +24,7 @@ struct SKINOBJECTSLIST {
DWORD dwObjLPReserved;
DWORD dwObjLPAlocated;
- char *szSkinPlace;
+ TCHAR *szSkinPlace;
LISTMODERNMASK *pMaskList;
SKINOBJECTDESCRIPTOR *pObjects;
SortedList *pTextList;
@@ -32,10 +32,10 @@ struct SKINOBJECTSLIST struct GLYPHIMAGE
{
- char * szFileName;
- DWORD dwLoadedTimes;
+ TCHAR *szFileName;
+ DWORD dwLoadedTimes;
HBITMAP hGlyph;
- BYTE isSemiTransp;
+ BYTE isSemiTransp;
};
typedef GLYPHIMAGE *LPGLYPHIMAGE;
diff --git a/plugins/Clist_modern/src/modern_clistmod.cpp b/plugins/Clist_modern/src/modern_clistmod.cpp index 3a102bd281..fdc095d935 100644 --- a/plugins/Clist_modern/src/modern_clistmod.cpp +++ b/plugins/Clist_modern/src/modern_clistmod.cpp @@ -67,49 +67,35 @@ BOOL (WINAPI *MySetProcessWorkingSetSize)(HANDLE,SIZE_T,SIZE_T); //returns normal icon or combined with status overlay. Needs to be destroyed.
HICON cliGetIconFromStatusMode(HANDLE hContact, const char *szProto,int status)
{
- HICON hIcon = NULL;
- HICON hXIcon = NULL;
// check if options is turned on
BYTE trayOption = db_get_b(NULL,"CLUI","XStatusTray",SETTING_TRAYOPTION_DEFAULT);
- if (trayOption&3 && szProto != NULL)
- {
+ if (trayOption&3 && szProto != NULL) {
// check service exists
char str[MAXMODULELABELLENGTH];
strcpy(str,szProto);
strcat(str,"/GetXStatusIcon");
- if ( ServiceExists(str))
- {
+ if ( ServiceExists(str)) {
// check status is online
- if (status>ID_STATUS_OFFLINE)
- {
+ if (status > ID_STATUS_OFFLINE) {
// get xicon
- hXIcon = (HICON)CallService(str, 0, 0);
- if (hXIcon)
- {
+ HICON hXIcon = (HICON)CallService(str, 0, 0);
+ if (hXIcon) {
// check overlay mode
- if (trayOption&2)
- {
+ if (trayOption & 2) {
// get overlay
HICON MainOverlay = (HICON)GetMainStatusOverlay(status);
- hIcon = ske_CreateJoinedIcon(hXIcon,MainOverlay,(trayOption&4)?192:0);
+ HICON hIcon = ske_CreateJoinedIcon(hXIcon,MainOverlay,(trayOption&4)?192:0);
DestroyIcon_protect(hXIcon);
DestroyIcon_protect(MainOverlay);
+ return hIcon;
}
- else
- {
- // paint it
- hIcon = hXIcon;
- }
+ return hXIcon;
}
}
}
}
- if ( !hIcon)
- {
- hIcon = ske_ImageList_GetIcon(g_himlCListClc,ExtIconFromStatusMode(hContact,szProto,status),ILD_NORMAL);
- }
- // if not ready take normal icon
- return hIcon;
+
+ return ske_ImageList_GetIcon(g_himlCListClc,ExtIconFromStatusMode(hContact,szProto,status),ILD_NORMAL);
}
int ExtIconFromStatusMode(HANDLE hContact, const char *szProto,int status)
diff --git a/plugins/Clist_modern/src/modern_clisttray.cpp b/plugins/Clist_modern/src/modern_clisttray.cpp index 81476a373a..9a4525ad1f 100644 --- a/plugins/Clist_modern/src/modern_clisttray.cpp +++ b/plugins/Clist_modern/src/modern_clisttray.cpp @@ -157,14 +157,15 @@ static VOID CALLBACK RefreshTimerProc(HWND hwnd,UINT message,UINT idEvent,DWORD void cliTrayIconUpdateBase(const char *szChangedProto)
{
+ if ( !szChangedProto) return;
+ if ( !pcli->pfnGetProtocolVisibility(szChangedProto)) return;
+
int i,count,netProtoCount,changed = -1;
PROTOACCOUNT **accs;
int averageMode = 0;
HWND hwnd = pcli->hwndContactList;
-
- if ( !szChangedProto) return;
-
- if ( !pcli->pfnGetProtocolVisibility(szChangedProto)) return;
+ DBVARIANT dbv;
+ char *szProto = NULL;
pcli->pfnLockTray();
if ( pcli->cycleTimerId ) {
@@ -189,58 +190,50 @@ void cliTrayIconUpdateBase(const char *szChangedProto) pcli->pfnTrayIconDestroy(hwnd);
pcli->pfnTrayIconInit(hwnd);
}
- else
- changed = pcli->pfnTrayIconSetBaseInfo(cliGetIconFromStatusMode(NULL,NULL,averageMode),NULL);
+ else changed = pcli->pfnTrayIconSetBaseInfo(cliGetIconFromStatusMode(NULL,NULL,averageMode),NULL);
}
- else
- {
- if ( db_get_b(NULL,"CList","TrayIcon",SETTING_TRAYICON_DEFAULT) == SETTING_TRAYICON_SINGLE
- && db_get_b(NULL,"CList","AlwaysPrimary",SETTING_ALWAYSPRIMARY_DEFAULT))
+ else {
+ if ( db_get_b(NULL,"CList","TrayIcon",SETTING_TRAYICON_DEFAULT) == SETTING_TRAYICON_SINGLE &&
+ db_get_b(NULL,"CList","AlwaysPrimary",SETTING_ALWAYSPRIMARY_DEFAULT))
{
- DBVARIANT dbv = {DBVT_DELETED};
- char *szProto;
- if (DBGetContactSettingString(NULL,"CList","PrimaryStatus",&dbv)) szProto = NULL;
- else szProto = dbv.pszVal;
+ if ( !DBGetContactSettingString(NULL,"CList","PrimaryStatus",&dbv)) {
+ szProto = NEWSTR_ALLOCA(dbv.pszVal);
+ db_free(&dbv);
+ }
changed = pcli->pfnTrayIconSetBaseInfo(cliGetIconFromStatusMode(NULL,szProto,averageMode),NULL);
- mir_free(szProto);
}
- else
- changed = pcli->pfnTrayIconSetBaseInfo(cliGetIconFromStatusMode(NULL,NULL,averageMode),NULL);
+ else changed = pcli->pfnTrayIconSetBaseInfo(cliGetIconFromStatusMode(NULL,NULL,averageMode),NULL);
}
}
else {
switch( db_get_b(NULL,"CList","TrayIcon",SETTING_TRAYICON_DEFAULT)) {
case SETTING_TRAYICON_SINGLE:
{
- DBVARIANT dbv = {DBVT_DELETED};
- char *szProto;
- int status;
- if (DBGetContactSettingString(NULL,"CList","PrimaryStatus",&dbv)) szProto = NULL;
- else szProto = dbv.pszVal;
- status = CallProtoService(szChangedProto,PS_GETSTATUS, 0, 0);
+ if ( !DBGetContactSettingString(NULL,"CList","PrimaryStatus",&dbv)) {
+ szProto = NEWSTR_ALLOCA(dbv.pszVal);
+ db_free(&dbv);
+ }
+ int status = CallProtoService(szChangedProto,PS_GETSTATUS, 0, 0);
if ((g_StatusBarData.connectingIcon == 1) && status >= ID_STATUS_CONNECTING && status <= ID_STATUS_CONNECTING+MAX_CONNECT_RETRIES) {
//
HICON hIcon;
// 1 check if multi connecting icon
CListTray_GetGlobalStatus(0, 0);
- if (g_bMultiConnectionMode)
- if (_strcmpi(szChangedProto,g_szConnectingProto))
+ if (g_bMultiConnectionMode) {
+ if (_strcmpi(szChangedProto, g_szConnectingProto))
{ pcli->pfnUnlockTray(); return; }
else
- hIcon = (HICON)CLUI_GetConnectingIconService((WPARAM)"",1);
- else
- hIcon = (HICON)CLUI_GetConnectingIconService((WPARAM)szChangedProto,0);
+ hIcon = (HICON)CLUI_GetConnectingIconService(NULL, 1);
+ }
+ else hIcon = (HICON)CLUI_GetConnectingIconService((WPARAM)szChangedProto,0);
+
if (hIcon) {
changed = pcli->pfnTrayIconSetBaseInfo(hIcon,NULL);
- db_free(&dbv);
break;
}
}
- else
- changed = pcli->pfnTrayIconSetBaseInfo(cliGetIconFromStatusMode(NULL,szProto,szProto?CallProtoService(szProto,PS_GETSTATUS, 0, 0):CallService(MS_CLIST_GETSTATUSMODE, 0, 0)),NULL);
-
- db_free(&dbv);
+ else changed = pcli->pfnTrayIconSetBaseInfo(cliGetIconFromStatusMode(NULL,szProto,szProto?CallProtoService(szProto,PS_GETSTATUS, 0, 0):CallService(MS_CLIST_GETSTATUSMODE, 0, 0)),NULL);
}
break;
diff --git a/plugins/Clist_modern/src/modern_clui.cpp b/plugins/Clist_modern/src/modern_clui.cpp index e3ec1751e9..21dddd2a97 100644 --- a/plugins/Clist_modern/src/modern_clui.cpp +++ b/plugins/Clist_modern/src/modern_clui.cpp @@ -55,6 +55,8 @@ CLUI* CLUI::m_pCLUI = NULL; BOOL CLUI::m_fMainMenuInited = FALSE;
HWND CLUI::m_hWnd = NULL;
+static TCHAR tszFolderPath[MAX_PATH];
+
void CLUI::cliOnCreateClc(void)
{
_ASSERT( m_pCLUI );
@@ -97,17 +99,18 @@ int CLUI::OnEvent_FontReload(WPARAM wParam,LPARAM lParam) int CLUI::OnEvent_ContactMenuPreBuild(WPARAM wParam, LPARAM lParam)
{
- TCHAR cls[128];
- HANDLE hItem;
- HWND hwndClist = GetFocus();
+ if (MirandaExiting())
+ return 0;
- if (MirandaExiting()) return 0;
+ HWND hwndClist = GetFocus();
+ TCHAR cls[128];
+ GetClassName(hwndClist, cls, SIZEOF(cls));
+ if ( lstrcmp( _T(CLISTCONTROL_CLASS), cls))
+ hwndClist = pcli->hwndContactList;
CLISTMENUITEM mi = { sizeof(mi) };
mi.flags = CMIM_FLAGS;
- GetClassName(hwndClist,cls,SIZEOF(cls));
- hwndClist = (!lstrcmp( _T(CLISTCONTROL_CLASS), cls))?hwndClist:pcli->hwndContactList;
- hItem = (HANDLE)SendMessage(hwndClist,CLM_GETSELECTION, 0, 0);
+ HANDLE hItem = (HANDLE)SendMessage(hwndClist, CLM_GETSELECTION, 0, 0);
if ( !hItem)
mi.flags = CMIM_FLAGS | CMIF_HIDDEN;
@@ -287,7 +290,7 @@ HRESULT CLUI::RegisterAvatarMenu() CLISTMENUITEM mi = { sizeof(mi) };
CreateServiceFunction("CList/ShowContactAvatar",CLUI::Service_Menu_ShowContactAvatar);
mi.position = 2000150000;
- mi.hIcon = LoadSmallIcon(g_hInst, MAKEINTRESOURCE(IDI_SHOW_AVATAR));
+ mi.hIcon = LoadSmallIcon(g_hInst, IDI_SHOW_AVATAR);
mi.pszName = LPGEN("Show Contact &Avatar");
mi.pszService = "CList/ShowContactAvatar";
hShowAvatarMenuItem = Menu_AddContactMenuItem(&mi);
@@ -295,7 +298,7 @@ HRESULT CLUI::RegisterAvatarMenu() CreateServiceFunction("CList/HideContactAvatar",CLUI::Service_Menu_HideContactAvatar);
mi.position = 2000150001;
- mi.hIcon = LoadSmallIcon(g_hInst, MAKEINTRESOURCE(IDI_HIDE_AVATAR));
+ mi.hIcon = LoadSmallIcon(g_hInst, IDI_HIDE_AVATAR);
mi.pszName = LPGEN("Hide Contact &Avatar");
mi.pszService = "CList/HideContactAvatar";
hHideAvatarMenuItem = Menu_AddContactMenuItem(&mi);
@@ -884,110 +887,101 @@ static LPPROTOTICKS CLUI_GetProtoTicksByProto(char * szProto) static int CLUI_GetConnectingIconForProtoCount(char *szAccoName)
{
- char fileFull[MAX_PATH];
- static char szFolderPath[MAX_PATH] = "";
-
- int count = 8;
+ int count;
+ TCHAR fileFull[MAX_PATH];
- if ( !szFolderPath[0] ) {
- char szRelativePath[MAX_PATH];
- GetModuleFileNameA(GetModuleHandle(NULL), szRelativePath, MAX_PATH);
- char *str = strrchr( szRelativePath, '\\' );
+ if ( !tszFolderPath[0] ) {
+ TCHAR szRelativePath[MAX_PATH];
+ GetModuleFileName( GetModuleHandle(NULL), szRelativePath, MAX_PATH);
+ TCHAR *str = _tcsrchr( szRelativePath, '\\' );
if (str != NULL)
*str = 0;
- PathToAbsolute(szRelativePath, szFolderPath);
+ PathToAbsoluteT(szRelativePath, tszFolderPath);
}
if ( szAccoName ) {
// first of all try to find by account name( or empty - global )
- mir_snprintf( fileFull, SIZEOF(fileFull), "%s\\Icons\\proto_conn_%s.dll", szFolderPath, szAccoName );
- count = ExtractIconExA(fileFull,-1,NULL,NULL,1);
- if ( count ) return count;
+ mir_sntprintf(fileFull, SIZEOF(fileFull), _T("%s\\Icons\\proto_conn_%S.dll"), tszFolderPath, szAccoName );
+ if (count = ExtractIconEx(fileFull, -1, NULL, NULL, 1))
+ return count;
if ( szAccoName[0] ) {
// second try to find by protocol name
PROTOACCOUNT *acc = ProtoGetAccount( szAccoName );
if (acc && !acc->bOldProto) {
- mir_snprintf( fileFull, SIZEOF(fileFull), "%s\\Icons\\proto_conn_%s.dll", szFolderPath, acc->szProtoName );
- count = ExtractIconExA(fileFull,-1,NULL,NULL,1);
- if (count)
+ mir_sntprintf(fileFull, SIZEOF(fileFull), _T("%s\\Icons\\proto_conn_%S.dll"), tszFolderPath, acc->szProtoName );
+ if (count = ExtractIconEx(fileFull, -1, NULL, NULL, 1))
return count;
}
}
}
+
// third try global
- mir_snprintf( fileFull, SIZEOF(fileFull), "%s\\Icons\\proto_conn.dll", szFolderPath );
- count = ExtractIconExA(fileFull,-1,NULL,NULL,1);
- if (count)
+ mir_sntprintf(fileFull, SIZEOF(fileFull), _T("%s\\Icons\\proto_conn.dll"), tszFolderPath );
+ if (count = ExtractIconEx(fileFull, -1, NULL, NULL, 1))
return count;
return 8;
}
-static HICON CLUI_ExtractIconFromPath(const char *path, BOOL * needFree)
+static HICON CLUI_ExtractIconFromPath(const TCHAR *path)
{
- char *comma;
- char file[MAX_PATH],fileFull[MAX_PATH];
+ TCHAR file[MAX_PATH], fileFull[MAX_PATH];
+ lstrcpyn(file, path, SIZEOF(file));
+ TCHAR *comma = _tcsrchr(file, ',');
int n;
- HICON hIcon;
- lstrcpynA(file,path,sizeof(file));
- comma = strrchr(file,',');
- if (comma == NULL) n = 0;
- else {n = atoi(comma+1); *comma = 0;}
- PathToAbsolute(file, fileFull);
- hIcon = NULL;
- ExtractIconExA(fileFull,n,NULL,&hIcon,1);
- if (needFree)
- *needFree = (hIcon != NULL);
-
+ if (comma == NULL)
+ n = 0;
+ else
+ n = _ttoi(comma+1), *comma = 0;
+ PathToAbsoluteT(file, fileFull);
+
+ HICON hIcon = NULL;
+ ExtractIconEx(fileFull, n, NULL, &hIcon, 1);
return hIcon;
}
-static HICON CLUI_LoadIconFromExternalFile(char *filename, int i, BOOL *needFree)
+static HICON CLUI_LoadIconFromExternalFile(TCHAR *filename, int i)
{
- char szPath[MAX_PATH], szFullPath[MAX_PATH],*str;
- if (needFree)
- *needFree = FALSE;
-
- GetModuleFileNameA(GetModuleHandle(NULL), szPath, MAX_PATH);
- str = strrchr(szPath,'\\');
- if (str != NULL) *str = 0;
- mir_snprintf(szFullPath, SIZEOF(szFullPath), "%s\\Icons\\%s,%d", szPath, filename, i);
- if (str != NULL) *str = '\\';
+ TCHAR szPath[MAX_PATH], szFullPath[MAX_PATH];
+ GetModuleFileName( GetModuleHandle(NULL), szPath, SIZEOF(szPath));
+ TCHAR *str = _tcsrchr(szPath,'\\');
+ if (str != NULL)
+ *str = 0;
+ mir_sntprintf(szFullPath, SIZEOF(szFullPath), _T("%s\\Icons\\%s,%d"), szPath, filename, i);
+ if (str != NULL)
+ *str = '\\';
- return CLUI_ExtractIconFromPath(szFullPath, needFree);
+ return CLUI_ExtractIconFromPath(szFullPath);
}
-static HICON CLUI_GetConnectingIconForProto(char *szAccoName, int b)
+static HICON CLUI_GetConnectingIconForProto(char *szAccoName, int idx)
{
- char szFullPath[MAX_PATH];
- HICON hIcon = NULL;
- BOOL needFree;
- b = b-1;
+ TCHAR szFullPath[MAX_PATH];
+ HICON hIcon;
if (szAccoName) {
- mir_snprintf(szFullPath, SIZEOF(szFullPath), "proto_conn_%s.dll",szAccoName);
- hIcon = CLUI_LoadIconFromExternalFile(szFullPath, b+1, &needFree);
- if (hIcon) return hIcon;
+ mir_sntprintf(szFullPath, SIZEOF(szFullPath), _T("proto_conn_%S.dll"), szAccoName);
+ if (hIcon = CLUI_LoadIconFromExternalFile(szFullPath, idx))
+ return hIcon;
if (szAccoName[0]) {
// second try to find by protocol name
- PROTOACCOUNT * acc = ProtoGetAccount( szAccoName );
+ PROTOACCOUNT *acc = ProtoGetAccount(szAccoName);
if (acc && !acc->bOldProto) {
- mir_snprintf( szFullPath, SIZEOF(szFullPath), "proto_conn_%s.dll", acc->szProtoName );
- hIcon = CLUI_LoadIconFromExternalFile(szFullPath, b+1, &needFree);
- if ( hIcon ) return hIcon;
+ mir_sntprintf(szFullPath, SIZEOF(szFullPath), _T("proto_conn_%S.dll"), acc->szProtoName );
+ if (hIcon = CLUI_LoadIconFromExternalFile(szFullPath, idx))
+ return hIcon;
}
}
}
// third try global
- mir_snprintf( szFullPath, SIZEOF(szFullPath), "proto_conn.dll");
- hIcon = CLUI_LoadIconFromExternalFile(szFullPath, b+1, &needFree);
- if ( hIcon ) return hIcon;
+ lstrcpyn(szFullPath, _T("proto_conn.dll"), SIZEOF(szFullPath));
+ if (hIcon = CLUI_LoadIconFromExternalFile(szFullPath, idx))
+ return hIcon;
- hIcon = LoadSmallIcon(g_hInst,(TCHAR *)(IDI_ICQC1+b+1));
- return(hIcon);
+ return LoadSmallIcon(g_hInst, IDI_ICQC1 + idx);
}
@@ -1035,14 +1029,13 @@ static int CLUI_CreateTimerForConnectingIcon(WPARAM wParam,LPARAM lParam) KillTimer(pcli->hwndContactList,TM_STATUSBARUPDATE+pt->nIndex);
int cnt = CLUI_GetConnectingIconForProtoCount(szProto);
if (cnt != 0) {
- int i=0;
nAnimatedIconStep = 100;/*DBGetContactSettingWord(NULL,"CLUI","DefaultStepConnectingIcon",100);*/
pt->nIconsCount = cnt;
if (pt->himlIconList)
ImageList_Destroy(pt->himlIconList);
pt->himlIconList = ImageList_Create(16,16,ILC_MASK|ILC_COLOR32,cnt,1);
- for (i=0; i < cnt; i++) {
- HICON ic = CLUI_GetConnectingIconForProto(szProto,i);
+ for (int i=0; i < cnt; i++) {
+ HICON ic = CLUI_GetConnectingIconForProto(szProto, i);
if (ic)
ImageList_AddIcon(pt->himlIconList, ic);
DestroyIcon_protect(ic);
@@ -2432,37 +2425,29 @@ LRESULT CLUI::OnNcHitTest( UINT msg, WPARAM wParam, LPARAM lParam ) LRESULT CLUI::OnShowWindow( UINT msg, WPARAM wParam, LPARAM lParam )
{
- BYTE gAlpha;
-
if (lParam) return 0;
if (mutex_bShowHideCalledFromAnimation) return 1;
- {
- if ( !wParam) gAlpha = 0;
- else
- gAlpha = ( db_get_b(NULL,"CList","Transparent",SETTING_TRANSPARENT_DEFAULT)?db_get_b(NULL,"CList","Alpha",SETTING_ALPHA_DEFAULT):255);
- if (wParam)
- {
- g_CluiData.bCurrentAlpha = 0;
- Sync(CLUIFrames_OnShowHide, pcli->hwndContactList,1);
- ske_RedrawCompleteWindow();
- }
- CLUI_SmoothAlphaTransition(m_hWnd, gAlpha, 1);
+ BYTE gAlpha = (!wParam) ? 0 : (db_get_b(NULL,"CList","Transparent",SETTING_TRANSPARENT_DEFAULT)?db_get_b(NULL,"CList","Alpha",SETTING_ALPHA_DEFAULT):255);
+ if (wParam) {
+ g_CluiData.bCurrentAlpha = 0;
+ Sync(CLUIFrames_OnShowHide, pcli->hwndContactList,1);
+ ske_RedrawCompleteWindow();
}
+ CLUI_SmoothAlphaTransition(m_hWnd, gAlpha, 1);
return FALSE;
}
LRESULT CLUI::OnSysCommand( UINT msg, WPARAM wParam, LPARAM lParam )
{
- switch (wParam)
- {
- case SC_MAXIMIZE:
- return 0;
+ switch (wParam) {
+ case SC_MAXIMIZE:
+ return 0;
- case SC_CLOSE:
- PostMessage(m_hWnd, msg, SC_MINIMIZE, lParam);
- return 0;
- }
+ case SC_CLOSE:
+ PostMessage(m_hWnd, msg, SC_MINIMIZE, lParam);
+ return 0;
+ }
DefWindowProc(m_hWnd, msg, wParam, lParam);
if ( db_get_b(NULL,"CList","OnDesktop",SETTING_ONDESKTOP_DEFAULT))
@@ -2652,29 +2637,24 @@ LRESULT CLUI::OnContextMenu( UINT msg, WPARAM wParam, LPARAM lParam ) DestroyTrayMenu(hMenu);
}
return FALSE;
-
}
+
LRESULT CLUI::OnMeasureItem( UINT msg, WPARAM wParam, LPARAM lParam )
{
LPMEASUREITEMSTRUCT pmis = (LPMEASUREITEMSTRUCT)lParam;
- switch ( pmis->itemData )
- {
+ switch ( pmis->itemData ) {
case MENU_MIRANDAMENU:
- {
- pmis->itemWidth = GetSystemMetrics( SM_CXSMICON ) * 4 / 3;
- pmis->itemHeight = 0;
- }
+ pmis->itemWidth = GetSystemMetrics( SM_CXSMICON ) * 4 / 3;
+ pmis->itemHeight = 0;
return TRUE;
+
case MENU_STATUSMENU:
- {
- HDC hdc;
- SIZE textSize;
- hdc = GetDC( m_hWnd );
- GetTextExtentPoint32A( hdc, Translate("Status"), lstrlenA( Translate("Status")), &textSize );
- pmis->itemWidth = textSize.cx;
- pmis->itemHeight = 0;
- ReleaseDC( m_hWnd, hdc );
- }
+ HDC hdc = GetDC( m_hWnd );
+ SIZE textSize;
+ GetTextExtentPoint32A( hdc, Translate("Status"), lstrlenA( Translate("Status")), &textSize );
+ pmis->itemWidth = textSize.cx;
+ pmis->itemHeight = 0;
+ ReleaseDC( m_hWnd, hdc );
return TRUE;
}
return CallService( MS_CLIST_MENUMEASUREITEM, wParam, lParam );
diff --git a/plugins/Clist_modern/src/modern_gdiplus.cpp b/plugins/Clist_modern/src/modern_gdiplus.cpp index c64c5079b4..733709183a 100644 --- a/plugins/Clist_modern/src/modern_gdiplus.cpp +++ b/plugins/Clist_modern/src/modern_gdiplus.cpp @@ -10,17 +10,22 @@ #include "hdr/modern_global_structure.h"
-BYTE saved_alpha;
-ULONG_PTR g_gdiplusToken;
+using namespace Gdiplus;
+
int mir_strlen(const char *a);
HBITMAP ske_CreateDIB32(int cx, int cy);
+
+BYTE saved_alpha;
+ULONG_PTR g_gdiplusToken;
+int g_hottrack;
+
void InitGdiPlus(void)
{
- Gdiplus::GdiplusStartupInput gdiplusStartupInput;
+ GdiplusStartupInput gdiplusStartupInput;
g_CluiData.fGDIPlusFail = false;
__try {
if (g_gdiplusToken == 0)
- Gdiplus::GdiplusStartup(&g_gdiplusToken, &gdiplusStartupInput, NULL);
+ GdiplusStartup(&g_gdiplusToken, &gdiplusStartupInput, NULL);
}
__except ( EXCEPTION_EXECUTE_HANDLER ) {
g_CluiData.fGDIPlusFail = true;
@@ -29,178 +34,126 @@ void InitGdiPlus(void) void ShutdownGdiPlus(void)
{
- Gdiplus::GdiplusStartupInput gdiplusStartupInput;
+ GdiplusStartupInput gdiplusStartupInput;
__try {
if (g_gdiplusToken)
- Gdiplus::GdiplusShutdown(g_gdiplusToken);
+ GdiplusShutdown(g_gdiplusToken);
}
__except ( EXCEPTION_EXECUTE_HANDLER ) {
g_CluiData.fGDIPlusFail = true;
- }
- g_gdiplusToken = 0;
+ }
+ g_gdiplusToken = 0;
}
-
-
-
-using namespace Gdiplus;
-
-static ColorMatrix ClrMatrix = {
- 1.0f, 0.0f, 0.0f, 0.0f, 0.0f,
- 0.0f, 1.0f, 0.0f, 0.0f, 0.0f,
- 0.0f, 0.0f, 1.0f, 0.0f, 0.0f,
- 0.0f, 0.0f, 0.0f, 0.5f, 0.0f,
- 0.0f, 0.0f, 0.0f, 0.0f, 1.0f
+static ColorMatrix ClrMatrix =
+{
+ 1.0f, 0.0f, 0.0f, 0.0f, 0.0f,
+ 0.0f, 1.0f, 0.0f, 0.0f, 0.0f,
+ 0.0f, 0.0f, 1.0f, 0.0f, 0.0f,
+ 0.0f, 0.0f, 0.0f, 0.5f, 0.0f,
+ 0.0f, 0.0f, 0.0f, 0.0f, 1.0f
};
-
-
-int g_hottrack;
-
DWORD argb_from_cola(COLORREF col, BYTE alpha)
{
- return((BYTE) (alpha) << 24 | col);
+ return((BYTE) (alpha) << 24 | col);
}
-HBITMAP GDIPlus_LoadGlyphImage(char *szFileName)
+
+HBITMAP GDIPlus_LoadGlyphImage(const TCHAR *tszFileName)
{
- WCHAR *string;
- string = (WCHAR*)malloc(sizeof(WCHAR)*(mir_strlen(szFileName)+2));
- MultiByteToWideChar(CP_ACP, 0, szFileName, -1, string, (mir_strlen(szFileName)+2)*sizeof(WCHAR));
// Create a Bitmap object from a JPEG file.
- Bitmap bitmap(string,0);
- free(string);
+ Bitmap bitmap(tszFileName, 0);
+
// Clone a portion of the bitmap.
Bitmap* clone = bitmap.Clone(0, 0, bitmap.GetWidth(), bitmap.GetHeight(), PixelFormat32bppPARGB);
HBITMAP hbmp = NULL;
- if (clone)
- {
+ if (clone) {
clone->GetHBITMAP(Color(0, 0, 0),&hbmp);
delete clone;
}
return hbmp;
}
+
void TextOutWithGDIp(HDC hDestDC, int x, int y, LPCTSTR lpString, int nCount)
{
-// Graphics s(hDestDC);
-// HBITMAP hs;
-// hs = (HBITMAP)GetCurrentObject(hDestDC,OBJ_BITMAP);
-// Bitmap sb(hs,NULL);
-// Bitmap *b = (sb.Clone(x,y,150, 30, PixelFormat32bppARGB));
-// Graphics g(b);//(100, 100, PixelFormat32bppPARGB);
-// //g.DrawImage(sb);
-// // s.SetCompositingMode(CompositingModeSourceCopy);
-// // g.SetCompositingMode(CompositingModeSourceCopy);
-// g.DrawImage(&sb, 0, 0, x,y,100, 30, UnitPixel);
-// //s.SetCompositingMode(CompositingModeSourceCopy);
-// //g.SetCompositingMode(CompositingModeSourceCopy);
-// // Create a string.
-//
-// WCHAR *string;
-// string = (WCHAR*)malloc(sizeof(WCHAR)*(nCount+2));
-// MultiByteToWideChar(CP_ACP, 0, lpString, -1, string, (nCount+2)*sizeof(WCHAR));
-// Font myFont(hDestDC);
-//
-// PointF origin((float)0, (float)0);
-// PointF origin2((float)x, (float)y);
-// g.SetTextRenderingHint(TextRenderingHintSystemDefault);
-// g.SetSmoothingMode(SmoothingModeAntiAlias);
-// COLORREF ref = GetTextColor(hDestDC);
-// SolidBrush blackBrush(Color(255, GetRValue(ref),GetGValue(ref),GetBValue(ref)));
-// g.SetInterpolationMode(InterpolationModeHighQualityBicubic);
-// g.DrawString(string,nCount,&myFont,origin, &blackBrush);
-// //g.SetCompositingMode(CompositingModeSourceCopy);
-// //s.SetCompositingMode(CompositingModeSourceCopy);
-// free(string);
-// //HDC temp = g.GetHDC();
-// //BitBlt(hDestDC,x,y,100, 100, temp, 0, 0, SRCCOPY);
-// //g.ReleaseHDC(temp);
-// s.DrawImage(b,origin2);
-//
}
void DrawAvatarImageWithGDIp(HDC hDestDC,int x, int y, DWORD width, DWORD height, HBITMAP hbmp, int x1, int y1, DWORD width1, DWORD height1,DWORD flag,BYTE alpha)
{
- BITMAP bmp;
- Bitmap *bm;
- BYTE * bmbits = NULL;
- GetObject(hbmp,sizeof(BITMAP),&bmp);
- Graphics g(hDestDC);
- if (bmp.bmBitsPixel == 32 && (flag&AVS_PREMULTIPLIED))
- {
- bmbits = (BYTE*)bmp.bmBits;
- if ( !bmbits)
- {
- bmbits = (BYTE*)malloc(bmp.bmHeight*bmp.bmWidthBytes);
- GetBitmapBits(hbmp,bmp.bmHeight*bmp.bmWidthBytes,bmbits);
- }
- bm = new Bitmap(bmp.bmWidth,bmp.bmHeight,bmp.bmWidthBytes,PixelFormat32bppPARGB,bmbits);
- bm->RotateFlip(RotateNoneFlipY);
- if ( !bmp.bmBits)
- {
- bm->RotateFlip(RotateNoneFlipY);
- free(bmbits);
- }
- }
- else
- bm = new Bitmap(hbmp,NULL);
-
- ImageAttributes attr;
- ColorMatrix ClrMatrix =
- {
- 1.0f, 0.0f, 0.0f, 0.0f, 0.0f,
- 0.0f, 1.0f, 0.0f, 0.0f, 0.0f,
- 0.0f, 0.0f, 1.0f, 0.0f, 0.0f,
- 0.0f, 0.0f, 0.0f, ((float)alpha)/255, 0.0f,
- 0.0f, 0.0f, 0.0f, 0.0f, 1.0f
- };
- attr.SetColorMatrix(&ClrMatrix, ColorMatrixFlagsDefault,ColorAdjustTypeBitmap);
- g.SetInterpolationMode(InterpolationModeHighQualityBicubic);
+ BITMAP bmp;
+ Bitmap *bm;
+ BYTE * bmbits = NULL;
+ GetObject(hbmp,sizeof(BITMAP),&bmp);
+ Graphics g(hDestDC);
+ if (bmp.bmBitsPixel == 32 && (flag&AVS_PREMULTIPLIED)) {
+ bmbits = (BYTE*)bmp.bmBits;
+ if ( !bmbits) {
+ bmbits = (BYTE*)malloc(bmp.bmHeight*bmp.bmWidthBytes);
+ GetBitmapBits(hbmp,bmp.bmHeight*bmp.bmWidthBytes,bmbits);
+ }
+ bm = new Bitmap(bmp.bmWidth,bmp.bmHeight,bmp.bmWidthBytes,PixelFormat32bppPARGB,bmbits);
+ bm->RotateFlip(RotateNoneFlipY);
+ if ( !bmp.bmBits) {
+ bm->RotateFlip(RotateNoneFlipY);
+ free(bmbits);
+ }
+ }
+ else bm = new Bitmap(hbmp,NULL);
+
+ ImageAttributes attr;
+ ColorMatrix ClrMatrix =
+ {
+ 1.0f, 0.0f, 0.0f, 0.0f, 0.0f,
+ 0.0f, 1.0f, 0.0f, 0.0f, 0.0f,
+ 0.0f, 0.0f, 1.0f, 0.0f, 0.0f,
+ 0.0f, 0.0f, 0.0f, ((float)alpha)/255, 0.0f,
+ 0.0f, 0.0f, 0.0f, 0.0f, 1.0f
+ };
+ attr.SetColorMatrix(&ClrMatrix, ColorMatrixFlagsDefault,ColorAdjustTypeBitmap);
+ g.SetInterpolationMode(InterpolationModeHighQualityBicubic);
RectF rect((float)x,(float)y,(float)width,(float)height);
- g.DrawImage(bm, rect, (float)x1, (float)y1, (float)width1, (float)height1 , UnitPixel, &attr, NULL, NULL);
- delete bm;
+ g.DrawImage(bm, rect, (float)x1, (float)y1, (float)width1, (float)height1 , UnitPixel, &attr, NULL, NULL);
+ delete bm;
}
+
BOOL GDIPlus_AlphaBlend(HDC hdcDest,int nXOriginDest,int nYOriginDest,int nWidthDest,int nHeightDest,HDC hdcSrc,int nXOriginSrc,int nYOriginSrc,int nWidthSrc,int nHeightSrc, BLENDFUNCTION * bf)
{
Graphics g(hdcDest);
BITMAP bmp;
HBITMAP hbmp = (HBITMAP)GetCurrentObject(hdcSrc,OBJ_BITMAP);
GetObject(hbmp,sizeof(BITMAP),&bmp);
- Bitmap *bm = new Bitmap(hbmp,NULL);
- if (bmp.bmBitsPixel == 32 && bf->AlphaFormat)
- {
+
+ Bitmap *bm;
+ if (bmp.bmBitsPixel == 32 && bf->AlphaFormat) {
bm = new Bitmap(bmp.bmWidth,bmp.bmHeight,bmp.bmWidthBytes,PixelFormat32bppPARGB,(BYTE*)bmp.bmBits);
bm->RotateFlip(RotateNoneFlipY);
}
- else
- bm = new Bitmap(hbmp,NULL);
+ else bm = new Bitmap(hbmp, NULL);
+
ImageAttributes attr;
ColorMatrix ClrMatrix =
{
1.0f, 0.0f, 0.0f, 0.0f, 0.0f,
- 0.0f, 1.0f, 0.0f, 0.0f, 0.0f,
- 0.0f, 0.0f, 1.0f, 0.0f, 0.0f,
- 0.0f, 0.0f, 0.0f, ((float)bf->SourceConstantAlpha)/255, 0.0f,
- 0.0f, 0.0f, 0.0f, 0.0f, 1.0f
+ 0.0f, 1.0f, 0.0f, 0.0f, 0.0f,
+ 0.0f, 0.0f, 1.0f, 0.0f, 0.0f,
+ 0.0f, 0.0f, 0.0f, ((float)bf->SourceConstantAlpha)/255, 0.0f,
+ 0.0f, 0.0f, 0.0f, 0.0f, 1.0f
};
attr.SetColorMatrix(&ClrMatrix, ColorMatrixFlagsDefault,ColorAdjustTypeBitmap);
- if (bf->BlendFlags&128 && nWidthDest < nWidthSrc && nHeightDest < nHeightSrc)
- {
- g.SetInterpolationMode(InterpolationModeHighQualityBicubic);
- g.SetPixelOffsetMode(PixelOffsetModeHalf);
- attr.SetGamma((REAL)0.8,ColorAdjustTypeBitmap);
- }
- else
- {
- g.SetInterpolationMode(InterpolationModeLowQuality);
- //g.SetPixelOffsetMode(PixelOffsetModeHalf);
+ if (bf->BlendFlags&128 && nWidthDest < nWidthSrc && nHeightDest < nHeightSrc) {
+ g.SetInterpolationMode(InterpolationModeHighQualityBicubic);
+ g.SetPixelOffsetMode(PixelOffsetModeHalf);
+ attr.SetGamma((REAL)0.8,ColorAdjustTypeBitmap);
}
+ else g.SetInterpolationMode(InterpolationModeLowQuality);
RectF rect((float)nXOriginDest,(float)nYOriginDest,(float)nWidthDest,(float)nHeightDest);
g.DrawImage(bm, rect, (float)nXOriginSrc, (float)nYOriginSrc, (float)nWidthSrc, (float)nHeightSrc , UnitPixel, &attr, NULL, NULL);
delete bm;
return TRUE;
}
+
COLORREF __inline _revcolref(COLORREF colref)
{
return RGB(GetBValue(colref), GetGValue(colref), GetRValue(colref));
diff --git a/plugins/Clist_modern/src/modern_skineditor.cpp b/plugins/Clist_modern/src/modern_skineditor.cpp index 7c8526c62c..4751720059 100644 --- a/plugins/Clist_modern/src/modern_skineditor.cpp +++ b/plugins/Clist_modern/src/modern_skineditor.cpp @@ -340,27 +340,26 @@ void SetControls(HWND hwndDlg, char * str) }
}
-
-
-int GetShortFileName(char * FullFile)
+int GetShortFileName(TCHAR *FullFile)
{
- char buf[MAX_PATH] = {0};
- char * f = strrchr(FullFile,'\\');
- char * file = f?mir_strdup(f+1):0;
- if ( !file) return 0;
- ske_GetFullFilename(buf,file, 0, TRUE);
- if (mir_bool_strcmpi(buf,FullFile))
- {
- _snprintf(FullFile,MAX_PATH,"%s",file);
+ TCHAR buf[MAX_PATH] = {0};
+ TCHAR *f = _tcsrchr(FullFile,'\\');
+ TCHAR *file = f ? mir_tstrdup(f+1) : 0;
+ if ( !file)
+ return 0;
+
+ ske_GetFullFilename(buf, file, 0, TRUE);
+ if ( mir_bool_tstrcmpi(buf, FullFile)) {
+ _tcsncpy(FullFile, file, MAX_PATH);
mir_free(file);
return 1; //skin folder relative
}
- PathToRelative(FullFile, buf);
+ PathToRelativeT(FullFile, buf);
if (buf[0] != '\\' && buf[1] != ':')
- _snprintf(FullFile,MAX_PATH,"\\%s",buf);
+ mir_sntprintf(FullFile, MAX_PATH, _T("\\%s"), buf);
else
- _snprintf(FullFile,MAX_PATH,"%s",buf);
+ _tcsncpy(FullFile, buf, MAX_PATH);
mir_free(file);
return 2; //mirand folder relative
@@ -507,23 +506,22 @@ static BOOL fileChanged = FALSE; static char * object_clipboard = NULL;
int GetFileSizes(HWND hwndDlg)
{
- char buf[MAX_PATH];
+ TCHAR buf[MAX_PATH];
SIZE sz = {0};
SendDlgItemMessageA(hwndDlg,IDC_FILE,WM_GETTEXT,(WPARAM)MAX_PATH,(LPARAM)buf);
- ske_GetFullFilename(buf,buf, 0, TRUE);
- {
- HBITMAP hbmp = ske_LoadGlyphImage(buf);
- if (hbmp)
- {
- BITMAP bm = {0};
- GetObject(hbmp,sizeof(BITMAP),&bm);
- sz.cx = bm.bmWidth;
- sz.cy = bm.bmHeight;
- ske_UnloadGlyphImage(hbmp);
- }
+ ske_GetFullFilename(buf, buf, 0, TRUE);
+
+ HBITMAP hbmp = ske_LoadGlyphImage(buf);
+ if (hbmp) {
+ BITMAP bm = {0};
+ GetObject(hbmp,sizeof(BITMAP),&bm);
+ sz.cx = bm.bmWidth;
+ sz.cy = bm.bmHeight;
+ ske_UnloadGlyphImage(hbmp);
}
- _snprintf(buf, MAX_PATH, "%s %d x %d %s",Translate("Image size is"),sz.cx, sz.cy, Translate("pixels"));
- SendDlgItemMessageA(hwndDlg,IDC_S_SIZE,WM_SETTEXT, 0, (LPARAM)buf);
+
+ mir_sntprintf(buf, MAX_PATH, _T("%s %d x %d %s"),TranslateT("Image size is"), sz.cx, sz.cy, TranslateT("pixels"));
+ SetDlgItemText(hwndDlg, IDC_S_SIZE, buf);
return 0;
}
@@ -639,42 +637,35 @@ INT_PTR CALLBACK DlgSkinEditorOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
UpdateInfo(hwndDlg);
}
- else if (LOWORD(wParam) == IDC_BROWSE)
- {
- if (HIWORD(wParam) == BN_CLICKED)
- {
- {
- char str[MAX_PATH] = {0};
- OPENFILENAMEA ofn = {0};
- char filter[512] = {0};
- int res = 0;
- ofn.lStructSize = OPENFILENAME_SIZE_VERSION_400;
- ofn.hwndOwner = hwndDlg;
- ofn.hInstance = NULL;
- ofn.lpstrFilter = "Images (*.png,*.jpg,*.bmp,*.gif,*.tga)\0*.png;*.jpg;*.jpeg;*.bmp;*.gif;*.tga\0All files (*.*)\0*.*\0\0";
- ofn.Flags = (OFN_FILEMUSTEXIST | OFN_HIDEREADONLY);
- SendDlgItemMessageA(hwndDlg,IDC_FILE,WM_GETTEXT,(WPARAM)SIZEOF(str),(LPARAM)str);
- if (str[0] == '\0' || strchr(str,'%'))
- {
- ofn.Flags |= OFN_NOVALIDATE;
- str[0] = '\0';
- }
- else
- {
- ske_GetFullFilename(str,str,(char*)0, TRUE);
- }
- ofn.lpstrFile = str;
-
- ofn.nMaxFile = SIZEOF(str);
- ofn.nMaxFileTitle = MAX_PATH;
- ofn.lpstrDefExt = "*.*";
- res = GetOpenFileNameA(&ofn);
- if (res) {
- GetShortFileName(ofn.lpstrFile);
- SendDlgItemMessageA(hwndDlg,IDC_FILE,WM_SETTEXT, 0, (LPARAM)ofn.lpstrFile);
- SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
- UpdateInfo(hwndDlg);
- }
+ else if (LOWORD(wParam) == IDC_BROWSE) {
+ if (HIWORD(wParam) == BN_CLICKED) {
+ TCHAR str[MAX_PATH] = {0};
+ OPENFILENAME ofn = {0};
+ TCHAR filter[512] = {0};
+ int res = 0;
+ ofn.lStructSize = OPENFILENAME_SIZE_VERSION_400;
+ ofn.hwndOwner = hwndDlg;
+ ofn.hInstance = NULL;
+ ofn.lpstrFilter = _T("Images (*.png,*.jpg,*.bmp,*.gif,*.tga)\0*.png;*.jpg;*.jpeg;*.bmp;*.gif;*.tga\0All files (*.*)\0*.*\0\0");
+ ofn.Flags = OFN_FILEMUSTEXIST | OFN_HIDEREADONLY;
+ GetDlgItemText(hwndDlg, IDC_FILE, str, SIZEOF(str));
+ if (str[0] == '\0' || _tcschr(str,'%')) {
+ ofn.Flags |= OFN_NOVALIDATE;
+ str[0] = '\0';
+ }
+ else ske_GetFullFilename(str, str, 0, TRUE);
+
+ ofn.lpstrFile = str;
+
+ ofn.nMaxFile = SIZEOF(str);
+ ofn.nMaxFileTitle = MAX_PATH;
+ ofn.lpstrDefExt = _T("*.*");
+ res = GetOpenFileName(&ofn);
+ if (res) {
+ GetShortFileName(ofn.lpstrFile);
+ SetDlgItemText(hwndDlg, IDC_FILE, ofn.lpstrFile);
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
+ UpdateInfo(hwndDlg);
}
}
}
diff --git a/plugins/Clist_modern/src/modern_skinengine.cpp b/plugins/Clist_modern/src/modern_skinengine.cpp index 1deee93360..a3efe5439b 100644 --- a/plugins/Clist_modern/src/modern_skinengine.cpp +++ b/plugins/Clist_modern/src/modern_skinengine.cpp @@ -88,7 +88,6 @@ static void ske_AddParseSkinFont(char * szFontID,char * szDefineString,SKINOBJEC static int ske_DeleteAllSettingInSection(char * SectionName);
static int ske_GetSkinFromDB(char * szSection, SKINOBJECTSLIST * Skin);
static LPSKINOBJECTDESCRIPTOR ske_FindObject(const char * szName, BYTE objType,SKINOBJECTSLIST* Skin);
-static HBITMAP ske_LoadGlyphImageByDecoders(char * szFileName);
static int ske_LoadSkinFromResource(BOOL bOnlyObjects);
static void ske_PreMultiplyChanells(HBITMAP hbmp,BYTE Mult);
static int ske_ValidateSingleFrameImage(FRAMEWND * Frame, BOOL SkipBkgBlitting);
@@ -1692,25 +1691,23 @@ INT_PTR ske_Service_DrawGlyph(WPARAM wParam,LPARAM lParam) pgl = ske_FindObject(preq->szObjectID, OT_GLYPHOBJECT,NULL);
if (pgl == NULL) return -1;
if (pgl->Data == NULL) return -1;
+
gl = (LPGLYPHOBJECT)pgl->Data;
- if ((gl->Style&7) == ST_SKIP) return ST_SKIP;
- if (gl->hGlyph == NULL && gl->hGlyph != (HBITMAP)-1 &&
- ( (gl->Style&7) == ST_IMAGE
- || (gl->Style&7) == ST_FRAGMENT
- || (gl->Style&7) == ST_SOLARIZE ))
- if (gl->szFileName)
- {
- gl->hGlyph = ske_LoadGlyphImage(gl->szFileName);
- if (gl->hGlyph)
- {
+ int iStyle = gl->Style & 7;
+ if (iStyle == ST_SKIP)
+ return ST_SKIP;
+
+ if (gl->hGlyph == NULL && gl->hGlyph != (HBITMAP)-1 && (iStyle == ST_IMAGE || iStyle == ST_FRAGMENT || iStyle == ST_SOLARIZE))
+ if (gl->szFileName) {
+ gl->hGlyph = ske_LoadGlyphImage( _A2T(gl->szFileName));
+ if (gl->hGlyph) {
BITMAP bmp = {0};
GetObject(gl->hGlyph,sizeof(BITMAP),&bmp);
gl->bmBitsPixel = (BYTE)bmp.bmBitsPixel;
gl->bmHeight = bmp.bmHeight;
gl->bmWidth = bmp.bmWidth;
}
- else
- gl->hGlyph = (HBITMAP)-1; //invalid
+ else gl->hGlyph = (HBITMAP)-1; //invalid
}
return ske_DrawSkinObject(preq,gl);
}
@@ -1769,36 +1766,30 @@ void ske_PreMultiplyChanells(HBITMAP hbmp,BYTE Mult) return;
}
-int ske_GetFullFilename(char * buf, char *file, char * skinfolder,BOOL madeAbsolute)
+int ske_GetFullFilename(TCHAR *buf, const TCHAR *file, TCHAR *skinfolder,BOOL madeAbsolute)
{
- char b2[MAX_PATH] = {0};
- char *SkinPlace = db_get_sa(NULL,SKIN,"SkinFolder");
- if ( !SkinPlace) SkinPlace = mir_strdup("\\Skin\\default");
+ TCHAR *SkinPlace = db_get_tsa(NULL,SKIN,"SkinFolder");
+ if (SkinPlace == NULL)
+ SkinPlace = mir_tstrdup( _T("\\Skin\\default"));
+
+ TCHAR b2[MAX_PATH];
if (file[0] != '\\' && file[1] != ':')
- _snprintf(b2, MAX_PATH,"%s\\%s",(skinfolder == NULL)?SkinPlace:((INT_PTR)skinfolder != -1)?skinfolder:"",file);
+ mir_sntprintf(b2, MAX_PATH, _T("%s\\%s"), (skinfolder == NULL) ? SkinPlace : ((INT_PTR)skinfolder != -1) ? skinfolder : _T(""), file);
else
- _snprintf(b2, MAX_PATH,"%s",file);
+ _tcsncpy(b2, file, SIZEOF(b2));
+
if (madeAbsolute) {
if (b2[0] == '\\' && b2[1] != '\\')
- PathToAbsolute(b2+1, buf);
+ PathToAbsoluteT(b2+1, buf);
else
- PathToAbsolute(b2, buf);
+ PathToAbsoluteT(b2, buf);
}
- else memcpy(buf,b2,MAX_PATH);
+ else _tcsncpy(buf, b2, SIZEOF(buf));
mir_free(SkinPlace);
return 0;
}
-
-static HBITMAP ske_skinLoadGlyphImage(char * szFileName)
-{
- if ( !g_CluiData.fGDIPlusFail && !wildcmpi(szFileName,"*.tga"))
- return GDIPlus_LoadGlyphImage(szFileName);
- else
- return ske_LoadGlyphImageByDecoders(szFileName);
-}
-
/*
This function is required to load TGA to dib buffer myself
Major part of routines is from http://tfcduke.developpez.com/tutoriel/format/tga/fichiers/tga.c
@@ -1874,29 +1865,23 @@ static BOOL ske_ReadTGAImageData(void * From, DWORD fromSize, BYTE * destBuf, DW return TRUE;
}
-static HBITMAP ske_LoadGlyphImage_TGA(char * szFilename)
+static HBITMAP ske_LoadGlyphImage_TGA(const TCHAR *szFilename)
{
BYTE *colormap = NULL;
int cx = 0, cy = 0;
BOOL err = FALSE;
tga_header_t header;
if ( !szFilename) return NULL;
- if ( !wildcmpi(szFilename,"*\\*%.tga"))
- {
+ if ( !wildcmpi(szFilename, _T("*\\*%.tga"))) {
//Loading TGA image from file
- FILE *fp;
- fp = fopen (szFilename, "rb");
- if ( !fp)
- {
+ FILE *fp = _tfopen (szFilename, _T("rb"));
+ if ( !fp) {
TRACEVAR("error: couldn't open \"%s\"!\n", szFilename);
return NULL;
}
/* read header */
fread (&header, sizeof (tga_header_t), 1, fp);
- if ( (header.pixel_depth != 32)
- || ((header.image_type != 10) && (header.image_type != 2))
- )
- {
+ if ((header.pixel_depth != 32) || ((header.image_type != 10) && (header.image_type != 2))) {
fclose(fp);
return NULL;
}
@@ -1910,10 +1895,7 @@ static HBITMAP ske_LoadGlyphImage_TGA(char * szFilename) err = !ske_ReadTGAImageData((void*)fp, 0, colormap, header.width*header.height*4,header.image_type == 10);
fclose(fp);
}
-
-
- else
- {
+ else {
/* reading from resources IDR_TGA_DEFAULT_SKIN */
DWORD size = 0;
BYTE * mem;
@@ -1937,11 +1919,12 @@ static HBITMAP ske_LoadGlyphImage_TGA(char * szFilename) }
FreeResource(hRes);
}
- if (colormap) //create dib section
- {
+
+ if (colormap) { //create dib section
BYTE * pt;
HBITMAP hbmp = ske_CreateDIB32Point(cx,cy,(void**)&pt);
- if (hbmp) memcpy(pt,colormap,cx*cy*4);
+ if (hbmp)
+ memcpy(pt,colormap,cx*cy*4);
free(colormap);
return hbmp;
}
@@ -2005,11 +1988,11 @@ HBITMAP ske_LoadGlyphImage_Png2Dib(char * szFilename) return hBitmap;
}
-static HBITMAP ske_LoadGlyphImageByDecoders(char * szFileName)
+static HBITMAP ske_LoadGlyphImageByDecoders(const TCHAR *tszFileName)
{
// Loading image from file by imgdecoder...
HBITMAP hBitmap = NULL;
- char ext[5];
+ TCHAR ext[5];
BYTE f = 0;
LPBYTE pBitmapBits;
LPVOID pImg = NULL;
@@ -2018,17 +2001,17 @@ static HBITMAP ske_LoadGlyphImageByDecoders(char * szFileName) BITMAP bmpInfo;
{
int l;
- l = mir_strlen(szFileName);
+ l = lstrlen(tszFileName);
memmove(ext,szFileName +(l-4),5);
}
- if ( !strchr(szFileName,'%') && !PathFileExistsA(szFileName)) return NULL;
- if (mir_bool_strcmpi(ext,".tga"))
- {
- hBitmap = ske_LoadGlyphImage_TGA(szFileName);
+ if ( !_tcschr(tszFileName,'%') && !PathFileExists(tszFileName))
+ return NULL;
+
+ if (mir_bool_tstrcmpi(ext, _T(".tga"))) {
+ hBitmap = ske_LoadGlyphImage_TGA(tszFileName);
f = 1;
}
- else if ( ServiceExists("Image/Png2Dib") && mir_bool_strcmpi(ext,".png"))
- {
+ else if ( ServiceExists("Image/Png2Dib") && mir_bool_tstrcmpi(ext, _T(".png"))) {
hBitmap = ske_LoadGlyphImage_Png2Dib(szFileName);
GetObject(hBitmap, sizeof(BITMAP), &bmpInfo);
f = (bmpInfo.bmBits != NULL);
@@ -2036,7 +2019,7 @@ static HBITMAP ske_LoadGlyphImageByDecoders(char * szFileName) // f = 1;
}
- else if (hImageDecoderModule == NULL || !mir_bool_strcmpi(ext,".png"))
+ else if (hImageDecoderModule == NULL || !mir_bool_tstrcmpi(ext, _T(".png")))
hBitmap = (HBITMAP)CallService(MS_UTILS_LOADBITMAP, 0, (LPARAM)szFileName);
else
{
@@ -2077,20 +2060,25 @@ static HBITMAP ske_LoadGlyphImageByDecoders(char * szFileName) return hBitmap;
}
-HBITMAP ske_LoadGlyphImage(char * szFileName)
+static HBITMAP ske_skinLoadGlyphImage(const TCHAR *tszFileName)
+{
+ if ( !g_CluiData.fGDIPlusFail && !wildcmpi(tszFileName, _T("*.tga")))
+ return GDIPlus_LoadGlyphImage(tszFileName);
+
+ return ske_LoadGlyphImageByDecoders(tszFileName);
+}
+
+HBITMAP ske_LoadGlyphImage(const TCHAR *tszFileName)
{
// try to find image in loaded
DWORD i;
HBITMAP hbmp;
- char szFile [MAX_PATH] = {0};
- ske_GetFullFilename(szFile,szFileName,g_SkinObjectList.szSkinPlace,TRUE);
+ TCHAR szFile [MAX_PATH] = {0};
+ ske_GetFullFilename(szFile, tszFileName, g_SkinObjectList.szSkinPlace, TRUE);
ske_LockSkin();
- if (pLoadedImages)
- {
- for (i=0; i < dwLoadedImagesCount; i++)
- {
- if (mir_bool_strcmpi(pLoadedImages[i].szFileName,szFile))
- {
+ if (pLoadedImages) {
+ for (i=0; i < dwLoadedImagesCount; i++) {
+ if (mir_bool_tstrcmpi(pLoadedImages[i].szFileName, szFile)) {
pLoadedImages[i].dwLoadedTimes++;
ske_UnlockSkin();
return pLoadedImages[i].hGlyph;
@@ -2117,7 +2105,7 @@ HBITMAP ske_LoadGlyphImage(char * szFileName) }
pLoadedImages[dwLoadedImagesCount].dwLoadedTimes = 1;
pLoadedImages[dwLoadedImagesCount].hGlyph = hbmp;
- pLoadedImages[dwLoadedImagesCount].szFileName = mir_strdup(szFile);
+ pLoadedImages[dwLoadedImagesCount].szFileName = mir_tstrdup(szFile);
dwLoadedImagesCount++;
ske_UnlockSkin();
return hbmp;
@@ -2350,14 +2338,14 @@ static int ske_GetSkinFromDB(char * szSection, SKINOBJECTSLIST * Skin) Skin->pMaskList = (LISTMODERNMASK*)mir_alloc(sizeof(LISTMODERNMASK));
memset(Skin->pMaskList, 0, sizeof(LISTMODERNMASK));
- Skin->szSkinPlace = db_get_sa(NULL,SKIN,"SkinFolder");
- if ( !Skin->szSkinPlace || (strchr(Skin->szSkinPlace, '%') && !db_get_b(NULL,SKIN,"Modified",0)))
+ Skin->szSkinPlace = db_get_tsa(NULL, SKIN, "SkinFolder");
+ if ( !Skin->szSkinPlace || (_tcschr(Skin->szSkinPlace, '%') && !db_get_b(NULL,SKIN,"Modified",0)))
{
BOOL bOnlyObjects = FALSE;
- if (Skin->szSkinPlace && strchr(Skin->szSkinPlace, '%'))
+ if (Skin->szSkinPlace && _tcschr(Skin->szSkinPlace, '%'))
bOnlyObjects = TRUE;
mir_free(Skin->szSkinPlace);
- Skin->szSkinPlace = mir_strdup("%Default%");
+ Skin->szSkinPlace = mir_tstrdup( _T("%Default%"));
ske_LoadSkinFromResource( bOnlyObjects );
}
//Load objects
@@ -2421,16 +2409,17 @@ int ske_LoadSkinFromIniFile(TCHAR * szFileName, BOOL bOnlyObjects) return 0;
}
-
static int ske_enumdb_SkinSectionDeletionProc (const char *szSetting,LPARAM lParam)
{
+ if (szSetting == NULL)
+ return 0;
- if (szSetting == NULL){return 0;};
nArrayLen++;
pszSettingName = (char **)realloc(pszSettingName,nArrayLen*sizeof(char *));
pszSettingName[nArrayLen-1] = _strdup(szSetting);
return 0;
-};
+}
+
static int ske_DeleteAllSettingInSection(char * SectionName)
{
DBCONTACTENUMSETTINGS dbces;
@@ -2443,21 +2432,18 @@ static int ske_DeleteAllSettingInSection(char * SectionName) CallService(MS_DB_CONTACT_ENUMSETTINGS, 0, (LPARAM)&dbces);
//delete all settings
- if (nArrayLen == 0){return 0;};
- {
- int i;
- for (i=0;i < nArrayLen;i++)
- {
- db_unset(0, SectionName,pszSettingName[i]);
- free(pszSettingName[i]);
- };
- free(pszSettingName);
- pszSettingName = NULL;
- nArrayLen = 0;
- };
- return 0;
-};
+ if (nArrayLen == 0)
+ return 0;
+ for (int i=0; i < nArrayLen; i++) {
+ db_unset(0, SectionName,pszSettingName[i]);
+ free(pszSettingName[i]);
+ }
+ free(pszSettingName);
+ pszSettingName = NULL;
+ nArrayLen = 0;
+ return 0;
+}
BOOL ske_TextOutA(HDC hdc, int x, int y, char * lpString, int nCount)
{
@@ -2471,23 +2457,13 @@ BOOL ske_TextOutA(HDC hdc, int x, int y, char * lpString, int nCount) BOOL ske_TextOut(HDC hdc, int x, int y, LPCTSTR lpString, int nCount)
{
- int ta;
SIZE sz;
- RECT rc = {0};
- if ( !g_CluiData.fGDIPlusFail && 0) ///text via gdi+
- {
- TextOutWithGDIp(hdc,x,y,lpString,nCount);
- return 0;
- }
- else
+ GetTextExtentPoint32(hdc,lpString,nCount,&sz);
+ int ta = GetTextAlign(hdc);
- {
- // return TextOut(hdc, x,y,lpString,nCount);
- GetTextExtentPoint32(hdc,lpString,nCount,&sz);
- ta = GetTextAlign(hdc);
- SetRect(&rc,x,y,x+sz.cx,y+sz.cy);
- ske_DrawText(hdc,lpString,nCount,&rc,DT_NOCLIP|DT_SINGLELINE|DT_LEFT);
- }
+ RECT rc = {0};
+ SetRect(&rc,x,y,x+sz.cx,y+sz.cy);
+ ske_DrawText(hdc,lpString,nCount,&rc,DT_NOCLIP|DT_SINGLELINE|DT_LEFT);
return 1;
}
@@ -3059,11 +3035,6 @@ BOOL ske_DrawText(HDC hdc, LPCTSTR lpString, int nCount, RECT *lpRect, UINT form return DrawText(hdc,lpString,nCount,lpRect,format&~DT_FORCENATIVERENDER);
form = format;
color = GetTextColor(hdc);
- if ( !g_CluiData.fGDIPlusFail && 0) ///text via gdi+
- {
- TextOutWithGDIp(hdc,lpRect->left,lpRect->top,lpString,nCount);
- return 0;
- }
return ske_AlphaTextOut(hdc,lpString,nCount,lpRect,form,color);
}
diff --git a/plugins/Clist_modern/src/modern_skinopt.cpp b/plugins/Clist_modern/src/modern_skinopt.cpp index 0d804d46bc..24ca4f66d9 100644 --- a/plugins/Clist_modern/src/modern_skinopt.cpp +++ b/plugins/Clist_modern/src/modern_skinopt.cpp @@ -315,47 +315,41 @@ INT_PTR CALLBACK DlgSkinOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPara break;
case WM_NOTIFY:
- switch (( ( LPNMHDR )lParam )->idFrom )
- {
+ switch (( ( LPNMHDR )lParam )->idFrom ) {
case IDC_TREE1:
{
NMTREEVIEW * nmtv = ( NMTREEVIEW * ) lParam;
- if ( !nmtv ) return 0;
- if ( nmtv->hdr.code == TVN_SELCHANGEDA
- || nmtv->hdr.code == TVN_SELCHANGEDW )
- {
+ if (nmtv == NULL)
+ return 0;
+
+ if (nmtv->hdr.code == TVN_SELCHANGEDA || nmtv->hdr.code == TVN_SELCHANGEDW) {
SkinListData * sd = NULL;
- if ( hPreviewBitmap )
- {
+ if (hPreviewBitmap) {
ske_UnloadGlyphImage( hPreviewBitmap );
hPreviewBitmap = NULL;
}
- if ( nmtv->itemNew.lParam )
- {
+
+ if (nmtv->itemNew.lParam) {
sd = ( SkinListData* )nmtv->itemNew.lParam;
- {
- TCHAR buf[MAX_PATH];
- PathToRelativeT(sd->File, buf);
- SendDlgItemMessage(hwndDlg, IDC_EDIT_SKIN_FILENAME, WM_SETTEXT, 0, (LPARAM)buf );
- }
- {
- TCHAR prfn[MAX_PATH] = {0};
- TCHAR imfn[MAX_PATH] = {0};
- TCHAR skinfolder[MAX_PATH] = {0};
- GetPrivateProfileString( _T("Skin_Description_Section"), _T("Preview"), _T(""), imfn, SIZEOF( imfn ), sd->File );
- IniParser::GetSkinFolder( sd->File, skinfolder );
- _sntprintf( prfn, SIZEOF( prfn ), _T("%s\\%s"), skinfolder, imfn );
- PathToAbsoluteT(prfn, imfn);
- char * imfn_ch = mir_t2a( imfn );
- hPreviewBitmap = ske_LoadGlyphImage( imfn_ch );
- mir_free( imfn_ch );
- }
+
+ TCHAR buf[MAX_PATH];
+ PathToRelativeT(sd->File, buf);
+ SendDlgItemMessage(hwndDlg, IDC_EDIT_SKIN_FILENAME, WM_SETTEXT, 0, (LPARAM)buf );
+
+ TCHAR prfn[MAX_PATH] = {0};
+ TCHAR imfn[MAX_PATH] = {0};
+ TCHAR skinfolder[MAX_PATH] = {0};
+ GetPrivateProfileString( _T("Skin_Description_Section"), _T("Preview"), _T(""), imfn, SIZEOF( imfn ), sd->File );
+ IniParser::GetSkinFolder( sd->File, skinfolder );
+ _sntprintf( prfn, SIZEOF( prfn ), _T("%s\\%s"), skinfolder, imfn );
+ PathToAbsoluteT(prfn, imfn);
+ hPreviewBitmap = ske_LoadGlyphImage(imfn);
+
EnableWindow( GetDlgItem( hwndDlg, IDC_BUTTON_APPLY_SKIN ), TRUE );
EnableWindow( GetDlgItem( hwndDlg, IDC_BUTTON_INFO ), TRUE );
if ( hPreviewBitmap )
InvalidateRect( GetDlgItem( hwndDlg, IDC_PREVIEW ), NULL, TRUE );
- else //prepare text
- {
+ else { //prepare text
TCHAR Author[255];
TCHAR URL[MAX_PATH];
TCHAR Contact[255];
@@ -396,8 +390,7 @@ INT_PTR CALLBACK DlgSkinOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPara SendDlgItemMessage( hwndDlg, IDC_STATIC_INFO, WM_SETTEXT, 0, (LPARAM)text );
}
}
- else
- {
+ else {
//no selected
SendDlgItemMessage( hwndDlg, IDC_EDIT_SKIN_FILENAME, WM_SETTEXT, 0, (LPARAM)TranslateT("Select skin from list"));
EnableWindow( GetDlgItem( hwndDlg, IDC_BUTTON_APPLY_SKIN ), FALSE );
@@ -408,28 +401,20 @@ INT_PTR CALLBACK DlgSkinOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPara ShowWindow( GetDlgItem( hwndDlg, IDC_PREVIEW ), hPreviewBitmap?SW_SHOW:SW_HIDE );
return 0;
}
- else if ( nmtv->hdr.code == TVN_DELETEITEMA || nmtv->hdr.code == TVN_DELETEITEMW )
- {
+ else if (nmtv->hdr.code == TVN_DELETEITEMA || nmtv->hdr.code == TVN_DELETEITEMW) {
mir_free_and_nil( nmtv->itemOld.lParam );
return 0;
}
- break;
}
+ break;
+
case 0:
- switch (( ( LPNMHDR )lParam )->code )
- {
+ switch (((LPNMHDR)lParam )->code) {
case PSN_APPLY:
- {
- {
- DWORD tick = GetTickCount( );
- pcli->pfnClcBroadcast( INTM_RELOADOPTIONS, 0, 0 );
- NotifyEventHooks( g_CluiData.hEventBkgrChanged, 0, 0 );
- pcli->pfnClcBroadcast( INTM_INVALIDATE, 0, 0 );
- RedrawWindow( GetParent( pcli->hwndContactTree ), NULL, NULL, RDW_INVALIDATE|RDW_FRAME|RDW_ALLCHILDREN );
- }
- return 0;
- }
- break;
+ pcli->pfnClcBroadcast( INTM_RELOADOPTIONS, 0, 0 );
+ NotifyEventHooks( g_CluiData.hEventBkgrChanged, 0, 0 );
+ pcli->pfnClcBroadcast( INTM_INVALIDATE, 0, 0 );
+ RedrawWindow( GetParent( pcli->hwndContactTree ), NULL, NULL, RDW_INVALIDATE|RDW_FRAME|RDW_ALLCHILDREN );
}
break;
}
@@ -449,7 +434,8 @@ int SearchSkinFiles( HWND hwndDlg, TCHAR * Folder ) {
do {
AddSkinToList( hwndDlg, Folder, fd.name );
- }while ( !_tfindnext( hFile, &fd ));
+ }
+ while ( !_tfindnext( hFile, &fd ));
_findclose( hFile );
}
_sntprintf( mask, SIZEOF( mask ), _T("%s\\*"), Folder );
@@ -467,6 +453,7 @@ int SearchSkinFiles( HWND hwndDlg, TCHAR * Folder ) }
return 0;
}
+
HTREEITEM FillAvailableSkinList( HWND hwndDlg )
{
struct _finddata_t fd = {0};
@@ -521,39 +508,26 @@ HTREEITEM AddSkinToListFullName( HWND hwndDlg, TCHAR * fullName ) HTREEITEM AddSkinToList( HWND hwndDlg, TCHAR * path, TCHAR* file )
{
- {
- TCHAR buf[MAX_PATH];
- _sntprintf( buf, SIZEOF( buf ), _T("%s\\%s"), path, file );
+ SkinListData *sd = ( SkinListData * )mir_alloc( sizeof( SkinListData ));
+ if ( !sd )
+ return 0;
+ TCHAR fullName[MAX_PATH], defskinname[MAX_PATH];
+ mir_sntprintf(fullName, SIZEOF(fullName), _T("%s\\%s"), path, file);
+ memmove(defskinname, file, (_tcslen( file )-4) * sizeof(TCHAR));
+ defskinname[_tcslen( file )+1] = _T('\0');
+ if ( !file || _tcschr( file, _T('%'))) {
+ _sntprintf( sd->File, MAX_PATH, _T("%%Default Skin%%"));
+ _sntprintf( sd->Name, 100, TranslateT("%Default Skin%"));
+ _tcsncpy(fullName, TranslateT("Default Skin"), SIZEOF(fullName));
}
- {
- TCHAR fullName[MAX_PATH] = {0};
- TCHAR defskinname[MAX_PATH] = {0};
- SkinListData * sd = NULL;
- sd = ( SkinListData * )mir_alloc( sizeof( SkinListData ));
- if ( !sd ) return 0;
- _sntprintf( fullName, SIZEOF( fullName ), _T("%s\\%s"), path, file );
- memmove( defskinname, file, (_tcslen( file )-4) * sizeof(TCHAR));
- defskinname[_tcslen( file )+1] = _T('\0');
- if ( !file || _tcschr( file, _T('%')))
- {
- //sd->File = "%Default Skin%";
- _sntprintf( sd->File, MAX_PATH, _T("%%Default Skin%%"));
- _sntprintf( sd->Name, 100, TranslateT("%Default Skin%"));
- return AddItemToTree( GetDlgItem( hwndDlg, IDC_TREE1 ), TranslateT("Default Skin"), sd->Name, sd );
- }
- else
- {
- GetPrivateProfileString( _T("Skin_Description_Section"), _T("Name"), defskinname, sd->Name, SIZEOF( sd->Name ), fullName );
- _tcscpy( sd->File, fullName );
- }
- return AddItemToTree( GetDlgItem( hwndDlg, IDC_TREE1 ), fullName, sd->Name, sd );
+ else {
+ GetPrivateProfileString( _T("Skin_Description_Section"), _T("Name"), defskinname, sd->Name, SIZEOF( sd->Name ), fullName );
+ _tcscpy(sd->File, fullName);
}
- return (HTREEITEM)-1;
+ return AddItemToTree( GetDlgItem( hwndDlg, IDC_TREE1 ), fullName, sd->Name, sd );
}
-
-
HTREEITEM FindChild( HWND hTree, HTREEITEM Parent, TCHAR * Caption, void * data )
{
HTREEITEM res = NULL, tmp = NULL;
@@ -561,8 +535,8 @@ HTREEITEM FindChild( HWND hTree, HTREEITEM Parent, TCHAR * Caption, void * data tmp = TreeView_GetChild( hTree, Parent );
else
tmp = TreeView_GetRoot( hTree );
- while ( tmp )
- {
+
+ while (tmp) {
TVITEM tvi;
TCHAR buf[255];
tvi.hItem = tmp;
@@ -570,81 +544,68 @@ HTREEITEM FindChild( HWND hTree, HTREEITEM Parent, TCHAR * Caption, void * data tvi.pszText = (LPTSTR)&buf;
tvi.cchTextMax = 254;
TreeView_GetItem( hTree, &tvi );
- if ( _tcsicmp( Caption, tvi.pszText ) == 0 )
- {
- if ( data )
- {
- SkinListData * sd = NULL;
- TVITEM tvi = {0};
- tvi.hItem = tmp;
- tvi.mask = TVIF_HANDLE|TVIF_PARAM;
- TreeView_GetItem( hTree, &tvi );
- sd = ( SkinListData* )( tvi.lParam );
- if ( sd )
- if ( !_tcsicmp( sd->File, (( SkinListData* )data )->File ))
- return tmp;
- }
- else
+ if ( _tcsicmp(Caption, tvi.pszText) == 0) {
+ if (!data)
return tmp;
+
+ TVITEM tvi = {0};
+ tvi.hItem = tmp;
+ tvi.mask = TVIF_HANDLE|TVIF_PARAM;
+ TreeView_GetItem(hTree, &tvi);
+ SkinListData *sd = (SkinListData*)tvi.lParam;
+ if (sd)
+ if ( !_tcsicmp(sd->File, (( SkinListData* )data )->File))
+ return tmp;
}
- tmp = TreeView_GetNextSibling( hTree, tmp );
+ tmp = TreeView_GetNextSibling(hTree, tmp);
}
return tmp;
}
-
HTREEITEM AddItemToTree( HWND hTree, TCHAR * folder, TCHAR * itemName, void * data )
{
HTREEITEM rootItem = NULL;
HTREEITEM cItem = NULL;
TCHAR path[MAX_PATH];//, mask[MAX_PATH];
- TCHAR * ptr;
- TCHAR * ptrE;
BOOL ext = FALSE;
PathToRelativeT(folder, path);
- ptrE = path;
+ TCHAR *ptrE = path;
while ( *ptrE != _T('\\') && *ptrE != _T('\0') && *ptrE != _T(':')) ptrE++;
- if ( *ptrE == _T('\\'))
- {
+ if (*ptrE == _T('\\')) {
*ptrE = _T('\0');
ptrE++;
}
else ptrE = path;
- ptr = ptrE;
- do
- {
+ TCHAR *ptr = ptrE;
+ do {
while ( *ptrE != _T('\\') && *ptrE != _T('\0')) ptrE++;
- if ( *ptrE == _T('\\'))
- {
+ if ( *ptrE == _T('\\')) {
*ptrE = _T('\0');
ptrE++;
// find item if not - create;
- {
- cItem = FindChild( hTree, rootItem, ptr, NULL );
- if ( !cItem ) // not found - create node
- {
- TVINSERTSTRUCT tvis;
- tvis.hParent = rootItem;
- tvis.hInsertAfter = TVI_ROOT;
- tvis.item.mask = TVIF_PARAM|TVIF_TEXT|TVIF_PARAM;
- tvis.item.pszText = ptr;
- {
- tvis.item.lParam = (LPARAM)NULL;
- }
- cItem = TreeView_InsertItem( hTree, &tvis );
- }
- rootItem = cItem;
- }
+ cItem = FindChild( hTree, rootItem, ptr, NULL );
+ if (!cItem) { // not found - create node
+ TVINSERTSTRUCT tvis;
+ tvis.hParent = rootItem;
+ tvis.hInsertAfter = TVI_ROOT;
+ tvis.item.mask = TVIF_PARAM|TVIF_TEXT|TVIF_PARAM;
+ tvis.item.pszText = ptr;
+ tvis.item.lParam = (LPARAM)NULL;
+ cItem = TreeView_InsertItem( hTree, &tvis );
+ }
+ rootItem = cItem;
+
ptr = ptrE;
}
else ext = TRUE;
- }while ( !ext );
+ }
+ while ( !ext );
+
//Insert item node
cItem = FindChild( hTree, rootItem, itemName, data );
- if ( !cItem )
- {
+ if ( !cItem ) {
TVINSERTSTRUCT tvis;
tvis.hParent = rootItem;
tvis.hInsertAfter = TVI_SORT;
@@ -653,20 +614,16 @@ HTREEITEM AddItemToTree( HWND hTree, TCHAR * folder, TCHAR * itemName, void * da tvis.item.lParam = (LPARAM)data;
return TreeView_InsertItem( hTree, &tvis );
}
- else
- {
- mir_free( data ); //need to free otherwise memory leak
- return cItem;
- }
- return 0;
+
+ mir_free(data); //need to free otherwise memory leak
+ return cItem;
}
INT_PTR SvcActiveSkin(WPARAM wParam, LPARAM lParam)
{
- TCHAR *skinfile;
- TCHAR skinfull[MAX_PATH];
- skinfile = DBGetStringT( NULL, SKIN, "SkinFile");
+ TCHAR *skinfile = DBGetStringT(NULL, SKIN, "SkinFile");
if ( skinfile ) {
+ TCHAR skinfull[MAX_PATH];
PathToAbsoluteT(skinfile, skinfull);
mir_free(skinfile);
return (INT_PTR)mir_tstrdup(skinfull);
@@ -684,14 +641,13 @@ INT_PTR SvcApplySkin(WPARAM wParam, LPARAM lParam) Sync( CLUIFrames_OnClistResize_mod, 0, 0 );
ske_RedrawCompleteWindow( );
Sync( CLUIFrames_OnClistResize_mod, 0, 0 );
- {
- HWND hwnd = pcli->hwndContactList;
- RECT rc = {0};
- GetWindowRect( hwnd, &rc );
- Sync( CLUIFrames_OnMoving, hwnd, &rc );
- }
- if ( g_hCLUIOptionsWnd )
- {
+
+ HWND hwnd = pcli->hwndContactList;
+ RECT rc = {0};
+ GetWindowRect( hwnd, &rc );
+ Sync( CLUIFrames_OnMoving, hwnd, &rc );
+
+ if ( g_hCLUIOptionsWnd ) {
SendDlgItemMessage( g_hCLUIOptionsWnd, IDC_LEFTMARGINSPIN, UDM_SETPOS, 0, db_get_b( NULL, "CLUI", "LeftClientMargin", SETTING_LEFTCLIENTMARIGN_DEFAULT ));
SendDlgItemMessage( g_hCLUIOptionsWnd, IDC_RIGHTMARGINSPIN, UDM_SETPOS, 0, db_get_b( NULL, "CLUI", "RightClientMargin", SETTING_RIGHTCLIENTMARIGN_DEFAULT ));
SendDlgItemMessage( g_hCLUIOptionsWnd, IDC_TOPMARGINSPIN, UDM_SETPOS, 0, db_get_b( NULL, "CLUI", "TopClientMargin", SETTING_TOPCLIENTMARIGN_DEFAULT ));
@@ -713,8 +669,7 @@ INT_PTR SvcPreviewSkin(WPARAM wParam, LPARAM lParam) workRect = dis->rcItem;
OffsetRect( &workRect, -workRect.left, -workRect.top );
- if (lParam)
- {
+ if (lParam) {
TCHAR prfn[MAX_PATH] = {0};
TCHAR imfn[MAX_PATH] = {0};
TCHAR skinfolder[MAX_PATH] = {0};
@@ -722,12 +677,9 @@ INT_PTR SvcPreviewSkin(WPARAM wParam, LPARAM lParam) IniParser::GetSkinFolder((LPCTSTR)lParam, skinfolder );
_sntprintf( prfn, SIZEOF( prfn ), _T("%s\\%s"), skinfolder, imfn );
PathToAbsoluteT(prfn, imfn);
- char * imfn_ch = mir_t2a(imfn);
- hPreviewBitmap = ske_LoadGlyphImage( imfn_ch );
- mir_free( imfn_ch );
- if ( hPreviewBitmap )
- {
+ hPreviewBitmap = ske_LoadGlyphImage(imfn);
+ if (hPreviewBitmap) {
//variables
BITMAP bmp = {0};
POINT imgPos = {0};
@@ -749,11 +701,8 @@ INT_PTR SvcPreviewSkin(WPARAM wParam, LPARAM lParam) imgPos.y = workRect.top+(( wHeight-dHeight )>>1 );
//DrawImage
if ( !g_CluiData.fGDIPlusFail ) //Use gdi+ engine
- {
DrawAvatarImageWithGDIp( dis->hDC, imgPos.x, imgPos.y, dWidth, dHeight, hPreviewBitmap, 0, 0, bmp.bmWidth, bmp.bmHeight, 8, 255 );
- }
- else
- {
+ else {
BLENDFUNCTION bf = {AC_SRC_OVER, 0, 255, AC_SRC_ALPHA };
imgDC = CreateCompatibleDC( dis->hDC );
imgOldbmp = ( HBITMAP )SelectObject( imgDC, hPreviewBitmap );
diff --git a/plugins/Clist_modern/src/modern_skinselector.cpp b/plugins/Clist_modern/src/modern_skinselector.cpp index 10b651ad97..523ebbdb84 100644 --- a/plugins/Clist_modern/src/modern_skinselector.cpp +++ b/plugins/Clist_modern/src/modern_skinselector.cpp @@ -65,9 +65,10 @@ int SkinSelector_DeleteMask(MODERNMASK *mm) }
#define _qtoupper(_c) (((_c) >= 'a' && (_c) <= 'z')?((_c)-('a'+'A')):(_c))
-BOOL wildcmpi(TCHAR* name, TCHAR* mask)
+
+BOOL wildcmpi(const WCHAR *name, const WCHAR *mask)
{
- TCHAR* last = '\0';
+ const WCHAR* last = NULL;
for (;; mask++, name++)
{
if (*mask != '?' && _qtoupper(*mask) != _qtoupper(*name)) break;
@@ -86,9 +87,9 @@ BOOL wildcmpi(TCHAR* name, TCHAR* mask) }
}
-BOOL wildcmpi(char * name, char * mask)
+BOOL wildcmpi(const char *name, const char *mask)
{
- char * last = '\0';
+ const char *last = NULL;
for (;; mask++, name++)
{
if (*mask != '?' && _qtoupper(*mask) != _qtoupper(*name)) break;
diff --git a/plugins/Clist_modern/src/modern_tbbutton.cpp b/plugins/Clist_modern/src/modern_tbbutton.cpp index d8f697ee3a..e8f59245a6 100644 --- a/plugins/Clist_modern/src/modern_tbbutton.cpp +++ b/plugins/Clist_modern/src/modern_tbbutton.cpp @@ -78,13 +78,15 @@ static int TBStateConvert2Flat(int state) static void PaintWorker(TBBUTTONDATA *bct, HDC hdcPaint , POINT *pOffset)
{
- POINT offset = {0};
- if (pOffset)
- offset = *pOffset;
-
if ( !hdcPaint)
return; //early exit
+ POINT offset;
+ if (pOffset)
+ offset = *pOffset;
+ else
+ offset.x = offset.y = 0;
+
RECT rcClient;
GetClientRect(bct->hwnd, &rcClient);
int width = rcClient.right - rcClient.left;
@@ -162,15 +164,11 @@ static void PaintWorker(TBBUTTONDATA *bct, HDC hdcPaint , POINT *pOffset) DrawEdge(hdcMem, &rcClient, BDR_SUNKENOUTER,BF_RECT|BF_SOFT);
}
- RECT rcTemp = rcClient; //content rect
- BYTE bPressed = (bct->stateId == PBS_PRESSED || bct->bIsPushed == TRUE)?1:0;
- HICON hHasIcon = bct->hIcon ? bct->hIcon : NULL;
- BOOL fHasText = (bct->szText[0] != '\0');
+ RECT rcTemp = rcClient; //content rect
+ bool bPressed = (bct->stateId == PBS_PRESSED || bct->bIsPushed == TRUE);
+ bool bHasText = (bct->szText[0] != '\0');
/* formatter */
- RECT rcIcon;
- RECT rcText;
-
if ( !g_CluiData.fDisableSkinEngine) {
/* correct rect according to rcMargins */
@@ -180,38 +178,37 @@ static void PaintWorker(TBBUTTONDATA *bct, HDC hdcPaint , POINT *pOffset) rcTemp.right -= bct->rcMargins.right;
}
- rcIcon = rcTemp;
- rcText = rcTemp;
-
/* reposition button items */
- if (hHasIcon && fHasText ) {
- rcIcon.right = rcIcon.left+16; /* CXSM_ICON */
- rcText.left = rcIcon.right+2;
- }
- else if (hHasIcon) {
- rcIcon.left += (rcIcon.right-rcIcon.left)/2-8;
- rcIcon.right = rcIcon.left+16;
+ RECT rcIcon = rcTemp, rcText = rcTemp;
+ if (bct->hIcon) {
+ if (bHasText) {
+ rcIcon.right = rcIcon.left+16; /* CXSM_ICON */
+ rcText.left = rcIcon.right+2;
+ }
+ else {
+ rcIcon.left += (rcIcon.right-rcIcon.left)/2-8;
+ rcIcon.right = rcIcon.left+16;
+ }
}
/* Check sizes*/
- if (hHasIcon && (rcIcon.right>rcTemp.right || rcIcon.bottom>rcTemp.bottom || rcIcon.left < rcTemp.left || rcIcon.top < rcTemp.top))
- hHasIcon = NULL;
+ if (bct->hIcon && (rcIcon.right>rcTemp.right || rcIcon.bottom>rcTemp.bottom || rcIcon.left < rcTemp.left || rcIcon.top < rcTemp.top))
+ bct->hIcon = NULL;
- if (fHasText && (rcText.right>rcTemp.right || rcText.bottom>rcTemp.bottom || rcText.left < rcTemp.left || rcText.top < rcTemp.top))
- fHasText = FALSE;
+ if (bHasText && (rcText.right>rcTemp.right || rcText.bottom>rcTemp.bottom || rcText.left < rcTemp.left || rcText.top < rcTemp.top))
+ bHasText = FALSE;
- if (hHasIcon) {
+ if (bct->hIcon) {
/* center icon vertically */
rcIcon.top += (rcClient.bottom-rcClient.top)/2 - 8; /* CYSM_ICON/2 */
rcIcon.bottom = rcIcon.top + 16; /* CYSM_ICON */
/* draw it */
- ske_DrawIconEx(hdcMem, rcIcon.left+bPressed, rcIcon.top+bPressed, hHasIcon,
- 16, 16, 0, NULL, DI_NORMAL);
+ ske_DrawIconEx(hdcMem, rcIcon.left+bPressed, rcIcon.top+bPressed, bct->hIcon, 16, 16, 0, NULL, DI_NORMAL);
}
- if (fHasText) {
+ if (bHasText) {
BOOL bCentered = TRUE;
- SetBkMode(hdcMem,TRANSPARENT);
+ SetBkMode(hdcMem, TRANSPARENT);
if (bct->nFontID >= 0)
g_clcPainter.ChangeToFont(hdcMem,NULL,bct->nFontID,NULL);
@@ -227,9 +224,9 @@ static void PaintWorker(TBBUTTONDATA *bct, HDC hdcPaint , POINT *pOffset) BitBlt(hdcPaint, 0, 0, width,height,hdcMem, 0, 0, SRCCOPY);
// better to use try/finally but looks like last one is Microsoft specific
- SelectObject(hdcMem,hOldFont);
- if ( !pOffset) {
- SelectObject(hdcMem,hbmOld);
+ SelectObject(hdcMem, hOldFont);
+ if ( !pOffset) {
+ SelectObject(hdcMem, hbmOld);
DeleteObject(hbmMem);
DeleteDC(hdcMem);
}
diff --git a/plugins/Clist_modern/src/modern_utils.cpp b/plugins/Clist_modern/src/modern_utils.cpp index de11433e3f..18c03de468 100644 --- a/plugins/Clist_modern/src/modern_utils.cpp +++ b/plugins/Clist_modern/src/modern_utils.cpp @@ -135,13 +135,13 @@ BOOL DebugDeleteObject(HGDIOBJ a) #endif
// load small icon (not shared) it IS NEED to be destroyed
-HICON LoadSmallIcon(HINSTANCE hInstance, LPCTSTR lpIconName)
+HICON LoadSmallIcon(HINSTANCE hInstance, int index)
{
- HICON hIcon = NULL; // icon handle
- int index = -(int)lpIconName;
TCHAR filename[MAX_PATH] = {0};
- GetModuleFileName(hInstance,filename,MAX_PATH);
- ExtractIconEx(filename,index,NULL,&hIcon,1);
+ GetModuleFileName(hInstance, filename, MAX_PATH);
+
+ HICON hIcon = NULL;
+ ExtractIconEx(filename, index, NULL, &hIcon, 1);
return hIcon;
}
|