aboutsummaryrefslogtreecommitdiff
path: root/Src/Plugins/Library/ml_devices/listWidgetInternal.h
blob: 8c53a7297788e7ffa9e089a06cbc92665c554aeb (plain) (blame)
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
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
#ifndef _NULLSOFT_WINAMP_ML_DEVICES_LIST_WIDGET_INTERNAL_HEADER
#define _NULLSOFT_WINAMP_ML_DEVICES_LIST_WIDGET_INTERNAL_HEADER

#if defined(_MSC_VER) && (_MSC_VER >= 1020)
#pragma once
#endif

#include <wtypes.h>
#include <vector>
#include "./imageCache.h"

typedef enum ListWidgetItemState
{
	ListWidgetItemState_Default = (0),
	ListWidgetItemState_Hovered = (1 << 0),
	ListWidgetItemState_Selected = (1 << 1),
	ListWidgetItemState_Interactive = (1 << 2),
	ListWidgetItemState_TextTruncated = (1 << 3),
	ListWidgetItemState_TextEdited = (1 << 4),

} ListWidgetItemSate;
DEFINE_ENUM_FLAG_OPERATORS(ListWidgetItemSate);

#define ListWidgetItem_State(_item)					(((ListWidgetItem*)(_item))->state)
#define ListWidgetItem_SetState(_item, _state)		(ListWidgetItem_State(_item) |= (_state)) 
#define ListWidgetItem_UnsetState(_item, _state)	(ListWidgetItem_State(_item) &= ~(_state))

#define ListWidgetItem_IsHovered(_item)			(0 != (ListWidgetItemState_Hovered & ListWidgetItem_State(_item)))
#define ListWidgetItem_SetHovered(_item)		ListWidgetItem_SetState(_item, ListWidgetItemState_Hovered)
#define ListWidgetItem_UnsetHovered(_item)		ListWidgetItem_UnsetState(_item, ListWidgetItemState_Hovered)

#define ListWidgetItem_IsSelected(_item)		(0 != (ListWidgetItemState_Selected & ListWidgetItem_State(_item)))
#define ListWidgetItem_SetSelected(_item)		ListWidgetItem_SetState(_item, ListWidgetItemState_Selected)
#define ListWidgetItem_UnsetSelected(_item)		ListWidgetItem_UnsetState(_item, ListWidgetItemState_Selected)

#define ListWidgetItem_IsInteractive(_item)		(0 != (ListWidgetItemState_Interactive & ListWidgetItem_State(_item)))
#define ListWidgetItem_SetInteractive(_item)	ListWidgetItem_SetState(_item, ListWidgetItemState_Interactive)
#define ListWidgetItem_UnsetInteractive(_item)	ListWidgetItem_UnsetState(_item, ListWidgetItemState_Interactive)


#define ListWidgetItem_IsTextTruncated(_item)		(0 != (ListWidgetItemState_TextTruncated & ListWidgetItem_State(_item)))
#define ListWidgetItem_SetTextTruncated(_item)		ListWidgetItem_SetState(_item, ListWidgetItemState_TextTruncated)
#define ListWidgetItem_UnsetTextTruncated(_item)	ListWidgetItem_UnsetState(_item, ListWidgetItemState_TextTruncated)

#define ListWidgetItem_IsTextEdited(_item)		(0 != (ListWidgetItemState_TextEdited & ListWidgetItem_State(_item)))
#define ListWidgetItem_SetTextEdited(_item)		ListWidgetItem_SetState(_item, ListWidgetItemState_TextEdited)
#define ListWidgetItem_UnsetTextEdited(_item)	ListWidgetItem_UnsetState(_item, ListWidgetItemState_TextEdited)


typedef struct ListWidgetConnection ListWidgetConnection;
typedef std::vector<ListWidgetConnection*> ListWidgetConnectionList;

typedef struct ListWidgetTooltip ListWidgetTooltip;

typedef enum ListWidgetCommandState
{	
	ListWidgetCommandState_Normal = (0),
	ListWidgetCommandState_Disabled = (1 << 0),
	ListWidgetCommandState_Primary = (1 << 1),
	ListWidgetCommandState_Pressed = (1 << 2),
} ListWidgetCommandState;
DEFINE_ENUM_FLAG_OPERATORS(ListWidgetCommandState);

