diff options
author | Vadim Dashevskiy <watcherhd@gmail.com> | 2013-05-16 18:19:56 +0000 |
---|---|---|
committer | Vadim Dashevskiy <watcherhd@gmail.com> | 2013-05-16 18:19:56 +0000 |
commit | 4653a5d7af56bf2697e2a9a87ddbc3f86a7fb541 (patch) | |
tree | 14c6c4d9b672bf75af43811ebb3e104495ce88b5 /plugins/wbOSD/src | |
parent | cf5350edbc17a09a8c5fb028ce7543bc5b8f4f33 (diff) |
- wbOSD: added to solutions
git-svn-id: http://svn.miranda-ng.org/main/trunk@4684 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/wbOSD/src')
-rw-r--r-- | plugins/wbOSD/src/events.cpp | 208 | ||||
-rw-r--r-- | plugins/wbOSD/src/main.cpp | 100 | ||||
-rw-r--r-- | plugins/wbOSD/src/options.cpp | 422 | ||||
-rw-r--r-- | plugins/wbOSD/src/resource.h | 57 | ||||
-rw-r--r-- | plugins/wbOSD/src/stdafx.cpp | 18 | ||||
-rw-r--r-- | plugins/wbOSD/src/version.h | 35 | ||||
-rw-r--r-- | plugins/wbOSD/src/wbOSD.cpp | 309 | ||||
-rw-r--r-- | plugins/wbOSD/src/wbOSD.h | 128 |
8 files changed, 1277 insertions, 0 deletions
diff --git a/plugins/wbOSD/src/events.cpp b/plugins/wbOSD/src/events.cpp new file mode 100644 index 0000000000..83d5d79c6b --- /dev/null +++ b/plugins/wbOSD/src/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 <m_message.h>
+
+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/src/main.cpp b/plugins/wbOSD/src/main.cpp new file mode 100644 index 0000000000..791ecb7c1f --- /dev/null +++ b/plugins/wbOSD/src/main.cpp @@ -0,0 +1,100 @@ +/*
+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 "version.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),
+ __PLUGIN_NAME,
+ PLUGIN_MAKE_VERSION(__MAJOR_VERSION, __MINOR_VERSION, __RELEASE_NUM, __BUILD_NUM),
+ __DESCRIPTION,
+ __AUTHOR,
+ __AUTHOREMAIL,
+ __COPYRIGHT,
+ __AUTHORWEB,
+ UNICODE_AWARE,
+ // {FC718BC7-ABC8-43CD-AAD9-761614617738}
+ { 0xfc718bc7, 0xabc8, 0x43cd, { 0xaa, 0xd9, 0x76, 0x16, 0x14, 0x61, 0x77, 0x38 } }
+};
+
+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/src/options.cpp b/plugins/wbOSD/src/options.cpp new file mode 100644 index 0000000000..fdc8787fa5 --- /dev/null +++ b/plugins/wbOSD/src/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<<tvi.lParam;
+ tvi.hItem=TreeView_GetNextSibling(hwndTree,tvi.hItem);
+ }
+ return flags;
+}
+
+int selectColor(HWND hwnd, COLORREF *clr)
+{
+ logmsg("SelectColor");
+
+ CHOOSECOLOR cc;
+ cc.lStructSize = sizeof(cc);
+ cc.hwndOwner = hwnd;
+ cc.hInstance = (HWND)hI;
+ cc.rgbResult = *clr;
+ cc.lpCustColors = pencustcolors;
+ cc.Flags = CC_FULLOPEN|CC_RGBINIT;
+ if (!ChooseColor(&cc))
+ return 1;
+
+ *clr=cc.rgbResult;
+ return 0;
+}
+
+int selectFont(HWND hDlg, LOGFONT *lf)
+{
+ COLORREF color=RGB(0, 0, 0);
+
+ logmsg("SelectFont");
+
+ HDC hDC = GetDC(hDlg);
+
+ CHOOSEFONT cf;
+ ZeroMemory(&cf, sizeof(CHOOSEFONT));
+ cf.lStructSize = sizeof(cf);
+ cf.hwndOwner = hDlg;
+ cf.hDC = hDC;
+ cf.lpLogFont = lf;
+ cf.rgbColors = 0;
+ cf.Flags = CF_INITTOLOGFONTSTRUCT | CF_EFFECTS | CF_BOTH | CF_FORCEFONTEXIST;
+ cf.nFontType = 0;
+ cf.rgbColors=color;
+
+ if (!ChooseFont(&cf)) {
+ if (cf.hDC)
+ DeleteDC(cf.hDC);
+
+ ReleaseDC(hDlg, hDC);
+ return 1;
+ }
+
+ if (cf.hDC)
+ DeleteDC(cf.hDC);
+
+ ReleaseDC(hDlg, hDC);
+ return 0;
+}
+
+void loadDBSettings(plgsettings *ps)
+{
+ logmsg("loadDBSettings");
+
+ ps->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/src/resource.h b/plugins/wbOSD/src/resource.h new file mode 100644 index 0000000000..64e57a5dfa --- /dev/null +++ b/plugins/wbOSD/src/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/src/stdafx.cpp b/plugins/wbOSD/src/stdafx.cpp new file mode 100644 index 0000000000..68250bbb4e --- /dev/null +++ b/plugins/wbOSD/src/stdafx.cpp @@ -0,0 +1,18 @@ +/*
+Copyright (C) 2012-13 Miranda NG Project (http://miranda-ng.org)
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation version 2
+of the License.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include "wbOSD.h"
\ No newline at end of file diff --git a/plugins/wbOSD/src/version.h b/plugins/wbOSD/src/version.h new file mode 100644 index 0000000000..2282deddae --- /dev/null +++ b/plugins/wbOSD/src/version.h @@ -0,0 +1,35 @@ +/*
+
+'File Association Manager'-Plugin for Miranda IM
+
+Copyright (C) 2005-2007 H. Herkenrath
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program (AssocMgr-License.txt); if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+
+#define __MAJOR_VERSION 0
+#define __MINOR_VERSION 2
+#define __RELEASE_NUM 1
+#define __BUILD_NUM 0
+
+#define __FILEVERSION_STRING __MAJOR_VERSION,__MINOR_VERSION,__RELEASE_NUM,__BUILD_NUM
+
+#define __PLUGIN_NAME "WannaBe OSD"
+#define __FILENAME "wbOSD.dll"
+#define __DESCRIPTION "Shows new message/status change info using onscreen display."
+#define __AUTHOR "Andrej Krutak"
+#define __AUTHOREMAIL "andree182@gmail.com"
+#define __AUTHORWEB "http://miranda-ng.org/"
+#define __COPYRIGHT "©2005 Andrej Krutak"
diff --git a/plugins/wbOSD/src/wbOSD.cpp b/plugins/wbOSD/src/wbOSD.cpp new file mode 100644 index 0000000000..9bdaf74370 --- /dev/null +++ b/plugins/wbOSD/src/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/src/wbOSD.h b/plugins/wbOSD/src/wbOSD.h new file mode 100644 index 0000000000..9233959a5f --- /dev/null +++ b/plugins/wbOSD/src/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 <tchar.h>
+#include <windows.h>
+#include <shlwapi.h>
+#include <commctrl.h>
+#include <stdio.h>
+
+#include "resource.h"
+#include <newpluginapi.h>
+#include <m_langpack.h>
+#include <m_database.h>
+#include <m_options.h>
+#include <m_clc.h>
+#include <m_system.h>
+#include <m_clist.h>
+#include <m_protocols.h>
+#include <m_protosvc.h>
+#include <m_utils.h>
+#include <m_contacts.h>
+#include <m_ignore.h>
+#include <win2k.h>
+
+#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;
+
|