Author: weiden
Date: Sat Sep 29 08:46:34 2007
New Revision: 29290
URL:
http://svn.reactos.org/svn/reactos?rev=29290&view=rev
Log:
Display monitor number and various bug fixes
Modified:
trunk/reactos/dll/cpl/desk/lang/en-US.rc
trunk/reactos/dll/cpl/desk/monslctl.c
Modified: trunk/reactos/dll/cpl/desk/lang/en-US.rc
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/cpl/desk/lang/en-US.rc…
==============================================================================
--- trunk/reactos/dll/cpl/desk/lang/en-US.rc (original)
+++ trunk/reactos/dll/cpl/desk/lang/en-US.rc Sat Sep 29 08:46:34 2007
@@ -101,7 +101,7 @@
CAPTION "Settings"
FONT 8, "MS Shell Dlg"
BEGIN
- LTEXT "Drag the monitor icons to mach the physical arrangement of your
monitors.",-1,3,3,240,10
+ LTEXT "Drag the monitor icons to match the physical arrangement of
your monitors.",-1,3,3,240,10
CONTROL
"",IDC_SETTINGS_MONSEL,"MONITORSELWNDCLASS",WS_CHILD|WS_VISIBLE|WS_TABSTOP,3,16,240,82,WS_EX_CLIENTEDGE
LTEXT "&Display:",1820,3,100,30,8
LTEXT "<none>",IDC_SETTINGS_DEVICE,9,109,224,8
Modified: trunk/reactos/dll/cpl/desk/monslctl.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/cpl/desk/monslctl.c?re…
==============================================================================
--- trunk/reactos/dll/cpl/desk/monslctl.c (original)
+++ trunk/reactos/dll/cpl/desk/monslctl.c Sat Sep 29 08:46:34 2007
@@ -1,4 +1,6 @@
#include <windows.h>
+#include <tchar.h>
+#include <stdio.h>
#include "monslctl.h"
static const TCHAR szMonitorSelWndClass[] = TEXT("MONITORSELWNDCLASS");
@@ -6,6 +8,8 @@
typedef struct _MONSL_MON
{
RECT rc;
+ HFONT hFont;
+ TCHAR szCaption[12];
} MONSL_MON, *PMONSL_MON;
typedef struct _MONITORSELWND
@@ -23,6 +27,7 @@
UINT Enabled : 1;
UINT HasFocus : 1;
UINT CanDisplay : 1;
+ UINT AllowSelectNone : 1;
};
};
DWORD MonitorsCount;
@@ -233,6 +238,22 @@
}
static VOID
+MonSelResetMonitors(IN OUT PMONITORSELWND infoPtr)
+{
+ DWORD Index;
+
+ for (Index = 0; Index < infoPtr->MonitorsCount; Index++)
+ {
+ if (infoPtr->Monitors[Index].hFont != NULL)
+ {
+ DeleteObject(infoPtr->Monitors[Index].hFont);
+ infoPtr->Monitors[Index].hFont = NULL;
+ }
+ }
+}
+
+
+static VOID
MonSelUpdateMonitorsInfo(IN OUT PMONITORSELWND infoPtr,
IN BOOL bRepaint)
{
@@ -278,6 +299,8 @@
&infoPtr->Monitors[Index].rc);
}
+ MonSelResetMonitors(infoPtr);
+
if (bRepaint)
MonSelRepaint(infoPtr);
}
@@ -294,15 +317,15 @@
IN DWORD dwMonitors,
IN const MONSL_MONINFO *MonitorsInfo)
{
- DWORD dwOldCount;
+ DWORD Index;
BOOL Ret = TRUE;
-
- dwOldCount = infoPtr->MonitorsCount;
if (infoPtr->MonitorInfo != NULL)
{
LocalFree((HLOCAL)infoPtr->MonitorInfo);
infoPtr->MonitorInfo = NULL;
+
+ MonSelResetMonitors(infoPtr);
LocalFree((HLOCAL)infoPtr->Monitors);
infoPtr->Monitors = NULL;
@@ -326,11 +349,20 @@
ZeroMemory(infoPtr->Monitors,
dwMonitors * sizeof(MONSL_MON));
+ for (Index = 0; Index < dwMonitors; Index++)
+ {
+ _stprintf(infoPtr->Monitors[Index].szCaption,
+ _T("%u"),
+ Index + 1);
+ }
+
infoPtr->MonitorsCount = dwMonitors;
if (infoPtr->SelectedMonitor >= (INT)infoPtr->MonitorsCount)
infoPtr->SelectedMonitor = -1;
- infoPtr->SelectedMonitor = 0;
+
+ if (!infoPtr->AllowSelectNone && infoPtr->SelectedMonitor
< 0)
+ infoPtr->SelectedMonitor = 0;
MonSelUpdateMonitorsInfo(infoPtr,
TRUE);
@@ -427,31 +459,94 @@
NULL);
}
-static VOID
-MonSelPaint(IN PMONITORSELWND infoPtr,
+static HFONT
+MonSelGetMonitorFont(IN OUT PMONITORSELWND infoPtr,
+ IN HDC hDC,
+ IN INT Index)
+{
+ TEXTMETRIC tm;
+ SIZE rcsize;
+ LOGFONT lf;
+ HFONT hPrevFont, hFont;
+ INT len;
+
+ hFont = infoPtr->Monitors[Index].hFont;
+ if (hFont == NULL &&
+ GetObject(infoPtr->hFont,
+ sizeof(LOGFONT),
+ &lf) != 0)
+ {
+ rcsize.cx = infoPtr->Monitors[Index].rc.right -
infoPtr->Monitors[Index].rc.left -
+ (2 * infoPtr->SelectionFrame.cx) - 2;
+ rcsize.cy = infoPtr->Monitors[Index].rc.bottom -
infoPtr->Monitors[Index].rc.top -
+ (2 * infoPtr->SelectionFrame.cy) - 2;
+ rcsize.cy = (rcsize.cy * 60) / 100;
+
+ len = _tcslen(infoPtr->Monitors[Index].szCaption);
+
+ hPrevFont = SelectObject(hDC,
+ infoPtr->hFont);
+
+ if (GetTextMetrics(hDC,
+ &tm))
+ {
+ lf.lfWeight = FW_SEMIBOLD;
+ lf.lfHeight = -MulDiv(rcsize.cy - tm.tmExternalLeading,
+ GetDeviceCaps(hDC,
+ LOGPIXELSY),
+ 72);
+
+ hFont = CreateFontIndirect(&lf);
+ if (hFont != NULL)
+ infoPtr->Monitors[Index].hFont = hFont;
+ }
+
+ SelectObject(hDC,
+ hPrevFont);
+ }
+
+ return hFont;
+}
+
+static VOID
+MonSelPaint(IN OUT PMONITORSELWND infoPtr,
IN HDC hDC,
IN LPRECT prcUpdate)
{
+ COLORREF crPrevText;
+ HFONT hFont, hPrevFont;
HBRUSH hbBk, hbOldBk;
HPEN hpFg, hpOldFg;
DWORD Index;
- RECT rc;
+ RECT rc, rctmp;
+ INT iPrevBkMode;
hbBk = GetSysColorBrush(COLOR_BACKGROUND);
hpFg = CreatePen(PS_SOLID,
0,
- GetSysColor(COLOR_WINDOW));
+ GetSysColor(COLOR_HIGHLIGHTTEXT));
hbOldBk = SelectObject(hDC,
hbBk);
hpOldFg = SelectObject(hDC,
hpFg);
+ iPrevBkMode = SetBkMode(hDC,
+ TRANSPARENT);
+ crPrevText = SetTextColor(hDC,
+ GetSysColor(COLOR_HIGHLIGHTTEXT));
for (Index = 0; Index < infoPtr->MonitorsCount; Index++)
{
MonSelRectToScreen(infoPtr,
&infoPtr->Monitors[Index].rc,
&rc);
+
+ if (!IntersectRect(&rctmp,
+ &rc,
+ prcUpdate))
+ {
+ continue;
+ }
if ((INT)Index == infoPtr->SelectedMonitor)
{
@@ -475,8 +570,34 @@
rc.top,
rc.right,
rc.bottom);
- }
-
+
+ InflateRect(&rc,
+ -1,
+ -1);
+
+ hFont = MonSelGetMonitorFont(infoPtr,
+ hDC,
+ Index);
+ if (hFont != NULL)
+ {
+ hPrevFont = SelectObject(hDC,
+ hFont);
+
+ DrawText(hDC,
+ infoPtr->Monitors[Index].szCaption,
+ -1,
+ &rc,
+ DT_VCENTER | DT_CENTER | DT_NOPREFIX | DT_SINGLELINE);
+
+ SelectObject(hDC,
+ hPrevFont);
+ }
+ }
+
+ SetTextColor(hDC,
+ crPrevText);
+ SetBkMode(hDC,
+ iPrevBkMode);
SelectObject(hDC,
hpOldFg);
SelectObject(hDC,
@@ -555,7 +676,7 @@
Index = MonSelHitTest(infoPtr,
&pt);
- if (Index >= 0)
+ if (Index >= 0 || infoPtr->AllowSelectNone)
{
MonSelSetCurSelMonitor(infoPtr,
Index);