typedef struct ListWidgetCommand ListWidgetCommand;

typedef struct ListWidgetActivity 
{
	unsigned int step;
	unsigned int percent;
	wchar_t *title;
	SIZE titleSize;
	BOOL cancelable;
}
ListWidgetActivity;

typedef struct ListWidgetActivityMetric
{
	long height;
	long width;
	long progressWidth;
	long progressHeight;
	long percentWidth;
	long percentHeight;
	long titleWidth;
	long titleHeight;
	long fontHeight;
	long offsetLeft;
	long offsetRight;
	long offsetTop;
	long offsetBottom;
	long spacing;
} ListWidgetActivityMetric;

typedef enum ListWidgetActivityChange
{
	ListWidgetActivityChanged_Nothing = 0,
	ListWidgetActivityChanged_Percent = (1 << 0),
	ListWidgetActivityChanged_Title = (1 << 1),
	ListWidgetActivityChanged_Cancelable = (1 << 2),
	ListWidgetActivityChanged_All = (ListWidgetActivityChanged_Percent | ListWidgetActivityChanged_Title | ListWidgetActivityChanged_Cancelable ),
}
ListWidtetActivityChange;
DEFINE_ENUM_FLAG_OPERATORS(ListWidtetActivityChange);


typedef enum ListWidgetItemPart
{
	ListWidgetItemPart_None = 0,
	ListWidgetItemPart_Frame = (1 << 0),
	ListWidgetItemPart_Image = (1 << 1),
	ListWidgetItemPart_Title = (1 << 2),
	ListWidgetItemPart_Activity = (1 << 3),
	ListWidgetItemPart_Command = (1 << 4),
	ListWidgetItemPart_Spacebar = (1 << 5),
	ListWidgetItemPart_Connection = (1 << 6),
}ListWidgetItemPart;
DEFINE_ENUM_FLAG_OPERATORS(ListWidgetItemPart);

typedef struct ListWidgetItem
{
	char *name;
	wchar_t *title;
	RECT rect;
	SIZE titleSize;
	DeviceImage *image;
	uint64_t spaceTotal;
	uint64_t spaceUsed;
	ListWidgetItemState state;
	ListWidgetConnection *connection;
	ListWidgetActivity *activity;
}ListWidgetItem;
typedef std::vector<ListWidgetItem*> ListWidgetItemList;

typedef struct ListWidgetGroup
{
	char *name;
	wchar_t *title;
	ListWidgetItemList items;
} ListWidgetGroup;
typedef std::vector<ListWidgetGroup*> ListWidgetGroupList;

typedef struct ListWidgetCategory
{
	char *name;
	wchar_t *title;
	BOOL collapsed;
	ListWidgetGroupList groups;
	RECT rect;
	long titleWidth;
	long countWidth;
	wchar_t *countString;
	wchar_t *emptyText;
	RECT	emptyTextRect;
}ListWidgetCategory;

typedef std::vector<ListWidgetCategory*> ListWidgetCategoryList;

typedef enum ListWidgetFlags
{
	ListWidgetFlag_NoFocusSelect = (1 << 0),
	ListWidgetFlag_LButtonDownOnCommand = (1 << 1),
} ListWidgetFlags;
DEFINE_ENUM_FLAG_OPERATORS(ListWidgetFlags);

