[RAPPS_NEW]
authorDavid Quintana <gigaherz@gmail.com>
Mon, 27 Apr 2015 15:01:40 +0000 (15:01 +0000)
committerDavid Quintana <gigaherz@gmail.com>
Mon, 27 Apr 2015 15:01:40 +0000 (15:01 +0000)
Initial work on a lightweight layout engine for ATL::CWindow.
Although a lot of work is still required making the classes more generic and layout-aware,
but it is already able to replicate the original rapps layout without explicit positioning of the windows.
Committing mostly for backup/history purposes.
CORE-9593

svn path=/trunk/; revision=67460

reactos/base/applications/rapps_new/CMakeLists.txt
reactos/base/applications/rapps_new/gui.cpp [new file with mode: 0644]
reactos/base/applications/rapps_new/listview.cpp [deleted file]
reactos/base/applications/rapps_new/rapps.h
reactos/base/applications/rapps_new/richedit.cpp [deleted file]
reactos/base/applications/rapps_new/rosui.h [new file with mode: 0644]
reactos/base/applications/rapps_new/statusbar.cpp [deleted file]
reactos/base/applications/rapps_new/toolbar.cpp
reactos/base/applications/rapps_new/winmain.cpp
reactos/include/reactos/rosctrls.h

index 985d021..bf91615 100644 (file)
@@ -7,15 +7,12 @@ include_directories(${REACTOS_SOURCE_DIR}/lib/atl)
 list(APPEND SOURCE
     aboutdlg.cpp
     available.cpp
+    gui.cpp
     installdlg.cpp
     installed.cpp
-    listview.cpp
     loaddlg.cpp
     misc.cpp
-    richedit.cpp
     settingsdlg.cpp
-    splitter.cpp
-    statusbar.cpp
     toolbar.cpp
     treeview.cpp
     winmain.cpp
diff --git a/reactos/base/applications/rapps_new/gui.cpp b/reactos/base/applications/rapps_new/gui.cpp
new file mode 100644 (file)
index 0000000..c441b94
--- /dev/null
@@ -0,0 +1,960 @@
+/* PROJECT:     ReactOS CE Applications Manager
+ * LICENSE:     GPL - See COPYING in the top level directory
+ * AUTHORS:     David Quintana <gigaherz@gmail.com>
+ */
+
+#include "rapps.h"
+
+#include <shlobj_undoc.h>
+#include <shlguid_undoc.h>
+
+#include <atlbase.h>
+#include <atlcom.h>
+#include <atlwin.h>
+#include <wininet.h>
+#include <shellutils.h>
+
+#include <rosctrls.h>
+
+#include "rosui.h"
+
+PWSTR pLink = NULL;
+
+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> >
+{
+    BOOL ProcessWindowMessage(HWND hwnd, UINT Msg, WPARAM wParam, LPARAM lParam, LRESULT& theResult, DWORD dwMapId)
+    {
+        theResult = 0;
+        return FALSE;
+    }
+
+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;
+        }
+    }
+
+    HWND Create(HWND hwndParent)
+    {
+        LoadLibraryW(L"riched20.dll");
+
+        HWND hwnd = CreateWindowExW(0,
+            L"RichEdit20W",
+            NULL,
+            WS_CHILD | WS_VISIBLE | ES_MULTILINE |
+            ES_LEFT | ES_READONLY,
+            205, 28, 465, 100,
+            hwndParent,
+            NULL,
+            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;
+    }
+
+};
+
+class CUiListView :
+    public CUiWindow<CListView>
+{
+    struct SortContext
+    {
+        CUiListView * lvw;
+        int iSubItem;
+    };
+
+public:
+    BOOL bAscending;
+
+    CUiListView()
+    {
+        bAscending = TRUE;
+    }
+
+    VOID ColumnClick(LPNMLISTVIEW pnmv)
+    {
+        SortContext ctx = { this, pnmv->iSubItem };
+
+        SortItems(s_CompareFunc, &ctx);
+
+        bAscending = !bAscending;
+    }
+
+    PVOID GetLParam(INT Index)
+    {
+        INT ItemIndex;
+        LVITEM Item;
+
+        if (Index == -1)
+        {
+            ItemIndex = (INT) SendMessage(LVM_GETNEXTITEM, -1, LVNI_FOCUSED);
+            if (ItemIndex == -1)
+                return NULL;
+        }
+        else
+        {
+            ItemIndex = Index;
+        }
+
+        ZeroMemory(&Item, sizeof(LVITEM));
+
+        Item.mask = LVIF_PARAM;
+        Item.iItem = ItemIndex;
+        if (!GetItem(&Item))
+            return NULL;
+
+        return (PVOID) Item.lParam;
+    }
+
+    BOOL AddColumn(INT Index, LPWSTR lpText, INT Width, INT Format)
+    {
+        LV_COLUMN Column;
+
+        ZeroMemory(&Column, sizeof(LV_COLUMN));
+
+        Column.mask = LVCF_FMT | LVCF_TEXT | LVCF_WIDTH | LVCF_SUBITEM;
+        Column.iSubItem = Index;
+        Column.pszText = (LPTSTR) lpText;
+        Column.cx = Width;
+        Column.fmt = Format;
+
+        return (InsertColumn(Index, &Column) == -1) ? FALSE : TRUE;
+    }
+
+    INT AddItem(INT ItemIndex, INT IconIndex, LPWSTR lpText, LPARAM lParam)
+    {
+        LV_ITEMW Item;
+
+        ZeroMemory(&Item, sizeof(LV_ITEM));
+
+        Item.mask = LVIF_TEXT | LVIF_PARAM | LVIF_STATE | LVIF_IMAGE;
+        Item.pszText = lpText;
+        Item.lParam = lParam;
+        Item.iItem = ItemIndex;
+        Item.iImage = IconIndex;
+
+        return InsertItem(&Item);
+    }
+
+    static INT CALLBACK s_CompareFunc(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort)
+    {
+        SortContext * ctx = ((SortContext*) lParamSort);
+        return ctx->lvw->CompareFunc(lParam1, lParam2, ctx->iSubItem);
+    }
+    
+    INT CompareFunc(LPARAM lParam1, LPARAM lParam2, INT iSubItem)
+    {
+        WCHAR Item1[MAX_STR_LEN], Item2[MAX_STR_LEN];
+        LVFINDINFO IndexInfo;
+        INT Index;
+
+        IndexInfo.flags = LVFI_PARAM;
+
+        IndexInfo.lParam = lParam1;
+        Index = FindItem(-1, &IndexInfo);
+        GetItemText(Index, iSubItem, Item1, sizeof(Item1) / sizeof(WCHAR));
+
+        IndexInfo.lParam = lParam2;
+        Index = FindItem(-1, &IndexInfo);
+        GetItemText(Index, iSubItem, Item2, sizeof(Item2) / sizeof(WCHAR));
+
+        if (bAscending)
+            return wcscmp(Item2, Item1);
+        else
+            return wcscmp(Item1, Item2);
+
+        return 0;
+    }
+
+    HWND Create(HWND hwndParent)
+    {
+        RECT r = { 205, 28, 465, 250 };
+        DWORD style = WS_CHILD | WS_VISIBLE | LVS_SORTASCENDING | LVS_REPORT | LVS_SINGLESEL | LVS_SHOWSELALWAYS;
+        HMENU menu = GetSubMenu(LoadMenuW(hInst, MAKEINTRESOURCEW(IDR_APPLICATIONMENU)), 0);
+        
+        HWND hwnd = CListView::Create(hwndParent, r, NULL, style, WS_EX_CLIENTEDGE, menu);
+
+        if (hwnd)
+            SetExtendedListViewStyle(LVS_EX_FULLROWSELECT);
+
+        return hwnd;
+    }
+
+};
+
+class CUiStatusBar :
+    public CUiWindow<CStatusBar>
+{
+};
+
+class CUiMainWindow :
+    public CWindowImpl<CUiMainWindow, 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;
+
+    HIMAGELIST hImageTreeView;
+
+    VOID InitApplicationsList(VOID)
+    {
+        WCHAR szText[MAX_STR_LEN];
+
+        /* Add columns to ListView */
+        LoadStringW(hInst, IDS_APP_NAME, szText, _countof(szText));
+        m_ListView->AddColumn(0, szText, 200, LVCFMT_LEFT);
+
+        LoadStringW(hInst, IDS_APP_INST_VERSION, szText, _countof(szText));
+        m_ListView->AddColumn(1, szText, 90, LVCFMT_RIGHT);
+
+        LoadStringW(hInst, IDS_APP_DESCRIPTION, szText, _countof(szText));
+        m_ListView->AddColumn(3, szText, 250, LVCFMT_LEFT);
+
+        UpdateApplicationsList(ENUM_ALL_COMPONENTS);
+    }
+
+    HTREEITEM AddCategory(HTREEITEM hRootItem, UINT TextIndex, UINT IconIndex)
+    {
+        WCHAR szText[MAX_STR_LEN];
+        INT Index;
+        HICON hIcon;
+
+        hIcon = (HICON) LoadImage(hInst,
+            MAKEINTRESOURCE(IconIndex),
+            IMAGE_ICON,
+            TREEVIEW_ICON_SIZE,
+            TREEVIEW_ICON_SIZE,
+            LR_CREATEDIBSECTION);
+
+        Index = ImageList_AddIcon(hImageTreeView, hIcon);
+        DestroyIcon(hIcon);
+
+        LoadStringW(hInst, TextIndex, szText, _countof(szText));
+
+        return TreeViewAddItem(hRootItem, szText, Index, Index, TextIndex);
+    }
+
+    VOID InitCategoriesList(VOID)
+    {
+        HTREEITEM hRootItem1, hRootItem2;
+
+        hRootItem1 = AddCategory(TVI_ROOT, IDS_INSTALLED, IDI_CATEGORY);
+        AddCategory(hRootItem1, IDS_APPLICATIONS, IDI_APPS);
+        AddCategory(hRootItem1, IDS_UPDATES, IDI_APPUPD);
+
+        hRootItem2 = AddCategory(TVI_ROOT, IDS_AVAILABLEFORINST, IDI_CATEGORY);
+        AddCategory(hRootItem2, IDS_CAT_AUDIO, IDI_CAT_AUDIO);
+        AddCategory(hRootItem2, IDS_CAT_VIDEO, IDI_CAT_VIDEO);
+        AddCategory(hRootItem2, IDS_CAT_GRAPHICS, IDI_CAT_GRAPHICS);
+        AddCategory(hRootItem2, IDS_CAT_GAMES, IDI_CAT_GAMES);
+        AddCategory(hRootItem2, IDS_CAT_INTERNET, IDI_CAT_INTERNET);
+        AddCategory(hRootItem2, IDS_CAT_OFFICE, IDI_CAT_OFFICE);
+        AddCategory(hRootItem2, IDS_CAT_DEVEL, IDI_CAT_DEVEL);
+        AddCategory(hRootItem2, IDS_CAT_EDU, IDI_CAT_EDU);
+        AddCategory(hRootItem2, IDS_CAT_ENGINEER, IDI_CAT_ENGINEER);
+        AddCategory(hRootItem2, IDS_CAT_FINANCE, IDI_CAT_FINANCE);
+        AddCategory(hRootItem2, IDS_CAT_SCIENCE, IDI_CAT_SCIENCE);
+        AddCategory(hRootItem2, IDS_CAT_TOOLS, IDI_CAT_TOOLS);
+        AddCategory(hRootItem2, IDS_CAT_DRIVERS, IDI_CAT_DRIVERS);
+        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);
+    }
+
+    BOOL CreateStatusBar()
+    {
+        m_StatusBar = new CUiStatusBar();
+        m_StatusBar->m_VerticalAlignment = UiAlign_RightBtm;
+        m_StatusBar->m_HorizontalAlignment = UiAlign_Stretch;
+        m_ClientPanel->Children().Append(m_StatusBar);
+
+        return m_StatusBar->Create(m_hWnd, (HMENU)IDC_STATUSBAR) != NULL;
+    }
+
+    BOOL CreateToolbar()
+    {
+        // TODO: WRAPPER
+        m_Toolbar = new CUiWindow<>();
+        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;
+    }
+
+    BOOL CreateTreeView()
+    {
+        // TODO: WRAPPER
+        m_TreeView = new CUiWindow<>();
+        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;
+    }
+
+    BOOL CreateListView()
+    {
+        m_ListView = new CUiListView();
+        m_ListView->m_VerticalAlignment = UiAlign_Stretch;
+        m_ListView->m_HorizontalAlignment = UiAlign_Stretch;
+        m_HSplitter->First().Append(m_ListView);
+
+        hListView = m_ListView->Create(m_hWnd);
+        return hListView != NULL;
+    }
+
+    BOOL CreateRichEdit()
+    {
+        m_RichEdit = new CUiRichEdit();
+        m_RichEdit->m_VerticalAlignment = UiAlign_Stretch;
+        m_RichEdit->m_HorizontalAlignment = UiAlign_Stretch;
+        m_HSplitter->Second().Append(m_RichEdit);
+
+        return m_RichEdit->Create(m_hWnd) != NULL;
+    }
+
+    BOOL CreateVSplitter()
+    {
+        m_VSplitter = new CUiSplitPanel();
+        m_VSplitter->m_VerticalAlignment = UiAlign_Stretch;
+        m_VSplitter->m_HorizontalAlignment = UiAlign_Stretch;
+        m_VSplitter->m_DynamicFirst = FALSE;
+        m_VSplitter->m_Horizontal = FALSE;
+        m_VSplitter->m_MinFirst = 240;
+        m_VSplitter->m_MinSecond = 300;
+        m_ClientPanel->Children().Append(m_VSplitter);
+
+        return m_VSplitter->Create(m_hWnd) != NULL;
+    }
+
+    BOOL CreateHSplitter()
+    {
+        m_HSplitter = new CUiSplitPanel();
+        m_HSplitter->m_VerticalAlignment = UiAlign_Stretch;
+        m_HSplitter->m_HorizontalAlignment = UiAlign_Stretch;
+        m_HSplitter->m_DynamicFirst = TRUE;
+        m_HSplitter->m_Horizontal = TRUE;
+        m_HSplitter->m_Pos = 32768;
+        m_HSplitter->m_MinFirst = 300;
+        m_HSplitter->m_MinSecond = 80;
+        m_VSplitter->Second().Append(m_HSplitter);
+
+        return m_HSplitter->Create(m_hWnd) != NULL;
+    }
+
+    BOOL CreateSearchBar(VOID)
+    {
+        WCHAR szBuf[MAX_STR_LEN];
+
+        // TODO: WRAPPER
+        m_SearchBar = new CUiWindow<>();
+        m_SearchBar->m_VerticalAlignment = UiAlign_LeftTop;
+        m_SearchBar->m_HorizontalAlignment = UiAlign_RightBtm;
+        m_SearchBar->m_Margin.top = 6;
+        m_SearchBar->m_Margin.right = 6;
+        //m_ClientPanel->Children().Append(m_SearchBar);
+
+        hSearchBar = CreateWindowExW(WS_EX_CLIENTEDGE,
+            L"Edit",
+            NULL,
+            WS_CHILD | WS_VISIBLE | ES_LEFT | ES_AUTOHSCROLL,
+            0,
+            0,
+            200,
+            22,
+            m_Toolbar->m_hWnd,
+            (HMENU) 0,
+            hInst,
+            0);
+
+        m_SearchBar->m_hWnd = hSearchBar;
+
+        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;
+    }
+
+    BOOL CreateLayout()
+    {
+        bool b = TRUE;
+
+        m_ClientPanel = new CUiPanel();
+        m_ClientPanel->m_VerticalAlignment = UiAlign_Stretch;
+        m_ClientPanel->m_HorizontalAlignment = UiAlign_Stretch;
+
+        // Top level
+        b = b && CreateStatusBar();
+        b = b && CreateToolbar();
+        b = b && CreateSearchBar();
+        b = b && CreateVSplitter();
+
+        // Inside V Splitter
+        b = b && CreateHSplitter();
+        b = b && CreateTreeView();
+
+        // Inside H Splitter
+        b = b && CreateListView();
+        b = b && CreateRichEdit();
+
+        if (b)
+        {
+            RECT rTop;
+            RECT rBottom;
+
+            /* Size status bar */
+            m_StatusBar->SendMessage(WM_SIZE, 0, 0);
+
+            /* Size tool bar */
+            SendMessage(hToolBar, TB_AUTOSIZE, 0, 0);
+
+            ::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;
+        }
+
+        return b;
+    }
+
+    BOOL InitControls()
+    {
+        /* Create image list */
+        hImageTreeView = ImageList_Create(TREEVIEW_ICON_SIZE, TREEVIEW_ICON_SIZE,
+            GetSystemColorDepth() | ILC_MASK,
+            0, 1);
+
+        if (CreateLayout())
+        {
+            WCHAR szBuffer1[MAX_STR_LEN], szBuffer2[MAX_STR_LEN];
+
+            InitApplicationsList();
+
+            InitCategoriesList();
+
+            LoadStringW(hInst, IDS_APPS_COUNT, szBuffer2, _countof(szBuffer2));
+            StringCbPrintfW(szBuffer1, sizeof(szBuffer1),
+                szBuffer2,
+                m_ListView->GetItemCount());
+            m_StatusBar->SetText(szBuffer1);
+            return TRUE;
+        }
+
+        return FALSE;
+    }
+
+    VOID OnSize(HWND hwnd, WPARAM wParam, LPARAM lParam)
+    {
+        /* Size status bar */
+        m_StatusBar->SendMessage(WM_SIZE, 0, 0);
+
+        /* Size tool bar */
+        SendMessage(hToolBar, TB_AUTOSIZE, 0, 0);
+
+
+        RECT r = { 0, 0, LOWORD(lParam), HIWORD(lParam) };
+
+        HDWP hdwp = NULL;
+
+        int count = m_ClientPanel->CountSizableChildren();
+        hdwp = BeginDeferWindowPos(count);
+        hdwp = m_ClientPanel->OnParentSize(r, hdwp);
+        EndDeferWindowPos(hdwp);
+
+        // TODO: Sub-layouts for children of children
+        count = m_SearchBar->CountSizableChildren();
+        hdwp = BeginDeferWindowPos(count);
+        hdwp = m_SearchBar->OnParentSize(r, hdwp);
+        EndDeferWindowPos(hdwp);
+    }
+
+    BOOL ProcessWindowMessage(HWND hwnd, UINT Msg, WPARAM wParam, LPARAM lParam, LRESULT& theResult, DWORD dwMapId)
+    {
+        theResult = 0;
+        switch (Msg)
+        {
+        case WM_CREATE:
+            if (!InitControls())
+                PostMessage(hwnd, WM_CLOSE, 0, 0);
+            break;
+
+        case WM_DESTROY:
+        {
+            ShowWindow(SW_HIDE);
+            SaveSettings(hwnd);
+
+            FreeLogs();
+
+            FreeCachedAvailableEntries();
+
+            if (IS_INSTALLED_ENUM(SelectedEnumType))
+                FreeInstalledAppList();
+
+            if (hImageTreeView)
+                ImageList_Destroy(hImageTreeView);
+
+            delete m_ClientPanel;
+
+            PostQuitMessage(0);
+            return 0;
+        }
+
+        case WM_COMMAND:
+            MainWndOnCommand(hwnd, wParam, lParam);
+            break;
+
+        case WM_NOTIFY:
+        {
+            LPNMHDR data = (LPNMHDR) lParam;
+
+            switch (data->code)
+            {
+            case TVN_SELCHANGED:
+            {
+                if (data->hwndFrom == hTreeView)
+                {
+                    switch (((LPNMTREEVIEW) lParam)->itemNew.lParam)
+                    {
+                    case IDS_INSTALLED:
+                        UpdateApplicationsList(ENUM_ALL_COMPONENTS);
+                        break;
+
+                    case IDS_APPLICATIONS:
+                        UpdateApplicationsList(ENUM_APPLICATIONS);
+                        break;
+
+                    case IDS_UPDATES:
+                        UpdateApplicationsList(ENUM_UPDATES);
+                        break;
+
+                    case IDS_AVAILABLEFORINST:
+                        UpdateApplicationsList(ENUM_ALL_AVAILABLE);
+                        break;
+
+                    case IDS_CAT_AUDIO:
+                        UpdateApplicationsList(ENUM_CAT_AUDIO);
+                        break;
+
+                    case IDS_CAT_DEVEL:
+                        UpdateApplicationsList(ENUM_CAT_DEVEL);
+                        break;
+
+                    case IDS_CAT_DRIVERS:
+                        UpdateApplicationsList(ENUM_CAT_DRIVERS);
+                        break;
+
+                    case IDS_CAT_EDU:
+                        UpdateApplicationsList(ENUM_CAT_EDU);
+                        break;
+
+                    case IDS_CAT_ENGINEER:
+                        UpdateApplicationsList(ENUM_CAT_ENGINEER);
+                        break;
+
+                    case IDS_CAT_FINANCE:
+                        UpdateApplicationsList(ENUM_CAT_FINANCE);
+                        break;
+
+                    case IDS_CAT_GAMES:
+                        UpdateApplicationsList(ENUM_CAT_GAMES);
+                        break;
+
+                    case IDS_CAT_GRAPHICS:
+                        UpdateApplicationsList(ENUM_CAT_GRAPHICS);
+                        break;
+
+                    case IDS_CAT_INTERNET:
+                        UpdateApplicationsList(ENUM_CAT_INTERNET);
+                        break;
+
+                    case IDS_CAT_LIBS:
+                        UpdateApplicationsList(ENUM_CAT_LIBS);
+                        break;
+
+                    case IDS_CAT_OFFICE:
+                        UpdateApplicationsList(ENUM_CAT_OFFICE);
+                        break;
+
+                    case IDS_CAT_OTHER:
+                        UpdateApplicationsList(ENUM_CAT_OTHER);
+                        break;
+
+                    case IDS_CAT_SCIENCE:
+                        UpdateApplicationsList(ENUM_CAT_SCIENCE);
+                        break;
+
+                    case IDS_CAT_TOOLS:
+                        UpdateApplicationsList(ENUM_CAT_TOOLS);
+                        break;
+
+                    case IDS_CAT_VIDEO:
+                        UpdateApplicationsList(ENUM_CAT_VIDEO);
+                        break;
+                    }
+                }
+
+                HMENU mainMenu = GetMenu(hwnd);
+                HMENU lvwMenu = GetMenu(m_ListView->m_hWnd);
+
+                /* Disable/enable items based on treeview selection */
+                if (IsSelectedNodeInstalled())
+                {
+                    EnableMenuItem(mainMenu, ID_REGREMOVE, MF_ENABLED);
+                    EnableMenuItem(mainMenu, ID_INSTALL, MF_GRAYED);
+                    EnableMenuItem(mainMenu, ID_UNINSTALL, MF_ENABLED);
+                    EnableMenuItem(mainMenu, ID_MODIFY, MF_ENABLED);
+
+                    EnableMenuItem(lvwMenu, ID_REGREMOVE, MF_ENABLED);
+                    EnableMenuItem(lvwMenu, ID_INSTALL, MF_GRAYED);
+                    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);
+                }
+                else
+                {
+                    EnableMenuItem(mainMenu, ID_REGREMOVE, MF_GRAYED);
+                    EnableMenuItem(mainMenu, ID_INSTALL, MF_ENABLED);
+                    EnableMenuItem(mainMenu, ID_UNINSTALL, MF_GRAYED);
+                    EnableMenuItem(mainMenu, ID_MODIFY, MF_GRAYED);
+
+                    EnableMenuItem(lvwMenu, ID_REGREMOVE, MF_GRAYED);
+                    EnableMenuItem(lvwMenu, ID_INSTALL, MF_ENABLED);
+                    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);
+                }
+            }
+            break;
+
+            case LVN_ITEMCHANGED:
+            {
+                LPNMLISTVIEW pnic = (LPNMLISTVIEW) lParam;
+
+                if (pnic->hdr.hwndFrom == m_ListView->m_hWnd)
+                {
+                    /* Check if this is a valid item
+                    * (technically, it can be also an unselect) */
+                    INT ItemIndex = pnic->iItem;
+                    if (ItemIndex == -1 ||
+                        ItemIndex >= ListView_GetItemCount(pnic->hdr.hwndFrom))
+                    {
+                        break;
+                    }
+
+                    /* Check if the focus has been moved to another item */
+                    if ((pnic->uChanged & LVIF_STATE) &&
+                        (pnic->uNewState & LVIS_FOCUSED) &&
+                        !(pnic->uOldState & LVIS_FOCUSED))
+                    {
+                        if (IS_INSTALLED_ENUM(SelectedEnumType))
+                            ShowInstalledAppInfo(ItemIndex);
+                        if (IS_AVAILABLE_ENUM(SelectedEnumType))
+                            ShowAvailableAppInfo(ItemIndex);
+                    }
+                }
+            }
+            break;
+
+            case LVN_COLUMNCLICK:
+            {
+                LPNMLISTVIEW pnmv = (LPNMLISTVIEW) lParam;
+
+                m_ListView->ColumnClick(pnmv);
+            }
+            break;
+
+            case NM_CLICK:
+            {
+                if (data->hwndFrom == m_ListView->m_hWnd && ((LPNMLISTVIEW) lParam)->iItem != -1)
+                {
+                    if (IS_INSTALLED_ENUM(SelectedEnumType))
+                        ShowInstalledAppInfo(-1);
+                    if (IS_AVAILABLE_ENUM(SelectedEnumType))
+                        ShowAvailableAppInfo(-1);
+                }
+            }
+            break;
+
+            case NM_DBLCLK:
+            {
+                if (data->hwndFrom == m_ListView->m_hWnd && ((LPNMLISTVIEW) lParam)->iItem != -1)
+                {
+                    /* this won't do anything if the program is already installed */
+                    SendMessage(hwnd, WM_COMMAND, ID_INSTALL, 0);
+                }
+            }
+            break;
+
+            case NM_RCLICK:
+            {
+                if (data->hwndFrom == m_ListView->m_hWnd && ((LPNMLISTVIEW) lParam)->iItem != -1)
+                {
+                    ShowPopupMenu(m_ListView->m_hWnd, 0, ID_INSTALL);
+                }
+            }
+            break;
+
+            case EN_LINK:
+                m_RichEdit->OnLink((ENLINK*) lParam);
+                break;
+
+            case TTN_GETDISPINFO:
+                ToolBarOnGetDispInfo((LPTOOLTIPTEXT) lParam);
+                break;
+            }
+        }
+        break;
+
+        case WM_SIZE:
+            OnSize(hwnd, wParam, lParam);
+            break;
+
+        case WM_SIZING:
+        {
+            LPRECT pRect = (LPRECT) lParam;
+
+            if (pRect->right - pRect->left < 565)
+                pRect->right = pRect->left + 565;
+
+            if (pRect->bottom - pRect->top < 300)
+                pRect->bottom = pRect->top + 300;
+
+            return TRUE;
+        }
+
+        case WM_SYSCOLORCHANGE:
+        {
+            /* 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_ListView->SendMessage(EM_SETBKGNDCOLOR, 0, GetSysColor(COLOR_BTNFACE));
+        }
+        break;
+        }
+
+        return FALSE;
+    }
+
+public:
+    CUiMainWindow() :
+        m_ClientPanel(NULL),
+        hImageTreeView(NULL)
+    {
+
+    }
+
+    static ATL::CWndClassInfo& GetWndClassInfo()
+    {
+        DWORD csStyle = CS_VREDRAW |CS_HREDRAW;
+        static ATL::CWndClassInfo wc =
+        {
+            { sizeof(WNDCLASSEX), csStyle, StartWindowProc,
+            0, 0, NULL, 
+            LoadIcon(_AtlBaseModule.GetModuleInstance(), MAKEINTRESOURCE(IDI_MAIN)),
+            LoadCursor(NULL, IDC_ARROW),
+            (HBRUSH) (COLOR_BTNFACE + 1), NULL,
+            L"RAppsWnd", NULL },
+            NULL, NULL, IDC_ARROW, TRUE, 0, _T("")
+        };
+        return wc;
+    }
+
+    HWND Create()
+    {
+        WCHAR szWindowName[MAX_STR_LEN];
+
+        LoadStringW(hInst, IDS_APPTITLE, szWindowName, _countof(szWindowName));
+
+        RECT r = {
+            (SettingsInfo.bSaveWndPos ? SettingsInfo.Left : CW_USEDEFAULT),
+            (SettingsInfo.bSaveWndPos ? SettingsInfo.Top : CW_USEDEFAULT),
+            (SettingsInfo.bSaveWndPos ? SettingsInfo.Width : 680),
+            (SettingsInfo.bSaveWndPos ? SettingsInfo.Height : 450)
+        };
+        r.right += r.left;
+        r.bottom += r.top;
+
+        return CWindowImpl::Create(NULL, r, szWindowName, WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN | WS_CLIPSIBLINGS, WS_EX_WINDOWEDGE);
+    }
+
+    CUiStatusBar * GetStatusBar()
+    {
+        return m_StatusBar;
+    }
+
+    CUiListView * GetListView()
+    {
+        return m_ListView;
+    }
+
+    CUiRichEdit * GetRichEdit()
+    {
+        return m_RichEdit;
+    }
+};
+
+CUiMainWindow * g_MainWindow;
+
+HWND CreateMainWindow()
+{
+    g_MainWindow = new CUiMainWindow();
+    return g_MainWindow->Create();
+}
+
+DWORD_PTR ListViewGetlParam(INT item)
+{
+    return g_MainWindow->GetListView()->GetItemData(item);
+}
+
+VOID SetStatusBarText(PCWSTR szText)
+{
+    g_MainWindow->GetStatusBar()->SetText(szText);
+}
+
+INT ListViewAddItem(INT ItemIndex, INT IconIndex, PWSTR lpName, LPARAM lParam)
+{
+    return g_MainWindow->GetListView()->AddItem(ItemIndex, IconIndex, lpName, lParam);
+}
+
+VOID NewRichEditText(PCWSTR szText, DWORD flags)
+{
+    g_MainWindow->GetRichEdit()->SetText(szText, flags);
+}
+
+VOID InsertRichEditText(PCWSTR szText, DWORD flags)
+{
+    g_MainWindow->GetRichEdit()->InsertText(szText, flags);
+}
\ No newline at end of file
diff --git a/reactos/base/applications/rapps_new/listview.cpp b/reactos/base/applications/rapps_new/listview.cpp
deleted file mode 100644 (file)
index 7c65cab..0000000
+++ /dev/null
@@ -1,121 +0,0 @@
-/*
- * PROJECT:         ReactOS Applications Manager
- * LICENSE:         GPL - See COPYING in the top level directory
- * FILE:            base/applications/rapps/listview.c
- * PURPOSE:         ListView functions
- * PROGRAMMERS:     Dmitry Chapyshev (dmitry@reactos.org)
- */
-
-#include "rapps.h"
-
-HWND hListView;
-BOOL bAscending = TRUE;
-
-PVOID
-ListViewGetlParam(INT Index)
-{
-    INT ItemIndex;
-    LVITEM Item;
-
-    if (Index == -1)
-    {
-        ItemIndex = (INT) SendMessage(hListView, LVM_GETNEXTITEM, -1, LVNI_FOCUSED);
-        if (ItemIndex == -1)
-            return NULL;
-    }
-    else
-    {
-        ItemIndex = Index;
-    }
-
-    ZeroMemory(&Item, sizeof(LVITEM));
-
-    Item.mask = LVIF_PARAM;
-    Item.iItem = ItemIndex;
-    if (!ListView_GetItem(hListView, &Item))
-        return NULL;
-
-    return (PVOID)Item.lParam;
-}
-
-BOOL
-ListViewAddColumn(INT Index, LPWSTR lpText, INT Width, INT Format)
-{
-    LV_COLUMN Column;
-
-    ZeroMemory(&Column, sizeof(LV_COLUMN));
-
-    Column.mask     = LVCF_FMT | LVCF_TEXT | LVCF_WIDTH | LVCF_SUBITEM;
-    Column.iSubItem = Index;
-    Column.pszText  = (LPTSTR)lpText;
-    Column.cx       = Width;
-    Column.fmt      = Format;
-
-    return (ListView_InsertColumn(hListView, Index, &Column) == -1) ? FALSE : TRUE;
-}
-
-INT
-ListViewAddItem(INT ItemIndex, INT IconIndex, LPWSTR lpText, LPARAM lParam)
-{
-    LV_ITEMW Item;
-
-    ZeroMemory(&Item, sizeof(LV_ITEM));
-
-    Item.mask       = LVIF_TEXT | LVIF_PARAM | LVIF_STATE | LVIF_IMAGE;
-    Item.pszText    = lpText;
-    Item.lParam     = lParam;
-    Item.iItem      = ItemIndex;
-    Item.iImage     = IconIndex;
-
-    return ListView_InsertItem(hListView, &Item);
-}
-
-INT
-CALLBACK
-ListViewCompareFunc(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort)
-{
-    WCHAR Item1[MAX_STR_LEN], Item2[MAX_STR_LEN];
-    LVFINDINFO IndexInfo;
-    INT Index;
-
-    IndexInfo.flags = LVFI_PARAM;
-
-    IndexInfo.lParam = lParam1;
-    Index = ListView_FindItem(hListView, -1, &IndexInfo);
-    ListView_GetItemText(hListView, Index, (INT)lParamSort, Item1, sizeof(Item1) / sizeof(WCHAR));
-
-    IndexInfo.lParam = lParam2;
-    Index = ListView_FindItem(hListView, -1, &IndexInfo);
-    ListView_GetItemText(hListView, Index, (INT)lParamSort, Item2, sizeof(Item2) / sizeof(WCHAR));
-
-    if (bAscending)
-        return wcscmp(Item2, Item1);
-    else
-        return wcscmp(Item1, Item2);
-
-    return 0;
-}
-
-BOOL
-CreateListView(HWND hwnd)
-{
-    hListView = CreateWindowExW(WS_EX_CLIENTEDGE,
-                                WC_LISTVIEWW,
-                                L"",
-                                WS_CHILD | WS_VISIBLE | LVS_SORTASCENDING | LVS_REPORT | LVS_SINGLESEL | LVS_SHOWSELALWAYS,
-                                205, 28, 465, 250,
-                                hwnd,
-                                GetSubMenu(LoadMenuW(hInst, MAKEINTRESOURCEW(IDR_APPLICATIONMENU)), 0),
-                                hInst,
-                                NULL);
-
-    if (!hListView)
-    {
-        /* TODO: Show error message */
-        return FALSE;
-    }
-
-    (VOID) ListView_SetExtendedListViewStyle(hListView, LVS_EX_FULLROWSELECT);
-
-    return TRUE;
-}
index 409a4b2..a12309e 100644 (file)
@@ -149,15 +149,6 @@ extern SETTINGS_INFO SettingsInfo;
 VOID SaveSettings(HWND hwnd);
 VOID FillDefaultSettings(PSETTINGS_INFO pSettingsInfo);
 
-/* listview.c */
-extern HWND hListView;
-extern BOOL bAscending;
-BOOL CreateListView(HWND hwnd);
-BOOL ListViewAddColumn(INT Index, LPWSTR lpText, INT Width, INT Format);
-INT ListViewAddItem(INT ItemIndex, INT IconIndex, LPWSTR lpText, LPARAM lParam);
-INT CALLBACK ListViewCompareFunc(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort);
-PVOID ListViewGetlParam(INT Index);
-
 /* loaddlg.c */
 BOOL DownloadApplication(INT Index);
 VOID DownloadApplicationsDB(LPCWSTR lpUrl);
@@ -181,30 +172,9 @@ BOOL WriteLogMessage(WORD wType, DWORD dwEventID, LPWSTR lpMsg);
 UINT ParserGetString(LPCWSTR lpKeyName, LPWSTR lpReturnedString, UINT nSize, LPCWSTR lpFileName);
 UINT ParserGetInt(LPCWSTR lpKeyName, LPCWSTR lpFileName);
 
-/* richedit.c */
-extern HWND hRichEdit;
-extern PWSTR pLink;
-BOOL CreateRichEdit(HWND hwnd);
-VOID RichEditOnLink(HWND hwnd, ENLINK *Link);
-VOID InsertRichEditText(LPCWSTR lpszText, DWORD dwEffects);
-VOID NewRichEditText(LPCWSTR lpszText, DWORD dwEffects);
-
 /* settingsdlg.c */
 VOID CreateSettingsDlg(HWND hwnd);
 
-/* splitter.c */
-extern HWND hVSplitter;
-extern HWND hHSplitter;
-BOOL CreateVSplitBar(HWND hwnd);
-BOOL CreateHSplitBar(HWND hwnd);
-int GetHSplitterPos(VOID);
-VOID SetHSplitterPos(int Pos);
-
-/* statusbar.c */
-extern HWND hStatusBar;
-BOOL CreateStatusBar(HWND hwnd);
-VOID SetStatusBarText(LPCWSTR lpszText);
-
 /* toolbar.c */
 extern HWND hToolBar;
 extern HWND hSearchBar;
@@ -216,4 +186,14 @@ 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);
+INT ListViewAddItem(INT ItemIndex, INT IconIndex, PWSTR lpName, LPARAM lParam);
+VOID SetStatusBarText(PCWSTR szText);
+VOID NewRichEditText(PCWSTR szText, DWORD flags);
+VOID InsertRichEditText(PCWSTR szText, DWORD flags);
+extern HWND hListView;
+extern PWSTR pLink;
+
 #endif /* _RAPPS_H */
