* optimize a few code paths

* add error checking in various places
* implement painting console image

svn path=/trunk/; revision=23734
This commit is contained in:
Johannes Anderwald 2006-08-27 00:46:50 +00:00
parent ab519c08f9
commit f8feed90ce
6 changed files with 88 additions and 22 deletions

View file

@ -217,24 +217,30 @@ ColorsProc(
{
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];
}

View file

@ -62,8 +62,11 @@ InitConsoleInfo()
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);

View file

@ -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 @@ typedef struct TAGConsoleInfo
{
TCHAR szProcessName[MAX_PATH];
BOOLEAN AppliedConfig;
BOOLEAN UseRasterFonts;
DWORD FontSize;
DWORD FontWeight;
DWORD CursorSize;
DWORD NumberOfHistoryBuffers;
DWORD HistoryBufferSize;

View file

@ -55,7 +55,7 @@ CONTROL "", IDC_STATIC_SELECT_FONT_PREVIEW, "Static", SS_OWNERDRAW | SS_SUNKEN,
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 @@ BEGIN
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

View file

@ -15,17 +15,66 @@ void PaintConsole(LPDRAWITEMSTRUCT drawItem, PConsoleInfo pConInfo)
{
COLORREF bkColor;
HBRUSH hBrush;
RECT cRect, fRect;
DWORD startx, starty;
DWORD endx, endy;
DWORD sizex, sizey;
bkColor = GetSysColor(COLOR_BACKGROUND);
hBrush = CreateSolidBrush(bkColor);
FillRect(drawItem->hDC, &drawItem->rcItem, GetSysColorBrush(COLOR_BACKGROUND));
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);
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 @@ void PaintText(LPDRAWITEMSTRUCT drawItem, PConsoleInfo pConInfo)
{
COLORREF pbkColor, ptColor;
COLORREF nbkColor, ntColor;
HBRUSH hBrush;
HBRUSH hBrush = NULL;
TCHAR szText[1024];
ZeroMemory(szText, sizeof(szText));
@ -45,7 +94,7 @@ void PaintText(LPDRAWITEMSTRUCT drawItem, PConsoleInfo pConInfo)
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 @@ void PaintText(LPDRAWITEMSTRUCT drawItem, PConsoleInfo pConInfo)
}
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);
}

View file

@ -91,5 +91,6 @@
//string ids
#define IDS_SCREEN_TEXT 700
#define IDS_RASTERFONTS 701
#endif