diff options
42 files changed, 775 insertions, 1864 deletions
diff --git a/include/delphi/custom_api.inc b/include/delphi/custom_api.inc index 92558ac10b..1dceb20658 100644 --- a/include/delphi/custom_api.inc +++ b/include/delphi/custom_api.inc @@ -23,7 +23,6 @@ {$include m_notify.inc}
{$include m_nudge.inc}
{$include m_nxsn.inc}
-{$include m_png.inc}
{$include m_proto_listeningto.inc}
{$include m_quickcontacts.inc}
{$include m_quotes.inc}
diff --git a/include/m_png.h b/include/m_png.h deleted file mode 100644 index c4d130fb71..0000000000 --- a/include/m_png.h +++ /dev/null @@ -1,62 +0,0 @@ -/*
-
-Miranda NG: the free IM client for Microsoft* Windows*
-
-Copyright (ñ) 2012-15 Miranda NG project (http://miranda-ng.org)
-Copyright (c) 2004-05 George Hazan (ghazan@postman.ru)
-
-Portions of this code are gotten from the libpng codebase.
-Copyright 2000, Willem van Schaik. For conditions of distribution and
-use, see the copyright/license/disclaimer notice in png.h
-
-Miranda IM: the free icq client for MS Windows
-Copyright (C) 2000-2002 Richard Hughes, Roland Rabien & Tristan Van de Vreede
-
-This program is free software; you can redistribute it and/or
-modify it under the terms of the GNU General Public License
-as published by the Free Software Foundation; either version 2
-of the License, or (at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
-*/
-
-/* Image/Dib2Png
-Converts a Device Independent Bitmap to a png stored in memory
- wParam=0
- lParam=(WPARAM)(DIB2PNG*)descr
-*/
-
-typedef struct
-{
- BITMAPINFO* pbmi;
- BYTE* pDiData;
- BYTE* pResult;
- long* pResultLen;
-}
- DIB2PNG;
-
-#define MS_DIB2PNG "Image/Dib2Png"
-
-/* Image/Png2Dib
-Converts a png stored in memory to a Device Independent Bitmap
- wParam=0
- lParam=(WPARAM)(PNG2DIB*)descr
-*/
-
-typedef struct
-{
- BYTE* pSource;
- DWORD cbSourceSize;
- BITMAPINFOHEADER** pResult;
-}
- PNG2DIB;
-
-#define MS_PNG2DIB "Image/Png2Dib"
diff --git a/include/m_string.h b/include/m_string.h index 82e279f31f..ae769e52bc 100644 --- a/include/m_string.h +++ b/include/m_string.h @@ -607,18 +607,21 @@ public: return _vscwprintf(pszFormat, args);
}
-#pragma warning(push)
-#pragma warning(disable : 4995 4996)
static int __stdcall Format(LPWSTR pszBuffer, LPCWSTR pszFormat, va_list args)
{
+ #pragma warning(push)
+ #pragma warning(disable : 4996)
return vswprintf(pszBuffer, pszFormat, args);
+ #pragma warning(pop)
}
static int __stdcall Format(LPWSTR pszBuffer, size_t nLength, LPCWSTR pszFormat, va_list args)
{
+ #pragma warning(push)
+ #pragma warning(disable : 4996)
return _vsnwprintf(pszBuffer, nLength, pszFormat, args);
+ #pragma warning(pop)
}
-#pragma warning(pop)
static int __stdcall GetBaseTypeLength(LPCSTR pszSrc)
{
diff --git a/plugins/AdvaImg/src/main.cpp b/plugins/AdvaImg/src/main.cpp index 5ba893dd51..87340ddd2c 100644 --- a/plugins/AdvaImg/src/main.cpp +++ b/plugins/AdvaImg/src/main.cpp @@ -28,7 +28,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include <commdlg.h>
#include <malloc.h>
-#include <m_png.h>
#include <m_clui.h>
#include <m_imgsrvc.h>
@@ -328,480 +327,35 @@ static INT_PTR serviceBmpFilterResizeBitmap(WPARAM wParam,LPARAM lParam) }
}
-
-FIBITMAP *
-FreeImage_LoadFromMem(FREE_IMAGE_FORMAT fif, fiio_mem_handle *handle, int flags) {
- //FreeImageIO io;
- //SetMemIO(&io);
-
+FIBITMAP* FreeImage_LoadFromMem(FREE_IMAGE_FORMAT fif, fiio_mem_handle *handle, int flags)
+{
if (handle && handle->data) {
- FIMEMORY *hmem = FreeImage_OpenMemory((BYTE *)handle->data, handle->datalen);
- FREE_IMAGE_FORMAT _fif = (fif != FIF_UNKNOWN) ? fif : FreeImage_GetFileTypeFromMemory(hmem, 0);
- FIBITMAP *dib = FreeImage_LoadFromMemory(_fif, hmem, flags);
- FreeImage_CloseMemory(hmem);
- //handle->curpos = 0;
- //return FreeImage_LoadFromHandle(fif, &io, (fi_handle)handle, flags);
+ FIMEMORY *hmem = FreeImage_OpenMemory((BYTE *)handle->data, handle->datalen);
+ FREE_IMAGE_FORMAT _fif = (fif != FIF_UNKNOWN) ? fif : FreeImage_GetFileTypeFromMemory(hmem, 0);
+ FIBITMAP *dib = FreeImage_LoadFromMemory(_fif, hmem, flags);
+ FreeImage_CloseMemory(hmem);
}
return NULL;
}
-FIMEMORY
-*FreeImage_SaveToMem(FREE_IMAGE_FORMAT fif, FIBITMAP *dib, fiio_mem_handle *handle, int flags) {
- //FreeImageIO io;
- //SetMemIO(&io);
-
+FIMEMORY* FreeImage_SaveToMem(FREE_IMAGE_FORMAT fif, FIBITMAP *dib, fiio_mem_handle *handle, int flags)
+{
if (handle) {
- FIMEMORY *hmem = FreeImage_OpenMemory(NULL, 0);
- if(fif == FIF_UNKNOWN)
- fif = FIF_BMP;
- handle->curpos = 0;
- FreeImage_SaveToMemory(fif, dib, hmem, flags);
- FreeImage_AcquireMemory(hmem, (BYTE **)&handle->data, (DWORD *)&handle->datalen);
- return hmem;
- //handle->filelen = 0;
- //handle->curpos = 0;
- //return FreeImage_SaveToHandle(fif, dib, &io, (fi_handle)handle, flags);
+ FIMEMORY *hmem = FreeImage_OpenMemory(NULL, 0);
+ if(fif == FIF_UNKNOWN)
+ fif = FIF_BMP;
+ handle->curpos = 0;
+ FreeImage_SaveToMemory(fif, dib, hmem, flags);
+ FreeImage_AcquireMemory(hmem, (BYTE **)&handle->data, (DWORD *)&handle->datalen);
+ return hmem;
}
return NULL;
}
-// ----------------------------------------------------------
-
-/*
-void
-SetMemIO(FreeImageIO *io) {
- io->read_proc = fiio_mem_ReadProc;
- io->seek_proc = fiio_mem_SeekProc;
- io->tell_proc = fiio_mem_TellProc;
- io->write_proc = fiio_mem_WriteProc;
-}
-
-// ----------------------------------------------------------
-
-#define FIIOMEM(member) (((fiio_mem_handle *)handle)->member)
-
-unsigned __stdcall fiio_mem_ReadProc(void *buffer, unsigned size, unsigned count, fi_handle handle) {
- unsigned x;
- for ( x=0; x<count; x++ ) {
- //if there isnt size bytes left to read, set pos to eof and return a short count
- if ( FIIOMEM(filelen)-FIIOMEM(curpos) < (long)size ) {
- FIIOMEM(curpos) = FIIOMEM(filelen);
- break;
- }
- //copy size bytes count times
- memcpy( buffer, (char *)FIIOMEM(data) + FIIOMEM(curpos), size );
- FIIOMEM(curpos) += size;
- buffer = (char *)buffer + size;
- }
- return x;
-}
-
-unsigned __stdcall fiio_mem_WriteProc(void *buffer, unsigned size, unsigned count, fi_handle handle) {
- void *newdata;
- long newdatalen;
- //double the data block size if we need to
- while( FIIOMEM(curpos)+(long)(size*count) >= FIIOMEM(datalen)) {
- //if we are at or above 1G, we cant double without going negative
- if ( FIIOMEM(datalen) & 0x40000000 ) {
- //max 2G
- if ( FIIOMEM(datalen) == 0x7FFFFFFF ) {
- return 0;
- }
- newdatalen = 0x7FFFFFFF;
- } else if ( FIIOMEM(datalen) == 0 ) {
- //default to 4K if nothing yet
- newdatalen = 4096;
- } else {
- //double size
- newdatalen = FIIOMEM(datalen) << 1;
- }
- newdata = realloc( FIIOMEM(data), newdatalen );
- if ( !newdata ) {
- return 0;
- }
- FIIOMEM(data) = newdata;
- FIIOMEM(datalen) = newdatalen;
- }
- memcpy( (char *)FIIOMEM(data) + FIIOMEM(curpos), buffer, size*count );
- FIIOMEM(curpos) += size*count;
- if ( FIIOMEM(curpos) > FIIOMEM(filelen)) {
- FIIOMEM(filelen) = FIIOMEM(curpos);
- }
- return count;
-}
-
-int __stdcall fiio_mem_SeekProc(fi_handle handle, long offset, int origin) {
- switch(origin) { //0 to filelen-1 are 'inside' the file
- default:
- case SEEK_SET: //can fseek() to 0-7FFFFFFF always
- if ( offset >= 0 ) {
- FIIOMEM(curpos) = offset;
- return 0;
- }
- break;
-
- case SEEK_CUR:
- if ( FIIOMEM(curpos)+offset >= 0 ) {
- FIIOMEM(curpos) += offset;
- return 0;
- }
- break;
-
- case SEEK_END:
- if ( FIIOMEM(filelen)+offset >= 0 ) {
- FIIOMEM(curpos) = FIIOMEM(filelen)+offset;
- return 0;
- }
- break;
- }
-
- return -1;
-}
-
-long __stdcall fiio_mem_TellProc(fi_handle handle) {
- return FIIOMEM(curpos);
-}
-
-*/
-
-// PNG image handler functions
-
-typedef struct {
- char* mBuffer;
- png_size_t mBufSize;
- png_size_t mBufPtr;
-}
-HMemBufInfo;
-
-static void png_read_data( png_structp png_ptr, png_bytep data, png_size_t length )
-{
- HMemBufInfo* io = ( HMemBufInfo* )png_get_io_ptr(png_ptr);
- if ( length + io->mBufPtr > io->mBufSize )
- length = io->mBufSize - io->mBufPtr;
-
- if ( length > 0 ) {
- memcpy( data, io->mBuffer + io->mBufPtr, length );
- io->mBufPtr += length;
- }
- else png_error(png_ptr, "Read Error");
-}
-
-static void png_write_data( png_structp png_ptr, png_bytep data, png_size_t length )
-{
- HMemBufInfo* io = ( HMemBufInfo* )png_get_io_ptr(png_ptr);
- if ( io->mBuffer != NULL )
- memcpy( io->mBuffer + io->mBufPtr, data, length );
-
- io->mBufPtr += length;
-}
-
-static void png_flush( png_structp png_ptr )
-{
-}
-
-/*
-* Converting a *in memory* png image into a bitmap
-*/
-
-extern "C" BOOL __declspec(dllexport) mempng2dib(BYTE* pSource, DWORD cbSourceSize, BITMAPINFOHEADER** ppDibData )
-{
- png_structp png_ptr = NULL;
- png_infop info_ptr = NULL;
- HMemBufInfo sBuffer = { (char*)pSource, cbSourceSize, 8 };
-
- BOOL bResult = FALSE;
- png_uint_32 iWidth;
- png_uint_32 iHeight;
- png_color pBkgColor;
- int iBitDepth;
- int iColorType;
- double dGamma;
- png_color_16* pBackground;
- png_byte ulChannels;
- png_size_t ulRowBytes;
- png_byte* pbImageData;
- png_byte** ppbRowPointers = NULL;
- int i;
- png_uint_32 j;
- int wDIRowBytes;
- BYTE* pImageData;
-
- *ppDibData = NULL;
-
- if ( pSource == NULL || cbSourceSize == 0 )
- return FALSE;
-
- if ( !png_check_sig( pSource, 8 ))
- return FALSE;
-
- // create the two png(-info) structures
- png_ptr = png_create_read_struct( PNG_LIBPNG_VER_STRING, NULL, NULL, NULL );
- if (!png_ptr)
- return FALSE;
-
- info_ptr = png_create_info_struct(png_ptr);
- if ( !info_ptr ) {
- png_destroy_read_struct(&png_ptr, NULL, NULL);
- return FALSE;
- }
-
- // initialize the png structure
- png_set_read_fn(png_ptr, (png_voidp)&sBuffer, png_read_data);
- png_set_sig_bytes(png_ptr, 8);
-
- // read all PNG info up to image data
- png_read_info(png_ptr, info_ptr);
-
- // get width, height, bit-depth and color-type
-
- png_get_IHDR(png_ptr, info_ptr, &iWidth, &iHeight, &iBitDepth, &iColorType, NULL, NULL, NULL);
-
- // expand images of all color-type and bit-depth to 3x8 bit RGB images
- // let the library process things like alpha, transparency, background
-
- if ( iBitDepth == 16 )
- png_set_strip_16( png_ptr );
- if ( iColorType == PNG_COLOR_TYPE_PALETTE )
- png_set_expand( png_ptr );
- if ( iBitDepth < 8 )
- png_set_expand( png_ptr );
- if (png_get_valid( png_ptr, info_ptr, PNG_INFO_tRNS ))
- png_set_expand( png_ptr );
- if ( iColorType == PNG_COLOR_TYPE_GRAY || iColorType == PNG_COLOR_TYPE_GRAY_ALPHA )
- png_set_gray_to_rgb( png_ptr );
-
- // set the background color to draw transparent and alpha images over.
- if (png_get_bKGD( png_ptr, info_ptr, &pBackground )) {
- png_set_background(png_ptr, pBackground, PNG_BACKGROUND_GAMMA_FILE, 1, 1.0);
- pBkgColor.red = (byte) pBackground->red;
- pBkgColor.green = (byte) pBackground->green;
- pBkgColor.blue = (byte) pBackground->blue;
- }
-
- // if required set gamma conversion
- if ( png_get_gAMA( png_ptr, info_ptr, &dGamma ))
- png_set_gamma( png_ptr, (double) 2.2, dGamma );
-
- // after the transformations have been registered update info_ptr data
- png_read_update_info(png_ptr, info_ptr);
-
- // get again width, height and the new bit-depth and color-type
- png_get_IHDR(png_ptr, info_ptr, &iWidth, &iHeight, &iBitDepth, &iColorType, NULL, NULL, NULL);
-
- // row_bytes is the width x number of channels
- ulRowBytes = png_get_rowbytes(png_ptr, info_ptr);
- ulChannels = png_get_channels(png_ptr, info_ptr);
- wDIRowBytes = (WORD) (( ulChannels * iWidth + 3L) >> 2) << 2;
-
- // now we can allocate memory to store the image
- { DWORD cbMemSize = sizeof( BITMAPINFOHEADER );
- cbMemSize += wDIRowBytes * iHeight;
- if (( pbImageData = ( png_byte* )GlobalAlloc( LPTR, cbMemSize )) == NULL ) {
- png_destroy_read_struct( &png_ptr, &info_ptr, NULL );
- return FALSE;
- } }
-
- // initialize the dib-structure
- { BITMAPINFOHEADER* pbmih = ( BITMAPINFOHEADER* )pbImageData;
- *ppDibData = pbmih;
-
- pbmih->biSize = sizeof( BITMAPINFOHEADER );
- pbmih->biWidth = iWidth;
- pbmih->biHeight = iHeight;
- pbmih->biPlanes = 1;
- pbmih->biBitCount = ( WORD )( ulChannels * 8 );
- pbmih->biCompression = 0;
- pbmih->biSizeImage = iWidth * iHeight * ulChannels;
-
- pbImageData += sizeof( BITMAPINFOHEADER );
- }
-
- pImageData = (BYTE*)malloc( ulRowBytes * iHeight );
- if ( pImageData == NULL ) {
- png_destroy_read_struct(&png_ptr, NULL, NULL);
- return FALSE;
- }
-
- // and allocate memory for an array of row-pointers
- ppbRowPointers = ( png_bytepp )alloca( iHeight * sizeof( png_bytep ));
-
- // set the individual row-pointers to point at the correct offsets
- for ( j = 0; j < iHeight; j++ )
- ppbRowPointers[j] = ( png_bytep )&pImageData[ j*ulRowBytes ];
-
- // now we can go ahead and just read the whole image
- png_read_image( png_ptr, ppbRowPointers );
- png_read_end(png_ptr, NULL);
-
- // repack bytes to fill the bitmap
- for ( i = iHeight-1; i >= 0; i-- )
- {
- png_byte a;
- png_bytep s = ppbRowPointers[i];
- BYTE* dest = pbImageData; pbImageData += wDIRowBytes;
-
- for ( j = 0; j < iWidth; j++ ) {
- png_byte r = *s++;
- png_byte g = *s++;
- png_byte b = *s++;
- if ( ulChannels == 4 )
- a = *s++;
-
- *dest++ = b;
- *dest++ = g;
- *dest++ = r;
- if ( ulChannels == 4 )
- *dest++ = a;
- } }
-
- free( pImageData );
- png_destroy_read_struct( &png_ptr, &info_ptr, NULL );
- return TRUE;
-}
-
-/*
-* Converting a bitmap into a png image
-*/
-
-static BOOL sttCheckAlphaIsValid( BITMAPINFO* pbmi, png_byte* pDiData )
-{
- int ciChannels = pbmi->bmiHeader.biBitCount / 8, i, j;
- int ulSrcRowBytes = ((( pbmi->bmiHeader.biWidth * ciChannels + 3 ) >> 2 ) << 2 );
- byte value = pDiData[ 3 ];
-
- if ( ciChannels < 4 )
- return FALSE;
-
- if ( value != 0 && value != 0xFF )
- return TRUE;
-
- for ( i=0; i < pbmi->bmiHeader.biHeight; i++ ) {
- png_byte* p = pDiData; pDiData += ulSrcRowBytes;
-
- for ( j=0; j < pbmi->bmiHeader.biWidth; j++, p += 4 )
- if ( p[3] != value )
- return TRUE;
- }
-
- return FALSE;
-}
-
-extern "C" BOOL __declspec(dllexport) dib2mempng( BITMAPINFO* pbmi, png_byte* pDiData, BYTE* pResult, long* pResultLen )
-{
- int ciBitDepth = 8;
- int ciChannels = pbmi->bmiHeader.biBitCount / 8;
-
- png_uint_32 ulSrcRowBytes, ulDstRowBytes;
- int i;
- png_structp png_ptr = NULL;
- png_infop info_ptr = NULL;
- png_bytepp ppbRowPointers;
- png_bytep pTempBuffer;
- BOOL bIsAlphaValid;
-
- HMemBufInfo sBuffer = { (char *)pResult, 0, 0 };
-
- png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, (png_error_ptr)NULL, (png_error_ptr)NULL);
- if (!png_ptr)
- return FALSE;
-
- info_ptr = png_create_info_struct(png_ptr);
- if (!info_ptr) {
- png_destroy_write_struct(&png_ptr, (png_infopp) NULL);
- return FALSE;
- }
-
- // initialize the png structure
- bIsAlphaValid = sttCheckAlphaIsValid( pbmi, pDiData );
- png_set_write_fn(png_ptr, (png_voidp)&sBuffer, png_write_data, png_flush);
-
- png_set_IHDR(png_ptr, info_ptr, pbmi->bmiHeader.biWidth, pbmi->bmiHeader.biHeight, ciBitDepth,
- ( bIsAlphaValid ) ? PNG_COLOR_TYPE_RGB_ALPHA : PNG_COLOR_TYPE_RGB,
- PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE);
-
- // write the file header information
- png_write_info(png_ptr, info_ptr);
-
- // swap the BGR pixels in the DiData structure to RGB
- png_set_bgr(png_ptr);
-
- // row_bytes is the width x number of channels
- ulSrcRowBytes = ((( pbmi->bmiHeader.biWidth * ciChannels + 3 ) >> 2 ) << 2 );
- ulDstRowBytes = ((( pbmi->bmiHeader.biWidth * ( ciChannels == 4 && bIsAlphaValid ? 4 : 3 ) + 3 ) >> 2 ) << 2 );
-
- ppbRowPointers = (png_bytepp)alloca( pbmi->bmiHeader.biHeight * sizeof(png_bytep));
-
- pTempBuffer = ( png_bytep )malloc( pbmi->bmiHeader.biHeight * ulDstRowBytes );
- if ( pTempBuffer != NULL ) {
- png_bytep pDest = pTempBuffer;
- for ( i = pbmi->bmiHeader.biHeight-1; i >= 0; i--) {
- BYTE *s, *d;
- int j;
- s = pDiData; pDiData += ulSrcRowBytes;
- d = ppbRowPointers[i] = pDest; pDest += ulDstRowBytes;
-
- if ( ciChannels >= 3 ) {
- for ( j = 0; j < pbmi->bmiHeader.biWidth; j++ ) {
- png_byte b = *s++;
- png_byte g = *s++;
- png_byte r = *s++;
- png_byte a = 0;
-
- if ( ciChannels == 4 )
- a = *s++;
-
- *d++ = b;
- *d++ = g;
- *d++ = r;
- if ( ciChannels == 4 && bIsAlphaValid )
- *d++ = a;
- } }
- else {
- for ( j = 0; j < pbmi->bmiHeader.biWidth; j++ ) {
- DWORD point = 0;
- if ( ciChannels == 1 ) {
- *d++ = ( BYTE )( point & 0x03 ) << 6;
- *d++ = ( BYTE )(( point & 0x0C ) >> 2 ) << 6;
- *d++ = ( BYTE )(( point & 0x30 ) >> 4 ) << 6;
- point = *s++;
- }
- else {
- point = *( WORD* )s;
- s += sizeof( WORD );
- *d++ = ( BYTE )(( point & 0x001F ) << 3 );
- *d++ = ( BYTE )((( point & 0x07e0 ) >> 6 ) << 3 );
- *d++ = ( BYTE )((( point & 0xF800 ) >> 11 ) << 3 );
- } } } }
-
- png_write_image (png_ptr, ppbRowPointers);
- png_write_end(png_ptr, info_ptr);
-
- if ( pResultLen != NULL )
- *pResultLen = (long)sBuffer.mBufPtr;
-
- free( pTempBuffer );
- }
-
- png_destroy_write_struct(&png_ptr, &info_ptr );
- return TRUE;
-}
-
///////////////////////////////////////////////////////////////////////////////
// Load - initializes the plugin instance
-static INT_PTR serviceDib2Png( WPARAM wParam, LPARAM lParam )
-{
- DIB2PNG* param = ( DIB2PNG* )lParam;
- return dib2mempng( param->pbmi, param->pDiData, param->pResult, param->pResultLen );
-}
-
-static INT_PTR servicePng2Dib( WPARAM wParam, LPARAM lParam )
-{
- PNG2DIB* param = ( PNG2DIB* )lParam;
- return mempng2dib( param->pSource, param->cbSourceSize, param->pResult );
-}
-
FI_INTERFACE feif = {0};
/*
@@ -866,21 +420,13 @@ static INT_PTR serviceLoad(WPARAM wParam, LPARAM lParam) static INT_PTR serviceLoadFromMem(WPARAM wParam, LPARAM lParam)
{
IMGSRVC_MEMIO *mio = (IMGSRVC_MEMIO *)wParam;
- //fiio_mem_handle fiio;
-
if(mio->iLen == 0 || mio->pBuf == NULL)
return 0;
- //fiio.curpos = 0;
- //fiio.data = mio->pBuf;
- //fiio.datalen = fiio.filelen = mio->iLen;
-
- FIMEMORY *hmem = FreeImage_OpenMemory((BYTE *)mio->pBuf, mio->iLen);
- FREE_IMAGE_FORMAT fif = (mio->fif != FIF_UNKNOWN) ? mio->fif : mio->fif = FreeImage_GetFileTypeFromMemory(hmem, 0);
- FIBITMAP *dib = FreeImage_LoadFromMemory(fif, hmem, mio->flags);
- FreeImage_CloseMemory(hmem);
-
- //FIBITMAP *dib = FreeImage_LoadFromMem(mio->fif, &fiio, mio->flags);
+ FIMEMORY *hmem = FreeImage_OpenMemory((BYTE *)mio->pBuf, mio->iLen);
+ FREE_IMAGE_FORMAT fif = (mio->fif != FIF_UNKNOWN) ? mio->fif : mio->fif = FreeImage_GetFileTypeFromMemory(hmem, 0);
+ FIBITMAP *dib = FreeImage_LoadFromMemory(fif, hmem, mio->flags);
+ FreeImage_CloseMemory(hmem);
if(dib == NULL || (lParam & IMGL_RETURNDIB))
return (INT_PTR)dib;
@@ -1185,8 +731,6 @@ static int IMGSERVICE_Load() {
FI_Populate();
- CreateServiceFunction(MS_DIB2PNG, serviceDib2Png);
- CreateServiceFunction(MS_PNG2DIB, servicePng2Dib);
CreateServiceFunction(MS_IMG_GETINTERFACE, serviceGetInterface);
CreateServiceFunction(MS_IMG_LOAD, serviceLoad);
CreateServiceFunction(MS_IMG_LOADFROMMEM, serviceLoadFromMem);
diff --git a/plugins/Clist_modern/src/modern_skinengine.cpp b/plugins/Clist_modern/src/modern_skinengine.cpp index f0d0cd173e..892b9a983f 100644 --- a/plugins/Clist_modern/src/modern_skinengine.cpp +++ b/plugins/Clist_modern/src/modern_skinengine.cpp @@ -24,7 +24,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. //Include #include "hdr/modern_commonheaders.h" -#include <m_png.h> #include "m_skin_eng.h" #include "hdr/modern_skinselector.h" #include "CLUIFrames/cluiframes.h" diff --git a/plugins/ExternalAPI/delphi/m_png.inc b/plugins/ExternalAPI/delphi/m_png.inc deleted file mode 100644 index 03fe8e5e9f..0000000000 --- a/plugins/ExternalAPI/delphi/m_png.inc +++ /dev/null @@ -1,67 +0,0 @@ -{
- Plugin of Miranda IM for reading/writing PNG images.
- Copyright (c) 2004-5 George Hazan (ghazan@postman.ru)
-
- Portions of this code are gotten from the libpng codebase.
- Copyright 2000, Willem van Schaik. For conditions of distribution and
- use, see the copyright/license/disclaimer notice in png.h
-
- Miranda IM: the free icq client for MS Windows
- Copyright (C) 2000-2002 Richard Hughes, Roland Rabien & Tristan Van de Vreede
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 2
- of the License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
- File name : $Source: /cvsroot/miranda/miranda/include/m_png.h,v $
- Revision : $Revision: 1.1 $
- Last change on : $Date: 2005/10/29 17:10:51 $
- Last change by : $Author: ghazan $
-}
-
-{$IFNDEF M_PNG}
-{$DEFINE M_PNG}
-{ Image/Dib2Png
- Converts a Device Independent Bitmap to a png stored in memory
- wParam=0
- lParam=(WPARAM)(DIB2PNG*)descr
-}
-type
- PDIB2PNG = ^TDIB2PNG;
- TDIB2PNG = record
- pbmi : PBITMAPINFO;
- pDiData : PBYTE;
- pResult : PBYTE;
- pResultLen : Plong;
- end;
-
-const
- MS_DIB2PNG:PAnsiChar = 'Image/Dib2Png';
-
-{ Image/Png2Dib
- Converts a png stored in memory to a Device Independent Bitmap
- wParam=0
- lParam=TPNG2DIB(descr)
-}
-type
- PPNG2DIB = ^TPNG2DIB;
- TPNG2DIB = record
- pSource : PBYTE;
- cbSourceSize : dword;
- pResult : ^PBITMAPINFOHEADER;
- end;
-
-const
- MS_PNG2DIB:PAnsiChar = 'Image/Png2Dib';
-
-{$ENDIF}
diff --git a/plugins/FloatingContacts/src/bitmap_funcs.cpp b/plugins/FloatingContacts/src/bitmap_funcs.cpp index 98d21fa935..47690ac980 100644 --- a/plugins/FloatingContacts/src/bitmap_funcs.cpp +++ b/plugins/FloatingContacts/src/bitmap_funcs.cpp @@ -932,78 +932,10 @@ bool MyBitmap::loadFromFile_gradient(const char *fn, const char *fnAlpha) return true;
}
-bool MyBitmap::loadFromFile_png(const char *fn, const char *fnAlpha)
-{
- if (ServiceExists(MS_PNG2DIB)) {
- HANDLE hFile, hMap = 0;
- BYTE *ppMap = 0;
- long cbFileSize = 0;
- BITMAPINFOHEADER *pDib;
- BYTE *pDibBits;
- if ((hFile = CreateFileA(fn, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL)) != INVALID_HANDLE_VALUE)
- if ((hMap = CreateFileMapping(hFile, NULL, PAGE_READONLY, 0, 0, NULL)) != NULL)
- if ((ppMap = (BYTE*)MapViewOfFile(hMap, FILE_MAP_READ, 0, 0, 0)) != NULL)
- cbFileSize = GetFileSize(hFile, NULL);
-
- if (cbFileSize) {
- PNG2DIB param;
- param.pSource = ppMap;
- param.cbSourceSize = cbFileSize;
- param.pResult = &pDib;
- if (CallService(MS_PNG2DIB, 0, (LPARAM)¶m))
- pDibBits = (BYTE*)(pDib + 1);
- else
- cbFileSize = 0;
- }
-
- if (ppMap) UnmapViewOfFile(ppMap);
- if (hMap) CloseHandle(hMap);
- if (hFile) CloseHandle(hFile);
-
- if (!cbFileSize) return false;
-
- BITMAPINFO *bi = (BITMAPINFO*)pDib;
- BYTE *pt = (BYTE*)bi;
- pt += bi->bmiHeader.biSize;
-
- if (bi->bmiHeader.biBitCount != 32) {
- allocate(abs(bi->bmiHeader.biWidth), abs(bi->bmiHeader.biHeight));
- HDC hdcTmp = CreateCompatibleDC(getDC());
- HBITMAP hBitmap = CreateDIBitmap(getDC(), pDib, CBM_INIT, pDibBits, bi, DIB_PAL_COLORS);
- SelectObject(hdcTmp, hBitmap);
- BitBlt(this->getDC(), 0, 0, abs(bi->bmiHeader.biWidth), abs(bi->bmiHeader.biHeight), hdcTmp, 0, 0, SRCCOPY);
- this->makeOpaque();
- DeleteDC(hdcTmp);
- DeleteObject(hBitmap);
- }
- else {
- allocate(abs(bi->bmiHeader.biWidth), abs(bi->bmiHeader.biHeight));
- BYTE *p2 = (BYTE *)pt;
- for (int y = 0; y < bi->bmiHeader.biHeight; ++y) {
- BYTE *p1 = (BYTE *)bits + (bi->bmiHeader.biHeight - y - 1)*bi->bmiHeader.biWidth * 4;
- for (int x = 0; x < bi->bmiHeader.biWidth; ++x) {
- p1[0] = p2[0];
- p1[1] = p2[1];
- p1[2] = p2[2];
- p1[3] = p2[3];
- p1 += 4;
- p2 += 4;
- }
- }
- premultipleChannels();
- }
-
- GlobalFree(pDib);
- return true;
- }
-
- return false;
-}
-
bool MyBitmap::loadFromFile_default(const char *fn, const char *fnAlpha)
{
SIZE sz;
- HBITMAP hBmpLoaded = (HBITMAP)LoadImageA(NULL, fn, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
+ HBITMAP hBmpLoaded = (HBITMAP)CallService(MS_IMG_LOAD, (WPARAM)fn, 0);
if (!hBmpLoaded)
return false;
@@ -1041,11 +973,6 @@ bool MyBitmap::loadFromFile(const char *fn, const char *fnAlpha) if (!strncmp(fn, "gradient:", mir_strlen("gradient:")))
return loadFromFile_gradient(fn, fnAlpha);
- char ext[5];
- memcpy(ext, fn + (mir_strlen(fn) - 4), 5);
- if (!mir_strcmpi(ext, ".png"))
- return loadFromFile_png(fn, fnAlpha);
-
return loadFromFile_default(fn, fnAlpha);
}
diff --git a/plugins/FloatingContacts/src/stdhdr.h b/plugins/FloatingContacts/src/stdhdr.h index e5d1b328a2..f4fa678833 100644 --- a/plugins/FloatingContacts/src/stdhdr.h +++ b/plugins/FloatingContacts/src/stdhdr.h @@ -21,7 +21,7 @@ #include <m_options.h>
#include <m_clistint.h>
#include <m_hotkeys.h>
-#include <m_png.h>
+#include <m_imgsrvc.h>
#include <win2k.h>
#include "bitmap_funcs.h"
diff --git a/plugins/HistoryStats/src/canvas.cpp b/plugins/HistoryStats/src/canvas.cpp index 5eb395f2b2..881fbc254f 100644 --- a/plugins/HistoryStats/src/canvas.cpp +++ b/plugins/HistoryStats/src/canvas.cpp @@ -137,53 +137,11 @@ bool Canvas::getDigest(Digest& digest) bool Canvas::writePNG(const TCHAR* szFileName)
{
- // read data from DIB
- BYTE* pData = new BYTE[m_nLineLength * m_nHeight];
-
- if (GetDIBits(m_hDC, m_hBmp, 0, m_nHeight, pData, reinterpret_cast<BITMAPINFO*>(m_pBMIH), DIB_RGB_COLORS) != m_nHeight) {
- delete[] pData;
- return false;
- }
-
- // apply transparency, if any
- updateTrans(pData);
-
- // calculate resulting image size
- long png_len = 0;
-
- if (!mu::png::dibToPng(m_pBMIH, pData, 0, &png_len) || png_len == 0) {
- delete[] pData;
- return false;
- }
-
- // get the resulting image data
- BYTE* pRawPNG = new BYTE[png_len];
-
- png_len = 0;
-
- if (!mu::png::dibToPng(m_pBMIH, pData, pRawPNG, &png_len)) {
- delete[] pData;
- delete[] pRawPNG;
-
- return false;
- }
-
- // write image data to file
- FILE* fp = _tfopen(szFileName, _T("wb"));
-
- if (!fp) {
- delete[] pData;
- delete[] pRawPNG;
-
- return false;
- }
-
- fwrite(pRawPNG, 1, png_len, fp);
- fclose(fp);
-
- // free buffers
- delete[] pRawPNG;
- delete[] pData;
-
- return true;
+ IMGSRVC_INFO img = { 0 };
+ img.cbSize = sizeof(img);
+ img.dwMask = IMGI_HBITMAP;
+ img.hbm = m_hBmp;
+ img.fif = FIF_PNG;
+ img.tszName = (TCHAR*)szFileName;
+ return CallService(MS_IMG_SAVE, (WPARAM)&img, IMGL_TCHAR) == 0;
}
diff --git a/plugins/HistoryStats/src/canvas.h b/plugins/HistoryStats/src/canvas.h index 81a69caed4..a5b7f06519 100644 --- a/plugins/HistoryStats/src/canvas.h +++ b/plugins/HistoryStats/src/canvas.h @@ -20,9 +20,6 @@ public: bool operator <(const Digest& other) const { return (memcmp(m_Digest, other.m_Digest, 20) < 0); }
};
-public:
- static bool hasPNG() { return mu::png::_available(); }
-
private:
int m_nChannels;
int m_nWidth;
diff --git a/plugins/HistoryStats/src/dlgoption_subglobal.cpp b/plugins/HistoryStats/src/dlgoption_subglobal.cpp index c2b0054cf5..9df4998661 100644 --- a/plugins/HistoryStats/src/dlgoption_subglobal.cpp +++ b/plugins/HistoryStats/src/dlgoption_subglobal.cpp @@ -286,14 +286,6 @@ void DlgOption::SubGlobal::loadSettings() m_Options.checkItem(*i, localS.m_HideContactMenuProtos.find(protoName) != localS.m_HideContactMenuProtos.end());
}
-
- // check for availability of 'libpng'
- if (!Canvas::hasPNG()) {
- if (m_Options.isItemChecked(m_hGraphicsModePNG))
- m_Options.setRadioChecked(m_hGraphicsMode, Settings::gmHTML);
-
- m_Options.enableItem(m_hGraphicsModePNG, false);
- }
}
void DlgOption::SubGlobal::saveSettings()
diff --git a/plugins/HistoryStats/src/mu_common.cpp b/plugins/HistoryStats/src/mu_common.cpp index 17c84e7eee..74cd534b0f 100644 --- a/plugins/HistoryStats/src/mu_common.cpp +++ b/plugins/HistoryStats/src/mu_common.cpp @@ -207,32 +207,6 @@ namespace mu }
/*
- * png
- */
-
- namespace png
- {
- bool _available()
- {
- return
- true &&
- ServiceExists(MS_DIB2PNG);
- }
-
- bool dibToPng(const BITMAPINFOHEADER* pBMIH, const BYTE* pDIData, BYTE* pImageData, long* pImageLen)
- {
- DIB2PNG info;
-
- info.pbmi = const_cast<BITMAPINFO*>(reinterpret_cast<const BITMAPINFO*>(pBMIH));
- info.pDiData = const_cast<BYTE*>(pDIData);
- info.pResult = pImageData;
- info.pResultLen = pImageLen;
-
- return bool_(CallService(MS_DIB2PNG, 0, reinterpret_cast<LPARAM>(&info)));
- }
- }
-
- /*
* proto
*/
diff --git a/plugins/HistoryStats/src/mu_common.h b/plugins/HistoryStats/src/mu_common.h index 8ad005a5f4..349c68c218 100644 --- a/plugins/HistoryStats/src/mu_common.h +++ b/plugins/HistoryStats/src/mu_common.h @@ -72,16 +72,6 @@ namespace mu }
/*
- * png
- */
-
- namespace png
- {
- bool _available();
- bool dibToPng(const BITMAPINFOHEADER* pBMIH, const BYTE* pDIData, BYTE* pImageData, long* pImageLen);
- }
-
- /*
* proto
*/
diff --git a/plugins/HistoryStats/src/settings.cpp b/plugins/HistoryStats/src/settings.cpp index 722e298a4f..a9c2b6ec06 100644 --- a/plugins/HistoryStats/src/settings.cpp +++ b/plugins/HistoryStats/src/settings.cpp @@ -524,7 +524,7 @@ ext::string Settings::getOutputPrefix(DWORD timeStarted) const bool Settings::isPNGOutputActiveAndAvailable() const
{
- return (m_GraphicsMode == gmPNG && Canvas::hasPNG());
+ return (m_GraphicsMode == gmPNG);
}
DWORD Settings::getIgnoreBefore() const
diff --git a/plugins/HistoryStats/src/statistic.cpp b/plugins/HistoryStats/src/statistic.cpp index e609101d3d..f2a5fceaf3 100644 --- a/plugins/HistoryStats/src/statistic.cpp +++ b/plugins/HistoryStats/src/statistic.cpp @@ -1303,7 +1303,6 @@ bool Statistic::createStatistics() /*
* Cleanup.
*/
- CloseHandle(hThread);
CloseHandle(m_hCancelEvent);
m_hCancelEvent = NULL;
m_hWndProgress = NULL;
@@ -1372,9 +1371,11 @@ bool Statistic::createStatisticsSteps() void __cdecl Statistic::threadProc(void *lpParameter)
{
Statistic* pStats = reinterpret_cast<Statistic*>(lpParameter);
-
SetEvent(pStats->m_hThreadPushEvent);
+ // perform action
+ pStats->createStatistics();
+
// check for errors
if (!pStats->m_ErrorText.empty() && !mu::system::terminated())
MessageBox(0, pStats->m_ErrorText.c_str(), TranslateT("HistoryStats - Error"), MB_ICONERROR | MB_OK);
diff --git a/plugins/HistoryStats/src/stdafx.h b/plugins/HistoryStats/src/stdafx.h index 6e49afefe2..76b7afa97b 100644 --- a/plugins/HistoryStats/src/stdafx.h +++ b/plugins/HistoryStats/src/stdafx.h @@ -56,7 +56,6 @@ #include <m_message.h> // not used
#include <m_netlib.h> // not used
#include <m_options.h>
-#include <m_png.h>
#include <m_popup.h> // not used
#include <m_protocols.h>
#include <m_protomod.h> // not used
@@ -67,6 +66,7 @@ #include <m_url.h> // not used
#include <m_userinfo.h> // not used
#include <m_utils.h>
+#include <m_imgsrvc.h>
#include <m_addcontact.h> // not used, depends on m_protosvc.h
#include <m_icq.h> // depends on m_protosvc.h
diff --git a/plugins/Popup/src/actions.cpp b/plugins/Popup/src/actions.cpp index d731bd9e80..291d2f10f8 100644 --- a/plugins/Popup/src/actions.cpp +++ b/plugins/Popup/src/actions.cpp @@ -143,7 +143,8 @@ DWORD MouseOverride(HWND hCombo, int number) // options
-void LoadOption_Actions() {
+void LoadOption_Actions()
+{
PopupOptions.actions = db_get_dw(NULL, MODULNAME, "Actions",
ACT_ENABLE | ACT_RIGHTICONS | ACT_DEF_KEEPWND | ACT_DEF_IMONLY |
ACT_DEF_NOGLOBAL | ACT_DEF_MESSAGE | ACT_DEF_DETAILS | ACT_DEF_MENU |
@@ -238,9 +239,7 @@ INT_PTR CALLBACK DlgProcPopupActions(HWND hwnd, UINT msg, WPARAM wParam, LPARAM mir_strncpy(szGroup, gActions[i]->lpzTitle, szName - gActions[i]->lpzTitle);
int grpId = 0;
-
- if ((grpId = groups.getIndex(szGroup)) < 0)
- {
+ if ((grpId = groups.getIndex(szGroup)) < 0) {
LVGROUP group = { 0 };
group.cbSize = sizeof(group);
group.mask = LVGF_HEADER | LVGF_GROUPID;
diff --git a/plugins/Popup/src/avatars.cpp b/plugins/Popup/src/avatars.cpp index aa5529c5ee..89dee0724c 100644 --- a/plugins/Popup/src/avatars.cpp +++ b/plugins/Popup/src/avatars.cpp @@ -25,25 +25,13 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. PopupAvatar *PopupAvatar::create(MCONTACT hContact)
{
- if (hContact)
- {
- if (ServiceExists(MS_AV_GETAVATARBITMAP))
- {
+ if (hContact) {
+ if (ServiceExists(MS_AV_GETAVATARBITMAP)) {
avatarCacheEntry *av = (avatarCacheEntry *)CallService(MS_AV_GETAVATARBITMAP, hContact, 0);
- // MessageBox(NULL, _T("00"), _T(MODULNAME_LONG), MB_OK);
if (av && (mir_tstrlen(av->szFilename) > 4))
- {
- // MessageBox(NULL, _T("01"), _T(MODULNAME_LONG), MB_OK);
if (!mir_tstrcmpi(av->szFilename + mir_tstrlen(av->szFilename) - 4, _T(".gif")))
- {
- // MessageBox(NULL, _T("02"), _T(MODULNAME_LONG), MB_OK);
if (db_get_b(NULL, MODULNAME, "EnableGifAnimation", 1) && GDIPlus_IsAnimatedGIF(av->szFilename))
- {
- // MessageBox(NULL, _T("03"), _T(MODULNAME_LONG), MB_OK);
return new GifAvatar(hContact);
- }
- }
- }
}
}
diff --git a/plugins/Popup/src/avatars_gif.cpp b/plugins/Popup/src/avatars_gif.cpp index cc935feccb..33ea2b02f4 100644 --- a/plugins/Popup/src/avatars_gif.cpp +++ b/plugins/Popup/src/avatars_gif.cpp @@ -60,8 +60,7 @@ void GifAvatar::draw(MyBitmap *bmp, int x, int y, int w, int h, POPUPOPTIONS *op {
if (!av || (w <= 0) || (h <= 0)) return;
- if (!frameCount || !frameDelays || !hBitmap || (cachedWidth != w) || (cachedHeight != h))
- {
+ if (!frameCount || !frameDelays || !hBitmap || (cachedWidth != w) || (cachedHeight != h)) {
cachedWidth = w;
cachedHeight = h;
if (frameDelays) {
@@ -75,13 +74,11 @@ void GifAvatar::draw(MyBitmap *bmp, int x, int y, int w, int h, POPUPOPTIONS *op if (!frameCount) return;
HRGN rgn;
- if (options->avatarRadius)
- {
+ if (options->avatarRadius) {
rgn = CreateRoundRectRgn(x, y, x + w, y + h, 2 * options->avatarRadius, 2 * options->avatarRadius);
SelectClipRgn(bmp->getDC(), rgn);
}
- else
- {
+ else {
rgn = CreateRectRgn(x, y, x + w, y + h);
}
@@ -89,9 +86,7 @@ void GifAvatar::draw(MyBitmap *bmp, int x, int y, int w, int h, POPUPOPTIONS *op SelectObject(hdcTmp, hBitmap);
SetStretchBltMode(bmp->getDC(), HALFTONE);
-
- if (av->dwFlags & AVS_PREMULTIPLIED)
- {
+ if (av->dwFlags & AVS_PREMULTIPLIED) {
BLENDFUNCTION bf;
bf.BlendOp = AC_SRC_OVER;
bf.BlendFlags = 0;
@@ -99,8 +94,7 @@ void GifAvatar::draw(MyBitmap *bmp, int x, int y, int w, int h, POPUPOPTIONS *op bf.AlphaFormat = AC_SRC_ALPHA;
AlphaBlend(bmp->getDC(), x, y, w, h, hdcTmp, frameSize.cx*activeFrame, 0, frameSize.cx, frameSize.cy, bf);
- if (options->avatarBorders && options->avatarPNGBorders)
- {
+ if (options->avatarBorders && options->avatarPNGBorders) {
HBRUSH hbr = CreateSolidBrush(fonts.clAvatarBorder);
bmp->saveAlpha(x, y, w, h);
FrameRgn(bmp->getDC(), rgn, hbr, 1, 1);
diff --git a/plugins/Popup/src/avatars_simple.cpp b/plugins/Popup/src/avatars_simple.cpp index ab5edadbf6..22e603db3d 100644 --- a/plugins/Popup/src/avatars_simple.cpp +++ b/plugins/Popup/src/avatars_simple.cpp @@ -23,14 +23,13 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "headers.h"
-SimpleAvatar::SimpleAvatar(HANDLE h, bool bUseBitmap) :
-PopupAvatar()
+SimpleAvatar::SimpleAvatar(HANDLE h, bool bUseBitmap)
+ : PopupAvatar()
{
bIsAnimated = false;
bIsValid = true;
- if (bUseBitmap)
- {
+ if (bUseBitmap) {
BITMAP bmp;
GetObject((HBITMAP)h, sizeof(bmp), &bmp);
width = abs(bmp.bmWidth);
@@ -45,14 +44,11 @@ PopupAvatar() return;
}
- if (h && ServiceExists(MS_AV_GETAVATARBITMAP))
- {
+ if (h && ServiceExists(MS_AV_GETAVATARBITMAP)) {
avNeedFree = false;
av = (avatarCacheEntry *)CallService(MS_AV_GETAVATARBITMAP, (WPARAM)h, 0);
- if (av)
- {
- if (av->hbmPic && (av->dwFlags&AVS_BITMAP_VALID) && !(av->dwFlags&AVS_HIDEONCLIST) && !(av->dwFlags&AVS_NOTREADY))
- {
+ if (av) {
+ if (av->hbmPic && (av->dwFlags&AVS_BITMAP_VALID) && !(av->dwFlags&AVS_HIDEONCLIST) && !(av->dwFlags&AVS_NOTREADY)) {
width = av->bmWidth;
height = av->bmHeight;
return;
@@ -83,13 +79,11 @@ void SimpleAvatar::draw(MyBitmap *bmp, int x, int y, int w, int h, POPUPOPTIONS if (!av) return;
HRGN rgn;
- if (options->avatarRadius)
- {
+ if (options->avatarRadius) {
rgn = CreateRoundRectRgn(x, y, x + w, y + h, 2 * options->avatarRadius, 2 * options->avatarRadius);
SelectClipRgn(bmp->getDC(), rgn);
}
- else
- {
+ else {
rgn = CreateRectRgn(x, y, x + w, y + h);
}
@@ -98,8 +92,7 @@ void SimpleAvatar::draw(MyBitmap *bmp, int x, int y, int w, int h, POPUPOPTIONS SetStretchBltMode(bmp->getDC(), HALFTONE);
- if (av->dwFlags & AVS_HASTRANSPARENCY)
- {
+ if (av->dwFlags & AVS_HASTRANSPARENCY) {
BLENDFUNCTION bf;
bf.BlendOp = AC_SRC_OVER;
bf.BlendFlags = 0;
@@ -107,8 +100,7 @@ void SimpleAvatar::draw(MyBitmap *bmp, int x, int y, int w, int h, POPUPOPTIONS bf.AlphaFormat = AC_SRC_ALPHA;
AlphaBlend(bmp->getDC(), x, y, w, h, hdcTmp, 0, 0, av->bmWidth, av->bmHeight, bf);
- if (options->avatarBorders && options->avatarPNGBorders)
- {
+ if (options->avatarBorders && options->avatarPNGBorders) {
HBRUSH hbr = CreateSolidBrush(fonts.clAvatarBorder);
bmp->saveAlpha(x, y, w, h);
FrameRgn(bmp->getDC(), rgn, hbr, 1, 1);
@@ -119,7 +111,7 @@ void SimpleAvatar::draw(MyBitmap *bmp, int x, int y, int w, int h, POPUPOPTIONS else {
bmp->saveAlpha(x, y, w, h);
StretchBlt(bmp->getDC(), x, y, w, h, hdcTmp, 0, 0, av->bmWidth, av->bmHeight, SRCCOPY);
- if (options->avatarBorders){
+ if (options->avatarBorders) {
HBRUSH hbr = CreateSolidBrush(fonts.clAvatarBorder);
FrameRgn(bmp->getDC(), rgn, hbr, 1, 1);
DeleteObject(hbr);
diff --git a/plugins/Popup/src/bitmap_funcs.cpp b/plugins/Popup/src/bitmap_funcs.cpp index 52e341dff5..15b51a5998 100644 --- a/plugins/Popup/src/bitmap_funcs.cpp +++ b/plugins/Popup/src/bitmap_funcs.cpp @@ -55,14 +55,14 @@ MyBitmap::MyBitmap(int w, int h) allocate(w, h);
}
-MyBitmap::MyBitmap(const TCHAR *fn, const TCHAR *fnAlpha)
+MyBitmap::MyBitmap(const TCHAR *fn)
{
dcBmp = 0;
hBmp = 0;
bits = 0;
width = height = 0;
bitsSave = 0;
- loadFromFile(fn, fnAlpha);
+ loadFromFile(fn);
}
MyBitmap::~MyBitmap()
@@ -720,78 +720,18 @@ bool MyBitmap::loadFromFile_gradient(const TCHAR *fn) return true;
}
-bool MyBitmap::loadFromFile_png(const TCHAR *fn)
+bool MyBitmap::loadFromFile(const TCHAR *fn)
{
- if (!ServiceExists(MS_PNG2DIB))
- return false;
-
- HANDLE hFile, hMap = 0;
- BYTE *ppMap = 0;
- long cbFileSize = 0;
- BITMAPINFOHEADER *pDib = 0;
- BYTE *pDibBits = 0;
- if ((hFile = CreateFile(fn, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL)) != INVALID_HANDLE_VALUE)
- if ((hMap = CreateFileMapping(hFile, NULL, PAGE_READONLY, 0, 0, NULL)) != NULL)
- if ((ppMap = (BYTE*)MapViewOfFile(hMap, FILE_MAP_READ, 0, 0, 0)) != NULL)
- cbFileSize = GetFileSize(hFile, NULL);
- if (cbFileSize) {
- PNG2DIB param;
- param.pSource = ppMap;
- param.cbSourceSize = cbFileSize;
- param.pResult = &pDib;
- if (CallService(MS_PNG2DIB, 0, (LPARAM)¶m))
- pDibBits = (BYTE*)(pDib + 1);
- else
- cbFileSize = 0;
- }
-
- if (ppMap) UnmapViewOfFile(ppMap);
- if (hMap) CloseHandle(hMap);
- if (hFile) CloseHandle(hFile);
-
- if (!cbFileSize) return false;
-
- BITMAPINFO *bi = (BITMAPINFO*)pDib;
- BYTE *pt = (BYTE*)bi;
- pt += bi->bmiHeader.biSize;
-
- if (bi->bmiHeader.biBitCount != 32) {
- allocate(abs(bi->bmiHeader.biWidth), abs(bi->bmiHeader.biHeight));
- HDC hdcTmp = CreateCompatibleDC(getDC());
- HBITMAP hBitmap = CreateDIBitmap(getDC(), pDib, CBM_INIT, pDibBits, bi, DIB_PAL_COLORS);
- HBITMAP hOldBmp = (HBITMAP)SelectObject(hdcTmp, hBitmap);
- BitBlt(this->getDC(), 0, 0, abs(bi->bmiHeader.biWidth), abs(bi->bmiHeader.biHeight), hdcTmp, 0, 0, SRCCOPY);
- this->makeOpaque();
- SelectObject(hdcTmp, hOldBmp);
- DeleteDC(hdcTmp);
- DeleteObject(hBitmap);
- }
- else {
- allocate(abs(bi->bmiHeader.biWidth), abs(bi->bmiHeader.biHeight));
- BYTE *p2 = (BYTE *)pt;
- for (int y = 0; y < bi->bmiHeader.biHeight; ++y) {
- BYTE *p1 = (BYTE *)bits + (bi->bmiHeader.biHeight - y - 1)*bi->bmiHeader.biWidth * 4;
- for (int x = 0; x < bi->bmiHeader.biWidth; ++x) {
- p1[0] = p2[0];
- p1[1] = p2[1];
- p1[2] = p2[2];
- p1[3] = p2[3];
- p1 += 4;
- p2 += 4;
- }
- }
+ if (bits) freemem();
- premultipleChannels();
- }
+ if (!_tcsncmp(fn, _T("pixel:"), mir_tstrlen(_T("pixel:"))))
+ return loadFromFile_pixel(fn);
- GlobalFree(pDib);
- return true;
-}
+ if (!_tcsncmp(fn, _T("gradient:"), mir_tstrlen(_T("gradient:"))))
+ return loadFromFile_gradient(fn);
-bool MyBitmap::loadFromFile_default(const TCHAR *fn, const TCHAR *fnAlpha)
-{
SIZE sz;
- HBITMAP hBmpLoaded = (HBITMAP)LoadImage(NULL, fn, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
+ HBITMAP hBmpLoaded = (HBITMAP)CallService(MS_IMG_LOAD, (WPARAM)fn, IMGL_TCHAR);
if (!hBmpLoaded)
return false;
@@ -809,36 +749,14 @@ bool MyBitmap::loadFromFile_default(const TCHAR *fn, const TCHAR *fnAlpha) DeleteDC(dcTmp);
MyBitmap alpha;
- if (fnAlpha && alpha.loadFromFile(fnAlpha) &&
- (alpha.getWidth() == width) &&
- (alpha.getHeight() == height)) {
- for (int i = 0; i < width*height; i++)
- bits[i] = (bits[i] & 0x00ffffff) | ((alpha.bits[i] & 0x000000ff) << 24);
+ if (bm.bmBitsPixel == 32)
premultipleChannels();
- }
- else makeOpaque();
+ else
+ makeOpaque();
return true;
}
-bool MyBitmap::loadFromFile(const TCHAR *fn, const TCHAR *fnAlpha)
-{
- if (bits) freemem();
-
- if (!_tcsncmp(fn, _T("pixel:"), mir_tstrlen(_T("pixel:"))))
- return loadFromFile_pixel(fn);
-
- if (!_tcsncmp(fn, _T("gradient:"), mir_tstrlen(_T("gradient:"))))
- return loadFromFile_gradient(fn);
-
- TCHAR ext[5];
- mir_tstrncpy(ext, fn + (mir_tstrlen(fn) - 4), SIZEOF(ext));
- if (!mir_tstrcmpi(ext, _T(".png")))
- return loadFromFile_png(fn);
-
- return loadFromFile_default(fn, fnAlpha);
-}
-
void MyBitmap::allocate(int w, int h)
{
width = w;
diff --git a/plugins/Popup/src/bitmap_funcs.h b/plugins/Popup/src/bitmap_funcs.h index 6840e8f89e..64150200ee 100644 --- a/plugins/Popup/src/bitmap_funcs.h +++ b/plugins/Popup/src/bitmap_funcs.h @@ -45,18 +45,16 @@ private: bool loadFromFile_pixel(const TCHAR *fn);
bool loadFromFile_gradient(const TCHAR *fn);
- bool loadFromFile_png(const TCHAR *fn);
- bool loadFromFile_default(const TCHAR *fn, const TCHAR *fnAlpha = 0);
void premultipleChannels();
public:
MyBitmap();
MyBitmap(int w, int h);
- MyBitmap(const TCHAR *fn, const TCHAR *fnAlpha = 0);
+ MyBitmap(const TCHAR *fn);
~MyBitmap();
void allocate(int w, int h);
- bool loadFromFile(const TCHAR *fn, const TCHAR *fnAlpha = 0);
+ bool loadFromFile(const TCHAR *fn);
int getWidth() { return width; }
int getHeight() { return height; }
diff --git a/plugins/Popup/src/config.cpp b/plugins/Popup/src/config.cpp index b0f7004aec..0139fcbbdd 100644 --- a/plugins/Popup/src/config.cpp +++ b/plugins/Popup/src/config.cpp @@ -68,14 +68,15 @@ HRESULT(WINAPI *MyDwmEnableBlurBehindWindow)(HWND hWnd, DWM_BLURBEHIND *pBlurBeh // ====== Common Vars ========================
// common funcs
-void LoadOptions() {
+void LoadOptions()
+{
memset(&PopupOptions, 0, sizeof(PopupOptions));
#if defined(_DEBUG)
PopupOptions.debug = db_get_b(NULL, MODULNAME, "debug", FALSE);
#endif
// Load Popup Options
- if (!OptionLoaded){
+ if (!OptionLoaded) {
LoadOption_General();
LoadOption_Skins();
LoadOption_Actions();
diff --git a/plugins/Popup/src/effects.cpp b/plugins/Popup/src/effects.cpp index 88b680a009..c0c6763ab3 100644 --- a/plugins/Popup/src/effects.cpp +++ b/plugins/Popup/src/effects.cpp @@ -50,24 +50,20 @@ public: this->frame = frame;
stage = (frame * 2 > frameCount) ? 1 : 0;
if (stage == 0)
- {
alpha = alpha0 + (alpha1 - alpha0) * frame * 2 / frameCount;
- }
else
- {
alpha = alpha0 + (alpha1 - alpha0) * (frame * 2 - frameCount) / frameCount;
- }
}
virtual int getPixelAlpha(int x, int y)
{
- if (stage == 0)
- {
- if ((x / 16 + y / 16) % 2) return alpha0;
+ if (stage == 0) {
+ if ((x / 16 + y / 16) % 2)
+ return alpha0;
return alpha;
}
- else
- {
- if ((x / 16 + y / 16) % 2) return alpha;
+ else {
+ if ((x / 16 + y / 16) % 2)
+ return alpha;
return alpha1;
}
}
diff --git a/plugins/Popup/src/font.cpp b/plugins/Popup/src/font.cpp index 5af5172e00..1b3ff5583f 100644 --- a/plugins/Popup/src/font.cpp +++ b/plugins/Popup/src/font.cpp @@ -25,7 +25,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. PopupFonts fonts = { 0 };
-void InitFonts() {
+void InitFonts()
+{
// Fonts
FontIDT fid = { 0 };
fid.cbSize = sizeof(FontIDT);
diff --git a/plugins/Popup/src/formula.cpp b/plugins/Popup/src/formula.cpp index cbd59163fd..2448fbb1fd 100644 --- a/plugins/Popup/src/formula.cpp +++ b/plugins/Popup/src/formula.cpp @@ -31,30 +31,21 @@ static inline bool myisspace(char ch) int Formula::eval_neq(TCHAR *&s, Args *args, bool *vars) const
{
int left = eval_sum(s, args, vars);
- while (*s)
- {
- if (myisspace(*s))
- {
+ while (*s) {
+ if (myisspace(*s)) {
++s;
}
- else
- if (*s == '<')
- {
- // this is needed due to side effects caused by min() macro...
- int tmp = eval_sum(++s, args, vars);
- left = min(left, tmp);
- }
- else
- if (*s == '>')
- {
- // this is needed due to side effects caused by max() macro...
- int tmp = eval_sum(++s, args, vars);
- left = max(left, tmp);
- }
- else
- {
- break;
- }
+ else if (*s == '<') {
+ // this is needed due to side effects caused by min() macro...
+ int tmp = eval_sum(++s, args, vars);
+ left = min(left, tmp);
+ }
+ else if (*s == '>') {
+ // this is needed due to side effects caused by max() macro...
+ int tmp = eval_sum(++s, args, vars);
+ left = max(left, tmp);
+ }
+ else break;
}
return left;
}
@@ -62,26 +53,17 @@ int Formula::eval_neq(TCHAR *&s, Args *args, bool *vars) const int Formula::eval_sum(TCHAR *&s, Args *args, bool *vars) const
{
int left = eval_mul(s, args, vars);
- while (*s)
- {
- if (myisspace(*s))
- {
+ while (*s) {
+ if (myisspace(*s)) {
++s;
}
- else
- if (*s == '+')
- {
- left += eval_mul(++s, args, vars);
- }
- else
- if (*s == '-')
- {
- left -= eval_mul(++s, args, vars);
- }
- else
- {
- break;
- }
+ else if (*s == '+') {
+ left += eval_mul(++s, args, vars);
+ }
+ else if (*s == '-') {
+ left -= eval_mul(++s, args, vars);
+ }
+ else break;
}
return left;
}
@@ -89,87 +71,65 @@ int Formula::eval_sum(TCHAR *&s, Args *args, bool *vars) const int Formula::eval_mul(TCHAR *&s, Args *args, bool *vars) const
{
int left = eval_atom(s, args, vars);
- while (*s)
- {
- if (myisspace(*s))
- {
+ while (*s) {
+ if (myisspace(*s)) {
++s;
}
- else
- if (*s == '*')
- {
- left *= eval_atom(++s, args, vars);
- }
- else
- if (*s == '/')
- {
- if (int right = eval_atom(++s, args, vars))
- left /= right;
- }
- else
- if (*s == '%')
- {
- if (int right = eval_atom(++s, args, vars))
- left %= right;
- }
- else
- {
- break;
- }
+ else if (*s == '*') {
+ left *= eval_atom(++s, args, vars);
+ }
+ else if (*s == '/') {
+ if (int right = eval_atom(++s, args, vars))
+ left /= right;
+ }
+ else if (*s == '%') {
+ if (int right = eval_atom(++s, args, vars))
+ left %= right;
+ }
+ else break;
}
return left;
}
int Formula::eval_atom(TCHAR *&s, Args *args, bool *vars) const
{
- while (*s)
- {
- if (myisspace(*s))
- {
+ while (*s) {
+ if (myisspace(*s)) {
++s;
}
- else
- if (*s == '(')
- {
- int res = eval_neq(++s, args, vars);
- if (*s == ')')
- ++s;
- return res;
- }
- else
- if ((*s == '+') || (*s == '-'))
- {
- int sign = 1;
- if (*s == '-')
- sign = -1;
- return sign * eval_neq(++s, args, vars);
- }
- else
- if (*s == '!')
- {
- return !eval_neq(++s, args, vars);
- }
- else
- if ((*s >= '0') && (*s <= '9'))
- {
- int res = 0;
- while ((*s >= '0') && (*s <= '9'))
- res = res * 10 + *s++ - '0';
- return res;
- }
- else
- {
- if (!args)
- return 0;
- char buf[1024];
- char *bufptr = buf;
- while (((*s >= '0') && (*s <= '9')) || ((*s >= 'a') && (*s <= 'z')) || ((*s >= 'A') && (*s <= 'A')) || (*s == '_') || (*s == '.'))
- *bufptr++ = *s++;
- *bufptr = 0;
- int res = args->get(buf);
- if (vars) *vars = true;
- return res;
- }
+ else if (*s == '(') {
+ int res = eval_neq(++s, args, vars);
+ if (*s == ')')
+ ++s;
+ return res;
+ }
+ else if ((*s == '+') || (*s == '-')) {
+ int sign = 1;
+ if (*s == '-')
+ sign = -1;
+ return sign * eval_neq(++s, args, vars);
+ }
+ else if (*s == '!') {
+ return !eval_neq(++s, args, vars);
+ }
+ else if ((*s >= '0') && (*s <= '9')) {
+ int res = 0;
+ while ((*s >= '0') && (*s <= '9'))
+ res = res * 10 + *s++ - '0';
+ return res;
+ }
+ else {
+ if (!args)
+ return 0;
+ char buf[1024];
+ char *bufptr = buf;
+ while (((*s >= '0') && (*s <= '9')) || ((*s >= 'a') && (*s <= 'z')) || ((*s >= 'A') && (*s <= 'A')) || (*s == '_') || (*s == '.'))
+ *bufptr++ = *s++;
+ *bufptr = 0;
+ int res = args->get(buf);
+ if (vars) *vars = true;
+ return res;
+ }
}
return 0;
}
diff --git a/plugins/Popup/src/headers.h b/plugins/Popup/src/headers.h index 91935af8c6..ce6142318a 100644 --- a/plugins/Popup/src/headers.h +++ b/plugins/Popup/src/headers.h @@ -74,7 +74,6 @@ http://miranda-ng.org/distr/ #include <m_message.h>
#include <m_userinfo.h>
#include <m_addcontact.h>
-#include <m_png.h>
#include <m_clc.h>
#include <m_icolib.h>
#include <m_hotkeys.h>
@@ -83,6 +82,7 @@ http://miranda-ng.org/distr/ #include <m_extraicons.h>
#include <m_popup.h>
#include <m_string.h>
+#include <m_imgsrvc.h>
#include <m_metacontacts.h>
#include <m_folders.h>
diff --git a/plugins/Popup/src/history.cpp b/plugins/Popup/src/history.cpp index 4bdb947fb8..b2c2d0473b 100644 --- a/plugins/Popup/src/history.cpp +++ b/plugins/Popup/src/history.cpp @@ -124,100 +124,100 @@ static INT_PTR CALLBACK HistoryDlgProc(HWND hwnd, UINT msg, WPARAM, LPARAM lPara switch (msg) {
case WM_INITDIALOG:
- {
- oldWidth = 0;
- HWND hwndList = GetDlgItem(hwnd, IDC_POPUP_LIST);
- for (int i = 0; i < arPopupHistory.getCount(); ++i)
- ListBox_SetItemData(hwndList, ListBox_AddString(hwndList, _T("")), 0);
- SendMessage(hwnd, WM_SETICON, ICON_SMALL, (LPARAM)IcoLib_GetIcon(ICO_HISTORY, 0));
- SendMessage(hwnd, WM_SETICON, ICON_BIG, (LPARAM)IcoLib_GetIcon(ICO_HISTORY, 1));
-
- if (gbHppInstalled && PopupOptions.UseHppHistoryLog) {
- logType = LOG_HPP;
- ShowWindow(GetDlgItem(hwnd, IDC_POPUP_LIST), SW_HIDE);
-
- IEVIEWWINDOW ieWindow;
- ieWindow.cbSize = sizeof(IEVIEWWINDOW);
- ieWindow.iType = IEW_CREATE;
- ieWindow.dwFlags = 0;
- ieWindow.dwMode = IEWM_MUCC;
- ieWindow.parent = hwnd;
- ieWindow.x = 0;
- ieWindow.y = 0;
- ieWindow.cx = 100;
- ieWindow.cy = 100;
- CallService(MS_HPP_EG_WINDOW, 0, (LPARAM)&ieWindow);
- hwndLog = ieWindow.hwnd;
- ShowWindow(hwndLog, SW_SHOW);
-
- RECT rcLst; GetWindowRect(hwndList, &rcLst);
- POINT pt;
- pt.x = rcLst.left;
- pt.y = rcLst.top;
- ScreenToClient(hwnd, &pt);
-
- ieWindow.cbSize = sizeof(IEVIEWWINDOW);
- ieWindow.iType = IEW_SETPOS;
- ieWindow.parent = hwnd;
- ieWindow.hwnd = hwndLog;
- ieWindow.x = pt.x;
- ieWindow.y = pt.y;
- ieWindow.cx = rcLst.right - rcLst.left;
- ieWindow.cy = rcLst.bottom - rcLst.top;
- CallService(MS_HPP_EG_WINDOW, 0, (LPARAM)&ieWindow);
-
- IEVIEWEVENTDATA ieData;
-
- IEVIEWEVENT ieEvent;
- ieEvent.cbSize = sizeof(ieEvent);
- ieEvent.iType = IEE_LOG_MEM_EVENTS;
- ieEvent.dwFlags = 0;
- ieEvent.hwnd = hwndLog;
- ieEvent.eventData = &ieData;
- ieEvent.count = 1;
- ieEvent.codepage = 0;
- ieEvent.pszProto = NULL;
-
- for (int i = 0; i < arPopupHistory.getCount(); ++i) {
- POPUPDATA2* ppd = arPopupHistory[i];
- ieData.cbSize = sizeof(ieData);
- ieData.iType = IEED_EVENT_SYSTEM;
- ieData.dwFlags = 0;
- ieData.color = ppd->colorText;
- if (ppd->flags & PU2_UNICODE) {
- ieData.dwFlags |= IEEDF_UNICODE_TEXT | IEEDF_UNICODE_NICK;
- ieData.pszNickW = ppd->lptzTitle;
- ieData.pszTextW = ppd->lptzText;
- ieData.pszText2W = NULL;
- }
- else {
- ieData.dwFlags |= 0;
- ieData.pszNick = ppd->lpzTitle;
- ieData.pszText = ppd->lpzText;
- ieData.pszText2 = NULL;
+ {
+ oldWidth = 0;
+ HWND hwndList = GetDlgItem(hwnd, IDC_POPUP_LIST);
+ for (int i = 0; i < arPopupHistory.getCount(); ++i)
+ ListBox_SetItemData(hwndList, ListBox_AddString(hwndList, _T("")), 0);
+ SendMessage(hwnd, WM_SETICON, ICON_SMALL, (LPARAM)IcoLib_GetIcon(ICO_HISTORY, 0));
+ SendMessage(hwnd, WM_SETICON, ICON_BIG, (LPARAM)IcoLib_GetIcon(ICO_HISTORY, 1));
+
+ if (gbHppInstalled && PopupOptions.UseHppHistoryLog) {
+ logType = LOG_HPP;
+ ShowWindow(GetDlgItem(hwnd, IDC_POPUP_LIST), SW_HIDE);
+
+ IEVIEWWINDOW ieWindow;
+ ieWindow.cbSize = sizeof(IEVIEWWINDOW);
+ ieWindow.iType = IEW_CREATE;
+ ieWindow.dwFlags = 0;
+ ieWindow.dwMode = IEWM_MUCC;
+ ieWindow.parent = hwnd;
+ ieWindow.x = 0;
+ ieWindow.y = 0;
+ ieWindow.cx = 100;
+ ieWindow.cy = 100;
+ CallService(MS_HPP_EG_WINDOW, 0, (LPARAM)&ieWindow);
+ hwndLog = ieWindow.hwnd;
+ ShowWindow(hwndLog, SW_SHOW);
+
+ RECT rcLst; GetWindowRect(hwndList, &rcLst);
+ POINT pt;
+ pt.x = rcLst.left;
+ pt.y = rcLst.top;
+ ScreenToClient(hwnd, &pt);
+
+ ieWindow.cbSize = sizeof(IEVIEWWINDOW);
+ ieWindow.iType = IEW_SETPOS;
+ ieWindow.parent = hwnd;
+ ieWindow.hwnd = hwndLog;
+ ieWindow.x = pt.x;
+ ieWindow.y = pt.y;
+ ieWindow.cx = rcLst.right - rcLst.left;
+ ieWindow.cy = rcLst.bottom - rcLst.top;
+ CallService(MS_HPP_EG_WINDOW, 0, (LPARAM)&ieWindow);
+
+ IEVIEWEVENTDATA ieData;
+
+ IEVIEWEVENT ieEvent;
+ ieEvent.cbSize = sizeof(ieEvent);
+ ieEvent.iType = IEE_LOG_MEM_EVENTS;
+ ieEvent.dwFlags = 0;
+ ieEvent.hwnd = hwndLog;
+ ieEvent.eventData = &ieData;
+ ieEvent.count = 1;
+ ieEvent.codepage = 0;
+ ieEvent.pszProto = NULL;
+
+ for (int i = 0; i < arPopupHistory.getCount(); ++i) {
+ POPUPDATA2* ppd = arPopupHistory[i];
+ ieData.cbSize = sizeof(ieData);
+ ieData.iType = IEED_EVENT_SYSTEM;
+ ieData.dwFlags = 0;
+ ieData.color = ppd->colorText;
+ if (ppd->flags & PU2_UNICODE) {
+ ieData.dwFlags |= IEEDF_UNICODE_TEXT | IEEDF_UNICODE_NICK;
+ ieData.pszNickW = ppd->lptzTitle;
+ ieData.pszTextW = ppd->lptzText;
+ ieData.pszText2W = NULL;
+ }
+ else {
+ ieData.dwFlags |= 0;
+ ieData.pszNick = ppd->lpzTitle;
+ ieData.pszText = ppd->lpzText;
+ ieData.pszText2 = NULL;
+ }
+ ieData.bIsMe = FALSE;
+ ieData.time = ppd->dwTimestamp;
+ ieData.dwData = 0;
+ ieData.next = NULL;
+ CallService(MS_HPP_EG_EVENT, 0, (WPARAM)&ieEvent);
}
- ieData.bIsMe = FALSE;
- ieData.time = ppd->dwTimestamp;
- ieData.dwData = 0;
- ieData.next = NULL;
- CallService(MS_HPP_EG_EVENT, 0, (WPARAM)&ieEvent);
}
- }
- else {
- logType = LOG_DEFAULT;
- hwndLog = hwndList;
+ else {
+ logType = LOG_DEFAULT;
+ hwndLog = hwndList;
- ShowWindow(hwndLog, SW_SHOW);
- }
+ ShowWindow(hwndLog, SW_SHOW);
+ }
- Utils_RestoreWindowPosition(hwnd, NULL, MODULNAME, "popupHistory_");
+ Utils_RestoreWindowPosition(hwnd, NULL, MODULNAME, "popupHistory_");
- if (logType == LOG_DEFAULT) {
- SendMessage(hwnd, UM_RESIZELIST, 0, 0);
- ListBox_SetTopIndex(hwndLog, arPopupHistory.getCount() - 1);
+ if (logType == LOG_DEFAULT) {
+ SendMessage(hwnd, UM_RESIZELIST, 0, 0);
+ ListBox_SetTopIndex(hwndLog, arPopupHistory.getCount() - 1);
+ }
}
- }
- return TRUE;
+ return TRUE;
case WM_MEASUREITEM:
if (logType == LOG_DEFAULT) {
@@ -293,39 +293,40 @@ static INT_PTR CALLBACK HistoryDlgProc(HWND hwnd, UINT msg, WPARAM, LPARAM lPara return TRUE;
case WM_SIZE:
- {
- RECT rcLst; GetClientRect(hwnd, &rcLst);
- rcLst.left += 10;
- rcLst.top += 10;
- rcLst.right -= 10;
- rcLst.bottom -= 10;
- if (logType == LOG_HPP) {
- SetWindowPos(hwndLog, NULL,
- rcLst.left, rcLst.top, rcLst.right - rcLst.left, rcLst.bottom - rcLst.top,
- SWP_NOZORDER | SWP_DEFERERASE | SWP_SHOWWINDOW);
-
- IEVIEWWINDOW ieWindow;
- ieWindow.cbSize = sizeof(IEVIEWWINDOW);
- ieWindow.iType = IEW_SETPOS;
- ieWindow.parent = hwnd;
- ieWindow.hwnd = hwndLog;
- ieWindow.x = rcLst.left;
- ieWindow.y = rcLst.top;
- ieWindow.cx = rcLst.right - rcLst.left;
- ieWindow.cy = rcLst.bottom - rcLst.top;
- CallService(MS_HPP_EG_WINDOW, 0, (LPARAM)&ieWindow);
- }
- else if (logType == LOG_DEFAULT) {
- SetWindowPos(hwndLog, NULL,
- rcLst.left, rcLst.top, rcLst.right - rcLst.left, rcLst.bottom - rcLst.top,
- SWP_NOZORDER | SWP_DEFERERASE | SWP_SHOWWINDOW);
- if (rcLst.right - rcLst.left != oldWidth) {
- oldWidth = rcLst.right - rcLst.left;
- PostMessage(hwnd, UM_RESIZELIST, 0, 0);
+ {
+ RECT rcLst;
+ GetClientRect(hwnd, &rcLst);
+ rcLst.left += 10;
+ rcLst.top += 10;
+ rcLst.right -= 10;
+ rcLst.bottom -= 10;
+ if (logType == LOG_HPP) {
+ SetWindowPos(hwndLog, NULL,
+ rcLst.left, rcLst.top, rcLst.right - rcLst.left, rcLst.bottom - rcLst.top,
+ SWP_NOZORDER | SWP_DEFERERASE | SWP_SHOWWINDOW);
+
+ IEVIEWWINDOW ieWindow;
+ ieWindow.cbSize = sizeof(IEVIEWWINDOW);
+ ieWindow.iType = IEW_SETPOS;
+ ieWindow.parent = hwnd;
+ ieWindow.hwnd = hwndLog;
+ ieWindow.x = rcLst.left;
+ ieWindow.y = rcLst.top;
+ ieWindow.cx = rcLst.right - rcLst.left;
+ ieWindow.cy = rcLst.bottom - rcLst.top;
+ CallService(MS_HPP_EG_WINDOW, 0, (LPARAM)&ieWindow);
+ }
+ else if (logType == LOG_DEFAULT) {
+ SetWindowPos(hwndLog, NULL,
+ rcLst.left, rcLst.top, rcLst.right - rcLst.left, rcLst.bottom - rcLst.top,
+ SWP_NOZORDER | SWP_DEFERERASE | SWP_SHOWWINDOW);
+ if (rcLst.right - rcLst.left != oldWidth) {
+ oldWidth = rcLst.right - rcLst.left;
+ PostMessage(hwnd, UM_RESIZELIST, 0, 0);
+ }
}
}
- }
- return TRUE;
+ return TRUE;
case UM_RESIZELIST:
if (logType == LOG_DEFAULT) {
diff --git a/plugins/Popup/src/icons.cpp b/plugins/Popup/src/icons.cpp index 6775f971d6..321e62d569 100644 --- a/plugins/Popup/src/icons.cpp +++ b/plugins/Popup/src/icons.cpp @@ -29,14 +29,14 @@ static IconItem iconList[] = { LPGEN("Popups are enabled"), ICO_TB_POPUP_ON, IDI_POPUP },
{ LPGEN("Popups are disabled"), ICO_TB_POPUP_OFF, IDI_NOPOPUP },
- // common popup
+ // common popup
{ LPGEN("Popups are enabled"), ICO_POPUP_ON, IDI_POPUP },
{ LPGEN("Popups are disabled"), ICO_POPUP_OFF, IDI_NOPOPUP },
{ LPGEN("With \"favorite\" overlay"), ICO_FAV, IDI_PU_FAVOURITE },
{ LPGEN("With \"fullscreen\" overlay"), ICO_FULLSCREEN, IDI_PU_FULLSCREEN },
{ LPGEN("Popup History"), ICO_HISTORY, IDI_HISTORY },
- // option
+ // option
{ LPGEN("Refresh skin list"), ICO_OPT_RELOAD, IDI_RELOAD },
{ LPGEN("Popup placement"), ICO_OPT_RESIZE, IDI_RESIZE },
{ LPGEN("OK"), ICO_OPT_OK, IDI_ACT_OK },
@@ -47,7 +47,7 @@ static IconItem iconList[] = { LPGEN("Show in fullscreen"), ICO_OPT_FULLSCREEN, IDI_OPT_FULLSCREEN },
{ LPGEN("Blocked contact"), ICO_OPT_BLOCK, IDI_OPT_BLOCK },
- // action
+ // action
{ LPGEN("Quick reply"), ICO_ACT_REPLY, IDI_ACT_REPLY },
{ LPGEN("Pin popup"), ICO_ACT_PIN, IDI_ACT_PIN },
{ LPGEN("Pinned popup"), ICO_ACT_PINNED, IDI_ACT_PINNED },
@@ -57,7 +57,6 @@ static IconItem iconList[] = { LPGEN("Add contact permanently"), ICO_ACT_ADD, IDI_ACT_ADD },
{ LPGEN("Dismiss popup"), ICO_ACT_CLOSE, IDI_ACT_CLOSE },
{ LPGEN("Copy to clipboard"), ICO_ACT_COPY, IDI_ACT_COPY }
-
};
/**
diff --git a/plugins/Popup/src/notifications.cpp b/plugins/Popup/src/notifications.cpp index 58d0461124..b5a9740f46 100644 --- a/plugins/Popup/src/notifications.cpp +++ b/plugins/Popup/src/notifications.cpp @@ -27,13 +27,11 @@ HANDLE g_hntfError, g_hntfWarning, g_hntfNotification; #define PopupNotificationData_SIGNATURE 0x11BEDA1A
-
int TreeDataSortFunc(const POPUPTREEDATA *p1, const POPUPTREEDATA *p2)
{
if (int cmp = mir_tstrcmp(p1->pszTreeRoot, p2->pszTreeRoot))
return cmp;
return mir_tstrcmp(p1->pszDescription, p2->pszDescription);
-
}
LIST<POPUPTREEDATA> gTreeData(20, TreeDataSortFunc);
@@ -229,12 +227,8 @@ HANDLE FindTreeData(LPTSTR group, LPTSTR name, BYTE typ) {
for (int i = 0; i < gTreeData.getCount(); i++) {
POPUPTREEDATA *p = gTreeData[i];
- if (p->typ == typ &&
- (!group || (mir_tstrcmp(p->pszTreeRoot, group) == 0)) &&
- (!name || (mir_tstrcmp(p->pszDescription, name) == 0)))
- {
+ if (p->typ == typ && (!group || (mir_tstrcmp(p->pszTreeRoot, group) == 0)) && (!name || (mir_tstrcmp(p->pszDescription, name) == 0)))
return p;
- }
}
return NULL;
}
@@ -251,14 +245,14 @@ void FillNotificationData(POPUPDATA2 *ppd, DWORD *disableWhen) ppd->iSeconds = ptd->timeoutValue;
*disableWhen = ptd->enabled ? ptd->disableWhen : 0xFFFFFFFF;
- LOGFONTA lf; // dummy to make FS happy (use LOGFONTA coz we use MS_FONT_GET)
- FontID fontid = { 0 }; // use ansi version of fontID coz POPUPNOTIFICATION use char
+ LOGFONTA lf; // dummy to make FS happy (use LOGFONTA coz we use MS_FONT_GET)
+ FontID fontid = { 0 }; // use ansi version of fontID coz POPUPNOTIFICATION use char
fontid.cbSize = sizeof(fontid);
mir_snprintf(fontid.group, SIZEOF(fontid.group), PU_FNT_AND_COLOR"/%s", ptd->notification.lpzGroup);
mir_snprintf(fontid.name, SIZEOF(fontid.name), "%s (colors only)", ptd->notification.lpzName);
ppd->colorText = (COLORREF)CallService(MS_FONT_GET, (WPARAM)&fontid, (LPARAM)&lf);
- ColourID colourid = { 0 }; // use ansi version of ColourID coz POPUPNOTIFICATION use char
+ ColourID colourid = { 0 }; // use ansi version of ColourID coz POPUPNOTIFICATION use char
colourid.cbSize = sizeof(colourid);
mir_snprintf(colourid.group, SIZEOF(colourid.group), PU_FNT_AND_COLOR"/%s", ptd->notification.lpzGroup);
mir_snprintf(colourid.name, SIZEOF(colourid.name), "%s (colors only)", ptd->notification.lpzName);
@@ -274,8 +268,7 @@ bool IsValidNotification(HANDLE hNotification) if (!hNotification) return false;
bool res = false;
- __try
- {
+ __try {
if (((POPUPTREEDATA *)hNotification)->signature == PopupNotificationData_SIGNATURE)
res = true;
}
@@ -293,8 +286,7 @@ bool PerformAction(HANDLE hNotification, HWND hwnd, UINT message, WPARAM wparam, POPUPTREEDATA *ptd = (POPUPTREEDATA *)hNotification;
char *lpzAction = NULL;
- switch (message)
- {
+ switch (message) {
case WM_LBUTTONUP:
case WM_COMMAND:
lpzAction = ptd->leftAction;
@@ -312,14 +304,12 @@ bool PerformAction(HANDLE hNotification, HWND hwnd, UINT message, WPARAM wparam, if (!mir_strcmp(lpzAction, POPUP_ACTION_NOTHING))
return true;
- if (!mir_strcmp(lpzAction, POPUP_ACTION_DISMISS))
- {
+ if (!mir_strcmp(lpzAction, POPUP_ACTION_DISMISS)) {
PUDeletePopup(hwnd);
return true;
}
- for (int i = 0; i < ptd->notification.actionCount; ++i)
- {
+ for (int i = 0; i < ptd->notification.actionCount; ++i) {
if (!(ptd->notification.lpActions[i].dwFlags&PNAF_CALLBACK))
continue;
if (mir_strcmp(ptd->notification.lpActions[i].lpzTitle, lpzAction))
diff --git a/plugins/Popup/src/opt_skins.cpp b/plugins/Popup/src/opt_skins.cpp index c4bfb60fba..52ac9b6ddc 100644 --- a/plugins/Popup/src/opt_skins.cpp +++ b/plugins/Popup/src/opt_skins.cpp @@ -349,127 +349,121 @@ INT_PTR CALLBACK DlgProcPopSkinsOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR switch (msg) {
case WM_INITDIALOG:
- {
- HWND hCtrl = NULL;
- DWORD dwIndex = 0;
-
- // Skin List
- hCtrl = GetDlgItem(hwndDlg, IDC_SKINLIST);
- ListBox_ResetContent(hCtrl);
- for (const Skins::SKINLIST *sl = skins.getSkinList(); sl; sl = sl->next)
{
- dwIndex = ListBox_AddString(hCtrl, sl->name);
- ListBox_SetItemData(hCtrl, dwIndex, sl->name);
- }
- ListBox_SetCurSel(hCtrl, ListBox_FindString(hCtrl, 0, PopupOptions.SkinPack));
+ // Skin List
+ HWND hCtrl = GetDlgItem(hwndDlg, IDC_SKINLIST);
+ ListBox_ResetContent(hCtrl);
+ for (const Skins::SKINLIST *sl = skins.getSkinList(); sl; sl = sl->next) {
+ DWORD dwIndex = ListBox_AddString(hCtrl, sl->name);
+ ListBox_SetItemData(hCtrl, dwIndex, sl->name);
+ }
+ ListBox_SetCurSel(hCtrl, ListBox_FindString(hCtrl, 0, PopupOptions.SkinPack));
- // Skin List reload button
- SendDlgItemMessage(hwndDlg, IDC_BTN_RELOAD, BUTTONSETASFLATBTN, TRUE, 0);
- SendDlgItemMessage(hwndDlg, IDC_BTN_RELOAD, BM_SETIMAGE, IMAGE_ICON, (LPARAM)IcoLib_GetIcon(ICO_OPT_RELOAD, 0));
- SendDlgItemMessage(hwndDlg, IDC_BTN_RELOAD, BUTTONADDTOOLTIP, (WPARAM)Translate("Refresh List"), 0);
+ // Skin List reload button
+ SendDlgItemMessage(hwndDlg, IDC_BTN_RELOAD, BUTTONSETASFLATBTN, TRUE, 0);
+ SendDlgItemMessage(hwndDlg, IDC_BTN_RELOAD, BM_SETIMAGE, IMAGE_ICON, (LPARAM)IcoLib_GetIcon(ICO_OPT_RELOAD, 0));
+ SendDlgItemMessage(hwndDlg, IDC_BTN_RELOAD, BUTTONADDTOOLTIP, (WPARAM)Translate("Refresh List"), 0);
- // Skin Option List
- SkinOptionList_Update(skinOptions, &skinOptionsCount, hwndDlg);
+ // Skin Option List
+ SkinOptionList_Update(skinOptions, &skinOptionsCount, hwndDlg);
- // PreviewBox
- mir_subclassWindow(GetDlgItem(hwndDlg, IDC_PREVIEWBOX), WndProcPreviewBox);
- updatePreviewImage(GetDlgItem(hwndDlg, IDC_PREVIEWBOX));
+ // PreviewBox
+ mir_subclassWindow(GetDlgItem(hwndDlg, IDC_PREVIEWBOX), WndProcPreviewBox);
+ updatePreviewImage(GetDlgItem(hwndDlg, IDC_PREVIEWBOX));
- // hooks
- hhkFontsReload = HookEventMessage(ME_FONT_RELOAD, hwndDlg, WM_USER);
+ // hooks
+ hhkFontsReload = HookEventMessage(ME_FONT_RELOAD, hwndDlg, WM_USER);
- TranslateDialogDefault(hwndDlg);
- bDlgInit = true;
- }
- return TRUE;
+ TranslateDialogDefault(hwndDlg);
+ bDlgInit = true;
+ }
+ return TRUE;
case WM_USER:
updatePreviewImage(GetDlgItem(hwndDlg, IDC_PREVIEWBOX));
return TRUE;
case WM_COMMAND:
- {
- HWND hCtrl = NULL;
- UINT idCtrl = LOWORD(wParam);
- switch (HIWORD(wParam)) {
- case BN_KILLFOCUS: // Button controls
- case BN_SETFOCUS: // Button controls
- return TRUE;
- break;
- case BN_CLICKED: // Button controls
- switch (idCtrl) {
- case IDC_PREVIEW:
- PopupPreview();
- break;
-
- case IDC_BTN_RELOAD:
- {
- DWORD dwIndex = 0;
- TCHAR szNewSkin[128];
- LPTSTR pszOldSkin = mir_tstrdup(PopupOptions.SkinPack);
- skins.load();
- hCtrl = GetDlgItem(hwndDlg, IDC_SKINLIST);
- ListBox_ResetContent(hCtrl);
- for (const Skins::SKINLIST *sl = skins.getSkinList(); sl; sl = sl->next)
- {
- dwIndex = ListBox_AddString(hCtrl, sl->name);
- ListBox_SetItemData(hCtrl, dwIndex, sl->name);
- }
- ListBox_SetCurSel(hCtrl, ListBox_FindString(hCtrl, 0, PopupOptions.SkinPack));
- // make shure we have select skin (ListBox_SetCurSel may be fail)
- ListBox_GetText(hCtrl, ListBox_GetCurSel(hCtrl), &szNewSkin);
- if (mir_tstrcmp(pszOldSkin, szNewSkin) != 0) {
- mir_free(PopupOptions.SkinPack);
- PopupOptions.SkinPack = mir_tstrdup(szNewSkin);
- }
- mir_free(pszOldSkin);
+ {
+ HWND hCtrl = NULL;
+ UINT idCtrl = LOWORD(wParam);
+ switch (HIWORD(wParam)) {
+ case BN_KILLFOCUS: // Button controls
+ case BN_SETFOCUS: // Button controls
+ return TRUE;
- const PopupSkin *skin = 0;
- if (skin = skins.getSkin(PopupOptions.SkinPack)) {
- // update Skin Option List from reload SkinPack
- bDlgInit = false;
- bDlgInit = SkinOptionList_Update(skinOptions, &skinOptionsCount, hwndDlg);
- }
+ case BN_CLICKED: // Button controls
+ switch (idCtrl) {
+ case IDC_PREVIEW:
+ PopupPreview();
+ break;
- SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
- }// end IDC_BTN_RELOAD:
- break;
- case IDC_GETSKINS:
- CallService(MS_UTILS_OPENURL, 0, (LPARAM)"http://miranda-ng.org/addons/category/13");
- break;
- }// end switch(idCtrl)
- updatePreviewImage(GetDlgItem(hwndDlg, IDC_PREVIEWBOX));
- break;
- case CBN_SELCHANGE: // combo box controls
- switch (idCtrl) {
- case IDC_SKINLIST:
- {
- // Skin list change
- mir_free(PopupOptions.SkinPack);
- PopupOptions.SkinPack = mir_tstrdup((TCHAR *)SendDlgItemMessage(
- hwndDlg,
- IDC_SKINLIST,
- LB_GETITEMDATA,
- (WPARAM)SendDlgItemMessage(hwndDlg, IDC_SKINLIST, LB_GETCURSEL, 0, 0),
- 0));
- const PopupSkin *skin = 0;
- if (skin = skins.getSkin(PopupOptions.SkinPack)) {
- mir_free(PopupOptions.SkinPack);
- PopupOptions.SkinPack = mir_tstrdup(skin->getName());
+ case IDC_GETSKINS:
+ CallService(MS_UTILS_OPENURL, 0, (LPARAM)"http://miranda-ng.org/addons/category/13");
+ break;
- // update Skin Option List
- bDlgInit = false;
- bDlgInit = SkinOptionList_Update(skinOptions, &skinOptionsCount, hwndDlg);
+ case IDC_BTN_RELOAD:
+ LPTSTR pszOldSkin = NEWTSTR_ALLOCA(PopupOptions.SkinPack);
+ skins.load();
+ hCtrl = GetDlgItem(hwndDlg, IDC_SKINLIST);
+ ListBox_ResetContent(hCtrl);
+ for (const Skins::SKINLIST *sl = skins.getSkinList(); sl; sl = sl->next) {
+ DWORD dwIndex = ListBox_AddString(hCtrl, sl->name);
+ ListBox_SetItemData(hCtrl, dwIndex, sl->name);
+ }
+ ListBox_SetCurSel(hCtrl, ListBox_FindString(hCtrl, 0, PopupOptions.SkinPack));
+
+ // make shure we have select skin (ListBox_SetCurSel may be fail)
+ TCHAR szNewSkin[128];
+ ListBox_GetText(hCtrl, ListBox_GetCurSel(hCtrl), &szNewSkin);
+ if (mir_tstrcmp(pszOldSkin, szNewSkin) != 0) {
+ mir_free(PopupOptions.SkinPack);
+ PopupOptions.SkinPack = mir_tstrdup(szNewSkin);
+ }
+
+ const PopupSkin *skin = 0;
+ if (skin = skins.getSkin(PopupOptions.SkinPack)) {
+ // update Skin Option List from reload SkinPack
+ bDlgInit = false;
+ bDlgInit = SkinOptionList_Update(skinOptions, &skinOptionsCount, hwndDlg);
+ }
+
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
+ break;
}
updatePreviewImage(GetDlgItem(hwndDlg, IDC_PREVIEWBOX));
- }
- SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
- break;
- }// end switch(idCtrl)
+ break;
+
+ case CBN_SELCHANGE: // combo box controls
+ switch (idCtrl) {
+ case IDC_SKINLIST:
+ {
+ // Skin list change
+ mir_free(PopupOptions.SkinPack);
+ PopupOptions.SkinPack = mir_tstrdup((TCHAR *)SendDlgItemMessage(
+ hwndDlg,
+ IDC_SKINLIST,
+ LB_GETITEMDATA,
+ (WPARAM)SendDlgItemMessage(hwndDlg, IDC_SKINLIST, LB_GETCURSEL, 0, 0),
+ 0));
+ const PopupSkin *skin = 0;
+ if (skin = skins.getSkin(PopupOptions.SkinPack)) {
+ mir_free(PopupOptions.SkinPack);
+ PopupOptions.SkinPack = mir_tstrdup(skin->getName());
+
+ // update Skin Option List
+ bDlgInit = false;
+ bDlgInit = SkinOptionList_Update(skinOptions, &skinOptionsCount, hwndDlg);
+ }
+ updatePreviewImage(GetDlgItem(hwndDlg, IDC_PREVIEWBOX));
+ }
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
+ break;
+ }// end switch(idCtrl)
+ break;
+ }// end switch (HIWORD(wParam))
break;
- }// end switch (HIWORD(wParam))
- break;
- }// end WM_COMMAND
+ }// end WM_COMMAND
case WM_NOTIFY:
if (!bDlgInit) return FALSE;
@@ -481,22 +475,22 @@ INT_PTR CALLBACK DlgProcPopSkinsOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR return TRUE;
case PSN_APPLY:
- {
- // skin pack
- db_set_ts(NULL, MODULNAME, "SkinPack", PopupOptions.SkinPack);
- // skin options
- const PopupSkin *skin = 0;
- if (skin = skins.getSkin(PopupOptions.SkinPack))
- skin->saveOpts();
- skins.freeAllButActive();
- // more Skin options
- db_set_b(NULL, MODULNAME, "DisplayTime", PopupOptions.DisplayTime);
- db_set_b(NULL, MODULNAME, "DropShadow", PopupOptions.DropShadow);
- db_set_b(NULL, MODULNAME, "EnableShadowRegion", PopupOptions.EnableFreeformShadows);
- db_set_b(NULL, MODULNAME, "EnableAeroGlass", PopupOptions.EnableAeroGlass);
- db_set_b(NULL, MODULNAME, "UseMText", PopupOptions.UseMText);
- }// end PSN_APPLY:
- return TRUE;
+ {
+ // skin pack
+ db_set_ts(NULL, MODULNAME, "SkinPack", PopupOptions.SkinPack);
+ // skin options
+ const PopupSkin *skin = 0;
+ if (skin = skins.getSkin(PopupOptions.SkinPack))
+ skin->saveOpts();
+ skins.freeAllButActive();
+ // more Skin options
+ db_set_b(NULL, MODULNAME, "DisplayTime", PopupOptions.DisplayTime);
+ db_set_b(NULL, MODULNAME, "DropShadow", PopupOptions.DropShadow);
+ db_set_b(NULL, MODULNAME, "EnableShadowRegion", PopupOptions.EnableFreeformShadows);
+ db_set_b(NULL, MODULNAME, "EnableAeroGlass", PopupOptions.EnableAeroGlass);
+ db_set_b(NULL, MODULNAME, "UseMText", PopupOptions.UseMText);
+ }// end PSN_APPLY:
+ return TRUE;
}// switch (((LPNMHDR)lParam)->code)
break;
}// end switch (((LPNMHDR)lParam)->idFrom)
@@ -529,72 +523,73 @@ static void BoxPreview_OnPaint(HWND hwnd, HDC mydc, int mode) switch (mode) {
case 0:
- { // Avatar
- HDC hdcAvatar = CreateCompatibleDC(mydc);
- HBITMAP hbmSave = (HBITMAP)SelectObject(hdcAvatar, hbmNoAvatar);
- GetClientRect(hwnd, &rc);
- BITMAP bmp;
- GetObject(hbmNoAvatar, sizeof(bmp), &bmp);
- StretchBlt(mydc, 0, 0, rc.right, rc.bottom, hdcAvatar, 0, 0, abs(bmp.bmWidth), abs(bmp.bmHeight), SRCCOPY);
- SelectObject(hdcAvatar, hbmSave);
- DeleteDC(hdcAvatar);
- HRGN rgn = CreateRoundRectRgn(0, 0, rc.right, rc.bottom, 2 * PopupOptions.avatarRadius, 2 * PopupOptions.avatarRadius);
- FrameRgn(mydc, rgn, (HBRUSH)GetStockObject(BLACK_BRUSH), 1, 1);
- DeleteObject(rgn);
+ { // Avatar
+ HDC hdcAvatar = CreateCompatibleDC(mydc);
+ HBITMAP hbmSave = (HBITMAP)SelectObject(hdcAvatar, hbmNoAvatar);
+ GetClientRect(hwnd, &rc);
+ BITMAP bmp;
+ GetObject(hbmNoAvatar, sizeof(bmp), &bmp);
+ StretchBlt(mydc, 0, 0, rc.right, rc.bottom, hdcAvatar, 0, 0, abs(bmp.bmWidth), abs(bmp.bmHeight), SRCCOPY);
+ SelectObject(hdcAvatar, hbmSave);
+ DeleteDC(hdcAvatar);
+ HRGN rgn = CreateRoundRectRgn(0, 0, rc.right, rc.bottom, 2 * PopupOptions.avatarRadius, 2 * PopupOptions.avatarRadius);
+ FrameRgn(mydc, rgn, (HBRUSH)GetStockObject(BLACK_BRUSH), 1, 1);
+ DeleteObject(rgn);
+ }
break;
- }
+
case 1:
- { // Opacity
- HBRUSH hbr = CreateSolidBrush(fonts.clBack);
- HFONT hfnt = (HFONT)SelectObject(mydc, fonts.title);
- GetClientRect(hwnd, &rc);
- FillRect(mydc, &rc, hbr);
- DrawIconEx(mydc, 10, (rc.bottom - rc.top - 16) / 2, IcoLib_GetIcon(ICO_POPUP_ON, 0), 16, 16, 0, hbr, DI_NORMAL);
- SetBkMode(mydc, TRANSPARENT);
- GetClientRect(hwnd, &rc);
- rc.left += 30; // 10+16+4 -- icon
- rc.right -= (rc.right - rc.left) / 3;
- rc.bottom -= (rc.bottom - rc.top) / 3;
- DrawText(mydc, _T(MODULNAME_LONG), -1, &rc, DT_CENTER | DT_NOPREFIX | DT_SINGLELINE | DT_VCENTER);
- GetClientRect(hwnd, &rc);
- rc.left += 30; // 10+16+4 -- icon
- rc.left += (rc.right - rc.left) / 3;
- rc.top += (rc.bottom - rc.top) / 3;
- DrawText(mydc, _T(MODULNAME_LONG), -1, &rc, DT_CENTER | DT_NOPREFIX | DT_SINGLELINE | DT_VCENTER);
- GetClientRect(hwnd, &rc);
- FrameRect(mydc, &rc, (HBRUSH)GetStockObject(BLACK_BRUSH));
- SelectObject(mydc, hfnt);
- DeleteObject(hbr);
- }
- break;
+ { // Opacity
+ HBRUSH hbr = CreateSolidBrush(fonts.clBack);
+ HFONT hfnt = (HFONT)SelectObject(mydc, fonts.title);
+ GetClientRect(hwnd, &rc);
+ FillRect(mydc, &rc, hbr);
+ DrawIconEx(mydc, 10, (rc.bottom - rc.top - 16) / 2, IcoLib_GetIcon(ICO_POPUP_ON, 0), 16, 16, 0, hbr, DI_NORMAL);
+ SetBkMode(mydc, TRANSPARENT);
+ GetClientRect(hwnd, &rc);
+ rc.left += 30; // 10+16+4 -- icon
+ rc.right -= (rc.right - rc.left) / 3;
+ rc.bottom -= (rc.bottom - rc.top) / 3;
+ DrawText(mydc, _T(MODULNAME_LONG), -1, &rc, DT_CENTER | DT_NOPREFIX | DT_SINGLELINE | DT_VCENTER);
+ GetClientRect(hwnd, &rc);
+ rc.left += 30; // 10+16+4 -- icon
+ rc.left += (rc.right - rc.left) / 3;
+ rc.top += (rc.bottom - rc.top) / 3;
+ DrawText(mydc, _T(MODULNAME_LONG), -1, &rc, DT_CENTER | DT_NOPREFIX | DT_SINGLELINE | DT_VCENTER);
+ GetClientRect(hwnd, &rc);
+ FrameRect(mydc, &rc, (HBRUSH)GetStockObject(BLACK_BRUSH));
+ SelectObject(mydc, hfnt);
+ DeleteObject(hbr);
+ }
+ break;
case 2:
- { // Position
- HBRUSH hbr = CreateSolidBrush(GetSysColor(COLOR_WINDOW));
- GetClientRect(hwnd, &rc);
- FillRect(mydc, &rc, hbr);
- DeleteObject(hbr);
-
- hbr = CreateSolidBrush(GetSysColor(COLOR_HIGHLIGHT));
- GetClientRect(hwnd, &rc);
- rc.right -= 100;
- rc.top += 100;
- FillRect(mydc, &rc, hbr);
- DeleteObject(hbr);
-
- HPEN hpen = (HPEN)SelectObject(mydc, CreatePen(PS_DOT, 1, RGB(0, 0, 0)));
- MoveToEx(mydc, 0, 100, NULL);
- LineTo(mydc, 201, 100);
- MoveToEx(mydc, 100, 0, NULL);
- LineTo(mydc, 100, 201);
- DeleteObject(SelectObject(mydc, hpen));
-
- HRGN hrgn = CreateRectRgn(0, 0, 0, 0);
- GetWindowRgn(hwnd, hrgn);
- FrameRgn(mydc, hrgn, (HBRUSH)GetStockObject(BLACK_BRUSH), 1, 1);
- DeleteObject(hrgn);
- }
- break;
+ { // Position
+ HBRUSH hbr = CreateSolidBrush(GetSysColor(COLOR_WINDOW));
+ GetClientRect(hwnd, &rc);
+ FillRect(mydc, &rc, hbr);
+ DeleteObject(hbr);
+
+ hbr = CreateSolidBrush(GetSysColor(COLOR_HIGHLIGHT));
+ GetClientRect(hwnd, &rc);
+ rc.right -= 100;
+ rc.top += 100;
+ FillRect(mydc, &rc, hbr);
+ DeleteObject(hbr);
+
+ HPEN hpen = (HPEN)SelectObject(mydc, CreatePen(PS_DOT, 1, RGB(0, 0, 0)));
+ MoveToEx(mydc, 0, 100, NULL);
+ LineTo(mydc, 201, 100);
+ MoveToEx(mydc, 100, 0, NULL);
+ LineTo(mydc, 100, 201);
+ DeleteObject(SelectObject(mydc, hpen));
+
+ HRGN hrgn = CreateRectRgn(0, 0, 0, 0);
+ GetWindowRgn(hwnd, hrgn);
+ FrameRgn(mydc, hrgn, (HBRUSH)GetStockObject(BLACK_BRUSH), 1, 1);
+ DeleteObject(hrgn);
+ }
+ break;
}
}
diff --git a/plugins/Popup/src/popup_gdiplus.cpp b/plugins/Popup/src/popup_gdiplus.cpp index aeee9ecb03..d323654740 100644 --- a/plugins/Popup/src/popup_gdiplus.cpp +++ b/plugins/Popup/src/popup_gdiplus.cpp @@ -43,7 +43,8 @@ void LoadGDIPlus() if (g_gdiplusToken == 0)
Gdiplus::GdiplusStartup(&g_gdiplusToken, &gdiplusStartupInput, NULL);
}
- __except (EXCEPTION_EXECUTE_HANDLER) {
+ __except (EXCEPTION_EXECUTE_HANDLER)
+ {
gbGdiPlusLoaded = false;
}
}
@@ -55,7 +56,8 @@ void UnloadGDIPlus() if (g_gdiplusToken && gbGdiPlusLoaded)
Gdiplus::GdiplusShutdown(g_gdiplusToken);
}
- __except (EXCEPTION_EXECUTE_HANDLER) {
+ __except (EXCEPTION_EXECUTE_HANDLER)
+ {
// do nothing
}
gbGdiPlusLoaded = true;
@@ -87,12 +89,10 @@ HBITMAP SkinEngine_CreateDIB32(int cx, int cy) UINT *ptPixels;
HBITMAP DirectBitmap = CreateDIBSection(NULL, &RGB32BitsBITMAPINFO, DIB_RGB_COLORS, (void **)&ptPixels, NULL, 0);
- if ((DirectBitmap == NULL || ptPixels == NULL) && cx != 0 && cy != 0)
- {
+ if ((DirectBitmap == NULL || ptPixels == NULL) && cx != 0 && cy != 0) {
;
}
- else
- {
+ else {
memset(ptPixels, 0, cx*cy * 4);
}
return DirectBitmap;
@@ -172,9 +172,8 @@ void GDIPlus_ExtractAnimatedGIF(TCHAR *szName, int width, int height, HBITMAP &p int * delays = (int*)mir_alloc(nFrameCount*sizeof(int));
memset(delays, 0, nFrameCount*sizeof(int));
- for (int i = 1; i < nFrameCount + 1; i++)
- {
- GUID pageGuid = FrameDimensionTime;
+ for (int i = 1; i < nFrameCount + 1; i++) {
+ GUID pageGuid = FrameDimensionTime;
RectF rect((float)(i - 1)*clipWidth, (float)0, (float)clipWidth, (float)clipHeight);
graphics.DrawImage(&image, rect, (float)0, (float)0, (float)imWidth, (float)imHeight, UnitPixel, &attr, NULL, NULL);
image.SelectActiveFrame(&pageGuid, i);
diff --git a/plugins/Popup/src/popup_thread.cpp b/plugins/Popup/src/popup_thread.cpp index 29f45dc3d7..a8f269635f 100644 --- a/plugins/Popup/src/popup_thread.cpp +++ b/plugins/Popup/src/popup_thread.cpp @@ -24,7 +24,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "headers.h"
#include <process.h>
-// globals
+// globals
static int gIdleRequests = 0;
static bool gTerminating = false;
static HWND gHwndManager = 0;
@@ -34,7 +34,7 @@ static HANDLE hThread = 0; static LIST<PopupWnd2> popupList(3);
-// forwards
+// forwards
enum
{
// message id's
@@ -178,15 +178,14 @@ static LRESULT CALLBACK PopupThreadManagerWndProc(HWND hwnd, UINT message, WPARA break;
case UTM_REMOVE_WINDOW:
- {
for (int i = popupList.getCount() - 1; i >= 0; i--)
if (popupList[i] == wnd)
popupList.remove(i);
- }
- RepositionPopups();
- --nPopups;
- delete wnd;
- break;
+
+ RepositionPopups();
+ --nPopups;
+ delete wnd;
+ break;
case UTM_LOCK_QUEUE:
++gLockCount;
diff --git a/plugins/Popup/src/popup_wnd2.cpp b/plugins/Popup/src/popup_wnd2.cpp index aad7891cbb..1dd02de909 100644 --- a/plugins/Popup/src/popup_wnd2.cpp +++ b/plugins/Popup/src/popup_wnd2.cpp @@ -968,16 +968,16 @@ LRESULT CALLBACK PopupWnd2::WindowProc(UINT message, WPARAM wParam, LPARAM lPara break;
case ACT_DEF_ADD:
- {
- ADDCONTACTSTRUCT acs = { 0 };
- acs.hContact = m_hContact;
- acs.handleType = HANDLE_CONTACT;
- acs.szProto = 0;
- CallServiceSync(MS_ADDCONTACT_SHOW, NULL, (LPARAM)&acs);
- if (!(PopupOptions.actions&ACT_DEF_KEEPWND))
- PUDeletePopup(m_hwnd);
- }
- break;
+ {
+ ADDCONTACTSTRUCT acs = { 0 };
+ acs.hContact = m_hContact;
+ acs.handleType = HANDLE_CONTACT;
+ acs.szProto = 0;
+ CallServiceSync(MS_ADDCONTACT_SHOW, NULL, (LPARAM)&acs);
+ if (!(PopupOptions.actions&ACT_DEF_KEEPWND))
+ PUDeletePopup(m_hwnd);
+ }
+ break;
case ACT_DEF_PIN:
if (m_bIsPinned)
@@ -1018,57 +1018,57 @@ LRESULT CALLBACK PopupWnd2::WindowProc(UINT message, WPARAM wParam, LPARAM lPara break;
case UM_POPUPMODIFYACTIONICON:
- {
- LPPOPUPACTIONID actionId = (LPPOPUPACTIONID)wParam;
- for (int i = 0; i < m_actionCount; ++i)
- if ((m_actions[i].actionA.wParam == actionId->wParam) &&
- (m_actions[i].actionA.lParam == actionId->lParam)) {
- m_actions[i].actionA.lchIcon = (HICON)lParam;
- animate();
- break;
- }
- }
- break;
+ {
+ LPPOPUPACTIONID actionId = (LPPOPUPACTIONID)wParam;
+ for (int i = 0; i < m_actionCount; ++i)
+ if ((m_actions[i].actionA.wParam == actionId->wParam) &&
+ (m_actions[i].actionA.lParam == actionId->lParam)) {
+ m_actions[i].actionA.lchIcon = (HICON)lParam;
+ animate();
+ break;
+ }
+ }
+ break;
case UM_MENUDONE:
- {
- unlock();
- if (!(PopupOptions.actions&ACT_DEF_KEEPWND))
- PUDeletePopup(m_hwnd);
- break;
- }
+ {
+ unlock();
+ if (!(PopupOptions.actions&ACT_DEF_KEEPWND))
+ PUDeletePopup(m_hwnd);
+ break;
+ }
case WM_LBUTTONUP:
- {
- int i;
- for (i = 0; i < m_actionCount; ++i)
- if (m_actions[i].hover) {
- SendMessage(m_hwnd, UM_POPUPACTION, m_actions[i].actionA.wParam, m_actions[i].actionA.lParam);
- break;
- }
+ {
+ int i;
+ for (i = 0; i < m_actionCount; ++i)
+ if (m_actions[i].hover) {
+ SendMessage(m_hwnd, UM_POPUPACTION, m_actions[i].actionA.wParam, m_actions[i].actionA.lParam);
+ break;
+ }
- if (i == m_actionCount) {
- if (PopupOptions.overrideLeft != false && (m_hContact != NULL || PopupOptions.overrideLeft == 5 || PopupOptions.overrideLeft == 6)) {
- switch (PopupOptions.overrideLeft) {
- default:
- case 1:SendMessage(m_hwnd, UM_POPUPACTION, 0, ACT_DEF_MESSAGE); break;
- case 2:SendMessage(m_hwnd, UM_POPUPACTION, 0, ACT_DEF_REPLY); break;
- case 3:SendMessage(m_hwnd, UM_POPUPACTION, 0, ACT_DEF_DETAILS); break;
- case 4:SendMessage(m_hwnd, UM_POPUPACTION, 0, ACT_DEF_MENU); break;
- case 5:SendMessage(m_hwnd, UM_POPUPACTION, 0, ACT_DEF_DISMISS); break;
- case 6:SendMessage(m_hwnd, UM_POPUPACTION, 0, ACT_DEF_PIN); break;
- case 7:SendMessage(m_hwnd, UM_POPUPACTION, 0, ACT_DEF_COPY); break;
+ if (i == m_actionCount) {
+ if (PopupOptions.overrideLeft != false && (m_hContact != NULL || PopupOptions.overrideLeft == 5 || PopupOptions.overrideLeft == 6)) {
+ switch (PopupOptions.overrideLeft) {
+ default:
+ case 1:SendMessage(m_hwnd, UM_POPUPACTION, 0, ACT_DEF_MESSAGE); break;
+ case 2:SendMessage(m_hwnd, UM_POPUPACTION, 0, ACT_DEF_REPLY); break;
+ case 3:SendMessage(m_hwnd, UM_POPUPACTION, 0, ACT_DEF_DETAILS); break;
+ case 4:SendMessage(m_hwnd, UM_POPUPACTION, 0, ACT_DEF_MENU); break;
+ case 5:SendMessage(m_hwnd, UM_POPUPACTION, 0, ACT_DEF_DISMISS); break;
+ case 6:SendMessage(m_hwnd, UM_POPUPACTION, 0, ACT_DEF_PIN); break;
+ case 7:SendMessage(m_hwnd, UM_POPUPACTION, 0, ACT_DEF_COPY); break;
+ }
+ }
+ else {
+ lock();
+ if (!PerformAction(m_hNotification, m_hwnd, message, wParam, lParam))
+ SendMessage(m_hwnd, WM_COMMAND, 0, 0);
+ unlock();
}
}
- else {
- lock();
- if (!PerformAction(m_hNotification, m_hwnd, message, wParam, lParam))
- SendMessage(m_hwnd, WM_COMMAND, 0, 0);
- unlock();
- }
+ break;
}
- break;
- }
case WM_MBUTTONUP:
if (PopupOptions.overrideMiddle != false && (m_hContact != NULL || PopupOptions.overrideMiddle == 5 || PopupOptions.overrideMiddle == 6)) {
@@ -1123,16 +1123,16 @@ LRESULT CALLBACK PopupWnd2::WindowProc(UINT message, WPARAM wParam, LPARAM lPara break;
case AVATAR_TIMER:
- {
- int newDelay = m_avatar->activeFrameDelay();
- animate();
- if ((newDelay <= 0) || (newDelay != m_avatarFrameDelay)) KillTimer(m_hwnd, AVATAR_TIMER);
- if (newDelay > 0) {
- SetTimer(m_hwnd, AVATAR_TIMER, newDelay, 0);
- m_avatarFrameDelay = newDelay;
+ {
+ int newDelay = m_avatar->activeFrameDelay();
+ animate();
+ if ((newDelay <= 0) || (newDelay != m_avatarFrameDelay)) KillTimer(m_hwnd, AVATAR_TIMER);
+ if (newDelay > 0) {
+ SetTimer(m_hwnd, AVATAR_TIMER, newDelay, 0);
+ m_avatarFrameDelay = newDelay;
+ }
}
- }
- break;
+ break;
case CURSOR_TIMER:
POINT pt; GetCursorPos(&pt);
@@ -1161,12 +1161,12 @@ LRESULT CALLBACK PopupWnd2::WindowProc(UINT message, WPARAM wParam, LPARAM lPara break;
case UM_CALLMETHOD:
- {
- MethodPtr *method_copy = (MethodPtr *)wParam;
- (this->*(*method_copy))(lParam);
- delete method_copy;
- }
- break;
+ {
+ MethodPtr *method_copy = (MethodPtr *)wParam;
+ (this->*(*method_copy))(lParam);
+ delete method_copy;
+ }
+ break;
case WM_PAINT:
if (GetUpdateRect(m_hwnd, 0, FALSE)) {
@@ -1184,44 +1184,44 @@ LRESULT CALLBACK PopupWnd2::WindowProc(UINT message, WPARAM wParam, LPARAM lPara break;
case WM_MOUSEMOVE:
- {
- const PopupSkin *skin = skins.getSkin(m_lpzSkin ? m_lpzSkin : m_options->SkinPack);
- if (skin)
- if (skin->onMouseMove(this, LOWORD(lParam), HIWORD(lParam)))
- animate();
-
- if (m_bIsHovered) break;
- TRACKMOUSEEVENT tme;
- tme.cbSize = sizeof(tme);
- tme.dwFlags = TME_LEAVE;
- tme.dwHoverTime = HOVER_DEFAULT;
- tme.hwndTrack = m_hwnd;
- _TrackMouseEvent(&tme);
- if (!m_customPopup) PopupThreadLock();
+ {
+ const PopupSkin *skin = skins.getSkin(m_lpzSkin ? m_lpzSkin : m_options->SkinPack);
+ if (skin)
+ if (skin->onMouseMove(this, LOWORD(lParam), HIWORD(lParam)))
+ animate();
+
+ if (m_bIsHovered) break;
+ TRACKMOUSEEVENT tme;
+ tme.cbSize = sizeof(tme);
+ tme.dwFlags = TME_LEAVE;
+ tme.dwHoverTime = HOVER_DEFAULT;
+ tme.hwndTrack = m_hwnd;
+ _TrackMouseEvent(&tme);
+ if (!m_customPopup) PopupThreadLock();
- if (m_options->OpaqueOnHover)
- updateLayered(255);
+ if (m_options->OpaqueOnHover)
+ updateLayered(255);
- m_bIsHovered = true;
- }
- break;
+ m_bIsHovered = true;
+ }
+ break;
case WM_MOUSELEAVE:
- {
- const PopupSkin *skin = skins.getSkin(m_lpzSkin ? m_lpzSkin : m_options->SkinPack);
- if (skin)
- if (skin->onMouseMove(this, LOWORD(lParam), HIWORD(lParam)))
- animate();
+ {
+ const PopupSkin *skin = skins.getSkin(m_lpzSkin ? m_lpzSkin : m_options->SkinPack);
+ if (skin)
+ if (skin->onMouseMove(this, LOWORD(lParam), HIWORD(lParam)))
+ animate();
- if (!m_bIsHovered) break;
+ if (!m_bIsHovered) break;
- if (m_options->OpaqueOnHover)
- updateLayered(m_options->UseTransparency ? m_options->Alpha : 255);
+ if (m_options->OpaqueOnHover)
+ updateLayered(m_options->UseTransparency ? m_options->Alpha : 255);
- if (!m_customPopup) PopupThreadUnlock();
- m_bIsHovered = false;
- }
- break;
+ if (!m_customPopup) PopupThreadUnlock();
+ m_bIsHovered = false;
+ }
+ break;
case WM_CLOSE:
hide();
diff --git a/plugins/Popup/src/services.cpp b/plugins/Popup/src/services.cpp index 1d54e21027..69b06749d8 100644 --- a/plugins/Popup/src/services.cpp +++ b/plugins/Popup/src/services.cpp @@ -284,28 +284,29 @@ INT_PTR Popup_Query(WPARAM wParam, LPARAM) return 0;
switch (wParam) {
- case PUQS_ENABLEPOPUPS: {
- if (PopupOptions.ModuleIsEnabled) return 1; // They're already ON!!!
- else { // Module was disabled.
- svcEnableDisableMenuCommand(0, 0);
- return 0;
- }
- }
- case PUQS_DISABLEPOPUPS: {
- if (!(PopupOptions.ModuleIsEnabled)) return 1; // They're already OFF!!!
- else {
- svcEnableDisableMenuCommand(0, 0);
- return 0;
- }
- }
+ case PUQS_ENABLEPOPUPS:
+ if (PopupOptions.ModuleIsEnabled)
+ return 1; // They're already ON!!!
+
+ // Module was disabled.
+ svcEnableDisableMenuCommand(0, 0);
+ return 0;
+
+ case PUQS_DISABLEPOPUPS:
+ if (!(PopupOptions.ModuleIsEnabled))
+ return 1; // They're already OFF!!!
+
+ svcEnableDisableMenuCommand(0, 0);
+ return 0;
+
case PUQS_GETSTATUS:
return (PopupOptions.ModuleIsEnabled);
+
default:
return -1;
}
}
-
//===== Popup/RegisterActions
INT_PTR Popup_RegisterActions(WPARAM wParam, LPARAM lParam)
{
@@ -427,9 +428,11 @@ INT_PTR Popup_UnregisterPopupClass(WPARAM, LPARAM lParam) }
//===== Popup/AddPopupClass (for core class api support)
-INT_PTR Popup_CreateClassPopup(WPARAM wParam, LPARAM lParam) {
+INT_PTR Popup_CreateClassPopup(WPARAM wParam, LPARAM lParam)
+{
POPUPDATACLASS *pdc = (POPUPDATACLASS *)lParam;
- if (!pdc || (pdc->cbSize != sizeof(POPUPDATACLASS))) return 1;
+ if (!pdc || (pdc->cbSize != sizeof(POPUPDATACLASS)))
+ return 1;
POPUPCLASS *pc;
if (wParam)
@@ -443,27 +446,27 @@ INT_PTR Popup_CreateClassPopup(WPARAM wParam, LPARAM lParam) { pc = NULL;
mir_free(group);
}
- if (pc) {
- POPUPDATA2 ppd2 = { sizeof(ppd2) };
- ppd2.colorBack = pc->colorBack;
- ppd2.colorText = pc->colorText;
- ppd2.lchIcon = pc->hIcon;
- ppd2.iSeconds = pc->iSeconds;
- ppd2.PluginWindowProc = pc->PluginWindowProc;
- if (pc->flags & PCF_UNICODE) {
- ppd2.flags = PU2_UNICODE;
- ppd2.lptzTitle = (TCHAR*)pdc->ptszTitle;
- ppd2.lptzText = (TCHAR*)pdc->ptszText;
- }
- else {
- ppd2.flags = PU2_ANSI;
- ppd2.lpzTitle = (char *)pdc->pszTitle;
- ppd2.lpzText = (char *)pdc->pszText;
- }
- ppd2.lchContact = pdc->hContact;
- ppd2.PluginData = pdc->PluginData;
+ if (pc == NULL)
+ return 1;
- return Popup_AddPopup2((WPARAM)&ppd2, pc->lParam);
+ POPUPDATA2 ppd2 = { sizeof(ppd2) };
+ ppd2.colorBack = pc->colorBack;
+ ppd2.colorText = pc->colorText;
+ ppd2.lchIcon = pc->hIcon;
+ ppd2.iSeconds = pc->iSeconds;
+ ppd2.PluginWindowProc = pc->PluginWindowProc;
+ if (pc->flags & PCF_UNICODE) {
+ ppd2.flags = PU2_UNICODE;
+ ppd2.lptzTitle = (TCHAR*)pdc->ptszTitle;
+ ppd2.lptzText = (TCHAR*)pdc->ptszText;
}
- return 1;
+ else {
+ ppd2.flags = PU2_ANSI;
+ ppd2.lpzTitle = (char *)pdc->pszTitle;
+ ppd2.lpzText = (char *)pdc->pszText;
+ }
+ ppd2.lchContact = pdc->hContact;
+ ppd2.PluginData = pdc->PluginData;
+
+ return Popup_AddPopup2((WPARAM)&ppd2, pc->lParam);
}
diff --git a/plugins/Popup/src/skin.cpp b/plugins/Popup/src/skin.cpp index 751370ef54..c83a430b6b 100644 --- a/plugins/Popup/src/skin.cpp +++ b/plugins/Popup/src/skin.cpp @@ -226,81 +226,81 @@ void PopupSkin::measure(HDC hdc, PopupWnd2 *wnd, int maxw, POPUPOPTIONS *options SIZE szNew = { 0, 0 };
switch (head->type & ST_TYPEMASK) {
case ST_TEXT:
- {
- int tmp = head->fw.eval(wnd->getArgs());
- // this is used to measure and layout text
- wnd->getRenderInfo()->textw = tmp ? tmp : (maxw - head->fx.eval(wnd->getArgs()));
- szNew.cx = wnd->getRenderInfo()->textw;
- if (wnd->isTextEmpty())
- szNew.cx = szNew.cy = 0;
- else {
- HFONT hFntSave = (HFONT)SelectObject(hdc, fonts.text);
- switch (wnd->getTextType()) {
- case PopupWnd2::TT_UNICODE:
- {
- RECT rc; SetRect(&rc, 0, 0, szNew.cx, 0);
- DrawTextEx(hdc, wnd->getText(), (int)mir_tstrlen(wnd->getText()), &rc,
- DT_CALCRECT | DT_EXPANDTABS | DT_LEFT | DT_NOPREFIX | DT_TOP | DT_WORDBREAK/*|DT_RTLREADING*/, NULL);
- szNew.cx = rc.right;
- szNew.cy = rc.bottom;
- }
- break;
- case PopupWnd2::TT_MTEXT:
- MText.Measure(hdc, &szNew, wnd->getTextM());
- break;
+ {
+ int tmp = head->fw.eval(wnd->getArgs());
+ // this is used to measure and layout text
+ wnd->getRenderInfo()->textw = tmp ? tmp : (maxw - head->fx.eval(wnd->getArgs()));
+ szNew.cx = wnd->getRenderInfo()->textw;
+ if (wnd->isTextEmpty())
+ szNew.cx = szNew.cy = 0;
+ else {
+ HFONT hFntSave = (HFONT)SelectObject(hdc, fonts.text);
+ switch (wnd->getTextType()) {
+ case PopupWnd2::TT_UNICODE:
+ {
+ RECT rc; SetRect(&rc, 0, 0, szNew.cx, 0);
+ DrawTextEx(hdc, wnd->getText(), (int)mir_tstrlen(wnd->getText()), &rc,
+ DT_CALCRECT | DT_EXPANDTABS | DT_LEFT | DT_NOPREFIX | DT_TOP | DT_WORDBREAK/*|DT_RTLREADING*/, NULL);
+ szNew.cx = rc.right;
+ szNew.cy = rc.bottom;
+ }
+ break;
+ case PopupWnd2::TT_MTEXT:
+ MText.Measure(hdc, &szNew, wnd->getTextM());
+ break;
+ }
+ SelectObject(hdc, hFntSave);
}
- SelectObject(hdc, hFntSave);
- }
- wnd->getRenderInfo()->texth = szNew.cy;
+ wnd->getRenderInfo()->texth = szNew.cy;
- SIZE szActions = measureActionBar(hdc, wnd);
- wnd->getRenderInfo()->actw = szActions.cx;
- if (szActions.cy) {
- szNew.cx = max(szNew.cx, szActions.cx);
- szNew.cy += szActions.cy;
- szNew.cy += 3;
- }
+ SIZE szActions = measureActionBar(hdc, wnd);
+ wnd->getRenderInfo()->actw = szActions.cx;
+ if (szActions.cy) {
+ szNew.cx = max(szNew.cx, szActions.cx);
+ szNew.cy += szActions.cy;
+ szNew.cy += 3;
+ }
- wnd->getRenderInfo()->realtextw = szNew.cx;
+ wnd->getRenderInfo()->realtextw = szNew.cx;
- if (szNew.cx > maxw - head->fx.eval(wnd->getArgs()))
- szNew.cx = maxw - head->fx.eval(wnd->getArgs());
- wnd->getArgs()->add("text.width", szNew.cx);
- wnd->getArgs()->add("text.height", szNew.cy);
- }
- break;
+ if (szNew.cx > maxw - head->fx.eval(wnd->getArgs()))
+ szNew.cx = maxw - head->fx.eval(wnd->getArgs());
+ wnd->getArgs()->add("text.width", szNew.cx);
+ wnd->getArgs()->add("text.height", szNew.cy);
+ }
+ break;
case ST_TITLE:
- {
- int tmp = head->fw.eval(wnd->getArgs());
- // this is used to measure and layout text
- wnd->getRenderInfo()->titlew = tmp ? tmp : (maxw - head->fx.eval(wnd->getArgs()) - STYLE_SZ_CLOCK);
- szNew.cx = wnd->getRenderInfo()->titlew;
- HFONT hFntSave = (HFONT)SelectObject(hdc, fonts.title);
- switch (wnd->getTextType()) {
- case PopupWnd2::TT_UNICODE:
{
- RECT rc; SetRect(&rc, 0, 0, szNew.cx, 0);
- DrawTextEx(hdc, wnd->getTitle(), (int)mir_tstrlen(wnd->getTitle()), &rc,
- DT_CALCRECT | DT_EXPANDTABS | DT_LEFT | DT_NOPREFIX | DT_TOP | DT_WORDBREAK/*|DT_RTLREADING*/, NULL);
- szNew.cx = rc.right;
- szNew.cy = rc.bottom;
+ int tmp = head->fw.eval(wnd->getArgs());
+ // this is used to measure and layout text
+ wnd->getRenderInfo()->titlew = tmp ? tmp : (maxw - head->fx.eval(wnd->getArgs()) - STYLE_SZ_CLOCK);
+ szNew.cx = wnd->getRenderInfo()->titlew;
+ HFONT hFntSave = (HFONT)SelectObject(hdc, fonts.title);
+ switch (wnd->getTextType()) {
+ case PopupWnd2::TT_UNICODE:
+ {
+ RECT rc; SetRect(&rc, 0, 0, szNew.cx, 0);
+ DrawTextEx(hdc, wnd->getTitle(), (int)mir_tstrlen(wnd->getTitle()), &rc,
+ DT_CALCRECT | DT_EXPANDTABS | DT_LEFT | DT_NOPREFIX | DT_TOP | DT_WORDBREAK/*|DT_RTLREADING*/, NULL);
+ szNew.cx = rc.right;
+ szNew.cy = rc.bottom;
+ }
+ break;
+ case PopupWnd2::TT_MTEXT:
+ MText.Measure(hdc, &szNew, wnd->getTitleM());
+ break;
+ }
+
+ SelectObject(hdc, hFntSave);
+ if (szNew.cx > maxw - head->fx.eval(wnd->getArgs()) - STYLE_SZ_CLOCK)
+ szNew.cx = maxw - head->fx.eval(wnd->getArgs()) - STYLE_SZ_CLOCK;
+ szNew.cx += STYLE_SZ_CLOCK;
+ wnd->getArgs()->add("title.width", szNew.cx);
+ wnd->getArgs()->add("title.height", szNew.cy);
}
break;
- case PopupWnd2::TT_MTEXT:
- MText.Measure(hdc, &szNew, wnd->getTitleM());
- break;
- }
-
- SelectObject(hdc, hFntSave);
- if (szNew.cx > maxw - head->fx.eval(wnd->getArgs()) - STYLE_SZ_CLOCK)
- szNew.cx = maxw - head->fx.eval(wnd->getArgs()) - STYLE_SZ_CLOCK;
- szNew.cx += STYLE_SZ_CLOCK;
- wnd->getArgs()->add("title.width", szNew.cx);
- wnd->getArgs()->add("title.height", szNew.cy);
- }
- break;
case ST_ICON:
szNew.cx = szNew.cy = 16;
@@ -499,12 +499,12 @@ void PopupSkin::display(MyBitmap *bmp, PopupWnd2 *wnd, POPUPOPTIONS *options, DW bmp->saveAlpha();
switch (wnd->getTextType()) {
case PopupWnd2::TT_UNICODE:
- {
- RECT rc; SetRect(&rc, pos.x, pos.y, pos.x + sz.cx, pos.y + sz.cy);
- DrawTextEx(hdc, wnd->getText(), (int)mir_tstrlen(wnd->getText()), &rc,
- DT_EXPANDTABS | DT_LEFT | DT_NOPREFIX | DT_TOP | DT_WORDBREAK/*|DT_RTLREADING*/, NULL);
- }
- break;
+ {
+ RECT rc; SetRect(&rc, pos.x, pos.y, pos.x + sz.cx, pos.y + sz.cy);
+ DrawTextEx(hdc, wnd->getText(), (int)mir_tstrlen(wnd->getText()), &rc,
+ DT_EXPANDTABS | DT_LEFT | DT_NOPREFIX | DT_TOP | DT_WORDBREAK/*|DT_RTLREADING*/, NULL);
+ }
+ break;
case PopupWnd2::TT_MTEXT:
MText.Display(hdc, pos, sz, wnd->getTextM());
break;
@@ -547,14 +547,14 @@ void PopupSkin::display(MyBitmap *bmp, PopupWnd2 *wnd, POPUPOPTIONS *options, DW switch (wnd->getTextType()) {
case PopupWnd2::TT_UNICODE:
- {
- HFONT hFntSave = (HFONT)SelectObject(hdc, fonts.title);
- RECT rc; SetRect(&rc, pos.x, pos.y, pos.x + sz.cx, pos.y + sz.cy);
- DrawTextEx(hdc, wnd->getTitle(), (int)mir_tstrlen(wnd->getTitle()), &rc,
- DT_EXPANDTABS | DT_LEFT | DT_NOPREFIX | DT_TOP | DT_WORDBREAK/*|DT_RTLREADING*/, NULL);
- SelectObject(hdc, hFntSave);
- }
- break;
+ {
+ HFONT hFntSave = (HFONT)SelectObject(hdc, fonts.title);
+ RECT rc; SetRect(&rc, pos.x, pos.y, pos.x + sz.cx, pos.y + sz.cy);
+ DrawTextEx(hdc, wnd->getTitle(), (int)mir_tstrlen(wnd->getTitle()), &rc,
+ DT_EXPANDTABS | DT_LEFT | DT_NOPREFIX | DT_TOP | DT_WORDBREAK/*|DT_RTLREADING*/, NULL);
+ SelectObject(hdc, hFntSave);
+ }
+ break;
case PopupWnd2::TT_MTEXT:
HFONT hFntSave = (HFONT)SelectObject(hdc, fonts.title);
MText.Display(hdc, pos, sz, wnd->getTitleM());
@@ -956,12 +956,8 @@ PopupSkin::SKINELEMENT *PopupSkin::loadObject(std::wistream &f) }
else if (!mir_tstrcmp(buf, _T("source"))) {
f >> buf;
- if (((element->type & ST_TYPEMASK) == ST_MYBITMAP) || ((element->type & ST_TYPEMASK) == ST_CLOCK)) {
- TCHAR *alpha = mir_tstrdup(buf);
- alpha[mir_tstrlen(alpha) - 1] = 'a';
- element->myBmp = new MyBitmap(buf, alpha);
- mir_free(alpha);
- }
+ if (((element->type & ST_TYPEMASK) == ST_MYBITMAP) || ((element->type & ST_TYPEMASK) == ST_CLOCK))
+ element->myBmp = new MyBitmap(buf);
}
else if (!mir_tstrcmp(buf, _T("mono"))) {
element->type |= ST_MONO;
diff --git a/plugins/SplashScreen/src/bitmap_funcs.cpp b/plugins/SplashScreen/src/bitmap_funcs.cpp index 3e4f3d8e54..e75395e838 100644 --- a/plugins/SplashScreen/src/bitmap_funcs.cpp +++ b/plugins/SplashScreen/src/bitmap_funcs.cpp @@ -38,14 +38,14 @@ MyBitmap::MyBitmap(int w, int h) allocate(w, h);
}
-MyBitmap::MyBitmap(TCHAR *fn, TCHAR *fnAlpha)
+MyBitmap::MyBitmap(TCHAR *fn)
{
dcBmp = 0;
hBmp = 0;
bits = 0;
width = height = 0;
bitsSave = 0;
- loadFromFile(fn, fnAlpha);
+ loadFromFile(fn);
}
MyBitmap::~MyBitmap()
@@ -125,133 +125,40 @@ void MyBitmap::DrawText(TCHAR *str, int x, int y) this->saveAlpha(x - 2, y - 2, sz.cx + 2, sz.cy + 2);
::DrawText(this->getDC(), str, -1, &rc, DT_LEFT | DT_TOP | DT_SINGLELINE | DT_NOPREFIX);
this->restoreAlpha(x - 2, y - 2, sz.cx + 2, sz.cy + 2);
- //(x,y,sz.cx,sz.cy);
}
-bool MyBitmap::loadFromFile(TCHAR *fn, TCHAR *fnAlpha)
+bool MyBitmap::loadFromFile(TCHAR *fn)
{
if (bits) free();
- SIZE sz;
-
- TCHAR *ext;
- ext = &fn[mir_tstrlen(fn) - 4];
-
- if (!mir_tstrcmpi(ext, _T(".png"))) {
- HANDLE hFile, hMap = NULL;
- BYTE *ppMap = NULL;
- long cbFileSize = 0;
- BITMAPINFOHEADER *pDib = { 0 };
- BYTE *pDibBits = 0;
-
- if (!png2dibConvertor) {
- return false;
- }
-
- if ((hFile = CreateFile(fn, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL)) != INVALID_HANDLE_VALUE)
- if ((hMap = CreateFileMapping(hFile, NULL, PAGE_READONLY, 0, 0, NULL)) != NULL)
- if ((ppMap = (BYTE*)MapViewOfFile(hMap, FILE_MAP_READ, 0, 0, 0)) != NULL)
- cbFileSize = GetFileSize(hFile, NULL);
- if (cbFileSize != 0) {
- PNG2DIB param;
- param.pSource = ppMap;
- param.cbSourceSize = cbFileSize;
- param.pResult = &pDib;
-
- if (png2dibConvertor((char*)param.pSource, param.cbSourceSize, param.pResult))
- pDibBits = (BYTE*)(pDib + 1);
- else
- cbFileSize = 0;
+ HBITMAP hBmpLoaded = (HBITMAP)CallService(MS_IMG_LOAD, (WPARAM)fn, IMGL_TCHAR);
+ if (!hBmpLoaded) {
#ifdef _DEBUG
- logMessage(_T("Loading splash file"), _T("done"));
+ logMessage(_T("MyBitmap::loadFromFile"), _T("Bitmap load failed"));
#endif
- }
-
- if (ppMap) UnmapViewOfFile(ppMap);
- if (hMap) CloseHandle(hMap);
- if (hFile) CloseHandle(hFile);
-
- if (!cbFileSize) return false;
-
- BITMAPINFO *bi = (BITMAPINFO*)pDib;
- BYTE *pt = (BYTE*)bi;
- pt += bi->bmiHeader.biSize;
- HBITMAP hBitmap = NULL;
-
- if (bi->bmiHeader.biBitCount != 32) {
- allocate(abs(bi->bmiHeader.biWidth), abs(bi->bmiHeader.biHeight));
- HDC hdcTmp = CreateCompatibleDC(getDC());
- HBITMAP hBitmap = CreateDIBitmap(getDC(), pDib, CBM_INIT, pDibBits, bi, DIB_PAL_COLORS);
- SelectObject(hdcTmp, hBitmap);
- BitBlt(this->getDC(), 0, 0, abs(bi->bmiHeader.biWidth), abs(bi->bmiHeader.biHeight), hdcTmp, 0, 0, SRCCOPY);
- this->makeOpaque();
- DeleteDC(hdcTmp);
- DeleteObject(hBitmap);
-
- }
- else {
- BYTE *ptPixels = pt;
- hBitmap = CreateDIBSection(NULL, bi, DIB_RGB_COLORS, (void **)&ptPixels, NULL, 0);
- memcpy(ptPixels, pt, bi->bmiHeader.biSizeImage);
-
- allocate(abs(bi->bmiHeader.biWidth), abs(bi->bmiHeader.biHeight));
- //memcpy(bits, pt, bi->bmiHeader.biSizeImage);
-
- BYTE *p2 = (BYTE*)pt;
- for (int y = 0; y < bi->bmiHeader.biHeight; ++y) {
- BYTE *p1 = (BYTE*)bits + (bi->bmiHeader.biHeight - y - 1)*bi->bmiHeader.biWidth * 4;
- for (int x = 0; x < bi->bmiHeader.biWidth; ++x) {
- p1[0] = p2[0];
- p1[1] = p2[1];
- p1[2] = p2[2];
- p1[3] = p2[3];
- p1 += 4;
- p2 += 4;
- }
- }
-
- premultipleChannels();
- }
-
- GlobalFree(pDib);
- DeleteObject(hBitmap);
- return true;
+ return false;
}
- else {
- HBITMAP hBmpLoaded = (HBITMAP)LoadImage(NULL, fn, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
- if (!hBmpLoaded) {
-#ifdef _DEBUG
- logMessage(_T("MyBitmap::loadFromFile"), _T("Bitmap load failed"));
-#endif
- return false;
- }
- BITMAP bm; GetObject(hBmpLoaded, sizeof(bm), &bm);
- SetBitmapDimensionEx(hBmpLoaded, bm.bmWidth, bm.bmHeight, NULL);
+ BITMAP bm; GetObject(hBmpLoaded, sizeof(bm), &bm);
+ SetBitmapDimensionEx(hBmpLoaded, bm.bmWidth, bm.bmHeight, NULL);
- HDC dcTmp = CreateCompatibleDC(0);
- GetBitmapDimensionEx(hBmpLoaded, &sz);
- HBITMAP hBmpDcSave = (HBITMAP)SelectObject(dcTmp, hBmpLoaded);
+ SIZE sz;
+ HDC dcTmp = CreateCompatibleDC(0);
+ GetBitmapDimensionEx(hBmpLoaded, &sz);
+ HBITMAP hBmpDcSave = (HBITMAP)SelectObject(dcTmp, hBmpLoaded);
- allocate(sz.cx, sz.cy);
- BitBlt(dcBmp, 0, 0, width, height, dcTmp, 0, 0, SRCCOPY);
+ allocate(sz.cx, sz.cy);
+ BitBlt(dcBmp, 0, 0, width, height, dcTmp, 0, 0, SRCCOPY);
- DeleteObject(SelectObject(dcTmp, hBmpDcSave));
- DeleteDC(dcTmp);
+ DeleteObject(SelectObject(dcTmp, hBmpDcSave));
+ DeleteDC(dcTmp);
- MyBitmap alpha;
- if (fnAlpha && alpha.loadFromFile(fnAlpha) &&
- (alpha.getWidth() == width) &&
- (alpha.getHeight() == height)) {
- for (int i = 0; i < width*height; i++)
- bits[i] = (bits[i] & 0x00ffffff) | ((alpha.bits[i] & 0x000000ff) << 24);
- premultipleChannels();
- }
- else {
- makeOpaque();
- }
- return true;
- }
+ if (bm.bmBitsPixel == 32)
+ premultipleChannels();
+ else
+ makeOpaque();
+
+ return true;
}
void MyBitmap::allocate(int w, int h)
@@ -293,4 +200,4 @@ void MyBitmap::premultipleChannels() {
for (int i = 0; i < width*height; i++)
bits[i] = rgba(getr(bits[i])*geta(bits[i]) / 255, getg(bits[i])*geta(bits[i]) / 255, getb(bits[i])*geta(bits[i]) / 255, geta(bits[i]));
-}
\ No newline at end of file +}
diff --git a/plugins/SplashScreen/src/bitmap_funcs.h b/plugins/SplashScreen/src/bitmap_funcs.h index f91423dc52..35be6683db 100644 --- a/plugins/SplashScreen/src/bitmap_funcs.h +++ b/plugins/SplashScreen/src/bitmap_funcs.h @@ -26,10 +26,10 @@ private: public:
MyBitmap();
MyBitmap(int w, int h);
- MyBitmap(TCHAR *fn, TCHAR *fnAlpha = 0);
+ MyBitmap(TCHAR *fn);
~MyBitmap();
- bool loadFromFile(TCHAR *fn, TCHAR *fnAlpha = 0);
+ bool loadFromFile(TCHAR *fn);
int getWidth() { return width; }
int getHeight() { return height; }
diff --git a/plugins/SplashScreen/src/headers.h b/plugins/SplashScreen/src/headers.h index ffb47ae14c..0ec78e6cd6 100644 --- a/plugins/SplashScreen/src/headers.h +++ b/plugins/SplashScreen/src/headers.h @@ -32,7 +32,7 @@ #include <m_database.h>
#include <m_options.h>
#include <m_langpack.h>
-#include <m_png.h>
+#include <m_imgsrvc.h>
#include <m_splash.h>
@@ -72,13 +72,8 @@ extern TCHAR szSplashFile[MAX_PATH], szSoundFile[MAX_PATH], szPrefix[128]; extern TCHAR *szMirDir;
extern char szVersion[MAX_PATH];
extern BOOL bserviceinvoked, bmodulesloaded, png2dibavail;
-extern HANDLE hSplashThread;
extern HINSTANCE hInst;
-// png2dib interface
-typedef BOOL ( *pfnConvertPng2dib )( char*, size_t, BITMAPINFOHEADER** );
-extern pfnConvertPng2dib png2dibConvertor;
-
extern int OptInit(WPARAM wParam, LPARAM lParam);
extern BOOL ShowSplash(BOOL bpreview);
extern VOID ReadDbConfig();
diff --git a/plugins/SplashScreen/src/main.cpp b/plugins/SplashScreen/src/main.cpp index 6f1dbf8546..e08d070729 100644 --- a/plugins/SplashScreen/src/main.cpp +++ b/plugins/SplashScreen/src/main.cpp @@ -25,8 +25,6 @@ int hLangpack; static HMODULE hAdvaimg = NULL;
-pfnConvertPng2dib png2dibConvertor = NULL;
-
BOOL bstartup = true; // startup?
BOOL bserviceinvoked = false;
BOOL bmodulesloaded = false; // modules are loaded
@@ -41,7 +39,6 @@ TCHAR szLogFile[MAX_PATH]; #endif
SPLASHOPTS options;
HWND hwndSplash;
-HANDLE hSplashThread;
PLUGININFOEX pluginInfo = {
sizeof(PLUGININFOEX),
@@ -87,32 +84,6 @@ void SplashMain() if (bstartup & (options.active == 1))
{
- if (hAdvaimg == NULL)
- {
- hAdvaimg = LoadLibrary(szhAdvaimgPath);
- if (hAdvaimg == NULL)
- {
- png2dibavail = false;
- bstartup = false;
- }
- if (hAdvaimg)
- {
- png2dibConvertor = (pfnConvertPng2dib)GetProcAddress(hAdvaimg, "mempng2dib");
- if (png2dibConvertor == NULL)
- {
- FreeLibrary(hAdvaimg); hAdvaimg = NULL;
- MessageBox(NULL,
- TranslateT("Your advaimg.dll is either obsolete or damaged. Get latest from Miranda alpha builds."),
- TranslateT("Error"),
- MB_OK | MB_ICONSTOP);
- }
-#ifdef _DEBUG
- if (png2dibConvertor)
- logMessage(_T("Loading advaimg"), _T("done"));
-#endif
- }
- }
-
DBVARIANT dbv = { 0 };
if (!db_get_ts(NULL, MODNAME, "VersionPrefix", &dbv))
{
@@ -315,9 +286,6 @@ extern "C" int __declspec(dllexport) Load(void) extern "C" int __declspec(dllexport) Unload(void)
{
- if (hSplashThread)
- CloseHandle(hSplashThread);
-
UnregisterClass(_T(SPLASH_CLASS), hInst);
// Freeing loaded libraries
diff --git a/plugins/SplashScreen/src/splash.cpp b/plugins/SplashScreen/src/splash.cpp index 8a75544b5f..8f885a74e9 100644 --- a/plugins/SplashScreen/src/splash.cpp +++ b/plugins/SplashScreen/src/splash.cpp @@ -24,18 +24,15 @@ MyBitmap *SplashBmp, *tmpBmp; LRESULT CALLBACK SplashWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
- switch (message)
- {
+ switch (message) {
case WM_LOADED:
- {
#ifdef _DEBUG
logMessage(_T("WM_LOADED"), _T("called"));
#endif
- if (!options.showtime) SetTimer(hwnd, 7, 2000, 0);
-
+ if (!options.showtime)
+ SetTimer(hwnd, 7, 2000, 0);
break;
- }
case WM_LBUTTONDOWN:
PostMessage(hwnd, WM_CLOSE, 0, 0);
@@ -51,82 +48,65 @@ LRESULT CALLBACK SplashWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM logMessage(_T("ShowTime value"), b);
#endif
- if (options.showtime > 0) //TimeToShow enabled
- {
- if (wParam == 6)
- {
+ if (options.showtime > 0) { // TimeToShow enabled
+ if (wParam == 6) {
PostMessage(hwnd, WM_CLOSE, 0, 0);
#ifdef _DEBUG
logMessage(_T("Showtime timer"), _T("triggered"));
#endif
}
}
- else
- {
+ else {
PostMessage(hwnd, WM_CLOSE, 0, 0);
- if (wParam == 7)
- {
+ if (wParam == 7) {
#ifdef _DEBUG
logMessage(_T("On Modules Loaded timer"), _T("triggered"));
#endif
}
- if (wParam == 8)
- {
-#ifdef _DEBUG
- logMessage(_T("On Modules Loaded workaround"), _T("triggered"));
-#endif
- }
}
-
break;
case WM_RBUTTONDOWN:
- {
ShowWindow(hwndSplash, SW_HIDE);
DestroyWindow(hwndSplash);
bpreviewruns = false; // preview is stopped.
break;
- }
case WM_CLOSE:
- {
- RECT rc; GetWindowRect(hwndSplash, &rc);
- POINT ptDst = { rc.left, rc.top };
- POINT ptSrc = { 0, 0 };
- SIZE sz = { rc.right - rc.left, rc.bottom - rc.top };
-
- BLENDFUNCTION blend;
- blend.BlendOp = AC_SRC_OVER;
- blend.BlendFlags = 0;
- blend.SourceConstantAlpha = 255;
- blend.AlphaFormat = AC_SRC_ALPHA;
-
- // Fade Out
- if (options.fadeout)
{
- int i;
- for (i = 255; i >= 0; i -= options.fosteps)
- {
- blend.SourceConstantAlpha = i;
- UpdateLayeredWindow(hwndSplash, NULL, &ptDst, &sz, SplashBmp->getDC(), &ptSrc, 0xffffffff, &blend, LWA_ALPHA);
- Sleep(1);
+ RECT rc; GetWindowRect(hwndSplash, &rc);
+ POINT ptDst = { rc.left, rc.top };
+ POINT ptSrc = { 0, 0 };
+ SIZE sz = { rc.right - rc.left, rc.bottom - rc.top };
+
+ BLENDFUNCTION blend;
+ blend.BlendOp = AC_SRC_OVER;
+ blend.BlendFlags = 0;
+ blend.SourceConstantAlpha = 255;
+ blend.AlphaFormat = AC_SRC_ALPHA;
+
+ // Fade Out
+ if (options.fadeout) {
+ int i;
+ for (i = 255; i >= 0; i -= options.fosteps) {
+ blend.SourceConstantAlpha = i;
+ UpdateLayeredWindow(hwndSplash, NULL, &ptDst, &sz, SplashBmp->getDC(), &ptSrc, 0xffffffff, &blend, LWA_ALPHA);
+ Sleep(1);
+ }
}
}
if (bserviceinvoked) bserviceinvoked = false;
if (bpreviewruns) bpreviewruns = false;
DestroyWindow(hwndSplash);
- }
+ break;
case WM_MOUSEMOVE:
- {
if (bserviceinvoked)
PostMessage(hwnd, WM_CLOSE, 0, 0);
break;
- }
case WM_DESTROY:
- {
#ifdef _DEBUG
logMessage(_T("WM_DESTROY"), _T("called"));
#endif
@@ -135,7 +115,6 @@ LRESULT CALLBACK SplashWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM PostQuitMessage(0);
break;
}
- }
return DefWindowProc(hwnd, message, wParam, lParam);
}
@@ -145,8 +124,7 @@ void __cdecl SplashThread(void *arg) IGraphBuilder *pGraph = NULL;
IMediaControl *pControl = NULL;
- if (options.playsnd)
- {
+ if (options.playsnd) {
// Initialize the COM library.
CoInitialize(NULL);
@@ -218,22 +196,18 @@ void __cdecl SplashThread(void *arg) blend.SourceConstantAlpha = 0;
blend.AlphaFormat = AC_SRC_ALPHA;
- if (options.showversion)
- {
+ if (options.showversion) {
// locate text markers:
int i, x = -1, y = -1;
int splashWidth = SplashBmp->getWidth();
for (i = 0; i < splashWidth; ++i)
- if (SplashBmp->getRow(0)[i] & 0xFF000000)
- {
- if (x < 0)
- {
+ if (SplashBmp->getRow(0)[i] & 0xFF000000) {
+ if (x < 0) {
x = i - 1; // 1 pixel for marker line
splashWithMarkers = true;
}
- else
- {
+ else {
x = -1;
splashWithMarkers = false;
break;
@@ -241,15 +215,12 @@ void __cdecl SplashThread(void *arg) }
int splashHeight = SplashBmp->getHeight();
for (i = 0; splashWithMarkers && (i < splashHeight); ++i)
- if (SplashBmp->getRow(i)[0] & 0xFF000000)
- {
- if (y < 0)
- {
+ if (SplashBmp->getRow(i)[0] & 0xFF000000) {
+ if (y < 0) {
y = i - 1; // 1 pixel for marker line
splashWithMarkers = true;
}
- else
- {
+ else {
y = -1;
splashWithMarkers = false;
break;
@@ -264,8 +235,7 @@ void __cdecl SplashThread(void *arg) lf.lfHeight = 14;
mir_tstrcpy(lf.lfFaceName, _T("Verdana"));
SelectObject(SplashBmp->getDC(), CreateFontIndirect(&lf));
- if (!splashWithMarkers)
- {
+ if (!splashWithMarkers) {
SIZE v_sz = { 0, 0 };
GetTextExtentPoint32(SplashBmp->getDC(), verString, (int)mir_tstrlen(verString), &v_sz);
x = SplashBmp->getWidth() / 2 - (v_sz.cx / 2);
@@ -282,11 +252,9 @@ void __cdecl SplashThread(void *arg) ShowWindow(hwndSplash, SW_SHOWNORMAL);
- if (options.fadein)
- {
+ if (options.fadein) {
// Fade in
- for (int i = 0; i < 255; i += options.fisteps)
- {
+ for (int i = 0; i < 255; i += options.fisteps) {
blend.SourceConstantAlpha = i;
UpdateLayeredWindow(hwndSplash, NULL, &ptDst, &sz, SplashBmp->getDC(), &ptSrc, 0xffffffff, &blend, LWA_ALPHA);
Sleep(1);
@@ -295,20 +263,16 @@ void __cdecl SplashThread(void *arg) blend.SourceConstantAlpha = 255;
UpdateLayeredWindow(hwndSplash, NULL, &ptDst, &sz, SplashBmp->getDC(), &ptSrc, 0xffffffff, &blend, LWA_ALPHA);
- if (DWORD(arg) > 0)
- {
- if (SetTimer(hwndSplash, 6, DWORD(arg), 0))
- {
+ if (DWORD(arg) > 0) {
+ if (SetTimer(hwndSplash, 6, DWORD(arg), 0)) {
#ifdef _DEBUG
logMessage(_T("Timer TimeToShow"), _T("set"));
#endif
}
}
else
- if (bmodulesloaded)
- {
- if (SetTimer(hwndSplash, 8, 2000, 0))
- {
+ if (bmodulesloaded) {
+ if (SetTimer(hwndSplash, 8, 2000, 0)) {
#ifdef _DEBUG
logMessage(_T("Timer Modules loaded"), _T("set"));
#endif
@@ -323,8 +287,7 @@ void __cdecl SplashThread(void *arg) DispatchMessage(&msg);
}
- if (options.playsnd)
- {
+ if (options.playsnd) {
pControl->Release();
pGraph->Release();
CoUninitialize();
@@ -344,15 +307,14 @@ BOOL ShowSplash(BOOL bpreview) logMessage(_T("Loading splash file"), szSplashFile);
#endif
- if (!SplashBmp->loadFromFile(szSplashFile, NULL))
+ if (!SplashBmp->loadFromFile(szSplashFile))
return 0;
#ifdef _DEBUG
logMessage(_T("Thread"), _T("start"));
#endif
- if (bpreview)
- {
+ if (bpreview) {
ShowWindow(hwndSplash, SW_HIDE);
DestroyWindow(hwndSplash);
@@ -361,8 +323,7 @@ BOOL ShowSplash(BOOL bpreview) logMessage(_T("Preview"), _T("yes"));
#endif
}
- else
- {
+ else {
timeout = options.showtime;
#ifdef _DEBUG
TCHAR b[40];
@@ -371,14 +332,10 @@ BOOL ShowSplash(BOOL bpreview) #endif
}
- hSplashThread = mir_forkthread(SplashThread, (void*)timeout);
+ mir_forkthread(SplashThread, (void*)timeout);
#ifdef _DEBUG
logMessage(_T("Thread"), _T("end"));
#endif
-
- CloseHandle(hSplashThread);
- hSplashThread = NULL;
-
return 1;
}
\ No newline at end of file diff --git a/protocols/Steam/src/steam_pooling.cpp b/protocols/Steam/src/steam_pooling.cpp index 89768c1a81..b6cb91f56e 100644 --- a/protocols/Steam/src/steam_pooling.cpp +++ b/protocols/Steam/src/steam_pooling.cpp @@ -41,7 +41,7 @@ void CSteamProto::ParsePollData(JSONNODE *data) } else { - AddDBEvent(hContact, EVENTTYPE_MESSAGE, timestamp, DBEF_UTF | DBEF_SENT, mir_strlen(szMessage) + 1, (PBYTE)(char*)szMessage); + AddDBEvent(hContact, EVENTTYPE_MESSAGE, timestamp, DBEF_UTF | DBEF_SENT, (int)mir_strlen(szMessage) + 1, (PBYTE)(char*)szMessage); } } else if (!lstrcmpi(type, _T("typing"))) |