summaryrefslogtreecommitdiff
path: root/plugins/SmileyAdd/src/general.cpp
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2013-11-10 11:41:26 +0000
committerGeorge Hazan <george.hazan@gmail.com>2013-11-10 11:41:26 +0000
commit0f954168b4bac9877e79f9150e7689cf67b98d10 (patch)
tree5132ce0e6550ff96acadfc34b685ea24218f0da4 /plugins/SmileyAdd/src/general.cpp
parent09fba0e6c57fe19189150de73a7a9ad7f3462224 (diff)
last portion of fixes
git-svn-id: http://svn.miranda-ng.org/main/trunk@6855 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/SmileyAdd/src/general.cpp')
-rw-r--r--plugins/SmileyAdd/src/general.cpp61
1 files changed, 18 insertions, 43 deletions
diff --git a/plugins/SmileyAdd/src/general.cpp b/plugins/SmileyAdd/src/general.cpp
index 2d736ae9e8..b10c77cdae 100644
--- a/plugins/SmileyAdd/src/general.cpp
+++ b/plugins/SmileyAdd/src/general.cpp
@@ -46,40 +46,29 @@ int CalculateTextHeight(HDC hdc, CHARFORMAT2* chf)
return fontSize.cy;
}
-
HICON GetDefaultIcon(bool copy)
{
HICON resIco = Skin_GetIcon("SmileyAdd_ButtonSmiley");
- if ( resIco == NULL || resIco == (HICON)CALLSERVICE_NOTFOUND )
- {
- resIco = (HICON)LoadImage(g_hInst, MAKEINTRESOURCE(IDI_SMILINGICON),
- IMAGE_ICON, 0, 0, copy ? 0 : LR_SHARED);
- }
- else
- {
- if (copy)
- {
- resIco = (HICON)CopyImage(resIco, IMAGE_ICON, 0, 0, 0);
- Skin_ReleaseIcon("SmileyAdd_ButtonSmiley");
- }
+ if (resIco == NULL)
+ resIco = (HICON)LoadImage(g_hInst, MAKEINTRESOURCE(IDI_SMILINGICON), IMAGE_ICON, 0, 0, copy ? 0 : LR_SHARED);
+ else if (copy) {
+ resIco = (HICON)CopyImage(resIco, IMAGE_ICON, 0, 0, 0);
+ Skin_ReleaseIcon("SmileyAdd_ButtonSmiley");
}
return resIco;
}
-
const TCHAR* GetImageExt(CMString &fname)
{
const TCHAR* ext = _T("");
int fileId = _topen(fname.c_str(), O_RDONLY | _O_BINARY);
- if (fileId != -1)
- {
+ if (fileId != -1) {
BYTE buf[6];
int bytes = _read(fileId, buf, sizeof(buf));
- if (bytes > 4)
- {
+ if (bytes > 4) {
if ( *(unsigned short*)buf == 0xd8ff )
ext = _T("jpg");
else if ( *(unsigned short*)buf == 0x4d42 )
@@ -94,8 +83,6 @@ const TCHAR* GetImageExt(CMString &fname)
return ext;
}
-
-
HICON ImageList_GetIconFixed (HIMAGELIST himl, INT i, UINT fStyle)
{
ICONINFO ii;
@@ -150,22 +137,19 @@ void pathToAbsolute(const CMString& pSrc, CMString& pOut)
{
TCHAR szOutPath[MAX_PATH];
- TCHAR* szVarPath = Utils_ReplaceVarsT(pSrc.c_str());
- if (szVarPath == (TCHAR*)CALLSERVICE_NOTFOUND || szVarPath == NULL)
- {
+ TCHAR *szVarPath = Utils_ReplaceVarsT(pSrc.c_str());
+ if (szVarPath == (TCHAR*)CALLSERVICE_NOTFOUND || szVarPath == NULL) {
TCHAR szExpPath[MAX_PATH];
ExpandEnvironmentStrings(pSrc.c_str(), szExpPath, SIZEOF(szExpPath));
PathToAbsoluteT(szExpPath, szOutPath);
}
- else
- {
+ else {
PathToAbsoluteT(szVarPath, szOutPath);
mir_free(szVarPath);
}
pOut = szOutPath;
}
-
/////////////////////////////////////////////////////////////////////////////////////////
// UrlDecode - converts URL chars like %20 into printable characters
@@ -181,16 +165,12 @@ void UrlDecode(char* str)
{
char* s = str, *d = str;
- while(*s)
- {
- if (*s == '%')
- {
+ while(*s) {
+ if (*s == '%') {
int digit1 = SingleHexToDecimal(s[1]);
- if ( digit1 != -1 )
- {
+ if (digit1 != -1) {
int digit2 = SingleHexToDecimal(s[2]);
- if ( digit2 != -1 )
- {
+ if (digit2 != -1) {
s += 3;
*d++ = (char)((digit1 << 4) | digit2);
continue;
@@ -211,15 +191,11 @@ bool InitGdiPlus(void)
static const TCHAR errmsg[] = _T("GDI+ not installed.\n")
_T("GDI+ can be downloaded here: http://www.microsoft.com/downloads");
- __try
- {
+ __try {
if (g_gdiplusToken == 0 && !gdiPlusFail)
- {
Gdiplus::GdiplusStartup(&g_gdiplusToken, &gdiplusStartupInput, NULL);
- }
}
- __except ( EXCEPTION_EXECUTE_HANDLER )
- {
+ __except(EXCEPTION_EXECUTE_HANDLER) {
gdiPlusFail = true;
ReportError(errmsg);
}
@@ -229,8 +205,7 @@ bool InitGdiPlus(void)
void DestroyGdiPlus(void)
{
- if (g_gdiplusToken != 0)
- {
+ if (g_gdiplusToken != 0) {
Gdiplus::GdiplusShutdown(g_gdiplusToken);
g_gdiplusToken = 0;
}
@@ -262,4 +237,4 @@ void ReportError(const TCHAR* errmsg)
pd.iSeconds = -1;
if (PUAddPopupT(&pd) == CALLSERVICE_NOTFOUND)
MessageBox(NULL, errmsg, title, MB_OK | MB_ICONWARNING | MB_TOPMOST);
-} \ No newline at end of file
+}