typedef struct ListWidget
{
	ListWidgetFlags flags;
	ListWidgetCategoryList categories;
	ListWidgetConnectionList connections;
	BackBuffer backBuffer;
	ListWidgetItem *hoveredItem;
	ListWidgetItem *selectedItem;
	ListWidgetItem *titleEditItem;
	ListWidgetCategory *pressedCategory;
	SIZE imageSize;
	long itemWidth;
	size_t itemsPerLine;
	size_t deviceHandler;
	ListWidgetCommand **commands;
	size_t commandsCount;
	size_t commandsMax;
	ListWidgetItemList activeItems;
	POINT previousMouse;
	
	HBITMAP spacebarBitmap;
	HBITMAP arrowsBitmap;
	
	HBITMAP hoverBitmap;
	HBITMAP selectBitmap;
	HBITMAP inactiveSelectBitmap;
	
	HBITMAP largeBadgeBitmap;
	HBITMAP smallBadgeBitmap;
	
	SIZE connectionSize;
	SIZE primaryCommandSize;
	SIZE secondaryCommandSize;
	DeviceImage *unknownCommandLargeImage;
	DeviceImage *unknownCommandSmallImage;
	
	ListWidgetActivityMetric activityMetrics;
	HFONT activityFont;
	HBITMAP activityBadgeBitmap;
	DeviceImage *activityProgressImage;
	BOOL activityTimerEnabled;
	
	HMENU  activeMenu;
	ListWidgetTooltip *tooltip;

	unsigned int selectionStatus;
	HWND titleEditor;

} ListWidget;

typedef struct 
ListWidgetItemMetric
{
	long titleMinWidth;
	long offsetLeft;
	long offsetTop;
	long offsetRight;
	long offsetBottom;
	long imageOffsetLeft;
	long imageOffsetTop;
	long imageOffsetRight;
	long imageOffsetBottom;
	long titleOffsetTop;
	long spacebarOffsetTop;
	long spacebarHeight;
} ListWidgetItemMetric;

typedef struct 
ListWidgetCategoryMetric
{
	long offsetLeft;
	long offsetTop;
	long offsetRight;
	long offsetBottom;
	long lineHeight;
	long lineOffsetTop;
	long titleOffsetLeft;
	long minHeight;
	long iconWidth;
	long iconHeight;
} ListWidgetCategoryMetric;

HBITMAP
ListWidget_GetSpacebarBitmap(ListWidget *self, 
							 WidgetStyle *style,
							 HWND hwnd,
							 long width, 
							 long height);

HBITMAP
ListWidget_GetHoverBitmap(ListWidget *self, 
							 WidgetStyle *style, 
							 HWND hwnd,
							 long width, 
							 long height);

HBITMAP
ListWidget_GetSelectBitmap(ListWidget *self, 
							 WidgetStyle *style, 
							 HWND hwnd,
							 long width, 
							 long height);

HBITMAP
ListWidget_GetInactiveSelectBitmap(ListWidget *self, 
								   WidgetStyle *style, 
								   HWND hwnd,
								   long width, 
								   long height);

HBITMAP
ListWidget_GetLargeBadgeBitmap(ListWidget *self, 
							   WidgetStyle *style, 
							   HWND hwnd,
							   long width, 
							   long height);


HBITMAP
ListWidget_GetSmallBadgeBitmap(ListWidget *self, 
					  		   WidgetStyle *style, 
							   HWND hwnd,
							   long width, 
							   long height);

HBITMAP
ListWidget_GetUnknownCommandSmallBitmap(ListWidget *self, 
					  					WidgetStyle *style, 
										long width, 
										long height);

HBITMAP
ListWidget_GetUnknownCommandLargeBitmap(ListWidget *self, 
					  					WidgetStyle *style, 
										long width, 
										long height);

HBITMAP
ListWidget_GetArrowsBitmap(ListWidget *self, 
						   WidgetStyle *style, 
						   HWND hwnd);

HBITMAP
ListWidget_GetActivityProgressBitmap(ListWidget *self, 
							 WidgetStyle *style);


HBITMAP
ListWidget_GetActivityBadgeBitmap(ListWidget *self,
								  WidgetStyle *style, 
								  HWND hwnd,
								  long width, 
								  long height);

BOOL
ListWidget_GetViewOrigin(HWND hwnd, 
						 POINT *pt);

BOOL
ListWidget_UpdateHoverEx(ListWidget *self, 
						 HWND hwnd, 
						 const POINT *cursor);

BOOL
ListWidget_UpdateHover(ListWidget *self, 
					   HWND hwnd);

BOOL
ListWidget_RemoveHover(ListWidget *self,
					   HWND hwnd,
					   BOOL invalidate);

