summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2014-06-07 18:22:37 +0000
committerGeorge Hazan <george.hazan@gmail.com>2014-06-07 18:22:37 +0000
commitc112e561e0c157cafa38f475cd5c4338070b6579 (patch)
tree268d6deaaca12d7c6d4b326156c2a8f2e287069c /plugins
parent0a23e4d06f01ee608f14fe4efd31baa39b27bb08 (diff)
code cleaning
git-svn-id: http://svn.miranda-ng.org/main/trunk@9418 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins')
-rw-r--r--plugins/Popup/src/skin.cpp1030
-rw-r--r--plugins/Popup/src/skin.h8
2 files changed, 419 insertions, 619 deletions
diff --git a/plugins/Popup/src/skin.cpp b/plugins/Popup/src/skin.cpp
index 9fffea5a7f..6f3d6b2670 100644
--- a/plugins/Popup/src/skin.cpp
+++ b/plugins/Popup/src/skin.cpp
@@ -30,7 +30,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
// PopupSkin
PopupSkin::PopupSkin(LPCTSTR aName)
{
- for (int i=0; i < 32; i++)
+ for (int i = 0; i < 32; i++)
m_flag_names[i] = NULL;
m_elements = 0;
m_name = aName ? mir_tstrdup(aName) : NULL;
@@ -39,34 +39,28 @@ PopupSkin::PopupSkin(LPCTSTR aName)
PopupSkin::~PopupSkin()
{
if (m_name) mir_free(m_name);
- for (int i=0; i < 32; i++)
+ for (int i = 0; i < 32; i++)
mir_free(m_flag_names[i]);
freeSkin(m_elements);
}
SIZE PopupSkin::measureAction(HDC hdc, POPUPACTION *act) const
{
- SIZE sz = {0};
- if (!(PopupOptions.actions&ACT_ENABLE))
+ SIZE sz = { 0 };
+ if (!(PopupOptions.actions & ACT_ENABLE))
return sz;
- if (PopupOptions.actions&ACT_LARGE)
- {
+ if (PopupOptions.actions & ACT_LARGE)
sz.cx = sz.cy = 32;
- } else
- {
+ else
sz.cx = sz.cy = 16;
- }
- if (PopupOptions.actions&ACT_TEXT)
- {
+ if (PopupOptions.actions & ACT_TEXT) {
char *name = strchr(act->lpzTitle, '/');
if (!name) name = act->lpzTitle;
else ++name;
SIZE szText, szSpace;
-
-
LPWSTR wname = mir_a2u(name);
WCHAR *str = TranslateW(wname);
GetTextExtentPoint32W(hdc, str, lstrlenW(str), &szText);
@@ -77,8 +71,8 @@ SIZE PopupSkin::measureAction(HDC hdc, POPUPACTION *act) const
sz.cx += szSpace.cx;
sz.cx += szText.cx;
sz.cy += 2;
- } else
- {
+ }
+ else {
sz.cx += 4;
sz.cy += 4;
}
@@ -88,18 +82,16 @@ SIZE PopupSkin::measureAction(HDC hdc, POPUPACTION *act) const
SIZE PopupSkin::measureActionBar(HDC hdc, PopupWnd2 *wnd) const
{
- SIZE sz = {0};
+ SIZE sz = { 0 };
HFONT hFntSave = (HFONT)SelectObject(hdc, fonts.action);
- for (int i=0; i < wnd->getActionCount(); ++i)
- {
+ for (int i = 0; i < wnd->getActionCount(); ++i) {
SIZE szAction = measureAction(hdc, &wnd->getActions()[i].actionA);
- if (PopupOptions.actions & ACT_TEXT)
- {
+ if (PopupOptions.actions & ACT_TEXT) {
sz.cx = max(sz.cx, szAction.cx);
sz.cy += szAction.cy;
- } else
- {
+ }
+ else {
sz.cx += szAction.cx;
sz.cy = max(sz.cy, szAction.cy);
}
@@ -110,17 +102,16 @@ SIZE PopupSkin::measureActionBar(HDC hdc, PopupWnd2 *wnd) const
void PopupSkin::drawAction(MyBitmap *bmp, POPUPACTION *act, int x, int y, bool hover) const
{
- if (!(PopupOptions.actions&ACT_ENABLE))
+ if (!(PopupOptions.actions & ACT_ENABLE))
return;
bmp->DrawIcon(act->lchIcon,
- (PopupOptions.actions&ACT_TEXT) ? x : (x+2),
+ (PopupOptions.actions & ACT_TEXT) ? x : (x+2),
y+2,
- (PopupOptions.actions&ACT_LARGE) ? 32 : 16,
- (PopupOptions.actions&ACT_LARGE) ? 32 : 16);
+ (PopupOptions.actions & ACT_LARGE) ? 32 : 16,
+ (PopupOptions.actions & ACT_LARGE) ? 32 : 16);
- if (PopupOptions.actions&ACT_TEXT)
- {
+ if (PopupOptions.actions & ACT_TEXT) {
char *name = strchr(act->lpzTitle, '/');
if (!name) name = act->lpzTitle;
else ++name;
@@ -133,41 +124,35 @@ void PopupSkin::drawAction(MyBitmap *bmp, POPUPACTION *act, int x, int y, bool h
GetTextExtentPoint32A(bmp->getDC(), " ", 1, &szSpace);
-
LPWSTR wname = mir_a2u(name);
WCHAR *str = TranslateW(wname);
GetTextExtentPoint32W(bmp->getDC(), str, lstrlenW(str), &szText);
bmp->Draw_TextW(str,
- (PopupOptions.actions&ACT_LARGE) ? (x+szSpace.cx+32) : (x+szSpace.cx+16),
- max(
- y+2,
- y+2 + (((PopupOptions.actions&ACT_LARGE) ? 32 : 16) - szText.cy)/2
- ));
+ (PopupOptions.actions&ACT_LARGE) ? (x + szSpace.cx + 32) : (x + szSpace.cx + 16),
+ max(y + 2, y + 2 + (((PopupOptions.actions&ACT_LARGE) ? 32 : 16) - szText.cy) / 2));
mir_free(wname);
SelectObject(bmp->getDC(), hFntSave);
}
else {
- if (hover)
- {
+ if (hover) {
RECT rc;
rc.left = x;
rc.top = y;
rc.right = x + ((PopupOptions.actions&ACT_LARGE) ? 32 : 16) + 4;
rc.bottom = y + ((PopupOptions.actions&ACT_LARGE) ? 32 : 16) + 4;
- bmp->saveAlpha(rc.left, rc.top, rc.right-rc.left, rc.bottom-rc.top);
+ bmp->saveAlpha(rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top);
HBRUSH hbr = CreateSolidBrush(fonts.clActionHover);
FrameRect(bmp->getDC(), &rc, hbr);
DeleteObject(hbr);
- bmp->restoreAlpha(rc.left, rc.top, rc.right-rc.left, rc.bottom-rc.top);
+ bmp->restoreAlpha(rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top);
}
}
}
void PopupSkin::drawActionBar(MyBitmap *bmp, PopupWnd2 *wnd, int x, int y) const
{
- for (int i=0; i < wnd->getActionCount(); ++i)
- {
+ for (int i = 0; i < wnd->getActionCount(); ++i) {
SIZE szAction = measureAction(bmp->getDC(), &wnd->getActions()[i].actionA);
drawAction(bmp, &wnd->getActions()[i].actionA, x, y, wnd->getActions()[i].hover);
@@ -177,12 +162,9 @@ void PopupSkin::drawActionBar(MyBitmap *bmp, PopupWnd2 *wnd, int x, int y) const
wnd->getActions()[i].rc.bottom = y + szAction.cy;
if (PopupOptions.actions & ACT_TEXT)
- {
y += szAction.cy;
- } else
- {
+ else
x += szAction.cx;
- }
}
}
@@ -195,35 +177,30 @@ void PopupSkin::measure(HDC hdc, PopupWnd2 *wnd, int maxw, POPUPOPTIONS *options
int STYLE_SZ_CLOCK = 0;
if (!this->useInternalClock())
for (head = m_elements; head; head = head->next)
- if ((head->type&ST_TYPEMASK) == ST_CLOCK)
+ if ((head->type & ST_TYPEMASK) == ST_CLOCK)
break;
- if (head && head->myBmp)
- {//layerd clock
+
+ if (head && head->myBmp) {//layerd clock
SIZE szNew;
- szNew.cx = head->clocksize[CLOCK_LEFT]+head->clocksize[CLOCK_RIGHT];
+ szNew.cx = head->clocksize[CLOCK_LEFT] + head->clocksize[CLOCK_RIGHT];
szNew.cy = head->myBmp->getHeight();
- for (char *p = wnd->getTime(); *p; p++)
- {
+ for (char *p = wnd->getTime(); *p; p++) {
if (*p == ':')
- {
szNew.cx += head->clocksize[CLOCK_SEPARATOR];
- } else
- if ((*p >= '0') && (*p <= '9'))
- {
- szNew.cx += head->clocksize[CLOCK_DIGITS+*p-'0'];
- }
+ else if ((*p >= '0') && (*p <= '9'))
+ szNew.cx += head->clocksize[CLOCK_DIGITS + *p - '0'];
}
- wnd->getArgs()->add("clock.width",szNew.cx);
- wnd->getArgs()->add("clock.height",szNew.cy);
+ wnd->getArgs()->add("clock.width", szNew.cx);
+ wnd->getArgs()->add("clock.height", szNew.cy);
STYLE_SZ_CLOCK = szNew.cx;
- } else
- {//normal clock
+ }
+ else { //normal clock
HFONT hfnSave = (HFONT)SelectObject(hdc, fonts.clock);
SIZE sz; GetTextExtentPoint32A(hdc, wnd->getTime(), lstrlenA(wnd->getTime()), &sz);
SelectObject(hdc, hfnSave);
- wnd->getArgs()->add("clock.width",sz.cx+2*STYLE_SZ_GAP);
- wnd->getArgs()->add("clock.height",sz.cy);
- STYLE_SZ_CLOCK = sz.cx+2*STYLE_SZ_GAP;
+ wnd->getArgs()->add("clock.width", sz.cx + 2 * STYLE_SZ_GAP);
+ wnd->getArgs()->add("clock.height", sz.cy);
+ STYLE_SZ_CLOCK = sz.cx + 2 * STYLE_SZ_GAP;
}
wnd->getArgs()->clear();
@@ -231,143 +208,125 @@ void PopupSkin::measure(HDC hdc, PopupWnd2 *wnd, int maxw, POPUPOPTIONS *options
wnd->getArgs()->add("window.width", maxw);
wnd->getArgs()->add("window.maxwidth", maxw);
- for (int i=0; i < 32; ++i)
- {
+ for (int i = 0; i < 32; ++i) {
char buf[10];
mir_snprintf(buf, SIZEOF(buf), "opt%d", i);
- wnd->getArgs()->add(buf, (m_flags&(1L<<i)) ? 1 : 0);
+ wnd->getArgs()->add(buf, (m_flags&(1L << i)) ? 1 : 0);
}
SIZE sz;
sz.cx = sz.cy = 0;
head = m_elements;
- while (head)
- {
- if ((m_flags & head->flag_mask) != (head->flags & head->flag_mask))
- {
+ while (head) {
+ if ((m_flags & head->flag_mask) != (head->flags & head->flag_mask)) {
head = head->next;
continue;
}
- SIZE szNew = {0,0};
- switch (head->type & ST_TYPEMASK)
- {
+ 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())
- {
+ 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_ANSI:
- {
- RECT rc; SetRect(&rc, 0, 0, szNew.cx, 0);
- DrawTextExA(hdc, wnd->getTextA(), lstrlenA(wnd->getTextA()), &rc,
- DT_CALCRECT|DT_EXPANDTABS|DT_LEFT|DT_NOPREFIX|DT_TOP|DT_WORDBREAK/*|DT_RTLREADING*/, NULL);
- szNew.cx = rc.right;
- szNew.cy = rc.bottom;
+ {
+ RECT rc; SetRect(&rc, 0, 0, szNew.cx, 0);
+ DrawTextExA(hdc, wnd->getTextA(), lstrlenA(wnd->getTextA()), &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_UNICODE:
- {
-
- RECT rc; SetRect(&rc, 0, 0, szNew.cx, 0);
- DrawTextExW(hdc, wnd->getTextW(), lstrlenW(wnd->getTextW()), &rc,
- DT_CALCRECT|DT_EXPANDTABS|DT_LEFT|DT_NOPREFIX|DT_TOP|DT_WORDBREAK/*|DT_RTLREADING*/, NULL);
- szNew.cx = rc.right;
- szNew.cy = rc.bottom;
-
+ {
+ RECT rc; SetRect(&rc, 0, 0, szNew.cx, 0);
+ DrawTextExW(hdc, wnd->getTextW(), lstrlenW(wnd->getTextW()), &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;
- 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()->texth = szNew.cy;
- wnd->getRenderInfo()->realtextw = szNew.cx;
+ 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;
+ }
- 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);
+ 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;
- }
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())
{
+ 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_ANSI:
- {
- RECT rc; SetRect(&rc, 0, 0, szNew.cx, 0);
- DrawTextExA(hdc, wnd->getTitleA(), lstrlenA(wnd->getTitleA()), &rc,
- DT_CALCRECT|DT_EXPANDTABS|DT_LEFT|DT_NOPREFIX|DT_TOP|DT_WORDBREAK/*|DT_RTLREADING*/, NULL);
- szNew.cx = rc.right;
- szNew.cy = rc.bottom;
+ {
+ RECT rc; SetRect(&rc, 0, 0, szNew.cx, 0);
+ DrawTextExA(hdc, wnd->getTitleA(), lstrlenA(wnd->getTitleA()), &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_UNICODE:
- {
-
- RECT rc; SetRect(&rc, 0, 0, szNew.cx, 0);
- DrawTextExW(hdc, wnd->getTitleW(), lstrlenW(wnd->getTitleW()), &rc,
- DT_CALCRECT|DT_EXPANDTABS|DT_LEFT|DT_NOPREFIX|DT_TOP|DT_WORDBREAK/*|DT_RTLREADING*/, NULL);
- szNew.cx = rc.right;
- szNew.cy = rc.bottom;
-
+ {
+ RECT rc; SetRect(&rc, 0, 0, szNew.cx, 0);
+ DrawTextExW(hdc, wnd->getTitleW(), lstrlenW(wnd->getTitleW()), &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);
}
- 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;
- wnd->getArgs()->add("icon.width",16);
- wnd->getArgs()->add("icon.height",16);
+ wnd->getArgs()->add("icon.width", 16);
+ wnd->getArgs()->add("icon.height", 16);
break;
case ST_BITMAP:
-// szNew.cx = szNew.cy = 0;
GetBmpSize(head->hbm, &szNew);
break;
@@ -379,64 +338,52 @@ void PopupSkin::measure(HDC hdc, PopupWnd2 *wnd, int maxw, POPUPOPTIONS *options
case ST_AVATAR:
wnd->getRenderInfo()->hasAvatar = false;
szNew.cx = szNew.cy = 0;
- if (wnd->getAvatar())
- {
+ if (wnd->getAvatar()) {
szNew.cx = wnd->getAvatar()->getWidth();
szNew.cy = wnd->getAvatar()->getHeight();
- wnd->getArgs()->add("avatarbitmap.width",max(1,szNew.cx));
- wnd->getArgs()->add("avatarbitmap.height",max(1,szNew.cy));
+ wnd->getArgs()->add("avatarbitmap.width", max(1, szNew.cx));
+ wnd->getArgs()->add("avatarbitmap.height", max(1, szNew.cy));
wnd->getRenderInfo()->hasAvatar = true;
}
break;
case ST_CLOCK:
- if (head && head->myBmp)
- {
- szNew.cx = head->clocksize[CLOCK_LEFT]+head->clocksize[CLOCK_RIGHT];
+ if (head && head->myBmp) {
+ szNew.cx = head->clocksize[CLOCK_LEFT] + head->clocksize[CLOCK_RIGHT];
szNew.cy = head->myBmp->getHeight();
- for (char *p = wnd->getTime(); *p; p++)
- {
+ for (char *p = wnd->getTime(); *p; p++) {
if (*p == ':')
- {
szNew.cx += head->clocksize[CLOCK_SEPARATOR];
- } else
- if ((*p >= '0') && (*p <= '9'))
- {
- szNew.cx += head->clocksize[CLOCK_DIGITS+*p-'0'];
- }
+ else if ((*p >= '0') && (*p <= '9'))
+ szNew.cx += head->clocksize[CLOCK_DIGITS + *p - '0'];
}
- wnd->getArgs()->add("clock.width",szNew.cx);
- wnd->getArgs()->add("clock.height",szNew.cy);
- } else
- {
+ wnd->getArgs()->add("clock.width", szNew.cx);
+ wnd->getArgs()->add("clock.height", szNew.cy);
+ }
+ else {
HFONT hfnSave = (HFONT)SelectObject(hdc, fonts.clock);
SIZE sz; GetTextExtentPoint32A(hdc, wnd->getTime(), lstrlenA(wnd->getTime()), &sz);
SelectObject(hdc, hfnSave);
- wnd->getArgs()->add("clock.width",sz.cx+2*STYLE_SZ_GAP);
- wnd->getArgs()->add("clock.height",sz.cy);
+ wnd->getArgs()->add("clock.width", sz.cx + 2 * STYLE_SZ_GAP);
+ wnd->getArgs()->add("clock.height", sz.cy);
}
break;
}
- if (head->proportional && szNew.cx && szNew.cy && (((head->fw.eval(wnd->getArgs()) > 0) && !head->fh.eval(wnd->getArgs())) || (!head->fw.eval(wnd->getArgs()) && (head->fh.eval(wnd->getArgs()) > 0))))
- {
- if (head->fw.eval(wnd->getArgs()))
- {
+ if (head->proportional && szNew.cx && szNew.cy && (((head->fw.eval(wnd->getArgs()) > 0) && !head->fh.eval(wnd->getArgs())) || (!head->fw.eval(wnd->getArgs()) && (head->fh.eval(wnd->getArgs()) > 0)))) {
+ if (head->fw.eval(wnd->getArgs())) {
szNew.cy = szNew.cy * head->fw.eval(wnd->getArgs()) / szNew.cx;
szNew.cx = head->fw.eval(wnd->getArgs());
- } else
- {
+ }
+ else {
szNew.cx = szNew.cx * head->fh.eval(wnd->getArgs()) / szNew.cy;
szNew.cy = head->fh.eval(wnd->getArgs());
-// szNew.cx = head->fx.eval(wnd->getArgs()) + szNew.cx * head->fh.eval(wnd->getArgs()) / szNew.cy;
-// szNew.cy = head->fy.eval(wnd->getArgs()) + head->fh.eval(wnd->getArgs());
}
}
- if ((head->type & ST_TYPEMASK) == ST_AVATAR)
- {
- wnd->getArgs()->add("avatar.width",szNew.cx);
- wnd->getArgs()->add("avatar.height",szNew.cy);
+ if ((head->type & ST_TYPEMASK) == ST_AVATAR) {
+ wnd->getArgs()->add("avatar.width", szNew.cx);
+ wnd->getArgs()->add("avatar.height", szNew.cy);
szNew.cy += 2;
}
@@ -444,26 +391,24 @@ void PopupSkin::measure(HDC hdc, PopupWnd2 *wnd, int maxw, POPUPOPTIONS *options
if (!head->fw.eval(wnd->getArgs()))
szNew.cx += head->fx.eval(wnd->getArgs());
else
- if (head->fw.eval(wnd->getArgs()) > 0)
- szNew.cx = head->fx.eval(wnd->getArgs()) + head->fw.eval(wnd->getArgs());
- else
- szNew.cx = 0;
+ if (head->fw.eval(wnd->getArgs()) > 0)
+ szNew.cx = head->fx.eval(wnd->getArgs()) + head->fw.eval(wnd->getArgs());
+ else
+ szNew.cx = 0;
if (!head->fh.eval(wnd->getArgs()))
szNew.cy += head->fy.eval(wnd->getArgs());
else
- if (head->fh.eval(wnd->getArgs()) > 0)
- szNew.cy = head->fy.eval(wnd->getArgs()) + head->fh.eval(wnd->getArgs());
- else
- szNew.cy = 0;
+ if (head->fh.eval(wnd->getArgs()) > 0)
+ szNew.cy = head->fy.eval(wnd->getArgs()) + head->fh.eval(wnd->getArgs());
+ else
+ szNew.cy = 0;
if (head->fx.eval(wnd->getArgs()) >= 0 && szNew.cx > sz.cx) sz.cx = szNew.cx;
if (head->fy.eval(wnd->getArgs()) >= 0 && szNew.cy > sz.cy) sz.cy = szNew.cy;
head = head->next;
}
-// if (pw->title_height > 20)
-// sz.cy += pw->title_height - 20;
sz.cx += m_right_gap;
sz.cy += m_bottom_gap;
@@ -473,17 +418,14 @@ void PopupSkin::measure(HDC hdc, PopupWnd2 *wnd, int maxw, POPUPOPTIONS *options
if (tmp = m_fw.eval(wnd->getArgs())) sz.cx = tmp;
if (tmp = m_fh.eval(wnd->getArgs())) sz.cy = tmp;
- if (options->DynamicResize)
- {
+ if (options->DynamicResize) {
if (options->UseMinimumWidth && sz.cx < options->MinimumWidth)
sz.cx = options->MinimumWidth;
- } else
- {
- sz.cx = options->MaximumWidth;
}
+ else sz.cx = options->MaximumWidth;
- wnd->getArgs()->add("window.width",sz.cx);
- wnd->getArgs()->add("window.height",sz.cy);
+ wnd->getArgs()->add("window.width", sz.cx);
+ wnd->getArgs()->add("window.height", sz.cy);
wnd->setSize(sz);
}
@@ -497,33 +439,27 @@ void PopupSkin::display(MyBitmap *bmp, PopupWnd2 *wnd, int maxw, POPUPOPTIONS *o
int STYLE_SZ_CLOCK = 0;
if (!this->useInternalClock())
for (head = m_elements; head; head = head->next)
- if ((head->type&ST_TYPEMASK) == ST_CLOCK)
+ if ((head->type & ST_TYPEMASK) == ST_CLOCK)
break;
- if (head && head->myBmp)
- {
+
+ if (head && head->myBmp) {
SIZE szNew;
- szNew.cx = head->clocksize[CLOCK_LEFT]+head->clocksize[CLOCK_RIGHT];
+ szNew.cx = head->clocksize[CLOCK_LEFT] + head->clocksize[CLOCK_RIGHT];
szNew.cy = head->myBmp->getHeight();
- for (char *p = wnd->getTime(); *p; p++)
- {
+ for (char *p = wnd->getTime(); *p; p++) {
if (*p == ':')
- {
szNew.cx += head->clocksize[CLOCK_SEPARATOR];
- } else
- if ((*p >= '0') && (*p <= '9'))
- {
- szNew.cx += head->clocksize[CLOCK_DIGITS+*p-'0'];
- }
+ else if ((*p >= '0') && (*p <= '9'))
+ szNew.cx += head->clocksize[CLOCK_DIGITS + *p - '0'];
}
STYLE_SZ_CLOCK = szNew.cx;
- } else
- {
+ }
+ else {
HFONT hfnSave = (HFONT)SelectObject(hdc, fonts.clock);
SIZE sz; GetTextExtentPoint32A(hdc, wnd->getTime(), lstrlenA(wnd->getTime()), &sz);
SelectObject(hdc, hfnSave);
- STYLE_SZ_CLOCK = sz.cx + 2*STYLE_SZ_GAP;
+ STYLE_SZ_CLOCK = sz.cx + 2 * STYLE_SZ_GAP;
}
-
head = m_elements;
@@ -531,164 +467,139 @@ void PopupSkin::display(MyBitmap *bmp, PopupWnd2 *wnd, int maxw, POPUPOPTIONS *o
SIZE szWnd = wnd->getSize();
SIZE pos;
bool actionsRendered = false;
- while (head)
- {
- if ((head->type&ST_TYPEMASK) == ST_AVATAR)
- {
- if (wnd->getAvatar()->isAnimated() && !(drawFlags&DF_ANIMATE))
- {
+ while (head) {
+ if ((head->type & ST_TYPEMASK) == ST_AVATAR) {
+ if (wnd->getAvatar()->isAnimated() && !(drawFlags & DF_ANIMATE)) {
head = head->next;
continue;
}
- if (!wnd->getAvatar()->isAnimated() && !(drawFlags&DF_STATIC))
- {
+ if (!wnd->getAvatar()->isAnimated() && !(drawFlags & DF_STATIC)) {
head = head->next;
continue;
}
- } else
- if ((head->type&ST_TYPEMASK) == ST_TEXT)
- {
- if (!wnd->getActionCount() && !(drawFlags&DF_STATIC))
- {
+ }
+ else if ((head->type & ST_TYPEMASK) == ST_TEXT) {
+ if (!wnd->getActionCount() && !(drawFlags & DF_STATIC)) {
head = head->next;
continue;
}
- } else
- if (!(drawFlags&DF_STATIC))
- {
+ }
+ else if (!(drawFlags & DF_STATIC)) {
head = head->next;
continue;
}
- if ((head->type&ST_BADPOS) || ((m_flags & head->flag_mask) != (head->flags & head->flag_mask)))
- {
+ if ((head->type & ST_BADPOS) || ((m_flags & head->flag_mask) != (head->flags & head->flag_mask))) {
head = head->next;
continue;
}
int hShift = 0;
- switch (head->type & ST_TYPEMASK)
- {
+ switch (head->type & ST_TYPEMASK) {
case ST_TEXT:
- {
if (head->textColor != (COLORREF)0xffffffff)
SetTextColor(hdc, head->textColor);
else
SetTextColor(hdc, wnd->getTextColor());
-
- POINT pos;
- pos.x = head->fx.eval(wnd->getArgs());
- pos.y = head->fy.eval(wnd->getArgs());
- SIZE sz;
- sz.cx = wnd->getRenderInfo()->textw;
- sz.cy = 1000;
-
- SetRect(&wnd->getRenderInfo()->textRect, pos.x, pos.y,
- pos.x + wnd->getRenderInfo()->realtextw,
- pos.y + wnd->getRenderInfo()->texth);
-
- if ((drawFlags&DF_STATIC) && !wnd->isTextEmpty())
{
- HFONT hFntSave = (HFONT)SelectObject(hdc, fonts.text);
- bmp->saveAlpha();
- switch (wnd->getTextType())
- {
+ POINT pos;
+ pos.x = head->fx.eval(wnd->getArgs());
+ pos.y = head->fy.eval(wnd->getArgs());
+ SIZE sz;
+ sz.cx = wnd->getRenderInfo()->textw;
+ sz.cy = 1000;
+
+ SetRect(&wnd->getRenderInfo()->textRect, pos.x, pos.y,
+ pos.x + wnd->getRenderInfo()->realtextw,
+ pos.y + wnd->getRenderInfo()->texth);
+
+ if ((drawFlags&DF_STATIC) && !wnd->isTextEmpty()) {
+ HFONT hFntSave = (HFONT)SelectObject(hdc, fonts.text);
+ bmp->saveAlpha();
+ switch (wnd->getTextType()) {
case PopupWnd2::TT_ANSI:
{
- RECT rc; SetRect(&rc, pos.x, pos.y, pos.x+sz.cx, pos.y+sz.cy);
+ RECT rc; SetRect(&rc, pos.x, pos.y, pos.x + sz.cx, pos.y + sz.cy);
DrawTextExA(hdc, wnd->getTextA(), lstrlenA(wnd->getTextA()), &rc,
- DT_EXPANDTABS|DT_LEFT|DT_NOPREFIX|DT_TOP|DT_WORDBREAK/*|DT_RTLREADING*/, NULL);
- break;
+ DT_EXPANDTABS | DT_LEFT | DT_NOPREFIX | DT_TOP | DT_WORDBREAK/*|DT_RTLREADING*/, NULL);
}
+ break;
case PopupWnd2::TT_UNICODE:
{
-
- RECT rc; SetRect(&rc, pos.x, pos.y, pos.x+sz.cx, pos.y+sz.cy);
+ RECT rc; SetRect(&rc, pos.x, pos.y, pos.x + sz.cx, pos.y + sz.cy);
DrawTextExW(hdc, wnd->getTextW(), lstrlenW(wnd->getTextW()), &rc,
- DT_EXPANDTABS|DT_LEFT|DT_NOPREFIX|DT_TOP|DT_WORDBREAK/*|DT_RTLREADING*/, NULL);
-
- break;
+ 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());
+ MText.Display(hdc, pos, sz, wnd->getTextM());
break;
}
+ SelectObject(hdc, hFntSave);
+ bmp->restoreAlpha();
}
- SelectObject(hdc, hFntSave);
- bmp->restoreAlpha();
- }
- if (!actionsRendered && (drawFlags&DF_ANIMATE))
- {
- int textAreaWidth = head->fw.eval(wnd->getArgs());
- if (textAreaWidth <= 0) textAreaWidth = wnd->getRenderInfo()->realtextw;
+ if (!actionsRendered && (drawFlags&DF_ANIMATE)) {
+ int textAreaWidth = head->fw.eval(wnd->getArgs());
+ if (textAreaWidth <= 0) textAreaWidth = wnd->getRenderInfo()->realtextw;
- drawActionBar(bmp, wnd,
- db_get_b(NULL, MODULNAME, "CenterActions", 0) ?
- (pos.x + (textAreaWidth - wnd->getRenderInfo()->actw)/2) :
- (PopupOptions.actions&ACT_RIGHTICONS) ?
+ drawActionBar(bmp, wnd,
+ db_get_b(NULL, MODULNAME, "CenterActions", 0) ?
+ (pos.x + (textAreaWidth - wnd->getRenderInfo()->actw) / 2) :
+ (PopupOptions.actions&ACT_RIGHTICONS) ?
(pos.x + textAreaWidth - wnd->getRenderInfo()->actw) :
- // else
+ // else
pos.x,
- pos.y + wnd->getRenderInfo()->texth + 3);
+ pos.y + wnd->getRenderInfo()->texth + 3);
- actionsRendered = true;
+ actionsRendered = true;
+ }
}
-
-
break;
- }
case ST_TITLE:
- {
if (head->textColor != (COLORREF)0xffffffff)
SetTextColor(hdc, head->textColor);
else
SetTextColor(hdc, wnd->getTitleColor());
-
- bmp->saveAlpha();
- POINT pos;
- pos.x = head->fx.eval(wnd->getArgs());
- pos.y = head->fy.eval(wnd->getArgs());
- SIZE sz;
- sz.cx = wnd->getRenderInfo()->titlew;
- sz.cy = 1000;
-
- switch (wnd->getTextType())
{
+ bmp->saveAlpha();
+ POINT pos;
+ pos.x = head->fx.eval(wnd->getArgs());
+ pos.y = head->fy.eval(wnd->getArgs());
+ SIZE sz;
+ sz.cx = wnd->getRenderInfo()->titlew;
+ sz.cy = 1000;
+
+ switch (wnd->getTextType()) {
case PopupWnd2::TT_ANSI:
{
HFONT hFntSave = (HFONT)SelectObject(hdc, fonts.title);
- RECT rc; SetRect(&rc, pos.x, pos.y, pos.x+sz.cx, pos.y+sz.cy);
+ RECT rc; SetRect(&rc, pos.x, pos.y, pos.x + sz.cx, pos.y + sz.cy);
DrawTextExA(hdc, wnd->getTitleA(), lstrlenA(wnd->getTitleA()), &rc,
- DT_EXPANDTABS|DT_LEFT|DT_NOPREFIX|DT_TOP|DT_WORDBREAK/*|DT_RTLREADING*/, NULL);
+ DT_EXPANDTABS | DT_LEFT | DT_NOPREFIX | DT_TOP | DT_WORDBREAK/*|DT_RTLREADING*/, NULL);
SelectObject(hdc, hFntSave);
- break;
}
+ break;
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);
+ RECT rc; SetRect(&rc, pos.x, pos.y, pos.x + sz.cx, pos.y + sz.cy);
DrawTextExW(hdc, wnd->getTitleW(), lstrlenW(wnd->getTitleW()), &rc,
- DT_EXPANDTABS|DT_LEFT|DT_NOPREFIX|DT_TOP|DT_WORDBREAK/*|DT_RTLREADING*/, NULL);
+ DT_EXPANDTABS | DT_LEFT | DT_NOPREFIX | DT_TOP | DT_WORDBREAK/*|DT_RTLREADING*/, NULL);
SelectObject(hdc, hFntSave);
-
- break;
}
+ break;
case PopupWnd2::TT_MTEXT:
- {
HFONT hFntSave = (HFONT)SelectObject(hdc, fonts.title);
- MText.Display(hdc, pos, sz, wnd->getTitleM());
+ MText.Display(hdc, pos, sz, wnd->getTitleM());
SelectObject(hdc, hFntSave);
break;
}
- }
- bmp->restoreAlpha();
+ bmp->restoreAlpha();
+ }
break;
- }
case ST_ICON:
bmp->DrawIcon(wnd->getIcon(), head->fx.eval(wnd->getArgs()), head->fy.eval(wnd->getArgs()), 16, 16);
@@ -697,41 +608,26 @@ void PopupSkin::display(MyBitmap *bmp, PopupWnd2 *wnd, int maxw, POPUPOPTIONS *o
case ST_MYBITMAP:
sz.cx = head->myBmp->getWidth();
sz.cy = head->myBmp->getHeight();
-/*
- if (head->fh.eval(wnd->getArgs()) > 0)
- sz.cy = head->fh.eval(wnd->getArgs());
- else
- if (head->fh.eval(wnd->getArgs()) < 0)
- sz.cy = szWnd.cy - head->fy.eval(wnd->getArgs()) + head->fh.eval(wnd->getArgs());
- if (head->fw.eval(wnd->getArgs()) > 0)
- sz.cx = head->fw.eval(wnd->getArgs());
- else
- if (head->fw.eval(wnd->getArgs()) < 0)
- sz.cx = szWnd.cx - head->fx.eval(wnd->getArgs()) + head->fw.eval(wnd->getArgs());
-*/
- if (head->proportional && sz.cx && sz.cy && (((head->fw.eval(wnd->getArgs()) > 0) && !head->fh.eval(wnd->getArgs())) || (!head->fw.eval(wnd->getArgs()) && (head->fh.eval(wnd->getArgs()) > 0))))
- {
- if (head->fw.eval(wnd->getArgs()))
- {
+ if (head->proportional && sz.cx && sz.cy && (((head->fw.eval(wnd->getArgs()) > 0) && !head->fh.eval(wnd->getArgs())) || (!head->fw.eval(wnd->getArgs()) && (head->fh.eval(wnd->getArgs()) > 0)))) {
+ if (head->fw.eval(wnd->getArgs())) {
sz.cy = sz.cy * head->fw.eval(wnd->getArgs()) / sz.cx;
sz.cx = head->fw.eval(wnd->getArgs());
- } else
- {
+ }
+ else {
sz.cx = sz.cx * head->fh.eval(wnd->getArgs()) / sz.cy;
sz.cy = head->fh.eval(wnd->getArgs());
}
- } else
- {
+ }
+ else {
if (head->fh.eval(wnd->getArgs()) > 0)
sz.cy = head->fh.eval(wnd->getArgs());
- else
- if (head->fh.eval(wnd->getArgs()) < 0)
+ else if (head->fh.eval(wnd->getArgs()) < 0)
sz.cy = szWnd.cy - head->fy.eval(wnd->getArgs()) + head->fh.eval(wnd->getArgs()) + 1;
+
if (head->fw.eval(wnd->getArgs()) > 0)
sz.cx = head->fw.eval(wnd->getArgs());
- else
- if (head->fw.eval(wnd->getArgs()) < 0)
+ else if (head->fw.eval(wnd->getArgs()) < 0)
sz.cx = szWnd.cx - head->fx.eval(wnd->getArgs()) + head->fw.eval(wnd->getArgs()) + 1;
}
@@ -739,124 +635,105 @@ void PopupSkin::display(MyBitmap *bmp, PopupWnd2 *wnd, int maxw, POPUPOPTIONS *o
pos.cx = ((head->fx.eval(wnd->getArgs(), &vars) < 0) && !vars) ? szWnd.cx + head->fx.eval(wnd->getArgs()) : head->fx.eval(wnd->getArgs());
pos.cy = ((head->fy.eval(wnd->getArgs(), &vars) < 0) && !vars) ? szWnd.cy + head->fy.eval(wnd->getArgs()) : head->fy.eval(wnd->getArgs());
- if (head->type & ST_MONO)
- {
+ if (head->type & ST_MONO) {
COLORREF back = wnd->getBackColor();
if (head->type & ST_BLEND)
- {
bmp->BlendColorized(head->myBmp, pos.cx, pos.cy, sz.cx, sz.cy, back);
- } else
- {
+ else
bmp->DrawColorized(head->myBmp, pos.cx, pos.cy, sz.cx, sz.cy, back);
- }
- } else
- {
+ }
+ else {
if (head->type & ST_BLEND)
- {
- bmp->Blend(head->myBmp, pos.cx, pos.cy, sz.cx ,sz.cy);
- } else
- {
- bmp->Draw(head->myBmp, pos.cx, pos.cy, sz.cx ,sz.cy);
- }
+ bmp->Blend(head->myBmp, pos.cx, pos.cy, sz.cx, sz.cy);
+ else
+ bmp->Draw(head->myBmp, pos.cx, pos.cy, sz.cx, sz.cy);
}
break;
case ST_AVATAR:
- {
- if (!wnd->getAvatar()) break;
-
- sz.cx = wnd->getAvatar()->getWidth();
- sz.cy = wnd->getAvatar()->getHeight();
-
- if (head->proportional && sz.cx && sz.cy && (((head->fw.eval(wnd->getArgs()) > 0) && !head->fh.eval(wnd->getArgs())) || (!head->fw.eval(wnd->getArgs()) && (head->fh.eval(wnd->getArgs()) > 0))))
- {
- if (head->fw.eval(wnd->getArgs()))
- {
- sz.cy = sz.cy * head->fw.eval(wnd->getArgs()) / sz.cx;
- sz.cx = head->fw.eval(wnd->getArgs());
- } else
- {
- sz.cx = sz.cx * head->fh.eval(wnd->getArgs()) / sz.cy;
- sz.cy = head->fh.eval(wnd->getArgs());
+ if (wnd->getAvatar()) {
+ sz.cx = wnd->getAvatar()->getWidth();
+ sz.cy = wnd->getAvatar()->getHeight();
+
+ if (head->proportional && sz.cx && sz.cy && (((head->fw.eval(wnd->getArgs()) > 0) && !head->fh.eval(wnd->getArgs())) || (!head->fw.eval(wnd->getArgs()) && (head->fh.eval(wnd->getArgs()) > 0)))) {
+ if (head->fw.eval(wnd->getArgs())) {
+ sz.cy = sz.cy * head->fw.eval(wnd->getArgs()) / sz.cx;
+ sz.cx = head->fw.eval(wnd->getArgs());
+ }
+ else {
+ sz.cx = sz.cx * head->fh.eval(wnd->getArgs()) / sz.cy;
+ sz.cy = head->fh.eval(wnd->getArgs());
+ }
+ }
+ else {
+ if (head->fh.eval(wnd->getArgs()) > 0)
+ sz.cy = head->fh.eval(wnd->getArgs());
+ else if (head->fh.eval(wnd->getArgs()) < 0)
+ sz.cy = szWnd.cy - head->fy.eval(wnd->getArgs()) + head->fh.eval(wnd->getArgs());
+
+ if (head->fw.eval(wnd->getArgs()) > 0)
+ sz.cx = head->fw.eval(wnd->getArgs());
+ else if (head->fw.eval(wnd->getArgs()) < 0)
+ sz.cx = szWnd.cx - head->fx.eval(wnd->getArgs()) + head->fw.eval(wnd->getArgs());
}
- } else
- {
- if (head->fh.eval(wnd->getArgs()) > 0)
- sz.cy = head->fh.eval(wnd->getArgs());
- else
- if (head->fh.eval(wnd->getArgs()) < 0)
- sz.cy = szWnd.cy - head->fy.eval(wnd->getArgs()) + head->fh.eval(wnd->getArgs());
-
- if (head->fw.eval(wnd->getArgs()) > 0)
- sz.cx = head->fw.eval(wnd->getArgs());
- else
- if (head->fw.eval(wnd->getArgs()) < 0)
- sz.cx = szWnd.cx - head->fx.eval(wnd->getArgs()) + head->fw.eval(wnd->getArgs());
- }
- pos.cx = head->fx.eval(wnd->getArgs()) < 0 ? szWnd.cx + head->fx.eval(wnd->getArgs()) - sz.cx : head->fx.eval(wnd->getArgs());
- pos.cy = head->fy.eval(wnd->getArgs()) < 0 ? szWnd.cy + head->fy.eval(wnd->getArgs()) - sz.cy : head->fy.eval(wnd->getArgs());
+ pos.cx = head->fx.eval(wnd->getArgs()) < 0 ? szWnd.cx + head->fx.eval(wnd->getArgs()) - sz.cx : head->fx.eval(wnd->getArgs());
+ pos.cy = head->fy.eval(wnd->getArgs()) < 0 ? szWnd.cy + head->fy.eval(wnd->getArgs()) - sz.cy : head->fy.eval(wnd->getArgs());
- wnd->getAvatar()->draw(bmp, pos.cx, pos.cy, sz.cx, sz.cy, options);
+ wnd->getAvatar()->draw(bmp, pos.cx, pos.cy, sz.cx, sz.cy, options);
+ }
break;
- }
case ST_CLOCK:
- {
- if (!options->DisplayTime)
- break;
-
- COLORREF back = wnd->getBackColor();
- int x = head->fx.eval(wnd->getArgs());
- int y = head->fy.eval(wnd->getArgs());
- if (head->myBmp)
- {
- int sy = head->myBmp->getHeight();
- if (head->type & ST_MONO)
- bmp->BlendPartColorized(head->myBmp, head->clockstart[CLOCK_LEFT], 0, head->clocksize[CLOCK_LEFT], sy, x, y, head->clocksize[CLOCK_LEFT], sy, back);
- else
- bmp->BlendPart(head->myBmp, head->clockstart[CLOCK_LEFT], 0, head->clocksize[CLOCK_LEFT], sy, x, y, head->clocksize[CLOCK_LEFT], sy);
- x += head->clocksize[CLOCK_LEFT];
- for (char *p = wnd->getTime(); *p; p++)
- {
- int clock_idx = -1;
- if (*p == ':')
- {
- clock_idx = CLOCK_SEPARATOR;
- } else
- if ((*p >= '0') && (*p <= '9'))
- {
- clock_idx = CLOCK_DIGITS + *p - '0';
- }
-
- if (clock_idx >= 0)
- {
- if (head->type & ST_MONO)
- bmp->BlendPartColorized(head->myBmp, head->clockstart[clock_idx], 0, head->clocksize[clock_idx], sy, x, y, head->clocksize[clock_idx], sy, back);
- else
- bmp->BlendPart(head->myBmp, head->clockstart[clock_idx], 0, head->clocksize[clock_idx], sy, x, y, head->clocksize[clock_idx], sy);
- x += head->clocksize[clock_idx];
+ if (options->DisplayTime) {
+ COLORREF back = wnd->getBackColor();
+ int x = head->fx.eval(wnd->getArgs());
+ int y = head->fy.eval(wnd->getArgs());
+ if (head->myBmp) {
+ int sy = head->myBmp->getHeight();
+ if (head->type & ST_MONO)
+ bmp->BlendPartColorized(head->myBmp, head->clockstart[CLOCK_LEFT], 0, head->clocksize[CLOCK_LEFT], sy, x, y, head->clocksize[CLOCK_LEFT], sy, back);
+ else
+ bmp->BlendPart(head->myBmp, head->clockstart[CLOCK_LEFT], 0, head->clocksize[CLOCK_LEFT], sy, x, y, head->clocksize[CLOCK_LEFT], sy);
+
+ x += head->clocksize[CLOCK_LEFT];
+ for (char *p = wnd->getTime(); *p; p++) {
+ int clock_idx = -1;
+ if (*p == ':')
+ clock_idx = CLOCK_SEPARATOR;
+ else if ((*p >= '0') && (*p <= '9'))
+ clock_idx = CLOCK_DIGITS + *p - '0';
+
+ if (clock_idx >= 0) {
+ if (head->type & ST_MONO)
+ bmp->BlendPartColorized(head->myBmp, head->clockstart[clock_idx], 0, head->clocksize[clock_idx], sy, x, y, head->clocksize[clock_idx], sy, back);
+ else
+ bmp->BlendPart(head->myBmp, head->clockstart[clock_idx], 0, head->clocksize[clock_idx], sy, x, y, head->clocksize[clock_idx], sy);
+ x += head->clocksize[clock_idx];
+ }
}
+ if (head->type & ST_MONO)
+ bmp->BlendPartColorized(head->myBmp, head->clockstart[CLOCK_RIGHT], 0, head->clocksize[CLOCK_RIGHT], sy, x, y, head->clocksize[CLOCK_RIGHT], sy, back);
+ else
+ bmp->BlendPart(head->myBmp, head->clockstart[CLOCK_RIGHT], 0, head->clocksize[CLOCK_RIGHT], sy, x, y, head->clocksize[CLOCK_RIGHT], sy);
+ x += head->clocksize[CLOCK_RIGHT];
}
- if (head->type & ST_MONO)
- bmp->BlendPartColorized(head->myBmp, head->clockstart[CLOCK_RIGHT], 0, head->clocksize[CLOCK_RIGHT], sy, x, y, head->clocksize[CLOCK_RIGHT], sy, back);
- else
- bmp->BlendPart(head->myBmp, head->clockstart[CLOCK_RIGHT], 0, head->clocksize[CLOCK_RIGHT], sy, x, y, head->clocksize[CLOCK_RIGHT], sy);
- x += head->clocksize[CLOCK_RIGHT];
- } else
- {
- SetTextColor(hdc, wnd->getClockColor());
- HFONT hfnSave = (HFONT)SelectObject(bmp->getDC(), fonts.clock);
- SIZE sz; GetTextExtentPoint32A(bmp->getDC(), wnd->getTime(), lstrlenA(wnd->getTime()), &sz);
- bmp->Draw_TextA(wnd->getTime(), x, y);
- SelectObject(bmp->getDC(), hfnSave);
+ else {
+ if (head->textColor != (COLORREF)0xffffffff)
+ SetTextColor(hdc, head->textColor);
+ else
+ SetTextColor(hdc, wnd->getClockColor());
+
+ HFONT hfnSave = (HFONT)SelectObject(bmp->getDC(), fonts.clock);
+ SIZE sz; GetTextExtentPoint32A(bmp->getDC(), wnd->getTime(), lstrlenA(wnd->getTime()), &sz);
+ bmp->Draw_TextA(wnd->getTime(), x, y);
+ SelectObject(bmp->getDC(), hfnSave);
+ }
+ break;
}
- break;
- }
}
head = head->next;
}
-
}
bool PopupSkin::onMouseMove(PopupWnd2 *wnd, int x, int y) const
@@ -868,12 +745,10 @@ bool PopupSkin::onMouseMove(PopupWnd2 *wnd, int x, int y) const
bool res = false;
bool hovered = false;
- for (int i=0; i < wnd->getActionCount(); ++i)
- {
+ for (int i = 0; i < wnd->getActionCount(); ++i) {
bool hover = PtInRect(&wnd->getActions()[i].rc, pt) ? true : false;
hovered |= hover;
- if (wnd->getActions()[i].hover != hover)
- {
+ if (wnd->getActions()[i].hover != hover) {
wnd->getActions()[i].hover = hover;
res = true;
}
@@ -888,10 +763,8 @@ bool PopupSkin::onMouseLeave(PopupWnd2 *wnd) const
{
bool res = false;
- for (int i=0; i < wnd->getActionCount(); ++i)
- {
- if (wnd->getActions()[i].hover)
- {
+ for (int i = 0; i < wnd->getActionCount(); ++i) {
+ if (wnd->getActions()[i].hover) {
wnd->getActions()[i].hover = false;
res = true;
}
@@ -905,16 +778,13 @@ bool PopupSkin::onMouseLeave(PopupWnd2 *wnd) const
void PopupSkin::loadOptions(std::istream &f)
{
char *buf = new char[1024];
- while (!f.eof())
- {
+ while (!f.eof()) {
f >> buf;
- if (*buf == '#')
- {
+ if (*buf == '#') {
f.ignore(1024, '\n');
continue;
}
- if (!strcmp(buf, "option"))
- {
+ if (!strcmp(buf, "option")) {
int id, val;
f >> id >> val;
f.getline(buf, 1024);
@@ -932,49 +802,41 @@ void PopupSkin::loadOptions(std::istream &f)
m_flags |= 1 << id;
else
m_flags &= ~(1 << id);
- } else
- if (!strcmp(buf, "end"))
- {
- break;
}
+ else if (!strcmp(buf, "end"))
+ break;
}
- delete [] buf;
+ delete[] buf;
}
bool PopupSkin::load(LPCTSTR dir)
{
- for (int i=0; i < 32; i++)
- {
- if (m_flag_names[i])
- {
+ for (int i = 0; i < 32; i++) {
+ if (m_flag_names[i]) {
mir_free(m_flag_names[i]);
m_flag_names[i] = NULL;
}
}
m_flags = 0;
- if (!_tcsncmp(_T("res:"), dir, 4))
- { // resource
- loadSkin(dir+4, _T("Skin"));
- } else
- { // filesystem
+ if (!_tcsncmp(_T("res:"), dir, 4)) // resource
+ loadSkin(dir + 4, _T("Skin"));
+ else { // filesystem
// skin info
TCHAR dir_save[1024];
GetCurrentDirectory(1024, dir_save);
SetCurrentDirectory(dir);
-
+
std::ifstream theFile;
theFile.open("popupskin.config", std::ios::in);
- if (theFile)
- {
+ if (theFile) {
loadOptions(theFile);
theFile.close();
}
WIN32_FIND_DATA ffd;
HANDLE hFind = FindFirstFile(_T("*.popupskin"), &ffd);
- while (hFind != INVALID_HANDLE_VALUE)
- {
+ while (hFind != INVALID_HANDLE_VALUE) {
loadSkin(ffd.cFileName);
break;
if (!FindNextFile(hFind, &ffd))
@@ -1003,69 +865,56 @@ void PopupSkin::loadSkin(std::istream &f)
head->type = ST_NOTHING;
head->next = NULL;
- while (!f.eof())
- {
+ while (!f.eof()) {
char buf[1024];
f >> buf;
-// fscanf(f, "%s", buf);
if (!*buf)
continue;
- if (*buf == '#' || *buf == ';')
- {
+ if (*buf == '#' || *buf == ';') {
f.ignore(1024, '\n');
continue;
}
- if (!lstrcmpA(buf,"popup-version"))
- {
+ if (!lstrcmpA(buf, "popup-version")) {
f >> m_popup_version;
- m_popup_version = PLUGIN_MAKE_VERSION((m_popup_version/1000000)%100, (m_popup_version/10000)%100, (m_popup_version/100)%100, (m_popup_version/1)%100);
+ m_popup_version = PLUGIN_MAKE_VERSION((m_popup_version / 1000000) % 100, (m_popup_version / 10000) % 100, (m_popup_version / 100) % 100, (m_popup_version / 1) % 100);
if (!isCompatible())
break;
- } else
- if (!lstrcmpA(buf,"padding-right"))
- {
+ }
+ else if (!lstrcmpA(buf, "padding-right")) {
f >> m_right_gap;
- } else
- if (!lstrcmpA(buf,"padding-bottom"))
- {
+ }
+ else if (!lstrcmpA(buf, "padding-bottom")) {
f >> m_bottom_gap;
- } else
- if (!lstrcmpA(buf,"shadow-region-opacity"))
- {
+ }
+ else if (!lstrcmpA(buf, "shadow-region-opacity")) {
f >> m_shadow_region_opacity;
- } else
- if (!lstrcmpA(buf,"legacy-region-opacity"))
- {
+ }
+ else if (!lstrcmpA(buf, "legacy-region-opacity")) {
f >> m_legacy_region_opacity;
- } else
- if (!lstrcmpA(buf,"w"))
- {
+ }
+ else if (!lstrcmpA(buf, "w")) {
f.getline(buf, 1024);
m_fw.set(buf);
- } else
- if (!lstrcmpA(buf,"h"))
- {
+ }
+ else if (!lstrcmpA(buf, "h")) {
f.getline(buf, 1024);
m_fh.set(buf);
- } else
- if (!lstrcmpA(buf,"object"))
- {
+ }
+ else if (!lstrcmpA(buf, "object")) {
head->next = loadObject(f);
if (head->next && ((head->next->type & ST_TYPEMASK) == ST_CLOCK))
m_internalClock = false;
head = head->next;
head->next = NULL;
- } else
- if (!lstrcmpA(buf,"options"))
- {
+ }
+ else if (!lstrcmpA(buf, "options")) {
loadOptions(f);
}
}
-
head = m_elements;
m_elements = m_elements->next;
delete head;
@@ -1086,10 +935,8 @@ void PopupSkin::loadSkin(LPCTSTR fn)
void PopupSkin::loadSkin(LPCTSTR lpName, LPCTSTR lpType)
{
HRSRC hRes = FindResource(hInst, lpName, lpType);
-// DWORD ResSize = SizeofResource(hInst,hRes);
- HRSRC hResLoad = (HRSRC)LoadResource(hInst, hRes);
+ HRSRC hResLoad = (HRSRC)LoadResource(hInst, hRes);
char *lpResLock = (char *)LockResource(hResLoad);
-// lpResLock [ResSize] = 0;
std::istringstream stream(lpResLock);
loadSkin(stream);
UnlockResource(lpResLock);
@@ -1098,11 +945,7 @@ void PopupSkin::loadSkin(LPCTSTR lpName, LPCTSTR lpType)
PopupSkin::SKINELEMENT *PopupSkin::loadObject(std::istream &f)
{
-// char pth[1024];
-// GetSkinPath(pth,1024);
-
SKINELEMENT *element = new SKINELEMENT;
-// element->x = element->y = element->w = element->h = 0;
element->proportional = 0;
element->type = ST_NOTHING|ST_BADPOS;
element->next = NULL;
@@ -1110,135 +953,109 @@ PopupSkin::SKINELEMENT *PopupSkin::loadObject(std::istream &f)
element->flags = 0;
element->myBmp = NULL;
- while (!f.eof())
- {
+ while (!f.eof()) {
char buf[1024];
f >> buf;
if (!*buf)
continue;
- if (*buf == '#' || *buf == ';')
- {
+ if (*buf == '#' || *buf == ';') {
f.ignore(1024, '\n');
continue;
}
- if (!lstrcmpA(buf,"type"))
- {
+ if (!lstrcmpA(buf, "type")) {
f >> buf;
- if (!lstrcmpA(buf,"icon"))
- element->type = ( element->type & ~ST_TYPEMASK ) | ST_ICON;
- else
- if (!lstrcmpA(buf,"bitmap"))
- element->type = ( element->type & ~ST_TYPEMASK ) | ST_MYBITMAP;
- else
- if (!lstrcmpA(buf,"text"))
- {
- element->type = ( element->type & ~ST_TYPEMASK ) | ST_TEXT;
+ if (!lstrcmpA(buf, "icon"))
+ element->type = (element->type & ~ST_TYPEMASK) | ST_ICON;
+ else if (!lstrcmpA(buf, "bitmap"))
+ element->type = (element->type & ~ST_TYPEMASK) | ST_MYBITMAP;
+ else if (!lstrcmpA(buf, "text")) {
+ element->type = (element->type & ~ST_TYPEMASK) | ST_TEXT;
element->textColor = (COLORREF)0xffffffff;
element->hfn = 0;
}
- else
- if (!lstrcmpA(buf,"title"))
- {
- element->type = ( element->type & ~ST_TYPEMASK ) | ST_TITLE;
+ else if (!lstrcmpA(buf, "title")) {
+ element->type = (element->type & ~ST_TYPEMASK) | ST_TITLE;
element->textColor = (COLORREF)0xffffffff;
element->hfn = 0;
- } else
- if (!lstrcmpA(buf,"avatar"))
- {
- element->type = ( element->type & ~ST_TYPEMASK ) | ST_AVATAR;
- } else
- if (!lstrcmpA(buf,"clock"))
- {
- element->type = ( element->type & ~ST_TYPEMASK ) | ST_CLOCK;
}
- } else
- if (!lstrcmpA(buf,"source"))
- {
+ else if (!lstrcmpA(buf, "avatar")) {
+ element->type = (element->type & ~ST_TYPEMASK) | ST_AVATAR;
+ }
+ else if (!lstrcmpA(buf, "clock")) {
+ element->type = (element->type & ~ST_TYPEMASK) | ST_CLOCK;
+ element->textColor = (COLORREF)0xffffffff;
+ element->hfn = 0;
+ }
+ }
+ else if (!lstrcmpA(buf, "source")) {
f >> buf;
-// fscanf(f, "%*[\x01-\x20]%[^\n]", buf);
-// if ( (element->type & ST_TYPEMASK ) == ST_BITMAP)
-// element->hbm = LoadImageFromFile(buf);
-// else
- if (((element->type & ST_TYPEMASK) == ST_MYBITMAP) || ((element->type & ST_TYPEMASK) == ST_CLOCK))
- {
+ if (((element->type & ST_TYPEMASK) == ST_MYBITMAP) || ((element->type & ST_TYPEMASK) == ST_CLOCK)) {
char *alpha = mir_strdup(buf);
- alpha[strlen(alpha)-1] = 'a';
- element->myBmp = new MyBitmap(buf,alpha);
+ alpha[strlen(alpha) - 1] = 'a';
+ element->myBmp = new MyBitmap(buf, alpha);
mir_free(alpha);
}
- } else
- if (!lstrcmpA(buf,"mono"))
- {
+ }
+ else if (!lstrcmpA(buf, "mono")) {
element->type |= ST_MONO;
- } else
- if (!lstrcmpA(buf,"layer"))
- {
+ }
+ else if (!lstrcmpA(buf, "layer")) {
element->type |= ST_BLEND;
- } else
- if (!lstrcmpA(buf,"proportional"))
- {
+ }
+ else if (!lstrcmpA(buf, "proportional")) {
f >> element->proportional;
- } else
- if (!lstrcmpA(buf,"x"))
- {
+ }
+ else if (!lstrcmpA(buf, "x")) {
f.getline(buf, 1024);
element->fx.set(buf);
element->type &= ~ST_BADPOS;
- } else
- if (!lstrcmpA(buf,"y"))
- {
+ }
+ else if (!lstrcmpA(buf, "y")) {
f.getline(buf, 1024);
element->fy.set(buf);
element->type &= ~ST_BADPOS;
- } else
- if (!lstrcmpA(buf,"w"))
- {
+ }
+ else if (!lstrcmpA(buf, "w")) {
f.getline(buf, 1024);
element->fw.set(buf);
- } else
- if (!lstrcmpA(buf,"h"))
- {
+ }
+ else if (!lstrcmpA(buf, "h")) {
f.getline(buf, 1024);
element->fh.set(buf);
- } else
- if (!lstrcmpA(buf,"ifset"))
- {
+ }
+ else if (!lstrcmpA(buf, "ifset")) {
int id;
f >> id; id--;
element->flag_mask |= 1 << id;
element->flags |= 1 << id;
- } else
- if (!lstrcmpA(buf,"ifnotset"))
- {
+ }
+ else if (!lstrcmpA(buf, "ifnotset")) {
int id;
f >> id; id--;
element->flag_mask |= 1 << id;
element->flags &= ~(1 << id);
- } else
- if (!lstrcmpA(buf,"color"))
- {
+ }
+ else if (!lstrcmpA(buf, "color")) {
if (((element->type & ST_TYPEMASK) != ST_TEXT) &&
- ((element->type & ST_TYPEMASK) != ST_TITLE)) continue;
+ ((element->type & ST_TYPEMASK) != ST_TITLE) &&
+ ((element->type & ST_TYPEMASK) != ST_CLOCK)) continue;
- int r,g,b;
+ int r, g, b;
f >> r >> g >> b;
- element->textColor = RGB(r,g,b);
- } else
- if (!lstrcmpA(buf,"clocksize"))
- {
- element->clockstart[0]=0;
+ element->textColor = RGB(r, g, b);
+ }
+ else if (!lstrcmpA(buf, "clocksize")) {
+ element->clockstart[0] = 0;
f >> element->clocksize[0];
- for (int i = 1; i < CLOCK_ITEMS; i++)
- {
- element->clockstart[i]=element->clockstart[i-1]+element->clocksize[i-1];
+ for (int i = 1; i < CLOCK_ITEMS; i++) {
+ element->clockstart[i] = element->clockstart[i - 1] + element->clocksize[i - 1];
f >> element->clocksize[i];
}
- } else
- if (!lstrcmpA(buf,"end"))
- {
+ }
+ else if (!lstrcmpA(buf, "end")) {
break;
}
}
@@ -1247,8 +1064,7 @@ PopupSkin::SKINELEMENT *PopupSkin::loadObject(std::istream &f)
void PopupSkin::freeSkin(SKINELEMENT *head)
{
- while (head)
- {
+ while (head) {
SKINELEMENT *next = head->next;
if ((head->type & ST_TYPEMASK) == ST_BITMAP)
@@ -1266,18 +1082,14 @@ void PopupSkin::freeSkin(SKINELEMENT *head)
void PopupSkin::saveOpts() const
{
char buf[128];
-
mir_snprintf(buf, sizeof(buf), "skin.%.120S", m_name);
-
db_set_dw(NULL, MODULNAME, buf, m_flags);
}
void PopupSkin::loadOpts() const
{
char buf[128];
-
mir_snprintf(buf, sizeof(buf), "skin.%.120S", m_name);
-
m_flags = db_get_dw(NULL, MODULNAME, buf, m_flags);
}
@@ -1291,11 +1103,10 @@ Skins::Skins()
Skins::~Skins()
{
- while (m_skins)
- {
+ while (m_skins) {
SKINLIST *next = m_skins->next;
delete m_skins->skin;
- delete [] m_skins->dir;
+ delete[] m_skins->dir;
mir_free(m_skins->name); // this is allocated with mir_strdup()
delete m_skins;
m_skins = next;
@@ -1304,11 +1115,10 @@ Skins::~Skins()
bool Skins::load(LPCTSTR dir1)
{
- while (m_skins)
- {
+ while (m_skins) {
SKINLIST *next = m_skins->next;
mir_free(m_skins->name);
- delete [] m_skins->dir;
+ delete[] m_skins->dir;
delete m_skins->skin;
delete m_skins;
m_skins = next;
@@ -1322,18 +1132,18 @@ bool Skins::load(LPCTSTR dir1)
lstrcpy(m_skins->dir, _T("res:classic.popupskin"));
m_skins->skin = 0;
- TCHAR dir[1024]={'\0'};
+ TCHAR dir[1024] = { '\0' };
if (ServiceExists(MS_FOLDERS_GET_PATH)) {
if (FoldersGetCustomPathT(folderId, dir, 1024, NULL) != 0)
return false;
}
else {
- GetModuleFileName(hInst,dir,1024);
- dir[lstrlen(dir)-18] = 0;
- lstrcat(dir,_T("\\skins\\popup"));
+ GetModuleFileName(hInst, dir, 1024);
+ dir[lstrlen(dir) - 18] = 0;
+ lstrcat(dir, _T("\\skins\\popup"));
DWORD fa = GetFileAttributes(dir);
- if ((fa==INVALID_FILE_ATTRIBUTES) || !(fa&FILE_ATTRIBUTE_DIRECTORY))
+ if ((fa == INVALID_FILE_ATTRIBUTES) || !(fa&FILE_ATTRIBUTE_DIRECTORY))
return false;
}
@@ -1343,10 +1153,8 @@ bool Skins::load(LPCTSTR dir1)
WIN32_FIND_DATA ffd;
HANDLE hFind = FindFirstFile(_T("*.*"), &ffd);
- while (hFind != INVALID_HANDLE_VALUE)
- {
- if ((ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) && lstrcmp(_T("."), ffd.cFileName) && lstrcmp(_T(".."), ffd.cFileName))
- {
+ while (hFind != INVALID_HANDLE_VALUE) {
+ if ((ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) && lstrcmp(_T("."), ffd.cFileName) && lstrcmp(_T(".."), ffd.cFileName)) {
SetCurrentDirectory(ffd.cFileName);
SKINLIST *skin = new SKINLIST;
@@ -1373,12 +1181,10 @@ bool Skins::load(LPCTSTR dir1)
const PopupSkin *Skins::getSkin(LPCTSTR name)
{
SKINLIST *any = 0;
- for (SKINLIST *p = m_skins; p; p = p->next)
- {
+ for (SKINLIST *p = m_skins; p; p = p->next) {
if (!lstrcmp(p->name, _T("* Popup Classic")) || !any)
any = p;
- if (!lstrcmpi(p->name, name))
- {
+ if (!lstrcmpi(p->name, name)) {
any = p;
break;
}
@@ -1403,8 +1209,7 @@ const PopupSkin *Skins::getSkin(LPCTSTR name)
void Skins::loadActiveSkin()
{
for (SKINLIST *p = m_skins; p; p = p->next)
- if (!lstrcmpi(p->name, PopupOptions.SkinPack))
- {
+ if (!lstrcmpi(p->name, PopupOptions.SkinPack)) {
if (p->skin)
break;
@@ -1417,8 +1222,7 @@ void Skins::loadActiveSkin()
void Skins::freeAllButActive()
{
for (SKINLIST *p = m_skins; p; p = p->next)
- if (lstrcmpi(p->name, PopupOptions.SkinPack))
- {
+ if (lstrcmpi(p->name, PopupOptions.SkinPack)) {
delete p->skin;
p->skin = NULL;
}
diff --git a/plugins/Popup/src/skin.h b/plugins/Popup/src/skin.h
index c8ac79688b..6f66b54187 100644
--- a/plugins/Popup/src/skin.h
+++ b/plugins/Popup/src/skin.h
@@ -78,12 +78,7 @@ public:
HICON hic;
HBITMAP hbm;
MyBitmap *myBmp;
- struct
- {
- COLORREF textColor;
- HFONT hfn;
-// int textw;
- };
+ HFONT hfn;
};
unsigned long flags;
unsigned long flag_mask;
@@ -91,6 +86,7 @@ public:
int clocksize[CLOCK_ITEMS];
int clockstart[CLOCK_ITEMS];
int proportional;
+ COLORREF textColor;
SKINELEMENT *next;
};