ReactOS  0.4.15-dev-1201-gb2cf5a4
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;
215 
216  INT ItemCount = 0;
217  INT CheckedItemCount = 0;
218  INT ColumnCount = 0;
219 
221 
223 
225 
226 public:
227  CAppsListView();
228 
229  VOID SetCheckboxesVisible(BOOL bIsVisible);
230 
231  VOID ColumnClick(LPNMLISTVIEW pnmv);
232 
233  BOOL AddColumn(INT Index, ATL::CStringW &Text, INT Width, INT Format);
234 
235  int AddColumn(INT Index, LPWSTR lpText, INT Width, INT Format);
236 
237  void DeleteColumn(INT Index);
238 
239  INT AddItem(INT ItemIndex, INT IconIndex, LPCWSTR lpText, LPARAM lParam);
240 
241  HIMAGELIST GetImageList(int iImageList);
242 
243  static INT CALLBACK s_CompareFunc(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort);
244 
245  INT CompareFunc(LPARAM lParam1, LPARAM lParam2, INT iSubItem);
246 
248 
249  BOOL GetCheckState(INT item);
250 
251  VOID SetCheckState(INT item, BOOL fCheck);
252 
253  VOID CheckAll();
254 
255  PVOID GetFocusedItemData();
256 
257  BOOL SetDisplayAppType(APPLICATION_VIEW_TYPE AppType);
258 
259  BOOL SetViewMode(DWORD ViewMode);
260 
261  BOOL AddInstalledApplication(CInstalledApplicationInfo *InstAppInfo, LPVOID CallbackParam);
262 
263  BOOL AddAvailableApplication(CAvailableApplicationInfo *AvlbAppInfo, BOOL InitCheckState, LPVOID CallbackParam);
264 
265  // this function is called when parent window receiving an notification about checkstate changing
266  VOID ItemCheckStateNotify(int iItem, BOOL bCheck);
267 };
268 
270  public CUiWindow< CToolbar<> >
271 {
274 
275  WCHAR szInstallBtn[MAX_STR_LEN];
276  WCHAR szUninstallBtn[MAX_STR_LEN];
277  WCHAR szModifyBtn[MAX_STR_LEN];
278  WCHAR szSelectAll[MAX_STR_LEN];
279 
280  VOID AddImageToImageList(HIMAGELIST hImageList, UINT ImageIndex);
281 
283 
284 public:
285 
286  CMainToolbar();
287 
289 
291 
292  VOID HideButtonCaption();
293 
294  VOID ShowButtonCaption();
295 
296  DWORD GetMaxButtonsWidth() const;
297 };
298 
299 class CSearchBar :
300  public CWindow
301 {
302 public:
303  const INT m_Width;
304  const INT m_Height;
305 
306  CSearchBar();
307 
308  VOID SetText(LPCWSTR lpszText);
309 
311 
312 };
313 
314 class CComboBox :
315  public CWindow
316 {
317  // ID refers to different types of view
318  enum
319  { m_AppDisplayTypeDetails, m_AppDisplayTypeList, m_AppDisplayTypeTile };
320 
321  // string ID for different. this should correspond with the enum above.
322  const UINT m_TypeStringID[3] =
324 
325  const int m_DefaultSelectType = m_AppDisplayTypeDetails;
326 public:
327 
328  int m_Width;
329  int m_Height;
330 
331  CComboBox();
332 
334 };
335 
337  public CUiWindow<CWindowImpl<CApplicationView>>
338 {
339 private:
340  CUiPanel *m_Panel = NULL;
341  CMainToolbar *m_Toolbar = NULL;
342  CUiWindow<CComboBox> *m_ComboBox = NULL;
343  CUiWindow<CSearchBar> *m_SearchBar = NULL;
344  CAppsListView *m_ListView = NULL;
345  CAppInfoDisplay *m_AppsInfo = NULL;
346  CUiSplitPanel *m_HSplitter = NULL;
347  CMainWindow *m_MainWindow = NULL;
349 
350  BOOL ProcessWindowMessage(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam, LRESULT &theResult, DWORD dwMapId);
351 
353 
354  BOOL CreateSearchBar();
355 
356  BOOL CreateComboBox();
357 
358  BOOL CreateHSplitter();
359 
361 
362  BOOL CreateAppInfoDisplay();
363 
365 
367 public:
368 
369  CApplicationView(CMainWindow *MainWindow);
370 
371  ~CApplicationView();
372 
373  static ATL::CWndClassInfo &GetWndClassInfo();
374 
376 
377  BOOL SetDisplayAppType(APPLICATION_VIEW_TYPE AppType);
378 
379  BOOL AddInstalledApplication(CInstalledApplicationInfo *InstAppInfo, LPVOID param);
380 
381  BOOL AddAvailableApplication(CAvailableApplicationInfo *AvlbAppInfo, BOOL InitCheckState, LPVOID param);
382 
383  void CheckAll();
384 
385  PVOID GetFocusedItemData();
386 
387  int GetItemCount();
388 
389  VOID AppendTabOrderWindow(int Direction, ATL::CSimpleArray<HWND> &TabOrderList);
390 
391  // this function is called when a item of listview get focus.
392  // CallbackParam is the param passed to listview when adding the item (the one getting focus now).
393  BOOL ItemGetFocus(LPVOID CallbackParam);
394 
395  // this function is called when a item of listview is checked/unchecked
396  // CallbackParam is the param passed to listview when adding the item (the one getting focus now).
397  BOOL ItemCheckStateChanged(BOOL bChecked, LPVOID CallbackParam);
398 
399 };
struct __ScrnshotDownloadParam ScrnshotDownloadParam
ASYNC_EVENT
Definition: asyncinet.h:5
int m_Width
Definition: appview.h:328
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
INT nLastHeaderID
Definition: appview.h:220
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
#define TRUE
Definition: types.h:120
_In_ BOOLEAN Create
Definition: pstypes.h:519
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:303
static void OnGetDispInfo(NMLVDISPINFO *plvdi)
Definition: listview.c:312
static int OnCommand(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: clipbrd.c:202
struct @1610 Msg[]
UINT_PTR WPARAM
Definition: windef.h:207
const INT m_Height
Definition: appview.h:304
DWORD m_dButtonsWidthMax
Definition: appview.h:273
int32_t INT
Definition: typedefs.h:58
static int Link(const char **args)
Definition: vfdcmd.c:2414
WPARAM wParam
Definition: combotst.c:138
struct TraceInfo Info
#define FALSE
Definition: types.h:117
static const WCHAR szText[]
Definition: dialog.c:139
const INT m_iToolbarHeight
Definition: appview.h:272
unsigned int BOOL
Definition: ntddk_ex.h:94
smooth NULL
Definition: ftsmooth.c:416
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
#define LPTOOLTIPTEXT
Definition: commctrl.h:1886
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
HIMAGELIST m_hImageListView
Definition: appview.h:224
BOOL bHasCheckboxes
Definition: appview.h:214
_Inout_ PSIZE_T _In_opt_ PMDLX _In_ MM_ROTATE_DIRECTION Direction
Definition: mmfuncs.h:772
GLfloat param
Definition: glext.h:5796
static const UCHAR Index[8]
Definition: usbohci.c:18
unsigned long DWORD
Definition: ntddk_ex.h:95
int m_Height
Definition: appview.h:329
ATL::CStringW DownloadFileName
Definition: appview.h:82
static const WCHAR IconIndex[]
Definition: install.c:52
void AddItem(DWORD, DWORD, DWORD, DWORD, int)
Definition: toolspage.c:25
Status
Definition: gdiplustypes.h:24
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
BOOL CreateListView(PMAIN_WND_INFO Info)
Definition: listview.c:355
#define MAX_STR_LEN
Definition: defines.h:35
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