BOOL
ListWidget_SelectItem(ListWidget *self, 
					  HWND hwnd, 
					  ListWidgetItem *item, 
					  BOOL ensureVisible);

BOOL
ListWidget_SetImageSize(ListWidget *self, 
						HWND hwnd, 
						int imageWidth, 
						int imageHeight, 
						BOOL redraw);

typedef enum ListWidgetLayoutFlags
{
	ListWidgetLayout_Normal = 0,
	ListWidgetLayout_NoRedraw = (1 << 0),
	ListWidgetLayout_UpdateNow = (1 << 1),
	ListWidgetLayout_KeepStable = (1 << 2),
}ListWidgetLayoutFlags;
DEFINE_ENUM_FLAG_OPERATORS(ListWidgetLayoutFlags);

BOOL
ListWidget_UpdateLayout(HWND hwnd, 
						ListWidgetLayoutFlags flags);

BOOL
ListWidget_DisplayContextMenu(ListWidget *self,
							  HWND hostWindow,
							  POINT pt);

BOOL
ListWidget_RegisterActiveItem(ListWidget *self,
							  HWND hwnd, 
							  ListWidgetItem *item);

BOOL
ListWidget_UnregisterActiveItem(ListWidget *self,
								HWND hwnd,
								ListWidgetItem *item);

double 
ListWidget_GetZoomRatio(ListWidget *self);

void
ListWidget_UpdateSelectionStatus(ListWidget *self,
								 HWND hwnd, 
								 BOOL ensureVisible);

void
ListWidget_UpdateSelectionSpaceStatus(ListWidget *self, 
									  HWND hwnd, 
									  BOOL ensureVisible);

void 
ListWidget_UpdateTitleEditorColors(HWND editor,
								   WidgetStyle *style);
/*
<<<<<<<<<<<<<<<<<<<<<<<<< Category >>>>>>>>>>>>>>>>>>>>>>>>>
*/

ListWidgetCategory *
ListWidget_CreateCategory(const char *name, 
						  const wchar_t *title, 
						  BOOL collapsed);

void 
ListWidget_DestroyCategory(ListWidgetCategory *category);

ListWidgetCategory *
ListWidget_GetCategoryFromPoint(ListWidget *self, 
								POINT point);

ListWidgetCategory *
ListWidget_FindCategory(ListWidget *self, 
						const char *name);

BOOL
ListWidget_GetCategoryMetrics(WidgetStyle *style,
							  ListWidgetCategoryMetric *metrics);

BOOL 
ListWidget_ToggleCategory(ListWidgetCategory *category, 
						  HWND hwnd);

void
ListWidget_ResetCategoryCounter(ListWidgetCategory *category);

void 
ListWidget_SortCategory(ListWidgetCategory *category);

BOOL
ListWidget_SetCategoryEmptyText(ListWidgetCategory *category, const wchar_t *text);

/*
<<<<<<<<<<<<<<<<<<<<<<<<< Group >>>>>>>>>>>>>>>>>>>>>>>>>
*/

ListWidgetGroup *
ListWidget_CreateGroup(const char *name);

ListWidgetGroup *
ListWidget_CreateGroupEx(const char *name, 
						 const wchar_t *title);

void 
ListWidget_DestroyGroup(ListWidgetGroup *group);

BOOL
ListWidget_AddGroup(ListWidgetCategory *category,
					ListWidgetGroup *group);
					

ListWidgetGroup *
ListWidget_FindGroup(ListWidgetCategory *category, 
					 const char *name);

ListWidgetGroup *
ListWidget_FindGroupEx(ListWidgetCategory *category, 
					 const char *name, 
					 size_t max);

void 
ListWidget_SortGroup(ListWidgetGroup *group);

/*
<<<<<<<<<<<<<<<<<<<<<<<<< Item >>>>>>>>>>>>>>>>>>>>>>>>>
*/

