From a3e70b2317a1e6b844ee6a2173ec3705cffaa47f Mon Sep 17 00:00:00 2001 From: Thomas Bluemel Date: Sat, 29 Sep 2007 06:22:44 +0000 Subject: [PATCH] Add ability to change/query single monitors and change/query the current selection in the monitor arrangement control svn path=/trunk/; revision=29291 --- reactos/dll/cpl/desk/monslctl.c | 168 ++++++++++++++++++++++++++++---- reactos/dll/cpl/desk/monslctl.h | 49 +++++++++- 2 files changed, 194 insertions(+), 23 deletions(-) diff --git a/reactos/dll/cpl/desk/monslctl.c b/reactos/dll/cpl/desk/monslctl.c index 197d6f1a1ad..4d36533d49b 100644 --- a/reactos/dll/cpl/desk/monslctl.c +++ b/reactos/dll/cpl/desk/monslctl.c @@ -39,6 +39,8 @@ typedef struct _MONITORSELWND POINT ScrollPos; SIZE Margin; SIZE SelectionFrame; + HBITMAP hbmDisabledPattern; + HBRUSH hbrDisabled; } MONITORSELWND, *PMONITORSELWND; static HFONT @@ -313,9 +315,9 @@ MonSelUpdateMonitorsInfo(IN OUT PMONITORSELWND infoPtr, } static BOOL -MonSelSetMonitorInfo(IN OUT PMONITORSELWND infoPtr, - IN DWORD dwMonitors, - IN const MONSL_MONINFO *MonitorsInfo) +MonSelSetMonitorsInfo(IN OUT PMONITORSELWND infoPtr, + IN DWORD dwMonitors, + IN const MONSL_MONINFO *MonitorsInfo) { DWORD Index; BOOL Ret = TRUE; @@ -393,9 +395,9 @@ MonSelSetMonitorInfo(IN OUT PMONITORSELWND infoPtr, } static DWORD -MonSelGetMonitorInfo(IN PMONITORSELWND infoPtr, - IN DWORD dwMonitors, - IN OUT PMONSL_MONINFO MonitorsInfo) +MonSelGetMonitorsInfo(IN PMONITORSELWND infoPtr, + IN DWORD dwMonitors, + IN OUT PMONSL_MONINFO MonitorsInfo) { if (dwMonitors != 0) { @@ -411,6 +413,41 @@ MonSelGetMonitorInfo(IN PMONITORSELWND infoPtr, return infoPtr->MonitorsCount; } +static BOOL +MonSelSetMonitorInfo(IN OUT PMONITORSELWND infoPtr, + IN INT Index, + IN const MONSL_MONINFO *MonitorsInfo) +{ + if (Index >= 0 && Index < (INT)infoPtr->MonitorsCount) + { + CopyMemory(&infoPtr->MonitorInfo[Index], + MonitorsInfo, + sizeof(MONSL_MONINFO)); + + MonSelUpdateMonitorsInfo(infoPtr, + TRUE); + return TRUE; + } + + return FALSE; +} + +static BOOL +MonSelGetMonitorInfo(IN PMONITORSELWND infoPtr, + IN INT Index, + IN OUT PMONSL_MONINFO MonitorsInfo) +{ + if (Index >= 0 && Index < (INT)infoPtr->MonitorsCount) + { + CopyMemory(MonitorsInfo, + &infoPtr->MonitorInfo[Index], + sizeof(MONSL_MONINFO)); + return TRUE; + } + + return FALSE; +} + static BOOL MonSelSetCurSelMonitor(IN OUT PMONITORSELWND infoPtr, IN INT Index) @@ -454,9 +491,21 @@ static VOID MonSelDestroy(IN OUT PMONITORSELWND infoPtr) { /* Free all monitors */ - MonSelSetMonitorInfo(infoPtr, - 0, - NULL); + MonSelSetMonitorsInfo(infoPtr, + 0, + NULL); + + if (infoPtr->hbrDisabled != NULL) + { + DeleteObject(infoPtr->hbrDisabled); + infoPtr->hbrDisabled = NULL; + } + + if (infoPtr->hbmDisabledPattern != NULL) + { + DeleteObject(infoPtr->hbmDisabledPattern); + infoPtr->hbmDisabledPattern = NULL; + } } static HFONT @@ -508,12 +557,44 @@ MonSelGetMonitorFont(IN OUT PMONITORSELWND infoPtr, return hFont; } +static BOOL +MonSelDrawDisabledRect(IN OUT PMONITORSELWND infoPtr, + IN HDC hDC, + IN const RECT *prc) +{ + BOOL Ret = FALSE; + + if (infoPtr->hbrDisabled == NULL) + { + static const DWORD Pattern[4] = {0x5555AAAA, 0x5555AAAA, 0x5555AAAA, 0x5555AAAA}; + + if (infoPtr->hbmDisabledPattern == NULL) + { + infoPtr->hbmDisabledPattern = CreateBitmap(8, + 8, + 1, + 1, + Pattern); + } + + if (infoPtr->hbmDisabledPattern != NULL) + infoPtr->hbrDisabled = CreatePatternBrush(infoPtr->hbmDisabledPattern); + } + + if (infoPtr->hbrDisabled != NULL) + { + /* FIXME - implement */ + } + + return Ret; +} + static VOID MonSelPaint(IN OUT PMONITORSELWND infoPtr, IN HDC hDC, - IN LPRECT prcUpdate) + IN const RECT *prcUpdate) { - COLORREF crPrevText; + COLORREF crPrevText, crPrevText2; HFONT hFont, hPrevFont; HBRUSH hbBk, hbOldBk; HPEN hpFg, hpOldFg; @@ -556,8 +637,17 @@ MonSelPaint(IN OUT PMONITORSELWND infoPtr, if (infoPtr->HasFocus && !(infoPtr->UIState & UISF_HIDEFOCUS)) { + /* NOTE: We need to switch the text color to the default, because + DrawFocusRect draws a solid line if the text is white! */ + + crPrevText2 = SetTextColor(hDC, + crPrevText); + DrawFocusRect(hDC, &rc); + + SetTextColor(hDC, + crPrevText2); } } @@ -592,6 +682,17 @@ MonSelPaint(IN OUT PMONITORSELWND infoPtr, SelectObject(hDC, hPrevFont); } + + if (infoPtr->MonitorInfo[Index].Flags & MSL_MIF_DISABLED) + { + InflateRect(&rc, + 1, + 1); + + MonSelDrawDisabledRect(infoPtr, + hDC, + &rc); + } } SetTextColor(hDC, @@ -801,19 +902,19 @@ MonitorSelWndProc(IN HWND hwnd, break; } - case MSLM_SETMONITORINFO: + case MSLM_SETMONITORSINFO: { - Ret = MonSelSetMonitorInfo(infoPtr, - (DWORD)wParam, - (const MONSL_MONINFO *)lParam); + Ret = MonSelSetMonitorsInfo(infoPtr, + (DWORD)wParam, + (const MONSL_MONINFO *)lParam); break; } - case MSLM_GETMONITORINFO: + case MSLM_GETMONITORSINFO: { - Ret = MonSelGetMonitorInfo(infoPtr, - (DWORD)wParam, - (PMONSL_MONINFO)lParam); + Ret = MonSelGetMonitorsInfo(infoPtr, + (DWORD)wParam, + (PMONSL_MONINFO)lParam); break; } @@ -830,6 +931,35 @@ MonitorSelWndProc(IN HWND hwnd, break; } + case MSLM_SETCURSEL: + { + Ret = MonSelSetCurSelMonitor(infoPtr, + (INT)wParam); + break; + } + + case MSLM_GETCURSEL: + { + Ret = infoPtr->SelectedMonitor; + break; + } + + case MSLM_SETMONITORINFO: + { + Ret = MonSelSetMonitorInfo(infoPtr, + (INT)wParam, + (const MONSL_MONINFO *)lParam); + break; + } + + case MSLM_GETMONITORINFO: + { + Ret = MonSelGetMonitorInfo(infoPtr, + (INT)wParam, + (PMONSL_MONINFO)lParam); + break; + } + case WM_CREATE: { infoPtr = (PMONITORSELWND) HeapAlloc(GetProcessHeap(), diff --git a/reactos/dll/cpl/desk/monslctl.h b/reactos/dll/cpl/desk/monslctl.h index 961369e8c8e..f3c2cc12c1c 100644 --- a/reactos/dll/cpl/desk/monslctl.h +++ b/reactos/dll/cpl/desk/monslctl.h @@ -13,7 +13,7 @@ typedef struct _MONSL_MONINFO } MONSL_MONINFO, *PMONSL_MONINFO; /* - * MSLM_SETMONITORINFO + * MSLM_SETMONITORSINFO * wParam: DWORD * Count of MONSL_MONINFO structures provided as lParam. * lParam: PMONSL_MONINFO @@ -21,10 +21,10 @@ typedef struct _MONSL_MONINFO * * Returns non-zero value if successful. */ -#define MSLM_SETMONITORINFO (WM_USER + 0x10) +#define MSLM_SETMONITORSINFO (WM_USER + 0x10) /* - * MSLM_GETMONITORINFO + * MSLM_GETMONITORSINFO * wParam: DWORD * Length of MONSL_MONINFO array buffer provided in lParam. * lParam: PMONSL_MONINFO @@ -32,7 +32,7 @@ typedef struct _MONSL_MONINFO * * Returns number of structures copied. */ -#define MSLM_GETMONITORINFO (WM_USER + 0x11) +#define MSLM_GETMONITORSINFO (WM_USER + 0x11) /* * MSLM_GETMONITORINFOCOUNT @@ -54,6 +54,47 @@ typedef struct _MONSL_MONINFO */ #define MSLM_HITTEST (WM_USER + 0x13) +/* + * MSLM_SETCURSEL + * wParam: INT + * Selects the monitor with this index. Pass -1 to clear the selection. + * lParam: Ignored. + * + * Returns a non-zero value if successful. + */ +#define MSLM_SETCURSEL (WM_USER + 0x14) + +/* + * MSLM_GETCURSEL + * wParam: Ignored. + * lParam: Ignored. + * + * Returns the index of the selected monitor, or -1 if none is currently selected. + */ +#define MSLM_GETCURSEL (WM_USER + 0x15) + +/* + * MSLM_SETMONITORINFO + * wParam: INT + * Index of the monitor information that is queried. + * lParam: PMONSL_MONINFO + * Pointer to a MONSL_MONINFO structures. + * + * Returns non-zero value if successful. + */ +#define MSLM_SETMONITORINFO (WM_USER + 0x16) + +/* + * MSLM_GETMONITORINFO + * wParam: INT + * Index of the monitor information to be changed. + * lParam: PMONSL_MONINFO + * Pointer to a MONSL_MONINFO structures. + * + * Returns non-zero value if successful. + */ +#define MSLM_GETMONITORINFO (WM_USER + 0x17) + BOOL RegisterMonitorSelectionControl(IN HINSTANCE hInstance); VOID UnregisterMonitorSelectionControl(IN HINSTANCE hInstance);