1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
|
#include "main.h"
#include <windows.h>
#include <windowsx.h>
#include <stdio.h>
#include <shlobj.h>
#include "..\..\General\gen_ml/ml.h"
#include "..\..\General\gen_ml/itemlist.h"
#include "../nu/listview.h"
#include "..\..\General\gen_ml/childwnd.h"
#include "../winamp/wa_ipc.h"
#include "../winamp/wa_dlg.h"
#include "resource1.h"
#include "SkinnedListView.h"
#include "DeviceView.h"
#include "api__ml_pmp.h"
#include "metadata_utils.h"
static int (*wad_handleDialogMsgs)(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
static void (*wad_DrawChildWindowBorders)(HWND hwndDlg, int *tab, int tabsize);
static void (*cr_init)(HWND hwndDlg, ChildWndResizeItem *list, int num);
static void (*cr_resize)(HWND hwndDlg, ChildWndResizeItem *list, int num);
static HWND m_hwnd;
static ChildWndResizeItem resize_rlist[]=
{
{IDC_LIST_DEVICES, 0x0010},
{IDC_LIST_TRANSFERS, 0x0011},
{IDC_TQ_STATIC, 0x0000},
{IDC_HDELIM, 0x0010},
{IDC_BUTTON_PAUSETRANSFERS, 0x0101},
{IDC_BUTTON_CLEARFINISHED, 0x0101},
{IDC_BUTTON_REMOVESELECTED, 0x0101},
{IDC_STATUS,0x0111},
};
static int m_nodrawtopborders=0,adiv_clickoffs,adivpos=-1;
SkinnedListView * listDevices=NULL;
static SkinnedListView * listTransfers=NULL;
//CRITICAL_SECTION listTransfersLock;
static INT_PTR CALLBACK adiv_newWndProc(HWND hwndDlg, UINT uMsg, WPARAM wParam,LPARAM lParam);
static void adiv_UpdPos(int xp);
static WNDPROC adiv_oldWndProc;
class DeviceContents : public ListContents
{
public:
virtual int GetNumColumns()
{
return 2;
}
virtual int GetNumRows()
{
return devices.GetSize();
}
virtual wchar_t * GetColumnTitle(int num)
{
switch (num)
{
case 0: return WASABI_API_LNGSTRINGW(IDS_NAME);
case 1: return WASABI_API_LNGSTRINGW(IDS_CAPACITY_FREE);
}
return L"";
}
virtual int GetColumnWidth(int num)
{
switch (num)
{
case 0: return global_config->ReadInt(L"devices_col0_width",150);
case 1: return global_config->ReadInt(L"devices_col1_width",100);
default: return 0;
}
}
virtual void ColumnResize(int col, int newWidth)
{
if (col==0) global_config->WriteInt(L"devices_col0_width",newWidth);
else if (col==1) global_config->WriteInt(L"devices_col1_width",newWidth);
}
virtual void GetCellText(int row, int col, wchar_t * buf, int buflen)
{
switch (col)
{
case 0:
((DeviceView *)devices.Get(row))->dev->getPlaylistName(0,buf,buflen);
return;
case 1:
{
wchar_t capacity[20]=L"";
Device * dev = ((DeviceView *)devices.Get(row))->dev;
WASABI_API_LNG->FormattedSizeString(capacity, ARRAYSIZE(capacity), dev->getDeviceCapacityTotal());
__int64 cap = dev->getDeviceCapacityTotal();
int pc;
if (cap) pc = (int)((((__int64)100)*dev->getDeviceCapacityAvailable()) / cap);
else pc = 0;
wsprintf(buf,L"%s (%d%%)",capacity,pc);
}
return;
}
}
virtual songid_t GetTrack(int pos) { return 0; }
};
static DeviceContents deviceListContents;
class TransferItemShadow
{
public:
CopyInst * c;
wchar_t * status, * type, * track;
wchar_t device[128];
bool changed;
TransferItemShadow(CopyInst * c)
{
changed = false;
this->c = c;
status = _wcsdup(c->statusCaption);
type = _wcsdup(c->typeCaption);
track = _wcsdup(c->trackCaption);
device[0] = 0;
c->dev->dev->getPlaylistName(0,device,128);
}
~TransferItemShadow()
{
free(status);
free(type);
free(track);
}
bool Equals(TransferItemShadow * a)
{
if (!a) return false;
return (c == a->c) && !wcscmp(track,a->track) && !wcscmp(status,a->status) && !wcscmp(device,a->device) && !wcscmp(type,a->type);
}
};
static C_ItemList *getTransferListShadow()
{
C_ItemList * list = new C_ItemList;
for (int i=0; i < devices.GetSize(); i++)
{
DeviceView *device = (DeviceView*)devices.Get(i);
LinkedQueue * txQueue = getTransferQueue(device);
LinkedQueue * finishedTX = getFinishedTransferQueue(device);
if (txQueue)
{
txQueue->lock();
int l = txQueue->GetSize();
for (int j=0; j<l; j++)
list->Add(new TransferItemShadow((CopyInst*)txQueue->Get(j)));
txQueue->unlock();
}
if (finishedTX)
{
finishedTX->lock();
int l = finishedTX->GetSize();
for (int j=0; j<l; j++)
list->Add(new TransferItemShadow((CopyInst*)finishedTX->Get(j)));
finishedTX->unlock();
}
}
return list;
}
class TransferContents2 : public ListContents
{
public:
CRITICAL_SECTION cs;
C_ItemList * listShadow;
TransferContents2() : listShadow(0)
{
oldSize = 0;
listShadow = getTransferListShadow();
InitializeCriticalSection(&cs);
}
virtual ~TransferContents2()
{
DeleteCriticalSection(&cs); delete listShadow;
}
virtual int GetNumColumns()
{
return 4;
}
virtual int GetNumRows()
{
return (listShadow ? listShadow->GetSize() : 0);
}
virtual wchar_t * GetColumnTitle(int num)
{
switch (num)
{
case 0: return WASABI_API_LNGSTRINGW(IDS_TYPE);
case 1: return WASABI_API_LNGSTRINGW(IDS_TRACK);
case 2: return WASABI_API_LNGSTRINGW(IDS_STATUS);
case 3: return WASABI_API_LNGSTRINGW(IDS_DEVICE);
}
return L"";
}
virtual int GetColumnWidth(int num)
{
switch (num)
{
case 0: return global_config->ReadInt(L"transfers_col0_width",100);
case 1: return global_config->ReadInt(L"transfers_col1_width",300);
case 2: return global_config->ReadInt(L"transfers_col2_width",150);
case 3: return global_config->ReadInt(L"transfers_col3_width",150);
default: return 0;
}
}
virtual void ColumnResize(int col, int newWidth)
{
if (col==0) global_config->WriteInt(L"transfers_col0_width",newWidth);
else if (col==1) global_config->WriteInt(L"transfers_col1_width",newWidth);
else if (col==2) global_config->WriteInt(L"transfers_col2_width",newWidth);
else if (col==3) global_config->WriteInt(L"transfers_col3_width",newWidth);
}
void lock()
{
EnterCriticalSection(&cs);
}
void unlock()
{
LeaveCriticalSection(&cs);
}
virtual void GetCellText(int row, int col, wchar_t * buf, int buflen)
{
lock();
if (row >= listShadow->GetSize())
{
unlock(); return;
}
TransferItemShadow * t = (TransferItemShadow *)listShadow->Get(row);
switch (col)
{
case 0: lstrcpyn(buf,t->type,buflen); break;
case 1: lstrcpyn(buf,t->track,buflen); break;
case 2: lstrcpyn(buf,t->status,buflen); break;
case 3: lstrcpyn(buf,t->device,buflen); break;
}
unlock();
}
void PushPopItem(CopyInst *c)
{
lock();
int size = listShadow->GetSize();
for (int i=0; i<size; i++)
{
TransferItemShadow * t = (TransferItemShadow *)listShadow->Get(i);
if (c == t->c)
{
t->changed=true;
listShadow->Del(i);
listShadow->Add(t);
if (listTransfers)
{
HWND hwnd = listTransfers->listview.getwnd();
PostMessage(hwnd,LVM_DELETEITEM,i,0);
PostMessage(hwnd,LVM_SETITEMCOUNT,size,LVSICF_NOINVALIDATEALL | LVSICF_NOSCROLL);
}
unlock();
return;
}
}
unlock();
}
void ItemUpdate(CopyInst * c)
{
lock();
int size = listShadow->GetSize();
for (int i=0; i<size; i++)
{
TransferItemShadow * t = (TransferItemShadow *)listShadow->Get(i);
if (c == t->c)
{
TransferItemShadow * n = new TransferItemShadow(c);
n->changed=true;
listShadow->Set(i,n);
delete t;
if (listTransfers)
{
HWND hwnd = listTransfers->listview.getwnd();
PostMessage(hwnd,LVM_REDRAWITEMS,i,i);
}
unlock();
return;
}
}
unlock();
}
int oldSize;
void FullUpdate()
{
C_ItemList * newListShadow = getTransferListShadow();
int newSize = newListShadow->GetSize();
lock();
oldSize = listShadow->GetSize();
for (int i=0; i<newSize; i++)
{
TransferItemShadow * newt = (TransferItemShadow *)newListShadow->Get(i);
TransferItemShadow * oldt = i<oldSize?(TransferItemShadow *)listShadow->Get(i):NULL;
newt->changed = !newt->Equals(oldt);
}
C_ItemList * oldListShadow = listShadow;
listShadow = newListShadow;
for (int i=0; i<oldListShadow->GetSize(); i++) delete(TransferItemShadow *)oldListShadow->Get(i);
delete oldListShadow;
if (listTransfers)
{
HWND hwnd = listTransfers->listview.getwnd();
if (newSize != oldSize) PostMessage(hwnd,LVM_SETITEMCOUNT,newSize, 0);
for (int i=0; i<newSize; i++)
{
TransferItemShadow * t = (TransferItemShadow *)listShadow->Get(i);
if (t->changed) PostMessage(hwnd,LVM_REDRAWITEMS,i,i);
}
}
unlock();
}
virtual songid_t GetTrack(int pos) { return 0; }
};
static void updateStatus()
{
int pcnum=0,num=0,time=0,total=0;
for (int i=0; i<devices.GetSize(); i++)
{
DeviceView* device = (DeviceView*)devices.Get(i);
LinkedQueue * txQueue = getTransferQueue(device);
LinkedQueue * finishedTX = getFinishedTransferQueue(device);
int txProgress = getTransferProgress(device);
int s = (txQueue ? txQueue->GetSize() : 0);
int n = (s * 100) - txProgress;
total += s * 100;
total += 100 * (finishedTX ? finishedTX->GetSize() : 0);
pcnum += n;
num += s;
int t = (int)(device->transferRate * (((double)n) / 100.0));
if (time < t) time = t;
}
if (total)
{
wchar_t caption[256] = {0};
int pc = ((total-pcnum)*100)/total;
wsprintf(caption,WASABI_API_LNGSTRINGW((time > 0 ? IDS_TRANFERS_PERCENT_REMAINING : IDS_TRANFERS_PERCENT_REMAINING_NOT_TIME)),num,pc,time/60,time%60);
SetDlgItemText(m_hwnd,IDC_STATUS,caption);
}
else SetDlgItemText(m_hwnd,IDC_STATUS,L"");
}
static TransferContents2 transferListContents;
void TransfersListUpdateItem(CopyInst * item)
{
transferListContents.ItemUpdate(item);
}
void TransfersListPushPopItem(CopyInst * item)
{
transferListContents.PushPopItem(item);
}
void UpdateDevicesListView(bool softUpdate)
{
if (listDevices) listDevices->UpdateList(softUpdate);
}
static bool AddSelectedItems(C_ItemList *items, W_ListView *listview, LinkedQueue *transfer_queue, int &row, DeviceView *&dev)
{
transfer_queue->lock();
int l = transfer_queue->GetSize();
for (int j=0; j<l; j++)
{
if (listview->GetSelected(row++))
{
CopyInst * c = (CopyInst *)transfer_queue->Get(j);
if (c->songid)
{
if (!dev && c->dev) dev = c->dev;
if (dev)
{
if (c->dev != dev)
{
transfer_queue->unlock();
return false;
}
else
items->Add((void*)c->songid);
}
}
}
}
transfer_queue->unlock();
return true;
}
static void RemoveSelectedItems(DeviceView *device, W_ListView *listview, LinkedQueue *transfer_queue, int &row, bool finished_queue)
{
transfer_queue->lock();
int j = transfer_queue->GetSize();
while (j-- > 0)
{
if (listview->GetSelected(--row))
{
if (j == 0 && !finished_queue)
{
CopyInst * d = (CopyInst *)transfer_queue->Get(j);
if (d && d->status == STATUS_WAITING && device->transferContext.IsPaused())
{
transfer_queue->Del(j);
d->Cancelled();
delete d;
} // otherwise don't bother
}
else
{
CopyInst * d = (CopyInst*)transfer_queue->Del(j);
if (d)
{
if (d->status == STATUS_WAITING && !finished_queue)
d->Cancelled();
delete d;
}
}
}
}
transfer_queue->unlock();
}
extern void handleContextMenuResult(int r, C_ItemList * items=NULL, DeviceView * dev=NULL);
extern int showContextMenu(int context,HWND hwndDlg, Device * dev, POINT pt);
extern int (*wad_getColor)(int idx);
INT_PTR CALLBACK pmp_devices_dlgproc(HWND hwndDlg, UINT uMsg, WPARAM wParam,LPARAM lParam)
{
if (wad_handleDialogMsgs)
{
BOOL a=wad_handleDialogMsgs(hwndDlg,uMsg,wParam,lParam); if (a) return a;
}
if (listDevices)
{
BOOL a=listDevices->DialogProc(hwndDlg,uMsg,wParam,lParam); if (a) return a;
}
if (listTransfers)
{
BOOL a=listTransfers->DialogProc(hwndDlg,uMsg,wParam,lParam); if (a) return a;
}
switch (uMsg)
{
case WM_INITDIALOG:
m_hwnd=hwndDlg;
*(void **)&wad_handleDialogMsgs=(void*)SendMessage(plugin.hwndLibraryParent,WM_ML_IPC,2,ML_IPC_SKIN_WADLG_GETFUNC);
*(void **)&wad_DrawChildWindowBorders=(void*)SendMessage(plugin.hwndLibraryParent,WM_ML_IPC,3,ML_IPC_SKIN_WADLG_GETFUNC);
*(void **)&cr_init=(void*)SendMessage(plugin.hwndLibraryParent,WM_ML_IPC,32,ML_IPC_SKIN_WADLG_GETFUNC);
*(void **)&cr_resize=(void*)SendMessage(plugin.hwndLibraryParent,WM_ML_IPC,33,ML_IPC_SKIN_WADLG_GETFUNC);
if (cr_init) cr_init(hwndDlg,resize_rlist,sizeof(resize_rlist)/sizeof(resize_rlist[0]));
listDevices = new SkinnedListView(&deviceListContents,IDC_LIST_DEVICES,plugin.hwndLibraryParent, hwndDlg);
listDevices->DialogProc(hwndDlg,uMsg,0,0);
transferListContents.lock();
listTransfers = new SkinnedListView(&transferListContents,IDC_LIST_TRANSFERS,plugin.hwndLibraryParent, hwndDlg);
listTransfers->DialogProc(hwndDlg,uMsg,0,0);
transferListContents.unlock();
adiv_oldWndProc=(WNDPROC)SetWindowLongPtr(GetDlgItem(hwndDlg,IDC_HDELIM),GWLP_WNDPROC,(LONG_PTR)adiv_newWndProc);
SetDlgItemText(hwndDlg,IDC_BUTTON_PAUSETRANSFERS,WASABI_API_LNGSTRINGW((TransferContext::IsAllPaused()?IDS_RESUME:IDS_PAUSE)));
SetTimer(hwndDlg,1,250,NULL);
updateStatus();
break;
case WM_TIMER:
if (wParam == 1)
{
updateStatus();
if (device_update_map[0])
{
device_update_map[0]=0;
transferListContents.FullUpdate();
}
}
break;
case WM_DISPLAYCHANGE:
break;
case WM_SETCURSOR: // set cursor when near the dividers
{
RECT r;
POINT p;
GetCursorPos(&p);
GetWindowRect(GetDlgItem(hwndDlg,IDC_HDELIM),&r);
r.top-=3;
r.bottom+=3;
if (PtInRect(&r,p))
{
SetCursor(LoadCursor(NULL,IDC_SIZENS));
return uMsg == WM_SETCURSOR;
}
break;
}
case WM_LBUTTONDOWN:
{
// forward dialog clicks to the dividers if they get near them
POINT p;
RECT r3;
GetWindowRect(GetDlgItem(hwndDlg,IDC_VDELIM),&r3);
GetCursorPos(&p);
GetWindowRect(GetDlgItem(hwndDlg,IDC_HDELIM),&r3);
if (p.x >= r3.left && p.x <= r3.right)
{
int d=p.y-r3.bottom;
int d2=p.y-r3.top;
if (d<0)d=-d;
if (d2<0)d2=-d2;
if (d < 6 || d2 < 6) SendDlgItemMessage(hwndDlg,IDC_HDELIM,uMsg,0,0);
}
}
break;
case WM_SIZE:
if (wParam != SIZE_MINIMIZED)
{
if (cr_resize) cr_resize(hwndDlg,resize_rlist,sizeof(resize_rlist)/sizeof(resize_rlist[0]));
}
break;
case WM_PAINT:
{
if (wad_DrawChildWindowBorders)
{
int tab[] = {m_nodrawtopborders==1?0:(IDC_LIST_DEVICES|DCW_SUNKENBORDER),
m_nodrawtopborders==2?0:(IDC_LIST_TRANSFERS|DCW_SUNKENBORDER),
IDC_HDELIM|DCW_DIVIDER
};
wad_DrawChildWindowBorders(hwndDlg,tab,3);
}
}
break;
case WM_DESTROY:
{
KillTimer(hwndDlg, 1);
m_hwnd=NULL;
SkinnedListView * ld = listDevices; listDevices=NULL; delete ld;
SkinnedListView * lt = listTransfers;
transferListContents.lock();
listTransfers=NULL;
transferListContents.unlock();
delete lt;
}
break;
case WM_NOTIFY:
{
LPNMHDR l=(LPNMHDR)lParam;
if (l->idFrom==IDC_LIST_TRANSFERS)
switch (l->code)
{
case NM_RETURN: // enter!
case NM_RCLICK: // right click!
case LVN_KEYDOWN:
{
DeviceView * dev = NULL;
C_ItemList items;
int row = 0;
for (int i=0; i<devices.GetSize(); i++)
{
DeviceView *device = (DeviceView*)devices.Get(i);
if (!AddSelectedItems(&items, &listTransfers->listview, getTransferQueue(device), row, dev))
return 0;
if (!AddSelectedItems(&items, &listTransfers->listview, getFinishedTransferQueue(device), row, dev))
return 0;
}
bool foundDev=false;
for (int k=0; k<devices.GetSize(); k++) if (dev == (DeviceView*)devices.Get(k)) foundDev=true;
if (dev && foundDev && items.GetSize())
{
if (l->code == NM_RCLICK)
{
LPNMITEMACTIVATE lva=(LPNMITEMACTIVATE)lParam;
handleContextMenuResult(showContextMenu(7,l->hwndFrom,dev->dev,lva->ptAction),&items,dev);
}
else if (l->code == NM_RETURN)
{
handleContextMenuResult((!GetAsyncKeyState(VK_SHIFT)?ID_TRACKSLIST_PLAYSELECTION:ID_TRACKSLIST_ENQUEUESELECTION),&items,dev);
}
else if (l->code == LVN_KEYDOWN)
{
switch (((LPNMLVKEYDOWN)lParam)->wVKey)
{
case VK_DELETE:
{
if (!(GetAsyncKeyState(VK_CONTROL)&0x8000) && !(GetAsyncKeyState(VK_SHIFT)&0x8000))
{
handleContextMenuResult(ID_TRACKSLIST_DELETE,&items,dev);
}
}
break;
case 0x45: //E
if ((GetAsyncKeyState(VK_CONTROL)&0x8000) && !(GetAsyncKeyState(VK_SHIFT)&0x8000))
{
handleContextMenuResult(ID_TRACKSLIST_EDITSELECTEDITEMS,&items,dev);
}
break;
}
}
}
break;
}
}
}
break;
case WM_COMMAND:
switch (LOWORD(wParam))
{
case IDC_BUTTON_CLEARFINISHED:
{
for (int i=0; i<devices.GetSize(); i++)
{
DeviceView *device = (DeviceView*)devices.Get(i);
LinkedQueue * finishedTX = getFinishedTransferQueue(device);
if (finishedTX)
{
finishedTX->lock();
int j=finishedTX->GetSize();
while (j-- > 0) delete(CopyInst*)finishedTX->Del(j);
finishedTX->unlock();
}
}
transferListContents.FullUpdate();
}
break;
case IDC_BUTTON_REMOVESELECTED:
{
int row = transferListContents.GetNumRows();
int i = devices.GetSize();
while (i-- > 0)
{
DeviceView *device = (DeviceView *)devices.Get(i);
RemoveSelectedItems(device, &listTransfers->listview, getTransferQueue(device), row, false);
RemoveSelectedItems(device, &listTransfers->listview, getFinishedTransferQueue(device), row, true);
}
transferListContents.FullUpdate();
}
break;
case IDC_BUTTON_PAUSETRANSFERS:
if (false != TransferContext::IsAllPaused())
TransferContext::ResumeAll();
else
TransferContext::PauseAll();
for (int i=0;i<devices.GetSize();i++)
{
DeviceView *device_view = (DeviceView*)devices.Get(i);
SetEvent(device_view->transferContext.notifier);
}
SetDlgItemText(hwndDlg,IDC_BUTTON_PAUSETRANSFERS,WASABI_API_LNGSTRINGW((TransferContext::IsAllPaused()?IDS_RESUME:IDS_PAUSE)));
break;
}
break;
case WM_MOUSEMOVE:
if (wParam==MK_LBUTTON)
{
if (GetCapture() == hwndDlg) ReleaseCapture();
}
break;
}
return 0;
}
// deals with the horizontal (IDC_HDELIM) divider
static void adiv_UpdPos(int yp)
{
RECT r,old_divider_rect;
GetClientRect(m_hwnd,&r);
GetWindowRect(GetDlgItem(m_hwnd,IDC_HDELIM),&old_divider_rect);
ScreenToClient(m_hwnd,(LPPOINT)&old_divider_rect);
ScreenToClient(m_hwnd,((LPPOINT)&old_divider_rect)+1);
if (yp < 50)
{
m_nodrawtopborders=1;
yp=20;
}
else m_nodrawtopborders=0;
if (yp > r.bottom-42-30)
{
yp=r.bottom-42;
m_nodrawtopborders=2;
}
int x;
for (x = 0; x < 4; x ++)
{
RECT myoldr;
GetWindowRect(GetDlgItem(m_hwnd,resize_rlist[x].id),&myoldr);
ScreenToClient(m_hwnd,(LPPOINT)&myoldr);
ScreenToClient(m_hwnd,((LPPOINT)&myoldr)+1);
switch (x)
{
case 0:
resize_rlist[x].rinfo.bottom=yp - old_divider_rect.top + myoldr.bottom;
break;
case 1:
resize_rlist[x].rinfo.top=yp - old_divider_rect.top + myoldr.top;
break;
case 2:
case 3:
{
int h=resize_rlist[x].rinfo.bottom - resize_rlist[x].rinfo.top;
resize_rlist[x].rinfo.top = yp - old_divider_rect.top + resize_rlist[x].rinfo.top;
resize_rlist[x].rinfo.bottom = resize_rlist[x].rinfo.top + h;
}
break;
}
}
cr_resize(m_hwnd,resize_rlist,4);
}
static INT_PTR CALLBACK adiv_newWndProc(HWND hwndDlg, UINT uMsg, WPARAM wParam,LPARAM lParam)
{
if (uMsg == WM_LBUTTONDOWN)
{
SetForegroundWindow(hwndDlg);
SetCapture(hwndDlg);
SetCursor(LoadCursor(NULL,IDC_SIZENS));
POINT p;
GetCursorPos(&p);
ScreenToClient(hwndDlg,&p);
adiv_clickoffs=p.y;
}
else if (uMsg == WM_SETCURSOR)
{
SetCursor(LoadCursor(NULL,IDC_SIZENS));
return TRUE;
}
else if (uMsg == WM_MOUSEMOVE && GetCapture()==hwndDlg)
{
POINT p;
GetCursorPos(&p);
ScreenToClient(GetParent(hwndDlg),&p);
adiv_UpdPos(p.y-adiv_clickoffs);
RECT r;
GetClientRect(GetParent(hwndDlg),&r);
if (r.bottom > r.top)
{
int percent = ((p.y-adiv_clickoffs) * 100000) / (r.bottom-r.top);
adivpos = percent;
}
}
else if (uMsg == WM_MOUSEMOVE)
{
SetCursor(LoadCursor(NULL,IDC_SIZENS));
}
else if (uMsg == WM_LBUTTONUP)
{
ReleaseCapture();
}
return CallWindowProc(adiv_oldWndProc,hwndDlg,uMsg,wParam,lParam);
}
|