typedef enum ListWidgetVisibleFlags
{
	VISIBLE_NORMAL	= 0,
	VISIBLE_PARTIAL_OK	= (1 << 0),
	VISIBLE_ALIGN_BOTTOM =(1 << 1),
	VISIBLE_ALIGN_TOP = (1 << 2),
	VISIBLE_ALIGN_ALWAYS = (1 << 3),
} ListWidgetVisibleFlags;
DEFINE_ENUM_FLAG_OPERATORS(ListWidgetVisibleFlags);

ListWidgetItem*
ListWidget_CreateItemFromDevice(ListWidget *self, 
								ifc_device* device);

void 
ListWidget_DestroyItem(ListWidgetItem *item);

BOOL
ListWidget_CalculateItemBaseSize(ListWidget *self,
								 WidgetStyle *style, 
								 SIZE *baseSize, 
								 long *itemTextWidth);

size_t		// number of removed items 
ListWidget_RemoveItem(ListWidget *self, 
					  HWND hwnd, 
					  const char *name);

ListWidgetItem *
ListWidget_GetFirstItem(ListWidget *self);

ListWidgetItem *
ListWidget_GetLastItem(ListWidget *self);

ListWidgetItem *
ListWidget_GetNextItem(ListWidget *self, 
					   ListWidgetItem *baseItem);

ListWidgetItem *
ListWidget_GetPreviousItem(ListWidget *self, 
						   ListWidgetItem *baseItem);

ListWidgetItem *
ListWidget_GetNextCategoryItem(ListWidget *self,
							   ListWidgetCategory *category,
							   ListWidgetItem *baseItem);

ListWidgetItem *
ListWidget_GetPreviousCategoryItem(ListWidget *self,
								   ListWidgetCategory *category,
								   ListWidgetItem *baseItem);

ListWidgetItem *
ListWidget_GetNextGroupItem(ListWidget *self,
							ListWidgetGroup *group,
							ListWidgetItem *baseItem);

ListWidgetItem *
ListWidget_GetPreviousGroupItem(ListWidget *self,
								ListWidgetGroup *group,
								ListWidgetItem *baseItem);

ListWidgetItem *
ListWidget_GetNextLineItem(ListWidget *self, 
						   ListWidgetItem *baseItem);

ListWidgetItem *
ListWidget_GetPreviousLineItem(ListWidget *self, 
							   ListWidgetItem *baseItem);

ListWidgetItem *
ListWidget_GetNextPageItem(ListWidget *self, 
						   HWND hwnd, 
						   ListWidgetItem *baseItem);

ListWidgetItem *
ListWidget_GetPreviousPageItem(ListWidget *self, 
						   HWND hwnd, 
						   ListWidgetItem *baseItem);

BOOL
ListWidget_EnsureItemVisisble(ListWidget *self, 
							  HWND hwnd, 
							  ListWidgetItem *item, 
							  ListWidgetVisibleFlags flags);

HBITMAP
ListWidget_GetItemImage(ListWidget *self,
						WidgetStyle *style,
						ListWidgetItem *item);

BOOL
ListWidget_GetItemMetrics(WidgetStyle *style,
						  ListWidgetItemMetric *metrics);

ListWidgetItem *
ListWidget_GetItemFromPointEx(ListWidget *self, 
							POINT point, 
							ListWidgetCategory **categoryOut,  // optional
							ListWidgetGroup **groupOut); // optional

ListWidgetItem *
ListWidget_GetItemFromPoint(ListWidget *self, 
							POINT point);



BOOL
ListWidget_AddItem(ListWidgetGroup *group,
				   ListWidgetItem *item);

ListWidgetItem *
ListWidget_FindGroupItem(ListWidgetGroup *group,
					const char *name);

ListWidgetItem *
ListWidget_FindGroupItemEx(ListWidgetGroup *group,
					const char *name, 
					size_t max);

ListWidgetGroup *
ListWidget_GetItemOwner(ListWidget *self, 
						ListWidgetItem *baseItem, 
						ListWidgetCategory **categoryOut);


ListWidgetItem *
ListWidget_FindItem(ListWidget *self,
					const char *name,
					ListWidgetCategory **categoryOut,
					ListWidgetGroup **groupOut);

BOOL
ListWidget_FindItemPos(ListWidget *self,
					   ListWidgetItem *item,
					   size_t *categoryOut,
					   size_t *groupOut, 
					   size_t *itemOut);