diff --git a/reactos/base/applications/rapps_new/richedit.cpp b/reactos/base/applications/rapps_new/richedit.cpp
deleted file mode 100644 (file)
index b6f1433..0000000
+++ /dev/null
@@ -1,136 +0,0 @@
-/*
- * PROJECT:         ReactOS Applications Manager
- * LICENSE:         GPL - See COPYING in the top level directory
- * FILE:            base/applications/rapps/richedit.c
- * PURPOSE:         RichEdit functions
- * PROGRAMMERS:     Dmitry Chapyshev (dmitry@reactos.org)
- */
-
-#include "rapps.h"
-
-#include <shlwapi.h>
-
-HWND hRichEdit;
-PWSTR pLink = NULL;
-
-VOID
-RichEditOnLink(HWND hwnd, 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(hRichEdit, EM_SETSEL, Link->chrg.cpMin, Link->chrg.cpMax);
-            SendMessageW(hRichEdit, EM_GETSELTEXT, 0, (LPARAM)pLink);
-
-            ShowPopupMenu(hwnd, IDR_LINKMENU, -1);
-        }
-        break;
-    }
-}
-
-static VOID
-SetRangeFormatting(LONG Start, LONG End, DWORD dwEffects)
-{
-    CHARFORMAT2 CharFormat;
-
-    SendMessageW(hRichEdit, EM_SETSEL, Start, End);
-
-    ZeroMemory(&CharFormat, sizeof(CHARFORMAT2));
-
-    CharFormat.cbSize = sizeof(CHARFORMAT2);
-    CharFormat.dwMask = dwEffects;
-    CharFormat.dwEffects = dwEffects;
-
-    SendMessageW(hRichEdit, EM_SETCHARFORMAT, SCF_WORD | SCF_SELECTION, (LPARAM)&CharFormat);
-
-    SendMessageW(hRichEdit, EM_SETSEL, End, End + 1);
-}
-
-static LONG
-GetRichEditTextLen(VOID)
-{
-    GETTEXTLENGTHEX TxtLenStruct;
-
-    TxtLenStruct.flags = GTL_NUMCHARS;
-    TxtLenStruct.codepage = 1200;
-
-    return (LONG) SendMessageW(hRichEdit, EM_GETTEXTLENGTHEX, (WPARAM)&TxtLenStruct, 0);
-}
-
-/*
- * Insert text (without cleaning old text)
- * Supported effects:
- *   - CFM_BOLD
- *   - CFM_ITALIC
- *   - CFM_UNDERLINE
- *   - CFM_LINK
- */
-VOID
-InsertRichEditText(LPCWSTR lpszText, DWORD dwEffects)
-{
-    SETTEXTEX SetText;
-    LONG Len = GetRichEditTextLen();
-
-    /* Insert new text */
-    SetText.flags = ST_SELECTION;
-    SetText.codepage = 1200;
-
-    SendMessageW(hRichEdit, 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
-NewRichEditText(LPCWSTR lpszText, DWORD dwEffects)
-{
-    SetWindowTextW(hRichEdit, L"");
-    InsertRichEditText(lpszText, dwEffects);
-}
-
-BOOL
-CreateRichEdit(HWND hwnd)
-{
-    LoadLibraryW(L"riched20.dll");
-
-    hRichEdit = CreateWindowExW(0,
-                                L"RichEdit20W",
-                                NULL,
-                                WS_CHILD | WS_VISIBLE | ES_MULTILINE |
-                                ES_LEFT | ES_READONLY,
-                                205, 28, 465, 100,
-                                hwnd,
-                                NULL,
-                                hInst,
-                                NULL);
-
-    if (!hRichEdit)
-    {
-        /* TODO: Show error message */
-        return FALSE;
-    }
-
-    SendMessageW(hRichEdit, EM_SETBKGNDCOLOR, 0, GetSysColor(COLOR_BTNFACE));
-    SendMessageW(hRichEdit, WM_SETFONT, (WPARAM)GetStockObject(DEFAULT_GUI_FONT), 0);
-    SendMessageW(hRichEdit, EM_SETEVENTMASK, 0, ENM_LINK | ENM_MOUSEEVENTS);
-    SendMessageW(hRichEdit, EM_SHOWSCROLLBAR, SB_VERT, TRUE);
-
-    return TRUE;
-}
diff --git a/reactos/base/applications/rapps_new/rosui.h b/reactos/base/applications/rapps_new/rosui.h
new file mode 100644 (file)
index 0000000..d210ab8
--- /dev/null
@@ -0,0 +1,796 @@
+/* PROJECT:     ReactOS UI Layout Engine
+ * LICENSE:     GPL - See COPYING in the top level directory
+ * AUTHORS:     David Quintana <gigaherz@gmail.com>
+ */
+#pragma once
+
+template<class T, int GrowthRate = 10>
+class CPointerArray
+{
+protected:
+    HDPA m_hDpa;
+
+public:
+    CPointerArray()
+    {
+        m_hDpa = DPA_Create(GrowthRate);
+    }
+
+    ~CPointerArray()
+    {
+        DPA_DestroyCallback(m_hDpa, s_OnRemoveItem, this);
+    }
+
+private:
+    static int CALLBACK s_OnRemoveItem(void * ptr, void * context)
+    {
+        CPointerArray * self = (CPointerArray*) context;
+        return (int) self->OnRemoveItem(reinterpret_cast<T*>(ptr));
+    }
+
+    static int CALLBACK s_OnCompareItems(void *p1, void *p2, LPARAM lParam)
+    {
+        CPointerArray * self = (CPointerArray*) lParam;
+        return self->OnCompareItems(reinterpret_cast<T*>(p1), reinterpret_cast<T*>(p2));
+    }
+
+public:
+    virtual BOOL OnRemoveItem(T * ptr)
+    {
+        return TRUE;
+    }
+
+    virtual int OnCompareItems(T * p1, T * p2)
+    {
+        int t = (reinterpret_cast<int>(p2) -reinterpret_cast<int>(p1));
+        if (t > 0)
+            return 1;
+        if (t < 0)
+            return -1;
+        return 0;
+    }
+
+public:
+    int GetCount() const
+    {
+        return DPA_GetPtrCount(m_hDpa);
+    }
+
+    T* Get(int i) const
+    {
+        return (T*) DPA_GetPtr(m_hDpa, i);
+    }
+
+    BOOL Set(int i, T* ptr)
+    {
+        return DPA_SetPtr(m_hDpa, i, ptr);
+    }
+
+    int Insert(int at, T* ptr)
+    {
+        return DPA_InsertPtr(m_hDpa, at, ptr);
+    }
+
+    int Append(T* ptr)
+    {
+        return DPA_InsertPtr(m_hDpa, DA_LAST, ptr);
+    }
+
+    int IndexOf(T* ptr) const
+    {
+        return DPA_GetPtrIndex(m_hDpa, ptr);
+    }
+
+    BOOL Remove(T* ptr)
+    {
+        int i = IndexOf(ptr);
+        if (i < 0)
+            return FALSE;
+        return RemoveAt(i);
+    }
+
+    BOOL RemoveAt(int i)
+    {
+        T* ptr = (T*) DPA_GetPtr(m_hDpa, i);
+        OnRemoveItem(ptr);
+        return DPA_DeletePtr(m_hDpa, i);
+    }
+
+    BOOL Clear()
+    {
+        DPA_EnumCallback(s_OnRemoveItem, this);
+        return DPA_DeleteAllPtrs(m_hDpa);
+    }
+
+    BOOL Sort()
+    {
+        return DPA_Sort(m_hDpa, s_OnCompareItems, (LPARAM)this);
+    }
+
+    int Search(T* item, int iStart, UINT uFlags)
+    {
+        return DPA_Search(m_hDpa, s_OnCompareItems, (LPARAM)this);
+    }
+};
+
+class CUiRect
+    : public RECT
+{
+public:
+    CUiRect()
+    {
+        left = right = top = bottom = 0;
+    }
+
+    CUiRect(int l, int t, int r, int b)
+    {
+        left = l;
+        right = r;
+        top = t;
+        bottom = b;
+    }
+};
+
+class CUiMargin
+    : public CUiRect
+{
+public:
+    CUiMargin()
+    {
+    }
+
+    CUiMargin(int all)
+        : CUiRect(all, all, all, all)
+    {
+    }
+
+    CUiMargin(int horz, int vert)
+        : CUiRect(horz, vert, horz, vert)
+    {
+    }
+};
+
+class CUiMeasure
+{
+public:
+    enum MeasureType
+    {
+        Type_FitContent = 0,
+        Type_Fixed = 1,
+        Type_Percent = 2,
+        Type_FitParent = 3
+    };
+
+private:
+    MeasureType m_Type;
+    int m_Value;
+
+public:
+    CUiMeasure()
+    {
+        m_Type = Type_FitContent;
+        m_Value = 0;
+    }
+
+    CUiMeasure(MeasureType type, int value)
+    {
+        m_Type = type;
+        m_Value = value;
+    }
+
+    int ComputeMeasure(int parent, int content)
+    {
+        switch (m_Type)
+        {
+        case Type_FitContent:
+            return content;
+        case Type_Fixed:
+            return m_Value;
+        case Type_Percent:
+            return max(content, parent * m_Value / 100);
+        case Type_FitParent:
+            return parent;
+        }
+
+        return 0;
+    }
+
+public:
+    static CUiMeasure FitContent()
+    {
+        return CUiMeasure(Type_FitContent, 0);
+    }
+
+    static CUiMeasure FitParent()
+    {
+        return CUiMeasure(Type_FitParent, 0);
+    }
+
+    static CUiMeasure Fixed(int pixels)
+    {
+        return CUiMeasure(Type_Fixed, pixels);
+    }
+
+    static CUiMeasure Percent(int percent)
+    {
+        return CUiMeasure(Type_Percent, percent);
+    }
+};
+
+enum CUiAlignment
+{
+    UiAlign_LeftTop,
+    UiAlign_Middle,
+    UiAlign_RightBtm,
+    UiAlign_Stretch
+};
+
+class CUiBox
+{
+public:
+    CUiMargin m_Margin;
+
+    CUiAlignment m_HorizontalAlignment;
+    CUiAlignment m_VerticalAlignment;
+
+protected:
+    CUiBox()
+    {
+        m_HorizontalAlignment = UiAlign_LeftTop;
+        m_VerticalAlignment = UiAlign_LeftTop;
+    }
+
+    virtual void ComputeRect(RECT parentRect, RECT currentRect, RECT* newRect)
+    {
+        parentRect.left += m_Margin.left;
+        parentRect.right -= m_Margin.right;
+        parentRect.top += m_Margin.top;
+        parentRect.bottom -= m_Margin.bottom;
+
+        if (parentRect.right < parentRect.left)
+            parentRect.right = parentRect.left;
+
+        if (parentRect.bottom < parentRect.top)
+            parentRect.bottom = parentRect.top;
+
+        SIZE szParent = { parentRect.right - parentRect.left, parentRect.bottom - parentRect.top };
+        SIZE szCurrent = { currentRect.right - currentRect.left, currentRect.bottom - currentRect.top };
+
+        currentRect = parentRect;
+
+        switch (m_HorizontalAlignment)
+        {
+        case UiAlign_LeftTop:
+            currentRect.right = currentRect.left + szCurrent.cx;
+            break;
+        case UiAlign_Middle:
+            currentRect.left = parentRect.left + (szParent.cx - szCurrent.cx) / 2;
+            currentRect.right = currentRect.left + szCurrent.cx;
+            break;
+        case UiAlign_RightBtm:
+            currentRect.left = currentRect.right - szCurrent.cx;
+            break;
+        default:
+            break;
+        }
+
+        switch (m_VerticalAlignment)
+        {
+        case UiAlign_LeftTop:
+            currentRect.bottom = currentRect.top + szCurrent.cy;
+            break;
+        case UiAlign_Middle:
+            currentRect.top = parentRect.top + (szParent.cy - szCurrent.cy) / 2;
+            currentRect.bottom = currentRect.top + szCurrent.cy;
+            break;
+        case UiAlign_RightBtm:
+            currentRect.top = currentRect.bottom - szCurrent.cy;
+            break;
+        default:
+            break;
+        }
+
+        *newRect = currentRect;
+    }
+
+
+public:
+    virtual void ComputeMinimalSize(SIZE* size)
+    {
+        // Override in subclass
+        size->cx = max(size->cx, 0);
+        size->cy = min(size->cy, 0);
+    };
+
+    virtual void ComputeContentBounds(RECT* rect)
+    {
+        // Override in subclass
+    };
+
+    virtual DWORD_PTR CountSizableChildren()
+    {
+        // Override in subclass
+        return 0;
+    };
+
+    virtual HDWP OnParentSize(RECT parentRect, HDWP hDwp)
+    {
+        // Override in subclass
+        return NULL;
+    };
+};
+
+class CUiPrimitive
+{
+protected:
+    CUiPrimitive * m_Parent;
+
+public:
+    virtual ~CUiPrimitive() {}
+
+    virtual CUiBox * AsBox() { return NULL; }
+};
+
+class CUiCollection :
+    public CPointerArray < CUiPrimitive >
+{
+    virtual BOOL OnRemoveItem(CUiPrimitive * ptr)
+    {
+        delete ptr;
+        return TRUE;
+    }
+};
+
+class CUiContainer
+{
+protected:
+    CUiCollection m_Children;
+
+public:
+    CUiCollection& Children() { return m_Children; }
+};
+
+class CUiPanel :
+    public CUiPrimitive,
+    public CUiBox,
+    public CUiContainer
+{
+public:
+    CUiMeasure m_Width;
+    CUiMeasure m_Height;
+
+    CUiPanel()
+    {
+        m_Width = CUiMeasure::FitParent();
+        m_Height = CUiMeasure::FitParent();
+    }
+
+    virtual ~CUiPanel()
+    {
+    }
+
+    virtual CUiBox * AsBox() { return this; }
+
+    virtual void ComputeMinimalSize(SIZE* size)
+    {
+        for (int i = 0; i < m_Children.GetCount(); i++)
+        {
+            CUiBox * box = m_Children.Get(i)->AsBox();
+            if (box)
+            {
+                box->ComputeMinimalSize(size);
+            }
+        }
+    };
+
+    virtual void ComputeContentBounds(RECT* rect)
+    {
+        for (int i = 0; i < m_Children.GetCount(); i++)
+        {
+            CUiBox * box = m_Children.Get(i)->AsBox();
+            if (box)
+            {
+                box->ComputeContentBounds(rect);
+            }
+        }
+    };
+
+    virtual DWORD_PTR CountSizableChildren()
+    {
+        int count = 0;
+        for (int i = 0; i < m_Children.GetCount(); i++)
+        {
+            CUiBox * box = m_Children.Get(i)->AsBox();
+            if (box)
+            {
+                count += box->CountSizableChildren();
+            }
+        }
+        return count;
+    }
+
+    virtual HDWP OnParentSize(RECT parentRect, HDWP hDwp)
+    {
+        RECT rect = { 0 };
+
+        SIZE content = { 0 };
+        ComputeMinimalSize(&content);
+
+        int preferredWidth = m_Width.ComputeMeasure(parentRect.right - parentRect.left, content.cx);
+        int preferredHeight = m_Height.ComputeMeasure(parentRect.bottom - parentRect.top, content.cy);
+
+        rect.right = preferredWidth;
+        rect.bottom = preferredHeight;
+
+        ComputeRect(parentRect, rect, &rect);
+
+        for (int i = 0; i < m_Children.GetCount(); i++)
+        {
+            CUiBox * box = m_Children.Get(i)->AsBox();
+            if (box)
+            {
+                hDwp = box->OnParentSize(rect, hDwp);
+            }
+        }
+
+        return hDwp;
+    }
+};
+
+template<class T = CWindow>
+class CUiWindow :
+    public CUiPrimitive,
+    public CUiBox,
+    public T
+{
+public:
+    virtual CUiBox * AsBox() { return this; }
+
+    HWND GetWindow() { return T::m_hWnd; }
+
+    virtual void ComputeMinimalSize(SIZE* size)
+    {
+        // TODO: Maybe use WM_GETMINMAXINFO?
+        return CUiBox::ComputeMinimalSize(size);
+    };
+
+    virtual void ComputeContentBounds(RECT* rect)
+    {
+        RECT r;
+        GetWindowRect(T::m_hWnd, &r);
+        rect->left = min(rect->left, r.left);
+        rect->top = min(rect->top, r.top);
+        rect->right = max(rect->right, r.right);
+        rect->bottom = max(rect->bottom, r.bottom);
+    };
+
+    virtual DWORD_PTR CountSizableChildren()
+    {
+        return 1;
+    };
+
+    virtual HDWP OnParentSize(RECT parentRect, HDWP hDwp)
+    {
+        RECT rect;
+
+        ::GetWindowRect(T::m_hWnd, &rect);
+
+        ComputeRect(parentRect, rect, &rect);
+
+        if (hDwp)
+        {
+            return DeferWindowPos(hDwp, T::m_hWnd, NULL, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, SWP_NOACTIVATE | SWP_NOZORDER);
+        }
+        else
+        {
+            T::SetWindowPos(NULL, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, SWP_NOACTIVATE | SWP_NOZORDER | SWP_DEFERERASE);
+            return NULL;
+        }
+    };
+
+public:
+    virtual ~CUiWindow()
+    {
+        T::DestroyWindow();
+    }
+};
+
+class CUiSplitPanel :
+    public CUiPrimitive,
+    public CUiBox,
+    public CWindowImpl<CUiSplitPanel>
+{
+    static const int THICKNESS = 4;
+
+protected:
+
+    HCURSOR m_hCursor;
+
+    CUiPanel m_First;
+    CUiPanel m_Second;
+
+    RECT m_LastRect;
+
+    BOOL m_HasOldRect;
+
+public:
+    int m_Pos;
+    BOOL m_Horizontal;
+    BOOL m_DynamicFirst;
+    int m_MinFirst;
+    int m_MinSecond;
+
+    CUiMeasure m_Width;
+    CUiMeasure m_Height;
+
+public:
+    CUiSplitPanel()
+    {
+        m_Width = CUiMeasure::FitParent();
+        m_Height = CUiMeasure::FitParent();
+        m_Pos = 100;
+        m_MinFirst = 100;
+        m_MinSecond = 100;
+        m_DynamicFirst = FALSE;
+        m_HasOldRect = FALSE;
+    }
+
+    virtual ~CUiSplitPanel()
+    {
+    }
+
+    virtual CUiBox * AsBox() { return this; }
+
+    CUiCollection& First() { return m_First.Children(); }
+    CUiCollection& Second() { return m_Second.Children(); }
+
+    virtual void ComputeMinimalSize(SIZE* size)
+    {
+        if (m_Horizontal)
+            size->cx = max(size->cx, THICKNESS);
+        else
+            size->cy = max(size->cy, THICKNESS);
+        m_First.ComputeMinimalSize(size);
+        m_Second.ComputeMinimalSize(size);
+    };
+
+    virtual void ComputeContentBounds(RECT* rect)
+    {
+        RECT r;
+
+        m_First.ComputeContentBounds(rect);
+        m_Second.ComputeContentBounds(rect);
+
+        ::GetWindowRect(m_hWnd, &r);
+
+        rect->left = min(rect->left, r.left);
+        rect->top = min(rect->top, r.top);
+        rect->right = max(rect->right, r.right);
+        rect->bottom = max(rect->bottom, r.bottom);
+    };
+
+    virtual DWORD_PTR CountSizableChildren()
+    {
+        int count = 1;
+        count += m_First.CountSizableChildren();
+        count += m_Second.CountSizableChildren();
+        return count;
+    };
+
+    virtual HDWP OnParentSize(RECT parentRect, HDWP hDwp)
+    {
+        RECT rect = { 0 };
+
+        SIZE content = { 0 };
+        ComputeMinimalSize(&content);
+
+        int preferredWidth = m_Width.ComputeMeasure(parentRect.right - parentRect.left, content.cx);
+        int preferredHeight = m_Width.ComputeMeasure(parentRect.bottom - parentRect.top, content.cy);
+
+        rect.right = preferredWidth;
+        rect.bottom = preferredHeight;
+
+        ComputeRect(parentRect, rect, &rect);
+
+        SIZE growth = { 0 };
+        if (m_HasOldRect)
+        {
+            RECT oldRect = m_LastRect;
+
+            growth.cx = (parentRect.right - parentRect.left) - (oldRect.right - oldRect.left);
+            growth.cy = (parentRect.bottom - parentRect.top) - (oldRect.bottom - oldRect.top);
+        }
+
+        RECT splitter = rect;
+        RECT first = rect;
+        RECT second = rect;
+
+        if (m_Horizontal)
+        {
+            rect.top += m_MinFirst;
+            rect.bottom -= THICKNESS + m_MinSecond;
+            if (m_DynamicFirst)
+            {
+                if (growth.cy > 0)
+                {
+                    m_Pos += min(growth.cy, rect.bottom - (m_Pos+THICKNESS));
+                }
+                else if (growth.cy < 0)
+                {
+                    m_Pos += max(growth.cy, rect.top - m_Pos);
+                }
+            }
+
+            if (m_Pos > rect.bottom)
+                m_Pos = rect.bottom;
+
+            if (m_Pos < rect.top)
+                m_Pos = rect.top;
+
+            splitter.top = m_Pos;
+            splitter.bottom = m_Pos + THICKNESS;
+            first.bottom = splitter.top;
+            second.top = splitter.bottom;
+        }
+        else
+        {
+            rect.left += m_MinFirst;
+            rect.right -= THICKNESS + m_MinSecond;
+            if (m_DynamicFirst)
+            {
+                if (growth.cx > 0)
+                {
+                    m_Pos += min(growth.cx, rect.right - (m_Pos + THICKNESS));
+                }
+                else if (growth.cx < 0)
+                {
+                    m_Pos += max(growth.cy, rect.left - m_Pos);
+                }
+            }
+
+            if (m_Pos > rect.right)
+                m_Pos = rect.right;
+
+            if (m_Pos < rect.left)
+                m_Pos = rect.left;
+
+            splitter.left = m_Pos;
+            splitter.right = m_Pos + THICKNESS;
+            first.right = splitter.left;
+            second.left = splitter.right;
+        }
+
+        m_LastRect = parentRect;
+        m_HasOldRect = TRUE;
+        
+        hDwp = m_First.OnParentSize(first, hDwp);
+        hDwp = m_Second.OnParentSize(second, hDwp);
+
+        if (hDwp)
+        {
+            return DeferWindowPos(hDwp, m_hWnd, NULL,
+                splitter.left, splitter.top,
+                splitter.right - splitter.left,
+                splitter.bottom - splitter.top,
+                SWP_NOACTIVATE | SWP_NOZORDER);
+        }
+        else
+        {
+            SetWindowPos(NULL,
+                splitter.left, splitter.top,
+                splitter.right - splitter.left,
+                splitter.bottom - splitter.top,
+                SWP_NOACTIVATE | SWP_NOZORDER);
+            return NULL;
+        }
+    };
+
+private:
+    BOOL ProcessWindowMessage(HWND hwnd, UINT Msg, WPARAM wParam, LPARAM lParam, LRESULT& theResult, DWORD dwMapId)
+    {
+        theResult = 0;
+        switch (Msg)
+        {
+        case WM_SETCURSOR:
+            SetCursor(m_hCursor);
+            theResult = TRUE;
+            break;
+
+        case WM_LBUTTONDOWN:
+            SetCapture();
+            break;
+
+        case WM_LBUTTONUP:
+        case WM_RBUTTONDOWN:
+            if (GetCapture() == m_hWnd)
+            {
+                ReleaseCapture();
+            }
+            break;
+
+        case WM_MOUSEMOVE:
+            if (GetCapture() == m_hWnd)
+            {
+                POINT Point;
+                GetCursorPos(&Point);
+                ::ScreenToClient(GetParent(), &Point);
+                if (m_Horizontal)
+                    SetPos(Point.y);
+                else
+                    SetPos(Point.x);
+            }
+            break;
+
+        default:
+            return FALSE;
+        }
+
+        return TRUE;
+    }
+
+public:
+    int GetPos(VOID)
+    {
+        return m_Pos;
+    }
+
+    void SetPos(int NewPos)
+    {
+        RECT rcParent;
+
+        rcParent = m_LastRect;
+
+        if (m_Horizontal)
+        {
+            rcParent.bottom -= THICKNESS;
+
+            m_Pos = NewPos;
+
+            if (m_Pos < rcParent.top)
+                m_Pos = rcParent.top;
+
+            if (m_Pos > rcParent.bottom)
+                m_Pos = rcParent.bottom;
+        }
+        else
+        {
+            rcParent.right -= THICKNESS;
+
+            m_Pos = NewPos;
+
+            if (m_Pos < rcParent.left)
+                m_Pos = rcParent.left;
+
+            if (m_Pos > rcParent.right)
+                m_Pos = rcParent.right;
+        }
+
+        int count = CountSizableChildren();
+
+        HDWP hdwp = NULL;
+        hdwp = BeginDeferWindowPos(count);
+        hdwp = OnParentSize(m_LastRect, hdwp);
+        EndDeferWindowPos(hdwp);
+    }
+
+public:
+    DECLARE_WND_CLASS_EX(_T("SplitterWindowClass"), CS_HREDRAW | CS_VREDRAW, COLOR_BTNFACE)
+
+    /* Create splitter bar */
+    HWND Create(HWND hwndParent)
+    {
+        if (m_Horizontal)
+            m_hCursor = LoadCursor(0, IDC_SIZENS);
+        else
+            m_hCursor = LoadCursor(0, IDC_SIZEWE);
+
+        DWORD style = WS_CHILD | WS_VISIBLE;
+        DWORD exStyle = WS_EX_TRANSPARENT;
+
+        RECT size = { 205, 180, 465, THICKNESS };
+        size.right += size.left;
+        size.bottom += size.top;
+
+        return CWindowImpl::Create(hwndParent, size, NULL, style, exStyle);
+    }
+};
diff --git a/reactos/base/applications/rapps_new/statusbar.cpp b/reactos/base/applications/rapps_new/statusbar.cpp
deleted file mode 100644 (file)
index 238cd54..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * PROJECT:         ReactOS Applications Manager
- * LICENSE:         GPL - See COPYING in the top level directory
- * FILE:            base/applications/rapps/statusbar.c
- * PURPOSE:         StatusBar functions
- * PROGRAMMERS:     Dmitry Chapyshev (dmitry@reactos.org)
- */
-
-#include "rapps.h"
-
-HWND hStatusBar;
-
-BOOL
-CreateStatusBar(HWND hwnd)
-{
-    hStatusBar = CreateWindowExW(0,
-                                 STATUSCLASSNAMEW,
-                                 NULL,
-                                 WS_CHILD | WS_VISIBLE | SBARS_SIZEGRIP,
-                                 0, 0, 0, 0,
-                                 hwnd,
-                                 (HMENU)IDC_STATUSBAR,
-                                 hInst,
-                                 NULL);
-
-    if (!hStatusBar)
-    {
-        /* TODO: Show error message */
-        return FALSE;
-    }
-
-    return TRUE;
-}
-
-VOID
-SetStatusBarText(LPCWSTR lpszText)
-{
-    if (hStatusBar)
-    {
-        SendMessageW(hStatusBar, SB_SETTEXT, SBT_NOBORDERS, (LPARAM)lpszText);
-    }
-}
index 51ddef5..81d567b 100644 (file)
@@ -110,35 +110,6 @@ InitImageList(VOID)
     return hImageList;
 }
 
-static
-BOOL
-CreateSearchBar(VOID)
-{
-    WCHAR szBuf[MAX_STR_LEN];
-
-    hSearchBar = CreateWindowExW(WS_EX_CLIENTEDGE,
-                                 L"Edit",
-                                 NULL,
-                                 WS_CHILD | WS_VISIBLE | ES_LEFT | ES_AUTOHSCROLL, 
-                                 0,
-                                 5,
-                                 200,
-                                 22,
-                                 hToolBar,
-                                 (HMENU)0,
-                                 hInst,
-                                 0);
-
-    SendMessageW(hSearchBar, WM_SETFONT, (WPARAM)GetStockObject(DEFAULT_GUI_FONT), 0);
-
-    LoadStringW(hInst, IDS_SEARCH_TEXT, szBuf, sizeof(szBuf) / sizeof(WCHAR));
-    SetWindowTextW(hSearchBar, szBuf);
-
-    SetParent(hSearchBar, hToolBar); 
-
-    return TRUE;
-}
-
 BOOL
 CreateToolBar(HWND hwnd)
 {
@@ -183,7 +154,5 @@ CreateToolBar(HWND hwnd)
 
     SendMessageW(hToolBar, TB_ADDBUTTONS, NumButtons, (LPARAM)Buttons);
 
-    CreateSearchBar();
-
     return TRUE;
 }
index 59aec0a..8d4b8c8 100644 (file)
@@ -17,7 +17,6 @@
 
 HWND hMainWnd;
 HINSTANCE hInst;
-HIMAGELIST hImageTreeView = NULL;
 INT SelectedEnumType = ENUM_ALL_COMPONENTS;
 SETTINGS_INFO SettingsInfo;
 
@@ -285,115 +284,6 @@ UpdateApplicationsList(INT EnumType)
     SendMessage(hListView, WM_SETREDRAW, TRUE, 0);
 }
 
