[RAPPS] appview displaymode support (#3008)

* [RAPPS] add function to set view-mode
* [RAPPS] move toolbar and searchbar into appview
* [RAPPS] remove settings and exit button from toolbar
* [RAPPS] add code to switch between list and tile mode
* [RAPPS] add auto-arrange for listview
* [RAPPS] adjust the minimum size of AppView
* [RAPPS] now image list of listview is stored inside the class
* [RAPPS] add list mode, and old list-mode are detail mode now
* [RAPPS] add check for unimplemented view mode
This commit is contained in:
He Yang 2020-07-29 18:50:57 +08:00 committed by Mark Jansen
parent e44c9b6630
commit 4c7bd34a47
No known key found for this signature in database
GPG key ID: B39240EE84BEAE8B
29 changed files with 729 additions and 517 deletions

View file

@ -8,6 +8,226 @@
#include "rapps.h"
#include "appview.h"
#include "gui.h"
#include <windowsx.h>
// **** CMainToolbar ****
VOID CMainToolbar::AddImageToImageList(HIMAGELIST hImageList, UINT ImageIndex)
{
HICON hImage;
if (!(hImage = (HICON)LoadImageW(hInst,
MAKEINTRESOURCE(ImageIndex),
IMAGE_ICON,
m_iToolbarHeight,
m_iToolbarHeight,
0)))
{
/* TODO: Error message */
}
ImageList_AddIcon(hImageList, hImage);
DeleteObject(hImage);
}
HIMAGELIST CMainToolbar::InitImageList()
{
HIMAGELIST hImageList;
/* Create the toolbar icon image list */
hImageList = ImageList_Create(m_iToolbarHeight,//GetSystemMetrics(SM_CXSMICON),
m_iToolbarHeight,//GetSystemMetrics(SM_CYSMICON),
ILC_MASK | GetSystemColorDepth(),
1, 1);
if (!hImageList)
{
/* TODO: Error message */
return NULL;
}
AddImageToImageList(hImageList, IDI_INSTALL);
AddImageToImageList(hImageList, IDI_UNINSTALL);
AddImageToImageList(hImageList, IDI_MODIFY);
AddImageToImageList(hImageList, IDI_CHECK_ALL);
AddImageToImageList(hImageList, IDI_REFRESH);
AddImageToImageList(hImageList, IDI_UPDATE_DB);
AddImageToImageList(hImageList, IDI_SETTINGS);
AddImageToImageList(hImageList, IDI_EXIT);
return hImageList;
}
CMainToolbar::CMainToolbar() : m_iToolbarHeight(24)
{
}
VOID CMainToolbar::OnGetDispInfo(LPTOOLTIPTEXT lpttt)
{
UINT idButton = (UINT)lpttt->hdr.idFrom;
switch (idButton)
{
case ID_EXIT:
lpttt->lpszText = MAKEINTRESOURCEW(IDS_TOOLTIP_EXIT);
break;
case ID_INSTALL:
lpttt->lpszText = MAKEINTRESOURCEW(IDS_TOOLTIP_INSTALL);
break;
case ID_UNINSTALL:
lpttt->lpszText = MAKEINTRESOURCEW(IDS_TOOLTIP_UNINSTALL);
break;
case ID_MODIFY:
lpttt->lpszText = MAKEINTRESOURCEW(IDS_TOOLTIP_MODIFY);
break;
case ID_SETTINGS:
lpttt->lpszText = MAKEINTRESOURCEW(IDS_TOOLTIP_SETTINGS);
break;
case ID_REFRESH:
lpttt->lpszText = MAKEINTRESOURCEW(IDS_TOOLTIP_REFRESH);
break;
case ID_RESETDB:
lpttt->lpszText = MAKEINTRESOURCEW(IDS_TOOLTIP_UPDATE_DB);
break;
}
}
HWND CMainToolbar::Create(HWND hwndParent)
{
/* Create buttons */
TBBUTTON Buttons[] =
{ /* iBitmap, idCommand, fsState, fsStyle, bReserved[2], dwData, iString */
{ 0, ID_TOOLBAR_INSTALL, TBSTATE_ENABLED, BTNS_BUTTON | BTNS_AUTOSIZE, { 0 }, 0, (INT_PTR)szInstallBtn },
{ 1, ID_UNINSTALL, TBSTATE_ENABLED, BTNS_BUTTON | BTNS_AUTOSIZE, { 0 }, 0, (INT_PTR)szUninstallBtn },
{ 2, ID_MODIFY, TBSTATE_ENABLED, BTNS_BUTTON | BTNS_AUTOSIZE, { 0 }, 0, (INT_PTR)szModifyBtn },
{ 3, ID_CHECK_ALL, TBSTATE_ENABLED, BTNS_BUTTON | BTNS_AUTOSIZE, { 0 }, 0, (INT_PTR)szSelectAll },
{ -1, 0, TBSTATE_ENABLED, BTNS_SEP, { 0 }, 0, 0 },
{ 4, ID_REFRESH, TBSTATE_ENABLED, BTNS_BUTTON | BTNS_AUTOSIZE, { 0 }, 0, 0 },
{ 5, ID_RESETDB, TBSTATE_ENABLED, BTNS_BUTTON | BTNS_AUTOSIZE, { 0 }, 0, 0 }
};
LoadStringW(hInst, IDS_INSTALL, szInstallBtn, _countof(szInstallBtn));
LoadStringW(hInst, IDS_UNINSTALL, szUninstallBtn, _countof(szUninstallBtn));
LoadStringW(hInst, IDS_MODIFY, szModifyBtn, _countof(szModifyBtn));
LoadStringW(hInst, IDS_SELECT_ALL, szSelectAll, _countof(szSelectAll));
m_hWnd = CreateWindowExW(0, TOOLBARCLASSNAMEW, NULL,
WS_CHILD | WS_VISIBLE | TBSTYLE_FLAT | TBSTYLE_TOOLTIPS | TBSTYLE_LIST,
0, 0, 0, 0,
hwndParent,
0, hInst, NULL);
if (!m_hWnd)
{
/* TODO: Show error message */
return FALSE;
}
SendMessageW(TB_SETEXTENDEDSTYLE, 0, TBSTYLE_EX_HIDECLIPPEDBUTTONS);
SetButtonStructSize();
/* Set image list */
HIMAGELIST hImageList = InitImageList();
if (!hImageList)
{
/* TODO: Show error message */
return FALSE;
}
ImageList_Destroy(SetImageList(hImageList));
AddButtons(_countof(Buttons), Buttons);
/* Remember ideal width to use as a max width of buttons */
SIZE size;
GetIdealSize(FALSE, &size);
m_dButtonsWidthMax = size.cx;
return m_hWnd;
}
VOID CMainToolbar::HideButtonCaption()
{
DWORD dCurrentExStyle = (DWORD)SendMessageW(TB_GETEXTENDEDSTYLE, 0, 0);
SendMessageW(TB_SETEXTENDEDSTYLE, 0, dCurrentExStyle | TBSTYLE_EX_MIXEDBUTTONS);
}
VOID CMainToolbar::ShowButtonCaption()
{
DWORD dCurrentExStyle = (DWORD)SendMessageW(TB_GETEXTENDEDSTYLE, 0, 0);
SendMessageW(TB_SETEXTENDEDSTYLE, 0, dCurrentExStyle & ~TBSTYLE_EX_MIXEDBUTTONS);
}
DWORD CMainToolbar::GetMaxButtonsWidth() const
{
return m_dButtonsWidthMax;
}
// **** CMainToolbar ****
// **** CSearchBar ****
CSearchBar::CSearchBar() : m_Width(180), m_Height(22)
{
}
VOID CSearchBar::SetText(LPCWSTR lpszText)
{
SendMessageW(SB_SETTEXT, SBT_NOBORDERS, (LPARAM)lpszText);
}
HWND CSearchBar::Create(HWND hwndParent)
{
ATL::CStringW szBuf;
m_hWnd = CreateWindowExW(WS_EX_CLIENTEDGE, L"Edit", NULL,
WS_CHILD | WS_VISIBLE | ES_LEFT | ES_AUTOHSCROLL,
0, 0, m_Width, m_Height,
hwndParent, (HMENU)NULL,
hInst, 0);
SendMessageW(WM_SETFONT, (WPARAM)GetStockObject(DEFAULT_GUI_FONT), 0);
szBuf.LoadStringW(IDS_SEARCH_TEXT);
SetWindowTextW(szBuf);
return m_hWnd;
}
// **** CSearchBar ****
// **** CComboBox ****
CComboBox::CComboBox() : m_Width(80), m_Height(22)
{
}
HWND CComboBox::Create(HWND hwndParent)
{
m_hWnd = CreateWindowW(WC_COMBOBOX, L"",
CBS_DROPDOWNLIST | CBS_HASSTRINGS | WS_CHILD | WS_OVERLAPPED | WS_VISIBLE,
0, 0, m_Width, m_Height, hwndParent, NULL, 0,
NULL);
SendMessageW(WM_SETFONT, (WPARAM)GetStockObject(DEFAULT_GUI_FONT), 0);
for (int i = 0; i < (int)_countof(m_TypeStringID); i++)
{
ATL::CStringW szBuf;
szBuf.LoadStringW(m_TypeStringID[i]);
SendMessageW(CB_ADDSTRING, 0, (LPARAM)(LPCWSTR)szBuf);
}
SendMessageW(CB_SETCURSEL, m_DefaultSelectType, 0); // select the first item
return m_hWnd;
}
// **** CComboBox ****
// **** CAppRichEdit ****
@ -1025,7 +1245,7 @@ INT CAppsListView::CompareFunc(LPARAM lParam1, LPARAM lParam2, INT iSubItem)
HWND CAppsListView::Create(HWND hwndParent)
{
RECT r = { 205, 28, 465, 250 };
DWORD style = WS_CHILD | WS_VISIBLE | LVS_SORTASCENDING | LVS_REPORT | LVS_SINGLESEL | LVS_SHOWSELALWAYS;
DWORD style = WS_CHILD | WS_VISIBLE | LVS_SORTASCENDING | LVS_REPORT | LVS_SINGLESEL | LVS_SHOWSELALWAYS | LVS_AUTOARRANGE;
HWND hwnd = CListView::Create(hwndParent, r, NULL, style, WS_EX_CLIENTEDGE);
@ -1034,11 +1254,14 @@ HWND CAppsListView::Create(HWND hwndParent)
SetCheckboxesVisible(FALSE);
}
HIMAGELIST hImageListView = ImageList_Create(LISTVIEW_ICON_SIZE,
m_hImageListView = ImageList_Create(LISTVIEW_ICON_SIZE,
LISTVIEW_ICON_SIZE,
GetSystemColorDepth() | ILC_MASK,
0, 1);
SetImageList(hImageListView, LVSIL_SMALL);
// currently, this two Imagelist is the same one.
SetImageList(m_hImageListView, LVSIL_SMALL);
SetImageList(m_hImageListView, LVSIL_NORMAL);
return hwnd;
}
@ -1083,10 +1306,10 @@ PVOID CAppsListView::GetFocusedItemData()
return (PVOID)GetItemData(item);
}
BOOL CAppsListView::SetDisplayMode(APPLICATION_VIEW_MODE Mode)
BOOL CAppsListView::SetDisplayAppType(APPLICATION_VIEW_TYPE AppType)
{
if (!DeleteAllItems()) return FALSE;
ApplicationViewMode = Mode;
ApplicationViewType = AppType;
bIsAscending = TRUE;
@ -1099,13 +1322,13 @@ BOOL CAppsListView::SetDisplayMode(APPLICATION_VIEW_MODE Mode)
DeleteColumn(--ColumnCount);
}
ImageList_RemoveAll(GetImageList(LVSIL_SMALL));
ImageList_RemoveAll(m_hImageListView);
// add new columns
ATL::CStringW szText;
switch (Mode)
switch (AppType)
{
case ApplicationViewInstalledApps:
case AppViewTypeInstalledApps:
/* Add columns to ListView */
szText.LoadStringW(IDS_APP_NAME);
@ -1121,7 +1344,7 @@ BOOL CAppsListView::SetDisplayMode(APPLICATION_VIEW_MODE Mode)
SetCheckboxesVisible(FALSE);
break;
case ApplicationViewAvailableApps:
case AppViewTypeAvailableApps:
/* Add columns to ListView */
szText.LoadStringW(IDS_APP_NAME);
@ -1137,7 +1360,7 @@ BOOL CAppsListView::SetDisplayMode(APPLICATION_VIEW_MODE Mode)
SetCheckboxesVisible(TRUE);
break;
case ApplicationViewEmpty:
case AppViewTypeEmpty:
default:
break;
}
@ -1146,16 +1369,21 @@ BOOL CAppsListView::SetDisplayMode(APPLICATION_VIEW_MODE Mode)
return TRUE;
}
BOOL CAppsListView::SetViewMode(DWORD ViewMode)
{
return SendMessage(LVM_SETVIEW, (WPARAM)ViewMode, 0) == 1;
}
BOOL CAppsListView::AddInstalledApplication(CInstalledApplicationInfo *InstAppInfo, LPVOID CallbackParam)
{
if (ApplicationViewMode != ApplicationViewInstalledApps)
if (ApplicationViewType != AppViewTypeInstalledApps)
{
return FALSE;
}
HICON hIcon = (HICON)LoadIconW(hInst, MAKEINTRESOURCEW(IDI_MAIN));
HIMAGELIST hImageList = GetImageList(LVSIL_SMALL);
int IconIndex = ImageList_AddIcon(hImageList, hIcon);
int IconIndex = ImageList_AddIcon(m_hImageListView, hIcon);
DestroyIcon(hIcon);
int Index = AddItem(ItemCount, IconIndex, InstAppInfo->szDisplayName, (LPARAM)CallbackParam);
@ -1168,7 +1396,7 @@ BOOL CAppsListView::AddInstalledApplication(CInstalledApplicationInfo *InstAppIn
BOOL CAppsListView::AddAvailableApplication(CAvailableApplicationInfo *AvlbAppInfo, BOOL InitCheckState, LPVOID CallbackParam)
{
if (ApplicationViewMode != ApplicationViewAvailableApps)
if (ApplicationViewType != AppViewTypeAvailableApps)
{
return FALSE;
}
@ -1192,9 +1420,7 @@ BOOL CAppsListView::AddAvailableApplication(CAvailableApplicationInfo *AvlbAppIn
hIcon = (HICON)LoadIconW(hInst, MAKEINTRESOURCEW(IDI_MAIN));
}
HIMAGELIST hImageList = GetImageList(LVSIL_SMALL);
int IconIndex = ImageList_AddIcon(hImageList, hIcon);
int IconIndex = ImageList_AddIcon(m_hImageListView, hIcon);
DestroyIcon(hIcon);
int Index = AddItem(ItemCount, IconIndex, AvlbAppInfo->m_szName, (LPARAM)CallbackParam);
@ -1240,10 +1466,19 @@ BOOL CApplicationView::ProcessWindowMessage(HWND hwnd, UINT message, WPARAM wPar
m_Panel->m_VerticalAlignment = UiAlign_Stretch;
m_Panel->m_HorizontalAlignment = UiAlign_Stretch;
bSuccess &= CreateToolbar();
bSuccess &= CreateSearchBar();
bSuccess &= CreateComboBox();
bSuccess &= CreateHSplitter();
bSuccess &= CreateListView();
bSuccess &= CreateAppInfoDisplay();
m_Toolbar->AutoSize();
RECT rTop;
::GetWindowRect(m_Toolbar->m_hWnd, &rTop);
m_HSplitter->m_Margin.top = rTop.bottom - rTop.top;
if (!bSuccess)
{
return -1; // creation failure
@ -1316,7 +1551,7 @@ BOOL CApplicationView::ProcessWindowMessage(HWND hwnd, UINT message, WPARAM wPar
{
/* this won't do anything if the program is already installed */
if (ApplicationViewMode == ApplicationViewAvailableApps)
if (ApplicationViewType == AppViewTypeAvailableApps)
{
m_MainWindow->InstallApplication((CAvailableApplicationInfo *)m_ListView->GetItemData(Item->iItem));
}
@ -1334,6 +1569,15 @@ BOOL CApplicationView::ProcessWindowMessage(HWND hwnd, UINT message, WPARAM wPar
break;
}
}
else if (pNotifyHeader->hwndFrom == m_Toolbar->GetWindow())
{
switch (pNotifyHeader->code)
{
case TTN_GETDISPINFO:
m_Toolbar->OnGetDispInfo((LPTOOLTIPTEXT)lParam);
break;
}
}
}
break;
@ -1342,6 +1586,8 @@ BOOL CApplicationView::ProcessWindowMessage(HWND hwnd, UINT message, WPARAM wPar
/* Forward WM_SYSCOLORCHANGE to common controls */
m_ListView->SendMessageW(WM_SYSCOLORCHANGE, wParam, lParam);
m_ListView->SendMessageW(EM_SETBKGNDCOLOR, 0, GetSysColor(COLOR_BTNFACE));
m_Toolbar->SendMessageW(WM_SYSCOLORCHANGE, wParam, lParam);
m_ComboBox->SendMessageW(WM_SYSCOLORCHANGE, wParam, lParam);
}
break;
@ -1360,6 +1606,37 @@ BOOL CApplicationView::ProcessWindowMessage(HWND hwnd, UINT message, WPARAM wPar
return FALSE;
}
BOOL CApplicationView::CreateToolbar()
{
m_Toolbar = new CMainToolbar();
m_Toolbar->m_VerticalAlignment = UiAlign_LeftTop;
m_Toolbar->m_HorizontalAlignment = UiAlign_Stretch;
m_Panel->Children().Append(m_Toolbar);
return m_Toolbar->Create(m_hWnd) != NULL;
}
BOOL CApplicationView::CreateSearchBar()
{
m_SearchBar = new CUiWindow<CSearchBar>();
m_SearchBar->m_VerticalAlignment = UiAlign_LeftTop;
m_SearchBar->m_HorizontalAlignment = UiAlign_RightBtm;
m_SearchBar->m_Margin.top = 4;
m_SearchBar->m_Margin.right = TOOLBAR_PADDING;
return m_SearchBar->Create(m_Toolbar->m_hWnd) != NULL;
}
BOOL CApplicationView::CreateComboBox()
{
m_ComboBox = new CUiWindow<CComboBox>();
m_ComboBox->m_VerticalAlignment = UiAlign_LeftTop;
m_ComboBox->m_HorizontalAlignment = UiAlign_RightBtm;
m_ComboBox->m_Margin.top = 4;
return m_ComboBox->Create(m_Toolbar->m_hWnd) != NULL;
}
BOOL CApplicationView::CreateHSplitter()
{
m_HSplitter = new CUiSplitPanel();
@ -1400,6 +1677,23 @@ VOID CApplicationView::OnSize(HWND hwnd, WPARAM wParam, LPARAM lParam)
if (wParam == SIZE_MINIMIZED)
return;
/* Size tool bar */
m_Toolbar->AutoSize();
/* Automatically hide captions */
DWORD dToolbarTreshold = m_Toolbar->GetMaxButtonsWidth();
DWORD dSearchbarMargin = (LOWORD(lParam) - m_SearchBar->m_Width - m_ComboBox->m_Width - TOOLBAR_PADDING * 2);
if (dSearchbarMargin > dToolbarTreshold)
{
m_Toolbar->ShowButtonCaption();
}
else if (dSearchbarMargin < dToolbarTreshold)
{
m_Toolbar->HideButtonCaption();
}
RECT r = { 0, 0, LOWORD(lParam), HIWORD(lParam) };
HDWP hdwp = NULL;
INT count = m_Panel->CountSizableChildren();
@ -1413,37 +1707,136 @@ VOID CApplicationView::OnSize(HWND hwnd, WPARAM wParam, LPARAM lParam)
EndDeferWindowPos(hdwp);
}
}
count = m_SearchBar->CountSizableChildren();
hdwp = BeginDeferWindowPos(count);
if (hdwp)
{
hdwp = m_SearchBar->OnParentSize(r, hdwp);
if (hdwp)
{
EndDeferWindowPos(hdwp);
}
}
m_ComboBox->m_Margin.right = m_SearchBar->m_Width + m_SearchBar->m_Margin.right + TOOLBAR_PADDING;
count = m_ComboBox->CountSizableChildren();
hdwp = BeginDeferWindowPos(count);
if (hdwp)
{
hdwp = m_ComboBox->OnParentSize(r, hdwp);
if (hdwp)
{
EndDeferWindowPos(hdwp);
}
}
}
VOID CApplicationView::OnCommand(WPARAM wParam, LPARAM lParam)
{
WORD wCommand = LOWORD(wParam);
switch (wCommand)
if (lParam)
{
case ID_INSTALL:
m_MainWindow->InstallApplication((CAvailableApplicationInfo *)GetFocusedItemData());
break;
if ((HWND)lParam == m_SearchBar->GetWindow())
{
ATL::CStringW szBuf;
switch (HIWORD(wParam))
{
case EN_SETFOCUS:
{
ATL::CStringW szWndText;
case ID_UNINSTALL:
m_MainWindow->SendMessageW(WM_COMMAND, ID_UNINSTALL, 0);
break;
szBuf.LoadStringW(IDS_SEARCH_TEXT);
m_SearchBar->GetWindowTextW(szWndText);
if (szBuf == szWndText)
{
m_SearchBar->SetWindowTextW(L"");
}
}
break;
case ID_MODIFY:
m_MainWindow->SendMessageW(WM_COMMAND, ID_MODIFY, 0);
break;
case EN_KILLFOCUS:
{
m_SearchBar->GetWindowTextW(szBuf);
if (szBuf.IsEmpty())
{
szBuf.LoadStringW(IDS_SEARCH_TEXT);
m_SearchBar->SetWindowTextW(szBuf.GetString());
}
}
break;
case ID_REGREMOVE:
m_MainWindow->SendMessageW(WM_COMMAND, ID_REGREMOVE, 0);
break;
case EN_CHANGE:
{
ATL::CStringW szWndText;
case ID_REFRESH:
m_MainWindow->SendMessageW(WM_COMMAND, ID_REFRESH, 0);
break;
szBuf.LoadStringW(IDS_SEARCH_TEXT);
m_SearchBar->GetWindowTextW(szWndText);
if (szBuf == szWndText)
{
szWndText = L"";
m_MainWindow->SearchTextChanged(szWndText);
}
else
{
m_MainWindow->SearchTextChanged(szWndText);
}
}
break;
}
case ID_RESETDB:
m_MainWindow->SendMessageW(WM_COMMAND, ID_RESETDB, 0);
break;
}
else if ((HWND)lParam == m_ComboBox->GetWindow())
{
int NotifyCode = HIWORD(wParam);
switch (NotifyCode)
{
case CBN_SELCHANGE:
int CurrSelection = m_ComboBox->SendMessageW(CB_GETCURSEL);
int ViewModeList[] = { LV_VIEW_DETAILS, LV_VIEW_LIST, LV_VIEW_TILE };
ATLASSERT(CurrSelection < (int)_countof(ViewModeList));
if (!m_ListView->SetViewMode(ViewModeList[CurrSelection]))
{
MessageBoxW(L"View mode invalid or unimplemented");
}
break;
}
}
}
else
{
WORD wCommand = LOWORD(wParam);
switch (wCommand)
{
case ID_INSTALL:
m_MainWindow->InstallApplication((CAvailableApplicationInfo *)GetFocusedItemData());
break;
case ID_TOOLBAR_INSTALL:
m_MainWindow->SendMessageW(WM_COMMAND, ID_INSTALL, 0);
break;
case ID_UNINSTALL:
m_MainWindow->SendMessageW(WM_COMMAND, ID_UNINSTALL, 0);
break;
case ID_MODIFY:
m_MainWindow->SendMessageW(WM_COMMAND, ID_MODIFY, 0);
break;
case ID_REGREMOVE:
m_MainWindow->SendMessageW(WM_COMMAND, ID_REGREMOVE, 0);
break;
case ID_REFRESH:
m_MainWindow->SendMessageW(WM_COMMAND, ID_REFRESH, 0);
break;
case ID_RESETDB:
m_MainWindow->SendMessageW(WM_COMMAND, ID_RESETDB, 0);
break;
}
}
}
@ -1454,6 +1847,8 @@ CApplicationView::CApplicationView(CMainWindow *MainWindow)
CApplicationView::~CApplicationView()
{
delete m_Toolbar;
delete m_SearchBar;
delete m_ListView;
delete m_AppsInfo;
delete m_HSplitter;
@ -1492,38 +1887,55 @@ HWND CApplicationView::Create(HWND hwndParent)
return CWindowImpl::Create(hwndParent, r, L"", WS_CHILD | WS_VISIBLE | WS_CLIPCHILDREN | WS_CLIPSIBLINGS, 0, menu);
}
BOOL CApplicationView::SetDisplayMode(APPLICATION_VIEW_MODE Mode)
BOOL CApplicationView::SetDisplayAppType(APPLICATION_VIEW_TYPE AppType)
{
if (!m_ListView->SetDisplayMode(Mode))
if (!m_ListView->SetDisplayAppType(AppType))
{
return FALSE;
}
ApplicationViewMode = Mode;
ApplicationViewType = AppType;
m_AppsInfo->SetWelcomeText();
HMENU hMenu = ::GetMenu(m_hWnd);
switch (Mode)
switch (AppType)
{
case ApplicationViewEmpty:
case AppViewTypeEmpty:
default:
EnableMenuItem(hMenu, ID_REGREMOVE, MF_GRAYED);
EnableMenuItem(hMenu, ID_INSTALL, MF_GRAYED);
EnableMenuItem(hMenu, ID_UNINSTALL, MF_GRAYED);
EnableMenuItem(hMenu, ID_MODIFY, MF_GRAYED);
m_Toolbar->SendMessageW(TB_ENABLEBUTTON, ID_REGREMOVE, TRUE);
m_Toolbar->SendMessageW(TB_ENABLEBUTTON, ID_INSTALL, FALSE);
m_Toolbar->SendMessageW(TB_ENABLEBUTTON, ID_UNINSTALL, TRUE);
m_Toolbar->SendMessageW(TB_ENABLEBUTTON, ID_MODIFY, TRUE);
break;
case ApplicationViewInstalledApps:
case AppViewTypeInstalledApps:
EnableMenuItem(hMenu, ID_REGREMOVE, MF_ENABLED);
EnableMenuItem(hMenu, ID_INSTALL, MF_GRAYED);
EnableMenuItem(hMenu, ID_UNINSTALL, MF_ENABLED);
EnableMenuItem(hMenu, ID_MODIFY, MF_ENABLED);
// TODO: instead of disable these button, I would rather remove them.
m_Toolbar->SendMessageW(TB_ENABLEBUTTON, ID_REGREMOVE, TRUE);
m_Toolbar->SendMessageW(TB_ENABLEBUTTON, ID_INSTALL, FALSE);
m_Toolbar->SendMessageW(TB_ENABLEBUTTON, ID_UNINSTALL, TRUE);
m_Toolbar->SendMessageW(TB_ENABLEBUTTON, ID_MODIFY, TRUE);
break;
case ApplicationViewAvailableApps:
case AppViewTypeAvailableApps:
EnableMenuItem(hMenu, ID_REGREMOVE, MF_GRAYED);
EnableMenuItem(hMenu, ID_INSTALL, MF_ENABLED);
EnableMenuItem(hMenu, ID_UNINSTALL, MF_GRAYED);
EnableMenuItem(hMenu, ID_MODIFY, MF_GRAYED);
// TODO: instead of disable these button, I would rather remove them.
m_Toolbar->SendMessageW(TB_ENABLEBUTTON, ID_REGREMOVE, FALSE);
m_Toolbar->SendMessageW(TB_ENABLEBUTTON, ID_INSTALL, TRUE);
m_Toolbar->SendMessageW(TB_ENABLEBUTTON, ID_UNINSTALL, FALSE);
m_Toolbar->SendMessageW(TB_ENABLEBUTTON, ID_MODIFY, FALSE);
break;
}
return TRUE;
@ -1531,7 +1943,7 @@ BOOL CApplicationView::SetDisplayMode(APPLICATION_VIEW_MODE Mode)
BOOL CApplicationView::AddInstalledApplication(CInstalledApplicationInfo *InstAppInfo, LPVOID param)
{
if (ApplicationViewMode != ApplicationViewInstalledApps)
if (ApplicationViewType != AppViewTypeInstalledApps)
{
return FALSE;
}
@ -1540,7 +1952,7 @@ BOOL CApplicationView::AddInstalledApplication(CInstalledApplicationInfo *InstAp
BOOL CApplicationView::AddAvailableApplication(CAvailableApplicationInfo *AvlbAppInfo, BOOL InitCheckState, LPVOID param)
{
if (ApplicationViewMode != ApplicationViewAvailableApps)
if (ApplicationViewType != AppViewTypeAvailableApps)
{
return FALSE;
}
@ -1565,6 +1977,9 @@ int CApplicationView::GetItemCount()
VOID CApplicationView::AppendTabOrderWindow(int Direction, ATL::CSimpleArray<HWND> &TabOrderList)
{
m_Toolbar->AppendTabOrderWindow(Direction, TabOrderList);
m_ComboBox->AppendTabOrderWindow(Direction, TabOrderList);
m_SearchBar->AppendTabOrderWindow(Direction, TabOrderList);
m_ListView->AppendTabOrderWindow(Direction, TabOrderList);
m_AppsInfo->AppendTabOrderWindow(Direction, TabOrderList);
@ -1575,15 +1990,15 @@ VOID CApplicationView::AppendTabOrderWindow(int Direction, ATL::CSimpleArray<HWN
// CallbackParam is the param passed to listview when adding the item (the one getting focus now).
BOOL CApplicationView::ItemGetFocus(LPVOID CallbackParam)
{
switch (ApplicationViewMode)
switch (ApplicationViewType)
{
case ApplicationViewInstalledApps:
case AppViewTypeInstalledApps:
return m_AppsInfo->ShowInstalledAppInfo((CInstalledApplicationInfo *)CallbackParam);
case ApplicationViewAvailableApps:
case AppViewTypeAvailableApps:
return m_AppsInfo->ShowAvailableAppInfo((CAvailableApplicationInfo *)CallbackParam);
case ApplicationViewEmpty:
case AppViewTypeEmpty:
default:
m_AppsInfo->SetWelcomeText();
return FALSE;

View file

@ -32,169 +32,6 @@
#define TREEVIEW_ICON_SIZE 24
// **** CMainToolbar ****
VOID CMainToolbar::AddImageToImageList(HIMAGELIST hImageList, UINT ImageIndex)
{
HICON hImage;
if (!(hImage = (HICON)LoadImageW(hInst,
MAKEINTRESOURCE(ImageIndex),
IMAGE_ICON,
m_iToolbarHeight,
m_iToolbarHeight,
0)))
{
/* TODO: Error message */
}
ImageList_AddIcon(hImageList, hImage);
DeleteObject(hImage);
}
HIMAGELIST CMainToolbar::InitImageList()
{
HIMAGELIST hImageList;
/* Create the toolbar icon image list */
hImageList = ImageList_Create(m_iToolbarHeight,//GetSystemMetrics(SM_CXSMICON),
m_iToolbarHeight,//GetSystemMetrics(SM_CYSMICON),
ILC_MASK | GetSystemColorDepth(),
1, 1);
if (!hImageList)
{
/* TODO: Error message */
return NULL;
}
AddImageToImageList(hImageList, IDI_INSTALL);
AddImageToImageList(hImageList, IDI_UNINSTALL);
AddImageToImageList(hImageList, IDI_MODIFY);
AddImageToImageList(hImageList, IDI_CHECK_ALL);
AddImageToImageList(hImageList, IDI_REFRESH);
AddImageToImageList(hImageList, IDI_UPDATE_DB);
AddImageToImageList(hImageList, IDI_SETTINGS);
AddImageToImageList(hImageList, IDI_EXIT);
return hImageList;
}
CMainToolbar::CMainToolbar() : m_iToolbarHeight(24)
{
}
VOID CMainToolbar::OnGetDispInfo(LPTOOLTIPTEXT lpttt)
{
UINT idButton = (UINT)lpttt->hdr.idFrom;
switch (idButton)
{
case ID_EXIT:
lpttt->lpszText = MAKEINTRESOURCEW(IDS_TOOLTIP_EXIT);
break;
case ID_INSTALL:
lpttt->lpszText = MAKEINTRESOURCEW(IDS_TOOLTIP_INSTALL);
break;
case ID_UNINSTALL:
lpttt->lpszText = MAKEINTRESOURCEW(IDS_TOOLTIP_UNINSTALL);
break;
case ID_MODIFY:
lpttt->lpszText = MAKEINTRESOURCEW(IDS_TOOLTIP_MODIFY);
break;
case ID_SETTINGS:
lpttt->lpszText = MAKEINTRESOURCEW(IDS_TOOLTIP_SETTINGS);
break;
case ID_REFRESH:
lpttt->lpszText = MAKEINTRESOURCEW(IDS_TOOLTIP_REFRESH);
break;
case ID_RESETDB:
lpttt->lpszText = MAKEINTRESOURCEW(IDS_TOOLTIP_UPDATE_DB);
break;
}
}
HWND CMainToolbar::Create(HWND hwndParent)
{
/* Create buttons */
TBBUTTON Buttons[] =
{ /* iBitmap, idCommand, fsState, fsStyle, bReserved[2], dwData, iString */
{ 0, ID_INSTALL, TBSTATE_ENABLED, BTNS_BUTTON | BTNS_AUTOSIZE, { 0 }, 0, (INT_PTR)szInstallBtn },
{ 1, ID_UNINSTALL, TBSTATE_ENABLED, BTNS_BUTTON | BTNS_AUTOSIZE, { 0 }, 0, (INT_PTR)szUninstallBtn },
{ 2, ID_MODIFY, TBSTATE_ENABLED, BTNS_BUTTON | BTNS_AUTOSIZE, { 0 }, 0, (INT_PTR)szModifyBtn },
{ 3, ID_CHECK_ALL, TBSTATE_ENABLED, BTNS_BUTTON | BTNS_AUTOSIZE, { 0 }, 0, (INT_PTR)szSelectAll },
{ -1, 0, TBSTATE_ENABLED, BTNS_SEP, { 0 }, 0, 0 },
{ 4, ID_REFRESH, TBSTATE_ENABLED, BTNS_BUTTON | BTNS_AUTOSIZE, { 0 }, 0, 0 },
{ 5, ID_RESETDB, TBSTATE_ENABLED, BTNS_BUTTON | BTNS_AUTOSIZE, { 0 }, 0, 0 },
{ -1, 0, TBSTATE_ENABLED, BTNS_SEP, { 0 }, 0, 0 },
{ 6, ID_SETTINGS, TBSTATE_ENABLED, BTNS_BUTTON | BTNS_AUTOSIZE, { 0 }, 0, 0 },
{ 7, ID_EXIT, TBSTATE_ENABLED, BTNS_BUTTON | BTNS_AUTOSIZE, { 0 }, 0, 0 },
};
LoadStringW(hInst, IDS_INSTALL, szInstallBtn, _countof(szInstallBtn));
LoadStringW(hInst, IDS_UNINSTALL, szUninstallBtn, _countof(szUninstallBtn));
LoadStringW(hInst, IDS_MODIFY, szModifyBtn, _countof(szModifyBtn));
LoadStringW(hInst, IDS_SELECT_ALL, szSelectAll, _countof(szSelectAll));
m_hWnd = CreateWindowExW(0, TOOLBARCLASSNAMEW, NULL,
WS_CHILD | WS_VISIBLE | TBSTYLE_FLAT | TBSTYLE_TOOLTIPS | TBSTYLE_LIST,
0, 0, 0, 0,
hwndParent,
0, hInst, NULL);
if (!m_hWnd)
{
/* TODO: Show error message */
return FALSE;
}
SendMessageW(TB_SETEXTENDEDSTYLE, 0, TBSTYLE_EX_HIDECLIPPEDBUTTONS);
SetButtonStructSize();
/* Set image list */
HIMAGELIST hImageList = InitImageList();
if (!hImageList)
{
/* TODO: Show error message */
return FALSE;
}
ImageList_Destroy(SetImageList(hImageList));
AddButtons(_countof(Buttons), Buttons);
/* Remember ideal width to use as a max width of buttons */
SIZE size;
GetIdealSize(FALSE, &size);
m_dButtonsWidthMax = size.cx;
return m_hWnd;
}
VOID CMainToolbar::HideButtonCaption()
{
DWORD dCurrentExStyle = (DWORD)SendMessageW(TB_GETEXTENDEDSTYLE, 0, 0);
SendMessageW(TB_SETEXTENDEDSTYLE, 0, dCurrentExStyle | TBSTYLE_EX_MIXEDBUTTONS);
}
VOID CMainToolbar::ShowButtonCaption()
{
DWORD dCurrentExStyle = (DWORD)SendMessageW(TB_GETEXTENDEDSTYLE, 0, 0);
SendMessageW(TB_SETEXTENDEDSTYLE, 0, dCurrentExStyle & ~TBSTYLE_EX_MIXEDBUTTONS);
}
DWORD CMainToolbar::GetMaxButtonsWidth() const
{
return m_dButtonsWidthMax;
}
// **** CMainToolbar ****
// **** CSideTreeView ****
@ -251,39 +88,11 @@ CSideTreeView::~CSideTreeView()
// **** CSideTreeView ****
// **** CSearchBar ****
CSearchBar::CSearchBar() : m_Width(200), m_Height(22)
{
}
VOID CSearchBar::SetText(LPCWSTR lpszText)
{
SendMessageW(SB_SETTEXT, SBT_NOBORDERS, (LPARAM)lpszText);
}
HWND CSearchBar::Create(HWND hwndParent)
{
ATL::CStringW szBuf;
m_hWnd = CreateWindowExW(WS_EX_CLIENTEDGE, L"Edit", NULL,
WS_CHILD | WS_VISIBLE | ES_LEFT | ES_AUTOHSCROLL,
0, 0, m_Width, m_Height,
hwndParent, (HMENU)NULL,
hInst, 0);
SendMessageW(WM_SETFONT, (WPARAM)GetStockObject(DEFAULT_GUI_FONT), 0);
szBuf.LoadStringW(IDS_SEARCH_TEXT);
SetWindowTextW(szBuf);
return m_hWnd;
}
// **** CSearchBar ****
// **** CMainWindow ****
CMainWindow::CMainWindow() :
m_ClientPanel(NULL),
bSearchEnabled(FALSE),
SelectedEnumType(ENUM_ALL_INSTALLED)
{
}
@ -337,16 +146,6 @@ BOOL CMainWindow::CreateStatusBar()
return m_StatusBar->Create(m_hWnd, (HMENU)IDC_STATUSBAR) != NULL;
}
BOOL CMainWindow::CreateToolbar()
{
m_Toolbar = new CMainToolbar();
m_Toolbar->m_VerticalAlignment = UiAlign_LeftTop;
m_Toolbar->m_HorizontalAlignment = UiAlign_Stretch;
m_ClientPanel->Children().Append(m_Toolbar);
return m_Toolbar->Create(m_hWnd) != NULL;
}
BOOL CMainWindow::CreateTreeView()
{
m_TreeView = new CSideTreeView();
@ -375,24 +174,15 @@ BOOL CMainWindow::CreateVSplitter()
m_VSplitter->m_DynamicFirst = FALSE;
m_VSplitter->m_Horizontal = FALSE;
m_VSplitter->m_MinFirst = 0;
m_VSplitter->m_MinSecond = 320;
// TODO: m_MinSecond should be calculate dynamically instead of hard-coded
m_VSplitter->m_MinSecond = 480;
m_VSplitter->m_Pos = 240;
m_ClientPanel->Children().Append(m_VSplitter);
return m_VSplitter->Create(m_hWnd) != NULL;
}
BOOL CMainWindow::CreateSearchBar()
{
m_SearchBar = new CUiWindow<CSearchBar>();
m_SearchBar->m_VerticalAlignment = UiAlign_LeftTop;
m_SearchBar->m_HorizontalAlignment = UiAlign_RightBtm;
m_SearchBar->m_Margin.top = 4;
m_SearchBar->m_Margin.right = 6;
return m_SearchBar->Create(m_Toolbar->m_hWnd) != NULL;
}
BOOL CMainWindow::CreateLayout()
{
BOOL b = TRUE;
@ -404,8 +194,6 @@ BOOL CMainWindow::CreateLayout()
// Top level
b = b && CreateStatusBar();
b = b && CreateToolbar();
b = b && CreateSearchBar();
b = b && CreateVSplitter();
// Inside V Splitter
@ -414,19 +202,13 @@ BOOL CMainWindow::CreateLayout()
if (b)
{
RECT rTop;
RECT rBottom;
/* Size status bar */
m_StatusBar->SendMessageW(WM_SIZE, 0, 0);
/* Size tool bar */
m_Toolbar->AutoSize();
::GetWindowRect(m_Toolbar->m_hWnd, &rTop);
::GetWindowRect(m_StatusBar->m_hWnd, &rBottom);
m_VSplitter->m_Margin.top = rTop.bottom - rTop.top;
m_VSplitter->m_Margin.bottom = rBottom.bottom - rBottom.top;
}
@ -439,8 +221,6 @@ VOID CMainWindow::LayoutCleanup()
delete m_TreeView;
delete m_ApplicationView;
delete m_VSplitter;
delete m_SearchBar;
delete m_Toolbar;
delete m_StatusBar;
return;
}
@ -467,21 +247,6 @@ VOID CMainWindow::OnSize(HWND hwnd, WPARAM wParam, LPARAM lParam)
/* Size status bar */
m_StatusBar->SendMessage(WM_SIZE, 0, 0);
/* Size tool bar */
m_Toolbar->AutoSize();
/* Automatically hide captions */
DWORD dToolbarTreshold = m_Toolbar->GetMaxButtonsWidth();
DWORD dSearchbarMargin = (LOWORD(lParam) - m_SearchBar->m_Width);
if (dSearchbarMargin > dToolbarTreshold)
{
m_Toolbar->ShowButtonCaption();
}
else if (dSearchbarMargin < dToolbarTreshold)
{
m_Toolbar->HideButtonCaption();
}
RECT r = { 0, 0, LOWORD(lParam), HIWORD(lParam) };
HDWP hdwp = NULL;
@ -496,18 +261,6 @@ VOID CMainWindow::OnSize(HWND hwnd, WPARAM wParam, LPARAM lParam)
EndDeferWindowPos(hdwp);
}
}
// TODO: Sub-layouts for children of children
count = m_SearchBar->CountSizableChildren();
hdwp = BeginDeferWindowPos(count);
if (hdwp)
{
hdwp = m_SearchBar->OnParentSize(r, hdwp);
if (hdwp)
{
EndDeferWindowPos(hdwp);
}
}
}
BOOL CMainWindow::RemoveSelectedAppFromRegistry()
@ -685,11 +438,6 @@ BOOL CMainWindow::ProcessWindowMessage(HWND hwnd, UINT Msg, WPARAM wParam, LPARA
EnableMenuItem(mainMenu, ID_INSTALL, MF_GRAYED);
EnableMenuItem(mainMenu, ID_UNINSTALL, MF_ENABLED);
EnableMenuItem(mainMenu, ID_MODIFY, MF_ENABLED);
m_Toolbar->SendMessageW(TB_ENABLEBUTTON, ID_REGREMOVE, TRUE);
m_Toolbar->SendMessageW(TB_ENABLEBUTTON, ID_INSTALL, FALSE);
m_Toolbar->SendMessageW(TB_ENABLEBUTTON, ID_UNINSTALL, TRUE);
m_Toolbar->SendMessageW(TB_ENABLEBUTTON, ID_MODIFY, TRUE);
}
else
{
@ -697,18 +445,10 @@ BOOL CMainWindow::ProcessWindowMessage(HWND hwnd, UINT Msg, WPARAM wParam, LPARA
EnableMenuItem(mainMenu, ID_INSTALL, MF_ENABLED);
EnableMenuItem(mainMenu, ID_UNINSTALL, MF_GRAYED);
EnableMenuItem(mainMenu, ID_MODIFY, MF_GRAYED);
m_Toolbar->SendMessageW(TB_ENABLEBUTTON, ID_REGREMOVE, FALSE);
m_Toolbar->SendMessageW(TB_ENABLEBUTTON, ID_INSTALL, TRUE);
m_Toolbar->SendMessageW(TB_ENABLEBUTTON, ID_UNINSTALL, FALSE);
m_Toolbar->SendMessageW(TB_ENABLEBUTTON, ID_MODIFY, FALSE);
}
}
break;
case TTN_GETDISPINFO:
m_Toolbar->OnGetDispInfo((LPTOOLTIPTEXT)lParam);
break;
}
}
break;
@ -735,7 +475,6 @@ BOOL CMainWindow::ProcessWindowMessage(HWND hwnd, UINT Msg, WPARAM wParam, LPARA
/* Forward WM_SYSCOLORCHANGE to common controls */
m_ApplicationView->SendMessageW(WM_SYSCOLORCHANGE, wParam, lParam);
m_TreeView->SendMessageW(WM_SYSCOLORCHANGE, wParam, lParam);
m_Toolbar->SendMessageW(WM_SYSCOLORCHANGE, 0, 0);
}
break;
@ -743,8 +482,8 @@ BOOL CMainWindow::ProcessWindowMessage(HWND hwnd, UINT Msg, WPARAM wParam, LPARA
if (wParam == SEARCH_TIMER_ID)
{
::KillTimer(hwnd, SEARCH_TIMER_ID);
if (bSearchEnabled)
UpdateApplicationsList(-1);
UpdateApplicationsList(-1);
}
break;
}
@ -788,153 +527,89 @@ VOID CMainWindow::OnCommand(WPARAM wParam, LPARAM lParam)
{
WORD wCommand = LOWORD(wParam);
if (lParam == (LPARAM)m_SearchBar->m_hWnd)
if (!lParam)
{
ATL::CStringW szBuf;
switch (HIWORD(wParam))
switch (wCommand)
{
case EN_SETFOCUS:
{
ATL::CStringW szWndText;
case ID_SETTINGS:
CreateSettingsDlg(m_hWnd);
break;
szBuf.LoadStringW(IDS_SEARCH_TEXT);
m_SearchBar->GetWindowTextW(szWndText);
if (szBuf == szWndText)
case ID_EXIT:
PostMessageW(WM_CLOSE, 0, 0);
break;
case ID_INSTALL:
if (IsAvailableEnum(SelectedEnumType))
{
bSearchEnabled = FALSE;
m_SearchBar->SetWindowTextW(L"");
}
}
break;
ATL::CSimpleArray<CAvailableApplicationInfo> AppsList;
case EN_KILLFOCUS:
{
m_SearchBar->GetWindowTextW(szBuf);
if (szBuf.IsEmpty())
{
szBuf.LoadStringW(IDS_SEARCH_TEXT);
bSearchEnabled = FALSE;
m_SearchBar->SetWindowTextW(szBuf.GetString());
}
}
break;
// enum all selected apps
m_AvailableApps.Enum(ENUM_CAT_SELECTED, s_EnumSelectedAppForDownloadProc, (PVOID)&AppsList);
case EN_CHANGE:
{
ATL::CStringW szWndText;
if (!bSearchEnabled)
{
bSearchEnabled = TRUE;
break;
}
szBuf.LoadStringW(IDS_SEARCH_TEXT);
m_SearchBar->GetWindowTextW(szWndText);
if (szBuf == szWndText)
{
szSearchPattern.Empty();
}
else
{
szSearchPattern = szWndText;
}
DWORD dwDelay;
SystemParametersInfoW(SPI_GETMENUSHOWDELAY, 0, &dwDelay, 0);
SetTimer(SEARCH_TIMER_ID, dwDelay);
}
break;
}
return;
}
switch (wCommand)
{
case ID_SETTINGS:
CreateSettingsDlg(m_hWnd);
break;
case ID_EXIT:
PostMessageW(WM_CLOSE, 0, 0);
break;
case ID_SEARCH:
m_SearchBar->SetFocus();
break;
case ID_INSTALL:
if (IsAvailableEnum(SelectedEnumType))
{
ATL::CSimpleArray<CAvailableApplicationInfo> AppsList;
// enum all selected apps
m_AvailableApps.Enum(ENUM_CAT_SELECTED, s_EnumSelectedAppForDownloadProc, (PVOID)&AppsList);
if (AppsList.GetSize())
{
if (DownloadListOfApplications(AppsList, FALSE))
if (AppsList.GetSize())
{
m_AvailableApps.RemoveAllSelected();
UpdateApplicationsList(-1);
}
}
else
{
// use the currently focused item in application-view
CAvailableApplicationInfo *FocusedApps = (CAvailableApplicationInfo *)m_ApplicationView->GetFocusedItemData();
if (FocusedApps)
{
if (DownloadApplication(FocusedApps, FALSE))
if (DownloadListOfApplications(AppsList, FALSE))
{
m_AvailableApps.RemoveAllSelected();
UpdateApplicationsList(-1);
}
}
else
{
// TODO: in this case, Install button in toolbar (and all other places) should be disabled
// or at least popup a messagebox telling user to select/check some app first
// use the currently focused item in application-view
CAvailableApplicationInfo *FocusedApps = (CAvailableApplicationInfo *)m_ApplicationView->GetFocusedItemData();
if (FocusedApps)
{
if (DownloadApplication(FocusedApps, FALSE))
{
UpdateApplicationsList(-1);
}
}
else
{
// TODO: in this case, Install button in toolbar (and all other places) should be disabled
// or at least popup a messagebox telling user to select/check some app first
}
}
}
break;
case ID_UNINSTALL:
if (UninstallSelectedApp(FALSE))
UpdateApplicationsList(-1);
break;
case ID_MODIFY:
if (UninstallSelectedApp(TRUE))
UpdateApplicationsList(-1);
break;
case ID_REGREMOVE:
RemoveSelectedAppFromRegistry();
break;
case ID_REFRESH:
UpdateApplicationsList(-1);
break;
case ID_RESETDB:
CAvailableApps::ForceUpdateAppsDB();
UpdateApplicationsList(-1);
break;
case ID_HELP:
MessageBoxW(L"Help not implemented yet", NULL, MB_OK);
break;
case ID_ABOUT:
ShowAboutDlg();
break;
case ID_CHECK_ALL:
m_ApplicationView->CheckAll();
break;
}
break;
case ID_UNINSTALL:
if (UninstallSelectedApp(FALSE))
UpdateApplicationsList(-1);
break;
case ID_MODIFY:
if (UninstallSelectedApp(TRUE))
UpdateApplicationsList(-1);
break;
case ID_REGREMOVE:
RemoveSelectedAppFromRegistry();
break;
case ID_REFRESH:
UpdateApplicationsList(-1);
break;
case ID_RESETDB:
CAvailableApps::ForceUpdateAppsDB();
UpdateApplicationsList(-1);
break;
case ID_HELP:
MessageBoxW(L"Help not implemented yet", NULL, MB_OK);
break;
case ID_ABOUT:
ShowAboutDlg();
break;
case ID_CHECK_ALL:
m_ApplicationView->CheckAll();
break;
}
}
@ -1012,16 +687,16 @@ VOID CMainWindow::UpdateApplicationsList(INT EnumType)
m_ApplicationView->SetRedraw(FALSE);
if (IsInstalledEnum(EnumType))
{
// set the display mode of application-view. this will remove all the item in application-view too.
m_ApplicationView->SetDisplayMode(ApplicationViewInstalledApps);
// set the display type of application-view. this will remove all the item in application-view too.
m_ApplicationView->SetDisplayAppType(AppViewTypeInstalledApps);
// enum installed softwares
m_InstalledApps.Enum(EnumType, s_EnumInstalledAppProc, this);
}
else if (IsAvailableEnum(EnumType))
{
// set the display mode of application-view. this will remove all the item in application-view too.
m_ApplicationView->SetDisplayMode(ApplicationViewAvailableApps);
// set the display type of application-view. this will remove all the item in application-view too.
m_ApplicationView->SetDisplayAppType(AppViewTypeAvailableApps);
// enum available softwares
m_AvailableApps.Enum(EnumType, s_EnumAvailableAppProc, this);
@ -1136,12 +811,26 @@ BOOL CMainWindow::InstallApplication(CAvailableApplicationInfo *Info)
return FALSE;
}
BOOL CMainWindow::SearchTextChanged(ATL::CStringW &SearchText)
{
if (szSearchPattern == SearchText)
{
return FALSE;
}
szSearchPattern = SearchText;
DWORD dwDelay;
SystemParametersInfoW(SPI_GETMENUSHOWDELAY, 0, &dwDelay, 0);
SetTimer(SEARCH_TIMER_ID, dwDelay);
return TRUE;
}
void CMainWindow::HandleTabOrder(int direction)
{
ATL::CSimpleArray<HWND> TabOrderHwndList;
m_Toolbar->AppendTabOrderWindow(direction, TabOrderHwndList);
m_SearchBar->AppendTabOrderWindow(direction, TabOrderHwndList);
m_TreeView->AppendTabOrderWindow(direction, TabOrderHwndList);
m_ApplicationView->AppendTabOrderWindow(direction, TabOrderHwndList);

View file

@ -34,6 +34,8 @@ using namespace Gdiplus;
// minimum width of richedit
#define RICHEDIT_MIN_WIDTH 160
// padding between controls in toolbar
#define TOOLBAR_PADDING 6
// user-defined window message
#define WM_RAPPS_DOWNLOAD_COMPLETE (WM_USER + 1) // notify download complete. wParam is error code, and lParam is a pointer to ScrnshotDownloadParam
@ -65,11 +67,11 @@ enum SCRNSHOT_STATUS
class CMainWindow;
enum APPLICATION_VIEW_MODE
enum APPLICATION_VIEW_TYPE
{
ApplicationViewEmpty,
ApplicationViewAvailableApps,
ApplicationViewInstalledApps
AppViewTypeEmpty,
AppViewTypeAvailableApps,
AppViewTypeInstalledApps
};
typedef struct __ScrnshotDownloadParam
@ -217,7 +219,9 @@ class CAppsListView :
INT nLastHeaderID;
APPLICATION_VIEW_MODE ApplicationViewMode = ApplicationViewEmpty;
APPLICATION_VIEW_TYPE ApplicationViewType = AppViewTypeEmpty;
HIMAGELIST m_hImageListView;
public:
CAppsListView();
@ -250,7 +254,9 @@ public:
PVOID GetFocusedItemData();
BOOL SetDisplayMode(APPLICATION_VIEW_MODE Mode);
BOOL SetDisplayAppType(APPLICATION_VIEW_TYPE AppType);
BOOL SetViewMode(DWORD ViewMode);
BOOL AddInstalledApplication(CInstalledApplicationInfo *InstAppInfo, LPVOID CallbackParam);
@ -260,20 +266,95 @@ public:
VOID ItemCheckStateNotify(int iItem, BOOL bCheck);
};
class CMainToolbar :
public CUiWindow< CToolbar<> >
{
const INT m_iToolbarHeight;
DWORD m_dButtonsWidthMax;
WCHAR szInstallBtn[MAX_STR_LEN];
WCHAR szUninstallBtn[MAX_STR_LEN];
WCHAR szModifyBtn[MAX_STR_LEN];
WCHAR szSelectAll[MAX_STR_LEN];
VOID AddImageToImageList(HIMAGELIST hImageList, UINT ImageIndex);
HIMAGELIST InitImageList();
public:
CMainToolbar();
VOID OnGetDispInfo(LPTOOLTIPTEXT lpttt);
HWND Create(HWND hwndParent);
VOID HideButtonCaption();
VOID ShowButtonCaption();
DWORD GetMaxButtonsWidth() const;
};
class CSearchBar :
public CWindow
{
public:
const INT m_Width;
const INT m_Height;
CSearchBar();
VOID SetText(LPCWSTR lpszText);
HWND Create(HWND hwndParent);
};
class CComboBox :
public CWindow
{
// ID refers to different types of view
enum
{ m_AppDisplayTypeDetails, m_AppDisplayTypeList, m_AppDisplayTypeTile };
// string ID for different. this should correspond with the enum above.
const UINT m_TypeStringID[3] =
{ IDS_APP_DISPLAY_DETAILS, IDS_APP_DISPLAY_LIST, IDS_APP_DISPLAY_TILE };
const int m_DefaultSelectType = m_AppDisplayTypeDetails;
public:
int m_Width;
int m_Height;
CComboBox();
HWND Create(HWND hwndParent);
};
class CApplicationView :
public CUiWindow<CWindowImpl<CApplicationView>>
{
private:
CUiPanel *m_Panel = NULL;
CMainToolbar *m_Toolbar = NULL;
CUiWindow<CComboBox> *m_ComboBox = NULL;
CUiWindow<CSearchBar> *m_SearchBar = NULL;
CAppsListView *m_ListView = NULL;
CAppInfoDisplay *m_AppsInfo = NULL;
CUiSplitPanel *m_HSplitter = NULL;
CMainWindow *m_MainWindow = NULL;
APPLICATION_VIEW_MODE ApplicationViewMode = ApplicationViewEmpty;
APPLICATION_VIEW_TYPE ApplicationViewType = AppViewTypeEmpty;
BOOL ProcessWindowMessage(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam, LRESULT &theResult, DWORD dwMapId);
BOOL CreateToolbar();
BOOL CreateSearchBar();
BOOL CreateComboBox();
BOOL CreateHSplitter();
BOOL CreateListView();
@ -293,7 +374,7 @@ public:
HWND Create(HWND hwndParent);
BOOL SetDisplayMode(APPLICATION_VIEW_MODE Mode);
BOOL SetDisplayAppType(APPLICATION_VIEW_TYPE AppType);
BOOL AddInstalledApplication(CInstalledApplicationInfo *InstAppInfo, LPVOID param);

View file

@ -23,35 +23,6 @@
#define TREEVIEW_ICON_SIZE 24
class CMainToolbar :
public CUiWindow< CToolbar<> >
{
const INT m_iToolbarHeight;
DWORD m_dButtonsWidthMax;
WCHAR szInstallBtn[MAX_STR_LEN];
WCHAR szUninstallBtn[MAX_STR_LEN];
WCHAR szModifyBtn[MAX_STR_LEN];
WCHAR szSelectAll[MAX_STR_LEN];
VOID AddImageToImageList(HIMAGELIST hImageList, UINT ImageIndex);
HIMAGELIST InitImageList();
public:
CMainToolbar();
VOID OnGetDispInfo(LPTOOLTIPTEXT lpttt);
HWND Create(HWND hwndParent);
VOID HideButtonCaption();
VOID ShowButtonCaption();
DWORD GetMaxButtonsWidth() const;
};
class CSideTreeView :
public CUiWindow<CTreeView>
@ -72,39 +43,20 @@ public:
~CSideTreeView();
};
class CSearchBar :
public CWindow
{
public:
const INT m_Width;
const INT m_Height;
CSearchBar();
VOID SetText(LPCWSTR lpszText);
HWND Create(HWND hwndParent);
};
class CMainWindow :
public CWindowImpl<CMainWindow, CWindow, CFrameWinTraits>
{
CUiPanel *m_ClientPanel = NULL;
CUiSplitPanel *m_VSplitter = NULL;
CMainToolbar *m_Toolbar = NULL;
CSideTreeView *m_TreeView = NULL;
CUiWindow<CStatusBar> *m_StatusBar = NULL;
CApplicationView *m_ApplicationView = NULL;
CUiWindow<CSearchBar> *m_SearchBar = NULL;
CAvailableApps m_AvailableApps;
CInstalledApps m_InstalledApps;
BOOL bSearchEnabled;
BOOL bUpdating = FALSE;
ATL::CStringW szSearchPattern;
@ -120,16 +72,12 @@ private:
BOOL CreateStatusBar();
BOOL CreateToolbar();
BOOL CreateTreeView();
BOOL CreateApplicationView();
BOOL CreateVSplitter();
BOOL CreateSearchBar();
BOOL CreateLayout();
VOID LayoutCleanup();
@ -178,6 +126,10 @@ public:
// this function is called when application-view is asked to install an application
// if Info is not zero, this app should be installed. otherwise those checked apps should be installed
BOOL InstallApplication(CAvailableApplicationInfo *Info);
// this function is called when search text is changed
BOOL SearchTextChanged(ATL::CStringW &SearchText);
void HandleTabOrder(int direction);
};

View file

@ -84,6 +84,7 @@
#define ID_RESETDB 561
#define ID_CHECK_ALL 562
#define ID_SEARCH 563
#define ID_TOOLBAR_INSTALL 564
/* Strings */
#define IDS_APPTITLE 100
@ -119,7 +120,9 @@
#define IDS_MISMATCH_CERT_INFO 130
#define IDS_UNABLE_PATH 131
#define IDS_APP_AUTHORS 132
#define IDS_APP_DISPLAY_DETAILS 133
#define IDS_APP_DISPLAY_LIST 134
#define IDS_APP_DISPLAY_TILE 135
/* Tooltips */
#define IDS_TOOLTIP_INSTALL 200

View file

@ -214,6 +214,9 @@ BEGIN
IDS_SELECTEDFORINST "Selected for installation"
IDS_MISMATCH_CERT_INFO "The certificate used is unknown:\nSubject: %s\nIssuer: %s\nDo you want to continue anyway?"
IDS_UNABLE_PATH "Incorrect path format."
IDS_APP_DISPLAY_DETAILS "details"
IDS_APP_DISPLAY_LIST "list"
IDS_APP_DISPLAY_TILE "tile"
END
STRINGTABLE

View file

@ -215,6 +215,9 @@ BEGIN
IDS_SELECTEDFORINST "Selected for installation"
IDS_MISMATCH_CERT_INFO "The certificate used is unknown:\nSubject: %s\nIssuer: %s\nDo you want to continue anyway?"
IDS_UNABLE_PATH "Incorrect path format."
IDS_APP_DISPLAY_DETAILS "details"
IDS_APP_DISPLAY_LIST "list"
IDS_APP_DISPLAY_TILE "tile"
END
STRINGTABLE

View file

@ -210,6 +210,9 @@ BEGIN
IDS_SELECTEDFORINST "Zur Installation ausgewählt"
IDS_MISMATCH_CERT_INFO "The certificate used is unknown:\nSubject: %s\nIssuer: %s\nDo you want to continue anyway?"
IDS_UNABLE_PATH "Incorrect path format."
IDS_APP_DISPLAY_DETAILS "details"
IDS_APP_DISPLAY_LIST "list"
IDS_APP_DISPLAY_TILE "tile"
END
STRINGTABLE

View file

@ -210,6 +210,9 @@ BEGIN
IDS_SELECTEDFORINST "Selected for installation"
IDS_MISMATCH_CERT_INFO "The certificate used is unknown:\nSubject: %s\nIssuer: %s\nDo you want to continue anyway?"
IDS_UNABLE_PATH "Incorrect path format."
IDS_APP_DISPLAY_DETAILS "details"
IDS_APP_DISPLAY_LIST "list"
IDS_APP_DISPLAY_TILE "tile"
END
STRINGTABLE

View file

@ -213,6 +213,9 @@ BEGIN
IDS_SELECTEDFORINST "Seleccionados para instalar"
IDS_MISMATCH_CERT_INFO "El certificado que usa es desconocido:\nSujeto: %s\nEmisor: %s\n¿Quiere continuar a pesar de ello?"
IDS_UNABLE_PATH "Formato de ruta incorrecto."
IDS_APP_DISPLAY_DETAILS "details"
IDS_APP_DISPLAY_LIST "list"
IDS_APP_DISPLAY_TILE "tile"
END
STRINGTABLE

View file

@ -218,6 +218,9 @@ BEGIN
IDS_SELECTEDFORINST "Installimiseks valitud"
IDS_MISMATCH_CERT_INFO "Kasutatud sertifikaat on tundmatu:\nSubject: %s\nIssuer: %s\nKas soovid siiski jätkata?"
IDS_UNABLE_PATH "Incorrect path format."
IDS_APP_DISPLAY_DETAILS "details"
IDS_APP_DISPLAY_LIST "list"
IDS_APP_DISPLAY_TILE "tile"
END
STRINGTABLE

View file

@ -210,6 +210,9 @@ BEGIN
IDS_SELECTEDFORINST "Sélectionnées pour installation"
IDS_MISMATCH_CERT_INFO "Certificat inconnu:\nSujet: %s\nEmetteur: %s\nVoulez-vous continuer ?"
IDS_UNABLE_PATH "Format de chemin invalide."
IDS_APP_DISPLAY_DETAILS "details"
IDS_APP_DISPLAY_LIST "list"
IDS_APP_DISPLAY_TILE "tile"
END
STRINGTABLE

View file

@ -216,6 +216,9 @@ BEGIN
IDS_SELECTEDFORINST "Selected for installation"
IDS_MISMATCH_CERT_INFO "The certificate used is unknown:\nSubject: %s\nIssuer: %s\nDo you want to continue anyway?"
IDS_UNABLE_PATH "Incorrect path format."
IDS_APP_DISPLAY_DETAILS "details"
IDS_APP_DISPLAY_LIST "list"
IDS_APP_DISPLAY_TILE "tile"
END
STRINGTABLE

View file

@ -210,6 +210,9 @@ BEGIN
IDS_SELECTEDFORINST "dipilih untuk pemasangan"
IDS_MISMATCH_CERT_INFO "Sertifikat yang dipakai tidak dikenal:\nSubyek: %s\nIssuer: %s\nYakin ingin lanjut?"
IDS_UNABLE_PATH "Incorrect path format."
IDS_APP_DISPLAY_DETAILS "details"
IDS_APP_DISPLAY_LIST "list"
IDS_APP_DISPLAY_TILE "tile"
END
STRINGTABLE

View file

@ -210,6 +210,9 @@ BEGIN
IDS_SELECTEDFORINST "Selezionate per l'installazione"
IDS_MISMATCH_CERT_INFO "Il certificato in uso è sconosciuto:\nSoggetto: %s\nEmittente: %s\nVuoi continuare comunque?"
IDS_UNABLE_PATH "Incorrect path format."
IDS_APP_DISPLAY_DETAILS "details"
IDS_APP_DISPLAY_LIST "list"
IDS_APP_DISPLAY_TILE "tile"
END
STRINGTABLE

View file

@ -210,6 +210,9 @@ BEGIN
IDS_SELECTEDFORINST "インストールを選択済み"
IDS_MISMATCH_CERT_INFO "証明書は未知のものです:\nSubject: %s\nIssuer: %s\nそれでも続けますか"
IDS_UNABLE_PATH "Incorrect path format."
IDS_APP_DISPLAY_DETAILS "details"
IDS_APP_DISPLAY_LIST "list"
IDS_APP_DISPLAY_TILE "tile"
END
STRINGTABLE

View file

@ -210,6 +210,9 @@ BEGIN
IDS_SELECTEDFORINST "Selected for installation"
IDS_MISMATCH_CERT_INFO "The certificate used is unknown:\nSubject: %s\nIssuer: %s\nDo you want to continue anyway?"
IDS_UNABLE_PATH "Incorrect path format."
IDS_APP_DISPLAY_DETAILS "details"
IDS_APP_DISPLAY_LIST "list"
IDS_APP_DISPLAY_TILE "tile"
END
STRINGTABLE

View file

@ -218,6 +218,9 @@ BEGIN
IDS_SELECTEDFORINST "Wybrane do instalacji"
IDS_MISMATCH_CERT_INFO "Użyty certyfikat jest nieznany:\nSubject: %s\nIssuer: %s\nCzy chcesz mimo to kontynuować?"
IDS_UNABLE_PATH "Niepoprawny format ścieżki."
IDS_APP_DISPLAY_DETAILS "details"
IDS_APP_DISPLAY_LIST "list"
IDS_APP_DISPLAY_TILE "tile"
END
STRINGTABLE

View file

@ -212,6 +212,9 @@ BEGIN
IDS_SELECTEDFORINST "Selected for installation"
IDS_MISMATCH_CERT_INFO "The certificate used is unknown:\nSubject: %s\nIssuer: %s\nDo you want to continue anyway?"
IDS_UNABLE_PATH "Incorrect path format."
IDS_APP_DISPLAY_DETAILS "details"
IDS_APP_DISPLAY_LIST "list"
IDS_APP_DISPLAY_TILE "tile"
END
STRINGTABLE

View file

@ -212,6 +212,9 @@ BEGIN
IDS_SELECTEDFORINST "Seleccionados para instalação"
IDS_MISMATCH_CERT_INFO "O certificado usado é desconhecido:\nAssunto: %s\nEmissor: %s\nDeseja continuar mesmo assim?"
IDS_UNABLE_PATH "Formato de caminho incorrecto."
IDS_APP_DISPLAY_DETAILS "details"
IDS_APP_DISPLAY_LIST "list"
IDS_APP_DISPLAY_TILE "tile"
END
STRINGTABLE

View file

@ -219,6 +219,9 @@ BEGIN
IDS_SELECTEDFORINST "Selectate pentru instalare"
IDS_MISMATCH_CERT_INFO "Certificatul în uz este necunoscut:\nSubiect: %s\nEmitent: %s\nVreți să continuați oricum?"
IDS_UNABLE_PATH "Incorrect path format."
IDS_APP_DISPLAY_DETAILS "details"
IDS_APP_DISPLAY_LIST "list"
IDS_APP_DISPLAY_TILE "tile"
END
STRINGTABLE

View file

@ -210,6 +210,9 @@ BEGIN
IDS_SELECTEDFORINST "Выбрано для установки"
IDS_MISMATCH_CERT_INFO "Используемый сертификат не опознан:\nНазначение: %s\nВыдан: %s\nВы хотите продолжить в любом случае?"
IDS_UNABLE_PATH "Incorrect path format."
IDS_APP_DISPLAY_DETAILS "details"
IDS_APP_DISPLAY_LIST "list"
IDS_APP_DISPLAY_TILE "tile"
END
STRINGTABLE

View file

@ -215,6 +215,9 @@ BEGIN
IDS_SELECTEDFORINST "Selected for installation"
IDS_MISMATCH_CERT_INFO "The certificate used is unknown:\nSubject: %s\nIssuer: %s\nDo you want to continue anyway?"
IDS_UNABLE_PATH "Incorrect path format."
IDS_APP_DISPLAY_DETAILS "details"
IDS_APP_DISPLAY_LIST "list"
IDS_APP_DISPLAY_TILE "tile"
END
STRINGTABLE

View file

@ -214,6 +214,9 @@ BEGIN
IDS_SELECTEDFORINST "Selected for installation"
IDS_MISMATCH_CERT_INFO "The certificate used is unknown:\nSubject: %s\nIssuer: %s\nDo you want to continue anyway?"
IDS_UNABLE_PATH "Incorrect path format."
IDS_APP_DISPLAY_DETAILS "details"
IDS_APP_DISPLAY_LIST "list"
IDS_APP_DISPLAY_TILE "tile"
END
STRINGTABLE

View file

@ -217,6 +217,9 @@ BEGIN
IDS_SELECTEDFORINST "Selected for installation"
IDS_MISMATCH_CERT_INFO "The certificate used is unknown:\nSubject: %s\nIssuer: %s\nDo you want to continue anyway?"
IDS_UNABLE_PATH "Incorrect path format."
IDS_APP_DISPLAY_DETAILS "details"
IDS_APP_DISPLAY_LIST "list"
IDS_APP_DISPLAY_TILE "tile"
END
STRINGTABLE

View file

@ -212,6 +212,9 @@ BEGIN
IDS_SELECTEDFORINST "Kurulum için seçildi"
IDS_MISMATCH_CERT_INFO "Kullanılan sertifika bilimmiyor:\nAçıklama: %s\nSertifikayı Veren: %s\nYine de sürdürmek istiyor musunuz?"
IDS_UNABLE_PATH "Incorrect path format."
IDS_APP_DISPLAY_DETAILS "details"
IDS_APP_DISPLAY_LIST "list"
IDS_APP_DISPLAY_TILE "tile"
END
STRINGTABLE

View file

@ -218,6 +218,9 @@ BEGIN
IDS_SELECTEDFORINST "Обрані для встановлення"
IDS_MISMATCH_CERT_INFO "The certificate used is unknown:\nSubject: %s\nIssuer: %s\nDo you want to continue anyway?"
IDS_UNABLE_PATH "Incorrect path format."
IDS_APP_DISPLAY_DETAILS "details"
IDS_APP_DISPLAY_LIST "list"
IDS_APP_DISPLAY_TILE "tile"
END
STRINGTABLE

View file

@ -213,6 +213,9 @@ BEGIN
IDS_SELECTEDFORINST "选中以安装"
IDS_MISMATCH_CERT_INFO "所使用的证书未知:\n主题: %s\n发行方: %s\n您是否仍然想继续"
IDS_UNABLE_PATH "不正确的URL格式。"
IDS_APP_DISPLAY_DETAILS "细节"
IDS_APP_DISPLAY_LIST "列表"
IDS_APP_DISPLAY_TILE "卡片"
END
STRINGTABLE

View file

@ -212,6 +212,9 @@ BEGIN
IDS_SELECTEDFORINST "選中以安裝"
IDS_MISMATCH_CERT_INFO "所使用的證書未知:\n主題%s\n發行方%s\n您是否仍然想繼續"
IDS_UNABLE_PATH "不正確的URL格式。"
IDS_APP_DISPLAY_DETAILS "details"
IDS_APP_DISPLAY_LIST "list"
IDS_APP_DISPLAY_TILE "tile"
END
STRINGTABLE