BOOL
ListWidget_SetItemTitle(ListWidgetItem *item, 
						const wchar_t *title);

BOOL
ListWidget_DisplayItemContextMenu(ListWidget *self,
								  HWND hostWindow,
								  ListWidgetItem *item, 
								  POINT pt);

size_t
ListWidget_GetItemCommands(ListWidgetItem *item, 
						   ListWidgetCommand **buffer, 
						   size_t bufferMax);

BOOL
ListWidget_SendItemCommand(const char *name, 
						   const char *command, 
						   HWND hostWindow, 
						   ULONG_PTR param,
						   BOOL enableIntercept);

BOOL
ListWidget_CreateItemActivity(ListWidgetItem *item);

BOOL
ListWidget_DeleteItemActivity(ListWidgetItem *item);



ListWidtetActivityChange
ListWidget_UpdateItemActivity(ListWidgetItem *item, 
							  ifc_deviceactivity *activity);

BOOL
ListWidget_InvalidateItemImage(ListWidget *self, 
							   HWND hwnd, 
							   ListWidgetItem *item);

BOOL
ListWidget_InvalidateItemActivity(ListWidget *self,
								  HWND hwnd, 
								  ListWidgetItem *item,
								  ListWidgetActivityChange changes);


BOOL
ListWidget_GetItemFrameRect(ListWidget *self, 
							ListWidgetItem *item, 
							ListWidgetItemMetric *metrics, 
							RECT *rect);

BOOL
ListWidget_GetItemImageRect(ListWidget *self,
							ListWidgetItem *item,
							ListWidgetItemMetric *metrics,
							RECT *rect);

BOOL
ListWidget_GetItemActivityRect(ListWidget *self,
							   ListWidgetItem *item, 
							   ListWidgetItemMetric *metrics, 
							   RECT *rect);

BOOL
ListWidget_GetItemActivityProgressRect(ListWidget *self,
									   HDC hdc,
									   ListWidgetItem *item, 
									   ListWidgetItemMetric *metrics, 
									   RECT *rect);

BOOL
ListWidget_GetItemActivityPercentRect(ListWidget *self,
									  HDC hdc,
									  ListWidgetItem *item,
									  ListWidgetItemMetric *metrics,
									  RECT *rect);

BOOL
ListWidget_GetItemActivityTitleRect(ListWidget *self, 
									HDC hdc,
									ListWidgetItem *item, 
									ListWidgetItemMetric *metrics,
									RECT *rect);

BOOL
ListWidget_GetItemSpacebarRect(ListWidget *self,
							   ListWidgetItem *item,
							   ListWidgetItemMetric *metrics,
							   RECT *rect);

BOOL
ListWidget_GetItemTitleRect(ListWidget *self,
							   ListWidgetItem *item,
							   ListWidgetItemMetric *metrics,
							   BOOL exactSize,
							   RECT *rect);

BOOL
ListWidget_GetItemConnectionRect(ListWidget *self,
							   ListWidgetItem *item,
							   ListWidgetItemMetric *metrics,
							   RECT *rect);

ListWidgetItemPart
ListWidget_GetItemPartFromPoint(ListWidget *self,
								ListWidgetItem *item,
								ListWidgetItemMetric *metrics, 
								POINT pt, 
								ListWidgetItemPart mask, 
								RECT *partRect);

BOOL
ListWidget_FormatItemTip(ListWidget *self,
						 ListWidgetItem *item,
						 wchar_t *buffer, 
						 size_t bufferMax);

BOOL
ListWidget_FormatItemTitleTip(ListWidget *self,
							  ListWidgetItem *item,
							  wchar_t *buffer,
							  size_t bufferMax);

BOOL
ListWidget_FormatItemCommandTip(ListWidget *self, 
								ListWidgetItem *item, 
								const RECT *commandRect, 
								wchar_t *buffer, 
								size_t bufferMax);

BOOL
ListWidget_FormatItemSpaceTip(ListWidget *self, 
							  ListWidgetItem *item, 
							  wchar_t *buffer, 
							  size_t bufferMax);

