Author: dquintana
Date: Wed Apr 29 00:07:54 2015
New Revision: 67474
URL:
http://svn.reactos.org/svn/reactos?rev=67474&view=rev
Log:
[RAPPS_NEW]
Continue the work converting the UI to using ATL-wrapped windows. CORE-9593
[RSHELL]
[EXPLORER]
Fixup two class declarations to work with the rosctrls.h changes.
Added:
trunk/reactos/base/applications/rapps_new/crichedit.h (with props)
Removed:
trunk/reactos/base/applications/rapps_new/toolbar.cpp
trunk/reactos/base/applications/rapps_new/treeview.cpp
Modified:
trunk/reactos/base/applications/rapps_new/CMakeLists.txt
trunk/reactos/base/applications/rapps_new/gui.cpp
trunk/reactos/base/applications/rapps_new/rapps.h
trunk/reactos/base/applications/rapps_new/winmain.cpp
trunk/reactos/base/shell/explorer/taskswnd.cpp
trunk/reactos/base/shell/explorer/trayntfy.cpp
trunk/reactos/base/shell/rshell/CMenuToolbars.cpp
trunk/reactos/base/shell/rshell/CMenuToolbars.h
trunk/reactos/include/reactos/rosctrls.h
Modified: trunk/reactos/base/applications/rapps_new/CMakeLists.txt
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/rapps_ne…
==============================================================================
--- trunk/reactos/base/applications/rapps_new/CMakeLists.txt [iso-8859-1] (original)
+++ trunk/reactos/base/applications/rapps_new/CMakeLists.txt [iso-8859-1] Wed Apr 29
00:07:54 2015
@@ -13,8 +13,6 @@
loaddlg.cpp
misc.cpp
settingsdlg.cpp
- toolbar.cpp
- treeview.cpp
winmain.cpp
rapps.h)
Added: trunk/reactos/base/applications/rapps_new/crichedit.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/rapps_ne…
==============================================================================
--- trunk/reactos/base/applications/rapps_new/crichedit.h (added)
+++ trunk/reactos/base/applications/rapps_new/crichedit.h [iso-8859-1] Wed Apr 29 00:07:54
2015
@@ -0,0 +1,98 @@
+#pragma once
+
+class CRichEdit :
+ public CWindow
+{
+public:
+ VOID SetRangeFormatting(LONG Start, LONG End, DWORD dwEffects)
+ {
+ CHARFORMAT2 CharFormat;
+
+ SendMessageW(EM_SETSEL, Start, End);
+
+ ZeroMemory(&CharFormat, sizeof(CHARFORMAT2));
+
+ CharFormat.cbSize = sizeof(CHARFORMAT2);
+ CharFormat.dwMask = dwEffects;
+ CharFormat.dwEffects = dwEffects;
+
+ SendMessageW(EM_SETCHARFORMAT, SCF_WORD | SCF_SELECTION, (LPARAM)
&CharFormat);
+
+ SendMessageW(EM_SETSEL, End, End + 1);
+ }
+
+ LONG GetTextLen(VOID)
+ {
+ GETTEXTLENGTHEX TxtLenStruct;
+
+ TxtLenStruct.flags = GTL_NUMCHARS;
+ TxtLenStruct.codepage = 1200;
+
+ return (LONG) SendMessageW(EM_GETTEXTLENGTHEX, (WPARAM) &TxtLenStruct, 0);
+ }
+
+ /*
+ * Insert text (without cleaning old text)
+ * Supported effects:
+ * - CFM_BOLD
+ * - CFM_ITALIC
+ * - CFM_UNDERLINE
+ * - CFM_LINK
+ */
+ VOID InsertText(LPCWSTR lpszText, DWORD dwEffects)
+ {
+ SETTEXTEX SetText;
+ LONG Len = GetTextLen();
+
+ /* Insert new text */
+ SetText.flags = ST_SELECTION;
+ SetText.codepage = 1200;
+
+ SendMessageW(EM_SETTEXTEX, (WPARAM) &SetText, (LPARAM) lpszText);
+
+ SetRangeFormatting(Len, Len + wcslen(lpszText),
+ (dwEffects == CFM_LINK) ? (PathIsURLW(lpszText) ? dwEffects : 0) :
dwEffects);
+ }
+
+ /*
+ * Clear old text and add new
+ */
+ VOID SetText(LPCWSTR lpszText, DWORD dwEffects)
+ {
+ SetWindowTextW(L"");
+ InsertText(lpszText, dwEffects);
+ }
+
+ HWND Create(HWND hwndParent)
+ {
+ // TODO: FreeLibrary when the window is destroyed
+ LoadLibraryW(L"riched20.dll");
+
+ m_hWnd = CreateWindowExW(0,
+ L"RichEdit20W",
+ NULL,
+ WS_CHILD | WS_VISIBLE | ES_MULTILINE |
+ ES_LEFT | ES_READONLY,
+ 205, 28, 465, 100,
+ hwndParent,
+ NULL,
+ _AtlBaseModule.GetModuleInstance(),
+ NULL);
+
+ if (m_hWnd)
+ {
+ SendMessageW(EM_SETBKGNDCOLOR, 0, GetSysColor(COLOR_BTNFACE));
+ SendMessageW(WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0);
+ SendMessageW(EM_SETEVENTMASK, 0, ENM_LINK | ENM_MOUSEEVENTS);
+ SendMessageW(EM_SHOWSCROLLBAR, SB_VERT, TRUE);
+ }
+
+ return m_hWnd;
+ }
+
+public:
+ virtual VOID OnLink(ENLINK *Link)
+ {
+ }
+
+};
Propchange: trunk/reactos/base/applications/rapps_new/crichedit.h
------------------------------------------------------------------------------
svn:eol-style = native
Modified: trunk/reactos/base/applications/rapps_new/gui.cpp
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/rapps_ne…
==============================================================================
--- trunk/reactos/base/applications/rapps_new/gui.cpp [iso-8859-1] (original)
+++ trunk/reactos/base/applications/rapps_new/gui.cpp [iso-8859-1] Wed Apr 29 00:07:54
2015
@@ -17,155 +17,167 @@
#include <rosctrls.h>
#include "rosui.h"
-
-PWSTR pLink = NULL;
+#include "crichedit.h"
+
+#define SEARCH_TIMER_ID 'SR'
HWND hListView = NULL;
-VOID UpdateApplicationsList(INT EnumType);
-VOID MainWndOnCommand(HWND hwnd, WPARAM wParam, LPARAM lParam);
-BOOL IsSelectedNodeInstalled(void);
-VOID FreeInstalledAppList(VOID);
-
-class CUiRichEdit :
- public CUiWindow< CWindowImplBaseT<CWindow> >
+class CMainToolbar :
+ public CUiWindow< CToolbar<> >
{
- BOOL ProcessWindowMessage(HWND hwnd, UINT Msg, WPARAM wParam, LPARAM lParam,
LRESULT& theResult, DWORD dwMapId)
- {
- theResult = 0;
- return FALSE;
+#define TOOLBAR_HEIGHT 24
+
+ WCHAR szInstallBtn[MAX_STR_LEN];
+ WCHAR szUninstallBtn[MAX_STR_LEN];
+ WCHAR szModifyBtn[MAX_STR_LEN];
+
+ VOID AddImageToImageList(HIMAGELIST hImageList, UINT ImageIndex)
+ {
+ HICON hImage;
+
+ if (!(hImage = (HICON) LoadImage(hInst,
+ MAKEINTRESOURCE(ImageIndex),
+ IMAGE_ICON,
+ TOOLBAR_HEIGHT,
+ TOOLBAR_HEIGHT,
+ 0)))
+ {
+ /* TODO: Error message */
+ }
+
+ ImageList_AddIcon(hImageList, hImage);
+ DeleteObject(hImage);
+ }
+
+ HIMAGELIST InitImageList(VOID)
+ {
+ HIMAGELIST hImageList;
+
+ /* Create the toolbar icon image list */
+ hImageList = ImageList_Create(TOOLBAR_HEIGHT,//GetSystemMetrics(SM_CXSMICON),
+ TOOLBAR_HEIGHT,//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_REFRESH);
+ AddImageToImageList(hImageList, IDI_SETTINGS);
+ AddImageToImageList(hImageList, IDI_EXIT);
+
+ return hImageList;
}
public:
- VOID SetRangeFormatting(LONG Start, LONG End, DWORD dwEffects)
- {
- CHARFORMAT2 CharFormat;
-
- SendMessageW(EM_SETSEL, Start, End);
-
- ZeroMemory(&CharFormat, sizeof(CHARFORMAT2));
-
- CharFormat.cbSize = sizeof(CHARFORMAT2);
- CharFormat.dwMask = dwEffects;
- CharFormat.dwEffects = dwEffects;
-
- SendMessageW(EM_SETCHARFORMAT, SCF_WORD | SCF_SELECTION, (LPARAM)
&CharFormat);
-
- SendMessageW(EM_SETSEL, End, End + 1);
- }
-
- LONG GetTextLen(VOID)
- {
- GETTEXTLENGTHEX TxtLenStruct;
-
- TxtLenStruct.flags = GTL_NUMCHARS;
- TxtLenStruct.codepage = 1200;
-
- return (LONG) SendMessageW(EM_GETTEXTLENGTHEX, (WPARAM) &TxtLenStruct, 0);
- }
-
- /*
- * Insert text (without cleaning old text)
- * Supported effects:
- * - CFM_BOLD
- * - CFM_ITALIC
- * - CFM_UNDERLINE
- * - CFM_LINK
- */
- VOID InsertText(LPCWSTR lpszText, DWORD dwEffects)
- {
- SETTEXTEX SetText;
- LONG Len = GetTextLen();
-
- /* Insert new text */
- SetText.flags = ST_SELECTION;
- SetText.codepage = 1200;
-
- SendMessageW(EM_SETTEXTEX, (WPARAM) &SetText, (LPARAM) lpszText);
-
- SetRangeFormatting(Len, Len + wcslen(lpszText),
- (dwEffects == CFM_LINK) ? (PathIsURLW(lpszText) ? dwEffects : 0) :
dwEffects);
- }
-
- /*
- * Clear old text and add new
- */
- VOID SetText(LPCWSTR lpszText, DWORD dwEffects)
- {
- SetWindowTextW(L"");
- InsertText(lpszText, dwEffects);
- }
-
- VOID OnLink(ENLINK *Link)
- {
- switch (Link->msg)
- {
- case WM_LBUTTONUP:
- case WM_RBUTTONUP:
- {
- if (pLink) HeapFree(GetProcessHeap(), 0, pLink);
-
- pLink = (PWSTR) HeapAlloc(GetProcessHeap(), 0,
- (max(Link->chrg.cpMin, Link->chrg.cpMax) -
- min(Link->chrg.cpMin, Link->chrg.cpMax) + 1) * sizeof(WCHAR));
- if (!pLink)
- {
- /* TODO: Error message */
- return;
- }
-
- SendMessageW(EM_SETSEL, Link->chrg.cpMin, Link->chrg.cpMax);
- SendMessageW(EM_GETSELTEXT, 0, (LPARAM) pLink);
-
- ShowPopupMenu(m_hWnd, IDR_LINKMENU, -1);
- }
- break;
+ VOID OnGetDispInfo(LPTOOLTIPTEXT lpttt)
+ {
+ UINT idButton = (UINT) lpttt->hdr.idFrom;
+
+ switch (idButton)
+ {
+ case ID_EXIT:
+ lpttt->lpszText = MAKEINTRESOURCE(IDS_TOOLTIP_EXIT);
+ break;
+
+ case ID_INSTALL:
+ lpttt->lpszText = MAKEINTRESOURCE(IDS_TOOLTIP_INSTALL);
+ break;
+
+ case ID_UNINSTALL:
+ lpttt->lpszText = MAKEINTRESOURCE(IDS_TOOLTIP_UNINSTALL);
+ break;
+
+ case ID_MODIFY:
+ lpttt->lpszText = MAKEINTRESOURCE(IDS_TOOLTIP_MODIFY);
+ break;
+
+ case ID_SETTINGS:
+ lpttt->lpszText = MAKEINTRESOURCE(IDS_TOOLTIP_SETTINGS);
+ break;
+
+ case ID_REFRESH:
+ lpttt->lpszText = MAKEINTRESOURCE(IDS_TOOLTIP_REFRESH);
+ break;
}
}
HWND Create(HWND hwndParent)
{
- LoadLibraryW(L"riched20.dll");
-
- HWND hwnd = CreateWindowExW(0,
- L"RichEdit20W",
+ static 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 },
+ { 5, 0, TBSTATE_ENABLED, BTNS_SEP, { 0 }, 0, 0 },
+ { 3, ID_REFRESH, TBSTATE_ENABLED, BTNS_BUTTON | BTNS_AUTOSIZE, { 0 }, 0, 0
},
+ { 5, 0, TBSTATE_ENABLED, BTNS_SEP, { 0 }, 0, 0 },
+ { 4, ID_SETTINGS, TBSTATE_ENABLED, BTNS_BUTTON | BTNS_AUTOSIZE, { 0 }, 0, 0
},
+ { 5, ID_EXIT, TBSTATE_ENABLED, BTNS_BUTTON | BTNS_AUTOSIZE, { 0 }, 0, 0 }
+ };
+
+ INT NumButtons = sizeof(Buttons) / sizeof(Buttons[0]);
+ HIMAGELIST hImageList;
+
+ LoadStringW(hInst, IDS_INSTALL, szInstallBtn, sizeof(szInstallBtn) /
sizeof(WCHAR));
+ LoadStringW(hInst, IDS_UNINSTALL, szUninstallBtn, sizeof(szUninstallBtn) /
sizeof(WCHAR));
+ LoadStringW(hInst, IDS_MODIFY, szModifyBtn, sizeof(szModifyBtn) /
sizeof(WCHAR));
+
+ m_hWnd = CreateWindowExW(0,
+ TOOLBARCLASSNAMEW,
NULL,
- WS_CHILD | WS_VISIBLE | ES_MULTILINE |
- ES_LEFT | ES_READONLY,
- 205, 28, 465, 100,
+ WS_CHILD | WS_VISIBLE | TBSTYLE_FLAT | TBSTYLE_TOOLTIPS | TBSTYLE_LIST,
+ 0, 0, 0, 0,
hwndParent,
- NULL,
+ 0,
hInst,
NULL);
-
- SubclassWindow(hwnd);
-
- if (hwnd)
- {
- SendMessageW(EM_SETBKGNDCOLOR, 0, GetSysColor(COLOR_BTNFACE));
- SendMessageW(WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0);
- SendMessageW(EM_SETEVENTMASK, 0, ENM_LINK | ENM_MOUSEEVENTS);
- SendMessageW(EM_SHOWSCROLLBAR, SB_VERT, TRUE);
- }
-
- return hwnd;
- }
-
+
+ if (!m_hWnd)
+ {
+ /* TODO: Show error message */
+ return FALSE;
+ }
+
+ SendMessageW(TB_SETEXTENDEDSTYLE, 0, TBSTYLE_EX_HIDECLIPPEDBUTTONS);
+ SetButtonStructSize();
+
+ hImageList = InitImageList();
+
+ if (!hImageList)
+ {
+ /* TODO: Show error message */
+ return FALSE;
+ }
+
+ ImageList_Destroy((HIMAGELIST) SetImageList(hImageList));
+
+ AddButtons(NumButtons, Buttons);
+
+ return m_hWnd;
+ }
};
-class CUiListView :
+class CAppsListView :
public CUiWindow<CListView>
{
struct SortContext
{
- CUiListView * lvw;
+ CAppsListView * lvw;
int iSubItem;
};
public:
BOOL bAscending;
- CUiListView()
+ CAppsListView()
{
bAscending = TRUE;
}
@@ -281,26 +293,38 @@
};
-class CUiStatusBar :
- public CUiWindow<CStatusBar>
-{
-};
-
-class CUiMainWindow :
- public CWindowImpl<CUiMainWindow, CWindow, CFrameWinTraits>
+class CMainWindow :
+ public CWindowImpl<CMainWindow, CWindow, CFrameWinTraits>
{
CUiPanel * m_ClientPanel;
-
- CUiWindow<> * m_Toolbar;
- CUiWindow<> * m_TreeView;
- CUiWindow<> * m_SearchBar;
- CUiStatusBar * m_StatusBar;
- CUiListView * m_ListView;
- CUiRichEdit * m_RichEdit;
CUiSplitPanel * m_VSplitter;
CUiSplitPanel * m_HSplitter;
+ CMainToolbar * m_Toolbar;
+ CAppsListView * m_ListView;
+
+ CUiWindow<CTreeView> * m_TreeView;
+ CUiWindow<CStatusBar> * m_StatusBar;
+ CUiWindow<CRichEdit> * m_RichEdit;
+
+ CUiWindow<> * m_SearchBar;
+
HIMAGELIST hImageTreeView;
+
+ PWSTR pLink;
+
+ BOOL SearchEnabled;
+
+public:
+ CMainWindow() :
+ m_ClientPanel(NULL),
+ hImageTreeView(NULL),
+ pLink(NULL),
+ SearchEnabled(TRUE)
+ {
+ }
+
+private:
VOID InitApplicationsList(VOID)
{
@@ -337,7 +361,7 @@
LoadStringW(hInst, TextIndex, szText, _countof(szText));
- return TreeViewAddItem(hRootItem, szText, Index, Index, TextIndex);
+ return m_TreeView->AddItem(hRootItem, szText, Index, Index, TextIndex);
}
VOID InitCategoriesList(VOID)
@@ -365,17 +389,15 @@
AddCategory(hRootItem2, IDS_CAT_LIBS, IDI_CAT_LIBS);
AddCategory(hRootItem2, IDS_CAT_OTHER, IDI_CAT_OTHER);
- (VOID) TreeView_SetImageList(hTreeView, hImageTreeView, TVSIL_NORMAL);
-
- (VOID) TreeView_Expand(hTreeView, hRootItem2, TVE_EXPAND);
- (VOID) TreeView_Expand(hTreeView, hRootItem1, TVE_EXPAND);
-
- (VOID) TreeView_SelectItem(hTreeView, hRootItem1);
+ m_TreeView->SetImageList(hImageTreeView, TVSIL_NORMAL);
+ m_TreeView->Expand(hRootItem2, TVE_EXPAND);
+ m_TreeView->Expand(hRootItem1, TVE_EXPAND);
+ m_TreeView->SelectItem(hRootItem1);
}
BOOL CreateStatusBar()
{
- m_StatusBar = new CUiStatusBar();
+ m_StatusBar = new CUiWindow<CStatusBar>();
m_StatusBar->m_VerticalAlignment = UiAlign_RightBtm;
m_StatusBar->m_HorizontalAlignment = UiAlign_Stretch;
m_ClientPanel->Children().Append(m_StatusBar);
@@ -385,35 +407,27 @@
BOOL CreateToolbar()
{
- // TODO: WRAPPER
- m_Toolbar = new CUiWindow<>();
+ m_Toolbar = new CMainToolbar();
m_Toolbar->m_VerticalAlignment = UiAlign_LeftTop;
m_Toolbar->m_HorizontalAlignment = UiAlign_Stretch;
m_ClientPanel->Children().Append(m_Toolbar);
-
- CreateToolBar(m_hWnd);
- m_Toolbar->m_hWnd = hToolBar;
-
- return hToolBar != NULL;
+
+ return m_Toolbar->Create(m_hWnd) != NULL;
}
BOOL CreateTreeView()
{
- // TODO: WRAPPER
- m_TreeView = new CUiWindow<>();
+ m_TreeView = new CUiWindow<CTreeView>();
m_TreeView->m_VerticalAlignment = UiAlign_Stretch;
m_TreeView->m_HorizontalAlignment = UiAlign_Stretch;
m_VSplitter->First().Append(m_TreeView);
-
- ::CreateTreeView(m_hWnd);
- m_TreeView->m_hWnd = hTreeView;
-
- return hTreeView != NULL;
+
+ return m_TreeView->Create(m_hWnd) != NULL;
}
BOOL CreateListView()
{
- m_ListView = new CUiListView();
+ m_ListView = new CAppsListView();
m_ListView->m_VerticalAlignment = UiAlign_Stretch;
m_ListView->m_HorizontalAlignment = UiAlign_Stretch;
m_HSplitter->First().Append(m_ListView);
@@ -424,7 +438,7 @@
BOOL CreateRichEdit()
{
- m_RichEdit = new CUiRichEdit();
+ m_RichEdit = new CUiWindow<CRichEdit>();
m_RichEdit->m_VerticalAlignment = UiAlign_Stretch;
m_RichEdit->m_HorizontalAlignment = UiAlign_Stretch;
m_HSplitter->Second().Append(m_RichEdit);
@@ -473,7 +487,7 @@
m_SearchBar->m_Margin.right = 6;
//m_ClientPanel->Children().Append(m_SearchBar);
- hSearchBar = CreateWindowExW(WS_EX_CLIENTEDGE,
+ HWND hwnd = CreateWindowExW(WS_EX_CLIENTEDGE,
L"Edit",
NULL,
WS_CHILD | WS_VISIBLE | ES_LEFT | ES_AUTOHSCROLL,
@@ -486,14 +500,14 @@
hInst,
0);
- m_SearchBar->m_hWnd = hSearchBar;
+ m_SearchBar->m_hWnd = hwnd;
m_SearchBar->SendMessageW(WM_SETFONT, (WPARAM)
GetStockObject(DEFAULT_GUI_FONT), 0);
LoadStringW(hInst, IDS_SEARCH_TEXT, szBuf, sizeof(szBuf) / sizeof(WCHAR));
m_SearchBar->SetWindowTextW(szBuf);
- return hSearchBar != NULL;
+ return hwnd != NULL;
}
BOOL CreateLayout()
@@ -527,15 +541,13 @@
m_StatusBar->SendMessage(WM_SIZE, 0, 0);
/* Size tool bar */
- SendMessage(hToolBar, TB_AUTOSIZE, 0, 0);
+ m_Toolbar->AutoSize();
::GetWindowRect(m_Toolbar->m_hWnd, &rTop);
::GetWindowRect(m_StatusBar->m_hWnd, &rBottom);
- m_VSplitter->m_Margin.left = 3;
- m_VSplitter->m_Margin.right = 3;
- m_VSplitter->m_Margin.top = rTop.bottom - rTop.top + 3;
- m_VSplitter->m_Margin.bottom = rBottom.bottom-rBottom.top + 3;
+ m_VSplitter->m_Margin.top = rTop.bottom - rTop.top;
+ m_VSplitter->m_Margin.bottom = rBottom.bottom-rBottom.top;
}
return b;
@@ -573,7 +585,7 @@
m_StatusBar->SendMessage(WM_SIZE, 0, 0);
/* Size tool bar */
- SendMessage(hToolBar, TB_AUTOSIZE, 0, 0);
+ m_Toolbar->AutoSize();
RECT r = { 0, 0, LOWORD(lParam), HIWORD(lParam) };
@@ -624,7 +636,7 @@
}
case WM_COMMAND:
- MainWndOnCommand(hwnd, wParam, lParam);
+ OnCommand(wParam, lParam);
break;
case WM_NOTIFY:
@@ -635,7 +647,7 @@
{
case TVN_SELCHANGED:
{
- if (data->hwndFrom == hTreeView)
+ if (data->hwndFrom == m_TreeView->m_hWnd)
{
switch (((LPNMTREEVIEW) lParam)->itemNew.lParam)
{
@@ -733,10 +745,10 @@
EnableMenuItem(lvwMenu, ID_UNINSTALL, MF_ENABLED);
EnableMenuItem(lvwMenu, ID_MODIFY, MF_ENABLED);
- SendMessage(hToolBar, TB_ENABLEBUTTON, ID_REGREMOVE, TRUE);
- SendMessage(hToolBar, TB_ENABLEBUTTON, ID_INSTALL, FALSE);
- SendMessage(hToolBar, TB_ENABLEBUTTON, ID_UNINSTALL, TRUE);
- SendMessage(hToolBar, TB_ENABLEBUTTON, ID_MODIFY, TRUE);
+ m_Toolbar->SendMessage(TB_ENABLEBUTTON, ID_REGREMOVE, TRUE);
+ m_Toolbar->SendMessage(TB_ENABLEBUTTON, ID_INSTALL, FALSE);
+ m_Toolbar->SendMessage(TB_ENABLEBUTTON, ID_UNINSTALL, TRUE);
+ m_Toolbar->SendMessage(TB_ENABLEBUTTON, ID_MODIFY, TRUE);
}
else
{
@@ -750,10 +762,10 @@
EnableMenuItem(lvwMenu, ID_UNINSTALL, MF_GRAYED);
EnableMenuItem(lvwMenu, ID_MODIFY, MF_GRAYED);
- SendMessage(hToolBar, TB_ENABLEBUTTON, ID_REGREMOVE, FALSE);
- SendMessage(hToolBar, TB_ENABLEBUTTON, ID_INSTALL, TRUE);
- SendMessage(hToolBar, TB_ENABLEBUTTON, ID_UNINSTALL, FALSE);
- SendMessage(hToolBar, TB_ENABLEBUTTON, ID_MODIFY, FALSE);
+ m_Toolbar->SendMessage(TB_ENABLEBUTTON, ID_REGREMOVE, FALSE);
+ m_Toolbar->SendMessage(TB_ENABLEBUTTON, ID_INSTALL, TRUE);
+ m_Toolbar->SendMessage(TB_ENABLEBUTTON, ID_UNINSTALL, FALSE);
+ m_Toolbar->SendMessage(TB_ENABLEBUTTON, ID_MODIFY, FALSE);
}
}
break;
@@ -827,11 +839,11 @@
break;
case EN_LINK:
- m_RichEdit->OnLink((ENLINK*) lParam);
+ OnLink((ENLINK*) lParam);
break;
case TTN_GETDISPINFO:
- ToolBarOnGetDispInfo((LPTOOLTIPTEXT) lParam);
+ m_Toolbar->OnGetDispInfo((LPTOOLTIPTEXT) lParam);
break;
}
}
@@ -858,24 +870,351 @@
{
/* Forward WM_SYSCOLORCHANGE to common controls */
m_ListView->SendMessage(WM_SYSCOLORCHANGE, 0, 0);
- SendMessage(hTreeView, WM_SYSCOLORCHANGE, 0, 0);
- SendMessage(hToolBar, WM_SYSCOLORCHANGE, 0, 0);
+ m_TreeView->SendMessage(WM_SYSCOLORCHANGE, 0, 0);
+ m_Toolbar->SendMessage(WM_SYSCOLORCHANGE, 0, 0);
m_ListView->SendMessage(EM_SETBKGNDCOLOR, 0, GetSysColor(COLOR_BTNFACE));
}
break;
+
+ case WM_TIMER:
+ if (wParam == SEARCH_TIMER_ID)
+ {
+ ::KillTimer(hwnd, SEARCH_TIMER_ID);
+ UpdateApplicationsList(-1);
+ }
+ break;
}
return FALSE;
}
+ virtual VOID OnLink(ENLINK *Link)
+ {
+ switch (Link->msg)
+ {
+ case WM_LBUTTONUP:
+ case WM_RBUTTONUP:
+ {
+ if (pLink) HeapFree(GetProcessHeap(), 0, pLink);
+
+ pLink = (PWSTR) HeapAlloc(GetProcessHeap(), 0,
+ (max(Link->chrg.cpMin, Link->chrg.cpMax) -
+ min(Link->chrg.cpMin, Link->chrg.cpMax) + 1) * sizeof(WCHAR));
+ if (!pLink)
+ {
+ /* TODO: Error message */
+ return;
+ }
+
+ m_RichEdit->SendMessageW(EM_SETSEL, Link->chrg.cpMin,
Link->chrg.cpMax);
+ m_RichEdit->SendMessageW(EM_GETSELTEXT, 0, (LPARAM) pLink);
+
+ ShowPopupMenu(m_RichEdit->m_hWnd, IDR_LINKMENU, -1);
+ }
+ break;
+ }
+ }
+
+ BOOL IsSelectedNodeInstalled(void)
+ {
+ HTREEITEM hSelectedItem = m_TreeView->GetSelection();
+ TV_ITEM tItem;
+
+ tItem.mask = TVIF_PARAM | TVIF_HANDLE;
+ tItem.hItem = hSelectedItem;
+ m_TreeView->GetItem(&tItem);
+ switch (tItem.lParam)
+ {
+ case IDS_INSTALLED:
+ case IDS_APPLICATIONS:
+ case IDS_UPDATES:
+ return TRUE;
+ default:
+ return FALSE;
+ }
+ }
+
+ VOID OnCommand(WPARAM wParam, LPARAM lParam)
+ {
+ WORD wCommand = LOWORD(wParam);
+
+ if (lParam == (LPARAM) m_SearchBar->m_hWnd)
+ {
+ WCHAR szBuf[MAX_STR_LEN];
+
+ switch (HIWORD(wParam))
+ {
+ case EN_SETFOCUS:
+ {
+ WCHAR szWndText[MAX_STR_LEN];
+
+ LoadStringW(hInst, IDS_SEARCH_TEXT, szBuf, _countof(szBuf));
+ GetWindowTextW(m_SearchBar->m_hWnd, szWndText, MAX_STR_LEN);
+ if (wcscmp(szBuf, szWndText) == 0)
+ {
+ SearchEnabled = FALSE;
+ m_SearchBar->SetWindowTextW(L"");
+ }
+ }
+ break;
+
+ case EN_KILLFOCUS:
+ {
+ GetWindowTextW(m_SearchBar->m_hWnd, szBuf, MAX_STR_LEN);
+ if (wcslen(szBuf) < 1)
+ {
+ LoadStringW(hInst, IDS_SEARCH_TEXT, szBuf, _countof(szBuf));
+ SearchEnabled = FALSE;
+ m_SearchBar->SetWindowTextW(szBuf);
+ }
+ }
+ break;
+
+ case EN_CHANGE:
+ {
+ WCHAR szWndText[MAX_STR_LEN];
+
+ if (!SearchEnabled)
+ {
+ SearchEnabled = TRUE;
+ break;
+ }
+
+ LoadStringW(hInst, IDS_SEARCH_TEXT, szBuf, _countof(szBuf));
+ GetWindowTextW(m_SearchBar->m_hWnd, szWndText, MAX_STR_LEN);
+ if (wcscmp(szBuf, szWndText) != 0)
+ {
+ StringCbCopy(szSearchPattern, sizeof(szSearchPattern),
+ szWndText);
+ }
+ else
+ {
+ szSearchPattern[0] = UNICODE_NULL;
+ }
+
+ DWORD dwDelay;
+ SystemParametersInfo(SPI_GETMENUSHOWDELAY, 0, &dwDelay, 0);
+ SetTimer(SEARCH_TIMER_ID, dwDelay);
+ }
+ break;
+ }
+
+ return;
+ }
+
+ switch (wCommand)
+ {
+ case ID_OPEN_LINK:
+ ShellExecuteW(m_hWnd, L"open", pLink, NULL, NULL,
SW_SHOWNOACTIVATE);
+ HeapFree(GetProcessHeap(), 0, pLink);
+ break;
+
+ case ID_COPY_LINK:
+ CopyTextToClipboard(pLink);
+ HeapFree(GetProcessHeap(), 0, pLink);
+ break;
+
+ case ID_SETTINGS:
+ CreateSettingsDlg(m_hWnd);
+ break;
+
+ case ID_EXIT:
+ PostMessageW(m_hWnd, WM_CLOSE, 0, 0);
+ break;
+
+ case ID_INSTALL:
+ if (DownloadApplication(-1))
+ /* TODO: Implement install dialog
+ * if (InstallApplication(-1))
+ */
+ UpdateApplicationsList(-1);
+ break;
+
+ case ID_UNINSTALL:
+ if (UninstallApplication(-1, FALSE))
+ UpdateApplicationsList(-1);
+ break;
+
+ case ID_MODIFY:
+ if (UninstallApplication(-1, TRUE))
+ UpdateApplicationsList(-1);
+ break;
+
+ case ID_REGREMOVE:
+ RemoveAppFromRegistry(-1);
+ break;
+
+ case ID_REFRESH:
+ UpdateApplicationsList(-1);
+ break;
+
+ case ID_RESETDB:
+ UpdateAppsDB();
+ UpdateApplicationsList(-1);
+ break;
+
+ case ID_HELP:
+ MessageBoxW(m_hWnd, L"Help not implemented yet", NULL, MB_OK);
+ break;
+
+ case ID_ABOUT:
+ ShowAboutDialog();
+ break;
+ }
+ }
+
+ VOID FreeInstalledAppList(VOID)
+ {
+ INT Count = ListView_GetItemCount(hListView) - 1;
+ PINSTALLED_INFO Info;
+
+ while (Count >= 0)
+ {
+ Info = (PINSTALLED_INFO) ListViewGetlParam(Count);
+ if (Info)
+ {
+ RegCloseKey(Info->hSubKey);
+ HeapFree(GetProcessHeap(), 0, Info);
+ }
+ Count--;
+ }
+ }
+
+ static BOOL SearchPatternMatch(PCWSTR szHaystack, PCWSTR szNeedle)
+ {
+ if (!*szNeedle)
+ return TRUE;
+ /* TODO: Improve pattern search beyond a simple case-insensitive substring
search. */
+ return StrStrIW(szHaystack, szNeedle) != NULL;
+ }
+
+ static BOOL CALLBACK s_EnumInstalledAppProc(INT ItemIndex, LPWSTR lpName,
PINSTALLED_INFO Info)
+ {
+ PINSTALLED_INFO ItemInfo;
+ WCHAR szText[MAX_PATH];
+ INT Index;
+
+ if (!SearchPatternMatch(lpName, szSearchPattern))
+ {
+ RegCloseKey(Info->hSubKey);
+ return TRUE;
+ }
+
+ ItemInfo = (PINSTALLED_INFO) HeapAlloc(GetProcessHeap(), 0,
sizeof(INSTALLED_INFO));
+ if (!ItemInfo)
+ {
+ RegCloseKey(Info->hSubKey);
+ return FALSE;
+ }
+
+ RtlCopyMemory(ItemInfo, Info, sizeof(INSTALLED_INFO));
+
+ Index = ListViewAddItem(ItemIndex, 0, lpName, (LPARAM) ItemInfo);
+
+ /* Get version info */
+ GetApplicationString(ItemInfo->hSubKey, L"DisplayVersion", szText);
+ ListView_SetItemText(hListView, Index, 1, szText);
+
+ /* Get comments */
+ GetApplicationString(ItemInfo->hSubKey, L"Comments", szText);
+ ListView_SetItemText(hListView, Index, 2, szText);
+
+ return TRUE;
+ }
+
+ static BOOL CALLBACK s_EnumAvailableAppProc(PAPPLICATION_INFO Info)
+ {
+ INT Index;
+
+ if (!SearchPatternMatch(Info->szName, szSearchPattern) &&
+ !SearchPatternMatch(Info->szDesc, szSearchPattern))
+ {
+ return TRUE;
+ }
+
+ /* Only add a ListView entry if...
+ - no RegName was supplied (so we cannot determine whether the application is
installed or not) or
+ - a RegName was supplied and the application is not installed
+ */
+ if (!*Info->szRegName || (!IsInstalledApplication(Info->szRegName, FALSE)
&& !IsInstalledApplication(Info->szRegName, TRUE)))
+ {
+ Index = ListViewAddItem(Info->Category, 0, Info->szName, (LPARAM)
Info);
+
+ ListView_SetItemText(hListView, Index, 1, Info->szVersion);
+ ListView_SetItemText(hListView, Index, 2, Info->szDesc);
+ }
+
+ return TRUE;
+ }
+
+ VOID UpdateApplicationsList(INT EnumType)
+ {
+ WCHAR szBuffer1[MAX_STR_LEN], szBuffer2[MAX_STR_LEN];
+ HICON hIcon;
+ HIMAGELIST hImageListView;
+
+ m_ListView->SendMessage(WM_SETREDRAW, FALSE, 0);
+
+ if (EnumType == -1) EnumType = SelectedEnumType;
+
+ if (IS_INSTALLED_ENUM(SelectedEnumType))
+ FreeInstalledAppList();
+
+ (VOID) ListView_DeleteAllItems(hListView);
+
+ /* Create image list */
+ hImageListView = ImageList_Create(LISTVIEW_ICON_SIZE,
+ LISTVIEW_ICON_SIZE,
+ GetSystemColorDepth() | ILC_MASK,
+ 0, 1);
+
+ hIcon = (HICON) LoadImage(hInst,
+ MAKEINTRESOURCE(IDI_MAIN),
+ IMAGE_ICON,
+ LISTVIEW_ICON_SIZE,
+ LISTVIEW_ICON_SIZE,
+ LR_CREATEDIBSECTION);
+
+ ImageList_AddIcon(hImageListView, hIcon);
+ DestroyIcon(hIcon);
+
+ if (IS_INSTALLED_ENUM(EnumType))
+ {
+ /* Enum installed applications and updates */
+ EnumInstalledApplications(EnumType, TRUE, s_EnumInstalledAppProc);
+ EnumInstalledApplications(EnumType, FALSE, s_EnumInstalledAppProc);
+ }
+ else if (IS_AVAILABLE_ENUM(EnumType))
+ {
+ /* Enum availabled applications */
+ EnumAvailableApplications(EnumType, s_EnumAvailableAppProc);
+ }
+
+ /* Set image list for ListView */
+ hImageListView = ListView_SetImageList(hListView, hImageListView, LVSIL_SMALL);
+
+ /* Destroy old image list */
+ if (hImageListView)
+ ImageList_Destroy(hImageListView);
+
+ SelectedEnumType = EnumType;
+
+ LoadStringW(hInst, IDS_APPS_COUNT, szBuffer2, _countof(szBuffer2));
+ StringCbPrintfW(szBuffer1, sizeof(szBuffer1),
+ szBuffer2,
+ ListView_GetItemCount(hListView));
+ SetStatusBarText(szBuffer1);
+
+ SetWelcomeText();
+
+ /* set automatic column width for program names if the list is not empty */
+ if (ListView_GetItemCount(hListView) > 0)
+ ListView_SetColumnWidth(hListView, 0, LVSCW_AUTOSIZE);
+
+ SendMessage(hListView, WM_SETREDRAW, TRUE, 0);
+ }
+
public:
- CUiMainWindow() :
- m_ClientPanel(NULL),
- hImageTreeView(NULL)
- {
-
- }
-
static ATL::CWndClassInfo& GetWndClassInfo()
{
DWORD csStyle = CS_VREDRAW |CS_HREDRAW;
@@ -910,32 +1249,36 @@
return CWindowImpl::Create(NULL, r, szWindowName, WS_OVERLAPPEDWINDOW |
WS_CLIPCHILDREN | WS_CLIPSIBLINGS, WS_EX_WINDOWEDGE);
}
- CUiStatusBar * GetStatusBar()
+ CStatusBar * GetStatusBar()
{
return m_StatusBar;
}
- CUiListView * GetListView()
+ CAppsListView * GetListView()
{
return m_ListView;
}
- CUiRichEdit * GetRichEdit()
+ CRichEdit * GetRichEdit()
{
return m_RichEdit;
}
};
-CUiMainWindow * g_MainWindow;
+CMainWindow * g_MainWindow;
HWND CreateMainWindow()
{
- g_MainWindow = new CUiMainWindow();
+ g_MainWindow = new CMainWindow();
return g_MainWindow->Create();
}
DWORD_PTR ListViewGetlParam(INT item)
{
+ if (item < 0)
+ {
+ item = g_MainWindow->GetListView()->GetSelectionMark();
+ }
return g_MainWindow->GetListView()->GetItemData(item);
}
Modified: trunk/reactos/base/applications/rapps_new/rapps.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/rapps_ne…
==============================================================================
--- trunk/reactos/base/applications/rapps_new/rapps.h [iso-8859-1] (original)
+++ trunk/reactos/base/applications/rapps_new/rapps.h [iso-8859-1] Wed Apr 29 00:07:54
2015
@@ -175,17 +175,6 @@
/* settingsdlg.c */
VOID CreateSettingsDlg(HWND hwnd);
-/* toolbar.c */
-extern HWND hToolBar;
-extern HWND hSearchBar;
-BOOL CreateToolBar(HWND hwnd);
-VOID ToolBarOnGetDispInfo(LPTOOLTIPTEXT lpttt);
-
-/* treeview.c */
-extern HWND hTreeView;
-BOOL CreateTreeView(HWND hwnd);
-HTREEITEM TreeViewAddItem(HTREEITEM hParent, LPWSTR lpText, INT Image, INT SelectedImage,
LPARAM lParam);
-
/* gui.cpp */
HWND CreateMainWindow();
DWORD_PTR ListViewGetlParam(INT item);
@@ -194,6 +183,11 @@
VOID NewRichEditText(PCWSTR szText, DWORD flags);
VOID InsertRichEditText(PCWSTR szText, DWORD flags);
extern HWND hListView;
-extern PWSTR pLink;
+extern WCHAR szSearchPattern[MAX_STR_LEN];
+
+//extern HWND hTreeView;
+//BOOL CreateTreeView(HWND hwnd);
+//HTREEITEM TreeViewAddItem(HTREEITEM hParent, LPWSTR lpText, INT Image, INT
SelectedImage, LPARAM lParam);
+
#endif /* _RAPPS_H */
Removed: trunk/reactos/base/applications/rapps_new/toolbar.cpp
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/rapps_ne…
==============================================================================
--- trunk/reactos/base/applications/rapps_new/toolbar.cpp [iso-8859-1] (original)
+++ trunk/reactos/base/applications/rapps_new/toolbar.cpp (removed)
@@ -1,158 +0,0 @@
-/*
- * PROJECT: ReactOS Applications Manager
- * LICENSE: GPL - See COPYING in the top level directory
- * FILE: base/applications/rapps/toolbar.c
- * PURPOSE: ToolBar functions
- * PROGRAMMERS: Dmitry Chapyshev (dmitry(a)reactos.org)
- */
-
-#include "rapps.h"
-
-#define TOOLBAR_HEIGHT 24
-
-HWND hToolBar;
-HWND hSearchBar;
-
-static WCHAR szInstallBtn[MAX_STR_LEN];
-static WCHAR szUninstallBtn[MAX_STR_LEN];
-static WCHAR szModifyBtn[MAX_STR_LEN];
-
-/* Toolbar buttons */
-static const 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},
- { 5, 0, TBSTATE_ENABLED, BTNS_SEP, {0}, 0, 0},
- { 3, ID_REFRESH, TBSTATE_ENABLED, BTNS_BUTTON | BTNS_AUTOSIZE, {0}, 0, 0},
- { 5, 0, TBSTATE_ENABLED, BTNS_SEP, {0}, 0, 0},
- { 4, ID_SETTINGS, TBSTATE_ENABLED, BTNS_BUTTON | BTNS_AUTOSIZE, {0}, 0, 0},
- { 5, ID_EXIT, TBSTATE_ENABLED, BTNS_BUTTON | BTNS_AUTOSIZE, {0}, 0, 0}
-};
-
-
-VOID
-ToolBarOnGetDispInfo(LPTOOLTIPTEXT lpttt)
-{
- UINT idButton = (UINT)lpttt->hdr.idFrom;
-
- switch (idButton)
- {
- case ID_EXIT:
- lpttt->lpszText = MAKEINTRESOURCE(IDS_TOOLTIP_EXIT);
- break;
-
- case ID_INSTALL:
- lpttt->lpszText = MAKEINTRESOURCE(IDS_TOOLTIP_INSTALL);
- break;
-
- case ID_UNINSTALL:
- lpttt->lpszText = MAKEINTRESOURCE(IDS_TOOLTIP_UNINSTALL);
- break;
-
- case ID_MODIFY:
- lpttt->lpszText = MAKEINTRESOURCE(IDS_TOOLTIP_MODIFY);
- break;
-
- case ID_SETTINGS:
- lpttt->lpszText = MAKEINTRESOURCE(IDS_TOOLTIP_SETTINGS);
- break;
-
- case ID_REFRESH:
- lpttt->lpszText = MAKEINTRESOURCE(IDS_TOOLTIP_REFRESH);
- break;
- }
-}
-
-VOID
-AddImageToImageList(HIMAGELIST hImageList, UINT ImageIndex)
-{
- HICON hImage;
-
- if (!(hImage = (HICON) LoadImage(hInst,
- MAKEINTRESOURCE(ImageIndex),
- IMAGE_ICON,
- TOOLBAR_HEIGHT,
- TOOLBAR_HEIGHT,
- 0)))
- {
- /* TODO: Error message */
- }
-
- ImageList_AddIcon(hImageList, hImage);
- DeleteObject(hImage);
-}
-
-HIMAGELIST
-InitImageList(VOID)
-{
- HIMAGELIST hImageList;
-
- /* Create the toolbar icon image list */
- hImageList = ImageList_Create(TOOLBAR_HEIGHT,//GetSystemMetrics(SM_CXSMICON),
- TOOLBAR_HEIGHT,//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_REFRESH);
- AddImageToImageList(hImageList, IDI_SETTINGS);
- AddImageToImageList(hImageList, IDI_EXIT);
-
- return hImageList;
-}
-
-BOOL
-CreateToolBar(HWND hwnd)
-{
- INT NumButtons = sizeof(Buttons) / sizeof(Buttons[0]);
- HIMAGELIST hImageList;
-
- LoadStringW(hInst, IDS_INSTALL, szInstallBtn, sizeof(szInstallBtn) / sizeof(WCHAR));
- LoadStringW(hInst, IDS_UNINSTALL, szUninstallBtn, sizeof(szUninstallBtn) /
sizeof(WCHAR));
- LoadStringW(hInst, IDS_MODIFY, szModifyBtn, sizeof(szModifyBtn) / sizeof(WCHAR));
-
- hToolBar = CreateWindowExW(0,
- TOOLBARCLASSNAMEW,
- NULL,
- WS_CHILD | WS_VISIBLE | TBSTYLE_FLAT | TBSTYLE_TOOLTIPS |
TBSTYLE_LIST,
- 0, 0, 0, 0,
- hwnd,
- 0,
- hInst,
- NULL);
-
- if (!hToolBar)
- {
- /* TODO: Show error message */
- return FALSE;
- }
-
- SendMessageW(hToolBar, TB_SETEXTENDEDSTYLE, 0, TBSTYLE_EX_HIDECLIPPEDBUTTONS);
- SendMessageW(hToolBar, TB_BUTTONSTRUCTSIZE, sizeof(Buttons[0]), 0);
-
- hImageList = InitImageList();
-
- if (!hImageList)
- {
- /* TODO: Show error message */
- return FALSE;
- }
-
- ImageList_Destroy((HIMAGELIST)SendMessageW(hToolBar,
- TB_SETIMAGELIST,
- 0,
- (LPARAM)hImageList));
-
- SendMessageW(hToolBar, TB_ADDBUTTONS, NumButtons, (LPARAM)Buttons);
-
- return TRUE;
-}
Removed: trunk/reactos/base/applications/rapps_new/treeview.cpp
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/rapps_ne…
==============================================================================
--- trunk/reactos/base/applications/rapps_new/treeview.cpp [iso-8859-1] (original)
+++ trunk/reactos/base/applications/rapps_new/treeview.cpp (removed)
@@ -1,53 +0,0 @@
-/*
- * PROJECT: ReactOS Applications Manager
- * LICENSE: GPL - See COPYING in the top level directory
- * FILE: base/applications/rapps/treeview.c
- * PURPOSE: TreeView functions
- * PROGRAMMERS: Dmitry Chapyshev (dmitry(a)reactos.org)
- */
-
-#include "rapps.h"
-
-HWND hTreeView;
-
-HTREEITEM
-TreeViewAddItem(HTREEITEM hParent, LPWSTR lpText, INT Image, INT SelectedImage, LPARAM
lParam)
-{
- TV_INSERTSTRUCTW Insert;
-
- ZeroMemory(&Insert, sizeof(TV_INSERTSTRUCT));
-
- Insert.item.mask = TVIF_TEXT | TVIF_PARAM | TVIF_IMAGE | TVIF_SELECTEDIMAGE;
- Insert.hInsertAfter = TVI_LAST;
- Insert.hParent = hParent;
- Insert.item.iSelectedImage = SelectedImage;
- Insert.item.iImage = Image;
- Insert.item.lParam = lParam;
- Insert.item.pszText = lpText;
-
- return TreeView_InsertItem(hTreeView, &Insert);
-}
-
-BOOL
-CreateTreeView(HWND hwnd)
-{
- hTreeView = CreateWindowExW(WS_EX_CLIENTEDGE,
- WC_TREEVIEWW,
- L"",
- WS_CHILD | WS_VISIBLE | TVS_HASLINES |
TVS_SHOWSELALWAYS,
- 0, 28, 200, 350,
- hwnd,
- NULL,
- hInst,
- NULL);
-
- if (!hListView)
- {
- /* TODO: Show error message */
- return FALSE;
- }
-
- SetFocus(hTreeView);
-
- return TRUE;
-}
Modified: trunk/reactos/base/applications/rapps_new/winmain.cpp
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/rapps_ne…
==============================================================================
--- trunk/reactos/base/applications/rapps_new/winmain.cpp [iso-8859-1] (original)
+++ trunk/reactos/base/applications/rapps_new/winmain.cpp [iso-8859-1] Wed Apr 29 00:07:54
2015
@@ -13,15 +13,12 @@
#include <atlcom.h>
#include <shellapi.h>
-#define SEARCH_TIMER_ID 'SR'
-
HWND hMainWnd;
HINSTANCE hInst;
INT SelectedEnumType = ENUM_ALL_COMPONENTS;
SETTINGS_INFO SettingsInfo;
WCHAR szSearchPattern[MAX_STR_LEN] = L"";
-BOOL SearchEnabled = TRUE;
class CRAppsModule : public CComModule
{
@@ -55,15 +52,6 @@
{
gModule.Term();
}
-}
-
-BOOL
-SearchPatternMatch(PCWSTR szHaystack, PCWSTR szNeedle)
-{
- if (!*szNeedle)
- return TRUE;
- /* TODO: Improve pattern search beyond a simple case-insensitive substring search.
*/
- return StrStrIW(szHaystack, szNeedle) != NULL;
}
VOID
@@ -132,309 +120,6 @@
{
RegSetValueExW(hKey, L"Settings", 0, REG_BINARY,
(LPBYTE)&SettingsInfo, sizeof(SETTINGS_INFO));
RegCloseKey(hKey);
- }
-}
-
-VOID
-FreeInstalledAppList(VOID)
-{
- INT Count = ListView_GetItemCount(hListView) - 1;
- PINSTALLED_INFO Info;
-
- while (Count >= 0)
- {
- Info = (PINSTALLED_INFO)ListViewGetlParam(Count);
- if (Info)
- {
- RegCloseKey(Info->hSubKey);
- HeapFree(GetProcessHeap(), 0, Info);
- }
- Count--;
- }
-}
-
-BOOL
-CALLBACK
-EnumInstalledAppProc(INT ItemIndex, LPWSTR lpName, PINSTALLED_INFO Info)
-{
- PINSTALLED_INFO ItemInfo;
- WCHAR szText[MAX_PATH];
- INT Index;
-
- if (!SearchPatternMatch(lpName, szSearchPattern))
- {
- RegCloseKey(Info->hSubKey);
- return TRUE;
- }
-
- ItemInfo = (PINSTALLED_INFO) HeapAlloc(GetProcessHeap(), 0, sizeof(INSTALLED_INFO));
- if (!ItemInfo)
- {
- RegCloseKey(Info->hSubKey);
- return FALSE;
- }
-
- RtlCopyMemory(ItemInfo, Info, sizeof(INSTALLED_INFO));
-
- Index = ListViewAddItem(ItemIndex, 0, lpName, (LPARAM)ItemInfo);
-
- /* Get version info */
- GetApplicationString(ItemInfo->hSubKey, L"DisplayVersion", szText);
- ListView_SetItemText(hListView, Index, 1, szText);
-
- /* Get comments */
- GetApplicationString(ItemInfo->hSubKey, L"Comments", szText);
- ListView_SetItemText(hListView, Index, 2, szText);
-
- return TRUE;
-}
-
-BOOL
-CALLBACK
-EnumAvailableAppProc(PAPPLICATION_INFO Info)
-{
- INT Index;
-
- if (!SearchPatternMatch(Info->szName, szSearchPattern) &&
- !SearchPatternMatch(Info->szDesc, szSearchPattern))
- {
- return TRUE;
- }
-
- /* Only add a ListView entry if...
- - no RegName was supplied (so we cannot determine whether the application is
installed or not) or
- - a RegName was supplied and the application is not installed
- */
- if (!*Info->szRegName || (!IsInstalledApplication(Info->szRegName, FALSE)
&& !IsInstalledApplication(Info->szRegName, TRUE)))
- {
- Index = ListViewAddItem(Info->Category, 0, Info->szName, (LPARAM)Info);
-
- ListView_SetItemText(hListView, Index, 1, Info->szVersion);
- ListView_SetItemText(hListView, Index, 2, Info->szDesc);
- }
-
- return TRUE;
-}
-
-VOID
-UpdateApplicationsList(INT EnumType)
-{
- WCHAR szBuffer1[MAX_STR_LEN], szBuffer2[MAX_STR_LEN];
- HICON hIcon;
- HIMAGELIST hImageListView;
-
- SendMessage(hListView, WM_SETREDRAW, FALSE, 0);
-
- if (EnumType == -1) EnumType = SelectedEnumType;
-
- if (IS_INSTALLED_ENUM(SelectedEnumType))
- FreeInstalledAppList();
-
- (VOID) ListView_DeleteAllItems(hListView);
-
- /* Create image list */
- hImageListView = ImageList_Create(LISTVIEW_ICON_SIZE,
- LISTVIEW_ICON_SIZE,
- GetSystemColorDepth() | ILC_MASK,
- 0, 1);
-
- hIcon = (HICON)LoadImage(hInst,
- MAKEINTRESOURCE(IDI_MAIN),
- IMAGE_ICON,
- LISTVIEW_ICON_SIZE,
- LISTVIEW_ICON_SIZE,
- LR_CREATEDIBSECTION);
-
- ImageList_AddIcon(hImageListView, hIcon);
- DestroyIcon(hIcon);
-
- if (IS_INSTALLED_ENUM(EnumType))
- {
- /* Enum installed applications and updates */
- EnumInstalledApplications(EnumType, TRUE, EnumInstalledAppProc);
- EnumInstalledApplications(EnumType, FALSE, EnumInstalledAppProc);
- }
- else if (IS_AVAILABLE_ENUM(EnumType))
- {
- /* Enum availabled applications */
- EnumAvailableApplications(EnumType, EnumAvailableAppProc);
- }
-
- /* Set image list for ListView */
- hImageListView = ListView_SetImageList(hListView, hImageListView, LVSIL_SMALL);
-
- /* Destroy old image list */
- if (hImageListView)
- ImageList_Destroy(hImageListView);
-
- SelectedEnumType = EnumType;
-
- LoadStringW(hInst, IDS_APPS_COUNT, szBuffer2, _countof(szBuffer2));
- StringCbPrintfW(szBuffer1, sizeof(szBuffer1),
- szBuffer2,
- ListView_GetItemCount(hListView));
- SetStatusBarText(szBuffer1);
-
- SetWelcomeText();
-
- /* set automatic column width for program names if the list is not empty */
- if (ListView_GetItemCount(hListView) > 0)
- ListView_SetColumnWidth(hListView, 0, LVSCW_AUTOSIZE);
-
- SendMessage(hListView, WM_SETREDRAW, TRUE, 0);
-}
-
-VOID CALLBACK
-SearchTimerProc(HWND hwnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime)
-{
- KillTimer(hwnd, SEARCH_TIMER_ID);
- UpdateApplicationsList(-1);
-}
-
-VOID
-MainWndOnCommand(HWND hwnd, WPARAM wParam, LPARAM lParam)
-{
- WORD wCommand = LOWORD(wParam);
-
- if (lParam == (LPARAM)hSearchBar)
- {
- WCHAR szBuf[MAX_STR_LEN];
-
- switch (HIWORD(wParam))
- {
- case EN_SETFOCUS:
- {
- WCHAR szWndText[MAX_STR_LEN];
-
- LoadStringW(hInst, IDS_SEARCH_TEXT, szBuf, _countof(szBuf));
- GetWindowTextW(hSearchBar, szWndText, MAX_STR_LEN);
- if (wcscmp(szBuf, szWndText) == 0)
- {
- SearchEnabled = FALSE;
- SetWindowTextW(hSearchBar, L"");
- }
- }
- break;
-
- case EN_KILLFOCUS:
- {
- GetWindowTextW(hSearchBar, szBuf, MAX_STR_LEN);
- if (wcslen(szBuf) < 1)
- {
- LoadStringW(hInst, IDS_SEARCH_TEXT, szBuf, _countof(szBuf));
- SearchEnabled = FALSE;
- SetWindowTextW(hSearchBar, szBuf);
- }
- }
- break;
-
- case EN_CHANGE:
- {
- WCHAR szWndText[MAX_STR_LEN];
-
- if (!SearchEnabled)
- {
- SearchEnabled = TRUE;
- break;
- }
-
- LoadStringW(hInst, IDS_SEARCH_TEXT, szBuf, _countof(szBuf));
- GetWindowTextW(hSearchBar, szWndText, MAX_STR_LEN);
- if (wcscmp(szBuf, szWndText) != 0)
- {
- StringCbCopy(szSearchPattern, sizeof(szSearchPattern),
- szWndText);
- }
- else
- {
- szSearchPattern[0] = UNICODE_NULL;
- }
-
- SetTimer(hwnd, SEARCH_TIMER_ID, 250, SearchTimerProc);
- }
- break;
- }
-
- return;
- }
-
- switch (wCommand)
- {
- case ID_OPEN_LINK:
- ShellExecuteW(hwnd, L"open", pLink, NULL, NULL,
SW_SHOWNOACTIVATE);
- HeapFree(GetProcessHeap(), 0, pLink);
- break;
-
- case ID_COPY_LINK:
- CopyTextToClipboard(pLink);
- HeapFree(GetProcessHeap(), 0, pLink);
- break;
-
- case ID_SETTINGS:
- CreateSettingsDlg(hwnd);
- break;
-
- case ID_EXIT:
- PostMessageW(hwnd, WM_CLOSE, 0, 0);
- break;
-
- case ID_INSTALL:
- if (DownloadApplication(-1))
- /* TODO: Implement install dialog
- * if (InstallApplication(-1))
- */
- UpdateApplicationsList(-1);
- break;
-
- case ID_UNINSTALL:
- if (UninstallApplication(-1, FALSE))
- UpdateApplicationsList(-1);
- break;
-
- case ID_MODIFY:
- if (UninstallApplication(-1, TRUE))
- UpdateApplicationsList(-1);
- break;
-
- case ID_REGREMOVE:
- RemoveAppFromRegistry(-1);
- break;
-
- case ID_REFRESH:
- UpdateApplicationsList(-1);
- break;
-
- case ID_RESETDB:
- UpdateAppsDB();
- UpdateApplicationsList(-1);
- break;
-
- case ID_HELP:
- MessageBoxW(hwnd, L"Help not implemented yet", NULL, MB_OK);
- break;
-
- case ID_ABOUT:
- ShowAboutDialog();
- break;
- }
-}
-
-BOOL IsSelectedNodeInstalled(void)
-{
- HTREEITEM hSelectedItem = TreeView_GetSelection(hTreeView);
- TV_ITEM tItem;
-
- tItem.mask = TVIF_PARAM | TVIF_HANDLE;
- tItem.hItem = hSelectedItem;
- TreeView_GetItem(hTreeView, &tItem);
- switch (tItem.lParam)
- {
- case IDS_INSTALLED:
- case IDS_APPLICATIONS:
- case IDS_UPDATES:
- return TRUE;
- default:
- return FALSE;
}
}
Modified: trunk/reactos/base/shell/explorer/taskswnd.cpp
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/explorer/tasksw…
==============================================================================
--- trunk/reactos/base/shell/explorer/taskswnd.cpp [iso-8859-1] (original)
+++ trunk/reactos/base/shell/explorer/taskswnd.cpp [iso-8859-1] Wed Apr 29 00:07:54 2015
@@ -103,7 +103,7 @@
} TASK_ITEM, *PTASK_ITEM;
class CTaskToolbar :
- public CToolbar<TASK_ITEM>
+ public CWindowImplBaseT< CToolbar<TASK_ITEM>, CControlWinTraits >
{
public:
INT UpdateTbButtonSpacing(IN BOOL bHorizontal, IN BOOL bThemed, IN UINT uiRows = 0,
IN UINT uiBtnsPerLine = 0)
@@ -170,7 +170,7 @@
TBSTYLE_TOOLTIPS | TBSTYLE_WRAPABLE | TBSTYLE_LIST | TBSTYLE_TRANSPARENT |
CCS_TOP | CCS_NORESIZE | CCS_NODIVIDER;
- return SubclassWindow(Create(hWndParent, styles));
+ return SubclassWindow(CToolbar::Create(hWndParent, styles));
}
};
Modified: trunk/reactos/base/shell/explorer/trayntfy.cpp
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/explorer/traynt…
==============================================================================
--- trunk/reactos/base/shell/explorer/trayntfy.cpp [iso-8859-1] (original)
+++ trunk/reactos/base/shell/explorer/trayntfy.cpp [iso-8859-1] Wed Apr 29 00:07:54 2015
@@ -37,7 +37,7 @@
} SYS_PAGER_COPY_DATA, *PSYS_PAGER_COPY_DATA;
class CNotifyToolbar :
- public CToolbar<NOTIFYICONDATA>
+ public CWindowImplBaseT< CToolbar<NOTIFYICONDATA>, CControlWinTraits >
{
static const int ICON_SIZE = 16;
@@ -367,7 +367,7 @@
TBSTYLE_FLAT | TBSTYLE_TOOLTIPS | TBSTYLE_WRAPABLE | TBSTYLE_TRANSPARENT |
CCS_TOP | CCS_NORESIZE | CCS_NOPARENTALIGN | CCS_NODIVIDER;
- SubclassWindow(Create(hWndParent, styles));
+ SubclassWindow(CToolbar::Create(hWndParent, styles));
SetWindowTheme(m_hWnd, L"TrayNotify", NULL);
Modified: trunk/reactos/base/shell/rshell/CMenuToolbars.cpp
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/rshell/CMenuToo…
==============================================================================
--- trunk/reactos/base/shell/rshell/CMenuToolbars.cpp [iso-8859-1] (original)
+++ trunk/reactos/base/shell/rshell/CMenuToolbars.cpp [iso-8859-1] Wed Apr 29 00:07:54
2015
@@ -383,7 +383,7 @@
rc.bottom = 1;
}
- SubclassWindow(Create(hwndParent, tbStyles, tbExStyles));
+ SubclassWindow(CToolbar::Create(hwndParent, tbStyles, tbExStyles));
SetWindowTheme(m_hWnd, L"", L"");
Modified: trunk/reactos/base/shell/rshell/CMenuToolbars.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/rshell/CMenuToo…
==============================================================================
--- trunk/reactos/base/shell/rshell/CMenuToolbars.h [iso-8859-1] (original)
+++ trunk/reactos/base/shell/rshell/CMenuToolbars.h [iso-8859-1] Wed Apr 29 00:07:54 2015
@@ -26,7 +26,7 @@
#define WM_USER_CHANGETRACKEDITEM (WM_APP+42)
class CMenuToolbarBase :
- public CToolbar<DWORD_PTR>
+ public CWindowImplBaseT< CToolbar<DWORD_PTR>, CControlWinTraits >
{
CContainedWindow m_pager;
private:
Modified: trunk/reactos/include/reactos/rosctrls.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/reactos/rosctrls.h…
==============================================================================
--- trunk/reactos/include/reactos/rosctrls.h [iso-8859-1] (original)
+++ trunk/reactos/include/reactos/rosctrls.h [iso-8859-1] Wed Apr 29 00:07:54 2015
@@ -190,9 +190,9 @@
DWORD_PTR GetItemData(int i)
{
- LVITEMW lvItem;
+ LVITEMW lvItem = { 0 };
+ lvItem.mask = LVIF_PARAM;
lvItem.iItem = i;
- lvItem.mask = LVIF_PARAM;
BOOL ret = GetItem(&lvItem);
return (DWORD_PTR)(ret ? lvItem.lParam : NULL);
}
@@ -218,7 +218,7 @@
template<typename TItemData = DWORD_PTR>
class CToolbar :
- public CWindowImplBaseT<CWindow>
+ public CWindow
{
public: // Configuration methods
@@ -415,14 +415,8 @@
};
class CStatusBar :
- public CWindowImplBaseT<CWindow>
+ public CWindow
{
- BOOL ProcessWindowMessage(HWND hwnd, UINT Msg, WPARAM wParam, LPARAM lParam,
LRESULT& theResult, DWORD dwMapId)
- {
- theResult = 0;
- return FALSE;
- }
-
public:
VOID SetText(LPCWSTR lpszText)
{
@@ -431,7 +425,7 @@
HWND Create(HWND hwndParent, HMENU hMenu)
{
- HWND hwnd = CreateWindowExW(0,
+ m_hWnd = CreateWindowExW(0,
STATUSCLASSNAMEW,
NULL,
WS_CHILD | WS_VISIBLE | SBARS_SIZEGRIP,
@@ -440,8 +434,140 @@
hMenu,
_AtlBaseModule.GetModuleInstance(),
NULL);
- SubclassWindow(hwnd);
- return hwnd;
+
+ return m_hWnd;
}
};
+
+class CTreeView :
+ public CWindow
+{
+public:
+ HWND Create(HWND hwndParent)
+ {
+ m_hWnd = CreateWindowExW(WS_EX_CLIENTEDGE,
+ WC_TREEVIEWW,
+ L"",
+ WS_CHILD | WS_VISIBLE | TVS_HASLINES | TVS_SHOWSELALWAYS,
+ 0, 28, 200, 350,
+ hwndParent,
+ NULL,
+ _AtlBaseModule.GetModuleInstance(),
+ NULL);
+
+ return m_hWnd;
+ }
+
+ HTREEITEM AddItem(HTREEITEM hParent, LPWSTR lpText, INT Image, INT SelectedImage,
LPARAM lParam)
+ {
+ TVINSERTSTRUCTW Insert;
+
+ ZeroMemory(&Insert, sizeof(TV_INSERTSTRUCT));
+
+ Insert.item.mask = TVIF_TEXT | TVIF_PARAM | TVIF_IMAGE | TVIF_SELECTEDIMAGE;
+ Insert.hInsertAfter = TVI_LAST;
+ Insert.hParent = hParent;
+ Insert.item.iSelectedImage = SelectedImage;
+ Insert.item.iImage = Image;
+ Insert.item.lParam = lParam;
+ Insert.item.pszText = lpText;
+
+ return InsertItem(&Insert);
+ }
+
+ void SetRedraw(BOOL redraw)
+ {
+ SendMessage(WM_SETREDRAW, redraw);
+ }
+
+ BOOL SetBkColor(COLORREF cr)
+ {
+ return (BOOL) SendMessage(TVM_SETBKCOLOR, 0, cr);
+ }
+
+ BOOL SetTextColor(COLORREF cr)
+ {
+ return (BOOL) SendMessage(TVM_SETTEXTCOLOR, 0, cr);
+ }
+
+ HIMAGELIST SetImageList(HIMAGELIST himl, int iImageList)
+ {
+ return (HIMAGELIST) SendMessage(TVM_SETIMAGELIST, iImageList,
reinterpret_cast<LPARAM>(himl));
+ }
+
+ HTREEITEM InsertItem(const TVINSERTSTRUCTW * pitem)
+ {
+ return (HTREEITEM) SendMessage(TVM_INSERTITEM, 0,
reinterpret_cast<LPARAM>(pitem));
+ }
+
+ BOOL DeleteItem(HTREEITEM i)
+ {
+ return (BOOL) SendMessage(TVM_DELETEITEM, 0, (LPARAM)i);
+ }
+
+ BOOL GetItem(TV_ITEM* pitem)
+ {
+ return (BOOL) SendMessage(TVM_GETITEM, 0,
reinterpret_cast<LPARAM>(pitem));
+ }
+
+ BOOL SetItem(const TV_ITEM * pitem)
+ {
+ return (BOOL) SendMessage(TVM_SETITEM, 0,
reinterpret_cast<LPARAM>(pitem));
+ }
+
+ int GetItemCount()
+ {
+ return SendMessage(TVM_GETCOUNT);
+ }
+
+ BOOL EnsureVisible(HTREEITEM i)
+ {
+ return (BOOL) SendMessage(TVM_ENSUREVISIBLE, 0, (LPARAM)i);
+ }
+
+ HWND EditLabel(HTREEITEM i)
+ {
+ return (HWND) SendMessage(TVM_EDITLABEL, 0, (LPARAM)i);
+ }
+
+ HTREEITEM GetNextItem(HTREEITEM i, WORD flags)
+ {
+ return (HTREEITEM)SendMessage(TVM_GETNEXTITEM, flags, (LPARAM)i);
+ }
+
+ UINT GetItemState(int i, UINT mask)
+ {
+ return SendMessage(TVM_GETITEMSTATE, i, (LPARAM) mask);
+ }
+
+ HTREEITEM HitTest(TVHITTESTINFO * phtInfo)
+ {
+ return (HTREEITEM) SendMessage(TVM_HITTEST, 0,
reinterpret_cast<LPARAM>(phtInfo));
+ }
+
+ DWORD_PTR GetItemData(HTREEITEM item)
+ {
+ TVITEMW lvItem;
+ lvItem.hItem = item;
+ lvItem.mask = TVIF_PARAM;
+ BOOL ret = GetItem(&lvItem);
+ return (DWORD_PTR) (ret ? lvItem.lParam : NULL);
+ }
+
+ HTREEITEM GetSelection()
+ {
+ return GetNextItem(NULL, TVGN_CARET);
+ }
+
+ BOOL Expand(HTREEITEM item, DWORD action)
+ {
+ return SendMessage(TVM_EXPAND, action, (LPARAM)item);
+ }
+
+ BOOL SelectItem(HTREEITEM item, DWORD action = TVGN_CARET)
+ {
+ return SendMessage(TVM_SELECTITEM, action, (LPARAM) item);
+ }
+
+};