-VOID
-InitApplicationsList(VOID)
-{
-    WCHAR szText[MAX_STR_LEN];
-
-    /* Add columns to ListView */
-    LoadStringW(hInst, IDS_APP_NAME, szText, _countof(szText));
-    ListViewAddColumn(0, szText, 200, LVCFMT_LEFT);
-
-    LoadStringW(hInst, IDS_APP_INST_VERSION, szText, _countof(szText));
-    ListViewAddColumn(1, szText, 90, LVCFMT_RIGHT);
-
-    LoadStringW(hInst, IDS_APP_DESCRIPTION, szText, _countof(szText));
-    ListViewAddColumn(3, szText, 250, LVCFMT_LEFT);
-
-    UpdateApplicationsList(ENUM_ALL_COMPONENTS);
-}
-
-HTREEITEM
-AddCategory(HTREEITEM hRootItem, UINT TextIndex, UINT IconIndex)
-{
-    WCHAR szText[MAX_STR_LEN];
-    INT Index;
-    HICON hIcon;
-
-    hIcon = (HICON)LoadImage(hInst,
-                      MAKEINTRESOURCE(IconIndex),
-                      IMAGE_ICON,
-                      TREEVIEW_ICON_SIZE,
-                      TREEVIEW_ICON_SIZE,
-                      LR_CREATEDIBSECTION);
-
-    Index = ImageList_AddIcon(hImageTreeView, hIcon);
-    DestroyIcon(hIcon);
-
-    LoadStringW(hInst, TextIndex, szText, _countof(szText));
-
-    return TreeViewAddItem(hRootItem, szText, Index, Index, TextIndex);
-}
-
-VOID
-InitCategoriesList(VOID)
-{
-    HTREEITEM hRootItem1, hRootItem2;
-
-    /* Create image list */
-    hImageTreeView = ImageList_Create(TREEVIEW_ICON_SIZE,
-                                      TREEVIEW_ICON_SIZE,
-                                      GetSystemColorDepth() | ILC_MASK,
-                                      0, 1);
-
-    hRootItem1 = AddCategory(TVI_ROOT, IDS_INSTALLED, IDI_CATEGORY);
-    AddCategory(hRootItem1, IDS_APPLICATIONS, IDI_APPS);
-    AddCategory(hRootItem1, IDS_UPDATES, IDI_APPUPD);
-
-    hRootItem2 = AddCategory(TVI_ROOT, IDS_AVAILABLEFORINST, IDI_CATEGORY);
-    AddCategory(hRootItem2, IDS_CAT_AUDIO, IDI_CAT_AUDIO);
-    AddCategory(hRootItem2, IDS_CAT_VIDEO, IDI_CAT_VIDEO);
-    AddCategory(hRootItem2, IDS_CAT_GRAPHICS, IDI_CAT_GRAPHICS);
-    AddCategory(hRootItem2, IDS_CAT_GAMES, IDI_CAT_GAMES);
-    AddCategory(hRootItem2, IDS_CAT_INTERNET, IDI_CAT_INTERNET);
-    AddCategory(hRootItem2, IDS_CAT_OFFICE, IDI_CAT_OFFICE);
-    AddCategory(hRootItem2, IDS_CAT_DEVEL, IDI_CAT_DEVEL);
-    AddCategory(hRootItem2, IDS_CAT_EDU, IDI_CAT_EDU);
-    AddCategory(hRootItem2, IDS_CAT_ENGINEER, IDI_CAT_ENGINEER);
-    AddCategory(hRootItem2, IDS_CAT_FINANCE, IDI_CAT_FINANCE);
-    AddCategory(hRootItem2, IDS_CAT_SCIENCE, IDI_CAT_SCIENCE);
-    AddCategory(hRootItem2, IDS_CAT_TOOLS, IDI_CAT_TOOLS);
-    AddCategory(hRootItem2, IDS_CAT_DRIVERS, IDI_CAT_DRIVERS);
-    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);
-}
-
-BOOL
-InitControls(HWND hwnd)
-{
-
-    if (CreateStatusBar(hwnd) &&
-        CreateToolBar(hwnd)   &&
-        CreateListView(hwnd)  &&
-        CreateTreeView(hwnd)  &&
-        CreateRichEdit(hwnd)  &&
-        CreateVSplitBar(hwnd) &&
-        CreateHSplitBar(hwnd))
-    {
-        WCHAR szBuffer1[MAX_STR_LEN], szBuffer2[MAX_STR_LEN];
-
-        InitApplicationsList();
-
-        InitCategoriesList();
-
-        LoadStringW(hInst, IDS_APPS_COUNT, szBuffer2, _countof(szBuffer2));
-        StringCbPrintfW(szBuffer1, sizeof(szBuffer1),
-                        szBuffer2,
-                        ListView_GetItemCount(hListView));
-        SetStatusBarText(szBuffer1);
-        return TRUE;
-    }
-
-    return FALSE;
-}
-
 VOID CALLBACK
 SearchTimerProc(HWND hwnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime)
 {
@@ -529,93 +419,6 @@ MainWndOnCommand(HWND hwnd, WPARAM wParam, LPARAM lParam)
     }
 }
 