BOOL
ListWidget_FormatItemStatus(ListWidget *self,
							ListWidgetItem *item,
							wchar_t *buffer,
							size_t bufferMax);

BOOL
ListWidget_FormatItemSpaceStatus(ListWidget *self,
								 ListWidgetItem *item, 
								 wchar_t *buffer, 
								 size_t bufferMax);
HWND
ListWidget_BeginItemTitleEdit(ListWidget *self, 
							  HWND hwnd, 
							  ListWidgetItem *item);

int
ListWidget_CompareItemPos(ListWidget *self, 
						  ListWidgetItem *item1,
						  ListWidgetItem *item2);

BOOL
ListWidget_GetViewItemPos(HWND hwnd, 
						  ListWidgetItem *item, 
						  POINT *pt);

/*
<<<<<<<<<<<<<<<<<<<<<<<<< Connection >>>>>>>>>>>>>>>>>>>>>>>>>
*/

ListWidgetConnection *
ListWidget_CreateConnection(const char *name);

void 
ListWidget_DestroyConnection(ListWidgetConnection *connection);


HBITMAP
ListWidget_GetConnectionImage(WidgetStyle *style, 
							  ListWidgetConnection *connection, 
							  int width, 
							  int height);

BOOL
ListWidget_ConnectionResetColors(WidgetStyle *style, 
								 ListWidgetConnection *connection);

void
ListWidget_ResetConnnectionsColors(ListWidget *self, 
								   WidgetStyle *style);

ListWidgetConnection *
ListWidget_FindConnection(ListWidget *self, 
						  const char *name);

BOOL
ListWidget_AddConnection(ListWidget *self, 
						 ListWidgetConnection *connection);

void
ListWidget_RemoveConnection(ListWidget *self, 
							const char *name);

void
ListWidget_RemoveAllConnections(ListWidget *self);


BOOL
ListWidget_UpdateConnectionImageSize(ListWidgetConnection *connection,
									 int width,
									 int height);

/*
<<<<<<<<<<<<<<<<<<<<<<<<< Command >>>>>>>>>>>>>>>>>>>>>>>>>
*/

ListWidgetCommand *
ListWidget_CreateCommand(const char *name, 
						 BOOL primary,
						 BOOL disabled);

void
ListWidget_DestroyCommand(ListWidgetCommand *command);

size_t 
ListWigdet_GetDeviceCommands(ListWidgetCommand **buffer, 
							 size_t bufferMax, 
							 ifc_device *device);

void
ListWidget_DestroyAllCommands(ListWidgetCommand** buffer,
							  size_t bufferMax);

const wchar_t *
ListWidget_GetCommandTitle(ListWidgetCommand *command);

const wchar_t *
ListWidget_GetCommandDescription(ListWidgetCommand *command);

HBITMAP
ListWidget_GetCommandLargeBitmap(WidgetStyle *style, 
								 ListWidgetCommand *command, 
								 int width,
								 int height);

HBITMAP
ListWidget_GetCommandSmallBitmap(WidgetStyle *style, 
								 ListWidgetCommand *command, 
								 int width,
								 int height);

BOOL
ListWidget_ResetCommandImages(ListWidgetCommand *command);

BOOL
ListWidget_GetCommandRect(ListWidgetCommand *command, 
						  RECT *rect);

BOOL
ListWidget_SetCommandRect(ListWidgetCommand *command, 
						  const RECT *rect);

BOOL
ListWidget_GetCommandRectEqual(ListWidgetCommand *command, 
							   const RECT *rect);

BOOL
ListWidget_GetCommandPrimary(ListWidgetCommand *command);

BOOL
ListWidget_GetCommandDisabled(ListWidgetCommand *command);


BOOL
ListWidget_EnableCommand(ListWidgetCommand *command,
						 BOOL enable);

BOOL
ListWidget_GetCommandPressed(ListWidgetCommand *command);


BOOL
ListWidget_SetCommandPressed(ListWidgetCommand *command,
							 BOOL pressed);

const char *
ListWidget_GetCommandName(ListWidgetCommand *command);

