[RAPPS]
[reactos.git] / reactos / base / applications / rapps / gui.cpp
index 50f190e..343771a 100644 (file)
@@ -3,8 +3,11 @@
  * AUTHORS:     David Quintana             <gigaherz@gmail.com>
  *              Alexander Shaposhnikov     <chaez.san@gmail.com>
  */
+#include "defines.h"
 
 #include "rapps.h"
+#include "rosui.h"
+#include "crichedit.h"
 
 #include <shlobj_undoc.h>
 #include <shlguid_undoc.h>
 #include <atlwin.h>
 #include <wininet.h>
 #include <shellutils.h>
-
 #include <rosctrls.h>
 
-#include "rosui.h"
-#include "crichedit.h"
-
 #define SEARCH_TIMER_ID 'SR'
+#define LISTVIEW_ICON_SIZE 24
+#define TREEVIEW_ICON_SIZE 24
 
 HWND hListView = NULL;
 
+INT
+GetSystemColorDepth()
+{
+    DEVMODEW pDevMode;
+    INT ColorDepth;
+
+    pDevMode.dmSize = sizeof(pDevMode);
+    pDevMode.dmDriverExtra = 0;
+
+    if (!EnumDisplaySettingsW(NULL, ENUM_CURRENT_SETTINGS, &pDevMode))
+    {
+        /* TODO: Error message */
+        return ILC_COLOR;
+    }
+
+    switch (pDevMode.dmBitsPerPel)
+    {
+    case 32: ColorDepth = ILC_COLOR32; break;
+    case 24: ColorDepth = ILC_COLOR24; break;
+    case 16: ColorDepth = ILC_COLOR16; break;
+    case  8: ColorDepth = ILC_COLOR8;  break;
+    case  4: ColorDepth = ILC_COLOR4;  break;
+    default: ColorDepth = ILC_COLOR;   break;
+    }
+
+    return ColorDepth;
+}
+
 class CAvailableAppView
 {
     static inline VOID InsertTextAfterLoaded_RichEdit(UINT uStringID,
@@ -207,8 +236,7 @@ class CMainToolbar :
         hImageList = ImageList_Create(TOOLBAR_HEIGHT,//GetSystemMetrics(SM_CXSMICON),
                                       TOOLBAR_HEIGHT,//GetSystemMetrics(SM_CYSMICON),
                                       ILC_MASK | GetSystemColorDepth(),
-                                      1,
-                                      1);
+                                      1, 1);
         if (!hImageList)
         {
             /* TODO: Error message */
@@ -325,7 +353,7 @@ class CAppsListView :
     struct SortContext
     {
         CAppsListView * lvw;
-        int iSubItem;
+        INT iSubItem;
     };
 
     BOOL bHasAllChecked;
@@ -816,7 +844,7 @@ private:
 
         RECT r = {0, 0, LOWORD(lParam), HIWORD(lParam)};
         HDWP hdwp = NULL;
-        int count = m_ClientPanel->CountSizableChildren();
+        INT count = m_ClientPanel->CountSizableChildren();
 
         hdwp = BeginDeferWindowPos(count);
         if (hdwp)
@@ -1024,7 +1052,7 @@ private:
                     {
                         if (IS_INSTALLED_ENUM(SelectedEnumType))
                             ShowInstalledAppInfo(ItemIndex);
-                        if (IS_AVAILABLE_ENUM(SelectedEnumType))
+                        if (isAvailableEnum(SelectedEnumType))
                             CAvailableAppView::ShowAvailableAppInfo(ItemIndex);
                     }
                     /* Check if the item is checked */
@@ -1052,7 +1080,7 @@ private:
                 {
                     if (IS_INSTALLED_ENUM(SelectedEnumType))
                         ShowInstalledAppInfo(-1);
-                    if (IS_AVAILABLE_ENUM(SelectedEnumType))
+                    if (isAvailableEnum(SelectedEnumType))
                         CAvailableAppView::ShowAvailableAppInfo(-1);
                 }
             }
@@ -1433,8 +1461,10 @@ private:
         nSelectedApps = 0;
         if (EnumType < 0) EnumType = SelectedEnumType;
 
-        if (IS_INSTALLED_ENUM(SelectedEnumType))
+        if (IS_INSTALLED_ENUM(EnumType))
+        {
             FreeInstalledAppList();
+        }
 
         m_ListView->DeleteAllItems();
 
@@ -1449,21 +1479,24 @@ private:
             ImageList_Destroy(hImageListBuf);
         }
 
-        if (IS_AVAILABLE_ENUM(EnumType))
+        if (isAvailableEnum(EnumType))
         {
             /* Enum available applications */
-            m_AvailableApps.EnumAvailableApplications(EnumType, s_EnumAvailableAppProc);
+            if (!m_AvailableApps.EnumAvailableApplications(EnumType, s_EnumAvailableAppProc))
+            {
+                return;
+            }
         }
 
         SelectedEnumType = EnumType;
-
         UpdateStatusBarText();
-
         SetWelcomeText();
 
-        /* set automatic column width for program names if the list is not empty */
+        /* Set automatic column width for program names if the list is not empty */
         if (m_ListView->GetItemCount() > 0)
+        {
             ListView_SetColumnWidth(m_ListView->GetWindow(), 0, LVSCW_AUTOSIZE);
+        }
 
         bUpdating = FALSE;
         m_ListView->SetRedraw(TRUE);