[ros-diffs] [janderwald] 23734: * optimize a few code paths * add error checking in various places * implement painting console image

janderwald at svn.reactos.org janderwald at svn.reactos.org
Sun Aug 27 02:46:50 CEST 2006


Author: janderwald
Date: Sun Aug 27 04:46:50 2006
New Revision: 23734

URL: http://svn.reactos.org/svn/reactos?rev=23734&view=rev
Log:
* optimize a few code paths
* add error checking in various places
* implement painting console image

Modified:
    trunk/reactos/dll/win32/console/colors.c
    trunk/reactos/dll/win32/console/console.c
    trunk/reactos/dll/win32/console/console.h
    trunk/reactos/dll/win32/console/en.rc
    trunk/reactos/dll/win32/console/layout.c
    trunk/reactos/dll/win32/console/resource.h

Modified: trunk/reactos/dll/win32/console/colors.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/console/colors.c?rev=23734&r1=23733&r2=23734&view=diff
==============================================================================
--- trunk/reactos/dll/win32/console/colors.c (original)
+++ trunk/reactos/dll/win32/console/colors.c Sun Aug 27 04:46:50 2006
@@ -217,24 +217,30 @@
 			{
 				DWORD index = LOWORD(wParam) - IDC_STATIC_COLOR1;
 
+				if (index == pConInfo->ActiveStaticControl)
+				{
+					/* same static control was re-clicked */
+					break;
+				}
+
 				SetDlgItemInt(hwndDlg, IDC_EDIT_COLOR_RED, GetRValue(s_Colors[index]), FALSE);
 				SetDlgItemInt(hwndDlg, IDC_EDIT_COLOR_GREEN, GetGValue(s_Colors[index]), FALSE);
 				SetDlgItemInt(hwndDlg, IDC_EDIT_COLOR_BLUE, GetBValue(s_Colors[index]), FALSE);
 
 				/* update global struct */
-				if (SendMessage(GetDlgItem(hwndDlg, IDC_RADIO_SCREEN_TEXT), BM_GETCHECK, 0, 0) & BST_CHECKED)
+				if (IsDlgButtonChecked(hwndDlg, IDC_RADIO_SCREEN_TEXT))
 				{
 					pConInfo->ScreenText = s_Colors[index];
 				}
-				else if (SendMessage(GetDlgItem(hwndDlg, IDC_RADIO_SCREEN_BACKGROUND), BM_GETCHECK, 0, 0) & BST_CHECKED)					
+				else if (IsDlgButtonChecked(hwndDlg, IDC_RADIO_SCREEN_BACKGROUND))
 				{
 					pConInfo->ScreenBackground = s_Colors[index];
 				}
-				else if (SendMessage(GetDlgItem(hwndDlg, IDC_RADIO_POPUP_TEXT), BM_GETCHECK, 0, 0) & BST_CHECKED)					
+				else if (IsDlgButtonChecked(hwndDlg, IDC_RADIO_POPUP_TEXT))
 				{
 					pConInfo->PopupText = s_Colors[index];
 				}
-				else if (SendMessage(GetDlgItem(hwndDlg, IDC_RADIO_POPUP_BACKGROUND), BM_GETCHECK, 0, 0) & BST_CHECKED)					
+				else if (IsDlgButtonChecked(hwndDlg, IDC_RADIO_POPUP_BACKGROUND))
 				{
 					pConInfo->PopupBackground = s_Colors[index];
 				}

Modified: trunk/reactos/dll/win32/console/console.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/console/console.c?rev=23734&r1=23733&r2=23734&view=diff
==============================================================================
--- trunk/reactos/dll/win32/console/console.c (original)
+++ trunk/reactos/dll/win32/console/console.c Sun Aug 27 04:46:50 2006
@@ -62,8 +62,11 @@
 	pConInfo->PopupText = RGB(128, 0, 128); 
 	pConInfo->PopupBackground = RGB(255, 255, 255); 
 	pConInfo->WindowSize = (DWORD)MAKELONG(80, 25);
-	pConInfo->WindowPosition = -1;
+	pConInfo->WindowPosition = UINT_MAX;
 	pConInfo->ScreenBuffer = MAKELONG(80, 300);
+	pConInfo->UseRasterFonts = TRUE;
+	pConInfo->FontSize = (DWORD)MAKELONG(8, 12);
+	pConInfo->FontWeight = FALSE;
 
 	GetModuleFileName(NULL, pConInfo->szProcessName, MAX_PATH);
 	GetStartupInfo(&StartupInfo);

Modified: trunk/reactos/dll/win32/console/console.h
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/console/console.h?rev=23734&r1=23733&r2=23734&view=diff
==============================================================================
--- trunk/reactos/dll/win32/console/console.h (original)
+++ trunk/reactos/dll/win32/console/console.h Sun Aug 27 04:46:50 2006
@@ -8,6 +8,7 @@
 #include <cpl.h>
 #include <tchar.h>
 #include <stdio.h>
+#include <limits.h>
 #include "resource.h"
 
 typedef struct
@@ -22,6 +23,9 @@
 {
   TCHAR szProcessName[MAX_PATH];
   BOOLEAN AppliedConfig;
+  BOOLEAN UseRasterFonts;
+  DWORD FontSize;
+  DWORD FontWeight;
   DWORD CursorSize;
   DWORD NumberOfHistoryBuffers;
   DWORD HistoryBufferSize;

Modified: trunk/reactos/dll/win32/console/en.rc
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/console/en.rc?rev=23734&r1=23733&r2=23734&view=diff
==============================================================================
--- trunk/reactos/dll/win32/console/en.rc (original)
+++ trunk/reactos/dll/win32/console/en.rc Sun Aug 27 04:46:50 2006
@@ -55,7 +55,7 @@
 LTEXT "Each character is:", -1, 130, 165, 75, 10
 LTEXT "screen pixel wide\nscreen pixel high", -1, 140, 180, 65, 20
 LTEXT "", IDC_FONT_SIZE_X, 125, 180, 10, 10
-LTEXT "", IDC_FONT_SIZE_Y, 125, 190, 10, 10
+LTEXT "", IDC_FONT_SIZE_Y, 125, 188, 10, 10
 END
 
 IDD_PROPPAGELAYOUT DIALOGEX 0, 0, 250, 220
@@ -147,4 +147,5 @@
   IDS_CPLDESCRIPTION "Configures console properties."
   IDS_APPLY_SHORTCUT_ALL "Modify &shortcut that started this window"
   IDS_SCREEN_TEXT "C:\ReactOS> dir\nSYSTEM          <DIR>     10-01-99     5:00\nSYSTEM32      <DIR>     10-01-99     5:00"
+  IDS_RASTERFONTS "Raster Fonts"
 END

Modified: trunk/reactos/dll/win32/console/layout.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/console/layout.c?rev=23734&r1=23733&r2=23734&view=diff
==============================================================================
--- trunk/reactos/dll/win32/console/layout.c (original)
+++ trunk/reactos/dll/win32/console/layout.c Sun Aug 27 04:46:50 2006
@@ -15,17 +15,66 @@
 {
 	COLORREF bkColor;
 	HBRUSH hBrush;
-
-	bkColor = GetSysColor(COLOR_BACKGROUND);
-	hBrush = CreateSolidBrush(bkColor);
-
-	FillRect(drawItem->hDC, &drawItem->rcItem, hBrush);
-	//TODO draw console image
-	//MoveToEx(drawItem->hDC, 0, 0, NULL);
-	//LineTo(drawItem->hDC, 10, 10);
-	//MoveToEx(drawItem->hDC, 30, 30, NULL);
-	//LineTo(drawItem->hDC, 40, 40);
-
+	RECT cRect, fRect;
+	DWORD startx, starty;
+	DWORD endx, endy;
+	DWORD sizex, sizey;
+
+	FillRect(drawItem->hDC, &drawItem->rcItem, GetSysColorBrush(COLOR_BACKGROUND));
+
+	sizex = drawItem->rcItem.right - drawItem->rcItem.left;
+	sizey = drawItem->rcItem.bottom - drawItem->rcItem.top;
+
+	if (pConInfo->WindowPosition == UINT_MAX)
+	{
+		startx = sizex / 3;
+		starty = sizey / 3;
+	}
+	else
+	{
+		//TODO
+		// calculate pos correctly when console centered
+		startx = sizex / 3;
+		starty = sizey / 3;
+	}
+
+	//TODO
+	// strech console when bold fonts are selected
+	endx = drawItem->rcItem.right - startx + 15;
+	endy = starty + sizey / 3;
+
+	/* draw console size */
+	SetRect(&cRect, startx, starty, endx, endy);
+	FillRect(drawItem->hDC, &cRect, GetSysColorBrush(COLOR_WINDOWFRAME));
+
+	/* draw console border */
+	SetRect(&fRect, startx + 1, starty + 1, cRect.right - 1, cRect.bottom - 1);
+	FrameRect(drawItem->hDC, &fRect, GetSysColorBrush(COLOR_ACTIVEBORDER));
+
+	/* draw left box */
+	SetRect(&fRect, startx + 3, starty + 3, startx + 5, starty + 5);
+	FillRect(drawItem->hDC, &fRect, GetSysColor(COLOR_ACTIVEBORDER));
+
+	/* draw window title */
+	SetRect(&fRect, startx + 7, starty + 3, cRect.right - 9, starty + 5);
+	FillRect(drawItem->hDC, &fRect, GetSysColorBrush(COLOR_ACTIVECAPTION));
+
+	/* draw first right box */
+	SetRect(&fRect, fRect.right + 1, starty + 3, fRect.right + 3, starty + 5);
+	FillRect(drawItem->hDC, &fRect, GetSysColor(COLOR_ACTIVEBORDER));
+
+	/* draw second right box */
+	SetRect(&fRect, fRect.right + 1, starty + 3, fRect.right + 3, starty + 5);
+	FillRect(drawItem->hDC, &fRect, GetSysColor(COLOR_ACTIVEBORDER));
+
+	/* draw scrollbar */
+	SetRect(&fRect, cRect.right - 5, fRect.bottom + 1, cRect.right - 3, cRect.bottom - 3);
+	FillRect(drawItem->hDC, &fRect, GetSysColorBrush(COLOR_SCROLLBAR));
+
+	/* draw console background */
+	hBrush = CreateSolidBrush(pConInfo->ScreenBackground);
+	SetRect(&fRect, startx + 3, starty + 6, cRect.right - 6, cRect.bottom - 3);
+	FillRect(drawItem->hDC, &fRect, hBrush);
 	DeleteObject((HGDIOBJ)hBrush);
 }
 
@@ -33,7 +82,7 @@
 {
 	COLORREF pbkColor, ptColor;
 	COLORREF nbkColor, ntColor;
-	HBRUSH hBrush;
+	HBRUSH hBrush = NULL;
 	TCHAR szText[1024];
 	
 	ZeroMemory(szText, sizeof(szText));
@@ -45,7 +94,7 @@
 		hBrush = CreateSolidBrush(nbkColor);
 		ntColor = pConInfo->ScreenText;
 	}
-	else
+	else if (drawItem->CtlID == IDC_STATIC_POPUP_COLOR)
 	{
 		nbkColor = pConInfo->PopupBackground;
 		hBrush = CreateSolidBrush(nbkColor);
@@ -58,16 +107,18 @@
 	}
 
 	FillRect(drawItem->hDC, &drawItem->rcItem, hBrush);
-	DeleteObject((HGDIOBJ)hBrush);
+	if (ntColor == nbkColor)
+	{
+		/* text has same color -> invisible */
+		return;
+	}
+
 	ptColor = SetTextColor(drawItem->hDC, ntColor);
 	pbkColor = SetBkColor(drawItem->hDC, nbkColor);
-	if (ntColor != nbkColor)
-	{
-		/* hide text when it has same background color as text color */
-		DrawText(drawItem->hDC, szText, _tcslen(szText), &drawItem->rcItem, 0);
-	}
+	DrawText(drawItem->hDC, szText, _tcslen(szText), &drawItem->rcItem, 0);
 	SetTextColor(drawItem->hDC, ptColor);
 	SetBkColor(drawItem->hDC, pbkColor);
+	DeleteObject((HGDIOBJ)hBrush);
 }
 
 

Modified: trunk/reactos/dll/win32/console/resource.h
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/console/resource.h?rev=23734&r1=23733&r2=23734&view=diff
==============================================================================
--- trunk/reactos/dll/win32/console/resource.h (original)
+++ trunk/reactos/dll/win32/console/resource.h Sun Aug 27 04:46:50 2006
@@ -91,5 +91,6 @@
 
 //string ids
 #define IDS_SCREEN_TEXT					700
+#define IDS_RASTERFONTS					701
 
 #endif




More information about the Ros-diffs mailing list