summaryrefslogtreecommitdiff
path: root/plugins/Watrack/stat/stat_dlg.inc
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/stat/stat_dlg.inc
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/stat/stat_dlg.inc')
-rw-r--r--plugins/Watrack/stat/stat_dlg.inc223
1 files changed, 223 insertions, 0 deletions
diff --git a/plugins/Watrack/stat/stat_dlg.inc b/plugins/Watrack/stat/stat_dlg.inc
new file mode 100644
index 0000000000..64a9b97f7c
--- /dev/null
+++ b/plugins/Watrack/stat/stat_dlg.inc
@@ -0,0 +1,223 @@
+{Statistic Dialog}
+
+{$include stat_rc.inc}
+
+procedure SetReportMask(Dlg:hwnd);
+begin
+ ReportMask:=0;
+ if IsDlgButtonChecked(Dlg,IDC_FREQART)=BST_CHECKED then
+ ReportMask:=ReportMask or stArtist;
+ if IsDlgButtonChecked(Dlg,IDC_FREQSONG)=BST_CHECKED then
+ ReportMask:=ReportMask or stCount;
+ if IsDlgButtonChecked(Dlg,IDC_FREQPATH)=BST_CHECKED then
+ ReportMask:=ReportMask or stPath;
+ if IsDlgButtonChecked(Dlg,IDC_LASTSONG)=BST_CHECKED then
+ ReportMask:=ReportMask or stDate;
+ if IsDlgButtonChecked(Dlg,IDC_SONGTIME)=BST_CHECKED then
+ ReportMask:=ReportMask or stLength;
+ if IsDlgButtonChecked(Dlg,IDC_FREQALBUM)=BST_CHECKED then
+ ReportMask:=ReportMask or stAlbum;
+end;
+
+procedure EnableItems(Dlg:hwnd;enable:boolean);
+begin
+ EnableWindow(GetDlgItem(Dlg,IDC_STATNAME) ,enable);
+ EnableWindow(GetDlgItem(Dlg,IDC_SNBUTTON) ,enable);
+ EnableWindow(GetDlgItem(Dlg,IDC_SORTFILE) ,enable);
+ EnableWindow(GetDlgItem(Dlg,IDC_REPORT) ,enable);
+ EnableWindow(GetDlgItem(Dlg,IDC_CLEAR) ,enable);
+ EnableWindow(GetDlgItem(Dlg,IDC_BYTITLE) ,enable);
+ EnableWindow(GetDlgItem(Dlg,IDC_BYDATE) ,enable);
+ EnableWindow(GetDlgItem(Dlg,IDC_BYCOUNT) ,enable);
+ EnableWindow(GetDlgItem(Dlg,IDC_BYPATH) ,enable);
+ EnableWindow(GetDlgItem(Dlg,IDC_BYLENGTH) ,enable);
+ EnableWindow(GetDlgItem(Dlg,IDC_DIRECTION),enable);
+ EnableWindow(GetDlgItem(Dlg,IDC_REPNAME) ,enable);
+ EnableWindow(GetDlgItem(Dlg,IDC_RNBUTTON) ,enable);
+ EnableWindow(GetDlgItem(Dlg,IDC_ITEMS) ,enable);
+ EnableWindow(GetDlgItem(Dlg,IDC_FREQART) ,enable);
+ EnableWindow(GetDlgItem(Dlg,IDC_FREQSONG) ,enable);
+ EnableWindow(GetDlgItem(Dlg,IDC_FREQALBUM),enable);
+ EnableWindow(GetDlgItem(Dlg,IDC_FREQPATH) ,enable);
+ EnableWindow(GetDlgItem(Dlg,IDC_LASTSONG) ,enable);
+ EnableWindow(GetDlgItem(Dlg,IDC_SONGTIME) ,enable);
+ EnableWindow(GetDlgItem(Dlg,IDC_RUNREPORT),enable);
+ EnableWindow(GetDlgItem(Dlg,IDC_ADDEXT) ,enable);
+ EnableWindow(GetDlgItem(Dlg,IDC_AUTOSORT) ,enable);
+end;
+
+function DlgProcOptions(Dialog:HWnd; hMessage:dword;wParam:WPARAM;lParam:LPARAM):LRESULT; stdcall;
+const
+ changed:boolean=false;
+var
+ buf,buf1:array [0..511] of AnsiChar;
+ tmp:longbool;
+ p:PAnsiChar;
+ f:THANDLE;
+begin
+ result:=0;
+ case hMessage of
+ WM_INITDIALOG: begin
+ TranslateDialogDefault(Dialog);
+ SetDlgItemInt(Dialog,IDC_ITEMS,ReportItems,false);
+ if ReportName=nil then
+ p:=''
+ else
+ p:=ReportName;
+ SetDlgItemTextA(Dialog,IDC_REPNAME,p);
+ if StatName=nil then
+ p:=''
+ else
+ p:=StatName;
+ SetDlgItemTextA(Dialog,IDC_STATNAME,p);
+ if TmplName=nil then
+ p:=''
+ else
+ p:=TmplName;
+ SetDlgItemTextA(Dialog,IDC_TMPLNAME,p);
+ SetDlgItemInt(Dialog,IDC_AUTOSORT,AutoSort,false);
+ CheckDlgButton(Dialog,IDC_RUNREPORT,RunReport);
+ CheckDlgButton(Dialog,IDC_ADDEXT,DoAddExt);
+
+ CheckDlgButton(Dialog,IDC_BYTITLE ,ord(SortMode=stArtist));
+ CheckDlgButton(Dialog,IDC_BYDATE ,ord(SortMode=stDate));
+ CheckDlgButton(Dialog,IDC_BYCOUNT ,ord(SortMode=stCount));
+ CheckDlgButton(Dialog,IDC_BYPATH ,ord(SortMode=stPath));
+ CheckDlgButton(Dialog,IDC_BYLENGTH,ord(SortMode=stLength));
+
+ if Direction=smReverse then
+ CheckDlgButton(Dialog,IDC_DIRECTION,BST_CHECKED);
+
+ if (ReportMask and stArtist)<>0 then
+ CheckDlgButton(Dialog,IDC_FREQART,BST_CHECKED);
+ if (ReportMask and stAlbum)<>0 then
+ CheckDlgButton(Dialog,IDC_FREQALBUM,BST_CHECKED);
+ if (ReportMask and stCount)<>0 then
+ CheckDlgButton(Dialog,IDC_FREQSONG,BST_CHECKED);
+ if (ReportMask and stPath)<>0 then
+ CheckDlgButton(Dialog,IDC_FREQPATH,BST_CHECKED);
+ if (ReportMask and stDate)<>0 then
+ CheckDlgButton(Dialog,IDC_LASTSONG,BST_CHECKED);
+ if (ReportMask and stLength)<>0 then
+ CheckDlgButton(Dialog,IDC_SONGTIME,BST_CHECKED);
+ result:=0;
+ changed:=false;
+ end;
+
+ WM_COMMAND: begin
+ if (wParam shr 16)=BN_CLICKED then
+ begin
+ case loword(wParam) of
+ IDC_BYTITLE : SortMode:=stArtist;
+ IDC_BYDATE : SortMode:=stDate;
+ IDC_BYCOUNT : SortMode:=stCount;
+ IDC_BYPATH : SortMode:=stPath;
+ IDC_BYLENGTH: SortMode:=stLength;
+ IDC_RUNREPORT: RunReport :=IsDlgButtonChecked(Dialog,IDC_RUNREPORT);
+ IDC_ADDEXT: DoAddExt :=IsDlgButtonChecked(Dialog,IDC_ADDEXT);
+ IDC_DIRECTION: begin
+ if IsDlgButtonChecked(Dialog,IDC_DIRECTION)=BST_CHECKED then
+ Direction:=smReverse
+ else
+ Direction:=smDirect;
+ end;
+
+ IDC_CLEAR: begin
+ DeleteFileA(StatName);
+ exit;
+ end;
+ IDC_SNBUTTON: begin
+ if ShowDlg(buf,StatName) then
+ SetDlgItemTextA(Dialog,IDC_STATNAME,buf);
+ end;
+ IDC_TNBUTTON: begin
+ if ShowDlg(buf,TmplName) then
+ SetDlgItemTextA(Dialog,IDC_TMPLNAME,buf);
+ end;
+ IDC_RNBUTTON: begin
+ if ShowDlg(buf,ReportName) then
+ SetDlgItemTextA(Dialog,IDC_REPNAME,buf);
+ end;
+ IDC_SORTFILE: begin
+ GetDlgItemTextA(Dialog,IDC_STATNAME,buf,511);
+ if buf[0]<>#0 then
+ SortFile(buf,SortMode,Direction);
+ exit;
+ end;
+ IDC_EXPORTDEF: begin
+ if ShowDlg(buf,TmplName) then
+ begin
+ f:=Rewrite(buf);
+ if f=THANDLE(INVALID_HANDLE_VALUE) then
+ err('Can''t create file')
+ else
+ begin
+ BlockWrite(f,IntTmpl^,StrLen(IntTmpl));
+ CloseHandle(f);
+ end;
+ end;
+ exit;
+ end;
+ IDC_REPORT: begin
+ ReportItems:=GetDlgItemInt(Dialog,IDC_ITEMS,tmp,false);
+ if ReportItems=0 then
+ ReportItems:=1;
+ GetDlgItemTextA(Dialog,IDC_REPNAME,buf1,511);
+ GetDlgItemTextA(Dialog,IDC_TMPLNAME,buf,511);
+ SetReportMask(Dialog);
+ CallService(MS_WAT_MAKEREPORT,TWPARAM(@buf),TLPARAM(@buf1));
+ end;
+ end;
+ end;
+ if ((wParam shr 16)=EN_CHANGE) or ((wParam shr 16)=BN_CLICKED) then
+ begin
+ SendMessage(GetParent(Dialog),PSM_CHANGED,0,0);
+ changed:=true;
+ end;
+ result:=1;
+ end;
+
+ WM_NOTIFY: begin
+ if (integer(PNMHdr(lParam)^.code)=PSN_APPLY) and changed then
+ begin
+ GetDlgItemTextA(Dialog,IDC_STATNAME,buf,511);
+ mFreeMem(StatName);
+ if buf[0]<>#0 then
+ begin
+ buf1[0]:=#0;
+ CallService(MS_UTILS_PATHTORELATIVE,TWPARAM(@buf),TLPARAM(@buf1));
+ StrDup(StatName,buf1);
+ end;
+
+ GetDlgItemTextA(Dialog,IDC_REPNAME,buf,511);
+ mFreeMem(ReportName);
+ if buf[0]<>#0 then
+ begin
+ buf1[0]:=#0;
+ CallService(MS_UTILS_PATHTORELATIVE,TWPARAM(@buf),TLPARAM(@buf1));
+ StrDup(ReportName,buf1);
+ end;
+
+ GetDlgItemTextA(Dialog,IDC_TMPLNAME,buf,511);
+ mFreeMem(TmplName);
+ if buf[0]<>#0 then
+ begin
+ buf1[0]:=#0;
+ CallService(MS_UTILS_PATHTORELATIVE,TWPARAM(@buf),TLPARAM(@buf1));
+ StrDup(TmplName,buf1);
+ end;
+
+ AutoSort:=GetDlgItemInt(Dialog,IDC_AUTOSORT,tmp,false);
+ ReportItems:=GetDlgItemInt(Dialog,IDC_ITEMS,tmp,false);
+ if ReportItems=0 then
+ ReportItems:=1;
+ SetReportMask(Dialog);
+ result:=1;
+ savestat;
+ changed:=false;
+ end;
+ end;
+ else
+ {result:=}DefWindowProc(Dialog,hMessage,wParam,lParam);
+ end;
+end;