diff options
author | George Hazan <george.hazan@gmail.com> | 2012-06-18 20:53:59 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2012-06-18 20:53:59 +0000 |
commit | 3f23417a1099f73dc28ec1b7d6ec2a1a7fc2b7a2 (patch) | |
tree | 3e0bcd88c55dad310da0dc980e252bf9fbfa6dc5 /src/modules/icolib | |
parent | 537b94169bf2483798a651ee3b96f7904eebe7b4 (diff) |
- PLUGININFO structure removed at all;
- Options_AddPage & UserInfo_AddPage replaced MS_OPT_ADDPAGE & MS_USERINFO_ADDPAGE services respectively
- total internal redesign of options' translation
- code reformatting
git-svn-id: http://svn.miranda-ng.org/main/trunk@477 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'src/modules/icolib')
-rw-r--r-- | src/modules/icolib/extracticon.cpp | 32 | ||||
-rw-r--r-- | src/modules/icolib/skin2icons.cpp | 946 |
2 files changed, 489 insertions, 489 deletions
diff --git a/src/modules/icolib/extracticon.cpp b/src/modules/icolib/extracticon.cpp index 06025ad843..6a9b3a2ccc 100644 --- a/src/modules/icolib/extracticon.cpp +++ b/src/modules/icolib/extracticon.cpp @@ -50,7 +50,7 @@ typedef struct void* _RelativeVirtualAddresstoPtr(IMAGE_DOS_HEADER* pDosHeader, DWORD rva)
{
IMAGE_NT_HEADERS* pPE = (IMAGE_NT_HEADERS*)((BYTE*)pDosHeader + pDosHeader->e_lfanew);
- IMAGE_SECTION_HEADER* pSection = IMAGE_FIRST_SECTION( pPE );
+ IMAGE_SECTION_HEADER* pSection = IMAGE_FIRST_SECTION(pPE);
int i;
for (i = 0; i < pPE->FileHeader.NumberOfSections; i++) {
@@ -145,12 +145,12 @@ void* _FindResource(IMAGE_DOS_HEADER* pDosHeader, void* prt, int resIndex, int r if (pRes[index].OffsetToData & IMAGE_RESOURCE_DATA_IS_DIRECTORY) {
IMAGE_RESOURCE_DIRECTORY* pDir;
- pDir = (IMAGE_RESOURCE_DIRECTORY*)((LPBYTE)prt + (pRes[index].OffsetToData & ~IMAGE_RESOURCE_DATA_IS_DIRECTORY) );
+ pDir = (IMAGE_RESOURCE_DIRECTORY*)((LPBYTE)prt + (pRes[index].OffsetToData & ~IMAGE_RESOURCE_DATA_IS_DIRECTORY));
pRes = (IMAGE_RESOURCE_DIRECTORY_ENTRY*)(pDir+1);
index = 0;
}
- if ( pRes[index].OffsetToData & IMAGE_RESOURCE_DATA_IS_DIRECTORY )
+ if (pRes[index].OffsetToData & IMAGE_RESOURCE_DATA_IS_DIRECTORY)
return NULL;
pEntry = (IMAGE_RESOURCE_DATA_ENTRY*)((LPBYTE)prt + pRes[index].OffsetToData);
@@ -183,21 +183,21 @@ UINT _ExtractFromExe(HANDLE hFile, int iconIndex, int cxIconSize, int cyIconSize if ((DWORD)(pDosHeader->e_lfanew) >= fileLen) goto cleanup;
pRes = _GetResourceTable(pDosHeader);
- if (!pRes) goto cleanup;
- if (!phicon) {
+ if ( !pRes) goto cleanup;
+ if ( !phicon) {
retval = _FindResourceCount(pRes, (int)RT_GROUP_ICON);
goto cleanup;
}
pIconDir = (NEWHEADER*)_FindResource(pDosHeader, pRes, iconIndex, (int)RT_GROUP_ICON, &cbSize);
- if (!pIconDir) goto cleanup;
+ if ( !pIconDir) goto cleanup;
if (pIconDir->Reserved || pIconDir->ResType != RES_ICON) goto cleanup;
idIcon = LookupIconIdFromDirectoryEx((LPBYTE)pIconDir, TRUE, cxIconSize, cyIconSize, flags);
pIcon = (LPBITMAPINFOHEADER)_FindResource(pDosHeader, pRes, -idIcon, (int)RT_ICON, &cbSize);
- if (!pIcon) goto cleanup;
+ if ( !pIcon) goto cleanup;
- if ( pIcon->biSize != sizeof(BITMAPINFOHEADER) && pIcon->biSize != sizeof(BITMAPCOREHEADER)) {
+ if (pIcon->biSize != sizeof(BITMAPINFOHEADER) && pIcon->biSize != sizeof(BITMAPCOREHEADER)) {
_ASSERT(0);
goto cleanup;
}
@@ -212,20 +212,20 @@ cleanup: return retval;
}
-UINT _ExtractFromICO( LPCTSTR pFileName, int iconIndex, int cxIcon, int cyIcon, HICON* phicon, UINT flags )
+UINT _ExtractFromICO(LPCTSTR pFileName, int iconIndex, int cxIcon, int cyIcon, HICON* phicon, UINT flags)
{
HICON hicon;
- if ( iconIndex >= 1 )
+ if (iconIndex >= 1)
return 0;
// do we just want a count?
- if (!phicon)
+ if ( !phicon)
return 1;
flags |= LR_LOADFROMFILE;
- hicon = (HICON)LoadImage( NULL, pFileName, IMAGE_ICON, cxIcon, cyIcon, flags );
- if (!hicon)
+ hicon = (HICON)LoadImage(NULL, pFileName, IMAGE_ICON, cxIcon, cyIcon, flags);
+ if ( !hicon)
return 0;
*phicon = hicon;
@@ -253,12 +253,12 @@ UINT _ExtractIconEx(LPCTSTR lpszFile, int iconIndex, int cxIcon, int cyIcon, HIC return 0;
// failed to read file signature
- if ( !ReadFile(hFile, &magic, sizeof(magic), &read, NULL ) || (read != sizeof(magic))) {
+ if ( !ReadFile(hFile, &magic, sizeof(magic), &read, NULL) || (read != sizeof(magic))) {
CloseHandle(hFile);
return 0;
}
- switch ( magic[0] ) {
+ switch (magic[0]) {
case IMAGE_DOS_SIGNATURE:
res = _ExtractFromExe(hFile, iconIndex, cxIcon, cyIcon, phicon, flags);
break;
@@ -269,7 +269,7 @@ UINT _ExtractIconEx(LPCTSTR lpszFile, int iconIndex, int cxIcon, int cyIcon, HIC break;
case MAGIC_ICON:
- if ((magic[1] == MAGIC_ICO1 || magic[1] == MAGIC_CUR ) && magic[2] >= 1 )
+ if ((magic[1] == MAGIC_ICO1 || magic[1] == MAGIC_CUR) && magic[2] >= 1)
res = _ExtractFromICO(lpszFile, iconIndex, cxIcon, cyIcon, phicon, flags);
break;
diff --git a/src/modules/icolib/skin2icons.cpp b/src/modules/icolib/skin2icons.cpp index 2c2776d523..e02fcf579a 100644 --- a/src/modules/icolib/skin2icons.cpp +++ b/src/modules/icolib/skin2icons.cpp @@ -42,25 +42,25 @@ struct IcoLibOptsData { CRITICAL_SECTION csIconList;
-#define SECTIONPARAM_MAKE(index, level, flags) MAKELONG((index)&0xFFFF, MAKEWORD( level, flags ) )
-#define SECTIONPARAM_INDEX(lparam) LOWORD( lparam )
-#define SECTIONPARAM_LEVEL(lparam) LOBYTE( HIWORD(lparam) )
-#define SECTIONPARAM_FLAGS(lparam) HIBYTE( HIWORD(lparam) )
+#define SECTIONPARAM_MAKE(index, level, flags) MAKELONG((index)&0xFFFF, MAKEWORD(level, flags))
+#define SECTIONPARAM_INDEX(lparam) LOWORD(lparam)
+#define SECTIONPARAM_LEVEL(lparam) LOBYTE(HIWORD(lparam))
+#define SECTIONPARAM_FLAGS(lparam) HIBYTE(HIWORD(lparam))
#define SECTIONPARAM_HAVEPAGE 0x0001
-static int sttCompareSections( const SectionItem* p1, const SectionItem* p2 )
-{ return _tcscmp( p1->name, p2->name );
+static int sttCompareSections(const SectionItem* p1, const SectionItem* p2)
+{ return _tcscmp(p1->name, p2->name);
}
-static LIST<SectionItem> sectionList( 20, sttCompareSections );
+static LIST<SectionItem> sectionList(20, sttCompareSections);
-static int sttCompareIconSourceFiles( const IconSourceFile* p1, const IconSourceFile* p2 )
-{ return _tcsicmp( p1->file, p2->file );
+static int sttCompareIconSourceFiles(const IconSourceFile* p1, const IconSourceFile* p2)
+{ return _tcsicmp(p1->file, p2->file);
}
-static LIST<IconSourceFile> iconSourceFileList( 10, sttCompareIconSourceFiles );
+static LIST<IconSourceFile> iconSourceFileList(10, sttCompareIconSourceFiles);
-static int sttCompareIconSourceItems( const IconSourceItem* p1, const IconSourceItem* p2 )
+static int sttCompareIconSourceItems(const IconSourceItem* p1, const IconSourceItem* p2)
{ if (p1->indx < p2->indx)
return -1;
@@ -79,82 +79,82 @@ static int sttCompareIconSourceItems( const IconSourceItem* p1, const IconSource if (p1->cy > p2->cy)
return 1;
- if ( p1->file == p2->file )
+ if (p1->file == p2->file)
return 0;
- return ( p1->file > p2->file ) ? 1 : -1;
+ return (p1->file > p2->file) ? 1 : -1;
}
-static LIST<IconSourceItem> iconSourceList( 20, sttCompareIconSourceItems );
+static LIST<IconSourceItem> iconSourceList(20, sttCompareIconSourceItems);
-static int sttCompareIcons( const IconItem* p1, const IconItem* p2 )
-{ return strcmp( p1->name, p2->name );
+static int sttCompareIcons(const IconItem* p1, const IconItem* p2)
+{ return strcmp(p1->name, p2->name);
}
-static LIST<IconItem> iconList( 20, sttCompareIcons );
+static LIST<IconItem> iconList(20, sttCompareIcons);
/////////////////////////////////////////////////////////////////////////////////////////
// Utility functions
static void __fastcall MySetCursor(TCHAR* nCursor)
-{ SetCursor( LoadCursor( NULL, nCursor ));
+{ SetCursor(LoadCursor(NULL, nCursor));
}
static void __fastcall SAFE_FREE(void** p)
{
- if ( *p ) {
- mir_free( *p );
+ if (*p) {
+ mir_free(*p);
*p = NULL;
} }
-static void __fastcall SafeDestroyIcon( HICON* icon )
+static void __fastcall SafeDestroyIcon(HICON* icon)
{
- if ( *icon ) {
- DestroyIcon( *icon );
+ if (*icon) {
+ DestroyIcon(*icon);
*icon = NULL;
} }
// Helper functions to manage Icon resources
-IconSourceFile* IconSourceFile_Get( const TCHAR* file, bool isPath )
+IconSourceFile* IconSourceFile_Get(const TCHAR* file, bool isPath)
{
TCHAR fileFull[ MAX_PATH ];
- if ( !file )
+ if ( !file)
return NULL;
if (isPath)
- pathToAbsoluteT( file, fileFull, NULL );
+ pathToAbsoluteT(file, fileFull, NULL);
/// TODO: convert path to long - eliminate duplicate items
else
- _tcscpy( fileFull, file );
+ _tcscpy(fileFull, file);
IconSourceFile key = { fileFull };
int ix;
- if (( ix = iconSourceFileList.getIndex( &key )) != -1 ) {
+ if ((ix = iconSourceFileList.getIndex(&key)) != -1) {
iconSourceFileList[ ix ]->ref_count++;
return iconSourceFileList[ ix ];
}
- IconSourceFile* newItem = (IconSourceFile*)mir_calloc( sizeof( IconSourceFile ));
- newItem->file = mir_tstrdup( fileFull );
+ IconSourceFile* newItem = (IconSourceFile*)mir_calloc(sizeof(IconSourceFile));
+ newItem->file = mir_tstrdup(fileFull);
newItem->ref_count = 1;
- iconSourceFileList.insert( newItem );
+ iconSourceFileList.insert(newItem);
return newItem;
}
-int IconSourceFile_Release( IconSourceFile** pitem )
+int IconSourceFile_Release(IconSourceFile** pitem)
{
- if ( pitem && *pitem && (*pitem)->ref_count ) {
+ if (pitem && *pitem && (*pitem)->ref_count) {
IconSourceFile* item = *pitem;
- if ( --item->ref_count <= 0 ) {
+ if (--item->ref_count <= 0) {
int indx;
- if (( indx = iconSourceFileList.getIndex( item )) != -1 ) {
- SAFE_FREE(( void** )&item->file );
- iconSourceFileList.remove( indx );
- SAFE_FREE(( void** )&item );
+ if ((indx = iconSourceFileList.getIndex(item)) != -1) {
+ SAFE_FREE((void**)&item->file);
+ iconSourceFileList.remove(indx);
+ SAFE_FREE((void**)&item);
}
}
*pitem = NULL;
@@ -169,15 +169,15 @@ static int BytesPerScanLine(int PixelsPerScanline, int BitsPerPixel, int Alignme return bytes / 8;
}
-static int InitializeBitmapInfoHeader( HBITMAP bitmap, BITMAPINFOHEADER* bi )
+static int InitializeBitmapInfoHeader(HBITMAP bitmap, BITMAPINFOHEADER* bi)
{
DIBSECTION DS;
int bytes;
DS.dsBmih.biSize = 0;
- bytes = GetObject( bitmap, sizeof(DS), &DS );
- if ( bytes == 0 ) return 1; // Failure
- else if (( bytes >= (sizeof(DS.dsBm) + sizeof(DS.dsBmih))) &&
+ bytes = GetObject(bitmap, sizeof(DS), &DS);
+ if (bytes == 0) return 1; // Failure
+ else if ((bytes >= (sizeof(DS.dsBm) + sizeof(DS.dsBmih))) &&
(DS.dsBmih.biSize >= DWORD(sizeof(DS.dsBmih))))
*bi = DS.dsBmih;
else {
@@ -188,25 +188,25 @@ static int InitializeBitmapInfoHeader( HBITMAP bitmap, BITMAPINFOHEADER* bi ) }
bi->biBitCount = DS.dsBm.bmBitsPixel * DS.dsBm.bmPlanes;
bi->biPlanes = 1;
- if ( bi->biClrImportant > bi->biClrUsed )
+ if (bi->biClrImportant > bi->biClrUsed)
bi->biClrImportant = bi->biClrUsed;
- if ( !bi->biSizeImage )
- bi->biSizeImage = BytesPerScanLine( bi->biWidth, bi->biBitCount, 32 ) * abs( bi->biHeight );
+ if ( !bi->biSizeImage)
+ bi->biSizeImage = BytesPerScanLine(bi->biWidth, bi->biBitCount, 32) * abs(bi->biHeight);
return 0; // Success
}
-static int InternalGetDIBSizes( HBITMAP bitmap, int* InfoHeaderSize, int* ImageSize )
+static int InternalGetDIBSizes(HBITMAP bitmap, int* InfoHeaderSize, int* ImageSize)
{
BITMAPINFOHEADER bi;
- if ( InitializeBitmapInfoHeader( bitmap, &bi )) return 1; // Failure
- if ( bi.biBitCount > 8 ) {
+ if (InitializeBitmapInfoHeader(bitmap, &bi)) return 1; // Failure
+ if (bi.biBitCount > 8) {
*InfoHeaderSize = sizeof(BITMAPINFOHEADER);
- if ((bi.biCompression & BI_BITFIELDS) != 0 )
+ if ((bi.biCompression & BI_BITFIELDS) != 0)
*InfoHeaderSize += 12;
}
else {
- if ( bi.biClrUsed == 0 )
+ if (bi.biClrUsed == 0)
*InfoHeaderSize = sizeof(BITMAPINFOHEADER) +
sizeof(RGBQUAD) * (int)(1 << bi.biBitCount);
else
@@ -217,53 +217,53 @@ static int InternalGetDIBSizes( HBITMAP bitmap, int* InfoHeaderSize, int* ImageS return 0; // Success
}
-static int InternalGetDIB( HBITMAP bitmap, HPALETTE palette, void* bitmapInfo, void* Bits )
+static int InternalGetDIB(HBITMAP bitmap, HPALETTE palette, void* bitmapInfo, void* Bits)
{
HPALETTE oldPal = 0;
- if ( InitializeBitmapInfoHeader( bitmap, (BITMAPINFOHEADER*)bitmapInfo )) return 1; // Failure
+ if (InitializeBitmapInfoHeader(bitmap, (BITMAPINFOHEADER*)bitmapInfo)) return 1; // Failure
HDC DC = CreateCompatibleDC(0);
- if ( palette ) {
- oldPal = SelectPalette( DC, palette, FALSE );
- RealizePalette( DC );
+ if (palette) {
+ oldPal = SelectPalette(DC, palette, FALSE);
+ RealizePalette(DC);
}
- int result = GetDIBits( DC, bitmap, 0, ((BITMAPINFOHEADER*)bitmapInfo)->biHeight, Bits, (BITMAPINFO*)bitmapInfo, DIB_RGB_COLORS) == 0;
+ int result = GetDIBits(DC, bitmap, 0, ((BITMAPINFOHEADER*)bitmapInfo)->biHeight, Bits, (BITMAPINFO*)bitmapInfo, DIB_RGB_COLORS) == 0;
- if ( oldPal ) SelectPalette( DC, oldPal, FALSE );
- DeleteDC( DC );
+ if (oldPal) SelectPalette(DC, oldPal, FALSE);
+ DeleteDC(DC);
return result;
}
-static int GetIconData( HICON icon, BYTE** data, int* size )
+static int GetIconData(HICON icon, BYTE** data, int* size)
{
ICONINFO iconInfo;
int MonoInfoSize, ColorInfoSize;
int MonoBitsSize, ColorBitsSize;
- if ( !data || !size ) return 1; // Failure
+ if ( !data || !size) return 1; // Failure
- if ( !GetIconInfo( icon, &iconInfo )) return 1; // Failure
+ if ( !GetIconInfo(icon, &iconInfo)) return 1; // Failure
- if ( InternalGetDIBSizes( iconInfo.hbmMask, &MonoInfoSize, &MonoBitsSize ) ||
- InternalGetDIBSizes( iconInfo.hbmColor, &ColorInfoSize, &ColorBitsSize )) {
- DeleteObject( iconInfo.hbmColor );
- DeleteObject( iconInfo.hbmMask );
+ if (InternalGetDIBSizes(iconInfo.hbmMask, &MonoInfoSize, &MonoBitsSize) ||
+ InternalGetDIBSizes(iconInfo.hbmColor, &ColorInfoSize, &ColorBitsSize)) {
+ DeleteObject(iconInfo.hbmColor);
+ DeleteObject(iconInfo.hbmMask);
return 1; // Failure
}
- void* MonoInfo = mir_alloc( MonoInfoSize );
- void* MonoBits = mir_alloc( MonoBitsSize );
- void* ColorInfo = mir_alloc( ColorInfoSize );
- void* ColorBits = mir_alloc( ColorBitsSize );
-
- if ( InternalGetDIB( iconInfo.hbmMask, 0, MonoInfo, MonoBits ) ||
- InternalGetDIB( iconInfo.hbmColor, 0, ColorInfo, ColorBits )) {
- SAFE_FREE( &MonoInfo );
- SAFE_FREE( &MonoBits );
- SAFE_FREE( &ColorInfo );
- SAFE_FREE( &ColorBits );
- DeleteObject( iconInfo.hbmColor );
- DeleteObject( iconInfo.hbmMask );
+ void* MonoInfo = mir_alloc(MonoInfoSize);
+ void* MonoBits = mir_alloc(MonoBitsSize);
+ void* ColorInfo = mir_alloc(ColorInfoSize);
+ void* ColorBits = mir_alloc(ColorBitsSize);
+
+ if (InternalGetDIB(iconInfo.hbmMask, 0, MonoInfo, MonoBits) ||
+ InternalGetDIB(iconInfo.hbmColor, 0, ColorInfo, ColorBits)) {
+ SAFE_FREE(&MonoInfo);
+ SAFE_FREE(&MonoBits);
+ SAFE_FREE(&ColorInfo);
+ SAFE_FREE(&ColorBits);
+ DeleteObject(iconInfo.hbmColor);
+ DeleteObject(iconInfo.hbmMask);
return 1; // Failure
}
@@ -272,141 +272,141 @@ static int GetIconData( HICON icon, BYTE** data, int* size ) BYTE* buf = *data;
((BITMAPINFOHEADER*)ColorInfo)->biHeight *= 2; // color height includes mono bits
- memcpy( buf, ColorInfo, ColorInfoSize );
+ memcpy(buf, ColorInfo, ColorInfoSize);
buf += ColorInfoSize;
- memcpy( buf, ColorBits, ColorBitsSize );
+ memcpy(buf, ColorBits, ColorBitsSize);
buf += ColorBitsSize;
- memcpy( buf, MonoBits, MonoBitsSize );
-
- SAFE_FREE( &MonoInfo );
- SAFE_FREE( &MonoBits );
- SAFE_FREE( &ColorInfo );
- SAFE_FREE( &ColorBits );
- DeleteObject( iconInfo.hbmColor );
- DeleteObject( iconInfo.hbmMask );
+ memcpy(buf, MonoBits, MonoBitsSize);
+
+ SAFE_FREE(&MonoInfo);
+ SAFE_FREE(&MonoBits);
+ SAFE_FREE(&ColorInfo);
+ SAFE_FREE(&ColorBits);
+ DeleteObject(iconInfo.hbmColor);
+ DeleteObject(iconInfo.hbmMask);
return 0; // Success
}
#define VER30 0x00030000
-static HICON IconSourceItem_GetIcon( IconSourceItem* item )
+static HICON IconSourceItem_GetIcon(IconSourceItem* item)
{
- if ( item->icon ) {
+ if (item->icon) {
item->icon_ref_count++;
return item->icon;
}
- if ( item->icon_size ) {
- item->icon = CreateIconFromResourceEx( item->icon_data, item->icon_size, TRUE, VER30, item->cx, item->cy, LR_COLOR );
- if ( item->icon ) {
+ if (item->icon_size) {
+ item->icon = CreateIconFromResourceEx(item->icon_data, item->icon_size, TRUE, VER30, item->cx, item->cy, LR_COLOR);
+ if (item->icon) {
item->icon_ref_count++;
return item->icon;
}
}
//SHOULD BE REPLACED WITH GOOD ENOUGH FUNCTION
- _ExtractIconEx( item->file->file, item->indx, item->cx, item->cy, &item->icon, LR_COLOR );
+ _ExtractIconEx(item->file->file, item->indx, item->cx, item->cy, &item->icon, LR_COLOR);
- if ( item->icon )
+ if (item->icon)
item->icon_ref_count++;
return item->icon;
}
-static int IconSourceItem_ReleaseIcon( IconSourceItem* item )
+static int IconSourceItem_ReleaseIcon(IconSourceItem* item)
{
- if ( item && item->icon_ref_count )
+ if (item && item->icon_ref_count)
{
item->icon_ref_count--;
- if ( !item->icon_ref_count ) {
- if ( !item->icon_size )
- if ( GetIconData( item->icon, &item->icon_data, &item->icon_size ))
+ if ( !item->icon_ref_count) {
+ if ( !item->icon_size)
+ if (GetIconData(item->icon, &item->icon_data, &item->icon_size))
item->icon_size = 0; // Failure
- SafeDestroyIcon( &item->icon );
+ SafeDestroyIcon(&item->icon);
}
return 0; // Success
}
return 1; // Failure
}
-IconSourceItem* GetIconSourceItem( const TCHAR* file, int indx, int cxIcon, int cyIcon )
+IconSourceItem* GetIconSourceItem(const TCHAR* file, int indx, int cxIcon, int cyIcon)
{
- if ( !file )
+ if ( !file)
return NULL;
- IconSourceFile* r_file = IconSourceFile_Get( file, true );
+ IconSourceFile* r_file = IconSourceFile_Get(file, true);
IconSourceItem key = { r_file, indx, cxIcon, cyIcon };
int ix;
- if (( ix = iconSourceList.getIndex( &key )) != -1 ) {
- IconSourceFile_Release( &r_file );
+ if ((ix = iconSourceList.getIndex(&key)) != -1) {
+ IconSourceFile_Release(&r_file);
iconSourceList[ ix ]->ref_count++;
return iconSourceList[ ix ];
}
- IconSourceItem* newItem = (IconSourceItem*)mir_calloc( sizeof( IconSourceItem ));
+ IconSourceItem* newItem = (IconSourceItem*)mir_calloc(sizeof(IconSourceItem));
newItem->file = r_file;
newItem->indx = indx;
newItem->ref_count = 1;
newItem->cx = cxIcon;
newItem->cy = cyIcon;
- iconSourceList.insert( newItem );
+ iconSourceList.insert(newItem);
return newItem;
}
-IconSourceItem* GetIconSourceItemFromPath( const TCHAR* path, int cxIcon, int cyIcon )
+IconSourceItem* GetIconSourceItemFromPath(const TCHAR* path, int cxIcon, int cyIcon)
{
TCHAR *comma;
TCHAR file[ MAX_PATH ];
int n;
- if ( !path )
+ if ( !path)
return NULL;
- lstrcpyn( file, path, SIZEOF( file ));
- comma = _tcsrchr( file, ',' );
- if ( !comma )
+ lstrcpyn(file, path, SIZEOF(file));
+ comma = _tcsrchr(file, ',');
+ if ( !comma)
n = 0;
else {
- n = _ttoi( comma+1 );
+ n = _ttoi(comma+1);
*comma = 0;
}
- return GetIconSourceItem( file, n, cxIcon, cyIcon );
+ return GetIconSourceItem(file, n, cxIcon, cyIcon);
}
-IconSourceItem* CreateStaticIconSourceItem( int cxIcon, int cyIcon )
+IconSourceItem* CreateStaticIconSourceItem(int cxIcon, int cyIcon)
{
TCHAR sourceName[ MAX_PATH ];
IconSourceFile key = { sourceName };
int i = 0;
do { // find new unique name
- mir_sntprintf( sourceName, SIZEOF( sourceName ), _T("*StaticIcon_%d"), ++i);
- } while ( iconSourceFileList.getIndex( &key ) != -1 );
+ mir_sntprintf(sourceName, SIZEOF(sourceName), _T("*StaticIcon_%d"), ++i);
+ } while (iconSourceFileList.getIndex(&key) != -1);
- IconSourceItem* newItem = (IconSourceItem*)mir_calloc( sizeof( IconSourceItem ));
- newItem->file = IconSourceFile_Get( sourceName, false );
+ IconSourceItem* newItem = (IconSourceItem*)mir_calloc(sizeof(IconSourceItem));
+ newItem->file = IconSourceFile_Get(sourceName, false);
newItem->indx = 0;
newItem->ref_count = 1;
newItem->cx = cxIcon;
newItem->cy = cyIcon;
- iconSourceList.insert( newItem );
+ iconSourceList.insert(newItem);
return newItem;
}
-static int IconSourceItem_Release( IconSourceItem** pitem )
+static int IconSourceItem_Release(IconSourceItem** pitem)
{
- if ( pitem && *pitem && (*pitem)->ref_count ) {
+ if (pitem && *pitem && (*pitem)->ref_count) {
IconSourceItem* item = *pitem;
item->ref_count--;
- if ( !item->ref_count ) {
+ if ( !item->ref_count) {
int indx;
- if (( indx = iconSourceList.getIndex( item )) != -1 ) {
- IconSourceFile_Release( &item->file );
- SafeDestroyIcon( &item->icon );
- SAFE_FREE(( void** )&item->icon_data );
- iconSourceList.remove( indx );
- SAFE_FREE(( void** )&item );
+ if ((indx = iconSourceList.getIndex(item)) != -1) {
+ IconSourceFile_Release(&item->file);
+ SafeDestroyIcon(&item->icon);
+ SAFE_FREE((void**)&item->icon_data);
+ iconSourceList.remove(indx);
+ SAFE_FREE((void**)&item);
}
}
*pitem = NULL;
@@ -418,47 +418,47 @@ static int IconSourceItem_Release( IconSourceItem** pitem ) /////////////////////////////////////////////////////////////////////////////////////////
// Service functions
-static HICON ExtractIconFromPath( const TCHAR *path, int cxIcon, int cyIcon )
+static HICON ExtractIconFromPath(const TCHAR *path, int cxIcon, int cyIcon)
{
TCHAR *comma;
TCHAR file[ MAX_PATH ], fileFull[ MAX_PATH ];
int n;
HICON hIcon;
- if ( !path )
+ if ( !path)
return (HICON)NULL;
- lstrcpyn( file, path, SIZEOF( file ));
- comma = _tcsrchr( file, ',' );
- if ( !comma )
+ lstrcpyn(file, path, SIZEOF(file));
+ comma = _tcsrchr(file, ',');
+ if ( !comma)
n = 0;
else {
- n = _ttoi( comma+1 );
+ n = _ttoi(comma+1);
*comma = 0;
}
- pathToAbsoluteT( file, fileFull, NULL );
+ pathToAbsoluteT(file, fileFull, NULL);
hIcon = NULL;
//SHOULD BE REPLACED WITH GOOD ENOUGH FUNCTION
- _ExtractIconEx( fileFull, n, cxIcon, cyIcon, &hIcon, LR_COLOR );
+ _ExtractIconEx(fileFull, n, cxIcon, cyIcon, &hIcon, LR_COLOR);
return hIcon;
}
static SectionItem* IcoLib_AddSection(TCHAR *sectionName, BOOL create_new)
{
- if ( !sectionName )
+ if ( !sectionName)
return NULL;
int indx;
SectionItem key = { sectionName, 0 };
- if (( indx = sectionList.getIndex( &key )) != -1 )
+ if ((indx = sectionList.getIndex(&key)) != -1)
return sectionList[ indx ];
- if ( create_new ) {
- SectionItem* newItem = ( SectionItem* )mir_calloc( sizeof( SectionItem ));
- newItem->name = mir_tstrdup( sectionName );
+ if (create_new) {
+ SectionItem* newItem = (SectionItem*)mir_calloc(sizeof(SectionItem));
+ newItem->name = mir_tstrdup(sectionName);
newItem->flags = 0;
- sectionList.insert( newItem );
+ sectionList.insert(newItem);
bNeedRebuild = TRUE;
return newItem;
}
@@ -468,15 +468,15 @@ static SectionItem* IcoLib_AddSection(TCHAR *sectionName, BOOL create_new) static void IcoLib_RemoveSection(SectionItem* section)
{
- if ( !section )
+ if ( !section)
return;
int indx;
- if (( indx = sectionList.getIndex( section )) != -1 ) {
- sectionList.remove( indx );
- SAFE_FREE(( void** )§ion->name);
- SAFE_FREE(( void** )§ion );
+ if ((indx = sectionList.getIndex(section)) != -1) {
+ sectionList.remove(indx);
+ SAFE_FREE((void**)§ion->name);
+ SAFE_FREE((void**)§ion);
bNeedRebuild = TRUE;
}
}
@@ -485,7 +485,7 @@ static IconItem* IcoLib_FindIcon(const char* pszIconName) {
int indx;
IconItem key = { (char*)pszIconName };
- if (( indx = iconList.getIndex( &key )) != -1 )
+ if ((indx = iconList.getIndex(&key)) != -1)
return iconList[ indx ];
return NULL;
@@ -496,13 +496,13 @@ static IconItem* IcoLib_FindHIcon(HICON hIcon, bool &big) IconItem* item = NULL;
int indx;
- for ( indx = 0; indx < iconList.getCount(); indx++ ) {
- if ( iconList[ indx ]->source_small && iconList[ indx ]->source_small->icon == hIcon) {
+ for (indx = 0; indx < iconList.getCount(); indx++) {
+ if (iconList[ indx ]->source_small && iconList[ indx ]->source_small->icon == hIcon) {
item = iconList[ indx ];
big = false;
break;
}
- else if ( iconList[ indx ]->source_big && iconList[ indx ]->source_big->icon == hIcon) {
+ else if (iconList[ indx ]->source_big && iconList[ indx ]->source_big->icon == hIcon) {
item = iconList[ indx ];
big = true;
break;
@@ -516,177 +516,177 @@ static void IcoLib_FreeIcon(IconItem* icon) {
if ( !icon) return;
- SAFE_FREE(( void** )&icon->name );
- SAFE_FREE(( void** )&icon->description );
- SAFE_FREE(( void** )&icon->default_file );
- SAFE_FREE(( void** )&icon->temp_file );
- if ( icon->section) {
+ SAFE_FREE((void**)&icon->name);
+ SAFE_FREE((void**)&icon->description);
+ SAFE_FREE((void**)&icon->default_file);
+ SAFE_FREE((void**)&icon->temp_file);
+ if (icon->section) {
if ( !--icon->section->ref_count)
- IcoLib_RemoveSection( icon->section );
+ IcoLib_RemoveSection(icon->section);
icon->section = NULL;
}
- IconSourceItem_Release( &icon->source_small );
- IconSourceItem_Release( &icon->source_big );
- IconSourceItem_Release( &icon->default_icon );
- SafeDestroyIcon( &icon->temp_icon );
+ IconSourceItem_Release(&icon->source_small);
+ IconSourceItem_Release(&icon->source_big);
+ IconSourceItem_Release(&icon->default_icon);
+ SafeDestroyIcon(&icon->temp_icon);
}
/////////////////////////////////////////////////////////////////////////////////////////
// IcoLib_AddNewIcon
-HANDLE IcoLib_AddNewIcon( SKINICONDESC* sid )
+HANDLE IcoLib_AddNewIcon(SKINICONDESC* sid)
{
int utf = 0, utf_path = 0;
IconItem* item;
- if ( !sid->cbSize )
+ if ( !sid->cbSize)
return NULL;
- if ( sid->cbSize < SKINICONDESC_SIZE_V1 )
+ if (sid->cbSize < SKINICONDESC_SIZE_V1)
return NULL;
- if ( sid->cbSize >= SKINICONDESC_SIZE ) {
+ if (sid->cbSize >= SKINICONDESC_SIZE) {
utf = sid->flags & SIDF_UNICODE ? 1 : 0;
utf_path = sid->flags & SIDF_PATH_UNICODE ? 1 : 0;
}
- EnterCriticalSection( &csIconList );
+ EnterCriticalSection(&csIconList);
- item = IcoLib_FindIcon( sid->pszName );
- if ( !item ) {
- item = ( IconItem* )mir_alloc( sizeof( IconItem ));
+ item = IcoLib_FindIcon(sid->pszName);
+ if ( !item) {
+ item = (IconItem*)mir_alloc(sizeof(IconItem));
item->name = sid->pszName;
- iconList.insert( item );
+ iconList.insert(item);
}
- else IcoLib_FreeIcon( item );
+ else IcoLib_FreeIcon(item);
- ZeroMemory( item, sizeof( *item ));
- item->name = mir_strdup( sid->pszName );
- if ( utf ) {
- item->description = mir_u2t( sid->pwszDescription );
- item->section = IcoLib_AddSection( sid->pwszSection, TRUE );
+ ZeroMemory(item, sizeof(*item));
+ item->name = mir_strdup(sid->pszName);
+ if (utf) {
+ item->description = mir_u2t(sid->pwszDescription);
+ item->section = IcoLib_AddSection(sid->pwszSection, TRUE);
}
else {
- item->description = mir_a2t( sid->pszDescription );
- WCHAR* pwszSection = sid->pszSection ? mir_a2u( sid->pszSection ) : NULL;
- item->section = IcoLib_AddSection( pwszSection, TRUE );
- SAFE_FREE(( void** )&pwszSection );
+ item->description = mir_a2t(sid->pszDescription);
+ WCHAR* pwszSection = sid->pszSection ? mir_a2u(sid->pszSection) : NULL;
+ item->section = IcoLib_AddSection(pwszSection, TRUE);
+ SAFE_FREE((void**)&pwszSection);
}
- if ( item->section ) {
+ if (item->section) {
item->section->ref_count++;
item->orderID = ++item->section->maxOrder;
}
else
item->orderID = 0;
- if ( sid->pszDefaultFile ) {
- if ( utf_path ) {
+ if (sid->pszDefaultFile) {
+ if (utf_path) {
WCHAR fileFull[ MAX_PATH ];
- pathToAbsoluteW( sid->pwszDefaultFile, fileFull, NULL );
- item->default_file = mir_wstrdup( fileFull );
+ pathToAbsoluteW(sid->pwszDefaultFile, fileFull, NULL);
+ item->default_file = mir_wstrdup(fileFull);
}
else {
- WCHAR *file = mir_a2u( sid->pszDefaultFile );
+ WCHAR *file = mir_a2u(sid->pszDefaultFile);
WCHAR fileFull[ MAX_PATH ];
- pathToAbsoluteW( file, fileFull, NULL );
- SAFE_FREE(( void** )&file );
- item->default_file = mir_wstrdup( fileFull );
+ pathToAbsoluteW(file, fileFull, NULL);
+ SAFE_FREE((void**)&file);
+ item->default_file = mir_wstrdup(fileFull);
} }
item->default_indx = sid->iDefaultIndex;
- if ( sid->cbSize >= SKINICONDESC_SIZE_V3 ) {
+ if (sid->cbSize >= SKINICONDESC_SIZE_V3) {
item->cx = sid->cx;
item->cy = sid->cy;
}
- if ( sid->cbSize >= SKINICONDESC_SIZE_V2 && sid->hDefaultIcon ) {
+ if (sid->cbSize >= SKINICONDESC_SIZE_V2 && sid->hDefaultIcon) {
bool big;
- IconItem* def_item = IcoLib_FindHIcon( sid->hDefaultIcon, big );
- if ( def_item ) {
+ IconItem* def_item = IcoLib_FindHIcon(sid->hDefaultIcon, big);
+ if (def_item) {
item->default_icon = big ? def_item->source_big : def_item->source_small;
item->default_icon->ref_count++;
}
else {
int cx = item->cx ? item->cx : GetSystemMetrics(SM_CXSMICON);
int cy = item->cy ? item->cy : GetSystemMetrics(SM_CYSMICON);
- item->default_icon = CreateStaticIconSourceItem( cx, cy );
- if ( GetIconData( sid->hDefaultIcon, &item->default_icon->icon_data, &item->default_icon->icon_size )) {
- IconSourceItem_Release( &item->default_icon );
+ item->default_icon = CreateStaticIconSourceItem(cx, cy);
+ if (GetIconData(sid->hDefaultIcon, &item->default_icon->icon_data, &item->default_icon->icon_size)) {
+ IconSourceItem_Release(&item->default_icon);
}
}
}
- if ( sid->cbSize >= SKINICONDESC_SIZE && item->section )
+ if (sid->cbSize >= SKINICONDESC_SIZE && item->section)
item->section->flags = sid->flags & SIDF_SORTED;
- LeaveCriticalSection( &csIconList );
+ LeaveCriticalSection(&csIconList);
return item;
}
/////////////////////////////////////////////////////////////////////////////////////////
// IcoLib_RemoveIcon
-static INT_PTR IcoLib_RemoveIcon( WPARAM, LPARAM lParam )
+static INT_PTR IcoLib_RemoveIcon(WPARAM, LPARAM lParam)
{
- if ( lParam ) {
+ if (lParam) {
int indx;
- EnterCriticalSection( &csIconList );
+ EnterCriticalSection(&csIconList);
- if (( indx = iconList.getIndex(( IconItem* )&lParam )) != -1 ) {
+ if ((indx = iconList.getIndex((IconItem*)&lParam)) != -1) {
IconItem *item = iconList[ indx ];
- IcoLib_FreeIcon( item );
- iconList.remove( indx );
- SAFE_FREE(( void** )&item );
+ IcoLib_FreeIcon(item);
+ iconList.remove(indx);
+ SAFE_FREE((void**)&item);
}
- LeaveCriticalSection( &csIconList );
- return ( indx == -1 ) ? 1 : 0;
+ LeaveCriticalSection(&csIconList);
+ return (indx == -1) ? 1 : 0;
}
return 1; // Failed
}
-HICON IconItem_GetDefaultIcon( IconItem* item, bool big )
+HICON IconItem_GetDefaultIcon(IconItem* item, bool big)
{
HICON hIcon = NULL;
- if ( item->default_icon && !big ) {
- IconSourceItem_Release( &item->source_small );
+ if (item->default_icon && !big) {
+ IconSourceItem_Release(&item->source_small);
item->source_small = item->default_icon;
item->source_small->ref_count++;
- hIcon = IconSourceItem_GetIcon( item->source_small );
+ hIcon = IconSourceItem_GetIcon(item->source_small);
}
- if ( !hIcon && item->default_file ) {
+ if ( !hIcon && item->default_file) {
int cx = item->cx ? item->cx : GetSystemMetrics(big ? SM_CXICON : SM_CXSMICON);
int cy = item->cy ? item->cy : GetSystemMetrics(big ? SM_CYICON : SM_CYSMICON);
- IconSourceItem* def_icon = GetIconSourceItem( item->default_file, item->default_indx, cx, cy );
- if ( big ) {
- if ( def_icon != item->source_big ) {
- IconSourceItem_Release( &item->source_big );
+ IconSourceItem* def_icon = GetIconSourceItem(item->default_file, item->default_indx, cx, cy);
+ if (big) {
+ if (def_icon != item->source_big) {
+ IconSourceItem_Release(&item->source_big);
item->source_big = def_icon;
- if ( def_icon ) {
+ if (def_icon) {
def_icon->ref_count++;
- hIcon = IconSourceItem_GetIcon( def_icon );
+ hIcon = IconSourceItem_GetIcon(def_icon);
}
}
else
- IconSourceItem_Release( &def_icon );
+ IconSourceItem_Release(&def_icon);
}
else {
- if ( def_icon != item->default_icon ) {
- IconSourceItem_Release( &item->default_icon );
+ if (def_icon != item->default_icon) {
+ IconSourceItem_Release(&item->default_icon);
item->default_icon = def_icon;
- if ( def_icon ) {
- IconSourceItem_Release( &item->source_small );
+ if (def_icon) {
+ IconSourceItem_Release(&item->source_small);
item->source_small = def_icon;
def_icon->ref_count++;
- hIcon = IconSourceItem_GetIcon( def_icon );
+ hIcon = IconSourceItem_GetIcon(def_icon);
}
}
else
- IconSourceItem_Release( &def_icon );
+ IconSourceItem_Release(&def_icon);
}
}
return hIcon;
@@ -696,7 +696,7 @@ HICON IconItem_GetDefaultIcon( IconItem* item, bool big ) /////////////////////////////////////////////////////////////////////////////////////////
// IconItem_GetIcon
-HICON IconItem_GetIcon( IconItem* item, bool big )
+HICON IconItem_GetIcon(IconItem* item, bool big)
{
DBVARIANT dbv = {0};
HICON hIcon = NULL;
@@ -704,20 +704,20 @@ HICON IconItem_GetIcon( IconItem* item, bool big ) big = big && !item->cx;
IconSourceItem* &source = big ? item->source_big : item->source_small;
- if ( !source && !DBGetContactSettingTString( NULL, "SkinIcons", item->name, &dbv )) {
+ if ( !source && !DBGetContactSettingTString(NULL, "SkinIcons", item->name, &dbv)) {
int cx = item->cx ? item->cx : GetSystemMetrics(big ? SM_CXICON : SM_CXSMICON);
int cy = item->cy ? item->cy : GetSystemMetrics(big ? SM_CYICON : SM_CYSMICON);
- source = GetIconSourceItemFromPath( dbv.ptszVal, cx, cy );
- DBFreeVariant( &dbv );
+ source = GetIconSourceItemFromPath(dbv.ptszVal, cx, cy);
+ DBFreeVariant(&dbv);
}
- if ( source )
- hIcon = IconSourceItem_GetIcon( source );
+ if (source)
+ hIcon = IconSourceItem_GetIcon(source);
- if ( !hIcon )
- hIcon = IconItem_GetDefaultIcon( item, big );
+ if ( !hIcon)
+ hIcon = IconItem_GetDefaultIcon(item, big);
- if ( !hIcon )
+ if ( !hIcon)
return hIconBlank;
return hIcon;
@@ -726,37 +726,37 @@ HICON IconItem_GetIcon( IconItem* item, bool big ) /////////////////////////////////////////////////////////////////////////////////////////
// IconItem_GetIcon_Preview
-HICON IconItem_GetIcon_Preview( IconItem* item )
+HICON IconItem_GetIcon_Preview(IconItem* item)
{
HICON hIcon = NULL;
- if ( !item->temp_reset ) {
- HICON hRefIcon = IconItem_GetIcon( item, false );
- hIcon = CopyIcon( hRefIcon );
- if ( item->source_small && item->source_small->icon == hRefIcon )
- IconSourceItem_ReleaseIcon( item->source_small );
+ if ( !item->temp_reset) {
+ HICON hRefIcon = IconItem_GetIcon(item, false);
+ hIcon = CopyIcon(hRefIcon);
+ if (item->source_small && item->source_small->icon == hRefIcon)
+ IconSourceItem_ReleaseIcon(item->source_small);
}
else {
- if ( item->default_icon ) {
- HICON hRefIcon = IconSourceItem_GetIcon( item->default_icon );
- if ( hRefIcon ) {
- hIcon = CopyIcon( hRefIcon );
- if ( item->default_icon->icon == hRefIcon )
- IconSourceItem_ReleaseIcon( item->default_icon );
+ if (item->default_icon) {
+ HICON hRefIcon = IconSourceItem_GetIcon(item->default_icon);
+ if (hRefIcon) {
+ hIcon = CopyIcon(hRefIcon);
+ if (item->default_icon->icon == hRefIcon)
+ IconSourceItem_ReleaseIcon(item->default_icon);
} }
- if ( !hIcon && item->default_file ) {
- IconSourceItem_Release( &item->default_icon );
- item->default_icon = GetIconSourceItem( item->default_file, item->default_indx, item->cx, item->cy );
- if ( item->default_icon ) {
- HICON hRefIcon = IconSourceItem_GetIcon( item->default_icon );
- if ( hRefIcon ) {
- hIcon = CopyIcon( hRefIcon );
- if ( item->default_icon->icon == hRefIcon )
- IconSourceItem_ReleaseIcon( item->default_icon );
+ if ( !hIcon && item->default_file) {
+ IconSourceItem_Release(&item->default_icon);
+ item->default_icon = GetIconSourceItem(item->default_file, item->default_indx, item->cx, item->cy);
+ if (item->default_icon) {
+ HICON hRefIcon = IconSourceItem_GetIcon(item->default_icon);
+ if (hRefIcon) {
+ hIcon = CopyIcon(hRefIcon);
+ if (item->default_icon->icon == hRefIcon)
+ IconSourceItem_ReleaseIcon(item->default_icon);
} } }
- if ( !hIcon )
+ if ( !hIcon)
return CopyIcon(hIconBlank);
}
return hIcon;
@@ -772,21 +772,21 @@ HICON IconItem_GetIcon_Preview( IconItem* item ) // cx/cyDesired = GetSystemMetrics(SM_CX/CYSMICON)
// fuLoad = 0
-HICON IcoLib_GetIcon( const char* pszIconName, bool big )
+HICON IcoLib_GetIcon(const char* pszIconName, bool big)
{
IconItem* item;
HICON result = NULL;
- if ( !pszIconName )
+ if ( !pszIconName)
return hIconBlank;
- EnterCriticalSection( &csIconList );
+ EnterCriticalSection(&csIconList);
- item = IcoLib_FindIcon( pszIconName );
- if ( item ) {
- result = IconItem_GetIcon( item, big );
+ item = IcoLib_FindIcon(pszIconName);
+ if (item) {
+ result = IconItem_GetIcon(item, big);
}
- LeaveCriticalSection( &csIconList );
+ LeaveCriticalSection(&csIconList);
return result;
}
@@ -794,16 +794,16 @@ HICON IcoLib_GetIcon( const char* pszIconName, bool big ) // IcoLib_GetIconHandle
// lParam: pszIconName
-HANDLE IcoLib_GetIconHandle( const char* pszIconName )
+HANDLE IcoLib_GetIconHandle(const char* pszIconName)
{
IconItem* item;
- if ( !pszIconName )
+ if ( !pszIconName)
return NULL;
- EnterCriticalSection( &csIconList );
- item = IcoLib_FindIcon( pszIconName );
- LeaveCriticalSection( &csIconList );
+ EnterCriticalSection(&csIconList);
+ item = IcoLib_FindIcon(pszIconName);
+ LeaveCriticalSection(&csIconList);
return (HANDLE)item;
}
@@ -813,27 +813,27 @@ HANDLE IcoLib_GetIconHandle( const char* pszIconName ) // lParam: icolib item handle
// wParam: 0
-HICON IcoLib_GetIconByHandle( HANDLE hItem, bool big )
+HICON IcoLib_GetIconByHandle(HANDLE hItem, bool big)
{
- if ( hItem == NULL )
+ if (hItem == NULL)
return NULL;
HICON result = hIconBlank;
- IconItem* pi = ( IconItem* )hItem;
+ IconItem* pi = (IconItem*)hItem;
- EnterCriticalSection( &csIconList );
+ EnterCriticalSection(&csIconList);
// we can get any junk here... but getIndex() is MUCH faster than indexOf().
__try
{
- if ( iconList.getIndex( pi ) != -1 )
- result = IconItem_GetIcon( pi, big );
+ if (iconList.getIndex(pi) != -1)
+ result = IconItem_GetIcon(pi, big);
}
- __except( EXCEPTION_EXECUTE_HANDLER )
+ __except(EXCEPTION_EXECUTE_HANDLER)
{
}
- LeaveCriticalSection( &csIconList );
+ LeaveCriticalSection(&csIconList);
return result;
}
@@ -842,21 +842,21 @@ HICON IcoLib_GetIconByHandle( HANDLE hItem, bool big ) // lParam: NULL
// wParam: HICON
-HANDLE IcoLib_IsManaged( HICON hIcon )
+HANDLE IcoLib_IsManaged(HICON hIcon)
{
IconItem* item;
- EnterCriticalSection( &csIconList );
+ EnterCriticalSection(&csIconList);
bool big;
- item = IcoLib_FindHIcon( hIcon, big );
- if ( item ) {
+ item = IcoLib_FindHIcon(hIcon, big);
+ if (item) {
IconSourceItem* source = big && !item->cx ? item->source_big : item->source_small;
- if ( source->icon_ref_count == 0 )
+ if (source->icon_ref_count == 0)
item = NULL;
}
- LeaveCriticalSection( &csIconList );
+ LeaveCriticalSection(&csIconList);
return NULL;
}
@@ -865,23 +865,23 @@ HANDLE IcoLib_IsManaged( HICON hIcon ) // lParam: NULL
// wParam: HICON
-static INT_PTR IcoLib_AddRef( WPARAM wParam, LPARAM )
+static INT_PTR IcoLib_AddRef(WPARAM wParam, LPARAM)
{
- EnterCriticalSection( &csIconList );
+ EnterCriticalSection(&csIconList);
bool big;
- IconItem *item = IcoLib_FindHIcon(( HICON )wParam, big);
+ IconItem *item = IcoLib_FindHIcon((HICON)wParam, big);
INT_PTR res = 1;
- if ( item ) {
+ if (item) {
IconSourceItem* source = big && !item->cx ? item->source_big : item->source_small;
- if ( source->icon_ref_count ) {
+ if (source->icon_ref_count) {
source->icon_ref_count++;
res = 0;
}
}
- LeaveCriticalSection( &csIconList );
+ LeaveCriticalSection(&csIconList);
return res;
}
@@ -890,31 +890,31 @@ static INT_PTR IcoLib_AddRef( WPARAM wParam, LPARAM ) // lParam: pszIconName or NULL
// wParam: HICON or NULL
-int IcoLib_ReleaseIcon( HICON hIcon, char* szIconName, bool big )
+int IcoLib_ReleaseIcon(HICON hIcon, char* szIconName, bool big)
{
IconItem *item = NULL;
EnterCriticalSection(&csIconList);
- if ( szIconName )
- item = IcoLib_FindIcon( szIconName );
+ if (szIconName)
+ item = IcoLib_FindIcon(szIconName);
- if ( !item && hIcon ) // find by HICON
- item = IcoLib_FindHIcon( hIcon, big );
+ if ( !item && hIcon) // find by HICON
+ item = IcoLib_FindHIcon(hIcon, big);
int res = 1;
- if ( item ) {
+ if (item) {
IconSourceItem* source = big && !item->cx ? item->source_big : item->source_small;
- if ( source && source->icon_ref_count ) {
- if ( iconEventActive )
+ if (source && source->icon_ref_count) {
+ if (iconEventActive)
source->icon_ref_count--;
else
- IconSourceItem_ReleaseIcon( source );
+ IconSourceItem_ReleaseIcon(source);
res = 0;
}
}
- LeaveCriticalSection( &csIconList );
+ LeaveCriticalSection(&csIconList);
return res;
}
@@ -928,27 +928,27 @@ static void LoadSectionIcons(TCHAR *filename, SectionItem* sectionActive) HICON hIcon;
int indx;
- mir_sntprintf( path, SIZEOF(path), _T("%s,"), filename );
- suffIndx = lstrlen( path );
+ mir_sntprintf(path, SIZEOF(path), _T("%s,"), filename);
+ suffIndx = lstrlen(path);
- EnterCriticalSection( &csIconList );
+ EnterCriticalSection(&csIconList);
- for ( indx = 0; indx < iconList.getCount(); indx++ ) {
+ for (indx = 0; indx < iconList.getCount(); indx++) {
IconItem *item = iconList[ indx ];
- if ( item->default_file && item->section == sectionActive ) {
- _itot( item->default_indx, path + suffIndx, 10 );
- hIcon = ExtractIconFromPath( path, item->cx, item->cy );
- if ( hIcon ) {
- SAFE_FREE(( void** )&item->temp_file );
- SafeDestroyIcon( &item->temp_icon );
+ if (item->default_file && item->section == sectionActive) {
+ _itot(item->default_indx, path + suffIndx, 10);
+ hIcon = ExtractIconFromPath(path, item->cx, item->cy);
+ if (hIcon) {
+ SAFE_FREE((void**)&item->temp_file);
+ SafeDestroyIcon(&item->temp_icon);
- item->temp_file = mir_tstrdup( path );
+ item->temp_file = mir_tstrdup(path);
item->temp_icon = hIcon;
item->temp_reset = FALSE;
} } }
- LeaveCriticalSection( &csIconList );
+ LeaveCriticalSection(&csIconList);
}
void LoadSubIcons(HWND htv, TCHAR *filename, HTREEITEM hItem)
@@ -960,37 +960,37 @@ void LoadSubIcons(HWND htv, TCHAR *filename, HTREEITEM hItem) tvi.mask = TVIF_HANDLE | TVIF_PARAM;
tvi.hItem = hItem;
- TreeView_GetItem( htv, &tvi );
+ TreeView_GetItem(htv, &tvi);
treeItem = (TreeItem *)tvi.lParam;
sectionActive = sectionList[ SECTIONPARAM_INDEX(treeItem->value) ];
- tvi.hItem = TreeView_GetChild( htv, tvi.hItem );
- while ( tvi.hItem ) {
- LoadSubIcons( htv, filename, tvi.hItem );
- tvi.hItem = TreeView_GetNextSibling( htv, tvi.hItem );
+ tvi.hItem = TreeView_GetChild(htv, tvi.hItem);
+ while (tvi.hItem) {
+ LoadSubIcons(htv, filename, tvi.hItem);
+ tvi.hItem = TreeView_GetNextSibling(htv, tvi.hItem);
}
- if ( SECTIONPARAM_FLAGS(treeItem->value) & SECTIONPARAM_HAVEPAGE )
- LoadSectionIcons( filename, sectionActive );
+ if (SECTIONPARAM_FLAGS(treeItem->value) & SECTIONPARAM_HAVEPAGE)
+ LoadSectionIcons(filename, sectionActive);
}
-static void UndoChanges( int iconIndx, int cmd )
+static void UndoChanges(int iconIndx, int cmd)
{
IconItem *item = iconList[ iconIndx ];
- if ( !item->temp_file && !item->temp_icon && item->temp_reset && cmd == ID_CANCELCHANGE )
+ if ( !item->temp_file && !item->temp_icon && item->temp_reset && cmd == ID_CANCELCHANGE)
item->temp_reset = FALSE;
else
{
- SAFE_FREE(( void** )&item->temp_file );
- SafeDestroyIcon( &item->temp_icon );
+ SAFE_FREE((void**)&item->temp_file);
+ SafeDestroyIcon(&item->temp_icon);
}
- if ( cmd == ID_RESET )
+ if (cmd == ID_RESET)
item->temp_reset = TRUE;
}
-void UndoSubItemChanges( HWND htv, HTREEITEM hItem, int cmd )
+void UndoSubItemChanges(HWND htv, HTREEITEM hItem, int cmd)
{
TVITEM tvi = {0};
TreeItem *treeItem;
@@ -998,28 +998,28 @@ void UndoSubItemChanges( HWND htv, HTREEITEM hItem, int cmd ) tvi.mask = TVIF_HANDLE | TVIF_PARAM;
tvi.hItem = hItem;
- TreeView_GetItem( htv, &tvi );
+ TreeView_GetItem(htv, &tvi);
treeItem = (TreeItem *)tvi.lParam;
- if ( SECTIONPARAM_FLAGS( treeItem->value ) & SECTIONPARAM_HAVEPAGE ) {
- EnterCriticalSection( &csIconList );
+ if (SECTIONPARAM_FLAGS(treeItem->value) & SECTIONPARAM_HAVEPAGE) {
+ EnterCriticalSection(&csIconList);
- for ( indx = 0; indx < iconList.getCount(); indx++ )
- if ( iconList[ indx ]->section == sectionList[ SECTIONPARAM_INDEX(treeItem->value) ])
- UndoChanges( indx, cmd );
+ for (indx = 0; indx < iconList.getCount(); indx++)
+ if (iconList[ indx ]->section == sectionList[ SECTIONPARAM_INDEX(treeItem->value) ])
+ UndoChanges(indx, cmd);
- LeaveCriticalSection( &csIconList );
+ LeaveCriticalSection(&csIconList);
}
- tvi.hItem = TreeView_GetChild( htv, tvi.hItem );
- while ( tvi.hItem ) {
- UndoSubItemChanges( htv, tvi.hItem, cmd );
- tvi.hItem = TreeView_GetNextSibling( htv, tvi.hItem );
+ tvi.hItem = TreeView_GetChild(htv, tvi.hItem);
+ while (tvi.hItem) {
+ UndoSubItemChanges(htv, tvi.hItem, cmd);
+ tvi.hItem = TreeView_GetNextSibling(htv, tvi.hItem);
} }
static void OpenIconsPage()
{
- CallService( MS_UTILS_OPENURL, 1, (LPARAM)"http://addons.miranda-im.org/index.php?action=display&id=35" );
+ CallService(MS_UTILS_OPENURL, 1, (LPARAM)"http://addons.miranda-im.org/index.php?action=display&id=35");
}
static int OpenPopupMenu(HWND hwndDlg)
@@ -1029,15 +1029,15 @@ static int OpenPopupMenu(HWND hwndDlg) int cmd;
GetCursorPos(&pt);
- hMenu = LoadMenu( hMirandaInst, MAKEINTRESOURCE( IDR_ICOLIB_CONTEXT ));
- hPopup = GetSubMenu( hMenu, 0 );
+ hMenu = LoadMenu(hMirandaInst, MAKEINTRESOURCE(IDR_ICOLIB_CONTEXT));
+ hPopup = GetSubMenu(hMenu, 0);
TranslateMenu(hPopup);
- cmd = TrackPopupMenu( hPopup, TPM_RIGHTBUTTON|TPM_RETURNCMD, pt.x, pt.y, 0, hwndDlg, NULL );
- DestroyMenu( hMenu );
+ cmd = TrackPopupMenu(hPopup, TPM_RIGHTBUTTON|TPM_RETURNCMD, pt.x, pt.y, 0, hwndDlg, NULL);
+ DestroyMenu(hMenu);
return cmd;
}
-static TCHAR* OpenFileDlg( HWND hParent, const TCHAR* szFile, BOOL bAll )
+static TCHAR* OpenFileDlg(HWND hParent, const TCHAR* szFile, BOOL bAll)
{
OPENFILENAME ofn = {0};
TCHAR filter[512], *pfilter, file[MAX_PATH*2];
@@ -1072,7 +1072,7 @@ static TCHAR* OpenFileDlg( HWND hParent, const TCHAR* szFile, BOOL bAll ) ofn.Flags = OFN_FILEMUSTEXIST | OFN_HIDEREADONLY | OFN_DONTADDTORECENT;
ofn.nMaxFile = MAX_PATH*2;
- if (!GetOpenFileName(&ofn))
+ if ( !GetOpenFileName(&ofn))
return NULL;
return mir_tstrdup(file);
@@ -1108,13 +1108,13 @@ void DoIconsChanged(HWND hwndDlg) EnterCriticalSection(&csIconList); // Destroy unused icons
for (int indx = 0; indx < iconList.getCount(); indx++) {
IconItem *item = iconList[indx];
- if ( item->source_small && !item->source_small->icon_ref_count) {
+ if (item->source_small && !item->source_small->icon_ref_count) {
item->source_small->icon_ref_count++;
- IconSourceItem_ReleaseIcon( item->source_small );
+ IconSourceItem_ReleaseIcon(item->source_small);
}
- if ( item->source_big && !item->source_big->icon_ref_count) {
+ if (item->source_big && !item->source_big->icon_ref_count) {
item->source_big->icon_ref_count++;
- IconSourceItem_ReleaseIcon( item->source_big );
+ IconSourceItem_ReleaseIcon(item->source_big);
}
}
LeaveCriticalSection(&csIconList);
@@ -1130,7 +1130,7 @@ static HTREEITEM FindNamedTreeItemAt(HWND hwndTree, HTREEITEM hItem, const TCHAR else
tvi.hItem = TreeView_GetRoot(hwndTree);
- if (!name)
+ if ( !name)
return tvi.hItem;
tvi.mask = TVIF_TEXT;
@@ -1141,7 +1141,7 @@ static HTREEITEM FindNamedTreeItemAt(HWND hwndTree, HTREEITEM hItem, const TCHAR {
TreeView_GetItem(hwndTree, &tvi);
- if (!lstrcmp(tvi.pszText, name))
+ if ( !lstrcmp(tvi.pszText, name))
return tvi.hItem;
tvi.hItem = TreeView_GetNextSibling(hwndTree, tvi.hItem);
@@ -1237,12 +1237,12 @@ INT_PTR CALLBACK DlgProcIconImport(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lvi.mask = LVIF_TEXT|LVIF_IMAGE|LVIF_PARAM;
lvi.iSubItem = 0;
lvi.iItem = 0;
- count = (int)_ExtractIconEx( filename, -1, 16, 16, NULL, LR_DEFAULTCOLOR );
+ count = (int)_ExtractIconEx(filename, -1, 16, 16, NULL, LR_DEFAULTCOLOR);
for (i = 0; i < count; lvi.iItem++, i++) {
mir_sntprintf(caption, SIZEOF(caption), _T("%d"), i+1);
lvi.pszText = caption;
//hIcon = ExtractIcon(hMirandaInst, filename, i);
- _ExtractIconEx( filename, i, 16, 16, &hIcon, LR_DEFAULTCOLOR );
+ _ExtractIconEx(filename, i, 16, 16, &hIcon, LR_DEFAULTCOLOR);
lvi.iImage = ImageList_AddIcon(hIml, hIcon);
DestroyIcon(hIcon);
lvi.lParam = i;
@@ -1253,16 +1253,16 @@ INT_PTR CALLBACK DlgProcIconImport(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM break;
case WM_COMMAND:
- switch( LOWORD( wParam )) {
+ switch(LOWORD(wParam)) {
case IDC_BROWSE:
{
TCHAR str[MAX_PATH];
TCHAR *file;
GetDlgItemText(hwndDlg, IDC_ICONSET, str, SIZEOF(str));
- if (!(file = OpenFileDlg(GetParent(hwndDlg), str, TRUE))) break;
+ if ( !(file = OpenFileDlg(GetParent(hwndDlg), str, TRUE))) break;
SetDlgItemText(hwndDlg, IDC_ICONSET, file);
- SAFE_FREE(( void** )&file );
+ SAFE_FREE((void**)&file);
}
break;
@@ -1314,7 +1314,7 @@ INT_PTR CALLBACK DlgProcIconImport(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM onItem = 1;
} }
- if (!onItem && dropHiLite != -1) {
+ if ( !onItem && dropHiLite != -1) {
ImageList_DragLeave(hwndDragOver);
ListView_SetItemState(hPPreview, dropHiLite, 0, LVIS_DROPHILITED);
UpdateWindow(hPPreview);
@@ -1396,44 +1396,44 @@ INT_PTR CALLBACK DlgProcIconImport(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM /////////////////////////////////////////////////////////////////////////////////////////
// IcoLib options window procedure
-static int CALLBACK DoSortIconsFunc(LPARAM lParam1, LPARAM lParam2, LPARAM )
+static int CALLBACK DoSortIconsFunc(LPARAM lParam1, LPARAM lParam2, LPARAM)
{ return lstrcmpi(TranslateTS(iconList[lParam1]->description), TranslateTS(iconList[lParam2]->description));
}
-static int CALLBACK DoSortIconsFuncByOrder(LPARAM lParam1, LPARAM lParam2, LPARAM )
+static int CALLBACK DoSortIconsFuncByOrder(LPARAM lParam1, LPARAM lParam2, LPARAM)
{ return iconList[lParam1]->orderID - iconList[lParam2]->orderID;
}
-static void SaveCollapseState( HWND hwndTree )
+static void SaveCollapseState(HWND hwndTree)
{
HTREEITEM hti;
TVITEM tvi;
- hti = TreeView_GetRoot( hwndTree );
- while ( hti != NULL ) {
+ hti = TreeView_GetRoot(hwndTree);
+ while (hti != NULL) {
HTREEITEM ht;
TreeItem *treeItem;
tvi.mask = TVIF_STATE | TVIF_HANDLE | TVIF_CHILDREN | TVIF_PARAM;
tvi.hItem = hti;
tvi.stateMask = (DWORD)-1;
- TreeView_GetItem( hwndTree, &tvi );
+ TreeView_GetItem(hwndTree, &tvi);
- if ( tvi.cChildren > 0 ) {
+ if (tvi.cChildren > 0) {
treeItem = (TreeItem *)tvi.lParam;
- if ( tvi.state & TVIS_EXPANDED )
- DBWriteContactSettingByte(NULL, "SkinIconsUI", treeItem->paramName, TVIS_EXPANDED );
+ if (tvi.state & TVIS_EXPANDED)
+ DBWriteContactSettingByte(NULL, "SkinIconsUI", treeItem->paramName, TVIS_EXPANDED);
else
- DBWriteContactSettingByte(NULL, "SkinIconsUI", treeItem->paramName, 0 );
+ DBWriteContactSettingByte(NULL, "SkinIconsUI", treeItem->paramName, 0);
}
- ht = TreeView_GetChild( hwndTree, hti );
- if ( ht == NULL ) {
- ht = TreeView_GetNextSibling( hwndTree, hti );
- while ( ht == NULL ) {
- hti = TreeView_GetParent( hwndTree, hti );
- if ( hti == NULL ) break;
- ht = TreeView_GetNextSibling( hwndTree, hti );
+ ht = TreeView_GetChild(hwndTree, hti);
+ if (ht == NULL) {
+ ht = TreeView_GetNextSibling(hwndTree, hti);
+ while (ht == NULL) {
+ hti = TreeView_GetParent(hwndTree, hti);
+ if (hti == NULL) break;
+ ht = TreeView_GetNextSibling(hwndTree, hti);
} }
hti = ht;
@@ -1485,7 +1485,7 @@ INT_PTR CALLBACK DlgProcIcoLibOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM TCHAR itemName[1024];
HTREEITEM hSection;
- if (!hwndTree) break;
+ if ( !hwndTree) break;
TreeView_SelectItem(hwndTree, NULL);
TreeView_DeleteAllItems(hwndTree);
@@ -1508,14 +1508,14 @@ INT_PTR CALLBACK DlgProcIcoLibOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM *sectionName = 0;
}
- pItemName = TranslateTS( pItemName );
+ pItemName = TranslateTS(pItemName);
hItem = FindNamedTreeItemAt(hwndTree, hSection, pItemName);
- if (!sectionName || !hItem) {
- if (!hItem) {
+ if ( !sectionName || !hItem) {
+ if ( !hItem) {
TVINSERTSTRUCT tvis = {0};
TreeItem *treeItem = (TreeItem *)mir_alloc(sizeof(TreeItem));
- treeItem->value = SECTIONPARAM_MAKE( indx, sectionLevel, sectionName?0:SECTIONPARAM_HAVEPAGE );
+ treeItem->value = SECTIONPARAM_MAKE(indx, sectionLevel, sectionName?0:SECTIONPARAM_HAVEPAGE);
treeItem->paramName = mir_t2a(itemName);
tvis.hParent = hSection;
@@ -1524,7 +1524,7 @@ INT_PTR CALLBACK DlgProcIcoLibOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM tvis.item.pszText = pItemName;
tvis.item.lParam = (LPARAM) treeItem;
- tvis.item.state = tvis.item.stateMask = DBGetContactSettingByte(NULL, "SkinIconsUI", treeItem->paramName, TVIS_EXPANDED );
+ tvis.item.state = tvis.item.stateMask = DBGetContactSettingByte(NULL, "SkinIconsUI", treeItem->paramName, TVIS_EXPANDED);
hItem = TreeView_InsertItem(hwndTree, &tvis);
}
else {
@@ -1532,9 +1532,9 @@ INT_PTR CALLBACK DlgProcIcoLibOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM TreeItem *treeItem;
tvi.hItem = hItem;
tvi.mask = TVIF_HANDLE | TVIF_PARAM;
- TreeView_GetItem( hwndTree, &tvi );
+ TreeView_GetItem(hwndTree, &tvi);
treeItem = (TreeItem *)tvi.lParam;
- treeItem->value = SECTIONPARAM_MAKE( indx, sectionLevel, SECTIONPARAM_HAVEPAGE );
+ treeItem->value = SECTIONPARAM_MAKE(indx, sectionLevel, SECTIONPARAM_HAVEPAGE);
} }
if (sectionName) {
@@ -1558,10 +1558,10 @@ INT_PTR CALLBACK DlgProcIcoLibOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM LVITEM lvi = {0};
HIMAGELIST hIml;
HICON hIcon;
- SectionItem* sectionActive = ( SectionItem* )lParam;
+ SectionItem* sectionActive = (SectionItem*)lParam;
int indx;
- EnableWindow(hPreview, sectionActive != NULL );
+ EnableWindow(hPreview, sectionActive != NULL);
ListView_DeleteAllItems(hPreview);
hIml = ListView_GetImageList(hPreview, LVSIL_NORMAL);
@@ -1580,17 +1580,17 @@ INT_PTR CALLBACK DlgProcIcoLibOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM if (item->section == sectionActive) {
lvi.pszText = TranslateTS(item->description);
hIcon = item->temp_icon;
- if ( !hIcon )
- hIcon = IconItem_GetIcon_Preview( item );
+ if ( !hIcon)
+ hIcon = IconItem_GetIcon_Preview(item);
lvi.iImage = ImageList_AddIcon(hIml, hIcon);
lvi.lParam = indx;
ListView_InsertItem(hPreview, &lvi);
- if (hIcon != item->temp_icon) SafeDestroyIcon( &hIcon );
+ if (hIcon != item->temp_icon) SafeDestroyIcon(&hIcon);
} }
LeaveCriticalSection(&csIconList);
- if ( sectionActive->flags & SIDF_SORTED )
+ if (sectionActive->flags & SIDF_SORTED)
ListView_SortItems(hPreview, DoSortIconsFunc, 0);
else
ListView_SortItems(hPreview, DoSortIconsFuncByOrder, 0);
@@ -1613,13 +1613,13 @@ INT_PTR CALLBACK DlgProcIcoLibOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM ListView_GetItem(hPreview, &lvi);
EnterCriticalSection(&csIconList);
hIcon = iconList[lvi.lParam]->temp_icon;
- if (!hIcon)
- hIcon = IconItem_GetIcon_Preview( iconList[lvi.lParam] );
+ if ( !hIcon)
+ hIcon = IconItem_GetIcon_Preview(iconList[lvi.lParam]);
LeaveCriticalSection(&csIconList);
if (hIcon)
ImageList_ReplaceIcon(hIml, lvi.iImage, hIcon);
- if (hIcon != iconList[lvi.lParam]->temp_icon) SafeDestroyIcon( &hIcon );
+ if (hIcon != iconList[lvi.lParam]->temp_icon) SafeDestroyIcon(&hIcon);
}
ListView_RedrawItems(hPreview, 0, count);
}
@@ -1634,85 +1634,85 @@ INT_PTR CALLBACK DlgProcIcoLibOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lvi.mask = LVIF_PARAM;
lvi.iItem = wParam;
- ListView_GetItem( hPreview, &lvi );
+ ListView_GetItem(hPreview, &lvi);
- EnterCriticalSection( &csIconList );
+ EnterCriticalSection(&csIconList);
item = iconList[ lvi.lParam ];
- SAFE_FREE(( void** )&item->temp_file );
- SafeDestroyIcon( &item->temp_icon );
- item->temp_file = mir_tstrdup( path );
- item->temp_icon = ( HICON )ExtractIconFromPath( path, item->cx, item->cy );
+ SAFE_FREE((void**)&item->temp_file);
+ SafeDestroyIcon(&item->temp_icon);
+ item->temp_file = mir_tstrdup(path);
+ item->temp_icon = (HICON)ExtractIconFromPath(path, item->cx, item->cy);
item->temp_reset = FALSE;
- LeaveCriticalSection( &csIconList );
- DoOptionsChanged( hwndDlg );
+ LeaveCriticalSection(&csIconList);
+ DoOptionsChanged(hwndDlg);
}
break;
case WM_COMMAND:
- if ( LOWORD(wParam) == IDC_IMPORT ) {
+ if (LOWORD(wParam) == IDC_IMPORT) {
dat->hwndIndex = CreateDialogParam(hMirandaInst, MAKEINTRESOURCE(IDD_ICOLIB_IMPORT), GetParent(hwndDlg), DlgProcIconImport, (LPARAM)hwndDlg);
EnableWindow((HWND)lParam, FALSE);
}
- else if ( LOWORD(wParam) == IDC_GETMORE ) {
+ else if (LOWORD(wParam) == IDC_GETMORE) {
OpenIconsPage();
break;
}
- else if (LOWORD(wParam) == IDC_LOADICONS ) {
+ else if (LOWORD(wParam) == IDC_LOADICONS) {
TCHAR filetmp[1] = {0};
TCHAR *file;
- if ( file = OpenFileDlg( hwndDlg, filetmp, FALSE )) {
- HWND htv = GetDlgItem( hwndDlg, IDC_CATEGORYLIST );
+ if (file = OpenFileDlg(hwndDlg, filetmp, FALSE)) {
+ HWND htv = GetDlgItem(hwndDlg, IDC_CATEGORYLIST);
TCHAR filename[ MAX_PATH ];
- CallService( MS_UTILS_PATHTORELATIVET, ( WPARAM )file, ( LPARAM )filename );
- SAFE_FREE(( void** )&file );
+ CallService(MS_UTILS_PATHTORELATIVET, (WPARAM)file, (LPARAM)filename);
+ SAFE_FREE((void**)&file);
- MySetCursor( IDC_WAIT );
- LoadSubIcons( htv, filename, TreeView_GetSelection( htv ));
- MySetCursor( IDC_ARROW );
+ MySetCursor(IDC_WAIT);
+ LoadSubIcons(htv, filename, TreeView_GetSelection(htv));
+ MySetCursor(IDC_ARROW);
- DoOptionsChanged( hwndDlg );
+ DoOptionsChanged(hwndDlg);
} }
break;
case WM_CONTEXTMENU:
- if (( HWND )wParam == hPreview ) {
- UINT count = ListView_GetSelectedCount( hPreview );
+ if ((HWND)wParam == hPreview) {
+ UINT count = ListView_GetSelectedCount(hPreview);
- if ( count > 0 ) {
- int cmd = OpenPopupMenu( hwndDlg );
- switch( cmd ) {
+ if (count > 0) {
+ int cmd = OpenPopupMenu(hwndDlg);
+ switch(cmd) {
case ID_CANCELCHANGE:
case ID_RESET:
{
LVITEM lvi = {0};
int itemIndx = -1;
- while (( itemIndx = ListView_GetNextItem( hPreview, itemIndx, LVNI_SELECTED )) != -1 ) {
+ while ((itemIndx = ListView_GetNextItem(hPreview, itemIndx, LVNI_SELECTED)) != -1) {
lvi.mask = LVIF_PARAM;
lvi.iItem = itemIndx; //lvhti.iItem;
- ListView_GetItem( hPreview, &lvi );
+ ListView_GetItem(hPreview, &lvi);
- UndoChanges( lvi.lParam, cmd );
+ UndoChanges(lvi.lParam, cmd);
}
- DoOptionsChanged( hwndDlg );
+ DoOptionsChanged(hwndDlg);
break;
} } }
}
else {
- HWND htv = GetDlgItem( hwndDlg, IDC_CATEGORYLIST );
- if (( HWND )wParam == htv ) {
- int cmd = OpenPopupMenu( hwndDlg );
+ HWND htv = GetDlgItem(hwndDlg, IDC_CATEGORYLIST);
+ if ((HWND)wParam == htv) {
+ int cmd = OpenPopupMenu(hwndDlg);
- switch( cmd ) {
+ switch(cmd) {
case ID_CANCELCHANGE:
case ID_RESET:
- UndoSubItemChanges( htv, TreeView_GetSelection( htv ), cmd );
- DoOptionsChanged( hwndDlg );
+ UndoSubItemChanges(htv, TreeView_GetSelection(htv), cmd);
+ DoOptionsChanged(hwndDlg);
break;
} } }
break;
@@ -1732,13 +1732,13 @@ INT_PTR CALLBACK DlgProcIcoLibOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM if (item->temp_reset) {
DBDeleteContactSetting(NULL, "SkinIcons", item->name);
if (item->source_small != item->default_icon) {
- IconSourceItem_Release( &item->source_small );
+ IconSourceItem_Release(&item->source_small);
}
}
else if (item->temp_file) {
DBWriteContactSettingTString(NULL, "SkinIcons", item->name, item->temp_file);
- IconSourceItem_Release( &item->source_small );
- SafeDestroyIcon( &item->temp_icon );
+ IconSourceItem_Release(&item->source_small);
+ SafeDestroyIcon(&item->temp_icon);
}
}
LeaveCriticalSection(&csIconList);
@@ -1758,15 +1758,15 @@ INT_PTR CALLBACK DlgProcIcoLibOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lvi.iItem = pInfoTip->iItem;
ListView_GetItem(pInfoTip->hdr.hwndFrom, &lvi);
- if ( lvi.lParam < iconList.getCount() ) {
+ if (lvi.lParam < iconList.getCount()) {
item = iconList[lvi.lParam];
- if ( item->temp_file )
- _tcsncpy( pInfoTip->pszText, item->temp_file, pInfoTip->cchTextMax );
- else if ( item->default_file )
- mir_sntprintf( pInfoTip->pszText, pInfoTip->cchTextMax, _T("%s, %d"), item->default_file, item->default_indx );
+ if (item->temp_file)
+ _tcsncpy(pInfoTip->pszText, item->temp_file, pInfoTip->cchTextMax);
+ else if (item->default_file)
+ mir_sntprintf(pInfoTip->pszText, pInfoTip->cchTextMax, _T("%s, %d"), item->default_file, item->default_indx);
}
}
- if ( bNeedRebuild ) {
+ if (bNeedRebuild) {
EnterCriticalSection(&csIconList);
bNeedRebuild = FALSE;
LeaveCriticalSection(&csIconList);
@@ -1782,10 +1782,10 @@ INT_PTR CALLBACK DlgProcIcoLibOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM NMTREEVIEW *pnmtv = (NMTREEVIEW*)lParam;
TVITEM tvi = pnmtv->itemNew;
TreeItem *treeItem = (TreeItem *)tvi.lParam;
- if ( treeItem )
- SendMessage(hwndDlg, DM_REBUILDICONSPREVIEW, 0, ( LPARAM )(
+ if (treeItem)
+ SendMessage(hwndDlg, DM_REBUILDICONSPREVIEW, 0, (LPARAM)(
(SECTIONPARAM_FLAGS(treeItem->value)&SECTIONPARAM_HAVEPAGE)?
- sectionList[ SECTIONPARAM_INDEX(treeItem->value) ] : NULL ) );
+ sectionList[ SECTIONPARAM_INDEX(treeItem->value) ] : NULL));
break;
}
case TVN_DELETEITEMA: // no idea why both TVN_SELCHANGEDA/W should be there but let's keep this both too...
@@ -1798,7 +1798,7 @@ INT_PTR CALLBACK DlgProcIcoLibOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM }
break;
} }
- if ( bNeedRebuild ) {
+ if (bNeedRebuild) {
EnterCriticalSection(&csIconList);
bNeedRebuild = FALSE;
LeaveCriticalSection(&csIconList);
@@ -1809,19 +1809,19 @@ INT_PTR CALLBACK DlgProcIcoLibOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM {
int indx;
- SaveCollapseState( GetDlgItem(hwndDlg, IDC_CATEGORYLIST) );
+ SaveCollapseState(GetDlgItem(hwndDlg, IDC_CATEGORYLIST));
DestroyWindow(dat->hwndIndex);
EnterCriticalSection(&csIconList);
for (indx = 0; indx < iconList.getCount(); indx++) {
IconItem *item = iconList[indx];
- SAFE_FREE(( void** )&item->temp_file);
+ SAFE_FREE((void**)&item->temp_file);
SafeDestroyIcon(&item->temp_icon);
}
LeaveCriticalSection(&csIconList);
- SAFE_FREE(( void** )&dat);
+ SAFE_FREE((void**)&dat);
break;
} }
@@ -1830,7 +1830,7 @@ INT_PTR CALLBACK DlgProcIcoLibOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM static UINT iconsExpertOnlyControls[]={IDC_IMPORT};
-static int SkinOptionsInit( WPARAM wParam, LPARAM )
+static int SkinOptionsInit(WPARAM wParam, LPARAM)
{
OPTIONSDIALOGPAGE odp = {0};
@@ -1844,11 +1844,11 @@ static int SkinOptionsInit( WPARAM wParam, LPARAM ) odp.pfnDlgProc = DlgProcIcoLibOpts;
odp.expertOnlyControls = iconsExpertOnlyControls;
odp.nExpertOnlyControls = SIZEOF(iconsExpertOnlyControls);
- CallService(MS_OPT_ADDPAGE, wParam, (LPARAM)&odp);
+ Options_AddPage(wParam, &odp);
return 0;
}
-static int SkinSystemModulesLoaded( WPARAM, LPARAM )
+static int SkinSystemModulesLoaded(WPARAM, LPARAM)
{
HookEvent(ME_OPT_INITIALISE, SkinOptionsInit);
return 0;
@@ -1857,32 +1857,32 @@ static int SkinSystemModulesLoaded( WPARAM, LPARAM ) /////////////////////////////////////////////////////////////////////////////////////////
// Module initialization and finalization procedure
-static INT_PTR sttIcoLib_AddNewIcon( WPARAM, LPARAM lParam )
-{ return (INT_PTR)IcoLib_AddNewIcon(( SKINICONDESC* )lParam );
+static INT_PTR sttIcoLib_AddNewIcon(WPARAM, LPARAM lParam)
+{ return (INT_PTR)IcoLib_AddNewIcon((SKINICONDESC*)lParam);
}
-static INT_PTR sttIcoLib_GetIcon( WPARAM wParam, LPARAM lParam )
-{ return (INT_PTR)IcoLib_GetIcon(( const char* )lParam, wParam != 0 );
+static INT_PTR sttIcoLib_GetIcon(WPARAM wParam, LPARAM lParam)
+{ return (INT_PTR)IcoLib_GetIcon((const char*)lParam, wParam != 0);
}
-static INT_PTR sttIcoLib_GetIconHandle( WPARAM, LPARAM lParam )
-{ return (INT_PTR)IcoLib_GetIconHandle(( const char* )lParam );
+static INT_PTR sttIcoLib_GetIconHandle(WPARAM, LPARAM lParam)
+{ return (INT_PTR)IcoLib_GetIconHandle((const char*)lParam);
}
-static INT_PTR sttIcoLib_GetIconByHandle( WPARAM wParam, LPARAM lParam )
-{ return (INT_PTR)IcoLib_GetIconByHandle(( HANDLE )lParam, wParam != 0 );
+static INT_PTR sttIcoLib_GetIconByHandle(WPARAM wParam, LPARAM lParam)
+{ return (INT_PTR)IcoLib_GetIconByHandle((HANDLE)lParam, wParam != 0);
}
-static INT_PTR sttIcoLib_ReleaseIcon( WPARAM wParam, LPARAM lParam )
-{ return (INT_PTR)IcoLib_ReleaseIcon(( HICON )wParam, ( char* )lParam, false );
+static INT_PTR sttIcoLib_ReleaseIcon(WPARAM wParam, LPARAM lParam)
+{ return (INT_PTR)IcoLib_ReleaseIcon((HICON)wParam, (char*)lParam, false);
}
-static INT_PTR sttIcoLib_ReleaseIconBig( WPARAM wParam, LPARAM lParam )
-{ return (INT_PTR)IcoLib_ReleaseIcon(( HICON )wParam, ( char* )lParam, true );
+static INT_PTR sttIcoLib_ReleaseIconBig(WPARAM wParam, LPARAM lParam)
+{ return (INT_PTR)IcoLib_ReleaseIcon((HICON)wParam, (char*)lParam, true);
}
-static INT_PTR sttIcoLib_IsManaged( WPARAM wParam, LPARAM )
-{ return (INT_PTR)IcoLib_IsManaged(( HICON )wParam );
+static INT_PTR sttIcoLib_IsManaged(WPARAM wParam, LPARAM)
+{ return (INT_PTR)IcoLib_IsManaged((HICON)wParam);
}
int LoadIcoLibModule(void)
@@ -1914,7 +1914,7 @@ void UnloadIcoLibModule(void) {
int indx;
- if ( !bModuleInitialized ) return;
+ if ( !bModuleInitialized) return;
DestroyHookableEvent(hIconsChangedEvent);
DestroyHookableEvent(hIcons2ChangedEvent);
@@ -1929,35 +1929,35 @@ void UnloadIcoLibModule(void) DestroyServiceFunction(hIcoLib_ReleaseIcon);
DeleteCriticalSection(&csIconList);
- for (indx = iconList.getCount()-1; indx >= 0; indx-- ) {
+ for (indx = iconList.getCount()-1; indx >= 0; indx--) {
IconItem* I = iconList[indx];
- iconList.remove( indx );
- IcoLib_FreeIcon( I );
- mir_free( I );
+ iconList.remove(indx);
+ IcoLib_FreeIcon(I);
+ mir_free(I);
}
iconList.destroy();
- for (indx = iconSourceList.getCount()-1; indx >= 0; indx-- ) {
+ for (indx = iconSourceList.getCount()-1; indx >= 0; indx--) {
IconSourceItem* I = iconSourceList[indx];
- iconSourceList.remove( indx );
- IconSourceFile_Release( &I->file );
- SafeDestroyIcon( &I->icon );
- SAFE_FREE(( void** )&I->icon_data );
- SAFE_FREE(( void** )&I );
+ iconSourceList.remove(indx);
+ IconSourceFile_Release(&I->file);
+ SafeDestroyIcon(&I->icon);
+ SAFE_FREE((void**)&I->icon_data);
+ SAFE_FREE((void**)&I);
}
iconSourceList.destroy();
- for (indx = iconSourceFileList.getCount()-1; indx >= 0; indx-- ) {
+ for (indx = iconSourceFileList.getCount()-1; indx >= 0; indx--) {
IconSourceFile* I = iconSourceFileList[indx];
- iconSourceFileList.remove( indx );
- SAFE_FREE(( void** )&I->file );
- SAFE_FREE(( void** )&I );
+ iconSourceFileList.remove(indx);
+ SAFE_FREE((void**)&I->file);
+ SAFE_FREE((void**)&I);
}
iconSourceFileList.destroy();
for (indx = 0; indx < sectionList.getCount(); indx++) {
- SAFE_FREE(( void** )§ionList[indx]->name );
- mir_free( sectionList[indx] );
+ SAFE_FREE((void**)§ionList[indx]->name);
+ mir_free(sectionList[indx]);
}
sectionList.destroy();
|