diff options
author | George Hazan <george.hazan@gmail.com> | 2015-06-02 15:55:48 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2015-06-02 15:55:48 +0000 |
commit | ab53b72bf7067feb9dede0fd76b5a3cbc13863b9 (patch) | |
tree | 677a18bc997d1cf118379b288a7c2dd2c160d9b1 /plugins/Popup/src/skin.cpp | |
parent | 1c229f90bfc6c8032bd2d20e297e97f321eb4db7 (diff) |
- old PNG conversion code (png2dib, dib2png) removed;
- m_png.h also removed;
- all calls of LoadImage replaced with CallService(MS_IMG_LOAD);
- four invalid CloseHandle() calls removed;
- massive code cleaning for Popup, HistoryStats & SplashScreen plugins
git-svn-id: http://svn.miranda-ng.org/main/trunk@13974 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/Popup/src/skin.cpp')
-rw-r--r-- | plugins/Popup/src/skin.cpp | 166 |
1 files changed, 81 insertions, 85 deletions
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;
|