summaryrefslogtreecommitdiff
path: root/plugins/MyDetails
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2012-07-20 08:18:28 +0000
committerGeorge Hazan <george.hazan@gmail.com>2012-07-20 08:18:28 +0000
commitc1c83bf5790a1adfeccd1e948e321ac3a7e3e54c (patch)
tree96238507bc618241b4598a3a1ab0df0286ebc43c /plugins/MyDetails
parent9984e12867718ad6b6c4973cf30e5b00d4005d14 (diff)
- skinning for a frame
- human-readable protocol names - code cleaning git-svn-id: http://svn.miranda-ng.org/main/trunk@1066 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/MyDetails')
-rw-r--r--plugins/MyDetails/commons.h3
-rw-r--r--plugins/MyDetails/data.cpp54
-rw-r--r--plugins/MyDetails/data.h2
-rw-r--r--plugins/MyDetails/frame.cpp756
-rw-r--r--plugins/MyDetails/options.cpp173
5 files changed, 411 insertions, 577 deletions
diff --git a/plugins/MyDetails/commons.h b/plugins/MyDetails/commons.h
index eeff18a681..51a1d02d52 100644
--- a/plugins/MyDetails/commons.h
+++ b/plugins/MyDetails/commons.h
@@ -82,7 +82,6 @@ extern long status_msg_dialog_open;
#include "../utils/mir_options.h"
#include "../utils/mir_icons.h"
-
#define PS_SETMYAVATAR "/SetMyAvatar"
#define PS_GETMYAVATAR "/GetMyAvatar"
#define PS_GETMYAVATARMAXSIZE "/GetMyAvatarMaxSize"
@@ -91,7 +90,6 @@ extern long status_msg_dialog_open;
#define PS_GETMYNICKNAMEMAXLENGTH "/GetMyNicknameMaxLength"
-
// See if a protocol service exists
__inline static int ProtoServiceExists(const char *szModule,const char *szService)
{
@@ -101,7 +99,6 @@ __inline static int ProtoServiceExists(const char *szModule,const char *szServic
return ServiceExists(str);
}
-
// Helper
static __inline int DRAW_TEXT(HDC hDC, LPCTSTR lpString, int nCount, LPRECT lpRect, UINT uFormat, const char *protocol,
SmileysParseInfo parseInfo)
diff --git a/plugins/MyDetails/data.cpp b/plugins/MyDetails/data.cpp
index 63892b0785..ffe701cccd 100644
--- a/plugins/MyDetails/data.cpp
+++ b/plugins/MyDetails/data.cpp
@@ -21,46 +21,35 @@ Boston, MA 02111-1307, USA.
#include "commons.h"
#include "data.h"
-
static char *StatusModeToDbSetting(int status,const char *suffix);
-
-
ProtocolArray *protocols = NULL;
-
void InitProtocolData()
{
- PROTOCOLDESCRIPTOR **protos;
- int i, count;
-
- CallService(MS_PROTO_ENUMPROTOCOLS, (WPARAM)&count, (LPARAM)&protos);
+ PROTOACCOUNT **protos;
+ int count;
+ CallService(MS_PROTO_ENUMACCOUNTS, (WPARAM)&count, (LPARAM)&protos);
protocols = new ProtocolArray(count);
- for (i = 0; i < count; i++)
- {
- if (protos[i]->type != PROTOTYPE_PROTOCOL)
+ for (int i = 0; i < count; i++) {
+ PROTOACCOUNT* acc = protos[i];
+ if (acc->type != PROTOTYPE_PROTOCOL)
continue;
- if (protos[i]->szName == NULL || protos[i]->szName[0] == '\0')
+ if (acc->szModuleName == NULL || acc->szModuleName[0] == '\0')
continue;
// Found a protocol
- Protocol *p = new Protocol(protos[i]->szName);
-
- if (p->IsValid())
- {
+ Protocol *p = new Protocol(acc->szModuleName, acc->tszAccountName);
+ if ( p->IsValid())
protocols->Add(p);
- }
else
- {
delete p;
- }
}
}
-
void DeInitProtocolData()
{
delete protocols;
@@ -69,12 +58,11 @@ void DeInitProtocolData()
// Protocol Class ///////////////////////////////////////////////////////////////////////////////////////////
-
-Protocol::Protocol(const char *aName)
+Protocol::Protocol(const char *aName, const TCHAR* descr)
{
lstrcpynA(name, aName, SIZEOF(name));
+ lstrcpyn(description, descr, SIZEOF(description));
- description[0] = _T('\0');
nickname[0] = _T('\0');
status_message[0] = _T('\0');
listening_to[0] = _T('\0');
@@ -85,12 +73,8 @@ Protocol::Protocol(const char *aName)
data_changed = true;
// Load services
-
- int caps;
-
- caps = CallProtoService(name, PS_GETCAPS, PFLAGNUM_1, 0);
+ int caps = CallProtoService(name, PS_GETCAPS, PFLAGNUM_1, 0);
valid = (caps & PF1_IM) == PF1_IM && strcmp(aName, "MetaContacts");
-
if ( !valid)
return;
@@ -106,10 +90,6 @@ Protocol::Protocol(const char *aName)
if (ProtoServiceExists(name, PS_GETMYAVATARMAXSIZE))
CallProtoService(name, PS_GETMYAVATARMAXSIZE, (WPARAM) &avatar_max_width, (LPARAM) &avatar_max_height);
- char tmp[100];
- CallProtoService(name, PS_GETNAME, SIZEOF(tmp), (LPARAM)tmp);
- lstrcpyn(description, _A2T(tmp), SIZEOF(description));
-
can_set_nick = ProtoServiceExists(name, PS_SETMYNICKNAME) != FALSE;
// Initial value
@@ -470,7 +450,7 @@ TCHAR * Protocol::GetListeningTo()
}
DBVARIANT dbv = {0};
- if (DBGetContactSettingTString(NULL, name, "ListeningTo", &dbv))
+ if ( DBGetContactSettingTString(NULL, name, "ListeningTo", &dbv))
{
lcopystr(listening_to, _T(""), SIZEOF(listening_to));
return listening_to;
@@ -495,13 +475,9 @@ ProtocolArray::ProtocolArray(int max_size)
ProtocolArray::~ProtocolArray()
{
- if (buffer != NULL)
- {
+ if (buffer != NULL) {
for ( int i = 0 ; i < buffer_len ; i++ )
- {
delete buffer[i];
- }
-
free(buffer);
}
}
@@ -622,7 +598,7 @@ void ProtocolArray::SetStatusMsgs(int status, const TCHAR *message)
DBWriteContactSettingTString(NULL,"SRAway",StatusModeToDbSetting(status,"Msg"),message);
// Save default also
- if ( !DBGetContactSettingByte(NULL,"SRAway",StatusModeToDbSetting(status,"UsePrev"),0))
+ if ( !db_get_b(NULL,"SRAway",StatusModeToDbSetting(status,"UsePrev"),0))
DBWriteContactSettingTString(NULL,"SRAway",StatusModeToDbSetting(status,"Default"),message);
for ( int i = 0 ; i < buffer_len ; i++ )
diff --git a/plugins/MyDetails/data.h b/plugins/MyDetails/data.h
index 4f3a560ce9..d8c75beda4 100644
--- a/plugins/MyDetails/data.h
+++ b/plugins/MyDetails/data.h
@@ -60,7 +60,7 @@ public:
// Methods ///////////////
- Protocol(const char *name);
+ Protocol(const char *name, const TCHAR *descr);
~Protocol();
bool IsValid();
diff --git a/plugins/MyDetails/frame.cpp b/plugins/MyDetails/frame.cpp
index 03aecc7664..a4ce6f2afc 100644
--- a/plugins/MyDetails/frame.cpp
+++ b/plugins/MyDetails/frame.cpp
@@ -17,16 +17,12 @@ not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
-
#include "commons.h"
-#include "frame.h"
-#include "wingdi.h"
-#include "winuser.h"
+#include <m_skin_eng.h>
// Prototypes /////////////////////////////////////////////////////////////////////////////////////
-
#define WINDOW_NAME_PREFIX "mydetails_window"
#define WINDOW_CLASS_NAME _T("MyDetailsFrame")
#define CONTAINER_CLASS_NAME _T("MyDetailsFrameContainer")
@@ -92,8 +88,6 @@ INT_PTR ShowFrameFunc(WPARAM wParam, LPARAM lParam);
INT_PTR HideFrameFunc(WPARAM wParam, LPARAM lParam);
INT_PTR ShowHideFrameFunc(WPARAM wParam, LPARAM lParam);
-
-
LRESULT CALLBACK FrameContainerWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
LRESULT CALLBACK FrameWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
void SetCycleTime();
@@ -158,7 +152,7 @@ struct MyDetailsFrameData
int protocol_number;
bool showing_menu;
-
+ bool skinning;
bool recalc_rectangles;
bool get_status_messages;
@@ -264,8 +258,7 @@ int CreateFrame()
wndclass.lpszClassName = WINDOW_CLASS_NAME;
RegisterClass(&wndclass);
- if (ServiceExists(MS_CLIST_FRAMES_ADDFRAME))
- {
+ if (ServiceExists(MS_CLIST_FRAMES_ADDFRAME)) {
hwnd_frame = CreateWindow(WINDOW_CLASS_NAME, TranslateT("My Details"),
WS_CHILD | WS_VISIBLE,
0,0,10,10, (HWND)CallService(MS_CLUI_GETHWND, 0, 0), NULL, hInst, NULL);
@@ -277,32 +270,27 @@ int CreateFrame()
Frame.cbSize = sizeof(CLISTFrame);
Frame.hWnd = hwnd_frame;
Frame.align = alTop;
- Frame.Flags = F_VISIBLE | F_SHOWTB | F_SHOWTBTIP | F_NOBORDER;
+ Frame.Flags = F_VISIBLE | F_SHOWTB | F_SHOWTBTIP | F_NOBORDER | F_SKINNED;
Frame.height = 100;
-
frame_id = CallService(MS_CLIST_FRAMES_ADDFRAME, (WPARAM)&Frame, 0);
-
- if (DBGetContactSettingByte(NULL, "MyDetails", "ForceHideFrame", 0))
- {
+ if ( db_get_b(NULL, "MyDetails", "ForceHideFrame", 0)) {
int flags = CallService(MS_CLIST_FRAMES_GETFRAMEOPTIONS, MAKEWPARAM(FO_FLAGS, frame_id), 0);
if (flags & F_VISIBLE)
CallService(MS_CLIST_FRAMES_SHFRAME, frame_id, 0);
- DBDeleteContactSetting(NULL, "MyDetails", "ForceHideFrame");
+ db_unset(NULL, "MyDetails", "ForceHideFrame");
}
- if (DBGetContactSettingByte(NULL, "MyDetails", "ForceShowFrame", 0))
- {
+ if ( db_get_b(NULL, "MyDetails", "ForceShowFrame", 0)) {
int flags = CallService(MS_CLIST_FRAMES_GETFRAMEOPTIONS, MAKEWPARAM(FO_FLAGS, frame_id), 0);
if (!(flags & F_VISIBLE))
CallService(MS_CLIST_FRAMES_SHFRAME, frame_id, 0);
- DBDeleteContactSetting(NULL, "MyDetails", "ForceShowFrame");
+ db_unset(NULL, "MyDetails", "ForceShowFrame");
}
}
- else
- {
+ else {
wndclass.style = CS_DBLCLKS | CS_HREDRAW | CS_VREDRAW;//CS_HREDRAW | CS_VREDRAW;
wndclass.lpfnWndProc = FrameContainerWindowProc;
wndclass.cbClsExtra = 0;
@@ -340,8 +328,7 @@ int CreateFrame()
menu.pszService= MODULE_NAME "/ShowHideMyDetails";
hMenuShowHideFrame = Menu_AddMainMenuItem(&menu);
- if (DBGetContactSettingByte(0, MODULE_NAME, SETTING_FRAME_VISIBLE, 1) == 1)
- {
+ if ( db_get_b(0, MODULE_NAME, SETTING_FRAME_VISIBLE, 1) == 1) {
ShowWindow(hwnd_container, SW_SHOW);
FixMainMenu();
}
@@ -350,7 +337,6 @@ int CreateFrame()
CreateServiceFunction(MS_MYDETAILS_SHOWFRAME, ShowFrameFunc);
CreateServiceFunction(MS_MYDETAILS_HIDEFRAME, HideFrameFunc);
CreateServiceFunction(MS_MYDETAILS_SHOWHIDEFRAME, ShowHideFrameFunc);
-
return 0;
}
@@ -358,35 +344,27 @@ int CreateFrame()
bool FrameIsFloating()
{
if (frame_id == -1)
- {
return true; // no frames, always floating
- }
return (CallService(MS_CLIST_FRAMES_GETFRAMEOPTIONS, MAKEWPARAM(FO_FLOATING, frame_id), 0) != 0);
}
-LRESULT CALLBACK FrameContainerWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) {
- switch(msg)
- {
- case WM_SHOWWINDOW:
- {
- if ((BOOL)wParam)
- Utils_RestoreWindowPosition(hwnd, 0, MODULE_NAME, WINDOW_NAME_PREFIX);
- else
- Utils_SaveWindowPosition(hwnd, 0, MODULE_NAME, WINDOW_NAME_PREFIX);
- break;
- }
-
- case WM_ERASEBKGND:
- {
- HWND child = (HWND)GetWindowLong(hwnd, GWLP_USERDATA);
+LRESULT CALLBACK FrameContainerWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
+{
+ switch(msg) {
+ case WM_SHOWWINDOW:
+ if ((BOOL)wParam)
+ Utils_RestoreWindowPosition(hwnd, 0, MODULE_NAME, WINDOW_NAME_PREFIX);
+ else
+ Utils_SaveWindowPosition(hwnd, 0, MODULE_NAME, WINDOW_NAME_PREFIX);
+ break;
- SendMessage(child, WM_ERASEBKGND, wParam, lParam);
- break;
- }
+ case WM_ERASEBKGND:
+ SendMessage((HWND)GetWindowLong(hwnd, GWLP_USERDATA), WM_ERASEBKGND, wParam, lParam);
+ break;
- case WM_SIZE:
+ case WM_SIZE:
{
HWND child = (HWND)GetWindowLong(hwnd, GWLP_USERDATA);
RECT r;
@@ -394,41 +372,33 @@ LRESULT CALLBACK FrameContainerWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LP
SetWindowPos(child, 0, r.left, r.top, r.right - r.left, r.bottom - r.top, SWP_NOZORDER | SWP_NOACTIVATE);
InvalidateRect(child, NULL, TRUE);
-
- return TRUE;
}
+ return TRUE;
- case WM_CLOSE:
- {
- DBWriteContactSettingByte(0, MODULE_NAME, SETTING_FRAME_VISIBLE, 0);
- ShowWindow(hwnd, SW_HIDE);
- FixMainMenu();
- return TRUE;
- }
+ case WM_CLOSE:
+ DBWriteContactSettingByte(0, MODULE_NAME, SETTING_FRAME_VISIBLE, 0);
+ ShowWindow(hwnd, SW_HIDE);
+ FixMainMenu();
+ return TRUE;
}
return DefWindowProc(hwnd, msg, wParam, lParam);
}
-
BOOL ScreenToClient(HWND hWnd, LPRECT lpRect)
{
- BOOL ret;
-
POINT pt;
-
pt.x = lpRect->left;
pt.y = lpRect->top;
- ret = ScreenToClient(hWnd, &pt);
-
- if ( !ret) return ret;
+ BOOL ret = ScreenToClient(hWnd, &pt);
+ if ( !ret)
+ return ret;
lpRect->left = pt.x;
lpRect->top = pt.y;
-
pt.x = lpRect->right;
pt.y = lpRect->bottom;
@@ -440,17 +410,14 @@ BOOL ScreenToClient(HWND hWnd, LPRECT lpRect)
return ret;
}
-
BOOL MoveWindow(HWND hWnd, const RECT &rect, BOOL bRepaint)
{
return MoveWindow(hWnd, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, bRepaint);
}
-
RECT GetInnerRect(const RECT &rc, const RECT &clipping)
{
RECT rc_ret = rc;
-
rc_ret.left = max(rc.left, clipping.left);
rc_ret.top = max(rc.top, clipping.top);
rc_ret.right = min(rc.right, clipping.right);
@@ -459,7 +426,6 @@ RECT GetInnerRect(const RECT &rc, const RECT &clipping)
return rc_ret;
}
-
RECT GetRect(HDC hdc, RECT rc, SIZE s, UINT uFormat, int next_top, int text_left, bool frame = true,
bool end_elipsis_on_frame = true)
{
@@ -545,60 +511,50 @@ RECT GetRect(HDC hdc, RECT rc, const TCHAR *text, const TCHAR *def_text, Protoco
HWND CreateTooltip(HWND hwnd, RECT &rect)
{
- // struct specifying control classes to register
- INITCOMMONCONTROLSEX iccex;
- HWND hwndTT; // handle to the ToolTip control
- // struct specifying info about tool in ToolTip control
- TOOLINFO ti;
- unsigned int uid = 0; // for ti initialization
+ // struct specifying control classes to register
+ INITCOMMONCONTROLSEX iccex;
+ HWND hwndTT; // handle to the ToolTip control
+ // struct specifying info about tool in ToolTip control
+ TOOLINFO ti;
+ unsigned int uid = 0; // for ti initialization
// Load the ToolTip class from the DLL.
- iccex.dwSize = sizeof(iccex);
- iccex.dwICC = ICC_BAR_CLASSES;
-
- if (!InitCommonControlsEx(&iccex))
- return NULL;
-
- /* CREATE A TOOLTIP WINDOW */
- hwndTT = CreateWindowEx(WS_EX_TOPMOST,
- TOOLTIPS_CLASS,
- NULL,
- WS_POPUP | TTS_NOPREFIX | TTS_ALWAYSTIP,
- CW_USEDEFAULT,
- CW_USEDEFAULT,
- CW_USEDEFAULT,
- CW_USEDEFAULT,
- hwnd,
- NULL,
- hInst,
- NULL
- );
-
- /* Gives problem with mToolTip
- SetWindowPos(hwndTT,
- HWND_TOPMOST,
- 0,
- 0,
- 0,
- 0,
- SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);
- */
-
- /* INITIALIZE MEMBERS OF THE TOOLINFO STRUCTURE */
- ti.cbSize = sizeof(TOOLINFO);
- ti.uFlags = TTF_SUBCLASS;
- ti.hwnd = hwnd;
- ti.hinst = hInst;
- ti.uId = uid;
- ti.lpszText = LPSTR_TEXTCALLBACK;
- // ToolTip control will cover the whole window
- ti.rect.left = rect.left;
- ti.rect.top = rect.top;
- ti.rect.right = rect.right;
- ti.rect.bottom = rect.bottom;
-
- /* SEND AN ADDTOOL MESSAGE TO THE TOOLTIP CONTROL WINDOW */
- SendMessage(hwndTT, TTM_ADDTOOL, 0, (LPARAM) (LPTOOLINFO) &ti);
+ iccex.dwSize = sizeof(iccex);
+ iccex.dwICC = ICC_BAR_CLASSES;
+
+ if (!InitCommonControlsEx(&iccex))
+ return NULL;
+
+ /* CREATE A TOOLTIP WINDOW */
+ hwndTT = CreateWindowEx(WS_EX_TOPMOST,
+ TOOLTIPS_CLASS,
+ NULL,
+ WS_POPUP | TTS_NOPREFIX | TTS_ALWAYSTIP,
+ CW_USEDEFAULT,
+ CW_USEDEFAULT,
+ CW_USEDEFAULT,
+ CW_USEDEFAULT,
+ hwnd,
+ NULL,
+ hInst,
+ NULL
+ );
+
+ /* INITIALIZE MEMBERS OF THE TOOLINFO STRUCTURE */
+ ti.cbSize = sizeof(TOOLINFO);
+ ti.uFlags = TTF_SUBCLASS;
+ ti.hwnd = hwnd;
+ ti.hinst = hInst;
+ ti.uId = uid;
+ ti.lpszText = LPSTR_TEXTCALLBACK;
+ // ToolTip control will cover the whole window
+ ti.rect.left = rect.left;
+ ti.rect.top = rect.top;
+ ti.rect.right = rect.right;
+ ti.rect.bottom = rect.bottom;
+
+ /* SEND AN ADDTOOL MESSAGE TO THE TOOLTIP CONTROL WINDOW */
+ SendMessage(hwndTT, TTM_ADDTOOL, 0, (LPARAM) (LPTOOLINFO) &ti);
SendMessage(hwndTT, TTM_SETDELAYTIME, (WPARAM) (DWORD) TTDT_AUTOPOP, (LPARAM) MAKELONG(24 * 60 * 60 * 1000, 0));
return hwndTT;
@@ -606,38 +562,32 @@ HWND CreateTooltip(HWND hwnd, RECT &rect)
void DeleteTooltipWindows(MyDetailsFrameData *data)
{
- if (data->nick_tt_hwnd != NULL)
- {
+ if (data->nick_tt_hwnd != NULL) {
DestroyWindow(data->nick_tt_hwnd);
data->nick_tt_hwnd = NULL;
}
- if (data->status_tt_hwnd != NULL)
- {
+ if (data->status_tt_hwnd != NULL) {
DestroyWindow(data->status_tt_hwnd);
data->status_tt_hwnd = NULL;
}
- if (data->next_proto_tt_hwnd != NULL)
- {
+ if (data->next_proto_tt_hwnd != NULL) {
DestroyWindow(data->next_proto_tt_hwnd);
data->next_proto_tt_hwnd = NULL;
}
- if (data->prev_proto_tt_hwnd != NULL)
- {
+ if (data->prev_proto_tt_hwnd != NULL) {
DestroyWindow(data->prev_proto_tt_hwnd);
data->prev_proto_tt_hwnd = NULL;
}
- if (data->away_msg_tt_hwnd != NULL)
- {
+ if (data->away_msg_tt_hwnd != NULL) {
DestroyWindow(data->away_msg_tt_hwnd);
data->away_msg_tt_hwnd = NULL;
}
- if (data->listening_to_tt_hwnd != NULL)
- {
+ if (data->listening_to_tt_hwnd != NULL) {
DestroyWindow(data->listening_to_tt_hwnd);
data->listening_to_tt_hwnd = NULL;
}
@@ -669,24 +619,18 @@ void CalcRectangles(HWND hwnd)
DeleteTooltipWindows(data);
- if (ServiceExists(MS_CLIST_FRAMES_SETFRAMEOPTIONS) && frame_id != -1)
- {
+ if (ServiceExists(MS_CLIST_FRAMES_SETFRAMEOPTIONS) && frame_id != -1) {
int flags = CallService(MS_CLIST_FRAMES_GETFRAMEOPTIONS, MAKEWPARAM(FO_FLAGS, frame_id), 0);
- if (flags & F_UNCOLLAPSED)
- {
+ if (flags & F_UNCOLLAPSED) {
RECT rf;
GetClientRect(hwnd, &rf);
int size = 0;
- if (rf.bottom - rf.top != size)
- {
- if (FrameIsFloating())
- {
+ if (rf.bottom - rf.top != size) {
+ if (FrameIsFloating()) {
HWND parent = GetParent(hwnd);
-
- if (parent != NULL)
- {
+ if (parent != NULL) {
RECT rp_client, rp_window, r_window;
GetClientRect(parent, &rp_client);
GetWindowRect(parent, &rp_window);
@@ -728,354 +672,312 @@ void CalcRectangles(HWND hwnd)
next_top = r.top;
text_left = r.left;
- //if (r.right > r.left && r.bottom > r.top)
- {
- // Draw image?
- //proto->GetAvatar();
- if (proto->CanGetAvatar())
- {
- if (proto->avatar_bmp != NULL)
- {
- data->draw_img = true;
+ // Draw image?
+ if (proto->CanGetAvatar()) {
+ if (proto->avatar_bmp != NULL) {
+ data->draw_img = true;
- BITMAP bmp;
- if (GetObject(proto->avatar_bmp, sizeof(bmp), &bmp))
- {
- // make bounds
- RECT rc = r;
+ BITMAP bmp;
+ if (GetObject(proto->avatar_bmp, sizeof(bmp), &bmp)) {
+ // make bounds
+ RECT rc = r;
- LONG width;
- LONG height;
+ LONG width;
+ LONG height;
- if (opts.draw_avatar_custom_size)
- {
- rc.right = opts.draw_avatar_custom_size_pixels;
+ if (opts.draw_avatar_custom_size) {
+ rc.right = opts.draw_avatar_custom_size_pixels;
- width = opts.draw_avatar_custom_size_pixels;
- height = opts.draw_avatar_custom_size_pixels;
- }
- else if (opts.resize_frame)
- {
- rc.right = rc.left + (rc.right - rc.left) / 3;
+ width = opts.draw_avatar_custom_size_pixels;
+ height = opts.draw_avatar_custom_size_pixels;
+ }
+ else if (opts.resize_frame) {
+ rc.right = rc.left + (rc.right - rc.left) / 3;
- width = rc.right - rc.left;
- height = rc.bottom - rc.top;
- }
- else
- {
- rc.right = rc.left + min((rc.right - rc.left) / 3, rc.bottom - rc.top);
+ width = rc.right - rc.left;
+ height = rc.bottom - rc.top;
+ }
+ else {
+ rc.right = rc.left + min((rc.right - rc.left) / 3, rc.bottom - rc.top);
- width = rc.right - rc.left;
- height = rc.bottom - rc.top;
- }
+ width = rc.right - rc.left;
+ height = rc.bottom - rc.top;
+ }
- // Fit to image proportions
- if ( !opts.draw_avatar_allow_to_grow)
- {
- if (width > bmp.bmWidth)
- width = bmp.bmWidth;
+ // Fit to image proportions
+ if ( !opts.draw_avatar_allow_to_grow) {
+ if (width > bmp.bmWidth)
+ width = bmp.bmWidth;
- if (height > bmp.bmHeight)
- height = bmp.bmHeight;
- }
+ if (height > bmp.bmHeight)
+ height = bmp.bmHeight;
+ }
- if ( !opts.resize_frame && height * bmp.bmWidth / bmp.bmHeight <= width)
- {
- width = height * bmp.bmWidth / bmp.bmHeight;
- }
- else
- {
- height = width * bmp.bmHeight / bmp.bmWidth;
- }
+ if ( !opts.resize_frame && height * bmp.bmWidth / bmp.bmHeight <= width)
+ width = height * bmp.bmWidth / bmp.bmHeight;
+ else
+ height = width * bmp.bmHeight / bmp.bmWidth;
- rc.right = rc.left + width;
- rc.bottom = rc.top + height;
+ rc.right = rc.left + width;
+ rc.bottom = rc.top + height;
- data->img_rect = rc;
+ data->img_rect = rc;
- avatar_bottom = data->img_rect.bottom + SPACE_TEXT_TEXT;
+ avatar_bottom = data->img_rect.bottom + SPACE_TEXT_TEXT;
- // Make space to nick
- text_left = data->img_rect.right + SPACE_IMG_TEXT;
- }
+ // Make space to nick
+ text_left = data->img_rect.right + SPACE_IMG_TEXT;
}
}
+ }
- // Always draw nick
- {
- data->draw_nick = true;
-
- SelectObject(hdc, hFont[FONT_NICK]);
-
- data->nick_rect = GetRect(hdc, r, proto->nickname, DEFAULT_NICKNAME, proto, uFormat,
- next_top, text_left);
+ // Always draw nick
+ data->draw_nick = true;
+ SelectObject(hdc, hFont[FONT_NICK]);
- if (proto->nickname[0] != '\0')
- data->nick_tt_hwnd = CreateTooltip(hwnd, data->nick_rect);
+ data->nick_rect = GetRect(hdc, r, proto->nickname, DEFAULT_NICKNAME, proto, uFormat, next_top, text_left);
- next_top = data->nick_rect.bottom + SPACE_TEXT_TEXT;
- }
+ if (proto->nickname[0] != '\0')
+ data->nick_tt_hwnd = CreateTooltip(hwnd, data->nick_rect);
- // Fits more?
- if (next_top > r.bottom)
- goto finish;
+ next_top = data->nick_rect.bottom + SPACE_TEXT_TEXT;
- if (next_top > avatar_bottom && opts.use_avatar_space_to_draw_text)
- text_left = r.left;
+ // Fits more?
+ if (next_top > r.bottom)
+ goto finish;
- // Protocol?
- if (opts.draw_show_protocol_name)
- {
- data->draw_proto = true;
+ if (next_top > avatar_bottom && opts.use_avatar_space_to_draw_text)
+ text_left = r.left;
- SelectObject(hdc, hFont[FONT_PROTO]);
+ // Protocol?
+ if (opts.draw_show_protocol_name) {
+ data->draw_proto = true;
- RECT tmp_r = r;
- int tmp_text_left = text_left;
- if (opts.show_protocol_cycle_button)
- {
- tmp_r.right -= 2 * ICON_SIZE;
- }
+ SelectObject(hdc, hFont[FONT_PROTO]);
- data->proto_rect = GetRect(hdc, tmp_r, proto->description, _T(""), proto, uFormat,
- next_top, tmp_text_left, false, true, false);
+ RECT tmp_r = r;
+ int tmp_text_left = text_left;
+ if (opts.show_protocol_cycle_button)
+ tmp_r.right -= 2 * ICON_SIZE;
+ data->proto_rect = GetRect(hdc, tmp_r, proto->description, _T(""), proto, uFormat,
+ next_top, tmp_text_left, false, true, false);
- if (opts.show_protocol_cycle_button)
- {
- data->draw_proto_cycle= true;
+ if (opts.show_protocol_cycle_button) {
+ data->draw_proto_cycle= true;
- RECT prev = r;
- prev.top = next_top;
- prev.bottom = min(r.bottom, prev.top + ICON_SIZE);
+ RECT prev = r;
+ prev.top = next_top;
+ prev.bottom = min(r.bottom, prev.top + ICON_SIZE);
- int diff = (data->proto_rect.bottom - data->proto_rect.top) - (prev.bottom - prev.top);
- if (diff < 0)
- {
- diff = -diff / 2;
- data->proto_rect.top += diff;
- data->proto_rect.bottom += diff;
- }
- else
- {
- diff = diff / 2;
- prev.top += diff;
- prev.bottom += diff;
- }
+ int diff = (data->proto_rect.bottom - data->proto_rect.top) - (prev.bottom - prev.top);
+ if (diff < 0) {
+ diff = -diff / 2;
+ data->proto_rect.top += diff;
+ data->proto_rect.bottom += diff;
+ }
+ else {
+ diff = diff / 2;
+ prev.top += diff;
+ prev.bottom += diff;
+ }
- prev.right -= ICON_SIZE;
- prev.left = prev.right - ICON_SIZE;
+ prev.right -= ICON_SIZE;
+ prev.left = prev.right - ICON_SIZE;
- RECT next = prev;
- next.left += ICON_SIZE;
- next.right += ICON_SIZE;
+ RECT next = prev;
+ next.left += ICON_SIZE;
+ next.right += ICON_SIZE;
- prev.left = max(text_left, prev.left);
- prev.right = min(r.right, prev.right);
- next.left = max(text_left, next.left);
- next.right = min(r.right, next.right);
+ prev.left = max(text_left, prev.left);
+ prev.right = min(r.right, prev.right);
+ next.left = max(text_left, next.left);
+ next.right = min(r.right, next.right);
- data->prev_proto_rect = prev;
- data->next_proto_rect = next;
+ data->prev_proto_rect = prev;
+ data->next_proto_rect = next;
- data->next_proto_tt_hwnd = CreateTooltip(hwnd, data->next_proto_rect);
- data->prev_proto_tt_hwnd = CreateTooltip(hwnd, data->prev_proto_rect);
+ data->next_proto_tt_hwnd = CreateTooltip(hwnd, data->next_proto_rect);
+ data->prev_proto_tt_hwnd = CreateTooltip(hwnd, data->prev_proto_rect);
- next_top = max(data->next_proto_rect.bottom, data->proto_rect.bottom) + SPACE_TEXT_TEXT;
- }
- else
- {
- next_top = data->proto_rect.bottom + SPACE_TEXT_TEXT;
- }
+ next_top = max(data->next_proto_rect.bottom, data->proto_rect.bottom) + SPACE_TEXT_TEXT;
}
+ else next_top = data->proto_rect.bottom + SPACE_TEXT_TEXT;
+ }
- // Fits more?
- if (next_top + 2 * BORDER_SPACE > r.bottom)
- goto finish;
+ // Fits more?
+ if (next_top + 2 * BORDER_SPACE > r.bottom)
+ goto finish;
- if (next_top > avatar_bottom && opts.use_avatar_space_to_draw_text)
- text_left = r.left;
+ if (next_top > avatar_bottom && opts.use_avatar_space_to_draw_text)
+ text_left = r.left;
- // Status data?
- {
- data->draw_status = true;
+ // Status data?
+ {
+ data->draw_status = true;
- SelectObject(hdc, hFont[FONT_STATUS]);
+ SelectObject(hdc, hFont[FONT_STATUS]);
- // Text size
- RECT r_tmp = r;
- DrawText(hdc, proto->status_name, _tcslen(proto->status_name), &r_tmp,
- DT_CALCRECT | (uFormat & ~DT_END_ELLIPSIS));
+ // Text size
+ RECT r_tmp = r;
+ DrawText(hdc, proto->status_name, _tcslen(proto->status_name), &r_tmp,
+ DT_CALCRECT | (uFormat & ~DT_END_ELLIPSIS));
- SIZE s;
- s.cy = max(r_tmp.bottom - r_tmp.top, ICON_SIZE);
- s.cx = ICON_SIZE + SPACE_ICON_TEXT + r_tmp.right - r_tmp.left;
+ SIZE s;
+ s.cy = max(r_tmp.bottom - r_tmp.top, ICON_SIZE);
+ s.cx = ICON_SIZE + SPACE_ICON_TEXT + r_tmp.right - r_tmp.left;
- // Status global rect
- data->status_rect = GetRect(hdc, r, s, uFormat, next_top, text_left, true, false);
+ // Status global rect
+ data->status_rect = GetRect(hdc, r, s, uFormat, next_top, text_left, true, false);
- if (proto->status_name[0] != '\0')
- data->status_tt_hwnd = CreateTooltip(hwnd, data->status_rect);
+ if (proto->status_name[0] != '\0')
+ data->status_tt_hwnd = CreateTooltip(hwnd, data->status_rect);
- next_top = data->status_rect.bottom + SPACE_TEXT_TEXT;
+ next_top = data->status_rect.bottom + SPACE_TEXT_TEXT;
- RECT rc_inner = data->status_rect;
- rc_inner.top += BORDER_SPACE;
- rc_inner.bottom -= BORDER_SPACE;
- rc_inner.left += BORDER_SPACE;
- rc_inner.right -= BORDER_SPACE;
+ RECT rc_inner = data->status_rect;
+ rc_inner.top += BORDER_SPACE;
+ rc_inner.bottom -= BORDER_SPACE;
+ rc_inner.left += BORDER_SPACE;
+ rc_inner.right -= BORDER_SPACE;
- // Icon
- data->status_icon_rect = rc_inner;
+ // Icon
+ data->status_icon_rect = rc_inner;
- if (opts.draw_text_align_right || opts.draw_text_rtl)
- data->status_icon_rect.left = max(data->status_icon_rect.right - ICON_SIZE, rc_inner.left);
- else
- data->status_icon_rect.right = min(data->status_icon_rect.left + ICON_SIZE, rc_inner.right);
+ if (opts.draw_text_align_right || opts.draw_text_rtl)
+ data->status_icon_rect.left = max(data->status_icon_rect.right - ICON_SIZE, rc_inner.left);
+ else
+ data->status_icon_rect.right = min(data->status_icon_rect.left + ICON_SIZE, rc_inner.right);
- if (r_tmp.bottom - r_tmp.top > ICON_SIZE)
- {
- data->status_icon_rect.top += (r_tmp.bottom - r_tmp.top - ICON_SIZE) / 2;
- data->status_icon_rect.bottom = data->status_icon_rect.top + ICON_SIZE;
- }
+ if (r_tmp.bottom - r_tmp.top > ICON_SIZE) {
+ data->status_icon_rect.top += (r_tmp.bottom - r_tmp.top - ICON_SIZE) / 2;
+ data->status_icon_rect.bottom = data->status_icon_rect.top + ICON_SIZE;
+ }
- // Text
- data->status_text_rect = GetInnerRect(rc_inner, r);
+ // Text
+ data->status_text_rect = GetInnerRect(rc_inner, r);
- if (opts.draw_text_align_right || opts.draw_text_rtl)
- data->status_text_rect.right = max(data->status_icon_rect.left - SPACE_ICON_TEXT, rc_inner.left);
- else
- data->status_text_rect.left = min(data->status_icon_rect.right + SPACE_ICON_TEXT, rc_inner.right);
+ if (opts.draw_text_align_right || opts.draw_text_rtl)
+ data->status_text_rect.right = max(data->status_icon_rect.left - SPACE_ICON_TEXT, rc_inner.left);
+ else
+ data->status_text_rect.left = min(data->status_icon_rect.right + SPACE_ICON_TEXT, rc_inner.right);
- if (ICON_SIZE > r_tmp.bottom - r_tmp.top)
- {
- data->status_text_rect.top += (ICON_SIZE - (r_tmp.bottom - r_tmp.top)) / 2;
- data->status_text_rect.bottom = data->status_text_rect.top + r_tmp.bottom - r_tmp.top;
- }
+ if (ICON_SIZE > r_tmp.bottom - r_tmp.top) {
+ data->status_text_rect.top += (ICON_SIZE - (r_tmp.bottom - r_tmp.top)) / 2;
+ data->status_text_rect.bottom = data->status_text_rect.top + r_tmp.bottom - r_tmp.top;
}
+ }
- // Fits more?
- if (next_top + 2 * BORDER_SPACE > r.bottom)
- goto finish;
+ // Fits more?
+ if (next_top + 2 * BORDER_SPACE > r.bottom)
+ goto finish;
- if (next_top > avatar_bottom && opts.use_avatar_space_to_draw_text)
- text_left = r.left;
+ if (next_top > avatar_bottom && opts.use_avatar_space_to_draw_text)
+ text_left = r.left;
- // Away msg?
- if (proto->CanGetStatusMsg())
- {
- data->draw_away_msg = true;
+ // Away msg?
+ if (proto->CanGetStatusMsg()) {
+ data->draw_away_msg = true;
- SelectObject(hdc, hFont[FONT_AWAY_MSG]);
+ SelectObject(hdc, hFont[FONT_AWAY_MSG]);
- data->away_msg_rect = GetRect(hdc, r, proto->status_message, DEFAULT_STATUS_MESSAGE, proto, uFormat,
- next_top, text_left);
+ data->away_msg_rect = GetRect(hdc, r, proto->status_message, DEFAULT_STATUS_MESSAGE, proto, uFormat, next_top, text_left);
- if (proto->status_message[0] != '\0')
- data->away_msg_tt_hwnd = CreateTooltip(hwnd, data->away_msg_rect);
+ if (proto->status_message[0] != '\0')
+ data->away_msg_tt_hwnd = CreateTooltip(hwnd, data->away_msg_rect);
- next_top = data->away_msg_rect.bottom + SPACE_TEXT_TEXT;
- }
+ next_top = data->away_msg_rect.bottom + SPACE_TEXT_TEXT;
+ }
- // Fits more?
- if (next_top + 2 * BORDER_SPACE > r.bottom)
- goto finish;
+ // Fits more?
+ if (next_top + 2 * BORDER_SPACE > r.bottom)
+ goto finish;
- if (next_top > avatar_bottom && opts.use_avatar_space_to_draw_text)
- text_left = r.left;
+ if (next_top > avatar_bottom && opts.use_avatar_space_to_draw_text)
+ text_left = r.left;
- // Listening to
- if (proto->ListeningToEnabled() && proto->GetStatus() > ID_STATUS_OFFLINE)
- {
- data->draw_listening_to = true;
+ // Listening to
+ if (proto->ListeningToEnabled() && proto->GetStatus() > ID_STATUS_OFFLINE) {
+ data->draw_listening_to = true;
- if (proto->listening_to[0] == '\0')
- {
- SelectObject(hdc, hFont[FONT_LISTENING_TO]);
+ if (proto->listening_to[0] == '\0') {
+ SelectObject(hdc, hFont[FONT_LISTENING_TO]);
- data->listening_to_rect = GetRect(hdc, r, proto->listening_to, DEFAULT_LISTENING_TO, proto, uFormat,
- next_top, text_left);
+ data->listening_to_rect = GetRect(hdc, r, proto->listening_to, DEFAULT_LISTENING_TO, proto, uFormat,
+ next_top, text_left);
- data->listening_to_text_rect = data->listening_to_rect;
- ZeroMemory(&data->listening_to_icon_rect, sizeof(data->listening_to_icon_rect));
+ data->listening_to_text_rect = data->listening_to_rect;
+ ZeroMemory(&data->listening_to_icon_rect, sizeof(data->listening_to_icon_rect));
- next_top = data->listening_to_rect.bottom + SPACE_TEXT_TEXT;
- }
- else
- {
- SelectObject(hdc, hFont[FONT_LISTENING_TO]);
+ next_top = data->listening_to_rect.bottom + SPACE_TEXT_TEXT;
+ }
+ else {
+ SelectObject(hdc, hFont[FONT_LISTENING_TO]);
- // Text size
- RECT r_tmp = r;
- DrawText(hdc, proto->listening_to, _tcslen(proto->listening_to), &r_tmp,
- DT_CALCRECT | (uFormat & ~DT_END_ELLIPSIS));
+ // Text size
+ RECT r_tmp = r;
+ DrawText(hdc, proto->listening_to, _tcslen(proto->listening_to), &r_tmp,
+ DT_CALCRECT | (uFormat & ~DT_END_ELLIPSIS));
- SIZE s;
- s.cy = max(r_tmp.bottom - r_tmp.top, ICON_SIZE);
- s.cx = ICON_SIZE + SPACE_ICON_TEXT + r_tmp.right - r_tmp.left;
+ SIZE s;
+ s.cy = max(r_tmp.bottom - r_tmp.top, ICON_SIZE);
+ s.cx = ICON_SIZE + SPACE_ICON_TEXT + r_tmp.right - r_tmp.left;
- // listening to global rect
- data->listening_to_rect = GetRect(hdc, r, s, uFormat, next_top, text_left, true, false);
+ // listening to global rect
+ data->listening_to_rect = GetRect(hdc, r, s, uFormat, next_top, text_left, true, false);
- data->listening_to_tt_hwnd = CreateTooltip(hwnd, data->listening_to_rect);
+ data->listening_to_tt_hwnd = CreateTooltip(hwnd, data->listening_to_rect);
- next_top = data->listening_to_rect.bottom + SPACE_TEXT_TEXT;
+ next_top = data->listening_to_rect.bottom + SPACE_TEXT_TEXT;
- RECT rc_inner = data->listening_to_rect;
- rc_inner.top += BORDER_SPACE;
- rc_inner.bottom -= BORDER_SPACE;
- rc_inner.left += BORDER_SPACE;
- rc_inner.right -= BORDER_SPACE;
+ RECT rc_inner = data->listening_to_rect;
+ rc_inner.top += BORDER_SPACE;
+ rc_inner.bottom -= BORDER_SPACE;
+ rc_inner.left += BORDER_SPACE;
+ rc_inner.right -= BORDER_SPACE;
- // Icon
- data->listening_to_icon_rect = rc_inner;
+ // Icon
+ data->listening_to_icon_rect = rc_inner;
- if (opts.draw_text_align_right || opts.draw_text_rtl)
- data->listening_to_icon_rect.left = max(data->listening_to_icon_rect.right - ICON_SIZE, rc_inner.left);
- else
- data->listening_to_icon_rect.right = min(data->listening_to_icon_rect.left + ICON_SIZE, rc_inner.right);
+ if (opts.draw_text_align_right || opts.draw_text_rtl)
+ data->listening_to_icon_rect.left = max(data->listening_to_icon_rect.right - ICON_SIZE, rc_inner.left);
+ else
+ data->listening_to_icon_rect.right = min(data->listening_to_icon_rect.left + ICON_SIZE, rc_inner.right);
- if (r_tmp.bottom - r_tmp.top > ICON_SIZE)
- {
- data->listening_to_icon_rect.top += (r_tmp.bottom - r_tmp.top - ICON_SIZE) / 2;
- data->listening_to_icon_rect.bottom = data->listening_to_icon_rect.top + ICON_SIZE;
- }
+ if (r_tmp.bottom - r_tmp.top > ICON_SIZE) {
+ data->listening_to_icon_rect.top += (r_tmp.bottom - r_tmp.top - ICON_SIZE) / 2;
+ data->listening_to_icon_rect.bottom = data->listening_to_icon_rect.top + ICON_SIZE;
+ }
- // Text
- data->listening_to_text_rect = GetInnerRect(rc_inner, r);
+ // Text
+ data->listening_to_text_rect = GetInnerRect(rc_inner, r);
- if (opts.draw_text_align_right || opts.draw_text_rtl)
- data->listening_to_text_rect.right = max(data->listening_to_icon_rect.left - SPACE_ICON_TEXT, rc_inner.left);
- else
- data->listening_to_text_rect.left = min(data->listening_to_icon_rect.right + SPACE_ICON_TEXT, rc_inner.right);
+ if (opts.draw_text_align_right || opts.draw_text_rtl)
+ data->listening_to_text_rect.right = max(data->listening_to_icon_rect.left - SPACE_ICON_TEXT, rc_inner.left);
+ else
+ data->listening_to_text_rect.left = min(data->listening_to_icon_rect.right + SPACE_ICON_TEXT, rc_inner.right);
- if (ICON_SIZE > r_tmp.bottom - r_tmp.top)
- {
- data->listening_to_text_rect.top += (ICON_SIZE - (r_tmp.bottom - r_tmp.top)) / 2;
- data->listening_to_text_rect.bottom = data->listening_to_text_rect.top + r_tmp.bottom - r_tmp.top;
- }
+ if (ICON_SIZE > r_tmp.bottom - r_tmp.top) {
+ data->listening_to_text_rect.top += (ICON_SIZE - (r_tmp.bottom - r_tmp.top)) / 2;
+ data->listening_to_text_rect.bottom = data->listening_to_text_rect.top + r_tmp.bottom - r_tmp.top;
}
}
}
r.bottom = max(next_top - SPACE_TEXT_TEXT, avatar_bottom);
- if (opts.resize_frame && ServiceExists(MS_CLIST_FRAMES_SETFRAMEOPTIONS) && frame_id != -1)
- {
+ if (opts.resize_frame && ServiceExists(MS_CLIST_FRAMES_SETFRAMEOPTIONS) && frame_id != -1) {
RECT rf;
GetClientRect(hwnd, &rf);
int size = r.bottom + opts.borders[BOTTOM];
- if (rf.bottom - rf.top != size)
- {
- if (FrameIsFloating())
- {
+ if (rf.bottom - rf.top != size) {
+ if (FrameIsFloating()) {
HWND parent = GetParent(hwnd);
- if (parent != NULL)
- {
+ if (parent != NULL) {
RECT rp_client, rp_window, r_window;
GetClientRect(parent, &rp_client);
GetWindowRect(parent, &rp_window);
@@ -1087,11 +989,9 @@ void CalcRectangles(HWND hwnd)
SetWindowPos(parent, 0, 0, 0, rp_window.right - rp_window.left, size + diff, SWP_NOZORDER | SWP_NOMOVE | SWP_NOACTIVATE);
}
}
- else if (IsWindowVisible(hwnd) && ServiceExists(MS_CLIST_FRAMES_ADDFRAME))
- {
+ else if (IsWindowVisible(hwnd) && ServiceExists(MS_CLIST_FRAMES_ADDFRAME)) {
int flags = CallService(MS_CLIST_FRAMES_GETFRAMEOPTIONS, MAKEWPARAM(FO_FLAGS, frame_id), 0);
- if (flags & F_VISIBLE)
- {
+ if (flags & F_VISIBLE) {
CallService(MS_CLIST_FRAMES_SETFRAMEOPTIONS, MAKEWPARAM(FO_HEIGHT, frame_id), (LPARAM)(size));
CallService(MS_CLIST_FRAMES_UPDATEFRAME, (WPARAM)frame_id, (LPARAM)(FU_TBREDRAW | FU_FMREDRAW | FU_FMPOS));
}
@@ -1126,14 +1026,18 @@ HBITMAP CreateBitmap32(int cx, int cy)
return DirectBitmap;
}
- void EraseBackground(HWND hwnd, HDC hdc)
+void EraseBackground(HWND hwnd, HDC hdc, MyDetailsFrameData* data)
{
RECT r;
GetClientRect(hwnd, &r);
- HBRUSH hB = CreateSolidBrush((COLORREF) DBGetContactSettingDword(NULL,"MyDetails","BackgroundColor",GetSysColor(COLOR_BTNFACE)));
- FillRect(hdc, &r, hB);
- DeleteObject(hB);
+ if (data->skinning)
+ SkinDrawWindowBack(hwnd, hdc, &r, "Main,ID=Background");
+ else {
+ HBRUSH hB = CreateSolidBrush((COLORREF) DBGetContactSettingDword(NULL,"MyDetails","BackgroundColor",GetSysColor(COLOR_BTNFACE)));
+ FillRect(hdc, &r, hB);
+ DeleteObject(hB);
+ }
}
void DrawTextWithRect(HDC hdc, const TCHAR *text, const TCHAR *def_text, RECT rc, UINT uFormat,
@@ -1214,9 +1118,8 @@ void Draw(HWND hwnd, HDC hdc_orig)
MyDetailsFrameData *data = (MyDetailsFrameData *)GetWindowLong(hwnd, GWLP_USERDATA);
Protocol *proto = protocols->Get(data->protocol_number);
- if (proto == NULL)
- {
- EraseBackground(hwnd, hdc_orig);
+ if (proto == NULL) {
+ EraseBackground(hwnd, hdc_orig, data);
return;
}
@@ -1237,7 +1140,7 @@ void Draw(HWND hwnd, HDC hdc_orig)
SetStretchBltMode(hdc, HALFTONE);
// Erase
- EraseBackground(hwnd, hdc);
+ EraseBackground(hwnd, hdc, data);
r.left += min(opts.borders[LEFT], r.right);
r.right = max(r.right - opts.borders[RIGHT], r.left);
@@ -1732,12 +1635,11 @@ LRESULT CALLBACK FrameWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar
data->recalc_rectangles = true;
data->get_status_messages = false;
data->showing_menu = false;
+ data->skinning = ServiceExists(MS_SKIN_DRAWGLYPH) != 0;
data->protocol_number = DBGetContactSettingWord(NULL,"MyDetails","ProtocolNumber",0);
if (data->protocol_number >= protocols->GetSize())
- {
data->protocol_number = 0;
- }
SetCycleTime(hwnd);
SetStatusMessageRefreshTime(hwnd);
@@ -1752,20 +1654,9 @@ LRESULT CALLBACK FrameWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar
return TRUE;
}
- /*
- case WM_ERASEBKGND:
- {
- //EraseBackground(hwnd, (HDC)wParam);
- Draw(hwnd, (HDC)wParam);
- return TRUE;
- }
- */
-
case WM_PRINTCLIENT:
- {
Draw(hwnd, (HDC)wParam);
return TRUE;
- }
case WM_PAINT:
{
@@ -1906,8 +1797,7 @@ LRESULT CALLBACK FrameWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar
mii.cch = _tcslen(protocols->Get(i)->description);
mii.wID = i + 1;
- if (i == data->protocol_number)
- {
+ if (i == data->protocol_number) {
mii.fMask |= MIIM_STATE;
mii.fState = MFS_DISABLED;
}
@@ -2615,20 +2505,10 @@ void FixMainMenu()
void RedrawFrame()
{
-// MyDetailsFrameData *data = (MyDetailsFrameData *)GetWindowLong(hwnd_frame, GWLP_USERDATA);
-// if (data != NULL)
-// {
-// data->recalc_rectangles = true;
-
- if (frame_id == -1)
- {
- InvalidateRect(hwnd_container, NULL, TRUE);
- }
- else
- {
- CallService(MS_CLIST_FRAMES_UPDATEFRAME, (WPARAM)frame_id, (LPARAM)FU_TBREDRAW | FU_FMREDRAW);
- }
-// }
+ if (frame_id == -1)
+ InvalidateRect(hwnd_container, NULL, TRUE);
+ else
+ CallService(MS_CLIST_FRAMES_UPDATEFRAME, (WPARAM)frame_id, (LPARAM)FU_TBREDRAW | FU_FMREDRAW);
}
void RefreshFrameAndCalcRects()
diff --git a/plugins/MyDetails/options.cpp b/plugins/MyDetails/options.cpp
index a8cf27ead3..6506e4a59f 100644
--- a/plugins/MyDetails/options.cpp
+++ b/plugins/MyDetails/options.cpp
@@ -28,34 +28,34 @@ Options opts;
// Functions //////////////////////////////////////////////////////////////////////////////////////
static OptPageControl pageControls[] = {
- { &opts.cycle_through_protocols, CONTROL_CHECKBOX, IDC_CYCLE_THROUGH_PROTOS, "CicleThroughtProtocols", (BYTE) 1 },
- { &opts.seconds_to_show_protocol, CONTROL_SPIN, IDC_CYCLE_TIME, "CicleTime", (WORD) 5, IDC_CYCLE_TIME_SPIN, (WORD) 1, (WORD) 255 },
- { &opts.draw_show_protocol_name, CONTROL_CHECKBOX, IDC_SHOW_PROTO_NAME, "ShowProtocolName", (BYTE) 1 },
- { &opts.show_protocol_cycle_button, CONTROL_CHECKBOX, IDC_SHOW_CYCLE_PROTO_BUTTON, "ShowProtocolCycleButton", (BYTE) 0 },
- { &opts.draw_text_rtl, CONTROL_CHECKBOX, IDC_TEXT_RTL, "TextRTL", (BYTE) 0 },
- { &opts.draw_text_align_right, CONTROL_CHECKBOX, IDC_TEXT_ALIGN_RIGHT, "TextAlignRight", (BYTE) 0 },
- { &opts.replace_smileys, CONTROL_CHECKBOX, IDC_REPLACE_SMILEYS, "ReplaceSmileys", (BYTE) 1 },
- { &opts.resize_smileys, CONTROL_CHECKBOX, IDC_RESIZE_SMILEYS, "ResizeSmileys", (BYTE) 0 },
- { &opts.use_contact_list_smileys, CONTROL_CHECKBOX, IDC_USE_CONTACT_LIST_SMILEYS, "UseContactListSmileys", (BYTE) 0 },
- { &opts.global_on_avatar, CONTROL_CHECKBOX, IDC_GLOBAL_ON_AVATAR, "GlobalOnAvatar", (BYTE) 0 },
- { &opts.global_on_nickname, CONTROL_CHECKBOX, IDC_GLOBAL_ON_NICKNAME, "GlobalOnNickname", (BYTE) 0 },
- { &opts.global_on_status, CONTROL_CHECKBOX, IDC_GLOBAL_ON_STATUS, "GlobalOnStatus", (BYTE) 0 },
- { &opts.global_on_status_message, CONTROL_CHECKBOX, IDC_GLOBAL_ON_STATUS_MESSAGE, "GlobalOnStatusMessage", (BYTE) 0 },
- { &opts.draw_avatar_allow_to_grow, CONTROL_CHECKBOX, IDC_AVATAR_ALLOW_TO_GROW, "AvatarAllowToGrow", (BYTE) 0 },
- { &opts.draw_avatar_custom_size, CONTROL_CHECKBOX, IDC_AVATAR_CUSTOM_SIZE_CHK, "AvatarCustomSize", (BYTE) 0 },
- { &opts.draw_avatar_custom_size_pixels, CONTROL_SPIN, IDC_AVATAR_CUSTOM_SIZE, "AvatarCustomSizePixels", (WORD) 30, IDC_AVATAR_CUSTOM_SIZE_SPIN, (WORD) 1, (WORD) 255 },
- { &opts.draw_avatar_border, CONTROL_CHECKBOX, IDC_AVATAR_DRAW_BORDER, "AvatarDrawBorders", (BYTE) 0 },
- { &opts.draw_avatar_border_color, CONTROL_COLOR, IDC_AVATAR_BORDER_COLOR, "AvatarBorderColor", (DWORD) RGB(0,0,0) },
- { &opts.draw_avatar_round_corner, CONTROL_CHECKBOX, IDC_AVATAR_ROUND_CORNERS, "AvatarRoundCorners", (BYTE) 1 },
- { &opts.draw_avatar_use_custom_corner_size, CONTROL_CHECKBOX, IDC_AVATAR_CUSTOM_CORNER_SIZE_CHECK, "AvatarUseCustomCornerSize", (BYTE) 0 },
- { &opts.draw_avatar_custom_corner_size, CONTROL_SPIN, IDC_AVATAR_CUSTOM_CORNER_SIZE, "AvatarCustomCornerSize", (WORD) 4, IDC_AVATAR_CUSTOM_CORNER_SIZE_SPIN, (WORD) 1, (WORD) 255 },
- { &opts.use_avatar_space_to_draw_text, CONTROL_CHECKBOX, IDC_AVATAR_USE_FREE_SPACE, "AvatarUseFreeSpaceToDrawText", (BYTE) 1 },
- { &opts.resize_frame, CONTROL_CHECKBOX, IDC_RESIZE_FRAME, "ResizeFrame", (BYTE) 0 },
- { &opts.borders[RIGHT], CONTROL_SPIN, IDC_BORDER_RIGHT, "BorderRight", (WORD) 8, IDC_BORDER_RIGHT_SPIN, (WORD) 0, (WORD) 255 },
- { &opts.borders[LEFT], CONTROL_SPIN, IDC_BORDER_LEFT, "BorderLeft", (WORD) 8, IDC_BORDER_LEFT_SPIN, (WORD) 0, (WORD) 255 },
- { &opts.borders[TOP], CONTROL_SPIN, IDC_BORDER_TOP, "BorderTop", (WORD) 8, IDC_BORDER_TOP_SPIN, (WORD) 0, (WORD) 255 },
- { &opts.borders[BOTTOM], CONTROL_SPIN, IDC_BORDER_BOTTOM, "BorderBottom", (WORD) 8, IDC_BORDER_BOTTOM_SPIN, (WORD) 0, (WORD) 255 },
- { &opts.bkg_color, CONTROL_COLOR, IDC_AVATAR_BKG_COLOR, "BackgroundColor", (DWORD) GetSysColor(COLOR_BTNFACE) }
+ { &opts.cycle_through_protocols, CONTROL_CHECKBOX, IDC_CYCLE_THROUGH_PROTOS, "CicleThroughtProtocols", (BYTE) 1 },
+ { &opts.seconds_to_show_protocol, CONTROL_SPIN, IDC_CYCLE_TIME, "CicleTime", (WORD) 5, IDC_CYCLE_TIME_SPIN, (WORD) 1, (WORD) 255 },
+ { &opts.draw_show_protocol_name, CONTROL_CHECKBOX, IDC_SHOW_PROTO_NAME, "ShowProtocolName", (BYTE) 1 },
+ { &opts.show_protocol_cycle_button, CONTROL_CHECKBOX, IDC_SHOW_CYCLE_PROTO_BUTTON, "ShowProtocolCycleButton", (BYTE) 0 },
+ { &opts.draw_text_rtl, CONTROL_CHECKBOX, IDC_TEXT_RTL, "TextRTL", (BYTE) 0 },
+ { &opts.draw_text_align_right, CONTROL_CHECKBOX, IDC_TEXT_ALIGN_RIGHT, "TextAlignRight", (BYTE) 0 },
+ { &opts.replace_smileys, CONTROL_CHECKBOX, IDC_REPLACE_SMILEYS, "ReplaceSmileys", (BYTE) 1 },
+ { &opts.resize_smileys, CONTROL_CHECKBOX, IDC_RESIZE_SMILEYS, "ResizeSmileys", (BYTE) 0 },
+ { &opts.use_contact_list_smileys, CONTROL_CHECKBOX, IDC_USE_CONTACT_LIST_SMILEYS, "UseContactListSmileys", (BYTE) 0 },
+ { &opts.global_on_avatar, CONTROL_CHECKBOX, IDC_GLOBAL_ON_AVATAR, "GlobalOnAvatar", (BYTE) 0 },
+ { &opts.global_on_nickname, CONTROL_CHECKBOX, IDC_GLOBAL_ON_NICKNAME, "GlobalOnNickname", (BYTE) 0 },
+ { &opts.global_on_status, CONTROL_CHECKBOX, IDC_GLOBAL_ON_STATUS, "GlobalOnStatus", (BYTE) 0 },
+ { &opts.global_on_status_message, CONTROL_CHECKBOX, IDC_GLOBAL_ON_STATUS_MESSAGE, "GlobalOnStatusMessage", (BYTE) 0 },
+ { &opts.draw_avatar_allow_to_grow, CONTROL_CHECKBOX, IDC_AVATAR_ALLOW_TO_GROW, "AvatarAllowToGrow", (BYTE) 0 },
+ { &opts.draw_avatar_custom_size, CONTROL_CHECKBOX, IDC_AVATAR_CUSTOM_SIZE_CHK, "AvatarCustomSize", (BYTE) 0 },
+ { &opts.draw_avatar_custom_size_pixels, CONTROL_SPIN, IDC_AVATAR_CUSTOM_SIZE, "AvatarCustomSizePixels", (WORD) 30, IDC_AVATAR_CUSTOM_SIZE_SPIN, (WORD) 1, (WORD) 255 },
+ { &opts.draw_avatar_border, CONTROL_CHECKBOX, IDC_AVATAR_DRAW_BORDER, "AvatarDrawBorders", (BYTE) 0 },
+ { &opts.draw_avatar_border_color, CONTROL_COLOR, IDC_AVATAR_BORDER_COLOR, "AvatarBorderColor", (DWORD) RGB(0,0,0) },
+ { &opts.draw_avatar_round_corner, CONTROL_CHECKBOX, IDC_AVATAR_ROUND_CORNERS, "AvatarRoundCorners", (BYTE) 1 },
+ { &opts.draw_avatar_use_custom_corner_size, CONTROL_CHECKBOX, IDC_AVATAR_CUSTOM_CORNER_SIZE_CHECK, "AvatarUseCustomCornerSize", (BYTE) 0 },
+ { &opts.draw_avatar_custom_corner_size, CONTROL_SPIN, IDC_AVATAR_CUSTOM_CORNER_SIZE, "AvatarCustomCornerSize", (WORD) 4, IDC_AVATAR_CUSTOM_CORNER_SIZE_SPIN, (WORD) 1, (WORD) 255 },
+ { &opts.use_avatar_space_to_draw_text, CONTROL_CHECKBOX, IDC_AVATAR_USE_FREE_SPACE, "AvatarUseFreeSpaceToDrawText", (BYTE) 1 },
+ { &opts.resize_frame, CONTROL_CHECKBOX, IDC_RESIZE_FRAME, "ResizeFrame", (BYTE) 0 },
+ { &opts.borders[RIGHT], CONTROL_SPIN, IDC_BORDER_RIGHT, "BorderRight", (WORD) 8, IDC_BORDER_RIGHT_SPIN, (WORD) 0, (WORD) 255 },
+ { &opts.borders[LEFT], CONTROL_SPIN, IDC_BORDER_LEFT, "BorderLeft", (WORD) 8, IDC_BORDER_LEFT_SPIN, (WORD) 0, (WORD) 255 },
+ { &opts.borders[TOP], CONTROL_SPIN, IDC_BORDER_TOP, "BorderTop", (WORD) 8, IDC_BORDER_TOP_SPIN, (WORD) 0, (WORD) 255 },
+ { &opts.borders[BOTTOM], CONTROL_SPIN, IDC_BORDER_BOTTOM, "BorderBottom", (WORD) 8, IDC_BORDER_BOTTOM_SPIN, (WORD) 0, (WORD) 255 },
+ { &opts.bkg_color, CONTROL_COLOR, IDC_AVATAR_BKG_COLOR, "BackgroundColor", (DWORD) GetSysColor(COLOR_BTNFACE) }
};
@@ -76,81 +76,62 @@ static INT_PTR CALLBACK DlgProcOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA
{
BOOL ret = SaveOptsDlgProc(pageControls, SIZEOF(pageControls), MODULE_NAME, hwndDlg, msg, wParam, lParam);
- switch (msg)
- {
- case WM_INITDIALOG:
- {
- if (!IsDlgButtonChecked(hwndDlg,IDC_AVATAR_DRAW_BORDER))
- {
- EnableWindow(GetDlgItem(hwndDlg,IDC_AVATAR_BORDER_COLOR_L),FALSE);
- EnableWindow(GetDlgItem(hwndDlg,IDC_AVATAR_BORDER_COLOR),FALSE);
- }
- if (!IsDlgButtonChecked(hwndDlg,IDC_AVATAR_ROUND_CORNERS))
- {
- EnableWindow(GetDlgItem(hwndDlg,IDC_AVATAR_CUSTOM_CORNER_SIZE_CHECK),FALSE);
- EnableWindow(GetDlgItem(hwndDlg,IDC_AVATAR_CUSTOM_CORNER_SIZE),FALSE);
- EnableWindow(GetDlgItem(hwndDlg,IDC_AVATAR_CUSTOM_CORNER_SIZE_SPIN),FALSE);
- }
- if (!IsDlgButtonChecked(hwndDlg,IDC_SHOW_PROTO_NAME))
- {
- EnableWindow(GetDlgItem(hwndDlg,IDC_SHOW_CYCLE_PROTO_BUTTON),FALSE);
- }
- if ( !ServiceExists(MS_SMILEYADD_BATCHPARSE))
- {
- EnableWindow(GetDlgItem(hwndDlg,IDC_REPLACE_SMILEYS),FALSE);
- EnableWindow(GetDlgItem(hwndDlg,IDC_USE_CONTACT_LIST_SMILEYS),FALSE);
- EnableWindow(GetDlgItem(hwndDlg,IDC_RESIZE_SMILEYS),FALSE);
- }
- if ( !ServiceExists(MS_CLIST_FRAMES_SETFRAMEOPTIONS))
- {
- EnableWindow(GetDlgItem(hwndDlg,IDC_RESIZE_FRAME),FALSE);
- }
+ switch (msg) {
+ case WM_INITDIALOG:
+ if (!IsDlgButtonChecked(hwndDlg,IDC_AVATAR_DRAW_BORDER)) {
+ EnableWindow(GetDlgItem(hwndDlg,IDC_AVATAR_BORDER_COLOR_L),FALSE);
+ EnableWindow(GetDlgItem(hwndDlg,IDC_AVATAR_BORDER_COLOR),FALSE);
+ }
- break;
+ if (!IsDlgButtonChecked(hwndDlg,IDC_AVATAR_ROUND_CORNERS)) {
+ EnableWindow(GetDlgItem(hwndDlg,IDC_AVATAR_CUSTOM_CORNER_SIZE_CHECK),FALSE);
+ EnableWindow(GetDlgItem(hwndDlg,IDC_AVATAR_CUSTOM_CORNER_SIZE),FALSE);
+ EnableWindow(GetDlgItem(hwndDlg,IDC_AVATAR_CUSTOM_CORNER_SIZE_SPIN),FALSE);
}
- case WM_COMMAND:
- {
- if (LOWORD(wParam)==IDC_AVATAR_DRAW_BORDER)
- {
- BOOL enabled = IsDlgButtonChecked(hwndDlg,IDC_AVATAR_DRAW_BORDER);
- EnableWindow(GetDlgItem(hwndDlg,IDC_AVATAR_BORDER_COLOR_L),enabled);
- EnableWindow(GetDlgItem(hwndDlg,IDC_AVATAR_BORDER_COLOR),enabled);
- }
- else if (LOWORD(wParam)==IDC_AVATAR_ROUND_CORNERS)
- {
- BOOL enabled = IsDlgButtonChecked(hwndDlg,IDC_AVATAR_ROUND_CORNERS);
- EnableWindow(GetDlgItem(hwndDlg,IDC_AVATAR_CUSTOM_CORNER_SIZE_CHECK),enabled);
- EnableWindow(GetDlgItem(hwndDlg,IDC_AVATAR_CUSTOM_CORNER_SIZE),enabled);
- EnableWindow(GetDlgItem(hwndDlg,IDC_AVATAR_CUSTOM_CORNER_SIZE_SPIN),enabled);
- }
- else if (LOWORD(wParam)==IDC_SHOW_PROTO_NAME)
- {
- BOOL enabled = IsDlgButtonChecked(hwndDlg,IDC_SHOW_PROTO_NAME);
- EnableWindow(GetDlgItem(hwndDlg,IDC_SHOW_CYCLE_PROTO_BUTTON),enabled);
- }
- break;
+ if (!IsDlgButtonChecked(hwndDlg,IDC_SHOW_PROTO_NAME))
+ EnableWindow(GetDlgItem(hwndDlg,IDC_SHOW_CYCLE_PROTO_BUTTON),FALSE);
+
+ if ( !ServiceExists(MS_SMILEYADD_BATCHPARSE)) {
+ EnableWindow(GetDlgItem(hwndDlg,IDC_REPLACE_SMILEYS),FALSE);
+ EnableWindow(GetDlgItem(hwndDlg,IDC_USE_CONTACT_LIST_SMILEYS),FALSE);
+ EnableWindow(GetDlgItem(hwndDlg,IDC_RESIZE_SMILEYS),FALSE);
+ }
+
+ if ( !ServiceExists(MS_CLIST_FRAMES_SETFRAMEOPTIONS))
+ EnableWindow(GetDlgItem(hwndDlg,IDC_RESIZE_FRAME),FALSE);
+
+ break;
+
+ case WM_COMMAND:
+ if (LOWORD(wParam)==IDC_AVATAR_DRAW_BORDER) {
+ BOOL enabled = IsDlgButtonChecked(hwndDlg,IDC_AVATAR_DRAW_BORDER);
+ EnableWindow(GetDlgItem(hwndDlg,IDC_AVATAR_BORDER_COLOR_L),enabled);
+ EnableWindow(GetDlgItem(hwndDlg,IDC_AVATAR_BORDER_COLOR),enabled);
+ }
+ else if (LOWORD(wParam)==IDC_AVATAR_ROUND_CORNERS) {
+ BOOL enabled = IsDlgButtonChecked(hwndDlg,IDC_AVATAR_ROUND_CORNERS);
+ EnableWindow(GetDlgItem(hwndDlg,IDC_AVATAR_CUSTOM_CORNER_SIZE_CHECK),enabled);
+ EnableWindow(GetDlgItem(hwndDlg,IDC_AVATAR_CUSTOM_CORNER_SIZE),enabled);
+ EnableWindow(GetDlgItem(hwndDlg,IDC_AVATAR_CUSTOM_CORNER_SIZE_SPIN),enabled);
+ }
+ else if (LOWORD(wParam)==IDC_SHOW_PROTO_NAME) {
+ BOOL enabled = IsDlgButtonChecked(hwndDlg,IDC_SHOW_PROTO_NAME);
+ EnableWindow(GetDlgItem(hwndDlg,IDC_SHOW_CYCLE_PROTO_BUTTON),enabled);
}
- case WM_NOTIFY:
- {
- switch (((LPNMHDR)lParam)->idFrom)
- {
- case 0:
- {
- switch (((LPNMHDR)lParam)->code)
- {
- case PSN_APPLY:
- {
- LoadOptions();
-
- return TRUE;
- }
- }
- break;
- }
+ break;
+
+ case WM_NOTIFY:
+ switch (((LPNMHDR)lParam)->idFrom) {
+ case 0:
+ switch (((LPNMHDR)lParam)->code) {
+ case PSN_APPLY:
+ LoadOptions();
+ return TRUE;
}
break;
}
+ break;
}
return ret;