-VOID
-MainWndOnSize(HWND hwnd, WPARAM wParam, LPARAM lParam)
-{
-    HDWP hdwp = BeginDeferWindowPos(5);
-    INT SearchBarWidth = GetWindowWidth(hSearchBar);
-    INT RichPos = GetWindowHeight(hRichEdit);
-    INT NewPos = HIWORD(lParam) - (RichPos + SPLIT_WIDTH + GetWindowHeight(hStatusBar));
-    INT VSplitterPos;
-
-    /* Size status bar */
-    SendMessage(hStatusBar, WM_SIZE, 0, 0);
-
-    /* Size tool bar */
-    SendMessage(hToolBar, TB_AUTOSIZE, 0, 0);
-
-    /* Size SearchBar */
-    MoveWindow(hSearchBar, LOWORD(lParam) - SearchBarWidth - 4, 5, SearchBarWidth, 22, TRUE);
-
-    /*
-     * HIWORD(lParam) - Height of main window
-     * LOWORD(lParam) - Width of main window
-     */
-
-    /* Size vertical splitter bar */
-    DeferWindowPos(hdwp,
-                   hVSplitter,
-                   0,
-                   (VSplitterPos = GetWindowWidth(hTreeView)),
-                   GetWindowHeight(hToolBar),
-                   SPLIT_WIDTH,
-                   HIWORD(lParam) - GetWindowHeight(hToolBar) - GetWindowHeight(hStatusBar),
-                   SWP_NOZORDER|SWP_NOACTIVATE);
-
-    /* Size TreeView */
-    DeferWindowPos(hdwp,
-                   hTreeView,
-                   0,
-                   0,
-                   GetWindowHeight(hToolBar),
-                   VSplitterPos,
-                   HIWORD(lParam) - GetWindowHeight(hToolBar) - GetWindowHeight(hStatusBar),
-                   SWP_NOZORDER|SWP_NOACTIVATE);
-
-    if(wParam != SIZE_MINIMIZED)
-    {
-        while (NewPos < SPLIT_WIDTH + GetWindowHeight(hToolBar))
-        {
-            RichPos--;
-            NewPos = HIWORD(lParam) - (RichPos +
-                     SPLIT_WIDTH + GetWindowHeight(hStatusBar));
-        }
-    }
-    SetHSplitterPos(NewPos);
-
-    /* Size ListView */
-    DeferWindowPos(hdwp,
-                   hListView,
-                   0,
-                   VSplitterPos + SPLIT_WIDTH,
-                   GetWindowHeight(hToolBar),
-                   LOWORD(lParam) - (VSplitterPos + SPLIT_WIDTH),
-                   GetHSplitterPos() - GetWindowHeight(hToolBar),
-                   SWP_NOZORDER|SWP_NOACTIVATE);
-
-    /* Size RichEdit */
-    DeferWindowPos(hdwp,
-                   hRichEdit,
-                   0,
-                   VSplitterPos + SPLIT_WIDTH,
-                   GetHSplitterPos() + SPLIT_WIDTH,
-                   LOWORD(lParam) - (VSplitterPos + SPLIT_WIDTH),
-                   RichPos,
-                   SWP_NOZORDER|SWP_NOACTIVATE);
-
-    /* Size horizontal splitter bar */
-    DeferWindowPos(hdwp,
-                   hHSplitter,
-                   0,
-                   VSplitterPos + SPLIT_WIDTH,
-                   GetHSplitterPos(),
-                   LOWORD(lParam) - (VSplitterPos + SPLIT_WIDTH),
-                   SPLIT_WIDTH,
-                   SWP_NOZORDER|SWP_NOACTIVATE);
-
-    EndDeferWindowPos(hdwp);
-}
-
 BOOL IsSelectedNodeInstalled(void)
 {
     HTREEITEM hSelectedItem = TreeView_GetSelection(hTreeView);
@@ -635,306 +438,10 @@ BOOL IsSelectedNodeInstalled(void)
     }
 }
 
