summaryrefslogtreecommitdiff
path: root/plugins/Watrack/popup
diff options
context:
space:
mode:
authorVadim Dashevskiy <watcherhd@gmail.com>2012-10-08 18:43:29 +0000
committerVadim Dashevskiy <watcherhd@gmail.com>2012-10-08 18:43:29 +0000
commit864081102a5f252415f41950b3039a896b4ae9c5 (patch)
treec6b764651e9dd1f8f53b98eab05f16ba4a492a79 /plugins/Watrack/popup
parentdb5149b48346c417e18add5702a9dfe7f6e28dd0 (diff)
Awkwars's plugins - welcome to our trunk
git-svn-id: http://svn.miranda-ng.org/main/trunk@1822 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/Watrack/popup')
-rw-r--r--plugins/Watrack/popup/pop_dlg.inc179
-rw-r--r--plugins/Watrack/popup/pop_opt.inc81
-rw-r--r--plugins/Watrack/popup/pop_rc.inc34
-rw-r--r--plugins/Watrack/popup/pop_vars.inc27
-rw-r--r--plugins/Watrack/popup/popup.rc55
-rw-r--r--plugins/Watrack/popup/popup.resbin0 -> 3352 bytes
-rw-r--r--plugins/Watrack/popup/popups.pas542
-rw-r--r--plugins/Watrack/popup/wat_info.icobin0 -> 1406 bytes
8 files changed, 918 insertions, 0 deletions
diff --git a/plugins/Watrack/popup/pop_dlg.inc b/plugins/Watrack/popup/pop_dlg.inc
new file mode 100644
index 0000000000..129b538780
--- /dev/null
+++ b/plugins/Watrack/popup/pop_dlg.inc
@@ -0,0 +1,179 @@
+{PopUp Option Dialog}
+
+// PopUp options
+const
+ DLGPOPUP = 'POPUP';
+
+function DlgPopUpOpt(Dialog:HWnd;hMessage:Uint;wParam:WPARAM;lParam:LPARAM):LRESULT; stdcall;
+const
+ dlginit:boolean=false;
+var
+ tmp:longbool;
+ ppd:PPOPUPDATAW;
+ fore,back:HWND;
+begin
+ result:=0;
+ case hMessage of
+ WM_INITDIALOG: begin
+ TranslateDialogDefault(Dialog);
+ dlginit:=false;
+
+ SetDlgItemTextW(Dialog,IDC_POPUP_TITLE,PopTitle);
+ SetDlgItemTextW(Dialog,IDC_POPUP_TEXT ,PopText);
+
+ CheckDlgButton(Dialog,IDC_SHOWFILE ,PopUpFile);
+ CheckDlgButton(Dialog,IDC_REQUEST ,PopRequest);
+
+ CheckDlgButton(Dialog,IDC_ACTLEFTCLOSE ,ord(LoByte(PopUpAction)=0));
+ CheckDlgButton(Dialog,IDC_ACTLEFTINFO ,ord(LoByte(PopUpAction)=1));
+ CheckDlgButton(Dialog,IDC_ACTLEFTPLAYER ,ord(LoByte(PopUpAction)=2));
+ CheckDlgButton(Dialog,IDC_ACTLEFTNEXT ,ord(LoByte(PopUpAction)=3));
+ CheckDlgButton(Dialog,IDC_ACTRIGHTCLOSE ,ord(HiByte(PopUpAction)=0));
+ CheckDlgButton(Dialog,IDC_ACTRIGHTINFO ,ord(HiByte(PopUpAction)=1));
+ CheckDlgButton(Dialog,IDC_ACTRIGHTPLAYER,ord(HiByte(PopUpAction)=2));
+ CheckDlgButton(Dialog,IDC_ACTRIGHTNEXT ,ord(HiByte(PopUpAction)=3));
+
+ CheckDlgButton(Dialog,IDC_USEBUTTONS,PopUpButtons);
+
+ SetDlgItemInt (Dialog,IDC_DELAY,PopUpPause,false);
+
+ if PopUpDelay<0 then
+ CheckDlgButton(Dialog,IDC_DELAYPERM,BST_CHECKED)
+ else if PopUpDelay=0 then
+ CheckDlgButton(Dialog,IDC_DELAYDEF,BST_CHECKED)
+ else
+ CheckDlgButton(Dialog,IDC_DELAYCUST,BST_CHECKED);
+ if PopUpDelay<=0 then
+ EnableWindow(GetDlgItem(Dialog,IDC_DELAY),false);
+
+ SendDlgItemMessage(Dialog,IDC_MACRO_HELP,BM_SETIMAGE,IMAGE_ICON,
+ CallService(MS_SKIN_LOADICON,SKINICON_OTHER_HELP,0));
+
+ fore:=GetDlgItem(Dialog,IDC_FORE);
+ back:=GetDlgItem(Dialog,IDC_BACK);
+ SendMessage(fore,CPM_SETCOLOUR,0,PopUpFore);
+ SendMessage(fore,CPM_SETDEFAULTCOLOUR,0,GetSysColor(COLOR_BTNTEXT));
+ SendMessage(back,CPM_SETCOLOUR,0,PopUpBack);
+ SendMessage(back,CPM_SETDEFAULTCOLOUR,0,GetSysColor(COLOR_BTNFACE));
+ SetDlgItemInt(Dialog,IDC_FORE,PopUpFore,false);
+ SetDlgItemInt(Dialog,IDC_BACK,PopUpBack,false);
+ if PopUpColor<2 then
+ begin
+ EnableWindow(fore,false);
+ EnableWindow(back,false);
+ end;
+ case PopUpColor of
+ 0: CheckDlgButton(Dialog,IDC_COLORDEF ,BST_CHECKED);
+ 1: CheckDlgButton(Dialog,IDC_COLORWIN ,BST_CHECKED);
+ 2: CheckDlgButton(Dialog,IDC_COLORCUST,BST_CHECKED);
+ end;
+ dlginit:=true;
+ end;
+
+ WM_COMMAND: begin
+ if (wParam shr 16)=BN_CLICKED then
+ begin
+ fore:=GetDlgItem(Dialog,IDC_FORE);
+ back:=GetDlgItem(Dialog,IDC_BACK);
+ case LoWord(wParam) of
+ IDC_MACRO_HELP: CallService(MS_WAT_MACROHELP,Dialog,0);
+ IDC_TEST: begin
+ mGetMem(ppd,SizeOf(TPOPUPDATAW));
+ FillChar(ppd^,SizeOf(ppd^),0);
+ ppd^.lchIcon:=LoadSkinnedIcon(SKINICON_OTHER_MIRANDA);
+ StrCopyW(ppd^.lpwzContactName,TranslateW('popup test'));
+ StrCopyW(ppd^.lpwzText,TranslateW('second line'));
+ if IsDlgButtonChecked(Dialog,IDC_COLORDEF)=BST_CHECKED then
+ begin
+ ppd^.colorBack:=0;
+ ppd^.colorText:=0;
+ end
+ else if IsDlgButtonChecked(Dialog,IDC_COLORWIN)=BST_CHECKED then
+ begin
+ ppd^.colorBack:=GetSysColor(COLOR_BTNFACE);
+ ppd^.colorText:=GetSysColor(COLOR_BTNTEXT);
+ end
+ else
+ begin
+ ppd^.colorBack:=SendMessage(back,CPM_GETCOLOUR,0,0);
+ ppd^.colorText:=SendMessage(fore,CPM_GETCOLOUR,0,0);
+ end;
+ CallService(MS_POPUP_ADDPOPUPW,twparam(ppd),0);
+ mFreeMem(ppd);
+ end;
+ IDC_DELAYCUST:
+ EnableWindow(GetDlgItem(Dialog,IDC_DELAY),true);
+ IDC_DELAYDEF,IDC_DELAYPERM:
+ EnableWindow(GetDlgItem(Dialog,IDC_DELAY),false);
+ IDC_COLORCUST: begin
+ EnableWindow(fore,true);
+ EnableWindow(back,true);
+ end;
+ IDC_COLORDEF,IDC_COLORWIN: begin
+ EnableWindow(fore,false);
+ EnableWindow(back,false);
+ end;
+ end;
+ end;
+ SendMessage(GetParent(Dialog),PSM_CHANGED,0,0);
+ result:=0;
+ end;
+
+ WM_NOTIFY: begin
+ if dlginit then
+ begin
+ if integer(PNMHdr(lParam)^.code)=PSN_APPLY then
+ begin
+
+ mFreeMem(PopTitle);
+ mFreeMem(PopText);
+ PopTitle:=GetDlgText(Dialog,IDC_POPUP_TITLE);
+ PopText :=GetDlgText(Dialog,IDC_POPUP_TEXT);
+
+ PopUpButtons:=IsDlgButtonChecked(Dialog,IDC_USEBUTTONS);
+
+ PopUpFile :=IsDlgButtonChecked(Dialog,IDC_SHOWFILE);
+ PopRequest:=IsDlgButtonChecked(Dialog,IDC_REQUEST);
+//color
+ if IsDlgButtonChecked(Dialog,IDC_COLORDEF)=BST_CHECKED then
+ PopUpColor:=0
+ else if IsDlgButtonChecked(Dialog,IDC_COLORWIN)=BST_CHECKED then
+ PopUpColor:=1
+ else
+ begin
+ PopUpColor:=2;
+ PopUpFore:=SendDlgItemMessage(Dialog,IDC_FORE,CPM_GETCOLOUR,0,0);
+ PopUpBack:=SendDlgItemMessage(Dialog,IDC_BACK,CPM_GETCOLOUR,0,0);
+ end;
+//pause
+ if IsDlgButtonChecked(Dialog,IDC_DELAYDEF)=BST_CHECKED then
+ PopUpDelay:=0
+ else if IsDlgButtonChecked(Dialog,IDC_DELAYPERM)=BST_CHECKED then
+ PopUpDelay:=-1
+ else
+ begin
+ PopUpDelay:=1;
+ PopUpPause:=GetDlgItemInt(Dialog,IDC_DELAY,tmp,false);
+ end;
+//action
+ if IsDlgButtonChecked(Dialog,IDC_ACTLEFTINFO)=BST_CHECKED then
+ PopUpAction:=1
+ else if IsDlgButtonChecked(Dialog,IDC_ACTLEFTPLAYER)=BST_CHECKED then
+ PopUpAction:=2
+ else if IsDlgButtonChecked(Dialog,IDC_ACTLEFTNEXT)=BST_CHECKED then
+ PopUpAction:=3
+ else
+ PopUpAction:=0;
+ if IsDlgButtonChecked(Dialog,IDC_ACTRIGHTINFO)=BST_CHECKED then
+ inc(PopUpAction,$100)
+ else if IsDlgButtonChecked(Dialog,IDC_ACTRIGHTPLAYER)=BST_CHECKED then
+ inc(PopUpAction,$200)
+ else if IsDlgButtonChecked(Dialog,IDC_ACTRIGHTNEXT)=BST_CHECKED then
+ inc(PopUpAction,$300);
+
+ savepopup;
+ end;
+ end;
+ end;
+ end;
+end;
diff --git a/plugins/Watrack/popup/pop_opt.inc b/plugins/Watrack/popup/pop_opt.inc
new file mode 100644
index 0000000000..591063923e
--- /dev/null
+++ b/plugins/Watrack/popup/pop_opt.inc
@@ -0,0 +1,81 @@
+{Popup options saving-loading}
+
+const
+ defPopupTitle = 'Now listening to';
+ defPopupText = '%artist% - %title%';
+ defAltPopupTitle = 'Now ?ifgreater(%width%,0,watching,listening to)';
+ defAltPopupText = '%artist% - %title%'#13#10'?iflonger(%album%,0, (from "%album%"),)';
+const
+ opt_ModStatus :PAnsiChar = 'module/popups';
+
+ opt_PopUpFile :PAnsiChar = 'popup/file';
+ opt_PopUpAction :PAnsiChar = 'popup/action';
+ opt_PopUpFore :PAnsiChar = 'popup/fore';
+ opt_PopUpBack :PAnsiChar = 'popup/back';
+ opt_PopUpPause :PAnsiChar = 'popup/time';
+ opt_PopUpDelay :PAnsiChar = 'popup/delay';
+ opt_PopUpColor :PAnsiChar = 'popup/color';
+ opt_ByRequest :PAnsiChar = 'popup/byrequest';
+ opt_PopTitle :PAnsiChar = 'popup/poptitle';
+ opt_PopText :PAnsiChar = 'popup/poptext';
+ opt_PopUpButtons:PAnsiChar = 'popup/usebuttons';
+
+ spref = 'strings/';
+
+function GetModStatus:integer;
+begin
+ result:=DBReadByte(0,PluginShort,opt_ModStatus,1);
+end;
+
+procedure SetModStatus(stat:integer);
+begin
+ DBWriteByte(0,PluginShort,opt_ModStatus,stat);
+end;
+
+procedure loadpopup;
+var
+ def1,def2:pWideChar;
+begin
+ PopUpButtons:=DBReadByte (0,PluginShort,opt_PopUpButtons,BST_CHECKED);
+ PopUpFile :=DBReadByte (0,PluginShort,opt_PopUpFile ,BST_CHECKED);
+ PopUpPause :=DBReadByte (0,PluginShort,opt_PopUpPause ,0);
+ PopUpDelay :=DBReadByte (0,PluginShort,opt_PopUpDelay ,0);
+ PopUpAction :=DBReadWord (0,PluginShort,opt_PopUpAction ,0);
+ PopUpColor :=DBReadByte (0,PluginShort,opt_PopUpColor ,0);
+ PopUpFore :=DBReadDWord(0,PluginShort,opt_PopUpFore ,GetSysColor(COLOR_BTNTEXT));
+ PopUpBack :=DBReadDWord(0,PluginShort,opt_PopUpBack ,GetSysColor(COLOR_BTNFACE));
+ PopRequest :=DBReadByte (0,PluginShort,opt_ByRequest ,BST_UNCHECKED);
+ if isVarsInstalled then
+ begin
+ def1:=defAltPopupTitle;
+ def2:=defAltPopupText;
+ end
+ else
+ begin
+ def1:=defPopupTitle;
+ def2:=defPopupText;
+ end;
+ PopTitle:=DBReadUnicode(0,PluginShort,opt_PopTitle,def1);
+ PopText :=DBReadUnicode(0,PluginShort,opt_PopText ,def2);
+end;
+
+procedure savepopup;
+begin
+ DBWriteByte (0,PluginShort,opt_PopUpButtons,PopUpButtons);
+ DBWriteByte (0,PluginShort,opt_PopUpFile ,PopUpFile);
+ DBWriteByte (0,PluginShort,opt_PopUpPause ,PopUpPause);
+ DBWriteByte (0,PluginShort,opt_PopUpDelay ,PopUpDelay);
+ DBWriteWord (0,PluginShort,opt_PopUpAction ,PopUpAction);
+ DBWriteByte (0,PluginShort,opt_PopUpColor ,PopUpColor);
+ DBWriteDWord (0,PluginShort,opt_PopUpFore ,PopUpFore);
+ DBWriteDWord (0,PluginShort,opt_PopUpBack ,PopUpBack);
+ DBWriteByte (0,PluginShort,opt_ByRequest ,PopRequest);
+ DBWriteUnicode(0,PluginShort,opt_PopTitle,PopTitle);
+ DBWriteUnicode(0,PluginShort,opt_PopText ,PopText);
+end;
+
+procedure freepopup;
+begin
+ mFreeMem(PopTitle);
+ mFreeMem(PopText);
+end;
diff --git a/plugins/Watrack/popup/pop_rc.inc b/plugins/Watrack/popup/pop_rc.inc
new file mode 100644
index 0000000000..4e8298d209
--- /dev/null
+++ b/plugins/Watrack/popup/pop_rc.inc
@@ -0,0 +1,34 @@
+{POPUP DLG}
+const
+ IDC_DELAY = 1026;
+ IDC_DELAYDEF = 1027;
+ IDC_DELAYCUST = 1028;
+ IDC_DELAYPERM = 1029;
+ IDC_COLORDEF = 1030;
+ IDC_BACK = 1031;
+ IDC_FORE = 1032;
+ IDC_COLORWIN = 1033;
+ IDC_COLORCUST = 1034;
+ IDC_SHOWFILE = 1035;
+ IDC_TEST = 1036;
+ IDC_ACTLEFTCLOSE = 1040;
+ IDC_ACTLEFTINFO = 1041;
+ IDC_ACTRIGHTCLOSE = 1042;
+ IDC_ACTRIGHTINFO = 1043;
+ IDC_ONKEY = 1044;
+ IDC_KEYEMPTY = 1050;
+ IDC_KEYCUSTOM = 1051;
+ IDC_KEYMSG = 1052;
+ IDC_KEYNOMSG = 1055;
+ IDC_ACTLEFTPLAYER = 1056;
+ IDC_ACTRIGHTPLAYER = 1057;
+ IDC_ACTLEFTNEXT = 1058;
+ IDC_ACTRIGHTNEXT = 1059;
+ IDC_REQUEST = 1060;
+ IDC_STAT_HKBOX = 1061;
+ IDC_POPUP_TITLE = 1062;
+ IDC_POPUP_TEXT = 1063;
+ IDC_MACRO_HELP = 1064;
+ IDC_USEBUTTONS = 1065;
+
+ BTN_INFO = 9;
diff --git a/plugins/Watrack/popup/pop_vars.inc b/plugins/Watrack/popup/pop_vars.inc
new file mode 100644
index 0000000000..4a845aaadc
--- /dev/null
+++ b/plugins/Watrack/popup/pop_vars.inc
@@ -0,0 +1,27 @@
+{popup variables}
+const
+ ActionList:PPOPUPACTION=nil;
+var
+ PopTitle,
+ PopText:pWideChar;
+ PopRequest,
+ PopUpFile:dword;
+ PopUpColor:dword;
+ PopUpFore,
+ PopUpBack:cardinal;
+ PopUpPause:cardinal;
+ PopUpDelay:integer;
+ PopUpAction:cardinal;
+ PopUpButtons:cardinal;
+
+ DisablePlugin:integer;
+ IsPopup2Present:boolean;
+ IsFreeImagePresent:boolean;
+var
+ hMenuInfo :THANDLE;
+ ssmi,sic,
+ plStatusHook:THANDLE;
+ PopupPresent:Bool;
+ onttbhook,
+ opthook:THANDLE;
+ ttbInfo:THANDLE; \ No newline at end of file
diff --git a/plugins/Watrack/popup/popup.rc b/plugins/Watrack/popup/popup.rc
new file mode 100644
index 0000000000..ae05c73860
--- /dev/null
+++ b/plugins/Watrack/popup/popup.rc
@@ -0,0 +1,55 @@
+#include "pop_rc.inc"
+
+LANGUAGE 0,0
+
+POPUP DIALOGEX 0, 0, 304, 226, 0
+STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD
+EXSTYLE WS_EX_CONTROLPARENT
+FONT 8, "MS Shell Dlg", 400, 0
+{
+ AUTOCHECKBOX "Show by request only", IDC_REQUEST, 156, 0, 144, 18, BS_MULTILINE
+
+ GROUPBOX "Colors", -1, 4, 18, 144, 74
+ CTEXT "Background", -1, 24, 64, 50, 8
+ CTEXT "Text" , -1, 84, 64, 50, 8
+ AUTORADIOBUTTON "Default colors", IDC_COLORDEF , 12, 28, 88, 10, NOT WS_TABSTOP
+ AUTORADIOBUTTON "Windows colors", IDC_COLORWIN , 12, 40, 88, 10, NOT WS_TABSTOP
+ AUTORADIOBUTTON "Custom colors" , IDC_COLORCUST, 12, 52, 88, 10, NOT WS_TABSTOP
+ CONTROL "", IDC_BACK, "ColourPicker", WS_TABSTOP, 24, 75, 50, 14
+ CONTROL "", IDC_FORE, "ColourPicker", WS_TABSTOP, 84, 75, 50, 14
+
+ GROUPBOX "Actions", -1, 156, 18, 144, 74
+ RTEXT "Close" , -1, 162, 40, 50, 10
+ RTEXT "Info" , -1, 162, 53, 50, 10
+ RTEXT "Show player", -1, 162, 66, 50, 10
+ RTEXT "Next track" , -1, 162, 79, 50, 10
+
+ CTEXT "Left click", -1, 208, 26, 40, 16
+ AUTORADIOBUTTON "", IDC_ACTLEFTCLOSE , 224, 40, 10, 10, NOT WS_TABSTOP
+ AUTORADIOBUTTON "", IDC_ACTLEFTINFO , 224, 53, 10, 10, NOT WS_TABSTOP
+ AUTORADIOBUTTON "", IDC_ACTLEFTPLAYER, 224, 66, 10, 10, NOT WS_TABSTOP
+ AUTORADIOBUTTON "", IDC_ACTLEFTNEXT , 224, 79, 10, 10, NOT WS_TABSTOP
+ CTEXT "Right click", -1, 248, 26, 40, 16
+ AUTORADIOBUTTON "", IDC_ACTRIGHTCLOSE , 262, 40, 10, 10, NOT WS_TABSTOP
+ AUTORADIOBUTTON "", IDC_ACTRIGHTINFO , 262, 53, 10, 10, NOT WS_TABSTOP
+ AUTORADIOBUTTON "", IDC_ACTRIGHTPLAYER, 262, 66, 10, 10, NOT WS_TABSTOP
+ AUTORADIOBUTTON "", IDC_ACTRIGHTNEXT , 262, 79, 10, 10, NOT WS_TABSTOP
+
+ GROUPBOX "Delay", -1, 4, 96, 144, 48
+ EDITTEXT IDC_DELAY, 86, 117, 36, 12, ES_AUTOHSCROLL | ES_NUMBER
+ LTEXT "sec", -1, 126, 118, 12, 8
+ AUTORADIOBUTTON "Default" , IDC_DELAYDEF , 12, 106, 128, 10, NOT WS_TABSTOP
+ AUTORADIOBUTTON "Custom" , IDC_DELAYCUST, 12, 118, 72, 10, NOT WS_TABSTOP
+ AUTORADIOBUTTON "Permanent", IDC_DELAYPERM, 12, 130, 128, 10, NOT WS_TABSTOP
+
+ AUTOCHECKBOX "Show file name in info" , IDC_SHOWFILE , 156, 94 , 144, 17, BS_MULTILINE
+ AUTOCHECKBOX "Use popup action buttons", IDC_USEBUTTONS, 156, 111, 144, 17, BS_MULTILINE
+ PUSHBUTTON "Test", IDC_TEST, 156, 128, 48, 16
+
+ CONTROL "M", IDC_MACRO_HELP ,"MButtonClass",WS_TABSTOP,278,138,16,16,$18000000
+ CTEXT "Popup Title / Text", -1, 6, 146, 270, 10
+ EDITTEXT IDC_POPUP_TITLE, 6, 156, 290, 14, ES_AUTOHSCROLL
+ EDITTEXT IDC_POPUP_TEXT , 6, 174, 290, 48, ES_MULTILINE | ES_AUTOVSCROLL | ES_AUTOHSCROLL | ES_WANTRETURN
+}
+
+BTN_INFO ICON "wat_info.ico"
diff --git a/plugins/Watrack/popup/popup.res b/plugins/Watrack/popup/popup.res
new file mode 100644
index 0000000000..707791399b
--- /dev/null
+++ b/plugins/Watrack/popup/popup.res
Binary files differ
diff --git a/plugins/Watrack/popup/popups.pas b/plugins/Watrack/popup/popups.pas
new file mode 100644
index 0000000000..381d33dab3
--- /dev/null
+++ b/plugins/Watrack/popup/popups.pas
@@ -0,0 +1,542 @@
+{PopUp support}
+unit Popups;
+{$include compilers.inc}
+interface
+{$Resource popup.res}
+implementation
+
+uses windows,messages,commctrl,
+ wat_api,waticons,global,
+ wrapper,common,m_api,dbsettings,mirutils;
+
+const
+ MenuInfoPos = 500050002;
+ PluginName = 'Winamp Track';
+const
+ IcoBtnInfo:PAnsiChar='WATrack_Info';
+const
+ HKN_POPUP:PAnsiChar = 'WAT_Popup';
+
+{$include pop_rc.inc}
+{$include pop_vars.inc}
+{$include pop_opt.inc}
+
+const
+ MainTmpl = 'artist: %ls'#13#10'title: "%ls"'#13#10'album: "%ls"'#13#10+
+ 'genre: %ls'#13#10'comment: %ls'#13#10'year: %ls'#13#10'track: %lu'#13#10+
+ 'bitrate: %lukbps %ls'#13#10'samplerate: %luKHz'#13#10+
+ 'channels: %lu'#13#10'length: %ls'#13#10'player: "%ls" v.%ls';
+ AddTmpl = #13#10'file: "%ls"'#13#10'size: %lu bytes';
+
+procedure ShowMusicInfo(si:pSongInfo);
+var
+ Tmpl:array [0..255] of WideChar;
+ buf:pWideChar;
+ lvars:array [0..15] of uint_ptr;
+ s:array [0..31] of WideChar;
+ p:PWideChar;
+begin
+ mGetMem(buf,16384);
+ with si^ do
+ begin
+ lvars[0]:=uint_ptr(artist);
+ lvars[1]:=uint_ptr(title);
+ lvars[2]:=uint_ptr(album);
+ lvars[3]:=uint_ptr(genre);
+ lvars[4]:=uint_ptr(comment);
+ lvars[5]:=uint_ptr(year);
+ lvars[6]:=track;
+ lvars[7]:=kbps;
+ if vbr>0 then
+ p:='VBR'
+ else
+ p:='CBR';
+ lvars[8]:=uint_ptr(p);
+ lvars[9]:=khz;
+ lvars[10]:=channels;
+ lvars[11]:=uint_ptr(IntToTime(s,total));
+ lvars[12]:=uint_ptr(player);
+ lvars[13]:=uint_ptr(txtver);
+ end;
+ StrCopyW(Tmpl,TranslateW(MainTmpl));
+ if PopUpFile=BST_CHECKED then
+ begin
+ lvars[14]:=uint_ptr(si^.mfile);
+ lvars[15]:=si^.fsize;
+ StrCatW(Tmpl,TranslateW(AddTmpl));
+ end;
+
+ wvsprintfw(buf,Tmpl,@lvars);
+ MessageBoxW(0,buf,PluginName,MB_OK);
+ mFreeMem(buf);
+end;
+
+function DumbPopupDlgProc(Wnd:hwnd;msg:uint;wParam:integer;lParam:longint):integer;stdcall;
+var
+ si:pSongInfo;
+ h:HBITMAP;
+begin
+ case msg of
+ WM_COMMAND,WM_CONTEXTMENU: begin
+ if msg=WM_CONTEXTMENU then
+ wParam:=HiByte(PopUpAction)
+ else
+ wParam:=LoByte(PopUpAction);
+ si:=pointer(CallService(MS_WAT_RETURNGLOBAL,0,0));
+ case wParam of
+ 1: ShowMusicInfo(si);
+ 2: ShowWindow(si^.plwnd,SW_RESTORE);
+ 3: CallServiceSync(MS_WAT_PRESSBUTTON,WAT_CTRL_NEXT,0);
+ end;
+ SendMessage(Wnd,UM_DESTROYPOPUP,0,0);
+ result:=1;
+ end;
+ UM_POPUPACTION: begin
+// if wParam<>0 then
+ result:=CallServiceSync(MS_WAT_PRESSBUTTON,lParam,0);
+ end;
+ UM_FREEPLUGINDATA: begin
+ h:=0;
+ h:=CallService(MS_POPUP_GETPLUGINDATA,Wnd,h);
+ if h<>0 then
+ DeleteObject(h);
+ result:=0;
+ end;
+ else
+ result:=DefWindowProc(Wnd,msg,wParam,lParam);
+ end;
+end;
+
+function MakeAction(var anAct:TPOPUPACTION;action:integer):PPOPUPACTION;
+begin
+ result:=@anAct;
+ anAct.cbSize :=SizeOf(TPOPUPACTION);
+ anAct.lchIcon:=GetIcon(action);
+ anAct.flags :=PAF_ENABLED;
+ anAct.wParam :=1;
+ anAct.lParam :=action;
+ StrCopy(StrCopyE(anAct.lpzTitle,'Watrack/'),GetIconDescr(action));
+end;
+
+function MakeActions:PPOPUPACTION;
+type
+ anacts = array [0..6] of TPOPUPACTION;
+var
+ actions:^anacts;
+begin
+ if PopUpButtons<>BST_UNCHECKED then
+ begin
+ mGetMem(actions,SizeOf(anacts));
+ result:=PPOPUPACTION(actions);
+ FillChar(actions^,SizeOf(actions^),0);
+ MakeAction(actions[0],WAT_CTRL_PREV);
+ MakeAction(actions[1],WAT_CTRL_PLAY);
+ MakeAction(actions[2],WAT_CTRL_PAUSE);
+ MakeAction(actions[3],WAT_CTRL_STOP);
+ MakeAction(actions[4],WAT_CTRL_NEXT);
+ MakeAction(actions[5],WAT_CTRL_VOLDN);
+ MakeAction(actions[6],WAT_CTRL_VOLUP);
+ end
+ else
+ result:=nil;
+end;
+
+procedure ThShowPopup(si:pSongInfo); cdecl;
+var
+ ppdu:PPOPUPDATAW;
+ title,descr:pWideChar;
+ flag:dword;
+ ppd2:PPOPUPDATA2;
+ Icon:HICON;
+ sec:integer;
+ cb,ct:TCOLORREF;
+ line:boolean;
+ tmp:pAnsiChar;
+begin
+ line:=CallService(MS_POPUP_ISSECONDLINESHOWN,0,0)<>0;
+
+ descr:=PWideChar(CallService(MS_WAT_REPLACETEXT,0,lparam(PopText)));
+ if line then
+ title:=PWideChar(CallService(MS_WAT_REPLACETEXT,0,lparam(PopTitle)))
+ else
+ title:=nil;
+
+ if (descr<>nil) or (title<>nil) then
+ begin
+ if si^.icon<>0 then
+ Icon:=si^.icon
+ else
+ Icon:=LoadSkinnedIcon(SKINICON_OTHER_MIRANDA);
+ if PopUpDelay<0 then
+ sec:=-1
+ else if PopUpDelay>0 then
+ sec:=PopUpPause
+ else
+ sec:=0;
+ case PopUpColor of
+ 0: begin
+ cb:=0;
+ ct:=0;
+ end;
+ 1: begin
+ cb:=GetSysColor(COLOR_BTNFACE);
+ ct:=GetSysColor(COLOR_BTNTEXT);
+ end;
+ 2: begin
+ cb:=PopUpBack;
+ ct:=PopUpFore;
+ end;
+ else
+ cb:=0;
+ ct:=0;
+ end;
+
+ if IsPopup2Present then
+ begin
+ mGetMem (ppd2 ,SizeOf(TPOPUPDATA2));
+ FillChar(ppd2^,SizeOf(TPOPUPDATA2),0);
+ with ppd2^ do
+ begin
+ cbSize :=SizeOf(TPOPUPDATA2);
+ flags :=PU2_UNICODE;
+ lchIcon :=Icon;
+ colorBack :=cb;
+ colorText :=ct;
+ PluginWindowProc:=@DumbPopupDlgProc;
+
+ if line then
+ begin
+ pzTitle.w:=title;
+ pzText .w:=descr;
+ end
+ else
+ pzTitle.w:=descr;
+
+ if ActionList=nil then
+ flag:=0
+ else
+ begin
+ flag :=APF_NEWDATA;
+ actionCount:=7;
+ lpActions :=ActionList;
+ end;
+
+ if si.cover<>nil then
+ begin
+ if IsFreeImagePresent then
+ hbmAvatar:=CallService(MS_IMG_LOAD,wparam(si.cover),IMGL_WCHAR)
+ else
+ hbmAvatar:=0;
+ if hbmAvatar=0 then
+ begin
+ WideToAnsi(si.cover,tmp);
+ hbmAvatar:=CallService(MS_UTILS_LOADBITMAP,0,lparam(tmp));
+ mFreeMem(tmp);
+ end;
+ end;
+ PluginData:=pointer(hbmAvatar);
+ end;
+ CallService(MS_POPUP_ADDPOPUP2,wparam(ppd2),flag);
+ mFreeMem(ppd2);
+ end
+ else
+ begin
+ mGetMem (ppdu ,SizeOf(TPOPUPDATAW));
+ FillChar(ppdu^,SizeOf(TPOPUPDATAW),0);
+ with ppdu^ do
+ begin
+ if line then
+ begin
+ if title<>nil then
+ StrCopyW(lpwzContactName,title,MAX_CONTACTNAME-1)
+ else
+ lpwzContactName[0]:=' ';
+ if descr<>nil then
+ StrCopyW(lpwzText,descr,MAX_SECONDLINE-1)
+ else
+ lpwzText[0]:=' ';
+ end
+ else
+ begin
+ StrCopyW(ppdu^.lpwzContactName,title,MAX_CONTACTNAME-1);
+ lpwzText[0]:=' ';
+ end;
+
+ lchIcon :=Icon;
+ PluginWindowProc:=@DumbPopupDlgProc;
+ iSeconds :=sec;
+ colorBack :=cb;
+ colorText :=ct;
+
+ // if ServiceExists(MS_POPUP_REGISTERACTIONS)=0 then
+ if ActionList=nil then
+ flag:=0
+ else
+ begin
+ flag :=APF_NEWDATA;
+ icbSize :=SizeOf(TPOPUPDATAW);
+ actionCount:=7;
+ lpActions :=ActionList;
+ end;
+ end;
+ CallService(MS_POPUP_ADDPOPUPW,wparam(ppdu),flag);
+ mFreeMem(ppdu);
+ end;
+ mFreeMem(title);
+ mFreeMem(descr);
+ end;
+end;
+
+procedure ShowPopUp(si:pSongInfo);
+begin
+ CloseHandle(mir_forkthread(@ThShowPopup,si));
+end;
+
+// --------------- Services and Hooks ----------------
+
+function OpenPopUp(wParam:WPARAM;lParam:LPARAM):int;cdecl;
+var
+ si:pSongInfo;
+begin
+ result:=0;
+ if DisablePlugin<>dsEnabled then
+ exit;
+ if CallService(MS_WAT_GETMUSICINFO,0,tlparam(@si))=WAT_PLS_NORMAL then
+ begin
+ if PopupPresent then
+ ShowPopUp(si)
+ else
+ ShowMusicInfo(si);
+ end;
+end;
+
+procedure regpophotkey;
+var
+ hkrec:HOTKEYDESC;
+begin
+ if DisablePlugin=dsPermanent then
+ exit;
+ FillChar(hkrec,SizeOf(hkrec),0);
+ with hkrec do
+ begin
+ cbSize :=HOTKEYDESC_SIZE_V1;
+ pszName :=HKN_POPUP;
+ pszDescription.a:='WATrack popup hotkey';
+ pszSection.a :=PluginName;
+ pszService :=MS_WAT_SHOWMUSICINFO;
+ DefHotKey:=((HOTKEYF_ALT or HOTKEYF_CONTROL) shl 8) or VK_F7 or HKF_MIRANDA_LOCAL;
+ end;
+ CallService(MS_HOTKEY_REGISTER,0,lparam(@hkrec));
+end;
+
+{$include pop_dlg.inc}
+
+function NewPlStatus(wParam:WPARAM;lParam:LPARAM):int;cdecl;
+var
+ mi:TCListMenuItem;
+ flag:integer;
+begin
+ result:=0;
+ case wParam of
+ WAT_EVENT_NEWTRACK: begin
+ if PopupPresent and (PopRequest=BST_UNCHECKED) then
+ ShowPopUp(pSongInfo(lParam));
+ end;
+ WAT_EVENT_PLUGINSTATUS: begin
+ DisablePlugin:=lParam;
+ case lParam of
+ dsEnabled: begin
+ flag:=0;
+ end;
+ dsPermanent: begin
+ flag:=CMIF_GRAYED;
+ end;
+ else // like 1
+ exit
+ end;
+ FillChar(mi,sizeof(mi),0);
+ mi.cbSize:=sizeof(mi);
+ mi.flags :=CMIM_FLAGS+flag;
+ CallService(MS_CLIST_MODIFYMENUITEM,hMenuInfo,tlparam(@mi));
+ end;
+ end;
+end;
+
+function IconChanged(wParam:WPARAM;lParam:LPARAM):int;cdecl;
+var
+ mi:TCListMenuItem;
+begin
+ result:=0;
+ FillChar(mi,SizeOf(mi),0);
+ mi.cbSize:=sizeof(mi);
+ mi.flags :=CMIM_ICON;
+ mi.hIcon :=CallService(MS_SKIN2_GETICON,0,tlparam(IcoBtnInfo));
+ CallService(MS_CLIST_MODIFYMENUITEM,hMenuInfo,tlparam(@mi));
+ if ActionList<>nil then
+ begin
+ mFreeMem(ActionList);
+ ActionList:=MakeActions;
+ CallService(MS_POPUP_REGISTERACTIONS,twparam(ActionList),7);
+ end;
+end;
+
+function OnOptInitialise(wParam:WPARAM;lParam:LPARAM):int;cdecl;
+var
+ odp:TOPTIONSDIALOGPAGE;
+begin
+ FillChar(odp,SizeOf(odp),0);
+ odp.cbSize :=OPTIONPAGE_OLD_SIZE2; //for 0.5 compatibility
+ odp.flags :=ODPF_BOLDGROUPS;
+ odp.Position :=900003000;
+ odp.hInstance :=hInstance;
+ odp.szTitle.a :=PluginName;
+
+ odp.szGroup.a :='PopUps';
+ odp.pszTemplate:=DLGPOPUP;
+ odp.pfnDlgProc :=@DlgPopUpOpt;
+ CallService(MS_OPT_ADDPAGE,wParam,tlparam(@odp));
+ result:=0;
+end;
+
+function OnTTBLoaded(wParam:WPARAM;lParam:LPARAM):int;cdecl;
+var
+ ttb:TTBButton;
+begin
+ result:=0;
+ if onttbhook<>0 then
+ UnhookEvent(onttbhook);
+ // get info button
+ FillChar(ttb,SizeOf(ttb),0);
+ ttb.cbSize :=SizeOf(ttb);
+ ttb.dwFlags :=TTBBF_VISIBLE{ or TTBBF_SHOWTOOLTIP};
+ ttb.hIconUp :=CallService(MS_SKIN2_GETICON,0,tlparam(IcoBtnInfo));
+ ttb.hIconDn :=ttb.hIconUp;
+ ttb.pszService:=MS_WAT_SHOWMUSICINFO;
+ ttb.name :='Music Info';
+ ttbInfo:=TopToolbar_AddButton(@ttb);
+ if ttbInfo=THANDLE(-1) then
+ ttbInfo:=0;
+end;
+
+// ------------ base interface functions -------------
+
+function InitProc(aGetStatus:boolean=false):integer;
+var
+ mi:TCListMenuItem;
+ sid:TSKINICONDESC;
+begin
+ if aGetStatus then
+ begin
+ if GetModStatus=0 then
+ begin
+ result:=0;
+ exit;
+ end;
+ end
+ else
+ SetModStatus(1);
+ result:=1;
+
+ ssmi:=CreateServiceFunction(MS_WAT_SHOWMUSICINFO,@OpenPopUp);
+
+ FillChar(sid,SizeOf(TSKINICONDESC),0);
+ sid.cbSize:=SizeOf(TSKINICONDESC);
+ sid.cx:=16;
+ sid.cy:=16;
+ sid.szSection.a:='WATrack';
+ sid.hDefaultIcon :=LoadImage(hInstance,MAKEINTRESOURCE(BTN_INFO),IMAGE_ICON,16,16,0);
+ sid.pszName :=IcoBtnInfo;
+ sid.szDescription.a:='Music Info';
+ Skin_AddIcon(@sid);
+ DestroyIcon(sid.hDefaultIcon);
+ sic:=HookEvent(ME_SKIN2_ICONSCHANGED,@IconChanged);
+
+ FillChar(mi,SizeOf(mi),0);
+ mi.cbSize :=SizeOf(mi);
+ mi.szPopupName.a:=PluginShort;
+ mi.hIcon :=CallService(MS_SKIN2_GETICON,0,lparam(IcoBtnInfo));
+ mi.szName.a :='Music Info';
+ mi.pszService :=MS_WAT_SHOWMUSICINFO;
+ mi.popupPosition:=MenuInfoPos;
+ hMenuInfo :=Menu_AddMainMenuItem(@mi);
+
+ if ServiceExists(MS_POPUP_ADDPOPUPW)<>0 then
+ begin
+ IsFreeImagePresent:=ServiceExists(MS_IMG_LOAD )<>0;
+ IsPopup2Present :=ServiceExists(MS_POPUP_ADDPOPUP2)<>0;
+ PopupPresent:=true;
+ opthook:=HookEvent(ME_OPT_INITIALISE,@OnOptInitialise);
+ loadpopup;
+ regpophotkey;
+
+ ActionList:=nil;
+ if ServiceExists(MS_POPUP_REGISTERACTIONS)<>0 then
+ begin
+ if RegisterButtonIcons then
+ begin
+ ActionList:=MakeActions;
+ if ActionList<>nil then
+ CallService(MS_POPUP_REGISTERACTIONS,wparam(ActionList),7);
+ end;
+ end;
+ end
+ else
+ begin
+ PopupPresent:=false;
+ end;
+
+ plStatusHook:=HookEvent(ME_WAT_NEWSTATUS,@NewPlStatus);
+
+ if ServiceExists(MS_TTB_ADDBUTTON)>0 then
+ begin
+ onttbhook:=0;
+ OnTTBLoaded(0,0);
+ if ttbInfo=0 then
+ onttbhook:=HookEvent(ME_TTB_MODULELOADED,@OnTTBLoaded);
+ end
+ else
+ ttbInfo:=0;
+end;
+
+procedure DeInitProc(aSetDisable:boolean);
+begin
+ if aSetDisable then
+ SetModStatus(0);
+
+ CallService(MS_CLIST_REMOVEMAINMENUITEM,hMenuInfo,0);
+ UnhookEvent(plStatusHook);
+ DestroyServiceFunction(ssmi);
+ UnhookEvent(sic);
+
+ freepopup;
+
+ if ttbInfo<>0 then
+ begin
+ if ServiceExists(MS_TTB_REMOVEBUTTON)>0 then
+ CallService(MS_TTB_REMOVEBUTTON,WPARAM(ttbInfo),0);
+ ttbInfo:=0;
+ end;
+
+ if PopupPresent then
+ begin
+ UnhookEvent(opthook);
+ mFreeMem(ActionList);
+ end;
+end;
+
+var
+ Popup:twModule;
+
+procedure Init;
+begin
+ Popup.Next :=ModuleLink;
+ Popup.Init :=@InitProc;
+ Popup.DeInit :=@DeInitProc;
+ Popup.AddOption :=nil;
+ Popup.ModuleName:='PopUps';
+ ModuleLink :=@Popup;
+end;
+
+begin
+ Init;
+end.
diff --git a/plugins/Watrack/popup/wat_info.ico b/plugins/Watrack/popup/wat_info.ico
new file mode 100644
index 0000000000..70d54c8bac
--- /dev/null
+++ b/plugins/Watrack/popup/wat_info.ico
Binary files differ