ReactOS  0.4.15-dev-3175-g222acf5
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 <rosctrls.h>
18 #include <gdiplus.h>
19 #include <math.h>
20 
21 using namespace Gdiplus;
22 
23 #define LISTVIEW_ICON_SIZE 32
24 
25 // default broken-image icon size
26 #define BROKENIMG_ICON_SIZE 96
27 
28 // the boundary of w/h ratio of scrnshot preview window
29 #define SCRNSHOT_MAX_ASPECT_RAT 2.5
30 
31 // padding between scrnshot preview and richedit (in pixel)
32 #define INFO_DISPLAY_PADDING 10
33 
34 // minimum width of richedit
35 #define RICHEDIT_MIN_WIDTH 160
36 
37 // padding between controls in toolbar
38 #define TOOLBAR_PADDING 6
39 
40 // user-defined window message
41 #define WM_RAPPS_DOWNLOAD_COMPLETE (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 
58 #define PI 3.1415927
59 
60 // retrieve the value using a mask
61 #define STATEIMAGETOINDEX(x) (((x) & LVIS_STATEIMAGEMASK) >> 12)
62 
63 // for listview with extend style LVS_EX_CHECKBOXES, State image 1 is the unchecked box, and state image 2 is the checked box.
64 // see this: https://docs.microsoft.com/en-us/windows/win32/controls/extended-list-view-styles
65 #define STATEIMAGE_UNCHECKED 1
66 #define STATEIMAGE_CHECKED 2
67 
68 class CMainWindow;
69 
71 {
75 };
76 
78 {
84 
85 
86 class CAppRichEdit :
87  public CUiWindow<CRichEdit>
88 {
89 private:
90  VOID LoadAndInsertText(UINT uStringID,
91  const ATL::CStringW &szText,
92  DWORD StringFlags,
93  DWORD TextFlags);
94 
95  VOID LoadAndInsertText(UINT uStringID,
96  DWORD StringFlags);
97 
98  VOID InsertVersionInfo(CAvailableApplicationInfo *Info);
99 
100  VOID InsertLicenseInfo(CAvailableApplicationInfo *Info);
101 
102  VOID InsertLanguageInfo(CAvailableApplicationInfo *Info);
103 
104 public:
105  BOOL ShowAvailableAppInfo(CAvailableApplicationInfo *Info);
106 
107  inline VOID InsertTextWithString(UINT StringID, DWORD StringFlags, const ATL::CStringW &Text, DWORD TextFlags);
108 
109  BOOL ShowInstalledAppInfo(CInstalledApplicationInfo *Info);
110 
112 };
113 
115  pASYNCINET AsyncInet,
117  WPARAM wParam,
118  LPARAM lParam,
119  VOID *Extension
120 );
121 
123  public CWindowImpl<CAppScrnshotPreview>
124 {
125 private:
126 
127  SCRNSHOT_STATUS ScrnshotPrevStauts = SCRNSHOT_PREV_EMPTY;
128  Image *pImage = NULL;
129  HICON hBrokenImgIcon = NULL;
130  BOOL bLoadingTimerOn = FALSE;
131  int LoadingAnimationFrame = 0;
132  int BrokenImgSize = BROKENIMG_ICON_SIZE;
133  pASYNCINET AsyncInet = NULL;
134  LONGLONG ContentID = 0; // used to determine whether image has been switched when download complete. Increase by 1 each time the content of this window changed
135  ATL::CStringW TempImagePath; // currently displayed temp file
136 
137  BOOL ProcessWindowMessage(HWND hwnd, UINT Msg, WPARAM wParam, LPARAM lParam, LRESULT &theResult, DWORD dwMapId);
138 
139  VOID DisplayLoading();
140 
141  VOID DisplayFailed();
142 
143  BOOL DisplayFile(LPCWSTR lpszFileName);
144 
145  VOID SetStatus(SCRNSHOT_STATUS Status);
146 
147  VOID PaintOnDC(HDC hdc, int width, int height, BOOL bDrawBkgnd);
148 
149  float GetLoadingDotWidth(int width, int height);
150 
151  float GetFrameDotShift(int Frame, int width, int height);
152 
153 public:
154  static ATL::CWndClassInfo &GetWndClassInfo();
155 
157 
158  VOID PreviousDisplayCleanup();
159 
160  VOID DisplayEmpty();
161 
162  BOOL DisplayImage(LPCWSTR lpszLocation);
163 
164  // calculate requested window width by given height
165  int GetRequestedWidth(int Height);
166 
168 };
169 
171  public CUiWindow<CWindowImpl<CAppInfoDisplay>>
172 {
173  LPWSTR pLink = NULL;
174 
175 private:
176  BOOL ProcessWindowMessage(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam, LRESULT &theResult, DWORD dwMapId);
177 
178  VOID ResizeChildren();
179 
180  VOID ResizeChildren(int Width, int Height);
181 
183 
184 public:
185 
186  CAppRichEdit *RichEdit = NULL;
187  CAppScrnshotPreview *ScrnshotPrev = NULL;
188 
189  static ATL::CWndClassInfo &GetWndClassInfo();
190 
192 
193  BOOL ShowAvailableAppInfo(CAvailableApplicationInfo *Info);
194 
195  BOOL ShowInstalledAppInfo(CInstalledApplicationInfo *Info);
196 
198 
200 
201  ~CAppInfoDisplay();
202 };
203 
205  public CUiWindow<CListView>
206 {
207  struct SortContext
208  {
211  };
212 
213  BOOL bIsAscending = TRUE;
214  BOOL bHasCheckboxes = FALSE;
215 
216  INT ItemCount = 0;
217  INT CheckedItemCount = 0;
218  INT ColumnCount = 0;
219 
220  INT nLastHeaderID = -1;
221 
223 
224  HIMAGELIST m_hImageListView = NULL;
225 
226 public:
227  CAppsListView();
228  ~CAppsListView();
229 
230  VOID SetCheckboxesVisible(BOOL bIsVisible);
231 
232  VOID ColumnClick(LPNMLISTVIEW pnmv);
233 
234  BOOL AddColumn(INT Index, ATL::CStringW &Text, INT Width, INT Format);
235 
236  int AddColumn(INT Index, LPWSTR lpText, INT Width, INT Format);
237 
238  void DeleteColumn(INT Index);
239 
240  INT AddItem(INT ItemIndex, INT IconIndex, LPCWSTR lpText, LPARAM lParam);
241 
242  HIMAGELIST GetImageList(int iImageList);
243 
244  static INT CALLBACK s_CompareFunc(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort);
245 
246  INT CompareFunc(LPARAM lParam1, LPARAM lParam2, INT iSubItem);
247 
249 
250  BOOL GetCheckState(INT item);
251 
252  VOID SetCheckState(INT item, BOOL fCheck);
253 
254  VOID CheckAll();
255 
256  PVOID GetFocusedItemData();
257 
258  BOOL SetDisplayAppType(APPLICATION_VIEW_TYPE AppType);
259 
260  BOOL SetViewMode(DWORD ViewMode);
261 
262  BOOL AddInstalledApplication(CInstalledApplicationInfo *InstAppInfo, LPVOID CallbackParam);
263 
264  BOOL AddAvailableApplication(CAvailableApplicationInfo *AvlbAppInfo, BOOL InitCheckState, LPVOID CallbackParam);
265 
266  // this function is called when parent window receiving an notification about checkstate changing
267  VOID ItemCheckStateNotify(int iItem, BOOL bCheck);
268 };
269 
271  public CUiWindow< CToolbar<> >
272 {
275 
276  WCHAR szInstallBtn[MAX_STR_LEN];
277  WCHAR szUninstallBtn[MAX_STR_LEN];
278  WCHAR szModifyBtn[MAX_STR_LEN];
279  WCHAR szSelectAll[MAX_STR_LEN];
280 
281  VOID AddImageToImageList(HIMAGELIST hImageList, UINT ImageIndex);
282 
284 
285 public:
286 
287  CMainToolbar();
288 
290 
292 
293  VOID HideButtonCaption();
294 
295  VOID ShowButtonCaption();
296 
297  DWORD GetMaxButtonsWidth() const;
298 };
299 
300 class CSearchBar :
301  public CWindow
302 {
303 public:
304  const INT m_Width;
305  const INT m_Height;
306 
307  CSearchBar();
308 
309  VOID SetText(LPCWSTR lpszText);
310 
312 
313 };
314 
315 class CComboBox :
316  public CWindow
317 {
318  // ID refers to different types of view
319  enum
320  { m_AppDisplayTypeDetails, m_AppDisplayTypeList, m_AppDisplayTypeTile };
321 
322  // string ID for different. this should correspond with the enum above.
323  const UINT m_TypeStringID[3] =
325 
326  const int m_DefaultSelectType = m_AppDisplayTypeDetails;
327 public:
328 
329  int m_Width;
330  int m_Height;
331 
332  CComboBox();
333 
335 };
336 
338  public CUiWindow<CWindowImpl<CApplicationView>>
339 {
340 private:
341  CUiPanel *m_Panel = NULL;
342  CMainToolbar *m_Toolbar = NULL;
343  CUiWindow<CComboBox> *m_ComboBox = NULL;
344  CUiWindow<CSearchBar> *m_SearchBar = NULL;
345  CAppsListView *m_ListView = NULL;
346  CAppInfoDisplay *m_AppsInfo = NULL;
347  CUiSplitPanel *m_HSplitter = NULL;
348  CMainWindow *m_MainWindow = NULL;
350 
351  BOOL ProcessWindowMessage(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam, LRESULT &theResult, DWORD dwMapId);
352 
354 
355  BOOL CreateSearchBar();
356 
357  BOOL CreateComboBox();
358 
359  BOOL CreateHSplitter();
360 
362 
363  BOOL CreateAppInfoDisplay();
364 
366 
368 public:
369 
370  CApplicationView(CMainWindow *MainWindow);
371 
372  ~CApplicationView();
373 
374  static ATL::CWndClassInfo &GetWndClassInfo();
375 
377 
378  BOOL SetDisplayAppType(APPLICATION_VIEW_TYPE AppType);
379 
380  BOOL AddInstalledApplication(CInstalledApplicationInfo *InstAppInfo, LPVOID param);
381 
382  BOOL AddAvailableApplication(CAvailableApplicationInfo *AvlbAppInfo, BOOL InitCheckState, LPVOID param);
383 
384  void CheckAll();
385 
386  PVOID GetFocusedItemData();
387 
388  int GetItemCount();
389 
390  VOID AppendTabOrderWindow(int Direction, ATL::CSimpleArray<HWND> &TabOrderList);
391 
392  // this function is called when a item of listview get focus.
393  // CallbackParam is the param passed to listview when adding the item (the one getting focus now).
394  BOOL ItemGetFocus(LPVOID CallbackParam);
395 
396  // this function is called when a item of listview is checked/unchecked
397  // CallbackParam is the param passed to listview when adding the item (the one getting focus now).
398  BOOL ItemCheckStateChanged(BOOL bChecked, LPVOID CallbackParam);
399 
400 };
struct __ScrnshotDownloadParam ScrnshotDownloadParam
ASYNC_EVENT
Definition: asyncinet.h:5
int m_Width
Definition: appview.h:329
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
GLint GLint GLsizei width
Definition: gl.h:1546
Definition: tftpd.h:59
static HICON
Definition: imagelist.c:84
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
WDF_EXTERN_C_START typedef _In_ WDFDEVICE _In_ WDFCONTEXT _In_ WDF_DMA_DIRECTION Direction
#define TRUE
Definition: types.h:120
_In_ BOOLEAN Create
Definition: pstypes.h:527
static HDC
Definition: imagelist.c:92
#define CALLBACK
Definition: compat.h:35
#define IDS_APP_DISPLAY_TILE
Definition: resource.h:125
const INT m_Width
Definition: appview.h:304
static void OnGetDispInfo(NMLVDISPINFO *plvdi)
Definition: listview.c:312
static int OnCommand(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: clipbrd.c:202
UINT_PTR WPARAM
Definition: windef.h:207
const INT m_Height
Definition: appview.h:305
DWORD m_dButtonsWidthMax
Definition: appview.h:274
int32_t INT
Definition: typedefs.h:58
static int Link(const char **args)
Definition: vfdcmd.c:2414
WPARAM wParam
Definition: combotst.c:138
_Must_inspect_result_ _In_ WDFCHILDLIST _In_ PWDF_CHILD_LIST_ITERATOR _Out_ WDFDEVICE _Inout_opt_ PWDF_CHILD_RETRIEVE_INFO Info
Definition: wdfchildlist.h:683
#define FALSE
Definition: types.h:117
static const WCHAR szText[]
Definition: dialog.c:139
const INT m_iToolbarHeight
Definition: appview.h:273
unsigned int BOOL
Definition: ntddk_ex.h:94
static HWND hwndParent
Definition: cryptui.c:300
#define IDS_APP_DISPLAY_DETAILS
Definition: resource.h:123
LONG_PTR LPARAM
Definition: windef.h:208
#define IDS_APP_DISPLAY_LIST
Definition: resource.h:124
SCRNSHOT_STATUS
Definition: appview.h:44
Status
Definition: gdiplustypes.h:24
#define LPTOOLTIPTEXT
Definition: commctrl.h:1890
int64_t LONGLONG
Definition: typedefs.h:68
static VOID OnSize(HWND hDlg, PDETAILDATA pData, INT cx, INT cy)
Definition: evtdetctl.c:484
__wchar_t WCHAR
Definition: xmlstorage.h:180
_In_ WDFCOLLECTION _In_ ULONG Index
GLfloat param
Definition: glext.h:5796
unsigned long DWORD
Definition: ntddk_ex.h:95
int m_Height
Definition: appview.h:330
ATL::CStringW DownloadFileName
Definition: appview.h:82
static const WCHAR IconIndex[]
Definition: install.c:52
struct @1586 Msg[]
void AddItem(DWORD, DWORD, DWORD, DWORD, int)
Definition: toolspage.c:25
HDC hdc
Definition: main.c:9
HIMAGELIST InitImageList(UINT StartResource, UINT EndResource, UINT Width, UINT Height, ULONG type)
Definition: misc.c:219
ATL::CStringW TempImagePath
Definition: appview.h:135
const DOCKBAR PVOID HWND hParent
Definition: tooldock.h:22
CAppsListView * lvw
Definition: appview.h:209
int ScrnshotDownloadCallback(pASYNCINET AsyncInet, ASYNC_EVENT Event, WPARAM wParam, LPARAM lParam, VOID *Extension)
Definition: appview.cpp:437
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
#define BROKENIMG_ICON_SIZE
Definition: appview.h:26
static ATOM item
Definition: dde.c:856
static INT CALLBACK CompareFunc(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort)
Definition: mainwnd.c:243
unsigned int UINT
Definition: ndis.h:50
#define NULL
Definition: types.h:112
BOOL CreateListView(PMAIN_WND_INFO Info)
Definition: listview.c:355
#define MAX_STR_LEN
Definition: defines.h:34
static VOID OnLink(HWND hDlg, ENLINK *penLink)
Definition: evtdetctl.c:350
static VOID SetWelcomeText(HWND hWnd)
Definition: gui.c:125
APPLICATION_VIEW_TYPE
Definition: appview.h:70
WCHAR * LPWSTR
Definition: xmlstorage.h:184
LONG_PTR LRESULT
Definition: windef.h:209
LPARAM lParam
Definition: combotst.c:139
_Inout_opt_ PUNICODE_STRING Extension
Definition: fltkernel.h:1092
HWND WINAPI CreateToolbar(HWND hwnd, DWORD style, UINT wID, INT nBitmaps, HINSTANCE hBMInst, UINT wBMID, LPCTBBUTTON lpButtons, INT iNumButtons)
Definition: commctrl.c:1122
char * Text
Definition: combotst.c:136