ReactOS 0.4.16-dev-297-gc569aee
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};
93
94int
96
97class CAppScrnshotPreview : public CWindowImpl<CAppScrnshotPreview>
98{
99 private:
102 Gdiplus::Image *pImage = NULL;
108 LONGLONG ContentID = 0; // used to determine whether image has been switched when download complete. Increase by 1
109 // each time the content of this window changed
110 CStringW TempImagePath; // currently displayed temp file
111
112 BOOL
114
115 VOID
117 VOID
119 BOOL
120 DisplayFile(LPCWSTR lpszFileName);
121 VOID
123
124 VOID
125 PaintOnDC(HDC hdc, int width, int height, BOOL bDrawBkgnd);
126 float
128 float
129 GetFrameDotShift(int Frame, int width, int height);
130
131 public:
132 static ATL::CWndClassInfo &
134
135 HWND
136 Create(HWND hParent);
137 VOID
139 VOID
140 DisplayEmpty();
141 BOOL
142 DisplayImage(LPCWSTR lpszLocation);
143
144 // calculate requested window width by given height
145 int
147
148 CAppScrnshotPreview(const CStringW &BasePath);
150};
151
152class CAppInfoDisplay : public CUiWindow<CWindowImpl<CAppInfoDisplay>>
153{
155
156 private:
157 BOOL
159 VOID
161
162 VOID
164 VOID
165 ResizeChildren(int Width, int Height);
166
167 public:
170
171 static ATL::CWndClassInfo &
173
174 HWND
176
177 VOID
179 void
180 SetWelcomeText(bool bAppwiz);
181 VOID
183
185};
186
187class CAppsListView : public CUiWindow<CWindowImpl<CAppsListView, CListView>>
188{
190 {
193 };
194
196 bool bHasCheckboxes = false;
197
201
203
205
208
213
214 LRESULT
216 LRESULT
217 OnAsyncIcon(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled);
218
219 public:
221 ~CAppsListView();
222
223 VOID
225
226 void
227 ShowCheckboxes(bool bShow);
228
229 VOID
231
232 BOOL
234 void
236
237 INT
238 AddItem(INT ItemIndex, INT IconIndex, LPCWSTR lpText, LPARAM lParam);
239
241 GetImageList(int iImageList);
242
243 static INT CALLBACK
244 s_CompareFunc(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort);
245
246 INT
247 CompareFunc(LPARAM lParam1, LPARAM lParam2, INT iSubItem);
248
249 HWND
251
252 BOOL
254 VOID
255 SetCheckState(INT item, BOOL fCheck);
256 VOID
257 CheckAll();
258
259 PVOID
261
262 BOOL
264 BOOL
265 SetViewMode(DWORD ViewMode);
266
267 BOOL
268 AddApplication(CAppInfo *AppInfo, BOOL InitialCheckState);
269
270 // this function is called when parent window receiving an notification about checkstate changing
271 VOID
272 ItemCheckStateNotify(int iItem, BOOL bCheck);
273};
274
276{
279
280 VOID
281 AddImageToImageList(HIMAGELIST hImageList, UINT ImageIndex);
282
285
286 public:
287 CMainToolbar();
288
289 VOID
291
292 HWND
294
295 void
296 ShowButtonCaption(bool bShow);
297
298 void
299 UpdateMaxButtonsWidth();
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
412 };
413 VOID
414 GetRestoreListSelectionData(RESTORELISTSELECTION &Restore);
415 VOID
416 RestoreListSelection(const RESTORELISTSELECTION &Restore);
417
418 // this function is called when a item of listview get focus.
419 // CallbackParam is the param passed to listview when adding the item (the one getting focus now).
420 VOID
421 ItemGetFocus(LPVOID CallbackParam);
422
423 // this function is called when a item of listview is checked/unchecked
424 // CallbackParam is the param passed to listview when adding the item (the one getting focus now).
425 VOID
426 ItemCheckStateChanged(BOOL bChecked, LPVOID CallbackParam);
427};
#define WM_RAPPSLIST_ASYNCICON
Definition: appview.h:42
int ScrnshotDownloadCallback(pASYNCINET AsyncInet, ASYNC_EVENT Event, WPARAM wParam, LPARAM lParam, VOID *Extension)
Definition: appview.cpp:319
#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:126
#define IDS_APP_DISPLAY_LIST
Definition: resource.h:127
#define IDS_APP_DISPLAY_TILE
Definition: resource.h:128
static void OnGetDispInfo(NMLVDISPINFO *plvdi)
Definition: listview.c:300
@ Create
Definition: registry.c:563
VOID OnCommand(WPARAM wParam, LPARAM lParam)
Definition: appview.cpp:1011
VOID ShowAppInfo(CAppInfo *Info)
Definition: appview.cpp:958
BOOL ProcessWindowMessage(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam, LRESULT &theResult, DWORD dwMapId)
Definition: appview.cpp:775
VOID OnLink(ENLINK *Link)
Definition: appview.cpp:894
VOID ResizeChildren()
Definition: appview.cpp:837
CAppRichEdit * RichEdit
Definition: appview.h:168
void SetWelcomeText(bool bAppwiz)
Definition: appview.cpp:974
CAppScrnshotPreview * ScrnshotPrev
Definition: appview.h:169
LPWSTR pLink
Definition: appview.h:154
static ATL::CWndClassInfo & GetWndClassInfo()
Definition: appview.cpp:924
VOID InsertTextWithString(UINT StringID, const CStringW &Text, DWORD TextFlags)
Definition: appview.cpp:309
VOID LoadAndInsertText(UINT uStringID, const CStringW &szText, DWORD TextFlags)
Definition: appview.cpp:285
float GetLoadingDotWidth(int width, int height)
Definition: appview.cpp:605
VOID PreviousDisplayCleanup()
Definition: appview.cpp:643
VOID SetStatus(SCRNSHOT_STATUS Status)
Definition: appview.cpp:515
SCRNSHOT_STATUS ScrnshotPrevStauts
Definition: appview.h:101
BOOL DisplayFile(LPCWSTR lpszFileName)
Definition: appview.cpp:501
VOID PaintOnDC(HDC hdc, int width, int height, BOOL bDrawBkgnd)
Definition: appview.cpp:521
BOOL ProcessWindowMessage(HWND hwnd, UINT Msg, WPARAM wParam, LPARAM lParam, LRESULT &theResult, DWORD dwMapId)
Definition: appview.cpp:356
HICON hBrokenImgIcon
Definition: appview.h:103
LONGLONG ContentID
Definition: appview.h:108
int LoadingAnimationFrame
Definition: appview.h:105
CStringW TempImagePath
Definition: appview.h:110
float GetFrameDotShift(int Frame, int width, int height)
Definition: appview.cpp:611
BOOL DisplayImage(LPCWSTR lpszLocation)
Definition: appview.cpp:676
pASYNCINET AsyncInet
Definition: appview.h:107
CStringW m_BasePath
Definition: appview.h:100
Gdiplus::Image * pImage
Definition: appview.h:102
static ATL::CWndClassInfo & GetWndClassInfo()
Definition: appview.cpp:619
int GetRequestedWidth(int Height)
Definition: appview.cpp:740
void DeleteColumn(INT Index)
Definition: appview.cpp:1240
VOID ColumnClick(LPNMLISTVIEW pnmv)
Definition: appview.cpp:1184
INT ItemCount
Definition: appview.h:198
BOOL SetViewMode(DWORD ViewMode)
Definition: appview.cpp:1452
INT ColumnCount
Definition: appview.h:200
void ShowCheckboxes(bool bShow)
Definition: appview.cpp:1177
VOID ItemCheckStateNotify(int iItem, BOOL bCheck)
Definition: appview.cpp:1506
VOID CheckAll()
Definition: appview.cpp:1341
HIMAGELIST m_hImageListView
Definition: appview.h:206
HIMAGELIST GetImageList(int iImageList)
Definition: appview.cpp:1268
BOOL SetDisplayAppType(APPLICATION_VIEW_TYPE AppType)
Definition: appview.cpp:1370
APPLICATION_VIEW_TYPE ApplicationViewType
Definition: appview.h:204
LRESULT OnEraseBackground(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
Definition: appview.cpp:1127
bool bHasCheckboxes
Definition: appview.h:196
PVOID GetFocusedItemData()
Definition: appview.cpp:1359
BOOL GetCheckState(INT item)
Definition: appview.cpp:1326
VOID SetWatermark(const CStringW &Text)
Definition: appview.cpp:1171
VOID SetCheckState(INT item, BOOL fCheck)
Definition: appview.cpp:1332
LRESULT OnAsyncIcon(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
Definition: appview.cpp:1145
INT nLastHeaderID
Definition: appview.h:202
BOOL AddColumn(INT Index, CStringW &Text, INT Width, INT Format)
Definition: appview.cpp:1224
CStringW m_Watermark
Definition: appview.h:207
BOOL AddApplication(CAppInfo *AppInfo, BOOL InitialCheckState)
Definition: appview.cpp:1458
INT CheckedItemCount
Definition: appview.h:199
static INT CALLBACK s_CompareFunc(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort)
Definition: appview.cpp:1274
BOOL bIsAscending
Definition: appview.h:195
INT CompareFunc(LPARAM lParam1, LPARAM lParam2, INT iSubItem)
Definition: appview.cpp:1281
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:278
const INT m_iToolbarHeight
Definition: appview.h:277
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 @1640 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:1129
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 MAX_PATH
Definition: compat.h:34
#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:88
static HICON
Definition: imagelist.c:80
static ATOM item
Definition: dde.c:856
unsigned int UINT
Definition: ndis.h:50
#define LPTOOLTIPTEXT
Definition: commctrl.h:1895
CAppsListView * lvw
Definition: appview.h:191
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:1628
__wchar_t WCHAR
Definition: xmlstorage.h:180
WCHAR * LPWSTR
Definition: xmlstorage.h:184
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
#define const
Definition: zconf.h:233