ReactOS 0.4.15-dev-8119-g4fb2fdb
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
21
22#define LISTVIEW_ICON_SIZE 32
23
24// default broken-image icon size
25#define BROKENIMG_ICON_SIZE 96
26
27// the boundary of w/h ratio of scrnshot preview window
28#define SCRNSHOT_MAX_ASPECT_RAT 2.5
29
30// padding between scrnshot preview and richedit (in pixel)
31#define INFO_DISPLAY_PADDING 10
32
33// minimum width of richedit
34#define RICHEDIT_MIN_WIDTH 160
35
36// padding between controls in toolbar
37#define TOOLBAR_PADDING 6
38
39// user-defined window message
40#define WM_RAPPS_DOWNLOAD_COMPLETE \
41 (WM_USER + 1) // notify download complete. wParam is error code, and lParam is a pointer to ScrnshotDownloadParam
42#define WM_RAPPS_RESIZE_CHILDREN (WM_USER + 2) // ask parent window to resize children.
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
214
215 LRESULT
217
218 public:
220 ~CAppsListView();
221
222 VOID
224 VOID
225 SetCheckboxesVisible(BOOL bIsVisible);
226
227 VOID
229
230 BOOL
232 void
234
235 INT
236 AddItem(INT ItemIndex, INT IconIndex, LPCWSTR lpText, LPARAM lParam);
237
239 GetImageList(int iImageList);
240
241 static INT CALLBACK
242 s_CompareFunc(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort);
243
244 INT
245 CompareFunc(LPARAM lParam1, LPARAM lParam2, INT iSubItem);
246
247 HWND
249
250 BOOL
252 VOID
253 SetCheckState(INT item, BOOL fCheck);
254 VOID
255 CheckAll();
256
257 PVOID
259
260 BOOL
262 BOOL
263 SetViewMode(DWORD ViewMode);
264
265 BOOL
266 AddApplication(CAppInfo *AppInfo, BOOL InitialCheckState);
267
268 // this function is called when parent window receiving an notification about checkstate changing
269 VOID
270 ItemCheckStateNotify(int iItem, BOOL bCheck);
271};
272
274{
277
278 VOID
279 AddImageToImageList(HIMAGELIST hImageList, UINT ImageIndex);
280
283
284 public:
285 CMainToolbar();
286
287 VOID
289
290 HWND
292
293 VOID
294 HideButtonCaption();
295 VOID
296 ShowButtonCaption();
297
298 DWORD
299 GetMaxButtonsWidth() const;
300};
301
302class CSearchBar : public CWindow
303{
304 public:
307
308 CSearchBar();
309
310 VOID
311 SetText(LPCWSTR lpszText);
312
313 HWND
315};
316
317class CComboBox : public CWindow
318{
319 // ID refers to different types of view
320 enum
321 {
324 m_AppDisplayTypeTile
325 };
326
327 // string ID for different. this should correspond with the enum above.
329
330 const int m_DefaultSelectType = m_AppDisplayTypeDetails;
331
332 public:
335
336 CComboBox();
337
338 HWND
340};
341
342class CApplicationView : public CUiWindow<CWindowImpl<CApplicationView>>
343{
344 private:
345 CUiPanel *m_Panel = NULL;
346 CMainToolbar *m_Toolbar = NULL;
349 CAppsListView *m_ListView = NULL;
350 CAppInfoDisplay *m_AppsInfo = NULL;
351 CUiSplitPanel *m_HSplitter = NULL;
352 CMainWindow *m_MainWindow = NULL;
354
355 BOOL
356 ProcessWindowMessage(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam, LRESULT &theResult, DWORD dwMapId);
357
358 BOOL
360 BOOL
361 CreateSearchBar();
362 BOOL
363 CreateComboBox();
364 BOOL
365 CreateHSplitter();
366 BOOL
368 BOOL
369 CreateAppInfoDisplay();
370
371 VOID
373 VOID
375
376 public:
377 CApplicationView(CMainWindow *MainWindow);
379
380 static ATL::CWndClassInfo &
381 GetWndClassInfo();
382
383 HWND
385 void
386 SetRedraw(BOOL bRedraw);
387 void
388 SetFocusOnSearchBar();
389 BOOL
390 SetDisplayAppType(APPLICATION_VIEW_TYPE AppType);
391
392 BOOL
393 AddApplication(CAppInfo *InstAppInfo, BOOL InitialCheckState);
394 VOID
395 SetWatermark(const CStringW &Text);
396
397 void
398 CheckAll();
399 PVOID
400 GetFocusedItemData();
401 int
402 GetItemCount();
403 VOID
404 AppendTabOrderWindow(int Direction, ATL::CSimpleArray<HWND> &TabOrderList);
405
406 // this function is called when a item of listview get focus.
407 // CallbackParam is the param passed to listview when adding the item (the one getting focus now).
408 VOID
409 ItemGetFocus(LPVOID CallbackParam);
410
411 // this function is called when a item of listview is checked/unchecked
412 // CallbackParam is the param passed to listview when adding the item (the one getting focus now).
413 VOID
414 ItemCheckStateChanged(BOOL bChecked, LPVOID CallbackParam);
415};
int ScrnshotDownloadCallback(pASYNCINET AsyncInet, ASYNC_EVENT Event, WPARAM wParam, LPARAM lParam, VOID *Extension)
Definition: appview.cpp:285
#define BROKENIMG_ICON_SIZE
Definition: appview.h:25
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
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:314
@ Create
Definition: registry.c:563
VOID OnCommand(WPARAM wParam, LPARAM lParam)
Definition: appview.cpp:943
VOID ShowAppInfo(CAppInfo *Info)
Definition: appview.cpp:919
BOOL ProcessWindowMessage(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam, LRESULT &theResult, DWORD dwMapId)
Definition: appview.cpp:741
VOID SetWelcomeText()
Definition: appview.cpp:935
VOID OnLink(ENLINK *Link)
Definition: appview.cpp:855
VOID ResizeChildren()
Definition: appview.cpp:798
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:885
VOID SetWelcomeText()
Definition: appview.cpp:269
VOID InsertTextWithString(UINT StringID, const CStringW &Text, DWORD TextFlags)
Definition: appview.cpp:260
VOID LoadAndInsertText(UINT uStringID, const CStringW &szText, DWORD TextFlags)
Definition: appview.cpp:236
float GetLoadingDotWidth(int width, int height)
Definition: appview.cpp:571
VOID PreviousDisplayCleanup()
Definition: appview.cpp:609
VOID SetStatus(SCRNSHOT_STATUS Status)
Definition: appview.cpp:481
SCRNSHOT_STATUS ScrnshotPrevStauts
Definition: appview.h:103
BOOL DisplayFile(LPCWSTR lpszFileName)
Definition: appview.cpp:467
VOID PaintOnDC(HDC hdc, int width, int height, BOOL bDrawBkgnd)
Definition: appview.cpp:487
BOOL ProcessWindowMessage(HWND hwnd, UINT Msg, WPARAM wParam, LPARAM lParam, LRESULT &theResult, DWORD dwMapId)
Definition: appview.cpp:322
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:577
BOOL DisplayImage(LPCWSTR lpszLocation)
Definition: appview.cpp:642
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:585
int GetRequestedWidth(int Height)
Definition: appview.cpp:706
void DeleteColumn(INT Index)
Definition: appview.cpp:1081
VOID ColumnClick(LPNMLISTVIEW pnmv)
Definition: appview.cpp:1025
BOOL bHasCheckboxes
Definition: appview.h:198
INT ItemCount
Definition: appview.h:200
BOOL SetViewMode(DWORD ViewMode)
Definition: appview.cpp:1279
INT ColumnCount
Definition: appview.h:202
VOID ItemCheckStateNotify(int iItem, BOOL bCheck)
Definition: appview.cpp:1359
VOID CheckAll()
Definition: appview.cpp:1187
HIMAGELIST m_hImageListView
Definition: appview.h:208
HIMAGELIST GetImageList(int iImageList)
Definition: appview.cpp:1109
BOOL SetDisplayAppType(APPLICATION_VIEW_TYPE AppType)
Definition: appview.cpp:1216
APPLICATION_VIEW_TYPE ApplicationViewType
Definition: appview.h:206
LRESULT OnEraseBackground(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
Definition: appview.cpp:986
PVOID GetFocusedItemData()
Definition: appview.cpp:1205
BOOL GetCheckState(INT item)
Definition: appview.cpp:1172
VOID SetCheckboxesVisible(BOOL bIsVisible)
Definition: appview.cpp:1010
VOID SetWatermark(const CStringW &Text)
Definition: appview.cpp:1004
VOID SetCheckState(INT item, BOOL fCheck)
Definition: appview.cpp:1178
INT nLastHeaderID
Definition: appview.h:204
BOOL AddColumn(INT Index, CStringW &Text, INT Width, INT Format)
Definition: appview.cpp:1065
CStringW m_Watermark
Definition: appview.h:209
BOOL AddApplication(CAppInfo *AppInfo, BOOL InitialCheckState)
Definition: appview.cpp:1285
INT CheckedItemCount
Definition: appview.h:201
static INT CALLBACK s_CompareFunc(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort)
Definition: appview.cpp:1115
BOOL bIsAscending
Definition: appview.h:197
INT CompareFunc(LPARAM lParam1, LPARAM lParam2, INT iSubItem)
Definition: appview.cpp:1122
@ m_AppDisplayTypeList
Definition: appview.h:323
@ m_AppDisplayTypeDetails
Definition: appview.h:322
int m_Width
Definition: appview.h:333
int m_Height
Definition: appview.h:334
DWORD m_dButtonsWidthMax
Definition: appview.h:276
const INT m_iToolbarHeight
Definition: appview.h:275
const INT m_Height
Definition: appview.h:306
const INT m_Width
Definition: appview.h:305
static int OnCommand(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: clipbrd.c:202
struct @1637 Msg[]
WPARAM wParam
Definition: combotst.c:138
char * Text
Definition: combotst.c:136
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