xref: /reactos/base/applications/rapps/include/gui.h (revision 4e5e72fa)
1 #pragma once
2 
3 #include "rapps.h"
4 #include "rosui.h"
5 #include "crichedit.h"
6 #include "asyncinet.h"
7 #include "appview.h"
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 #define SEARCH_TIMER_ID 'SR'
22 #define TREEVIEW_ICON_SIZE 24
23 
24 class CSideTreeView : public CUiWindow<CTreeView>
25 {
26     HIMAGELIST hImageTreeView;
27 
28   public:
29     CSideTreeView();
30 
31     HTREEITEM
32     AddItem(HTREEITEM hParent, CStringW &Text, INT Image, INT SelectedImage, LPARAM lParam);
33 
34     HTREEITEM
35     AddCategory(HTREEITEM hRootItem, UINT TextIndex, UINT IconIndex);
36 
37     HIMAGELIST
38     SetImageList();
39 
40     VOID
41     DestroyImageList();
42 
43     ~CSideTreeView();
44 };
45 
46 class CMainWindow : public CWindowImpl<CMainWindow, CWindow, CFrameWinTraits>
47 {
48     CUiPanel *m_ClientPanel = NULL;
49     CUiSplitPanel *m_VSplitter = NULL;
50 
51     CSideTreeView *m_TreeView = NULL;
52     CUiWindow<CStatusBar> *m_StatusBar = NULL;
53 
54     CApplicationView *m_ApplicationView = NULL;
55     friend class CApplicationView;
56 
57     CAppDB *m_Db;
58     CAtlList<CAppInfo *> m_Selected;
59 
60     BOOL bUpdating = FALSE;
61     BOOL m_bAppwizMode;
62     HTREEITEM hRootItemInstalled;
63 
64     CStringW szSearchPattern;
65     AppsCategories SelectedEnumType;
66 
67   public:
68     explicit CMainWindow(CAppDB *db, BOOL bAppwiz = FALSE);
69 
70     ~CMainWindow();
71 
72   private:
73     VOID
74     InitCategoriesList();
75 
76     BOOL
77     CreateStatusBar();
78     BOOL
79     CreateTreeView();
80     BOOL
81     CreateApplicationView();
82     BOOL
83     CreateVSplitter();
84     BOOL
85     CreateLayout();
86     VOID
87     LayoutCleanup();
88     BOOL
89     InitControls();
90 
91     VOID
92     OnSize(HWND hwnd, WPARAM wParam, LPARAM lParam);
93 
94     VOID
95     CheckAvailable();
96 
97     BOOL
98     RemoveSelectedAppFromRegistry();
99     BOOL
100     UninstallSelectedApp(BOOL bModify);
101 
102     BOOL
103     ProcessWindowMessage(HWND hwnd, UINT Msg, WPARAM wParam, LPARAM lParam, LRESULT &theResult, DWORD dwMapId);
104     VOID
105     ShowAboutDlg();
106     VOID
107     OnCommand(WPARAM wParam, LPARAM lParam);
108     VOID
109     UpdateStatusBarText();
110 
111     VOID
112     UpdateApplicationsList(AppsCategories EnumType, BOOL bReload = FALSE, BOOL bCheckAvailable = FALSE);
113     VOID
114     AddApplicationsToView(CAtlList<CAppInfo *> &List);
115 
116   public:
117     static ATL::CWndClassInfo &
118     GetWndClassInfo();
119 
120     HWND
121     Create();
122 
123     // this function is called when a item of application-view is checked/unchecked
124     // CallbackParam is the param passed to application-view when adding the item (the one getting focus now).
125     VOID
126     ItemCheckStateChanged(BOOL bChecked, LPVOID CallbackParam);
127 
128     // this function is called when application-view is asked to install an application
129     // if Info is not zero, this app should be installed. otherwise those checked apps should be installed
130     BOOL
131     InstallApplication(CAppInfo *Info);
132 
133     // this function is called when search text is changed
134     BOOL
135     SearchTextChanged(CStringW &SearchText);
136 
137     void
138     HandleTabOrder(int direction);
139 };
140 
141 // Main window
142 VOID
143 MainWindowLoop(CMainWindow *wnd, INT nShowCmd);
144