-LRESULT CALLBACK
-MainWindowProc(HWND hwnd, UINT Msg, WPARAM wParam, LPARAM lParam)
-{
-
-    switch (Msg)
-    {
-        case WM_CREATE:
-            if (!InitControls(hwnd))
-                PostMessage(hwnd, WM_CLOSE, 0, 0);
-            break;
-
-        case WM_COMMAND:
-            MainWndOnCommand(hwnd, wParam, lParam);
-            break;
-
-        case WM_NOTIFY:
-        {
-            LPNMHDR data = (LPNMHDR)lParam;
-
-            switch (data->code)
-            {
-                case TVN_SELCHANGED:
-                {
-                    if (data->hwndFrom == hTreeView)
-                    {
-                        switch (((LPNMTREEVIEW)lParam)->itemNew.lParam)
-                        {
-                            case IDS_INSTALLED:
-                                UpdateApplicationsList(ENUM_ALL_COMPONENTS);
-                                break;
-
-                            case IDS_APPLICATIONS:
-                                UpdateApplicationsList(ENUM_APPLICATIONS);
-                                break;
-
-                            case IDS_UPDATES:
-                                UpdateApplicationsList(ENUM_UPDATES);
-                                break;
-
-                            case IDS_AVAILABLEFORINST:
-                                UpdateApplicationsList(ENUM_ALL_AVAILABLE);
-                                break;
-
-                            case IDS_CAT_AUDIO:
-                                UpdateApplicationsList(ENUM_CAT_AUDIO);
-                                break;
-
-                            case IDS_CAT_DEVEL:
-                                UpdateApplicationsList(ENUM_CAT_DEVEL);
-                                break;
-
-                            case IDS_CAT_DRIVERS:
-                                UpdateApplicationsList(ENUM_CAT_DRIVERS);
-                                break;
-
-                            case IDS_CAT_EDU:
-                                UpdateApplicationsList(ENUM_CAT_EDU);
-                                break;
-
-                            case IDS_CAT_ENGINEER:
-                                UpdateApplicationsList(ENUM_CAT_ENGINEER);
-                                break;
-
-                            case IDS_CAT_FINANCE:
-                                UpdateApplicationsList(ENUM_CAT_FINANCE);
-                                break;
-
-                            case IDS_CAT_GAMES:
-                                UpdateApplicationsList(ENUM_CAT_GAMES);
-                                break;
-
-                            case IDS_CAT_GRAPHICS:
-                                UpdateApplicationsList(ENUM_CAT_GRAPHICS);
-                                break;
-
-                            case IDS_CAT_INTERNET:
-                                UpdateApplicationsList(ENUM_CAT_INTERNET);
-                                break;
-
-                            case IDS_CAT_LIBS:
-                                UpdateApplicationsList(ENUM_CAT_LIBS);
-                                break;
-
-                            case IDS_CAT_OFFICE:
-                                UpdateApplicationsList(ENUM_CAT_OFFICE);
-                                break;
-
-                            case IDS_CAT_OTHER:
-                                UpdateApplicationsList(ENUM_CAT_OTHER);
-                                break;
-
-                            case IDS_CAT_SCIENCE:
-                                UpdateApplicationsList(ENUM_CAT_SCIENCE);
-                                break;
-
-                            case IDS_CAT_TOOLS:
-                                UpdateApplicationsList(ENUM_CAT_TOOLS);
-                                break;
-
-                            case IDS_CAT_VIDEO:
-                                UpdateApplicationsList(ENUM_CAT_VIDEO);
-                                break;
-                        }
-                    }
-
-                    /* Disable/enable items based on treeview selection */
-                    if (IsSelectedNodeInstalled())
-                    {
-                        EnableMenuItem(GetMenu(hwnd), ID_REGREMOVE, MF_ENABLED);
-                        EnableMenuItem(GetMenu(hwnd), ID_INSTALL, MF_GRAYED);
-                        EnableMenuItem(GetMenu(hwnd), ID_UNINSTALL, MF_ENABLED);
-                        EnableMenuItem(GetMenu(hwnd), ID_MODIFY, MF_ENABLED);
-
-                        EnableMenuItem(GetMenu(hListView), ID_REGREMOVE, MF_ENABLED);
-                        EnableMenuItem(GetMenu(hListView), ID_INSTALL, MF_GRAYED);
-                        EnableMenuItem(GetMenu(hListView), ID_UNINSTALL, MF_ENABLED);
-                        EnableMenuItem(GetMenu(hListView), 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);
-                    }
-                    else
-                    {
-                        EnableMenuItem(GetMenu(hwnd), ID_REGREMOVE, MF_GRAYED);
-                        EnableMenuItem(GetMenu(hwnd), ID_INSTALL, MF_ENABLED);
-                        EnableMenuItem(GetMenu(hwnd), ID_UNINSTALL, MF_GRAYED);
-                        EnableMenuItem(GetMenu(hwnd), ID_MODIFY, MF_GRAYED);
-
-                        EnableMenuItem(GetMenu(hListView), ID_REGREMOVE, MF_GRAYED);
-                        EnableMenuItem(GetMenu(hListView), ID_INSTALL, MF_ENABLED);
-                        EnableMenuItem(GetMenu(hListView), ID_UNINSTALL, MF_GRAYED);
-                        EnableMenuItem(GetMenu(hListView), 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);
-                    }
-                }
-                break;
-
-                case LVN_ITEMCHANGED:
-                {
-                    LPNMLISTVIEW pnic = (LPNMLISTVIEW) lParam;
-
-                    if (pnic->hdr.hwndFrom == hListView)
-                    {
-                        /* Check if this is a valid item
-                         * (technically, it can be also an unselect) */
-                        INT ItemIndex = pnic->iItem;
-                        if (ItemIndex == -1 ||
-                            ItemIndex >= ListView_GetItemCount(pnic->hdr.hwndFrom))
-                        {
-                            break;
-                        }
-
-                        /* Check if the focus has been moved to another item */
-                        if ((pnic->uChanged & LVIF_STATE) &&
-                            (pnic->uNewState & LVIS_FOCUSED) &&
-                            !(pnic->uOldState & LVIS_FOCUSED))
-                        {
-                            if (IS_INSTALLED_ENUM(SelectedEnumType))
-                                ShowInstalledAppInfo(ItemIndex);
-                            if (IS_AVAILABLE_ENUM(SelectedEnumType))
-                                ShowAvailableAppInfo(ItemIndex);
-                        }
-                    }
-                }
-                break;
-
-                case LVN_COLUMNCLICK:
-                {
-                    LPNMLISTVIEW pnmv = (LPNMLISTVIEW) lParam;
-
-                    (VOID) ListView_SortItems(hListView, ListViewCompareFunc, pnmv->iSubItem);
-                    bAscending = !bAscending;
-                }
-                break;
-
-                case NM_CLICK:
-                {
-                    if (data->hwndFrom == hListView && ((LPNMLISTVIEW)lParam)->iItem != -1)
-                    {
-                        if (IS_INSTALLED_ENUM(SelectedEnumType))
-                            ShowInstalledAppInfo(-1);
-                        if (IS_AVAILABLE_ENUM(SelectedEnumType))
-                            ShowAvailableAppInfo(-1);
-                    }
-                }
-                break;
-
-                case NM_DBLCLK:
-                {
-                    if (data->hwndFrom == hListView && ((LPNMLISTVIEW)lParam)->iItem != -1)
-                    {
-                        /* this won't do anything if the program is already installed */
-                        SendMessage(hwnd, WM_COMMAND, ID_INSTALL, 0);
-                    }
-                }
-                break;
-
-                case NM_RCLICK:
-                {
-                    if (data->hwndFrom == hListView && ((LPNMLISTVIEW)lParam)->iItem != -1)
-                    {
-                        ShowPopupMenu(hListView, 0, ID_INSTALL);
-                    }
-                }
-                break;
-
-                case EN_LINK:
-                    RichEditOnLink(hwnd, (ENLINK*)lParam);
-                    break;
-
-                case TTN_GETDISPINFO:
-                    ToolBarOnGetDispInfo((LPTOOLTIPTEXT)lParam);
-                    break;
-            }
-        }
-        break;
-
-        case WM_PAINT:
-        break;
-
-        case WM_SIZE:
-        {
-            if ((GetClientWindowHeight(hMainWnd) - GetWindowHeight(hStatusBar) - SPLIT_WIDTH) < GetHSplitterPos())
-            {
-                INT NewSplitPos = GetClientWindowHeight(hwnd) - 100 - GetWindowHeight(hStatusBar) - SPLIT_WIDTH;
-                if (NewSplitPos > GetWindowHeight(hToolBar) + SPLIT_WIDTH)
-                    SetHSplitterPos(NewSplitPos);
-            }
-
-            MainWndOnSize(hwnd, wParam, lParam);
-        }
-        break;
-
-        case WM_SIZING:
-        {
-            int RichEditHeight = GetWindowHeight(hRichEdit);
-            LPRECT pRect = (LPRECT)lParam;
-
-            while (RichEditHeight <= 100)
-            {
-                if (GetHSplitterPos() - 1 < GetWindowHeight(hToolBar) + GetWindowHeight(hListView) + SPLIT_WIDTH)
-                    break;
-                SetHSplitterPos(GetHSplitterPos() - 1);
-                RichEditHeight++;
-            }
-
-            if (pRect->right-pRect->left < 565)
-                pRect->right = pRect->left + 565;
-
-            if (pRect->bottom-pRect->top < 300)
-                pRect->bottom = pRect->top + 300;
-            return TRUE;
-        }
-
-        case WM_SYSCOLORCHANGE:
-        {
-            /* Forward WM_SYSCOLORCHANGE to common controls */
-            SendMessage(hListView, WM_SYSCOLORCHANGE, 0, 0);
-            SendMessage(hTreeView, WM_SYSCOLORCHANGE, 0, 0);
-            SendMessage(hToolBar, WM_SYSCOLORCHANGE, 0, 0);
-            SendMessageW(hRichEdit, EM_SETBKGNDCOLOR, 0, GetSysColor(COLOR_BTNFACE));
-        }
-        break;
-
-        case WM_DESTROY:
-        {
-            ShowWindow(hwnd, SW_HIDE);
-            SaveSettings(hwnd);
-
-            FreeLogs();
-
-            FreeCachedAvailableEntries();
-
-            if (IS_INSTALLED_ENUM(SelectedEnumType))
-                FreeInstalledAppList();
-
-            if (hImageTreeView)
-                ImageList_Destroy(hImageTreeView);
-
-            PostQuitMessage(0);
-            return 0;
-        }
-        break;
-    }
-
-    return DefWindowProc(hwnd, Msg, wParam, lParam);
-}
-
 int WINAPI
 wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int nShowCmd)
 {
-    WNDCLASSEXW WndClass = {0};
     WCHAR szWindowClass[] = L"ROSAPPMGR";
-    WCHAR szWindowName[MAX_STR_LEN];
     HANDLE hMutex = NULL;
     HACCEL KeyBrd;
     MSG Msg;
@@ -974,33 +481,7 @@ wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int nSh
 
     InitCommonControls();
 
-    /* Create the window */
-    WndClass.cbSize        = sizeof(WNDCLASSEXW);
-    WndClass.lpszClassName = szWindowClass;
-    WndClass.lpfnWndProc   = MainWindowProc;
-    WndClass.hInstance     = hInstance;
-    WndClass.hIcon         = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_MAIN));
-    WndClass.hCursor       = LoadCursor(NULL, IDC_ARROW);
-    WndClass.hbrBackground = (HBRUSH)(COLOR_BTNFACE + 1);
-    WndClass.lpszMenuName  = MAKEINTRESOURCEW(IDR_MAINMENU);
-
-    if (RegisterClassExW(&WndClass) == (ATOM)0) goto Exit;
-
-    LoadStringW(hInst, IDS_APPTITLE, szWindowName, _countof(szWindowName));
-
-    hMainWnd = CreateWindowExW(WS_EX_WINDOWEDGE,
-                               szWindowClass,
-                               szWindowName,
-                               WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN | WS_CLIPSIBLINGS,
-                               (SettingsInfo.bSaveWndPos ? SettingsInfo.Left   : CW_USEDEFAULT),
-                               (SettingsInfo.bSaveWndPos ? SettingsInfo.Top    : CW_USEDEFAULT),
-                               (SettingsInfo.bSaveWndPos ? SettingsInfo.Width  : 680),
-                               (SettingsInfo.bSaveWndPos ? SettingsInfo.Height : 450),
-                               NULL,
-                               NULL,
-                               hInstance,
-                               NULL);
-
+    hMainWnd = CreateMainWindow();
     if (!hMainWnd) goto Exit;
 
     /* Maximize it if we must */
