Commit 238cdf71 authored by Owen Rudge's avatar Owen Rudge Committed by Alexandre Julliard

shell32: Use a listview for the control panel.

parent adda4859
......@@ -34,6 +34,7 @@
#include "wine/debug.h"
#include "cpl.h"
#include "wine/unicode.h"
#include "commctrl.h"
#define NO_SHLWAPI_REG
#include "shlwapi.h"
......@@ -164,18 +165,87 @@ CPlApplet* Control_LoadApplet(HWND hWnd, LPCWSTR cmd, CPanel* panel)
return NULL;
}
#define IDC_LISTVIEW 1000
#define NUM_COLUMNS 2
#define LISTVIEW_DEFSTYLE (WS_CHILD | WS_VISIBLE | WS_TABSTOP |\
LVS_SORTASCENDING | LVS_AUTOARRANGE | LVS_SINGLESEL)
static BOOL Control_CreateListView (CPanel *panel)
{
RECT ws;
WCHAR empty_string[] = {0};
WCHAR buf[MAX_STRING_LEN];
LVCOLUMNW lvc;
/* Create list view */
GetClientRect(panel->hWnd, &ws);
panel->hWndListView = CreateWindowExW(WS_EX_CLIENTEDGE, WC_LISTVIEWW,
empty_string, LISTVIEW_DEFSTYLE | LVS_ICON,
0, 0, ws.right - ws.left, ws.bottom - ws.top,
panel->hWnd, (HMENU) IDC_LISTVIEW, panel->hInst, NULL);
if (!panel->hWndListView)
return FALSE;
/* Create image lists for list view */
panel->hImageListSmall = ImageList_Create(GetSystemMetrics(SM_CXSMICON),
GetSystemMetrics(SM_CYSMICON), ILC_MASK, 1, 1);
panel->hImageListLarge = ImageList_Create(GetSystemMetrics(SM_CXICON),
GetSystemMetrics(SM_CYICON), ILC_MASK, 1, 1);
(void) ListView_SetImageList(panel->hWndListView, panel->hImageListSmall, LVSIL_SMALL);
(void) ListView_SetImageList(panel->hWndListView, panel->hImageListLarge, LVSIL_NORMAL);
/* Create columns for list view */
lvc.mask = LVCF_FMT | LVCF_TEXT | LVCF_SUBITEM | LVCF_WIDTH;
lvc.pszText = buf;
lvc.fmt = LVCFMT_LEFT;
/* Name column */
lvc.iSubItem = 0;
lvc.cx = (ws.right - ws.left) / 3;
LoadStringW(shell32_hInstance, IDS_CPANEL_NAME, buf, sizeof(buf) / sizeof(buf[0]));
if (ListView_InsertColumnW(panel->hWndListView, 0, &lvc) == -1)
return FALSE;
/* Description column */
lvc.iSubItem = 1;
lvc.cx = ((ws.right - ws.left) / 3) * 2;
LoadStringW(shell32_hInstance, IDS_CPANEL_DESCRIPTION, buf, sizeof(buf) /
sizeof(buf[0]));
if (ListView_InsertColumnW(panel->hWndListView, 1, &lvc) == -1)
return FALSE;
return(TRUE);
}
static void Control_WndProc_Create(HWND hWnd, const CREATESTRUCTW* cs)
{
CPanel* panel = (CPanel*)cs->lpCreateParams;
HMENU hMenu, hSubMenu;
CPlApplet* applet;
MENUITEMINFOW mii;
int menucount, i;
int menucount, i, index;
CPlItem *item;
LVITEMW lvItem;
INITCOMMONCONTROLSEX icex;
SetWindowLongPtrW(hWnd, 0, (LONG_PTR)panel);
panel->hWnd = hWnd;
/* Initialise common control DLL */
icex.dwSize = sizeof(INITCOMMONCONTROLSEX);
icex.dwICC = ICC_LISTVIEW_CLASSES;
InitCommonControlsEx(&icex);
/* create the list view */
if (!Control_CreateListView(panel))
return;
hMenu = LoadMenuW(shell32_hInstance, MAKEINTRESOURCEW(MENU_CPANEL));
/* insert menu items for applets */
......@@ -204,8 +274,26 @@ static void Control_WndProc_Create(HWND hWnd, const CREATESTRUCTW* cs)
mii.dwItemData = (DWORD) item;
if (InsertMenuItemW(hSubMenu, menucount, TRUE, &mii)) {
DrawMenuBar(hWnd);
menucount++;
/* add the list view item */
index = ImageList_AddIcon(panel->hImageListLarge, applet->info[i].hIcon);
ImageList_AddIcon(panel->hImageListSmall, applet->info[i].hIcon);
lvItem.mask = LVIF_IMAGE | LVIF_TEXT | LVIF_PARAM;
lvItem.iItem = menucount;
lvItem.iSubItem = 0;
lvItem.pszText = applet->info[i].szName;
lvItem.iImage = index;
lvItem.lParam = (LPARAM) item;
ListView_InsertItemW(panel->hWndListView, &lvItem);
/* add the description */
ListView_SetItemTextW(panel->hWndListView, menucount, 1,
applet->info[i].szInfo);
/* update menu bar, increment count */
DrawMenuBar(hWnd);
menucount++;
}
}
}
......@@ -250,6 +338,65 @@ static void Control_FreeCPlItems(HWND hWnd, CPanel *panel)
}
}
static void Control_UpdateListViewStyle(CPanel *panel, UINT style, UINT id)
{
HMENU hMenu, hSubMenu;
SetWindowLongW(panel->hWndListView, GWL_STYLE, LISTVIEW_DEFSTYLE | style);
/* update the menu */
hMenu = GetMenu(panel->hWnd);
hSubMenu = GetSubMenu(hMenu, 1);
CheckMenuRadioItem(hSubMenu, FCIDM_SHVIEW_BIGICON, FCIDM_SHVIEW_REPORTVIEW,
id, MF_BYCOMMAND);
}
static CPlItem* Control_GetCPlItem_From_MenuID(HWND hWnd, UINT id)
{
HMENU hMenu, hSubMenu;
MENUITEMINFOW mii;
/* retrieve the CPlItem structure from the menu item data */
hMenu = GetMenu(hWnd);
if (!hMenu)
return NULL;
hSubMenu = GetSubMenu(hMenu, 0);
if (!hSubMenu)
return NULL;
mii.cbSize = sizeof(MENUITEMINFOW);
mii.fMask = MIIM_DATA;
if (!GetMenuItemInfoW(hSubMenu, id, FALSE, &mii))
return NULL;
return (CPlItem *) mii.dwItemData;
}
static CPlItem* Control_GetCPlItem_From_ListView(CPanel *panel)
{
LVITEMW lvItem;
int selitem;
selitem = SendMessageW(panel->hWndListView, LVM_GETNEXTITEM, -1, LVNI_FOCUSED
| LVNI_SELECTED);
if (selitem != -1)
{
lvItem.iItem = selitem;
lvItem.mask = LVIF_PARAM;
if (SendMessageW(panel->hWndListView, LVM_GETITEMW, 0, (LPARAM) &lvItem))
return (CPlItem *) lvItem.lParam;
}
return NULL;
}
static LRESULT WINAPI Control_WndProc(HWND hWnd, UINT wMsg,
WPARAM lParam1, LPARAM lParam2)
{
......@@ -288,9 +435,19 @@ static LRESULT WINAPI Control_WndProc(HWND hWnd, UINT wMsg,
}
case FCIDM_SHVIEW_BIGICON:
Control_UpdateListViewStyle(panel, LVS_ICON, FCIDM_SHVIEW_BIGICON);
return 0;
case FCIDM_SHVIEW_SMALLICON:
Control_UpdateListViewStyle(panel, LVS_SMALLICON, FCIDM_SHVIEW_SMALLICON);
return 0;
case FCIDM_SHVIEW_LISTVIEW:
Control_UpdateListViewStyle(panel, LVS_LIST, FCIDM_SHVIEW_LISTVIEW);
return 0;
case FCIDM_SHVIEW_REPORTVIEW:
Control_UpdateListViewStyle(panel, LVS_REPORT, FCIDM_SHVIEW_REPORTVIEW);
return 0;
default:
......@@ -298,28 +455,7 @@ static LRESULT WINAPI Control_WndProc(HWND hWnd, UINT wMsg,
if ((LOWORD(lParam1) >= IDM_CPANEL_APPLET_BASE) &&
(LOWORD(lParam1) <= IDM_CPANEL_APPLET_BASE + panel->total_subprogs))
{
CPlItem *item;
HMENU hMenu, hSubMenu;
MENUITEMINFOW mii;
/* retrieve the CPlItem structure from the menu item data */
hMenu = GetMenu(hWnd);
if (!hMenu)
break;
hSubMenu = GetSubMenu(hMenu, 0);
if (!hSubMenu)
break;
mii.cbSize = sizeof(MENUITEMINFOW);
mii.fMask = MIIM_DATA;
if (!GetMenuItemInfoW(hSubMenu, LOWORD(lParam1), FALSE, &mii))
break;
item = (CPlItem *) mii.dwItemData;
CPlItem *item = Control_GetCPlItem_From_MenuID(hWnd, LOWORD(lParam1));
/* execute the applet if item is valid */
if (item)
......@@ -333,7 +469,46 @@ static LRESULT WINAPI Control_WndProc(HWND hWnd, UINT wMsg,
}
break;
case WM_NOTIFY:
{
LPNMHDR nmh = (LPNMHDR) lParam2;
switch (nmh->idFrom)
{
case IDC_LISTVIEW:
switch (nmh->code)
{
case NM_RETURN:
case NM_DBLCLK:
{
CPlItem *item = Control_GetCPlItem_From_ListView(panel);
/* execute the applet if item is valid */
if (item)
item->applet->proc(item->applet->hWnd, CPL_DBLCLK,
item->id, item->applet->info[item->id].lData);
return 0;
}
}
break;
}
break;
}
case WM_SIZE:
{
RECT rect;
GetClientRect(hWnd, &rect);
MoveWindow(panel->hWndListView, 0, 0, rect.right, rect.bottom, TRUE);
return 0;
}
}
}
return DefWindowProcW(hWnd, wMsg, lParam1, lParam2);
......@@ -353,7 +528,7 @@ static void Control_DoInterface(CPanel* panel, HWND hWnd, HINSTANCE hInst)
wc.lpfnWndProc = Control_WndProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = sizeof(CPlApplet*);
wc.hInstance = hInst;
wc.hInstance = panel->hInst = hInst;
wc.hIcon = 0;
wc.hCursor = LoadCursorW( 0, (LPWSTR)IDC_ARROW );
wc.hbrBackground = GetStockObject(WHITE_BRUSH);
......
......@@ -34,9 +34,13 @@ typedef struct CPlApplet {
} CPlApplet;
typedef struct CPanel {
CPlApplet* first; /* linked list */
HWND hWnd;
unsigned total_subprogs;
CPlApplet* first;
HWND hWnd;
HINSTANCE hInst;
unsigned total_subprogs;
HWND hWndListView;
HIMAGELIST hImageListLarge;
HIMAGELIST hImageListSmall;
} CPanel;
/* structure to reference an individual control panel item */
......
......@@ -40,6 +40,7 @@
#include "ole2.h"
#include "shlguid.h"
#include "commctrl.h"
#include "cpanel.h"
#include "enumidlist.h"
#include "pidl.h"
......
......@@ -242,5 +242,7 @@ STRINGTABLE
IDS_NEWFOLDER "New Folder"
IDS_CPANEL_TITLE "Wine Control Panel"
IDS_CPANEL_TITLE "Wine Control Panel"
IDS_CPANEL_NAME "Name"
IDS_CPANEL_DESCRIPTION "Description"
}
......@@ -95,4 +95,6 @@ FONT 8, "MS Shell Dlg"
STRINGTABLE
{
IDS_CPANEL_TITLE "Wine Control Panel"
IDS_CPANEL_NAME "Name"
IDS_CPANEL_DESCRIPTION "Description"
}
......@@ -106,6 +106,8 @@ BEGIN
IDS_SHV_COLUMN9 "Comments" /*FIXME*/
IDS_CPANEL_TITLE "Wine Control Panel"
IDS_CPANEL_NAME "Name"
IDS_CPANEL_DESCRIPTION "Description"
END
#pragma code_page(default)
......@@ -213,4 +213,6 @@ STRINGTABLE
IDS_NEWFOLDER "New Folder"
IDS_CPANEL_TITLE "Wine Control Panel"
IDS_CPANEL_NAME "Name"
IDS_CPANEL_DESCRIPTION "Description"
}
......@@ -275,6 +275,8 @@ STRINGTABLE
IDS_NEWFOLDER "Ny Folder"
IDS_CPANEL_TITLE "Wine Control Panel"
IDS_CPANEL_NAME "Name"
IDS_CPANEL_DESCRIPTION "Description"
}
STRINGTABLE
......
......@@ -274,6 +274,8 @@ STRINGTABLE
IDS_NEWFOLDER "Neuer Ordner"
IDS_CPANEL_TITLE "Wine Control Panel"
IDS_CPANEL_NAME "Name"
IDS_CPANEL_DESCRIPTION "Description"
}
STRINGTABLE
......
......@@ -280,6 +280,8 @@ STRINGTABLE
IDS_NEWFOLDER "New Folder"
IDS_CPANEL_TITLE "Wine Control Panel"
IDS_CPANEL_NAME "Name"
IDS_CPANEL_DESCRIPTION "Description"
}
STRINGTABLE
......
......@@ -260,4 +260,6 @@ STRINGTABLE
IDS_NEWFOLDER "New Folder"
IDS_CPANEL_TITLE "Wine Control Panel"
IDS_CPANEL_NAME "Name"
IDS_CPANEL_DESCRIPTION "Description"
}
......@@ -275,6 +275,8 @@ STRINGTABLE
IDS_NEWFOLDER "Nueva carpeta"
IDS_CPANEL_TITLE "Wine Control Panel"
IDS_CPANEL_NAME "Name"
IDS_CPANEL_DESCRIPTION "Description"
}
STRINGTABLE
......
......@@ -242,4 +242,6 @@ STRINGTABLE
IDS_NEWFOLDER "New Folder"
IDS_CPANEL_TITLE "Wine Control Panel"
IDS_CPANEL_NAME "Name"
IDS_CPANEL_DESCRIPTION "Description"
}
......@@ -280,6 +280,8 @@ STRINGTABLE
IDS_NEWFOLDER "Nouveau dossier"
IDS_CPANEL_TITLE "Wine Control Panel"
IDS_CPANEL_NAME "Name"
IDS_CPANEL_DESCRIPTION "Description"
}
STRINGTABLE
......
......@@ -94,4 +94,6 @@ FONT 8, "MS Shell Dlg"
STRINGTABLE
{
IDS_CPANEL_TITLE "Wine Control Panel"
IDS_CPANEL_NAME "Name"
IDS_CPANEL_DESCRIPTION "Description"
}
......@@ -244,4 +244,6 @@ STRINGTABLE
IDS_NEWFOLDER "New Folder"
IDS_CPANEL_TITLE "Wine Control Panel"
IDS_CPANEL_NAME "Name"
IDS_CPANEL_DESCRIPTION "Description"
}
......@@ -137,6 +137,8 @@ STRINGTABLE
IDS_OPEN "開く"
IDS_CPANEL_TITLE "Wine Control Panel"
IDS_CPANEL_NAME "Name"
IDS_CPANEL_DESCRIPTION "Description"
}
SHELL_ABOUT_MSGBOX DIALOG LOADONCALL MOVEABLE DISCARDABLE 15, 40, 220, 152
......
......@@ -285,6 +285,8 @@ IDS_CDBURN_AREA "Local Settings\\Application Data\\Microsoft\\CD Bur
IDS_NEWFOLDER "새 폴더"
IDS_CPANEL_TITLE "Wine Control Panel"
IDS_CPANEL_NAME "Name"
IDS_CPANEL_DESCRIPTION "Description"
}
STRINGTABLE
......
......@@ -282,6 +282,8 @@ STRINGTABLE
IDS_NEWFOLDER "Nieuwe Map"
IDS_CPANEL_TITLE "Wine Control Panel"
IDS_CPANEL_NAME "Name"
IDS_CPANEL_DESCRIPTION "Description"
}
STRINGTABLE
......
......@@ -280,6 +280,8 @@ STRINGTABLE
IDS_NEWFOLDER "Ny mappe"
IDS_CPANEL_TITLE "Wine Control Panel"
IDS_CPANEL_NAME "Name"
IDS_CPANEL_DESCRIPTION "Description"
}
STRINGTABLE
......
......@@ -281,6 +281,8 @@ STRINGTABLE
IDS_NEWFOLDER "Nowy Folder"
IDS_CPANEL_TITLE "Wine Control Panel"
IDS_CPANEL_NAME "Name"
IDS_CPANEL_DESCRIPTION "Description"
}
STRINGTABLE
......
......@@ -361,6 +361,8 @@ STRINGTABLE
IDS_NEWFOLDER "Nova Pasta"
IDS_CPANEL_TITLE "Wine Control Panel"
IDS_CPANEL_NAME "Name"
IDS_CPANEL_DESCRIPTION "Description"
}
LANGUAGE LANG_PORTUGUESE, SUBLANG_PORTUGUESE
......@@ -450,4 +452,6 @@ STRINGTABLE
IDS_NEWFOLDER "Nova Pasta"
IDS_CPANEL_TITLE "Wine Control Panel"
IDS_CPANEL_NAME "Name"
IDS_CPANEL_DESCRIPTION "Description"
}
......@@ -233,6 +233,8 @@ STRINGTABLE
IDS_FAVORITES "Favorite"
IDS_CPANEL_TITLE "Wine Control Panel"
IDS_CPANEL_NAME "Name"
IDS_CPANEL_DESCRIPTION "Description"
}
STRINGTABLE
......
......@@ -275,4 +275,6 @@ STRINGTABLE
IDS_NEWFOLDER "New Folder"
IDS_CPANEL_TITLE "Wine Control Panel"
IDS_CPANEL_NAME "Name"
IDS_CPANEL_DESCRIPTION "Description"
}
......@@ -275,6 +275,8 @@ STRINGTABLE
IDS_NEWFOLDER "Nova mapa"
IDS_CPANEL_TITLE "Wine Control Panel"
IDS_CPANEL_NAME "Name"
IDS_CPANEL_DESCRIPTION "Description"
}
STRINGTABLE
......
......@@ -105,4 +105,6 @@ BEGIN
IDS_SHV_COLUMN9 "Comments" /*FIXME*/
IDS_CPANEL_TITLE "Wine Control Panel"
IDS_CPANEL_NAME "Name"
IDS_CPANEL_DESCRIPTION "Description"
END
......@@ -94,4 +94,6 @@ FONT 8, "MS Shell Dlg"
STRINGTABLE
{
IDS_CPANEL_TITLE "Wine Control Panel"
IDS_CPANEL_NAME "Name"
IDS_CPANEL_DESCRIPTION "Description"
}
......@@ -243,4 +243,6 @@ STRINGTABLE
IDS_NEWFOLDER "New Folder"
IDS_CPANEL_TITLE "Wine Control Panel"
IDS_CPANEL_NAME "Name"
IDS_CPANEL_DESCRIPTION "Description"
}
......@@ -209,4 +209,6 @@ STRINGTABLE
IDS_NEWFOLDER "New Folder"
IDS_CPANEL_TITLE "Wine Control Panel"
IDS_CPANEL_NAME "Name"
IDS_CPANEL_DESCRIPTION "Description"
}
......@@ -99,4 +99,6 @@ FONT 8, "MS Shell Dlg"
STRINGTABLE
{
IDS_CPANEL_TITLE "Wine Control Panel"
IDS_CPANEL_NAME "Name"
IDS_CPANEL_DESCRIPTION "Description"
}
......@@ -106,6 +106,8 @@ BEGIN
IDS_SHV_COLUMN9 "Comments" /*FIXME*/
IDS_CPANEL_TITLE "Wine Control Panel"
IDS_CPANEL_NAME "Name"
IDS_CPANEL_DESCRIPTION "Description"
END
#pragma code_page(default)
......@@ -98,6 +98,8 @@
#define IDS_NEWFOLDER 142
#define IDS_CPANEL_TITLE 143
#define IDS_CPANEL_NAME 144
#define IDS_CPANEL_DESCRIPTION 145
#define IDS_RUNDLG_ERROR 160
#define IDS_RUNDLG_BROWSE_ERROR 161
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment