ReactOS 0.4.15-dev-8434-g155a7c7
appview.h
Go to the documentation of this file.
1#pragma once
2
3#include "rapps.h"
4#include "rosui.h"
5#include "crichedit.h"
6#include "asyncinet.h"
7
8#include <shlobj_undoc.h>
9#include <shlguid_undoc.h>
10
11#include <atlbase.h>
12#include <atlcom.h>
13#include <atltypes.h>
14#include <atlwin.h>
15#include <wininet.h>
16#include <shellutils.h>
17#include <ui/rosctrls.h>
18#include <gdiplus.h>
19#include <math.h>
20
22
23// default broken-image icon size
24#define BROKENIMG_ICON_SIZE 96
25
26// the boundary of w/h ratio of scrnshot preview window
27#define SCRNSHOT_MAX_ASPECT_RAT 2.5
28
29// padding between scrnshot preview and richedit (in pixel)
30#define INFO_DISPLAY_PADDING 10
31
32// minimum width of richedit
33#define RICHEDIT_MIN_WIDTH 160
34
35// padding between controls in toolbar
36#define TOOLBAR_PADDING 6
37
38// user-defined window message
39#define WM_RAPPS_DOWNLOAD_COMPLETE \
40 (WM_USER + 1) // notify download complete. wParam is error code, and lParam is a pointer to ScrnshotDownloadParam
41#define WM_RAPPS_RESIZE_CHILDREN (WM_USER + 2) // ask parent window to resize children.
42#define WM_RAPPSLIST_ASYNCICON (WM_APP + 0)
43
45{
46 SCRNSHOT_PREV_EMPTY, // show nothing
47 SCRNSHOT_PREV_LOADING, // image is loading (most likely downloading)
48 SCRNSHOT_PREV_IMAGE, // display image from a file
49 SCRNSHOT_PREV_FAILED // image can not be shown (download failure or wrong image)
50};
51
52#define TIMER_LOADING_ANIMATION 1 // Timer ID
53
54#define LOADING_ANIMATION_PERIOD 3 // Animation cycling period (in seconds)
55#define LOADING_ANIMATION_FPS 18 // Animation Frame Per Second
56
57#define PI 3.1415927
58
59// retrieve the value using a mask
60#define STATEIMAGETOINDEX(x) (((x)&LVIS_STATEIMAGEMASK) >> 12)
61
62// for listview with extend style LVS_EX_CHECKBOXES, State image 1 is the unchecked box, and state image 2 is the
63// checked box. see this: https://docs.microsoft.com/en-us/windows/win32/controls/extended-list-view-styles
64#define STATEIMAGE_UNCHECKED 1
65#define STATEIMAGE_CHECKED 2
66
67class CMainWindow;
68
70{
73};
74
76{
82
83class CAppRichEdit : public CUiWindow<CRichEdit>
84{
85 public:
86 VOID
87 LoadAndInsertText(UINT uStringID, const CStringW &szText, DWORD TextFlags);
88 VOID
89 LoadAndInsertText(UINT uStringID, DWORD StringFlags);
90 VOID
91 InsertTextWithString(UINT StringID, const CStringW &Text, DWORD TextFlags);
92 VOID
94};
95
96int
98
99class CAppScrnshotPreview : public CWindowImpl<CAppScrnshotPreview>
100{
101 private:
104 Gdiplus::Image *pImage = NULL;
110 LONGLONG ContentID = 0; // used to determine whether image has been switched when download complete. Increase by 1
111 // each time the content of this window changed
112 CStringW TempImagePath; // currently displayed temp file
113
114 BOOL
116
117 VOID
119 VOID
121 BOOL
122 DisplayFile(LPCWSTR lpszFileName);
123 VOID
125
126 VOID
127 PaintOnDC(HDC hdc, int width, int height, BOOL bDrawBkgnd);
128 float
130 float
131 GetFrameDotShift(int Frame, int width, int height);
132
133 public:
134 static ATL::CWndClassInfo &
136
137 HWND
138 Create(HWND hParent);
139 VOID
141 VOID
142 DisplayEmpty();
143 BOOL
144 DisplayImage(LPCWSTR lpszLocation);
145
146 // calculate requested window width by given height
147 int
149
150 CAppScrnshotPreview(const CStringW &BasePath);
152};
153
154class CAppInfoDisplay : public CUiWindow<CWindowImpl<CAppInfoDisplay>>
155{
157
158 private:
159 BOOL
161 VOID
163
164 VOID
166 VOID
167 ResizeChildren(int Width, int Height);
168
169 public:
172
173 static ATL::CWndClassInfo &
175
176 HWND
178
179 VOID
181 VOID
183 VOID
185
187};
188
189class CAppsListView : public CUiWindow<CWindowImpl<CAppsListView, CListView>>
190{
192 {
195 };
196
199
203
205
207
210
215
216 LRESULT
218 LRESULT
219 OnAsyncIcon(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled);
220
221 public:
223 ~CAppsListView();
224
225 VOID
227 VOID
228 SetCheckboxesVisible(BOOL bIsVisible);
229
230 VOID
232
233 BOOL
235 void
237
238 INT
239 AddItem(INT ItemIndex, INT IconIndex, LPCWSTR lpText, LPARAM lParam);
240
242 GetImageList(int iImageList);
243
244 static INT CALLBACK
245 s_CompareFunc(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort);
246
247 INT
248 CompareFunc(LPARAM lParam1, LPARAM lParam2, INT iSubItem);
249
250 HWND
252
253 BOOL
255 VOID
256 SetCheckState(INT item, BOOL fCheck);
257 VOID
258 CheckAll();
259
260 PVOID
262
263 BOOL
265 BOOL
266 SetViewMode(DWORD ViewMode);
267
268 BOOL
269 AddApplication(CAppInfo *AppInfo, BOOL InitialCheckState);
270
271 // this function is called when parent window receiving an notification about checkstate changing
272 VOID
273 ItemCheckStateNotify(int iItem, BOOL bCheck);
274};
275
277{
280
281 VOID
282 AddImageToImageList(HIMAGELIST hImageList, UINT ImageIndex);
283
286
287 public:
288 CMainToolbar();
289
290 VOID
292
293 HWND
295
296 VOID
297 HideButtonCaption();
298 VOID
299 ShowButtonCaption();
300
301 DWORD
302 GetMaxButtonsWidth() const;
303};
304
305class CSearchBar : public CWindow
306{
307 public:
310
311 CSearchBar();
312
313 VOID
314 SetText(LPCWSTR lpszText);
315
316 HWND
318};
319
320class CComboBox : public CWindow
321{
322 // ID refers to different types of view
323 enum
324 {
327 m_AppDisplayTypeTile
328 };
329
330 // string ID for different. this should correspond with the enum above.
332
333 const int m_DefaultSelectType = m_AppDisplayTypeDetails;
334
335 public:
338
339 CComboBox();
340
341 HWND
343};
344
345class CApplicationView : public CUiWindow<CWindowImpl<CApplicationView>>
346{
347 private:
348 CUiPanel *m_Panel = NULL;
349 CMainToolbar *m_Toolbar = NULL;
352 CAppsListView *m_ListView = NULL;
353 CAppInfoDisplay *m_AppsInfo = NULL;
354 CUiSplitPanel *m_HSplitter = NULL;
355 CMainWindow *m_MainWindow = NULL;
357
358 BOOL
359 ProcessWindowMessage(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam, LRESULT &theResult, DWORD dwMapId);
360
361 BOOL
363 BOOL
364 CreateSearchBar();
365 BOOL
366 CreateComboBox();
367 BOOL
368 CreateHSplitter();
369 BOOL
371 BOOL
372 CreateAppInfoDisplay();
373
374 VOID
376 VOID
378
379 public:
380 CApplicationView(CMainWindow *MainWindow);
382
383 static ATL::CWndClassInfo &
384 GetWndClassInfo();
385
386 HWND
388 void
389 SetRedraw(BOOL bRedraw);
390 void
391 SetFocusOnSearchBar();
392 BOOL
393 SetDisplayAppType(APPLICATION_VIEW_TYPE AppType);
394
395 BOOL
396 AddApplication(CAppInfo *InstAppInfo, BOOL InitialCheckState);
397 VOID
398 SetWatermark(const CStringW &Text);
399
400 void
401 CheckAll();
402 PVOID
403 GetFocusedItemData();
404 int
405 GetItemCount();
406 VOID
407 AppendTabOrderWindow(int Direction, ATL::CSimpleArray<HWND> &TabOrderList);
408
409 // this function is called when a item of listview get focus.
410 // CallbackParam is the param passed to listview when adding the item (the one getting focus now).
411 VOID
412 ItemGetFocus(LPVOID CallbackParam);
413
414 // this function is called when a item of listview is checked/unchecked
415 // CallbackParam is the param passed to listview when adding the item (the one getting focus now).
416 VOID
417 ItemCheckStateChanged(BOOL bChecked, LPVOID CallbackParam);
418};
#define WM_RAPPSLIST_ASYNCICON
Definition: appview.h:42
int ScrnshotDownloadCallback(pASYNCINET AsyncInet, ASYNC_EVENT Event, WPARAM wParam, LPARAM lParam, VOID *Extension)
Definition: appview.cpp:288
#define BROKENIMG_ICON_SIZE
Definition: appview.h:24
SCRNSHOT_STATUS
Definition: appview.h:45
@ SCRNSHOT_PREV_LOADING
Definition: appview.h:47
@ SCRNSHOT_PREV_FAILED
Definition: appview.h:49
@ SCRNSHOT_PREV_EMPTY
Definition: appview.h:46
@ SCRNSHOT_PREV_IMAGE
Definition: appview.h:48
struct __ScrnshotDownloadParam ScrnshotDownloadParam
HICON g_hDefaultPackageIcon
Definition: appview.cpp:16
APPLICATION_VIEW_TYPE
Definition: appview.h:70
@ AppViewTypeInstalledApps
Definition: appview.h:72
@ AppViewTypeAvailableApps
Definition: appview.h:71
ASYNC_EVENT
Definition: asyncinet.h:6
const WCHAR * class
Definition: main.c:68
BOOL CreateListView(PMAIN_WND_INFO Info)
Definition: listview.c:355
HIMAGELIST InitImageList(UINT StartResource, UINT EndResource, UINT Width, UINT Height, ULONG type)
Definition: misc.c:219
#define IDS_APP_DISPLAY_DETAILS
Definition: resource.h:121
#define IDS_APP_DISPLAY_LIST
Definition: resource.h:122
#define IDS_APP_DISPLAY_TILE
Definition: resource.h:123
static void OnGetDispInfo(NMLVDISPINFO *plvdi)
Definition: listview.c:313
@ Create
Definition: registry.c:563
VOID OnCommand(WPARAM wParam, LPARAM lParam)
Definition: appview.cpp:946
VOID ShowAppInfo(CAppInfo *Info)
Definition: appview.cpp:922
BOOL ProcessWindowMessage(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam, LRESULT &theResult, DWORD dwMapId)
Definition: appview.cpp:744
VOID SetWelcomeText()
Definition: appview.cpp:938
VOID OnLink(ENLINK *Link)
Definition: appview.cpp:858
VOID ResizeChildren()
Definition: appview.cpp:801
CAppRichEdit * RichEdit
Definition: appview.h:170
CAppScrnshotPreview * ScrnshotPrev
Definition: appview.h:171
LPWSTR pLink
Definition: appview.h:156
static ATL::CWndClassInfo & GetWndClassInfo()
Definition: appview.cpp:888
VOID SetWelcomeText()
Definition: appview.cpp:272
VOID InsertTextWithString(UINT StringID, const CStringW &Text, DWORD TextFlags)
Definition: appview.cpp:263
VOID LoadAndInsertText(UINT uStringID, const CStringW &szText, DWORD TextFlags)
Definition: appview.cpp:239
float GetLoadingDotWidth(int width, int height)
Definition: appview.cpp:574
VOID PreviousDisplayCleanup()
Definition: appview.cpp:612
VOID SetStatus(SCRNSHOT_STATUS Status)
Definition: appview.cpp:484
SCRNSHOT_STATUS ScrnshotPrevStauts
Definition: appview.h:103
BOOL DisplayFile(LPCWSTR lpszFileName)
Definition: appview.cpp:470
VOID PaintOnDC(HDC hdc, int width, int height, BOOL bDrawBkgnd)
Definition: appview.cpp:490
BOOL ProcessWindowMessage(HWND hwnd, UINT Msg, WPARAM wParam, LPARAM lParam, LRESULT &theResult, DWORD dwMapId)
Definition: appview.cpp:325
HICON hBrokenImgIcon
Definition: appview.h:105
LONGLONG ContentID
Definition: appview.h:110
int LoadingAnimationFrame
Definition: appview.h:107
CStringW TempImagePath
Definition: appview.h:112
float GetFrameDotShift(int Frame, int width, int height)
Definition: appview.cpp:580
BOOL DisplayImage(LPCWSTR lpszLocation)
Definition: appview.cpp:645
pASYNCINET AsyncInet
Definition: appview.h:109
CStringW m_BasePath
Definition: appview.h:102
Gdiplus::Image * pImage
Definition: appview.h:104
static ATL::CWndClassInfo & GetWndClassInfo()
Definition: appview.cpp:588
int GetRequestedWidth(int Height)
Definition: appview.cpp:709
void DeleteColumn(INT Index)
Definition: appview.cpp:1183
VOID ColumnClick(LPNMLISTVIEW pnmv)
Definition: appview.cpp:1127
BOOL bHasCheckboxes
Definition: appview.h:198
INT ItemCount
Definition: appview.h:200
BOOL SetViewMode(DWORD ViewMode)
Definition: appview.cpp:1393
INT ColumnCount
Definition: appview.h:202
VOID ItemCheckStateNotify(int iItem, BOOL bCheck)
Definition: appview.cpp:1447
VOID CheckAll()
Definition: appview.cpp:1284
HIMAGELIST m_hImageListView
Definition: appview.h:208
HIMAGELIST GetImageList(int iImageList)
Definition: appview.cpp:1211
BOOL SetDisplayAppType(APPLICATION_VIEW_TYPE AppType)
Definition: appview.cpp:1313
APPLICATION_VIEW_TYPE ApplicationViewType
Definition: appview.h:206
LRESULT OnEraseBackground(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
Definition: appview.cpp:1062
PVOID GetFocusedItemData()
Definition: appview.cpp:1302
BOOL GetCheckState(INT item)
Definition: appview.cpp:1269
VOID SetCheckboxesVisible(BOOL bIsVisible)
Definition: appview.cpp:1112
VOID SetWatermark(const CStringW &Text)
Definition: appview.cpp:1106
VOID SetCheckState(INT item, BOOL fCheck)
Definition: appview.cpp:1275
LRESULT OnAsyncIcon(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
Definition: appview.cpp:1080
INT nLastHeaderID
Definition: appview.h:204
BOOL AddColumn(INT Index, CStringW &Text, INT Width, INT Format)
Definition: appview.cpp:1167
CStringW m_Watermark
Definition: appview.h:209
BOOL AddApplication(CAppInfo *AppInfo, BOOL InitialCheckState)
Definition: appview.cpp:1399
INT CheckedItemCount
Definition: appview.h:201
static INT CALLBACK s_CompareFunc(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort)
Definition: appview.cpp:1217
BOOL bIsAscending
Definition: appview.h:197
INT CompareFunc(LPARAM lParam1, LPARAM lParam2, INT iSubItem)
Definition: appview.cpp:1224
int m_Width
Definition: appview.h:336
int m_Height
Definition: appview.h:337
@ m_AppDisplayTypeList
Definition: appview.h:326
@ m_AppDisplayTypeDetails
Definition: appview.h:325
DWORD m_dButtonsWidthMax
Definition: appview.h:279
const INT m_iToolbarHeight
Definition: appview.h:278
const INT m_Height
Definition: appview.h:309
const INT m_Width
Definition: appview.h:308
static int OnCommand(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: clipbrd.c:202
WPARAM wParam
Definition: combotst.c:138
char * Text
Definition: combotst.c:136
struct @1628 Msg[]
LPARAM lParam
Definition: combotst.c:139
HWND WINAPI CreateToolbar(HWND hwnd, DWORD style, UINT wID, INT nBitmaps, HINSTANCE hBMInst, UINT wBMID, LPCTBBUTTON lpButtons, INT iNumButtons)
Definition: commctrl.c:1122
static HWND hwndParent
Definition: cryptui.c:300
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define CALLBACK
Definition: compat.h:35
static const WCHAR IconIndex[]
Definition: install.c:52
static VOID OnSize(HWND hDlg, PDETAILDATA pData, INT cx, INT cy)
Definition: evtdetctl.c:470
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
_Inout_opt_ PUNICODE_STRING Extension
Definition: fltkernel.h:1092
Status
Definition: gdiplustypes.h:25
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
GLint GLint GLsizei width
Definition: gl.h:1546
#define MESSAGE_HANDLER(msg, func)
Definition: atlwin.h:1926
#define BEGIN_MSG_MAP(theClass)
Definition: atlwin.h:1898
#define END_MSG_MAP()
Definition: atlwin.h:1917
HDC hdc
Definition: main.c:9
static HDC
Definition: imagelist.c:92
static HICON
Definition: imagelist.c:84
static ATOM item
Definition: dde.c:856
unsigned int UINT
Definition: ndis.h:50
#define LPTOOLTIPTEXT
Definition: commctrl.h:1890
CAppsListView * lvw
Definition: appview.h:193
CStringW DownloadFileName
Definition: appview.h:80
Definition: tftpd.h:60
int64_t LONGLONG
Definition: typedefs.h:68
int32_t INT
Definition: typedefs.h:58
_In_ HFONT _Out_ PUINT _Out_ PUINT Width
Definition: font.h:89
_In_ HFONT _Out_ PUINT Height
Definition: font.h:88
#define AddItem
Definition: userenv.h:209
static int Link(const char **args)
Definition: vfdcmd.c:2414
_Must_inspect_result_ _In_ WDFCHILDLIST _In_ PWDF_CHILD_LIST_ITERATOR _Out_ WDFDEVICE _Inout_opt_ PWDF_CHILD_RETRIEVE_INFO Info
Definition: wdfchildlist.h:690
_In_ WDFCOLLECTION _In_ ULONG Index
WDF_EXTERN_C_START typedef _In_ WDFDEVICE _In_ WDFCONTEXT _In_ WDF_DMA_DIRECTION Direction
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023
LONG_PTR LPARAM
Definition: windef.h:208
LONG_PTR LRESULT
Definition: windef.h:209
UINT_PTR WPARAM
Definition: windef.h:207
#define WM_ERASEBKGND
Definition: winuser.h:1625
WCHAR * LPWSTR
Definition: xmlstorage.h:184
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
#define const
Definition: zconf.h:233