index d3d7500..e394f79 100644 (file)
@@ -112,7 +112,12 @@ public:
     {
         return (BOOL)SendMessage(LVM_SETITEM, 0, reinterpret_cast<LPARAM>(pitem));
     }
-    
+
+    BOOL FindItem(int iStart, const LV_FINDINFO * plvfi)
+    {
+        return (BOOL)SendMessage(LVM_FINDITEM, iStart, (LPARAM) plvfi);
+    }
+
     int GetItemCount()
     {
         return SendMessage(LVM_GETITEMCOUNT);
@@ -200,6 +205,15 @@ public:
         return GetItem(pItem);
     }
 
+    void GetItemText(int iItem, int iSubItem, LPTSTR pszText, int cchTextMax)
+    {
+        LV_ITEM itemInfo;
+        itemInfo.iSubItem = iSubItem;
+        itemInfo.pszText = pszText;
+        itemInfo.cchTextMax = cchTextMax;
+
+        SendMessage(LVM_GETITEMTEXT, iItem, (LPARAM) &itemInfo);
+    }
 };
 
 template<typename TItemData = DWORD_PTR>
@@ -399,3 +413,35 @@ public: // Utility methods
         return SetButtonInfo(index, &info);
     }
 };
+
+class CStatusBar :
+    public CWindowImplBaseT<CWindow>
+{
+    BOOL ProcessWindowMessage(HWND hwnd, UINT Msg, WPARAM wParam, LPARAM lParam, LRESULT& theResult, DWORD dwMapId)
+    {
+        theResult = 0;
+        return FALSE;
+    }
+
+public:
+    VOID SetText(LPCWSTR lpszText)
+    {
+        SendMessage(SB_SETTEXT, SBT_NOBORDERS, (LPARAM) lpszText);
+    }
+
+    HWND Create(HWND hwndParent, HMENU hMenu)
+    {
+        HWND hwnd = CreateWindowExW(0,
+            STATUSCLASSNAMEW,
+            NULL,
+            WS_CHILD | WS_VISIBLE | SBARS_SIZEGRIP,
+            0, 0, 0, 0,
+            hwndParent,
+            hMenu,
+            _AtlBaseModule.GetModuleInstance(),
+            NULL);
+        SubclassWindow(hwnd);
+        return hwnd;
+    }
+
+};