summaryrefslogtreecommitdiff
path: root/Plugins/emoticons/EmoticonsSelectionLayout.cpp
diff options
context:
space:
mode:
authorpescuma <pescuma@c086bb3d-8645-0410-b8da-73a8550f86e7>2008-04-14 04:48:16 +0000
committerpescuma <pescuma@c086bb3d-8645-0410-b8da-73a8550f86e7>2008-04-14 04:48:16 +0000
commit1f4071514a3f75e80c539fcedc4d9603f1cb6b46 (patch)
tree96504bbb586b3dd12fe07918135969c2cb906d75 /Plugins/emoticons/EmoticonsSelectionLayout.cpp
parent6ae86c78a2ab8ab7ee876f9caf11e5c3079284fe (diff)
Allow service calls inside .emo
git-svn-id: http://pescuma.googlecode.com/svn/trunk/Miranda@80 c086bb3d-8645-0410-b8da-73a8550f86e7
Diffstat (limited to 'Plugins/emoticons/EmoticonsSelectionLayout.cpp')
-rw-r--r--Plugins/emoticons/EmoticonsSelectionLayout.cpp61
1 files changed, 56 insertions, 5 deletions
diff --git a/Plugins/emoticons/EmoticonsSelectionLayout.cpp b/Plugins/emoticons/EmoticonsSelectionLayout.cpp
index a30bed0..b593bff 100644
--- a/Plugins/emoticons/EmoticonsSelectionLayout.cpp
+++ b/Plugins/emoticons/EmoticonsSelectionLayout.cpp
@@ -81,6 +81,26 @@ RECT EmoticonsSelectionLayout::CalcRect(TCHAR *txt)
return rc;
}
+#ifdef UNICODE
+
+RECT EmoticonsSelectionLayout::CalcRect(char *txt)
+{
+ HDC hdc = GetDC(hwnd);
+ HFONT hFont = GetFont(hdc);
+ HFONT oldFont = (HFONT) SelectObject(hdc, hFont);
+
+ RECT rc = { 0, 0, 0xFFFF, 0xFFFF };
+ DrawTextA(hdc, txt, strlen(txt), &rc, DT_CALCRECT | DT_NOPREFIX);
+
+ SelectObject(hdc, oldFont);
+ ReleaseFont(hFont);
+
+ ReleaseDC(hwnd, hdc);
+ return rc;
+}
+
+#endif
+
void EmoticonsSelectionLayout::GetEmoticonSize(Emoticon *e, int &width, int &height)
{
width = 0;
@@ -91,9 +111,18 @@ void EmoticonsSelectionLayout::GetEmoticonSize(Emoticon *e, int &width, int &hei
if (e->img == NULL || e->img->img == NULL)
{
- RECT rc = CalcRect(e->texts[0]);
- height = rc.bottom - rc.top + 1;
- width = rc.right - rc.left + 1;
+ if (e->texts.getCount() > 0)
+ {
+ RECT rc = CalcRect(e->texts[0]);
+ height = rc.bottom - rc.top + 1;
+ width = rc.right - rc.left + 1;
+ }
+ else
+ {
+ RECT rc = CalcRect(e->description);
+ height = rc.bottom - rc.top + 1;
+ width = rc.right - rc.left + 1;
+ }
}
}
@@ -102,7 +131,7 @@ int EmoticonsSelectionLayout::GetNumOfCols(int num_emotes)
int cols = num_emotes / MAX_LINES;
if (num_emotes % MAX_LINES != 0)
cols++;
- return min(max(cols, MIN_COLS), MAX_COLS);
+ return min(cols, MAX_COLS);
}
int EmoticonsSelectionLayout::GetNumOfLines(int num_emotes, int cols)
@@ -220,6 +249,21 @@ void EmoticonsSelectionLayout::DrawEmoticonText(HDC hdc, TCHAR *txt, RECT rc)
ReleaseFont(hFont);
}
+#ifdef UNICODE
+
+void EmoticonsSelectionLayout::DrawEmoticonText(HDC hdc, char *txt, RECT rc)
+{
+ HFONT hFont = GetFont(hdc);
+ HFONT oldFont = (HFONT) SelectObject(hdc, hFont);
+
+ DrawTextA(hdc, txt, strlen(txt), &rc, DT_NOPREFIX);
+
+ SelectObject(hdc, oldFont);
+ ReleaseFont(hFont);
+}
+
+#endif
+
void EmoticonsSelectionLayout::DrawEmoticon(HDC hdc, int index, RECT fullRc)
{
Emoticon *e = ssd->module->emoticons[index];
@@ -235,7 +279,14 @@ void EmoticonsSelectionLayout::DrawEmoticon(HDC hdc, int index, RECT fullRc)
if (e->img == NULL || e->img->img == NULL)
{
- DrawEmoticonText(hdc, e->texts[0], rc);
+ if (e->texts.getCount() > 0)
+ {
+ DrawEmoticonText(hdc, e->texts[0], rc);
+ }
+ else
+ {
+ DrawEmoticonText(hdc, e->description, rc);
+ }
}
else
{