Author: agreen Date: Wed May 25 17:08:53 2011 New Revision: 51905
URL: http://svn.reactos.org/svn/reactos?rev=51905&view=rev Log: [Explorer_new] - Remove CaptionDrawTemp - Added flashing task - Added theming to toolbar buttons
Added: branches/GSoC_2011/NewExplorer/base/shell/explorer-new/explorer.exe.manifest (with props) Modified: branches/GSoC_2011/NewExplorer/base/shell/explorer-new/CMakeLists.txt branches/GSoC_2011/NewExplorer/base/shell/explorer-new/explorer.rc branches/GSoC_2011/NewExplorer/base/shell/explorer-new/precomp.h branches/GSoC_2011/NewExplorer/base/shell/explorer-new/taskswnd.c
Modified: branches/GSoC_2011/NewExplorer/base/shell/explorer-new/CMakeLists.txt URL: http://svn.reactos.org/svn/reactos/branches/GSoC_2011/NewExplorer/base/shell... ============================================================================== --- branches/GSoC_2011/NewExplorer/base/shell/explorer-new/CMakeLists.txt [iso-8859-1] (original) +++ branches/GSoC_2011/NewExplorer/base/shell/explorer-new/CMakeLists.txt [iso-8859-1] Wed May 25 17:08:53 2011 @@ -34,6 +34,7 @@ shell32 shlwapi version + uxtheme msvcrt kernel32 ntdll)
Added: branches/GSoC_2011/NewExplorer/base/shell/explorer-new/explorer.exe.manifest URL: http://svn.reactos.org/svn/reactos/branches/GSoC_2011/NewExplorer/base/shell... ============================================================================== --- branches/GSoC_2011/NewExplorer/base/shell/explorer-new/explorer.exe.manifest (added) +++ branches/GSoC_2011/NewExplorer/base/shell/explorer-new/explorer.exe.manifest [iso-8859-1] Wed May 25 17:08:53 2011 @@ -1,0 +1,22 @@ +<?xml version="1.0" encoding="UTF-8" standalone="yes"?> +<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0"> +<assemblyIdentity + version="1.0.0.0" + processorArchitecture="X86" + name="ReactOS.Explorer" + type="win32" +/> +<description>This is ReactOS Explorer</description> +<dependency> + <dependentAssembly> + <assemblyIdentity + type="win32" + name="Microsoft.Windows.Common-Controls" + version="6.0.0.0" + processorArchitecture="X86" + publicKeyToken="6595b64144ccf1df" + language="*" + /> + </dependentAssembly> +</dependency> +</assembly>
Propchange: branches/GSoC_2011/NewExplorer/base/shell/explorer-new/explorer.exe.manifest ------------------------------------------------------------------------------ svn:eol-style = native
Modified: branches/GSoC_2011/NewExplorer/base/shell/explorer-new/explorer.rc URL: http://svn.reactos.org/svn/reactos/branches/GSoC_2011/NewExplorer/base/shell... ============================================================================== --- branches/GSoC_2011/NewExplorer/base/shell/explorer-new/explorer.rc [iso-8859-1] (original) +++ branches/GSoC_2011/NewExplorer/base/shell/explorer-new/explorer.rc [iso-8859-1] Wed May 25 17:08:53 2011 @@ -20,6 +20,7 @@ IDB_TASKBARPROP_NOLOCK_NOGROUP_NOQL BITMAP DISCARDABLE res/nolock_nogroup_noql.bmp IDB_TASKBARPROP_NOLOCK_NOGROUP_QL BITMAP DISCARDABLE res/nolock_nogroup_ql.bmp IDB_TASKBARPROP_NOLOCK_GROUP_QL BITMAP DISCARDABLE res/nolock_group_ql.bmp +CREATEPROCESS_MANIFEST_RESOURCE_ID RT_MANIFEST "explorer.exe.manifest"
#include "lang/bg-BG.rc" #include "lang/cs-CZ.rc"
Modified: branches/GSoC_2011/NewExplorer/base/shell/explorer-new/precomp.h URL: http://svn.reactos.org/svn/reactos/branches/GSoC_2011/NewExplorer/base/shell... ============================================================================== --- branches/GSoC_2011/NewExplorer/base/shell/explorer-new/precomp.h [iso-8859-1] (original) +++ branches/GSoC_2011/NewExplorer/base/shell/explorer-new/precomp.h [iso-8859-1] Wed May 25 17:08:53 2011 @@ -17,7 +17,9 @@ #include <tchar.h> #include <stdio.h> #include <stdlib.h> - +#include <uxtheme.h> + +#include "tmschema.h" #include "resource.h" #include "comcsup.h" #include "todo.h"
Modified: branches/GSoC_2011/NewExplorer/base/shell/explorer-new/taskswnd.c URL: http://svn.reactos.org/svn/reactos/branches/GSoC_2011/NewExplorer/base/shell... ============================================================================== --- branches/GSoC_2011/NewExplorer/base/shell/explorer-new/taskswnd.c [iso-8859-1] (original) +++ branches/GSoC_2011/NewExplorer/base/shell/explorer-new/taskswnd.c [iso-8859-1] Wed May 25 17:08:53 2011 @@ -20,10 +20,6 @@
#include <precomp.h>
-/* By default we don't use DrawCaptionTemp() because it causes some minimal - drawing glitches with the toolbar custom painting code */ -#define TASK_USE_DRAWCAPTIONTEMP 1 - /* Set DUMP_TASKS to 1 to enable a dump of the tasks and task groups every 5 seconds */ #define DUMP_TASKS 0 @@ -47,14 +43,6 @@ struct {
-#if TASK_USE_DRAWCAPTIONTEMP != 0 - - /* DisplayTooltip is TRUE when the group button text didn't fit into - the button. */ - DWORD DisplayTooltip : 1; - -#endif - DWORD IsCollapsed : 1; }; }; @@ -65,26 +53,15 @@ HWND hWnd; PTASK_GROUP Group; INT Index; - -#if !(TASK_USE_DRAWCAPTIONTEMP != 0) - INT IconIndex;
-#endif +
union { DWORD dwFlags; struct { - -#if TASK_USE_DRAWCAPTIONTEMP != 0 - - /* DisplayTooltip is TRUE when the window text didn't fit into the - button. */ - DWORD DisplayTooltip : 1; - -#endif
/* IsFlashing is TRUE when the task bar item should be flashing. */ DWORD IsFlashing : 1; @@ -113,9 +90,11 @@ PTASK_ITEM TaskItems; PTASK_ITEM ActiveTaskItem;
+ HTHEME TaskBandTheme; HWND hWndToolbar; UINT TbButtonsPerLine; WORD ToolbarBtnCount; + HIMAGELIST TaskIcons;
union { @@ -139,12 +118,6 @@ static VOID TaskSwitchWnd_UpdateButtonsSize(IN OUT PTASK_SWITCH_WND This, IN BOOL bRedrawDisabled);
-#if TASK_USE_DRAWCAPTIONTEMP != 0 - -#define TaskSwitchWnd_GetWndTextFromTaskItem(a,b) NULL - -#else /* !TASK_USE_DRAWCAPTIONTEMP */ - static LPTSTR TaskSwitchWnd_GetWndTextFromTaskItem(IN OUT PTASK_SWITCH_WND This, IN PTASK_ITEM TaskItem) @@ -161,7 +134,6 @@ return NULL; }
-#endif
#if DUMP_TASKS != 0 static VOID @@ -408,19 +380,44 @@ /* FIXME: Implement */ }
+static HICON +TaskSwitchWnd_GetWndIcon(HWND hwnd) +{ + HICON hIcon = 0; + + SendMessageTimeout(hwnd, WM_GETICON, ICON_SMALL2, 0, SMTO_ABORTIFHUNG, 1000, (PDWORD_PTR)&hIcon); + + if (!hIcon) + SendMessageTimeout(hwnd, WM_GETICON, ICON_SMALL, 0, SMTO_ABORTIFHUNG, 1000, (PDWORD_PTR)&hIcon); + + if (!hIcon) + SendMessageTimeout(hwnd, WM_GETICON, ICON_BIG, 0, SMTO_ABORTIFHUNG, 1000, (PDWORD_PTR)&hIcon); + + if (!hIcon) + hIcon = (HICON)GetClassLongPtr(hwnd, GCL_HICONSM); + + if (!hIcon) + hIcon = (HICON)GetClassLongPtr(hwnd, GCL_HICON); + + return hIcon; +} static INT TaskSwitchWnd_UpdateTaskItemButton(IN OUT PTASK_SWITCH_WND This, IN PTASK_ITEM TaskItem) { TBBUTTONINFO tbbi; - + HICON icon; + ASSERT(TaskItem->Index >= 0);
tbbi.cbSize = sizeof(tbbi); - tbbi.dwMask = TBIF_BYINDEX | TBIF_STATE | TBIF_TEXT; + tbbi.dwMask = TBIF_BYINDEX | TBIF_STATE | TBIF_TEXT | TBIF_IMAGE; tbbi.fsState = TBSTATE_ENABLED; if (This->ActiveTaskItem == TaskItem) tbbi.fsState |= TBSTATE_CHECKED; + + if (TaskItem->RenderFlashed) + tbbi.fsState |= TBSTATE_MARKED;
/* Check if we're updating a button that is the last one in the line. If so, we need to set the TBSTATE_WRAP flag! */ @@ -433,6 +430,10 @@ tbbi.pszText = TaskSwitchWnd_GetWndTextFromTaskItem(This, TaskItem);
+ icon = TaskSwitchWnd_GetWndIcon(TaskItem->hWnd); + TaskItem->IconIndex = ImageList_ReplaceIcon(This->TaskIcons,TaskItem->IconIndex,icon); + tbbi.iImage = TaskItem->IconIndex; + if (!SendMessage(This->hWndToolbar, TB_SETBUTTONINFO, (WPARAM)TaskItem->Index, @@ -445,6 +446,40 @@ DbgPrint("Updated button %d for hwnd 0x%p\n", TaskItem->Index, TaskItem->hWnd); return TaskItem->Index; } + +static void +TaskSwitchWnd_RemoveIcon(IN OUT PTASK_SWITCH_WND This, + IN PTASK_ITEM TaskItem) +{ + TBBUTTONINFO tbbi; + PTASK_ITEM currentTaskItem,LastItem; + + if(TaskItem->IconIndex==-1) + return; + + tbbi.cbSize = sizeof(tbbi); + tbbi.dwMask = TBIF_IMAGE; + + currentTaskItem = This->TaskItems; + LastItem = currentTaskItem + This->TaskItemCount; + while (currentTaskItem != LastItem) + { + if (currentTaskItem->IconIndex > TaskItem->IconIndex) + { + currentTaskItem->IconIndex--; + tbbi.iImage = currentTaskItem->IconIndex; + + SendMessage(This->hWndToolbar, + TB_SETBUTTONINFO, + (WPARAM)currentTaskItem->Index, + (LPARAM)&tbbi); + } + currentTaskItem++; + } + + ImageList_Remove(This->TaskIcons, TaskItem->IconIndex); +} +
static PTASK_ITEM TaskSwitchWnd_FindLastTaskItemOfGroup(IN OUT PTASK_SWITCH_WND This, @@ -541,6 +576,7 @@ { TBBUTTON tbBtn; INT iIndex; + HICON icon;
if (TaskItem->Index >= 0) { @@ -556,7 +592,10 @@ TaskItem->Group); }
- tbBtn.iBitmap = 0; + icon = TaskSwitchWnd_GetWndIcon(TaskItem->hWnd); + TaskItem->IconIndex = ImageList_AddIcon(This->TaskIcons, icon); + + tbBtn.iBitmap = TaskItem->IconIndex; tbBtn.fsState = TBSTATE_ENABLED | TBSTATE_ELLIPSES; tbBtn.fsStyle = BTNS_CHECK | BTNS_NOPREFIX | BTNS_SHOWTEXT; tbBtn.dwData = TaskItem->Index; @@ -612,6 +651,7 @@ { TaskSwitchWnd_BeginUpdate(This);
+ TaskSwitchWnd_RemoveIcon(This,TaskItem); iIndex = TaskItem->Index; if (SendMessage(This->hWndToolbar, TB_DELETEBUTTON, @@ -1107,7 +1147,10 @@ TaskSwitchWnd_FlashTaskItem(IN OUT PTASK_SWITCH_WND This, IN OUT PTASK_ITEM TaskItem) { - /* FIXME: Implement */ + TaskItem->RenderFlashed=1; + TaskSwitchWnd_UpdateTaskItemButton(This, + TaskItem); + }
static BOOL @@ -1151,6 +1194,7 @@ else if (TaskItem->Index >= 0) { UpdateTaskItem: + TaskItem->RenderFlashed=0; TaskSwitchWnd_UpdateTaskItemButton(This, TaskItem); } @@ -1384,6 +1428,18 @@ }
return Ret; +} + +static VOID +TaskSwitchWnd_UpdateTheme(IN OUT PTASK_SWITCH_WND This) +{ + if(This->TaskBandTheme) + CloseThemeData(This->TaskBandTheme); + + if(IsThemeActive()) + This->TaskBandTheme = OpenThemeData(This->hWnd, L"TaskBand"); + else + This->TaskBandTheme = 0; }
static VOID @@ -1410,11 +1466,16 @@ HMODULE hShell32; SIZE BtnSize;
+ SetWindowTheme(This->hWndToolbar, L"TaskBand", NULL); + TaskSwitchWnd_UpdateTheme(This); /* Identify the version we're using */ SendMessage(This->hWndToolbar, TB_BUTTONSTRUCTSIZE, sizeof(TBBUTTON), 0); + + This->TaskIcons = ImageList_Create(16, 16, ILC_COLOR32, 0, 1000); + SendMessage(This->hWndToolbar, TB_SETIMAGELIST, 0, (LPARAM)This->TaskIcons);
/* Calculate the default button size. Don't save this in This->ButtonSize.cx so that the actual button width gets updated correctly on the first recalculation */ @@ -1497,6 +1558,7 @@ } }
+ CloseThemeData(This->TaskBandTheme); TaskSwitchWnd_DeleteAllTasks(This); }
@@ -1729,7 +1791,7 @@ GetCursorPos(&pt); cmd = TrackPopupMenu(hmenu, TPM_LEFTBUTTON|TPM_RIGHTBUTTON|TPM_RETURNCMD, pt.x, pt.y, 0, This->hWndToolbar, NULL); if (cmd) { - SetForegroundWindow(TaskItem->hWnd); // reactivate window after the context menu has closed + SetForegroundWindow(TaskItem->hWnd); // reactivate window after the context menu has closed PostMessage(TaskItem->hWnd, WM_SYSCOMMAND, cmd, 0); } } @@ -1778,16 +1840,10 @@ TaskSwichWnd_HandleItemPaint(IN OUT PTASK_SWITCH_WND This, IN OUT NMTBCUSTOMDRAW *nmtbcd) { - HFONT hCaptionFont, hBoldCaptionFont; LRESULT Ret = CDRF_DODEFAULT; PTASK_GROUP TaskGroup; PTASK_ITEM TaskItem;
-#if TASK_USE_DRAWCAPTIONTEMP != 0 - - UINT uidctFlags = DC_TEXT | DC_ICON | DC_NOSENDMSG; - -#endif TaskItem = FindTaskItemByIndex(This, (INT)nmtbcd->nmcd.dwItemSpec); TaskGroup = FindTaskGroupByIndex(This, @@ -1798,97 +1854,29 @@
if (TaskItem != NULL && IsWindow(TaskItem->hWnd)) { - hCaptionFont = ITrayWindow_GetCaptionFonts(This->Tray, - &hBoldCaptionFont); - if (nmtbcd->nmcd.uItemState & CDIS_CHECKED) - hCaptionFont = hBoldCaptionFont; - -#if TASK_USE_DRAWCAPTIONTEMP != 0 - - /* Make sure we don't draw on the button edges */ - InflateRect(&nmtbcd->nmcd.rc, - -GetSystemMetrics(SM_CXEDGE), - -GetSystemMetrics(SM_CYEDGE)); - - if ((nmtbcd->nmcd.uItemState & CDIS_MARKED) && TaskItem->RenderFlashed) - { - /* This is a slight glitch. We have to move the rectangle so that - the button content appears to be pressed. However, when flashing - is enabled, we can see a light line at the top and left inner - border. We need to fill that area with the flashing color. Note - that since we're using DrawCaptionTemp() the flashing color is - COLOR_ACTIVECAPTION, not COLOR_HIGHLIGHT! */ - FillRect(nmtbcd->nmcd.hdc, - &nmtbcd->nmcd.rc, - (HBRUSH)(COLOR_ACTIVECAPTION + 1)); - - /* Make the button content appear pressed. This however draws a bit - into the right and bottom border of the button edge, making it - look a bit odd. However, selecting a clipping region to prevent - that from happening causes problems with DrawCaptionTemp()! */ - OffsetRect(&nmtbcd->nmcd.rc, - 1, - 1); - - /* Render flashed */ - uidctFlags |= DC_ACTIVE; - } - else - { - uidctFlags |= DC_INBUTTON; - if (nmtbcd->nmcd.uItemState & CDIS_CHECKED) - uidctFlags |= DC_ACTIVE; - } - - if (DrawCapTemp != NULL) - { - /* Draw the button content */ - TaskItem->DisplayTooltip = !DrawCapTemp(TaskItem->hWnd, - nmtbcd->nmcd.hdc, - &nmtbcd->nmcd.rc, - hCaptionFont, - NULL, - NULL, - uidctFlags); - } - - return CDRF_SKIPDEFAULT; - -#else /* !TASK_USE_DRAWCAPTIONTEMP */ - /* Make the entire button flashing if neccessary */ if (nmtbcd->nmcd.uItemState & CDIS_MARKED) { - if (TaskItem->RenderFlashed) - { - nmtbcd->hbrMonoDither = GetSysColorBrush(COLOR_HIGHLIGHT); - nmtbcd->clrTextHighlight = GetSysColor(COLOR_HIGHLIGHTTEXT); - nmtbcd->nHLStringBkMode = TRANSPARENT; - - /* We don't really need to set clrMark because we set the - background mode to TRANSPARENT! */ - nmtbcd->clrMark = GetSysColor(COLOR_HIGHLIGHT); - - Ret |= TBCDRF_USECDCOLORS; + Ret=TBCDRF_NOBACKGROUND; + if(!This->TaskBandTheme){ + SelectObject(nmtbcd->nmcd.hdc, GetSysColorBrush(COLOR_HIGHLIGHT)); + Rectangle(nmtbcd->nmcd.hdc, + nmtbcd->nmcd.rc.left, + nmtbcd->nmcd.rc.top, + nmtbcd->nmcd.rc.right, + nmtbcd->nmcd.rc.bottom); + }else{ + DrawThemeBackground(This->TaskBandTheme, nmtbcd->nmcd.hdc, TDP_FLASHBUTTON, 0, &nmtbcd->nmcd.rc, 0); } - else - Ret |= TBCDRF_NOMARK; - } - - /* Select the font we want to use */ - SelectObject(nmtbcd->nmcd.hdc, - hCaptionFont); - return Ret | CDRF_NEWFONT; - -#endif - + nmtbcd->clrText = GetSysColor(COLOR_HIGHLIGHTTEXT); + return Ret; + } } } else if (TaskGroup != NULL) { /* FIXME: Implement painting for task groups */ } - return Ret; }
@@ -1907,22 +1895,7 @@ switch (nmtbcd->nmcd.dwDrawStage) {
-#if TASK_USE_DRAWCAPTIONTEMP != 0 - case CDDS_ITEMPREPAINT: - /* We handle drawing in the post-paint stage so that we - don't have to draw the button edges, etc */ - Ret = CDRF_NOTIFYPOSTPAINT; - break; - - case CDDS_ITEMPOSTPAINT: - -#else /* !TASK_USE_DRAWCAPTIONTEMP */ - - case CDDS_ITEMPREPAINT: - -#endif - Ret = TaskSwichWnd_HandleItemPaint(This, nmtbcd); break; @@ -1940,6 +1913,13 @@ }
return Ret; +} + +static void TaskSwitchWnd_DrawBackground(HWND wnd, HDC dc) +{ + RECT rect; + GetClientRect(wnd, &rect); + DrawThemeParentBackground(wnd, dc, &rect); }
static LRESULT CALLBACK @@ -1961,6 +1941,12 @@ { switch (uMsg) { + case WM_THEMECHANGED: + TaskSwitchWnd_UpdateTheme(This); + break; + case WM_ERASEBKGND: + TaskSwitchWnd_DrawBackground(hwnd,(HDC)wParam); + break; case WM_SIZE: { SIZE szClient;