From a197d77bd256a1ebe58454a34315e252d5441edc Mon Sep 17 00:00:00 2001 From: Tobias Weimer Date: Sun, 12 May 2013 13:31:34 +0000 Subject: wbOSD adopted, initial version git-svn-id: http://svn.miranda-ng.org/main/trunk@4638 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/wbOSD/buildnumber.h | 6 + plugins/wbOSD/events.cpp | 208 ++++++++++++++++ plugins/wbOSD/main.cpp | 99 ++++++++ plugins/wbOSD/options.cpp | 422 +++++++++++++++++++++++++++++++++ plugins/wbOSD/readme.txt | 84 +++++++ plugins/wbOSD/resource.h | 57 +++++ plugins/wbOSD/wbOSD.cpp | 309 ++++++++++++++++++++++++ plugins/wbOSD/wbOSD.h | 128 ++++++++++ plugins/wbOSD/wbOSD.rc | 188 +++++++++++++++ plugins/wbOSD/wbOSD_10.vcxproj | 188 +++++++++++++++ plugins/wbOSD/wbOSD_10.vcxproj.filters | 50 ++++ 11 files changed, 1739 insertions(+) create mode 100644 plugins/wbOSD/buildnumber.h create mode 100644 plugins/wbOSD/events.cpp create mode 100644 plugins/wbOSD/main.cpp create mode 100644 plugins/wbOSD/options.cpp create mode 100644 plugins/wbOSD/readme.txt create mode 100644 plugins/wbOSD/resource.h create mode 100644 plugins/wbOSD/wbOSD.cpp create mode 100644 plugins/wbOSD/wbOSD.h create mode 100644 plugins/wbOSD/wbOSD.rc create mode 100644 plugins/wbOSD/wbOSD_10.vcxproj create mode 100644 plugins/wbOSD/wbOSD_10.vcxproj.filters (limited to 'plugins') diff --git a/plugins/wbOSD/buildnumber.h b/plugins/wbOSD/buildnumber.h new file mode 100644 index 0000000000..b77727792f --- /dev/null +++ b/plugins/wbOSD/buildnumber.h @@ -0,0 +1,6 @@ +#ifndef _BUILDNUMBER_ +#define BUILDNUMBER 0 +#define __FILEVERSION_STRING 0,2,1,0 +#define __VERSION_STRING "0.2.1.0" +#define __VERSION_DWORD 0x20100 +#endif //_BUILDNUMBER_ diff --git a/plugins/wbOSD/events.cpp b/plugins/wbOSD/events.cpp new file mode 100644 index 0000000000..83d5d79c6b --- /dev/null +++ b/plugins/wbOSD/events.cpp @@ -0,0 +1,208 @@ +/* +Wannabe OSD +This plugin tries to become miranda's standard OSD ;-) + +(C) 2005 Andrej Krutak + +Distributed under GNU's GPL 2 or later +*/ + +#include "wbOSD.h" +#include + +extern HWND hwnd; +extern HANDLE hHookContactStatusChanged; + +void logmsg2(char *str) +{ + FILE *f=fopen("c:\\logm.txt", "a"); + fprintf(f, "%s\n", str); + fclose(f); +} + +void showmsgwnd(unsigned int param) +{ + logmsg("showmsgwnd"); + if (db_get_b(NULL,THIS_MODULE, "showMessageWindow", DEFAULT_SHOWMSGWIN)) + CallService(MS_MSG_SENDMESSAGET, (WPARAM)param, 0); +} + +LRESULT ShowOSD(TCHAR *str, int timeout, COLORREF color, HANDLE user) +{ + logmsg("ShowOSD"); + + if (!hwnd) + return 0; + + if (timeout==0) + timeout=db_get_dw(NULL,THIS_MODULE, "timeout", DEFAULT_TIMEOUT); + + osdmsg om; + om.text=str; + om.timeout=timeout; + om.color=color; + om.param=(unsigned int)user; + om.callback=showmsgwnd; + + return SendMessage(hwnd, WM_USER+4, (WPARAM)&om, 0); +} + +int ProtoAck(WPARAM,LPARAM lparam) +{ + ACKDATA *ack=(ACKDATA *)lparam; + + logmsg("ProtoAck"); + + if (!db_get_b(NULL,THIS_MODULE, "a_user", DEFAULT_ANNOUNCESTATUS)) + return 0; + + if (!(db_get_dw(NULL,THIS_MODULE,"showWhen", DEFAULT_SHOWWHEN)&(1<<(db_get_w(NULL, "CList", "Status", ID_STATUS_OFFLINE)-ID_STATUS_OFFLINE)))) + return 0; + + if ( ack->type == ACKTYPE_STATUS ) { + if (!db_get_b(NULL,THIS_MODULE, "showMyStatus", DEFAULT_SHOWMYSTATUS)) + return 0; + + if ( ack->result == ACKRESULT_SUCCESS && (LPARAM)ack->hProcess != ack->lParam ) { + DWORD ann = db_get_dw( NULL, THIS_MODULE, "announce", DEFAULT_ANNOUNCE ); + if ( ann & ( 1 << ( ack->lParam - ID_STATUS_OFFLINE ))) { + TCHAR buffer[512]; + mir_sntprintf(buffer, SIZEOF(buffer), TranslateT("%s is %s"), CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)ack->hContact, GCDNF_TCHAR), CallService(MS_CLIST_GETSTATUSMODEDESCRIPTION,(WPARAM) ack->lParam,GSMDF_TCHAR)); + ShowOSD(buffer, 0, db_get_dw(NULL,THIS_MODULE, "clr_status", DEFAULT_CLRSTATUS), ack->hContact); + } } } + + return 0; +} + +int ContactSettingChanged(WPARAM wParam,LPARAM lParam) +{ + HANDLE hContact = (HANDLE) wParam; + DBCONTACTWRITESETTING *cws=(DBCONTACTWRITESETTING*)lParam; + + logmsg("ContactSettingChanged1"); + + if(hContact==NULL || lstrcmpA(cws->szSetting,"Status")) return 0; + + WORD newStatus = cws->value.wVal; + WORD oldStatus = DBGetContactSettingRangedWord(hContact,"UserOnline","OldStatus2",ID_STATUS_OFFLINE, ID_STATUS_MIN, ID_STATUS_MAX); + + if (oldStatus == newStatus) return 0; + + logmsg("ContactSettingChanged2"); + + db_set_w(hContact,"UserOnline","OldStatus2", newStatus); + + if(CallService(MS_IGNORE_ISIGNORED,wParam,IGNOREEVENT_USERONLINE)) return 0; + + DWORD dwStatuses = MAKELPARAM(oldStatus, newStatus); + NotifyEventHooks(hHookContactStatusChanged, wParam, (LPARAM)dwStatuses); + + return 0; +} + +int ContactStatusChanged(WPARAM wParam, LPARAM lParam) +{ + HANDLE hContact = (HANDLE) wParam; + WORD oldStatus = LOWORD(lParam); + WORD newStatus = HIWORD(lParam); + DWORD ann=db_get_dw(NULL,THIS_MODULE,"announce", DEFAULT_ANNOUNCE); + + logmsg("ContactStatusChanged1"); + + if (!db_get_b(NULL,THIS_MODULE, "a_user", DEFAULT_ANNOUNCESTATUS)) + return 0; + + if (!(db_get_dw(NULL,THIS_MODULE,"showWhen", DEFAULT_SHOWWHEN)&(1<<(db_get_w(NULL, "CList", "Status", ID_STATUS_OFFLINE)-ID_STATUS_OFFLINE)))) + return 0; + + if (!(ann&(1<<(newStatus-ID_STATUS_OFFLINE))) ) + return 0; + + logmsg("ContactStatusChanged2"); + + if (db_get_b(hContact,"CList","NotOnList",0) || db_get_b(hContact,"CList","Hidden",0) || + (CallService(MS_IGNORE_ISIGNORED,wParam,IGNOREEVENT_USERONLINE) && newStatus==ID_STATUS_ONLINE) + ) + return 0; + + TCHAR bufferW[512]; + mir_sntprintf(bufferW, SIZEOF(bufferW), TranslateT("%s is %s"), CallService(MS_CLIST_GETCONTACTDISPLAYNAME, wParam, GCDNF_TCHAR), CallService(MS_CLIST_GETSTATUSMODEDESCRIPTION,newStatus,GSMDF_TCHAR)); + ShowOSD(bufferW, 0, db_get_dw(NULL,THIS_MODULE, "clr_status", DEFAULT_CLRSTATUS), hContact); + return 0; +} + +int HookedNewEvent(WPARAM wParam, LPARAM lParam) +{ + logmsg("HookedNewEvent1"); + HANDLE hDBEvent = (HANDLE) lParam; + DBEVENTINFO dbe; + dbe.cbSize = sizeof(dbe); + dbe.cbBlob = db_event_getBlobSize(hDBEvent); + if (dbe.cbBlob == -1) + return 0; + + dbe.pBlob = (PBYTE) malloc(dbe.cbBlob); + if(db_event_get(hDBEvent,&dbe)) + return 0; + + if (dbe.flags & DBEF_SENT || dbe.eventType == 25368) + return 0; + + if (db_get_b(NULL,THIS_MODULE, "messages", DEFAULT_ANNOUNCEMESSAGES)==0) + return 0; + + if (!(db_get_dw(NULL,THIS_MODULE,"showWhen", DEFAULT_SHOWWHEN)&(1<<(db_get_w(NULL, "CList", "Status", ID_STATUS_OFFLINE)-ID_STATUS_OFFLINE)))) + return 0; + + logmsg("HookedNewEvent2"); + + TCHAR buf[512]; + _tcsncpy(buf, DEFAULT_MESSAGEFORMAT,SIZEOF(buf)); + + DBVARIANT dbv; + if(!db_get_ts(NULL,THIS_MODULE,"message_format",&dbv)) { + _tcscpy(buf, dbv.ptszVal); + db_free(&dbv); + } + + int i1=-1, i2=-1; + TCHAR* pbuf = buf; + while (*pbuf) { + if (*pbuf=='%') { + if (*(pbuf+1)=='n') { + if (i1==-1) + i1=1; + else i2=1; + *(pbuf+1)='s'; + } else if (*(pbuf+1)=='m') { + if (i1==-1) + i1=2; + else i2=2; + *(pbuf+1)='s'; + } else if (*(pbuf+1)=='l') { + *pbuf=0x0d; + *(pbuf+1)=0x0a; + } + } + pbuf++; + } + + TCHAR *c1 = 0, *c2 = 0; + if ( i1 == 1 ) + c1 = mir_tstrdup(( TCHAR* )CallService(MS_CLIST_GETCONTACTDISPLAYNAME, wParam, GCDNF_TCHAR)); + else if ( i1 == 2 ) + c1 = DbGetEventTextT( &dbe, 0 ); + + if ( i2 == 1 ) + c2 = mir_tstrdup(( TCHAR* )CallService(MS_CLIST_GETCONTACTDISPLAYNAME, wParam, GCDNF_TCHAR)); + else if ( i2 == 2 ) + c2 = DbGetEventTextT( &dbe, 0 ); + + TCHAR buffer[512]; + mir_sntprintf(buffer, SIZEOF(buffer), buf, c1, c2); + ShowOSD(buffer, 0, db_get_dw(NULL,THIS_MODULE, "clr_msg", DEFAULT_CLRMSG), (HANDLE)wParam); + + mir_free( c1 ); + mir_free( c2 ); + return 0; +} diff --git a/plugins/wbOSD/main.cpp b/plugins/wbOSD/main.cpp new file mode 100644 index 0000000000..d4d4cc260a --- /dev/null +++ b/plugins/wbOSD/main.cpp @@ -0,0 +1,99 @@ +/* +Wannabe OSD +This plugin tries to become miranda's standard OSD ;-) + +(C) 2005 Andrej Krutak + +Distributed under GNU's GPL 2 or later +*/ + +#include "wbOSD.h" +#include "buildnumber.h" + +HINSTANCE hI; + +HWND hwnd=0; +HANDLE hservosda; +int hLangpack = 0; +HANDLE hHookedNewEvent, hHookedInit, hProtoAck, hContactSettingChanged, hHookContactStatusChanged, hContactStatusChanged, hpluginShutDown; +HINSTANCE hUser32; +BOOL (WINAPI*pSetLayeredWindowAttributes)(HWND, COLORREF, BYTE, DWORD); + +void logmsg2(char *str); +int MainInit(WPARAM,LPARAM); + +///////////////////////////////////////////////////////////////////////////////////////// + +static PLUGININFOEX pluginInfo = { + sizeof(PLUGININFOEX), + "WannaBe OSD", + __VERSION_DWORD, + "Show new message/status change info using onscreen display", + "Andrej Krutak", + "andree182 {at} gmail (dot) com", + "©2005 Andrej Krutak", + "http://urtax.ms.mff.cuni.cz/~andree/", + UNICODE_AWARE, + { 0xfc718bc7, 0xabc8, 0x43cd, { 0xaa, 0xd9, 0x76, 0x16, 0x14, 0x61, 0x77, 0x38 } } // {FC718BC7-ABC8-43CD-AAD9-761614617738} +}; + +extern "C" __declspec(dllexport) PLUGININFOEX *MirandaPluginInfoEx(DWORD) +{ + return &pluginInfo; +} + +///////////////////////////////////////////////////////////////////////////////////////// + +extern "C" __declspec(dllexport) int Load() +{ + mir_getLP(&pluginInfo); + + logmsg("Load"); + pSetLayeredWindowAttributes=0; + +#ifndef FORCE_9XDRAWING + hUser32=LoadLibrary(_T("user32.dll")); +#else + hUser32=0; +#endif + + if (hUser32) { + pSetLayeredWindowAttributes=(BOOL(WINAPI*)(HWND, COLORREF, BYTE, DWORD))GetProcAddress(hUser32, "SetLayeredWindowAttributes"); + if (!pSetLayeredWindowAttributes) { + FreeLibrary(hUser32); + hUser32=0; + } + } + + hHookedInit = HookEvent(ME_SYSTEM_MODULESLOADED, MainInit); + return 0; +} + +///////////////////////////////////////////////////////////////////////////////////////// + +extern "C" __declspec(dllexport) int Unload() +{ + logmsg("Unload"); + UnhookEvent(hpluginShutDown); + UnhookEvent(hProtoAck); + UnhookEvent(hContactSettingChanged); + UnhookEvent(hContactStatusChanged); + UnhookEvent(hHookedNewEvent); + UnhookEvent(hHookedInit); + + if (hUser32) + FreeLibrary(hUser32); + pSetLayeredWindowAttributes=0; + + DestroyServiceFunction(hservosda); + DestroyHookableEvent(hHookContactStatusChanged); + return 0; +} + +///////////////////////////////////////////////////////////////////////////////////////// + +BOOL WINAPI DllMain(HINSTANCE hinst,DWORD fdwReason,LPVOID lpvReserved) +{ + hI = hinst; + return TRUE; +} diff --git a/plugins/wbOSD/options.cpp b/plugins/wbOSD/options.cpp new file mode 100644 index 0000000000..fdc8787fa5 --- /dev/null +++ b/plugins/wbOSD/options.cpp @@ -0,0 +1,422 @@ +/* +Wannabe OSD +This plugin tries to become miranda's standard OSD ;-) + +(C) 2005 Andrej Krutak + +Distributed under GNU's GPL 2 or later +*/ + +#include "wbOSD.h" + +COLORREF pencustcolors[16]; + +const static osdmsg defstr={_T(""), 0, RGB(0, 0, 0), 0, 0}; + +void FillCheckBoxTree(HWND hwndTree,DWORD style) +{ + logmsg("FillCheckBoxTree"); + + TVINSERTSTRUCT tvis; + tvis.hParent = NULL; + tvis.hInsertAfter = TVI_LAST; + tvis.item.mask = TVIF_PARAM|TVIF_TEXT|TVIF_STATE; + for ( WORD status = ID_STATUS_OFFLINE; status <=ID_STATUS_OUTTOLUNCH; status++ ) { + tvis.item.lParam = status - ID_STATUS_OFFLINE; + tvis.item.pszText = (TCHAR*) CallService(MS_CLIST_GETSTATUSMODEDESCRIPTION,(WPARAM) status,GSMDF_TCHAR); + tvis.item.stateMask = TVIS_STATEIMAGEMASK; + tvis.item.state = INDEXTOSTATEIMAGEMASK(( style & ( 1 << tvis.item.lParam )) != 0 ? 2 : 1 ); + TreeView_InsertItem( hwndTree, &tvis ); + } +} + +DWORD MakeCheckBoxTreeFlags(HWND hwndTree) +{ + DWORD flags=0; + + logmsg("MakeCheckBoxTreeFlags"); + + TVITEM tvi; + tvi.mask=TVIF_HANDLE|TVIF_PARAM|TVIF_STATE; + tvi.hItem=TreeView_GetRoot(hwndTree); + while(tvi.hItem) { + TreeView_GetItem(hwndTree,&tvi); + if(((tvi.state&TVIS_STATEIMAGEMASK)>>12==2)) flags|=1<align=db_get_b(NULL,THIS_MODULE, "align", DEFAULT_ALIGN); + ps->salign=db_get_b(NULL,THIS_MODULE, "salign", DEFAULT_SALIGN); + ps->altShadow=db_get_b(NULL,THIS_MODULE, "altShadow", DEFAULT_ALTSHADOW); + ps->transparent=db_get_b(NULL,THIS_MODULE, "transparent", DEFAULT_TRANPARENT); + ps->showShadow=db_get_b(NULL,THIS_MODULE, "showShadow", DEFAULT_SHOWSHADOW); + ps->messages=db_get_b(NULL,THIS_MODULE, "messages", DEFAULT_ANNOUNCEMESSAGES); + ps->a_user=db_get_b(NULL,THIS_MODULE, "a_user", DEFAULT_ANNOUNCESTATUS); + ps->distance=db_get_b(NULL,THIS_MODULE, "distance", DEFAULT_DISTANCE); + ps->winx=db_get_dw(NULL,THIS_MODULE, "winx", DEFAULT_WINX); + ps->winy=db_get_dw(NULL,THIS_MODULE, "winy", DEFAULT_WINY); + ps->winxpos=db_get_dw(NULL,THIS_MODULE, "winxpos", DEFAULT_WINXPOS); + ps->winypos=db_get_dw(NULL,THIS_MODULE, "winypos", DEFAULT_WINYPOS); + ps->alpha=db_get_b(NULL,THIS_MODULE, "alpha", DEFAULT_ALPHA); + ps->showmystatus=db_get_b(NULL,THIS_MODULE, "showMyStatus", DEFAULT_SHOWMYSTATUS); + ps->timeout=db_get_dw(NULL,THIS_MODULE, "timeout", DEFAULT_TIMEOUT); + ps->clr_msg=db_get_dw(NULL,THIS_MODULE, "clr_msg", DEFAULT_CLRMSG); + ps->clr_status=db_get_dw(NULL,THIS_MODULE, "clr_status", DEFAULT_CLRSTATUS); + ps->clr_shadow=db_get_dw(NULL,THIS_MODULE, "clr_shadow", DEFAULT_CLRSHADOW); + ps->bkclr=db_get_dw(NULL,THIS_MODULE, "bkclr", DEFAULT_BKCLR); + + ps->showMsgWindow=db_get_b(NULL,THIS_MODULE, "showMessageWindow", DEFAULT_SHOWMSGWIN); + ps->showWhen=db_get_dw(NULL,THIS_MODULE,"showWhen", DEFAULT_SHOWWHEN); + + DBVARIANT dbv; + if (!db_get_ts( NULL, THIS_MODULE, "message_format", &dbv )) { + _tcscpy(ps->msgformat, dbv.ptszVal); + db_free(&dbv); + } + else _tcscpy(ps->msgformat, DEFAULT_MESSAGEFORMAT); + + ps->announce=db_get_dw(NULL,THIS_MODULE,"announce", DEFAULT_ANNOUNCE); + + ps->lf.lfHeight=db_get_dw(NULL,THIS_MODULE, "fntHeight", DEFAULT_FNT_HEIGHT); + ps->lf.lfWidth=db_get_dw(NULL,THIS_MODULE, "fntWidth", DEFAULT_FNT_WIDTH); + ps->lf.lfEscapement=db_get_dw(NULL,THIS_MODULE, "fntEscapement", DEFAULT_FNT_ESCAPEMENT); + ps->lf.lfOrientation=db_get_dw(NULL,THIS_MODULE, "fntOrientation", DEFAULT_FNT_ORIENTATION); + ps->lf.lfWeight=db_get_dw(NULL,THIS_MODULE, "fntWeight", DEFAULT_FNT_WEIGHT); + ps->lf.lfItalic=db_get_b(NULL,THIS_MODULE, "fntItalic", DEFAULT_FNT_ITALIC); + ps->lf.lfUnderline=db_get_b(NULL,THIS_MODULE, "fntUnderline", DEFAULT_FNT_UNDERLINE); + ps->lf.lfStrikeOut=db_get_b(NULL,THIS_MODULE, "fntStrikeout", DEFAULT_FNT_STRIKEOUT); + ps->lf.lfCharSet=db_get_b(NULL,THIS_MODULE, "fntCharSet", DEFAULT_FNT_CHARSET); + ps->lf.lfOutPrecision=db_get_b(NULL,THIS_MODULE, "fntOutPrecision", DEFAULT_FNT_OUTPRECISION); + ps->lf.lfClipPrecision=db_get_b(NULL,THIS_MODULE, "fntClipPrecision", DEFAULT_FNT_CLIPRECISION); + ps->lf.lfQuality=db_get_b(NULL,THIS_MODULE, "fntQuality", DEFAULT_FNT_QUALITY); + ps->lf.lfPitchAndFamily=db_get_b(NULL,THIS_MODULE, "fntPitchAndFamily", DEFAULT_FNT_PITCHANDFAM); + + if(!db_get_ts(NULL,THIS_MODULE,"fntFaceName",&dbv)) { + _tcscpy(ps->lf.lfFaceName, dbv.ptszVal); + db_free(&dbv); + } + else + _tcscpy(ps->lf.lfFaceName, DEFAULT_FNT_FACENAME); +} + +void saveDBSettings(plgsettings *ps) +{ + logmsg("saveDBSettings"); + + db_set_b(NULL,THIS_MODULE,"showShadow", ps->showShadow); + db_set_b(NULL,THIS_MODULE,"altShadow",ps->altShadow); + db_set_b(NULL,THIS_MODULE,"distance",ps->distance); + + db_set_dw(NULL,THIS_MODULE,"winx",ps->winx); + db_set_dw(NULL,THIS_MODULE,"winy",ps->winy); + db_set_dw(NULL,THIS_MODULE,"winxpos", ps->winxpos); + db_set_dw(NULL,THIS_MODULE,"winypos", ps->winypos); + + db_set_b(NULL,THIS_MODULE,"alpha",ps->alpha); + db_set_dw(NULL,THIS_MODULE,"timeout", ps->timeout); + + db_set_b(NULL,THIS_MODULE,"transparent",ps->transparent); + db_set_b(NULL,THIS_MODULE,"messages",ps->messages); + db_set_b(NULL,THIS_MODULE,"a_user",ps->a_user); + db_set_ts(NULL,THIS_MODULE, "message_format", ps->msgformat); + + db_set_b(NULL,THIS_MODULE,"align",ps->align); + db_set_b(NULL,THIS_MODULE,"salign",ps->salign); + + db_set_b(NULL,THIS_MODULE,"showMyStatus",ps->showmystatus); + + db_set_dw(NULL,THIS_MODULE,"clr_msg", ps->clr_msg); + db_set_dw(NULL,THIS_MODULE,"clr_shadow", ps->clr_shadow); + db_set_dw(NULL,THIS_MODULE,"clr_status", ps->clr_status); + db_set_dw(NULL,THIS_MODULE,"bkclr", ps->bkclr); + + db_set_dw(NULL,THIS_MODULE, "fntHeight", ps->lf.lfHeight); + db_set_dw(NULL,THIS_MODULE, "fntWidth", ps->lf.lfWidth); + db_set_dw(NULL,THIS_MODULE, "fntEscapement", ps->lf.lfEscapement); + db_set_dw(NULL,THIS_MODULE, "fntOrientation", ps->lf.lfOrientation); + db_set_dw(NULL,THIS_MODULE, "fntWeight", ps->lf.lfWeight); + db_set_b(NULL,THIS_MODULE, "fntItalic", ps->lf.lfItalic); + db_set_b(NULL,THIS_MODULE, "fntUnderline", ps->lf.lfUnderline); + db_set_b(NULL,THIS_MODULE, "fntStrikeout", ps->lf.lfStrikeOut); + db_set_b(NULL,THIS_MODULE, "fntCharSet", ps->lf.lfCharSet); + db_set_b(NULL,THIS_MODULE, "fntOutPrecision", ps->lf.lfOutPrecision); + db_set_b(NULL,THIS_MODULE, "fntClipPrecision", ps->lf.lfClipPrecision); + db_set_b(NULL,THIS_MODULE, "fntQuality", ps->lf.lfQuality); + db_set_b(NULL,THIS_MODULE, "fntPitchAndFamily", ps->lf.lfPitchAndFamily); + db_set_ts(NULL,THIS_MODULE, "fntFaceName", ps->lf.lfFaceName); + + db_set_dw(NULL,THIS_MODULE,"announce", ps->announce); + + db_set_b(NULL,THIS_MODULE, "showMessageWindow", ps->showMsgWindow); + db_set_dw(NULL,THIS_MODULE,"showWhen", ps->showWhen); +} + +INT_PTR CALLBACK OptDlgProc(HWND hDlg,UINT msg,WPARAM wparam,LPARAM lparam) +{ + RECT rect; + plgsettings *ps; //0: current; 1: original + + logmsg("OptDlgProc"); + + switch(msg){ + case WM_INITDIALOG: + logmsg("OptDlgProc::INITDIALOG"); + TranslateDialogDefault(hDlg); + + ps=(plgsettings*)malloc(sizeof(plgsettings)*2); + loadDBSettings(&ps[0]); + ps[1]=ps[0]; + SetWindowLongPtr(hDlg, GWLP_USERDATA, (LONG)ps); + SetWindowLongPtr(hwnd, GWL_STYLE, (LONG)(pSetLayeredWindowAttributes?0:WS_CLIPSIBLINGS)|WS_POPUP|WS_SIZEBOX); + SetWindowPos(hwnd, 0, 0, 0, 0, 0, SWP_NOZORDER|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_FRAMECHANGED); + + SetWindowLongPtr(GetDlgItem(hDlg,IDC_TREE1),GWL_STYLE,GetWindowLong(GetDlgItem(hDlg,IDC_TREE1),GWL_STYLE)|TVS_NOHSCROLL|TVS_CHECKBOXES); + SetWindowLongPtr(GetDlgItem(hDlg,IDC_TREE2),GWL_STYLE,GetWindowLong(GetDlgItem(hDlg,IDC_TREE1),GWL_STYLE)|TVS_NOHSCROLL|TVS_CHECKBOXES); + + CheckDlgButton(hDlg, IDC_RADIO1+ps->align-1, BST_CHECKED); + CheckDlgButton(hDlg, IDC_RADIO10+9-ps->salign, BST_CHECKED); + CheckDlgButton(hDlg, IDC_CHECK1, ps->altShadow); + CheckDlgButton(hDlg, IDC_CHECK2, ps->showMsgWindow); + CheckDlgButton(hDlg, IDC_CHECK3, ps->transparent); + CheckDlgButton(hDlg, IDC_CHECK4, ps->showShadow); + CheckDlgButton(hDlg, IDC_CHECK5, ps->messages); + + SetDlgItemText(hDlg, IDC_EDIT2, ps->msgformat); + + CheckDlgButton(hDlg, IDC_CHECK6, ps->a_user); + CheckDlgButton(hDlg, IDC_CHECK7, ps->showmystatus); + SetDlgItemInt(hDlg, IDC_EDIT1, ps->distance, 0); + + SendDlgItemMessage(hDlg, IDC_SLIDER1, TBM_SETRANGE, (WPARAM)0, MAKELONG(0, 255)); + SendDlgItemMessage(hDlg, IDC_SLIDER1, TBM_SETPOS, (WPARAM)TRUE, (LPARAM)ps->alpha); + + { + TCHAR buf[20]; + mir_sntprintf(buf, SIZEOF(buf), _T("%d %%"), ps->alpha*100/255); + SetDlgItemText(hDlg, IDC_ALPHATXT, buf); + } + + SetDlgItemInt(hDlg, IDC_EDIT5, ps->timeout, 0); + FillCheckBoxTree(GetDlgItem(hDlg, IDC_TREE1), ps->announce); + FillCheckBoxTree(GetDlgItem(hDlg, IDC_TREE2), ps->showWhen); + return 0; + + case WM_HSCROLL: + if (LOWORD(wparam)==SB_ENDSCROLL||LOWORD(wparam)==SB_THUMBPOSITION||LOWORD(wparam)==SB_ENDSCROLL) + return 0; + ps=(plgsettings*)GetWindowLongPtr(hDlg, GWLP_USERDATA); + ps->alpha=SendDlgItemMessage(hDlg, IDC_SLIDER1, TBM_GETPOS, 0, 0); + { + TCHAR buf[20]; + mir_sntprintf(buf, SIZEOF(buf), _T("%d %%"), ps->alpha*100/255); + SetDlgItemText(hDlg, IDC_ALPHATXT, buf); + } + goto xxx; + case WM_DESTROY: + logmsg("OptDlgProc::DESTROY"); + ps=(plgsettings*)GetWindowLongPtr(hDlg, GWLP_USERDATA); + ps[0]=ps[1]; + saveDBSettings(&ps[0]); + + SetWindowLongPtr(hwnd, GWL_STYLE, (LONG)(pSetLayeredWindowAttributes?0:WS_CLIPSIBLINGS)|WS_POPUP); + SetWindowPos(hwnd, 0, 0, 0, 0, 0, SWP_NOZORDER|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_FRAMECHANGED); + + SetWindowPos(hwnd, 0, ps->winxpos, ps->winypos, ps->winx, ps->winy, SWP_NOZORDER|SWP_NOACTIVATE); + if (pSetLayeredWindowAttributes) + pSetLayeredWindowAttributes(hwnd, ps->bkclr, ps->alpha, (ps->transparent?LWA_COLORKEY:0)|LWA_ALPHA); + + free((void*)GetWindowLongPtr(hDlg, GWLP_USERDATA)); + return 0; + case WM_COMMAND: + logmsg("OptDlgProc::COMMAND"); + ps=(plgsettings*)GetWindowLongPtr(hDlg, GWLP_USERDATA); + switch (LOWORD(wparam)) { + case IDC_BUTTON7: + MessageBox(hDlg, _T("Variables:\n %n : Nick\n %m : Message\n %l : New line"), _T("Help"), MB_ICONINFORMATION|MB_OK); + return 0; + case IDC_BUTTON5: + SendMessage(hwnd, WM_USER+1, (WPARAM)_T("miranda is gr8 and this is a long message ;-)"), 0); + break; + case IDC_BUTTON1: + selectFont(hDlg, &(ps->lf)); + break; + case IDC_BUTTON2: + selectColor(hDlg, &ps->clr_status); + break; + case IDC_BUTTON6: + selectColor(hDlg, &ps->clr_msg); + break; + case IDC_BUTTON3: + selectColor(hDlg, &ps->clr_shadow); + break; + case IDC_BUTTON4: + selectColor(hDlg, &ps->bkclr); + break; + case IDC_CHECK4: + ps->showShadow=IsDlgButtonChecked(hDlg, IDC_CHECK4); + break; + case IDC_CHECK1: + ps->altShadow=IsDlgButtonChecked(hDlg, IDC_CHECK1); + break; + case IDC_CHECK2: + ps->showMsgWindow=IsDlgButtonChecked(hDlg, IDC_CHECK2); + case IDC_EDIT1: + ps->distance=GetDlgItemInt(hDlg, IDC_EDIT1, 0, 0); + break; + case IDC_EDIT5: + ps->timeout=GetDlgItemInt(hDlg, IDC_EDIT5, 0, 0); + break; + case IDC_CHECK3: + ps->transparent=IsDlgButtonChecked(hDlg, IDC_CHECK3); + break; + case IDC_CHECK5: + ps->messages=IsDlgButtonChecked(hDlg, IDC_CHECK5); + break; + case IDC_CHECK6: + ps->a_user=IsDlgButtonChecked(hDlg, IDC_CHECK6); + break; + case IDC_CHECK7: + ps->showmystatus=IsDlgButtonChecked(hDlg, IDC_CHECK7); + break; + case IDC_RADIO1: + case IDC_RADIO2: + case IDC_RADIO3: + case IDC_RADIO4: + case IDC_RADIO5: + case IDC_RADIO6: + case IDC_RADIO7: + case IDC_RADIO8: + case IDC_RADIO9: + if (IsDlgButtonChecked(hDlg, LOWORD(wparam))) + ps->align=LOWORD(wparam)-IDC_RADIO1+1; + break; + case IDC_RADIO10: + case IDC_RADIO11: + case IDC_RADIO12: + case IDC_RADIO13: + case IDC_RADIO14: + case IDC_RADIO15: + case IDC_RADIO16: + case IDC_RADIO17: + case IDC_RADIO18: + if (IsDlgButtonChecked(hDlg, LOWORD(wparam))) + ps->salign=10-(LOWORD(wparam)-IDC_RADIO10+1); + break; + } +xxx: + saveDBSettings(ps); + SetWindowPos(hwnd, 0, 0, 0, ps->winx, ps->winy, SWP_NOMOVE|SWP_NOZORDER|SWP_NOACTIVATE); + if (pSetLayeredWindowAttributes) + pSetLayeredWindowAttributes(hwnd, db_get_dw(NULL,THIS_MODULE, "bkclr", DEFAULT_BKCLR), db_get_b(NULL,THIS_MODULE, "alpha", DEFAULT_ALPHA), (db_get_b(NULL,THIS_MODULE, "transparent", DEFAULT_TRANPARENT)?LWA_COLORKEY:0)|LWA_ALPHA); + InvalidateRect(hwnd, 0, TRUE); + SendMessage(GetParent(hDlg),PSM_CHANGED,0,0); + + return 0; + + case WM_NOTIFY: + logmsg("OptDlgProc::NOTIFY"); + switch(((LPNMHDR)lparam)->code){ + case TVN_SETDISPINFO: + case NM_CLICK: + case NM_RETURN: + case TVN_SELCHANGED: + if (((LPNMHDR)lparam)->idFrom==IDC_TREE1) + SendMessage(GetParent(hDlg),PSM_CHANGED,0,0); + break; + case PSN_APPLY: + ps=(plgsettings*)GetWindowLongPtr(hDlg, GWLP_USERDATA); + + GetWindowRect(hwnd, &rect); + ps->winx=rect.right-rect.left; + ps->winy=rect.bottom-rect.top; + ps->winxpos=rect.left; + ps->winypos=rect.top; + ps->announce=MakeCheckBoxTreeFlags(GetDlgItem(hDlg, IDC_TREE1)); + ps->showWhen=MakeCheckBoxTreeFlags(GetDlgItem(hDlg, IDC_TREE2)); + GetDlgItemText(hDlg, IDC_EDIT2, ps->msgformat, 255); + ps[1]=ps[0]; //apply current settings at closing + + saveDBSettings(ps); + if (pSetLayeredWindowAttributes) + pSetLayeredWindowAttributes(hwnd, db_get_dw(NULL,THIS_MODULE, "bkclr", DEFAULT_BKCLR), db_get_b(NULL,THIS_MODULE, "alpha", DEFAULT_ALPHA), (db_get_b(NULL,THIS_MODULE, "transparent", DEFAULT_TRANPARENT)?LWA_COLORKEY:0)|LWA_ALPHA); + InvalidateRect(hwnd, 0, TRUE); + break; + } + break; + } + + return 0; +} + +int OptionsInit(WPARAM wparam,LPARAM) +{ + OPTIONSDIALOGPAGE odp = { sizeof(odp) }; + odp.position=150000000; + odp.groupPosition=950000000; + odp.hInstance=hI; + odp.pszTemplate=MAKEINTRESOURCEA(IDD_DIALOG1); + odp.ptszGroup=LPGENT("Plugins"); + odp.ptszTitle=LPGENT("OSD"); + odp.pfnDlgProc=OptDlgProc; + odp.flags=ODPF_BOLDGROUPS|ODPF_TCHAR; + Options_AddPage(wparam,&odp); + return 0; +} diff --git a/plugins/wbOSD/readme.txt b/plugins/wbOSD/readme.txt new file mode 100644 index 0000000000..09815bf989 --- /dev/null +++ b/plugins/wbOSD/readme.txt @@ -0,0 +1,84 @@ +Wannabe (Miranda's) OSD +(c)2005 Andrej Krutak +Distribute under the GNU GPL 2.0 license + +======================================================= + +Hello there, I'm happy you are trying out my OSD plugin... I've just started +to make it (in fact, it's the first miranda plugin i ever made ;-) so please +excuse bugs etc. (but you may report them, of course ;-) + +The plugin is trying to implement all the functionality of the 'old' OSD plugin. +However, I never got to it's documentation, so I can't tell if everything's gonna +work the way it should... Let me know :o) + +And I'll be happy if you send some suggestions/code parts etc., but please, +send it into the forum of this project on miranda's web ;-) + + + +------| Short tips: |---------------------------------- + +Moving the OSD: +Simply drag it by pressing left mouse button and then move the cursor ;-) +Note that only position changes done while settings dialog is shown are +saved. + +Closing the actual OSD: +Press the right button over the OSD - that will close the OSD and +show a message window for the contact who caused the OSD activity. + + + +------| Changelog: |----------------------------------- + +0.2.0.5 + New: Enable/disable OSD announces for specific own statuses + Fix: User interface improvemets... + Fix: used 100% of the processor time sometimes + +0.2.0.1 + Fix: Help button + Fix: Translation of status announces + +0.2.0.0 + Fix: multiline output + New: separate color for status & message announces + New: by pressing the right mouse button you can send message + New: message announce format can be customized a little + Fix: User interface improvemets... + Fix: again a little bit more compatible to win9x ;-) + Info: The unicode version might be broken, sorry if it is + +0.1.5.0 + New: unicode support (thanx to SilverCircle) + New: multiline output (thanx to SilverCircle) + (Hopefully)Fix: win9x-workaround memory leak +0.1.0.0 + New: more comfortable OSD positioning + New: possibility to not show own status changes + New: translation support + Fix: should work under win9x, however the transparency doesn't work well + Fix: some small bugfixes (e.g. saving of announce settings) ;-) + +0.0.2.0 + New: some more documentation + New: settings applied to osd instantly, saved after apply + New: user offline notification + Fix: only showing status of people in the contact list + +0.0.1.1 + Tiny little fix ;-) + +0.0.1.0 + Initial release + + + + +------| Some TODOs: |---------------------------------- + +* different color schemes for messages/online notifications etc. (in progess) +* test (and make work in case it doesn't) under other os than winxp +* add some other formatting options (not sure if it's worth the work) +* other things ;-) diff --git a/plugins/wbOSD/resource.h b/plugins/wbOSD/resource.h new file mode 100644 index 0000000000..64e57a5dfa --- /dev/null +++ b/plugins/wbOSD/resource.h @@ -0,0 +1,57 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by wbOSD.rc +// +#define IDD_DIALOG1 101 +#define IDC_BUTTON1 1001 +#define IDC_BUTTON2 1002 +#define IDC_BUTTON3 1003 +#define IDC_BUTTON6 1004 +#define IDC_BUTTON4 1008 +#define IDC_EDIT1 1009 +#define IDC_CHECK1 1010 +#define IDC_CHECK3 1013 +#define IDC_EDIT4 1015 +#define IDC_EDIT5 1016 +#define IDC_CHECK4 1017 +#define IDC_TREE1 1018 +#define IDC_CHECK5 1019 +#define IDC_CHECK6 1020 +#define IDC_BUTTON5 1021 +#define IDC_CHECK7 1022 +#define IDC_CHECK8 1023 +#define IDC_CHECK2 1023 +#define IDC_SLIDER1 1024 +#define IDC_ALPHATXT 1025 +#define IDC_EDIT2 1027 +#define IDC_BUTTON7 1028 +#define IDC_TREE2 1029 +#define IDC_RADIO1 1101 +#define IDC_RADIO2 1102 +#define IDC_RADIO3 1103 +#define IDC_RADIO4 1104 +#define IDC_RADIO5 1105 +#define IDC_RADIO6 1106 +#define IDC_RADIO7 1107 +#define IDC_RADIO8 1108 +#define IDC_RADIO9 1109 +#define IDC_RADIO10 1120 +#define IDC_RADIO11 1121 +#define IDC_RADIO12 1122 +#define IDC_RADIO13 1123 +#define IDC_RADIO14 1124 +#define IDC_RADIO15 1125 +#define IDC_RADIO16 1126 +#define IDC_RADIO17 1127 +#define IDC_RADIO18 1128 + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NEXT_RESOURCE_VALUE 102 +#define _APS_NEXT_COMMAND_VALUE 40001 +#define _APS_NEXT_CONTROL_VALUE 1029 +#define _APS_NEXT_SYMED_VALUE 101 +#endif +#endif diff --git a/plugins/wbOSD/wbOSD.cpp b/plugins/wbOSD/wbOSD.cpp new file mode 100644 index 0000000000..9bdaf74370 --- /dev/null +++ b/plugins/wbOSD/wbOSD.cpp @@ -0,0 +1,309 @@ +/* +Wannabe OSD +This plugin tries to become miranda's standard OSD ;-) + +(C) 2005 Andrej Krutak + +Distributed under GNU's GPL 2 or later +*/ + +#include "wbOSD.h" + +TCHAR szClassName[] = _T("wbOSD"); +const static osdmsg defstr={_T(""), 0, RGB(0, 0, 0), 0, 0}; + +int DrawMe(HWND hwnd, TCHAR *string, COLORREF color) +{ + PAINTSTRUCT ps; + RECT rect, rect2; + UINT talign=0; + int sxo, syo; + plgsettings plgs; + + logmsg("DrawMe"); + if (!string) string=_T("bullshit"); + + loadDBSettings(&plgs); + HFONT fh=CreateFontIndirect(&(plgs.lf)); + + HDC hdc=BeginPaint(hwnd, &ps); + SetBkMode(hdc, TRANSPARENT); + + GetClientRect(hwnd, &rect); + HBRUSH bkb=CreateSolidBrush(plgs.bkclr); + FillRect(hdc, &rect, bkb); + + DeleteObject(bkb); + + HGDIOBJ oo=SelectObject(hdc, fh); + +// rect2.left=0; +// rect2.top=0; +// DrawText(hdc, string, -1, &rect2, DT_SINGLELINE|DT_CALCRECT); + rect2 = rect; + DrawText(hdc, string, -1, &rect2, DT_WORDBREAK|DT_CALCRECT); + + if (plgs.align>=1 && plgs.align<=3) + rect.top=0; + if (plgs.align>=4 && plgs.align<=6) + rect.top=(rect.bottom-rect2.bottom)/2; + if (plgs.align>=7 && plgs.align<=9) + rect.top=rect.bottom-rect2.bottom; + + if (((plgs.align-1)%3)==0) + rect.left=0; + else if (((plgs.align-2)%3)==0) + rect.left=(rect.right-rect2.right)/2; + else if (((plgs.align-3)%3)==0) + rect.left=rect.right-rect2.right; + + rect.bottom=rect.top+rect2.bottom; + rect.right=rect.left+rect2.right; + + //draw shadow + if (plgs.showShadow) { + logmsg("DrawMe::showShadow"); + if (plgs.salign>=1 && plgs.salign<=3) syo=-plgs.distance; + if (plgs.salign>=4 && plgs.salign<=6) syo=0; + if (plgs.salign>=7 && plgs.salign<=9) syo=plgs.distance; + + if (((plgs.salign-1)%3)==0) sxo=-plgs.distance; + else if (((plgs.salign-2)%3)==0) sxo=0; + else if (((plgs.salign-3)%3)==0) sxo=plgs.distance; + + SetTextColor(hdc, plgs.clr_shadow); + if (plgs.altShadow==0) { + rect2=rect; + OffsetRect(&rect, sxo, syo); + + DrawText(hdc, string, -1, &rect2, DT_WORDBREAK|talign); + } else { + rect2=rect; + rect2.left+=plgs.distance; + DrawText(hdc, string, -1, &rect2, DT_WORDBREAK|talign); + + rect2=rect; + rect2.left-=plgs.distance; + DrawText(hdc, string, -1, &rect2, DT_WORDBREAK|talign); + + rect2=rect; + rect2.top-=plgs.distance; + DrawText(hdc, string, -1, &rect2, DT_WORDBREAK|talign); + + rect2=rect; + rect2.top+=plgs.distance; + DrawText(hdc, string, -1, &rect2, DT_WORDBREAK|talign); + + OffsetRect(&rect, sxo/2, syo/2); + } + } + + //draw text + SetTextColor(hdc, color); + DrawText(hdc, string, -1, &rect, DT_WORDBREAK); + + SelectObject(hdc, oo); + DeleteObject(fh); + EndPaint(hwnd, &ps); + + return 0; +} + +LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) +{ + osdmsg* ms; + + switch (message) { + case WM_CREATE: + logmsg("WindowProcedure::CREATE"); + SetWindowLongPtr(hwnd, GWLP_USERDATA, (LONG)&defstr); + return 0; + + case WM_DESTROY: + logmsg("WindowProcedure::DESTROY"); + return 0; + + case WM_PAINT: + logmsg("WindowProcedure::PAINT"); + + ms=(osdmsg*)GetWindowLongPtr(hwnd, GWLP_USERDATA); + if (ms) + return DrawMe(hwnd, ms->text, ms->color); + + PAINTSTRUCT ps; + BeginPaint(hwnd, &ps); + EndPaint(hwnd, &ps); + return 0; + + case WM_NCRBUTTONDOWN: + logmsg("WindowProcedure::NCRBUTTONDOWN"); + + ms = (osdmsg*)GetWindowLongPtr(hwnd, GWLP_USERDATA); + if ( ms ) { + if ( ms->callback) ms->callback(ms->param); + SendMessage(hwnd, WM_USER+3, 0, 0); + } + return 0; + + case WM_TIMER: + logmsg("WindowProcedure::TIMER"); + SendMessage(hwnd, WM_USER+3, wParam, 0); + return 0; + + case WM_USER+1: //draw text ((char *)string, (int) timeout + logmsg("WindowProcedure::USER+1"); + + ms=(osdmsg*)mir_alloc(sizeof(osdmsg)); + ms->text = mir_tstrdup((TCHAR *)wParam ); + if ( lParam == 0 ) + lParam = db_get_dw( NULL,THIS_MODULE, "timeout", DEFAULT_TIMEOUT ); + ms->timeout = lParam; + ms->callback = 0; + ms->color = db_get_dw(NULL,THIS_MODULE, "clr_msg", DEFAULT_CLRMSG); + ms->param = 0; + SendMessage(hwnd, WM_USER+4, (WPARAM)ms, 0); + mir_free(ms->text); + mir_free(ms); + return 0; + + case WM_USER+2: //show + logmsg("WindowProcedure::USER+2"); + SetWindowPos(hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE|SWP_SHOWWINDOW|SWP_NOACTIVATE); + return 0; + + case WM_USER+3: //hide + ms = ( osdmsg* )GetWindowLongPtr(hwnd, GWLP_USERDATA); + logmsg("WindowProcedure::USER+3"); + if ( !ms ) + return 0; + + logmsg("WindowProcedure::USER+3/om"); + KillTimer(hwnd, (UINT)ms); + mir_free(ms->text); + mir_free(ms); + SetWindowLongPtr(hwnd, GWLP_USERDATA, 0); + ShowWindow(hwnd, SW_HIDE); + return 0; + + case WM_USER+4: + logmsg("WindowProcedure::USER+4"); + + ms = (osdmsg*)GetWindowLongPtr(hwnd, GWLP_USERDATA); + if ( ms != 0 ) { + logmsg("WindowProcedure::USER+4/old"); + KillTimer(hwnd, (UINT)ms); + mir_free(ms->text); + mir_free(ms); + SetWindowLongPtr(hwnd, GWLP_USERDATA, 0); + if (!pSetLayeredWindowAttributes) { + logmsg("WindowProcedure::USER+4/old+9x"); + ShowWindow(hwnd, SW_HIDE); + Sleep(50); + } } + + ms =(osdmsg*)mir_alloc(sizeof(osdmsg)); + memcpy(ms, (osdmsg*)wParam, sizeof(osdmsg)); + ms->text = mir_tstrdup( ms->text ); + + SetWindowLongPtr(hwnd, GWLP_USERDATA, (LONG)ms); + SetTimer(hwnd, (UINT)ms, (int)ms->timeout, 0); + InvalidateRect(hwnd, 0, TRUE); + SendMessage(hwnd, WM_USER+2, 0, 0); + return 0; + + case WM_NCHITTEST: + { + RECT rect; + GetWindowRect(hwnd, &rect); + + logmsg("WindowProcedure::NCHITTEST"); + + if (LOWORD(lParam)>=(rect.left+5) && LOWORD(lParam)<=(rect.right-5) && + HIWORD(lParam)>=(rect.top+5) && HIWORD(lParam)<=(rect.bottom-5)) + return HTCAPTION; + return DefWindowProc (hwnd, message, wParam, lParam); + } + //here will be the doubleclick => open-message-window solution ;-) + //case WM_NCLBUTTONDBLCLK: + // CallService(MS_MSG_SENDMESSAGE, wparam,(LPARAM)&odp); + // return 0; + default: + return DefWindowProc (hwnd, message, wParam, lParam); + } + + return 0; +} + +INT_PTR OSDAnnounce(WPARAM wParam, LPARAM lParam) +{ + logmsg("OSDAnnounce"); + return SendMessage(hwnd, WM_USER+1, wParam, lParam); +} + +int pluginShutDown(WPARAM wparam,LPARAM lparam) +{ + logmsg("pluginShutDown"); + if (hwnd) { + logmsg("pluginShutDown/hwnd"); + SendMessage(hwnd, WM_USER+3, 0, 0); + DestroyWindow(hwnd); + hwnd=0; + } + return 0; +} + +int MainInit(WPARAM wparam,LPARAM lparam) +{ + logmsg("MainInit"); + HookEvent(ME_OPT_INITIALISE,OptionsInit); + + WNDCLASSEX wincl; + wincl.hInstance = hI; + wincl.lpszClassName = szClassName; + wincl.lpfnWndProc = WindowProcedure; + wincl.style = CS_DBLCLKS; + wincl.cbSize = sizeof (WNDCLASSEX); + + wincl.hIcon = LoadIcon (NULL, IDI_APPLICATION); + wincl.hIconSm = LoadIcon (NULL, IDI_APPLICATION); + wincl.hCursor = LoadCursor (NULL, IDC_ARROW); + wincl.lpszMenuName = NULL; + wincl.cbClsExtra = 0; + wincl.cbWndExtra = 0; + wincl.hbrBackground = 0; + + if ( !RegisterClassEx( &wincl )) + return 0; + + hwnd = CreateWindowEx((pSetLayeredWindowAttributes?WS_EX_LAYERED:0)|WS_EX_TOOLWINDOW, szClassName, _T("WannaBeOSD"), + (pSetLayeredWindowAttributes?0:WS_CLIPSIBLINGS) | WS_POPUP, + db_get_dw(NULL,THIS_MODULE, "winxpos", DEFAULT_WINXPOS), + db_get_dw(NULL,THIS_MODULE, "winypos", DEFAULT_WINYPOS), + db_get_dw(NULL,THIS_MODULE, "winx", DEFAULT_WINX), + db_get_dw(NULL,THIS_MODULE, "winy", DEFAULT_WINY), + HWND_DESKTOP, NULL, hI, NULL); + + SetWindowLongPtr(hwnd, GWLP_USERDATA, 0); + + if (pSetLayeredWindowAttributes) + pSetLayeredWindowAttributes(hwnd, db_get_dw(NULL,THIS_MODULE, "bkclr", DEFAULT_BKCLR), db_get_b(NULL,THIS_MODULE, "alpha", DEFAULT_ALPHA), (db_get_b(NULL,THIS_MODULE, "transparent", DEFAULT_TRANPARENT)?LWA_COLORKEY:0)|LWA_ALPHA); + + hservosda=CreateServiceFunction("OSD/Announce", OSDAnnounce); + + hHookedNewEvent = HookEvent(ME_DB_EVENT_ADDED, HookedNewEvent); + + // try to create ME_STATUSCHANGE_CONTACTSTATUSCHANGED event... I hope it fails when newstatusnotify or equal creates it before ;-) + + hContactStatusChanged = HookEvent(ME_STATUSCHANGE_CONTACTSTATUSCHANGED,ContactStatusChanged); + if (!hContactStatusChanged) { + hHookContactStatusChanged = CreateHookableEvent(ME_STATUSCHANGE_CONTACTSTATUSCHANGED); + hContactSettingChanged = HookEvent(ME_DB_CONTACT_SETTINGCHANGED,ContactSettingChanged); + + hContactStatusChanged = HookEvent(ME_STATUSCHANGE_CONTACTSTATUSCHANGED,ContactStatusChanged); + } + hProtoAck=HookEvent(ME_PROTO_ACK,ProtoAck); + + hpluginShutDown=HookEvent(ME_SYSTEM_SHUTDOWN,pluginShutDown); + + return 0; +} diff --git a/plugins/wbOSD/wbOSD.h b/plugins/wbOSD/wbOSD.h new file mode 100644 index 0000000000..9233959a5f --- /dev/null +++ b/plugins/wbOSD/wbOSD.h @@ -0,0 +1,128 @@ +/* +Wannabe OSD +This plugin tries to become miranda's standard OSD ;-) + +(C) 2005 Andrej Krutak + +Distributed under GNU's GPL 2 or later +*/ + +#define _WIN32_WINNT 0x0500 +#define _CRT_SECURE_NO_WARNINGS + +#include +#include +#include +#include +#include + +#include "resource.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define THIS_MODULE "mirandaosd" + +//SETTINGS DEFAULTS +#define DEFAULT_FNT_HEIGHT -30 +#define DEFAULT_FNT_WIDTH 0 +#define DEFAULT_FNT_ESCAPEMENT 0 +#define DEFAULT_FNT_ORIENTATION 0 +#define DEFAULT_FNT_WEIGHT 700 +#define DEFAULT_FNT_ITALIC 0 +#define DEFAULT_FNT_UNDERLINE 0 +#define DEFAULT_FNT_STRIKEOUT 0 +#define DEFAULT_FNT_CHARSET 0 +#define DEFAULT_FNT_OUTPRECISION 3 +#define DEFAULT_FNT_CLIPRECISION 2 +#define DEFAULT_FNT_QUALITY 1 +#define DEFAULT_FNT_PITCHANDFAM 49 +#define DEFAULT_FNT_FACENAME _T("Arial") + +#define DEFAULT_CLRMSG RGB(255, 100, 0) //fore +#define DEFAULT_CLRSTATUS RGB(40, 160, 255) //fore +#define DEFAULT_CLRSHADOW RGB(0, 0, 0) //bk +#define DEFAULT_BKCLR RGB(255, 255, 255) +#define DEFAULT_ALIGN 1 +#define DEFAULT_SALIGN 1 +#define DEFAULT_DISTANCE 2 +#define DEFAULT_ALTSHADOW 0 +#define DEFAULT_TRANPARENT 1 +#define DEFAULT_WINX 500 +#define DEFAULT_WINY 100 +#define DEFAULT_WINXPOS 10 +#define DEFAULT_WINYPOS 10 +#define DEFAULT_ALPHA 175 +#define DEFAULT_TIMEOUT 3000 +#define DEFAULT_SHOWSHADOW 1 +#define DEFAULT_ANNOUNCEMESSAGES 1 +#define DEFAULT_ANNOUNCESTATUS 1 +#define DEFAULT_ANNOUNCE 0x00000002 //status mask +#define DEFAULT_SHOWMYSTATUS 1 +#define DEFAULT_MESSAGEFORMAT _T("Message from %n: %m") +#define DEFAULT_SHOWMSGWIN 1 +#define DEFAULT_SHOWWHEN 0x00000002 + +//HOOKS +#define ME_STATUSCHANGE_CONTACTSTATUSCHANGED "Miranda/StatusChange/ContactStatusChanged" + +int ContactStatusChanged(WPARAM wParam, LPARAM lParam); +int ProtoAck(WPARAM wparam,LPARAM lparam); +int ContactSettingChanged(WPARAM wparam,LPARAM lparam); +int HookedNewEvent(WPARAM wParam, LPARAM lParam); + +//ANNOUNCING MESSAGES FROM OUTSIDE ;-) +INT_PTR OSDAnnounce(WPARAM wParam, LPARAM lParam); + + + +#define ID_STATUS_MIN ID_STATUS_OFFLINE +#define ID_STATUS_MAX ID_STATUS_OUTTOLUNCH + +typedef struct _plgsettings { + int align, salign, altShadow, showShadow, a_user, distance, onlyfromlist, showmystatus; + int showMsgWindow; + int messages; //also other events... + TCHAR msgformat[256]; + int winx, winy, winxpos, winypos, alpha, transparent, timeout; + COLORREF clr_msg, clr_status, clr_shadow, bkclr; + DWORD announce, showWhen; + LOGFONT lf; +} plgsettings; + +typedef struct _osdmsg { + TCHAR *text; + int timeout; //ms + COLORREF color; + void (*callback)(unsigned int param); + int param; +} osdmsg; + +//#define logmsg(x) logmsg2(x) + +#ifndef logmsg +#define logmsg(x) //x +#endif + +int OptionsInit(WPARAM wparam,LPARAM lparam); + +extern BOOL (WINAPI*pSetLayeredWindowAttributes)(HWND, COLORREF, BYTE, DWORD); + +void loadDBSettings(plgsettings *ps); + +extern HINSTANCE hI; +extern HWND hwnd; +extern HANDLE hservosda; +extern HANDLE hHookedNewEvent, hHookedInit, hProtoAck, hContactSettingChanged, hHookContactStatusChanged, hContactStatusChanged, hpluginShutDown; +extern HINSTANCE hUser32; + diff --git a/plugins/wbOSD/wbOSD.rc b/plugins/wbOSD/wbOSD.rc new file mode 100644 index 0000000000..0dad96f6e8 --- /dev/null +++ b/plugins/wbOSD/wbOSD.rc @@ -0,0 +1,188 @@ +// Microsoft Visual C++ generated resource script. +// +#include "resource.h" + +#define APSTUDIO_READONLY_SYMBOLS +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 2 resource. +// +#include "afxres.h" + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// Slovak resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_SKY) +#ifdef _WIN32 +LANGUAGE LANG_SLOVAK, SUBLANG_DEFAULT +#pragma code_page(1250) +#endif //_WIN32 + +///////////////////////////////////////////////////////////////////////////// +// +// Dialog +// + +IDD_DIALOG1 DIALOGEX 0, 0, 316, 250 +STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION +CAPTION "Dialog" +FONT 8, "MS Shell Dlg", 400, 0, 0x1 +BEGIN + CONTROL "Radio1",IDC_RADIO1,"Button",BS_AUTORADIOBUTTON | + WS_GROUP,21,22,8,8 + CONTROL "Radio1",IDC_RADIO2,"Button",BS_AUTORADIOBUTTON,39,22,8, + 8 + CONTROL "Radio1",IDC_RADIO3,"Button",BS_AUTORADIOBUTTON,59,22,8, + 8 + CONTROL "Radio1",IDC_RADIO4,"Button",BS_AUTORADIOBUTTON,21,33,8, + 8 + CONTROL "Radio1",IDC_RADIO5,"Button",BS_AUTORADIOBUTTON,39,33,8, + 8 + CONTROL "Radio1",IDC_RADIO6,"Button",BS_AUTORADIOBUTTON,59,33,8, + 8 + CONTROL "Radio1",IDC_RADIO7,"Button",BS_AUTORADIOBUTTON,21,45,8, + 8 + CONTROL "Radio1",IDC_RADIO8,"Button",BS_AUTORADIOBUTTON,39,45,8, + 8 + CONTROL "Radio1",IDC_RADIO9,"Button",BS_AUTORADIOBUTTON,59,45,8, + 8 + PUSHBUTTON "Select font",IDC_BUTTON1,80,17,68,14 + PUSHBUTTON "Text color",IDC_BUTTON2,175,91,68,14 + PUSHBUTTON "Background color",IDC_BUTTON4,11,182,67,14 + CONTROL "Transparent",IDC_CHECK3,"Button",BS_AUTOCHECKBOX | + WS_TABSTOP,11,199,72,10 + CONTROL "Radio1",IDC_RADIO10,"Button",BS_AUTORADIOBUTTON | + WS_GROUP,21,99,8,8 + CONTROL "Radio1",IDC_RADIO11,"Button",BS_AUTORADIOBUTTON,39,99,8, + 8 + CONTROL "Radio1",IDC_RADIO12,"Button",BS_AUTORADIOBUTTON,59,99,8, + 8 + CONTROL "Radio1",IDC_RADIO13,"Button",BS_AUTORADIOBUTTON,21,110, + 8,8 + CONTROL "Radio1",IDC_RADIO14,"Button",BS_AUTORADIOBUTTON,39,110, + 8,8 + CONTROL "Radio1",IDC_RADIO15,"Button",BS_AUTORADIOBUTTON,59,110, + 8,8 + CONTROL "Radio1",IDC_RADIO16,"Button",BS_AUTORADIOBUTTON,21,121, + 8,8 + CONTROL "Radio1",IDC_RADIO17,"Button",BS_AUTORADIOBUTTON,39,121, + 8,8 + CONTROL "Radio1",IDC_RADIO18,"Button",BS_AUTORADIOBUTTON,59,121, + 8,8 + PUSHBUTTON "Shadow color",IDC_BUTTON3,80,92,67,14 + CONTROL "Alternative shadow",IDC_CHECK1,"Button",BS_AUTOCHECKBOX | + WS_TABSTOP,13,135,133,10 + EDITTEXT IDC_EDIT1,79,148,27,14,ES_AUTOHSCROLL | ES_NUMBER + GROUPBOX "Shadow align",IDC_STATIC,13,89,62,43 + GROUPBOX "General",IDC_STATIC,6,0,150,66 + GROUPBOX "Shadow",IDC_STATIC,5,70,151,99 + GROUPBOX "Align",IDC_STATIC,13,13,61,43 + LTEXT "Shadow distance:",IDC_STATIC,10,151,64,8, + SS_PATHELLIPSIS,WS_EX_RIGHT + GROUPBOX "Other",IDC_STATIC,5,171,152,75 + LTEXT "Alpha:",IDC_STATIC,92,183,60,8,SS_PATHELLIPSIS + GROUPBOX "Announce",IDC_STATIC,162,0,150,246 + LTEXT "Timeout (ms):",IDC_STATIC,91,213,62,8,SS_PATHELLIPSIS + EDITTEXT IDC_EDIT5,91,224,27,14,ES_AUTOHSCROLL | ES_NUMBER + CONTROL "",IDC_TREE1,"SysTreeView32",TVS_DISABLEDRAGDROP | + TVS_NOTOOLTIPS | WS_BORDER | WS_TABSTOP | 0x4000,170,22, + 138,55 + CONTROL "Show",IDC_CHECK4,"Button",BS_AUTOCHECKBOX | WS_TABSTOP, + 13,80,85,10 + CONTROL "Show events",IDC_CHECK5,"Button",BS_AUTOCHECKBOX | + WS_TABSTOP,167,110,139,10 + CONTROL "Status changes",IDC_CHECK6,"Button",BS_AUTOCHECKBOX | + WS_TABSTOP,167,10,136,10 + PUSHBUTTON "Show testing OSD",IDC_BUTTON5,11,224,67,14 + CONTROL "Show my status changes",IDC_CHECK7,"Button", + BS_AUTOCHECKBOX | WS_TABSTOP,175,80,133,10 + CONTROL "Show message window after click",IDC_CHECK2,"Button", + BS_AUTOCHECKBOX | WS_TABSTOP,167,156,138,10 + CONTROL "",IDC_SLIDER1,"msctls_trackbar32",TBS_BOTH | + TBS_NOTICKS | WS_TABSTOP,87,193,45,15 + LTEXT "Static",IDC_ALPHATXT,136,195,17,8 + PUSHBUTTON "Text color",IDC_BUTTON6,175,121,68,14 + EDITTEXT IDC_EDIT2,214,137,81,14,ES_AUTOHSCROLL + LTEXT "Format:",IDC_STATIC,177,140,35,8 + PUSHBUTTON "?",IDC_BUTTON7,298,137,10,14 + CONTROL "",IDC_TREE2,"SysTreeView32",TVS_DISABLEDRAGDROP | + TVS_NOTOOLTIPS | WS_BORDER | WS_TABSTOP | 0x4000,170,182, + 138,59 + LTEXT "Show when my status is:",IDC_STATIC,168,171,139,8 +END + + +///////////////////////////////////////////////////////////////////////////// +// +// DESIGNINFO +// + +#ifdef APSTUDIO_INVOKED +GUIDELINES DESIGNINFO +BEGIN + IDD_DIALOG1, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 309 + TOPMARGIN, 7 + BOTTOMMARGIN, 243 + END +END +#endif // APSTUDIO_INVOKED + +#endif // Slovak resources +///////////////////////////////////////////////////////////////////////////// + + +///////////////////////////////////////////////////////////////////////////// +// English (U.S.) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) +#ifdef _WIN32 +LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US +#pragma code_page(1252) +#endif //_WIN32 + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE +BEGIN + "resource.h\0" +END + +2 TEXTINCLUDE +BEGIN + "#include ""afxres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE +BEGIN + "\r\n" + "\0" +END + +#endif // APSTUDIO_INVOKED + +#endif // English (U.S.) resources +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/plugins/wbOSD/wbOSD_10.vcxproj b/plugins/wbOSD/wbOSD_10.vcxproj new file mode 100644 index 0000000000..0fc1f2760f --- /dev/null +++ b/plugins/wbOSD/wbOSD_10.vcxproj @@ -0,0 +1,188 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + wbOSD + {DA450122-7F0B-45DA-9EAA-421887AD8450} + Win32Proj + + + + DynamicLibrary + Unicode + true + + + DynamicLibrary + Unicode + true + + + DynamicLibrary + Unicode + + + DynamicLibrary + Unicode + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.30319.1 + $(SolutionDir)$(Configuration)\Plugins\ + $(SolutionDir)$(Configuration)64\Plugins\ + $(SolutionDir)$(Configuration)\Obj\$(ProjectName)\ + $(SolutionDir)$(Configuration)64\Obj\$(ProjectName)\ + true + true + $(SolutionDir)$(Configuration)\Plugins\ + $(SolutionDir)$(Configuration)64\Plugins\ + $(SolutionDir)$(Configuration)\Obj\$(ProjectName)\ + $(SolutionDir)$(Configuration)64\Obj\$(ProjectName)\ + false + false + + + + Disabled + WIN32;_DEBUG;_WINDOWS;_USRDLL;WBOSD_EXPORTS;%(PreprocessorDefinitions) + true + EnableFastChecks + MultiThreadedDebugDLL + Use + Level3 + EditAndContinue + ../../include;%(AdditionalIncludeDirectories) + wbOSD.h + + + true + $(OutDir)wbOSD.pdb + Windows + $(OutDir)wbOSD.lib + MachineX86 + $(ProfileDir)..\..\bin10\lib + + + + + Disabled + WIN64;_DEBUG;_WINDOWS;_USRDLL;WBOSD_EXPORTS;%(PreprocessorDefinitions) + EnableFastChecks + MultiThreadedDebugDLL + Use + Level3 + ProgramDatabase + ../../include;%(AdditionalIncludeDirectories) + wbOSD.h + + + true + $(OutDir)wbOSD.pdb + Windows + $(OutDir)wbOSD.lib + $(ProfileDir)..\..\bin10\lib + + + + + WIN32;NDEBUG;_WINDOWS;_USRDLL;WBOSD_EXPORTS;%(PreprocessorDefinitions) + MultiThreadedDLL + Use + Level3 + ProgramDatabase + Full + Size + ../../include;%(AdditionalIncludeDirectories) + wbOSD.h + + + true + Windows + true + true + $(OutDir)wbOSD.lib + MachineX86 + $(ProfileDir)..\..\bin10\lib + + + + + WIN64;NDEBUG;_WINDOWS;_USRDLL;WBOSD_EXPORTS;%(PreprocessorDefinitions) + MultiThreadedDLL + Use + Level3 + ProgramDatabase + Full + Size + ../../include;%(AdditionalIncludeDirectories) + wbOSD.h + + + true + Windows + true + true + $(OutDir)wbOSD.lib + $(ProfileDir)..\..\bin10\lib + + + + + + Create + Create + Create + Create + Create + Create + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/plugins/wbOSD/wbOSD_10.vcxproj.filters b/plugins/wbOSD/wbOSD_10.vcxproj.filters new file mode 100644 index 0000000000..d27d519e26 --- /dev/null +++ b/plugins/wbOSD/wbOSD_10.vcxproj.filters @@ -0,0 +1,50 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx + + + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + + + Header Files + + + Resource Files + + + Header Files + + + + + Resource Files + + + + + + \ No newline at end of file -- cgit v1.2.3