aboutsummaryrefslogtreecommitdiff
path: root/Src/Plugins/Library/ml_online/Setup/setupGroup.h
blob: ce3f3c5f2edbba3ccb8c721da3c3cda360c47e98 (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
#ifndef NULLOSFT_ONLINEMEDIA_PLUGIN_SETUPGROUP_HEADER
#define NULLOSFT_ONLINEMEDIA_PLUGIN_SETUPGROUP_HEADER

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

#include <wtypes.h>
#include "./setupRecord.h"
#include "./setupListbox.h"
#include <vector>

class SetupListboxLabel;
class SetupLog;
class SetupPage;
class ifc_omstorage;

class SetupGroup : public SetupListboxItem
{
public:
	typedef enum
	{
		styleDefaultUnsubscribed = 0x00000001,
		styleDefaultSubscribed = 0x00000002,
		styleSortAlphabetically = 0x00000008,
		styleSaveAll = 0x00000010,
	} GroupStyles;
protected:
	typedef enum
	{
		flagCollapsed = 0x0001,
		flagMenuActive = 0x0002,
		flagLoading = 0x0004,
	} GroupFlags;

protected:
	SetupGroup(INT groupId, LPCWSTR pszName, LPCWSTR pszAddress, const GUID *storageId, const GUID *filterId, UINT fStyle);
	~SetupGroup();

public:
	static SetupGroup *CreateInstance(INT groupId, LPCWSTR pszName, LPCWSTR pszAddress, const GUID *storageId, const GUID *filterId, UINT fStyle);

public:
	ULONG AddRef();
	ULONG Release();

	INT GetId() { return id; }
	HRESULT GetName(LPWSTR pszBuffer, INT cchBufferMax);
	HRESULT GetLongName(LPWSTR pszBuffer, INT cchBufferMax);
	HRESULT GetDescription(LPWSTR pszBuffer, INT cchBufferMax);

	size_t GetRecordCount();
	SetupRecord *GetRecord(size_t index) { return list[index]; }

	size_t GetListboxCount();
	SetupListboxItem *GetListboxItem(size_t index);

	BOOL IsModified();
	
	BOOL IsExpanded();
	void SetExpanded(BOOL fExpanded);
	void SelectAll(SetupListbox *instance, BOOL fSelect);

	HRESULT RequestReload();
	HRESULT Save(SetupLog *log);


	void SetEmptyText(LPCWSTR pszText, BOOL fInvalidate);
	void SetLongName(LPCWSTR pszText);
	void SetDescription(LPCWSTR pszText);
	
	void GetColors(HDC hdc, UINT state, COLORREF *rgbBkOut, COLORREF *rgbTextOut);
	HBRUSH GetBrush(HDC hdc, UINT state);

	HRESULT SignalLoadCompleted(HANDLE event);
	void ValidateSelection(SetupListbox *instance);

	/* SetupListboxItem */ 
	BOOL MeasureItem(SetupListbox *instance, UINT *cx, UINT *cy);
	BOOL DrawItem(SetupListbox *instance, HDC hdc, const RECT *prc, UINT state);
	INT_PTR KeyToItem(SetupListbox *instance, const RECT *prcItem, INT vKey);
	BOOL MouseMove(SetupListbox *instance, const RECT *prcItem, UINT mouseFlags, POINT pt);
	BOOL MouseLeave(SetupListbox *instance, const RECT *prcItem);
	BOOL LButtonDown(SetupListbox *instance, const RECT *prcItem, UINT mouseFlags, POINT pt);
	BOOL LButtonUp(SetupListbox *instance, const RECT *prcItem, UINT mouseFlags, POINT pt);
	BOOL LButtonDblClk(SetupListbox *instance, const RECT *prcItem, UINT mouseFlags, POINT pt);
	BOOL RButtonDown(SetupListbox *instance, const RECT *prcItem, UINT mouseFlags, POINT pt);
	BOOL RButtonUp(SetupListbox *instance, const RECT *prcItem, UINT mouseFlags, POINT pt);
	void CaptureChanged(SetupListbox *instance, const RECT *prcItem, SetupListboxItem *captured);
	BOOL IsDisabled() { return FALSE; }
	void Command(SetupListbox *instance, INT commandId, INT eventId);
	HWND CreateDetailsView(HWND hParent);
	BOOL GetUniqueName(LPWSTR pszBuffer, UINT cchBufferMax);

	void SetError(HRESULT code) { errorCode = code; }
	HRESULT GetError() { return errorCode; }

	void Clear(BOOL fInvalidate);

	void SetPageWnd(HWND hPage);

protected:
	void InvertExpanded(SetupListbox *instance);
	void OnLoadCompleted();
	

private:	
	friend static void CALLBACK SetupGroup_LoadCallback(ifc_omstorageasync *result);
	

protected:
	ULONG ref;
	INT id;
	LPWSTR name;
	LPWSTR longName;
	LPWSTR description;
	UINT style;
	UINT flags;
	LPWSTR address;
	GUID storageId;
	GUID filterId;
	HRESULT errorCode;
	std::vector<SetupRecord*> list;
	SetupListboxLabel *emptyLabel;
	CRITICAL_SECTION lock;
	ifc_omstorageasync *loadResult;
	HWND hPage;
	HANDLE loadComplete;
};

#endif //NULLOSFT_ONLINEMEDIA_PLUGIN_SETUPGROUP_HEADER