/*
<<<<<<<<<<<<<<<<<<<<<<<<< Paint >>>>>>>>>>>>>>>>>>>>>>>>>
*/

typedef struct ListWidgetPaintSpacebar
{
	HBITMAP bitmap;
	long width;
	long height;
	long emptyBarOffset;
	long filledBarOffset;
} ListWidgetPaintSpacebar;

typedef struct ListWidgetPaintArrow
{
	HBITMAP bitmap;
	long width;
	long height;
	long collapsedOffset;
	long expandedOffset;
} ListWidgetPaintArrow;


typedef struct ListWidgetPaint
{
	ListWidget *widget;
	WidgetStyle *style;
	HWND hwnd;
	HDC hdc;
	BOOL erase;
	const RECT *paintRect;
	HDC sourceDC;
	ListWidgetPaintSpacebar spacebar;
	ListWidgetItemMetric itemMetrics;
	ListWidgetCategoryMetric categoryMetrics;
	ListWidgetPaintArrow arrow;
	RECT partRect;
	BOOL focused;
} ListWidgetPaint;

BOOL
ListWidgetPaint_Initialize(ListWidgetPaint *self, 
						   ListWidget *widget, 
						   WidgetStyle *style,
						   HWND hwnd,
						   HDC hdc,
						   const RECT *paintRect, 
						   BOOL erase);

void
ListWidgetPaint_Uninitialize(ListWidgetPaint *self);

BOOL
ListWidgetPaint_DrawItem(ListWidgetPaint *self, 
						 ListWidgetItem *item);

BOOL
ListWidgetPaint_DrawCategory(ListWidgetPaint *self, 
							 ListWidgetCategory *category);

BOOL
ListWidgetPaint_DrawEmptyCategoryText(ListWidgetPaint *self, 
									  ListWidgetCategory *category);


/*
<<<<<<<<<<<<<<<<<<<<<<<<< Tooltip >>>>>>>>>>>>>>>>>>>>>>>>>
*/

ListWidgetTooltip*
ListWidget_TooltipCreate(HWND hwnd);

void
ListWidget_TooltipDestroy(ListWidgetTooltip *tooltip);

void
ListWidget_TooltipFontChanged(ListWidgetTooltip *tooltip);

BOOL
ListWidget_TooltipActivate(ListWidgetTooltip *tooltip, 
						   const RECT *rect);

BOOL
ListWidget_TooltipUpdate(ListWidgetTooltip *tooltip, 
						 ListWidgetItem *item, 
						 ListWidgetItemPart part, 
						 const RECT *partRect);

void
ListWidget_TooltipHide(ListWidgetTooltip *tooltip);

void
ListWidget_TooltipRelayMouseMessage(ListWidgetTooltip *tooltip, 
									unsigned int message, 
									unsigned int vKeys,
									const POINT *cursor);
BOOL
ListWidget_TooltipProcessNotification(ListWidget *self, 
									  ListWidgetTooltip *tooltip, 
									  NMHDR *pnmh,
									  LRESULT *result);

ListWidgetItem *
ListWidget_TooltipGetCurrent(ListWidgetTooltip *tooltip, 
							 ListWidgetItemPart *part, 
							 RECT *partRect);

BOOL
ListWidget_TooltipGetChanged(ListWidgetTooltip *tooltip,
							 ListWidgetItem *item,
							 ListWidgetItemPart part,
							 const RECT *partRect);

typedef enum TooltipUpdateReason
{
	Tooltip_DeviceTitleChanged = 1,
	Tooltip_DeviceSpaceChanged = 2,
	Tooltip_DeviceActivityChanged = 3,
	Tooltip_DeviceModelChanged = 4,
	Tooltip_DeviceStatusChanged = 5,
} TooltipUpdateReason;

BOOL
ListWidget_TooltipUpdateText(ListWidget *self, 
							 ListWidgetTooltip *tooltip,
							 ListWidgetItem *item,
							 TooltipUpdateReason reason);

#endif //_NULLSOFT_WINAMP_ML_DEVICES_LIST_WIDGET_INTERNAL_HEADER