[MMSYS] Add icons for the sound tree (#1235)
authorStanislav Motylkov <x86corez@gmail.com>
Sun, 13 Jan 2019 18:13:20 +0000 (21:13 +0300)
committerHermès BÉLUSCA - MAÏTO <hermes.belusca-maito@reactos.org>
Sun, 13 Jan 2019 18:13:20 +0000 (19:13 +0100)
CORE-15584

dll/cpl/mmsys/mmsys.rc
dll/cpl/mmsys/resource.h
dll/cpl/mmsys/resources/4366.ico
dll/cpl/mmsys/sounds.c

index 603ad5d..3d0a873 100644 (file)
@@ -27,8 +27,8 @@ IDI_JOY_ICON ICON "resources/4361.ico"
 4363 ICON "resources/4363.ico"
 IDI_CAMERA_ICON ICON "resources/4364.ico"
 4365 ICON "resources/4365.ico"
-4366 ICON "resources/4366.ico"
-4367 ICON "resources/4367.ico"
+IDI_SOUND_SECTION ICON "resources/4366.ico"
+IDI_SOUND_ASSIGNED ICON "resources/4367.ico"
 4368 ICON "resources/4368.ico"
 4369 ICON "resources/4369.ico"
 4370 ICON "resources/4370.ico"
index 246f9ef..e5aff82 100644 (file)
@@ -7,6 +7,8 @@
 #define IDI_MIDICON         3007
 #define IDI_JOY_ICON        4361
 #define IDI_CAMERA_ICON     4364
+#define IDI_SOUND_SECTION   4366
+#define IDI_SOUND_ASSIGNED  4367
 #define IDI_SHUTDOWN_ICON   3009
 #define IDI_NO_HW           4390
 #define IDI_MUTED_ICON      4393
@@ -77,3 +79,8 @@
 #define IDS_CPLDESCRIPTION 1001
 #define IDS_NO_SOUND       1002
 #define IDS_NO_DEVICES     1003
+
+/* Sounds Image List */
+#define IMAGE_SOUND_SECTION  0
+#define IMAGE_SOUND_ASSIGNED 1
+#define IMAGE_SOUND_NONE     2
index 16972b9..34bde78 100644 (file)
Binary files a/dll/cpl/mmsys/resources/4366.ico and b/dll/cpl/mmsys/resources/4366.ico differ
index 4976e23..1fc9fb9 100644 (file)
@@ -57,6 +57,7 @@ static PLABEL_MAP s_Map = NULL;
 static PAPP_MAP s_App = NULL;
 
 TCHAR szDefault[MAX_PATH];
+HIMAGELIST hSoundsImageList = NULL;
 
 /* A filter string is a list separated by NULL and ends with double NULLs. */
 LPWSTR MakeFilter(LPWSTR psz)
@@ -813,6 +814,7 @@ ShowSoundScheme(HWND hwndDlg)
     PSOUND_SCHEME_CONTEXT pScheme;
     PAPP_MAP pAppMap;
     PLABEL_MAP pLabelMap;
+    PLABEL_CONTEXT pLabelContext;
     HWND hDlgCtrl, hList;
     TVINSERTSTRUCT tvItem;
     HTREEITEM hTreeItem;
@@ -820,6 +822,11 @@ ShowSoundScheme(HWND hwndDlg)
     hDlgCtrl = GetDlgItem(hwndDlg, IDC_SOUND_SCHEME);
     hList = GetDlgItem(hwndDlg, IDC_SCHEME_LIST);
 
+    if (hSoundsImageList != NULL)
+    {
+        TreeView_SetImageList(hList, hSoundsImageList, TVSIL_NORMAL);
+    }
+
     lIndex = SendMessage(hDlgCtrl, CB_GETCURSEL, (WPARAM)0, (LPARAM)0);
     if (lIndex == CB_ERR)
     {
@@ -842,10 +849,12 @@ ShowSoundScheme(HWND hwndDlg)
         tvItem.hParent = TVI_ROOT;
         tvItem.hInsertAfter = TVI_FIRST;
 
-        tvItem.item.mask = TVIF_STATE | TVIF_TEXT | TVIF_PARAM;
+        tvItem.item.mask = TVIF_STATE | TVIF_TEXT | TVIF_PARAM | TVIF_IMAGE | TVIF_SELECTEDIMAGE;
         tvItem.item.state = TVIS_EXPANDED;
         tvItem.item.stateMask = TVIS_EXPANDED;
         tvItem.item.pszText = pAppMap->szDesc;
+        tvItem.item.iImage = IMAGE_SOUND_SECTION;
+        tvItem.item.iSelectedImage = IMAGE_SOUND_SECTION;
         tvItem.item.lParam = (LPARAM)NULL;
 
         hTreeItem = TreeView_InsertItem(hList, &tvItem);
@@ -853,14 +862,26 @@ ShowSoundScheme(HWND hwndDlg)
         pLabelMap = pAppMap->LabelMap;
         while (pLabelMap)
         {
+            pLabelContext = FindLabelContext(pScheme, pAppMap->szName, pLabelMap->szName);
+
             ZeroMemory(&tvItem, sizeof(tvItem));
             tvItem.hParent = /*TVI_ROOT;*/ hTreeItem;
             tvItem.hInsertAfter = TVI_SORT;
 
-            tvItem.item.mask = TVIF_STATE | TVIF_TEXT | TVIF_PARAM;
+            tvItem.item.mask = TVIF_STATE | TVIF_TEXT | TVIF_PARAM | TVIF_IMAGE | TVIF_SELECTEDIMAGE;
             tvItem.item.state = TVIS_EXPANDED;
             tvItem.item.stateMask = TVIS_EXPANDED;
             tvItem.item.pszText = pLabelMap->szDesc;
+            if (pLabelContext->szValue && _tcslen(pLabelContext->szValue) > 0)
+            {
+                tvItem.item.iImage = IMAGE_SOUND_ASSIGNED;
+                tvItem.item.iSelectedImage = IMAGE_SOUND_ASSIGNED;
+            }
+            else
+            {
+                tvItem.item.iImage = IMAGE_SOUND_NONE;
+                tvItem.item.iSelectedImage = IMAGE_SOUND_NONE;
+            }
             tvItem.item.lParam = (LPARAM)FindLabelContext(pScheme, pAppMap->szName, pLabelMap->szName);
 
             TreeView_InsertItem(hList, &tvItem);
@@ -940,6 +961,68 @@ ApplyChanges(HWND hwndDlg)
 }
 
 
+HIMAGELIST
+InitImageList(UINT StartResource,
+              UINT EndResource,
+              UINT Width,
+              UINT Height,
+              ULONG type)
+{
+    HANDLE hImage;
+    HIMAGELIST himl;
+    UINT i;
+    INT ret;
+
+    /* Create the toolbar icon image list */
+    himl = ImageList_Create(Width,
+                            Height,
+                            ILC_MASK | ILC_COLOR32,
+                            EndResource - StartResource,
+                            0);
+    if (himl == NULL)
+        return NULL;
+
+    ret = 0;
+    for (i = StartResource; i <= EndResource && ret != -1; i++)
+    {
+        hImage = LoadImageW(hApplet,
+                            MAKEINTRESOURCEW(i),
+                            type,
+                            Width,
+                            Height,
+                            LR_LOADTRANSPARENT);
+        if (hImage == NULL)
+        {
+            ImageList_Destroy(himl);
+            himl = NULL;
+            break;
+        }
+
+        if (type == IMAGE_BITMAP)
+        {
+            ret = ImageList_AddMasked(himl,
+                                      hImage,
+                                      RGB(255, 0, 128));
+        }
+        else if (type == IMAGE_ICON)
+        {
+            ret = ImageList_AddIcon(himl,
+                                    hImage);
+        }
+
+        DeleteObject(hImage);
+    }
+
+    if (ret == -1)
+    {
+        ImageList_Destroy(himl);
+        himl = NULL;
+    }
+
+    return himl;
+}
+
+
 /* Sounds property page dialog callback */
 INT_PTR
 CALLBACK
@@ -964,6 +1047,12 @@ SoundsDlgProc(HWND hwndDlg,
                         BM_SETIMAGE,(WPARAM)IMAGE_ICON,
                         (LPARAM)(HANDLE)LoadIcon(hApplet, MAKEINTRESOURCE(IDI_PLAY_ICON)));
 
+            hSoundsImageList = InitImageList(IDI_SOUND_SECTION,
+                                             IDI_SOUND_ASSIGNED,
+                                             GetSystemMetrics(SM_CXSMICON),
+                                             GetSystemMetrics(SM_CXSMICON),
+                                             IMAGE_ICON);
+
             LoadEventLabels();
             LoadSoundProfiles(hwndDlg);
             LoadSoundFiles(hwndDlg);
@@ -1114,6 +1203,12 @@ SoundsDlgProc(HWND hwndDlg,
             }
             break;
         }
+        case WM_DESTROY:
+        {
+            if (hSoundsImageList)
+                ImageList_Destroy(hSoundsImageList);
+            break;
+        }
         case WM_NOTIFY:
         {
             PLABEL_CONTEXT pLabelContext;