Author: janderwald
Date: Fri Aug 25 16:19:42 2006
New Revision: 23704
URL:
http://svn.reactos.org/svn/reactos?rev=23704&view=rev
Log:
* share common painting code
* align static control in same way
Modified:
trunk/reactos/dll/win32/console/colors.c
trunk/reactos/dll/win32/console/console.h
trunk/reactos/dll/win32/console/en.rc
trunk/reactos/dll/win32/console/font.c
trunk/reactos/dll/win32/console/layout.c
Modified: trunk/reactos/dll/win32/console/colors.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/console/colors.c…
==============================================================================
--- trunk/reactos/dll/win32/console/colors.c (original)
+++ trunk/reactos/dll/win32/console/colors.c Fri Aug 25 16:19:42 2006
@@ -8,7 +8,6 @@
*/
#include "console.h"
-
static COLORREF s_Colors[] =
{
@@ -30,7 +29,6 @@
RGB(255, 255, 255)
};
-static TCHAR szText[1024];
static
@@ -39,43 +37,6 @@
{
HBRUSH hBrush;
DWORD index;
-
- if (drawItem->CtlID < IDC_STATIC_COLOR1 || drawItem->CtlID >
IDC_STATIC_COLOR16)
- {
- COLORREF pbkColor, ptColor;
- COLORREF nbkColor, ntColor;
- /* draw static controls */
- if (drawItem->CtlID == IDC_STATIC_SCREEN_COLOR)
- {
- nbkColor = pConInfo->ScreenBackground;
- hBrush = CreateSolidBrush(nbkColor);
- ntColor = pConInfo->ScreenText;
- }
- else
- {
- nbkColor = pConInfo->PopupBackground;
- hBrush = CreateSolidBrush(nbkColor);
- ntColor = pConInfo->PopupText;
- }
-
- if (!hBrush)
- {
- return FALSE;
- }
-
- FillRect(drawItem->hDC, &drawItem->rcItem, hBrush);
- DeleteObject((HGDIOBJ)hBrush);
- 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);
- }
- SetTextColor(drawItem->hDC, ptColor);
- SetBkColor(drawItem->hDC, pbkColor);
- return TRUE;
- }
index = drawItem->CtlID - IDC_STATIC_COLOR1;
hBrush = CreateSolidBrush(s_Colors[index]);
@@ -101,6 +62,7 @@
PConsoleInfo pConInfo;
LPNMUPDOWN lpnmud;
LPPSHNOTIFY lppsn;
+ LPDRAWITEMSTRUCT drawItem;
DWORD red = -1;
DWORD green = -1;
DWORD blue = -1;
@@ -113,8 +75,6 @@
{
pConInfo = (PConsoleInfo) ((LPPROPSHEETPAGE)lParam)->lParam;
SetWindowLongPtr(hwndDlg, DWLP_USER, (LONG_PTR)pConInfo);
- ZeroMemory(szText, sizeof(szText));
- LoadString(hApplet, IDS_SCREEN_TEXT, szText, sizeof(szText) / sizeof(TCHAR));
SendMessage(GetDlgItem(hwndDlg, IDC_RADIO_SCREEN_BACKGROUND), BM_SETCHECK,
BST_CHECKED, 0);
SendMessage(GetDlgItem(hwndDlg, IDC_UPDOWN_COLOR_RED), UDM_SETRANGE, 0,
(LPARAM)MAKELONG(255, 0));
SendMessage(GetDlgItem(hwndDlg, IDC_UPDOWN_COLOR_GREEN), UDM_SETRANGE, 0,
(LPARAM)MAKELONG(255, 0));
@@ -124,7 +84,16 @@
}
case WM_DRAWITEM:
{
- return PaintStaticControls(hwndDlg, pConInfo, (LPDRAWITEMSTRUCT) lParam);
+ drawItem = (LPDRAWITEMSTRUCT)lParam;
+ if (drawItem->CtlID >= IDC_STATIC_COLOR1 && drawItem->CtlID <=
IDC_STATIC_COLOR16)
+ {
+ return PaintStaticControls(hwndDlg, pConInfo, drawItem);
+ }
+ else if (drawItem->CtlID == IDC_STATIC_SCREEN_COLOR || drawItem->CtlID ==
IDC_STATIC_POPUP_COLOR)
+ {
+ PaintText(drawItem, pConInfo);
+ return TRUE;
+ }
}
case WM_NOTIFY:
{
Modified: trunk/reactos/dll/win32/console/console.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/console/console.…
==============================================================================
--- trunk/reactos/dll/win32/console/console.h (original)
+++ trunk/reactos/dll/win32/console/console.h Fri Aug 25 16:19:42 2006
@@ -41,6 +41,8 @@
BOOL WriteConsoleOptions(PConsoleInfo pConInfo);
void ApplyConsoleInfo(HWND hwndDlg, PConsoleInfo pConInfo);
+void PaintConsole(LPDRAWITEMSTRUCT drawItem, PConsoleInfo pConInfo);
+void PaintText(LPDRAWITEMSTRUCT drawItem, PConsoleInfo pConInfo);
//globals
Modified: trunk/reactos/dll/win32/console/en.rc
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/console/en.rc?re…
==============================================================================
--- trunk/reactos/dll/win32/console/en.rc (original)
+++ trunk/reactos/dll/win32/console/en.rc Fri Aug 25 16:19:42 2006
@@ -45,13 +45,13 @@
BEGIN
LTEXT "Window Preview", -1, 10, 7, 65, 10
LTEXT "Size", -1, 130, 10, 30, 10
-CONTROL "", IDC_STATIC_FONT_WINDOW_PREVIEW, "Static", SS_BLACKRECT |
SS_SUNKEN, 10, 20, 115, 70
+CONTROL "", IDC_STATIC_FONT_WINDOW_PREVIEW, "Static", SS_OWNERDRAW |
SS_SUNKEN, 10, 20, 115, 70
LISTBOX IDC_LBOX_FONTS, 130, 20, 55, 80, LBS_DISABLENOSCROLL | WS_VSCROLL
LTEXT "&Font", -1, 10, 105, 35, 10
CHECKBOX "&Bold fonts", IDC_CHECK_BOLD_FONTS, 45, 105, 60, 10
LISTBOX IDC_LBOX_TYPE, 10, 120, 110, 50, LBS_DISABLENOSCROLL | WS_VSCROLL
GROUPBOX "", IDC_GROUPBOX_FONT_NAME, 10, 155, 200, 50
-CONTROL "", IDC_STATIC_SELECT_FONT_PREVIEW, "Static", SS_BLACKRECT |
SS_SUNKEN, 15, 165, 95, 35
+CONTROL "", IDC_STATIC_SELECT_FONT_PREVIEW, "Static", SS_OWNERDRAW |
SS_SUNKEN, 15, 165, 95, 35
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
@@ -63,30 +63,30 @@
CAPTION "Layout"
FONT 8, "MS Shell Dlg"
BEGIN
-LTEXT "Window Preview", -1, 10, 10, 65, 10
-CONTROL "", IDC_STATIC_LAYOUT_WINDOW_PREVIEW, "Static", SS_SUNKEN |
SS_OWNERDRAW, 10, 20, 100, 70
-GROUPBOX "Screen Buffer Size", -1, 115, 15, 115, 40
-LTEXT "&Width:", -1, 120, 30, 25, 10
-LTEXT "&Height:", -1, 120, 40, 25, 10
+LTEXT "Window Preview", -1, 10, 7, 65, 10
+CONTROL "", IDC_STATIC_LAYOUT_WINDOW_PREVIEW, "Static", SS_SUNKEN |
SS_OWNERDRAW, 10, 20, 115, 70
+GROUPBOX "Screen Buffer Size", -1, 130, 15, 115, 40
+LTEXT "&Width:", -1, 135, 30, 25, 10
+LTEXT "&Height:", -1, 135, 40, 25, 10
EDITTEXT IDC_EDIT_SCREEN_BUFFER_WIDTH, 165, 30, 35, 10, ES_RIGHT | WS_GROUP
CONTROL "", IDC_UPDOWN_SCREEN_BUFFER_WIDTH, UPDOWN_CLASS,UDS_SETBUDDYINT |
UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS | WS_BORDER | WS_GROUP, 185, 30, 30, 10
EDITTEXT IDC_EDIT_SCREEN_BUFFER_HEIGHT, 165, 40, 35, 10, ES_RIGHT | WS_GROUP
CONTROL "", IDC_UPDOWN_SCREEN_BUFFER_HEIGHT, UPDOWN_CLASS,UDS_SETBUDDYINT |
UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS | WS_BORDER | WS_GROUP, 185, 30, 30, 10
-GROUPBOX "Window Size", -1, 115, 60, 115, 40
-LTEXT "&W&idth:", -1, 120, 70, 25, 10
-LTEXT "&H&eight:", -1, 120, 80, 25, 10
+GROUPBOX "Window Size", -1, 130, 60, 115, 40
+LTEXT "&W&idth:", -1, 135, 70, 25, 10
+LTEXT "&H&eight:", -1, 135, 80, 25, 10
EDITTEXT IDC_EDIT_WINDOW_SIZE_WIDTH, 165, 70, 30, 10, ES_RIGHT | WS_GROUP
CONTROL "", IDC_UPDOWN_WINDOW_SIZE_WIDTH, UPDOWN_CLASS,UDS_SETBUDDYINT |
UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS | WS_BORDER | WS_GROUP, 185, 30, 30, 10
EDITTEXT IDC_EDIT_WINDOW_SIZE_HEIGHT, 165, 80, 30, 10, ES_RIGHT | WS_GROUP
CONTROL "", IDC_UPDOWN_WINDOW_SIZE_HEIGHT, UPDOWN_CLASS,UDS_SETBUDDYINT |
UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS | WS_BORDER | WS_GROUP, 185, 30, 30, 10
-GROUPBOX "Window Position", -1, 115, 105, 115, 55
-LTEXT "&Left:", -1, 120, 120, 25, 10
-LTEXT "&Top:", -1, 120, 130, 25, 10
+GROUPBOX "Window Position", -1, 130, 105, 115, 55
+LTEXT "&Left:", -1, 135, 120, 25, 10
+LTEXT "&Top:", -1, 135, 130, 25, 10
EDITTEXT IDC_EDIT_WINDOW_POS_LEFT, 165, 120, 30, 10, ES_RIGHT | WS_GROUP
CONTROL "", IDC_UPDOWN_WINDOW_POS_LEFT, UPDOWN_CLASS,UDS_SETBUDDYINT |
UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS | WS_BORDER | WS_GROUP, 170, 30, 30, 10
EDITTEXT IDC_EDIT_WINDOW_POS_TOP, 165, 130, 30, 10, ES_RIGHT | WS_GROUP
CONTROL "", IDC_UPDOWN_WINDOW_POS_TOP, UPDOWN_CLASS,UDS_SETBUDDYINT |
UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS | WS_BORDER | WS_GROUP, 170, 30, 30, 10
-CHECKBOX "Let system &position window", IDC_CHECK_SYSTEM_POS_WINDOW, 120,
145, 100, 10
+CHECKBOX "Let system &position window", IDC_CHECK_SYSTEM_POS_WINDOW, 135,
145, 100, 10
END
IDD_PROPPAGECOLORS DIALOGEX 0, 0, 250, 220
Modified: trunk/reactos/dll/win32/console/font.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/console/font.c?r…
==============================================================================
--- trunk/reactos/dll/win32/console/font.c (original)
+++ trunk/reactos/dll/win32/console/font.c Fri Aug 25 16:19:42 2006
@@ -19,6 +19,9 @@
LPARAM lParam
)
{
+ LPDRAWITEMSTRUCT drawItem;
+ PConsoleInfo pConInfo = (PConsoleInfo)GetWindowLongPtr(hwndDlg, DWLP_USER);
+
UNREFERENCED_PARAMETER(hwndDlg);
UNREFERENCED_PARAMETER(wParam);
@@ -26,10 +29,28 @@
switch(uMsg)
{
case WM_INITDIALOG:
+ {
+ pConInfo = (PConsoleInfo) ((LPPROPSHEETPAGE)lParam)->lParam;
+ SetWindowLongPtr(hwndDlg, DWLP_USER, (LONG_PTR)pConInfo);
return TRUE;
-
+ }
+ case WM_DRAWITEM:
+ {
+ drawItem = (LPDRAWITEMSTRUCT)lParam;
+ if (drawItem->CtlID == IDC_STATIC_FONT_WINDOW_PREVIEW)
+ {
+ PaintConsole(drawItem, pConInfo);
+ }
+ else if (drawItem->CtlID == IDC_STATIC_SELECT_FONT_PREVIEW)
+ {
+ PaintText(drawItem, pConInfo);
+ }
+ return TRUE;
+ }
default:
+ {
break;
+ }
}
return FALSE;
Modified: trunk/reactos/dll/win32/console/layout.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/console/layout.c…
==============================================================================
--- trunk/reactos/dll/win32/console/layout.c (original)
+++ trunk/reactos/dll/win32/console/layout.c Fri Aug 25 16:19:42 2006
@@ -8,6 +8,69 @@
*/
#include "console.h"
+
+
+
+void PaintConsole(LPDRAWITEMSTRUCT drawItem, PConsoleInfo pConInfo)
+{
+ 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);
+
+ DeleteObject((HGDIOBJ)hBrush);
+}
+
+void PaintText(LPDRAWITEMSTRUCT drawItem, PConsoleInfo pConInfo)
+{
+ COLORREF pbkColor, ptColor;
+ COLORREF nbkColor, ntColor;
+ HBRUSH hBrush;
+ TCHAR szText[1024];
+
+ ZeroMemory(szText, sizeof(szText));
+ LoadString(hApplet, IDS_SCREEN_TEXT, szText, sizeof(szText) / sizeof(TCHAR));
+
+ if (drawItem->CtlID == IDC_STATIC_SCREEN_COLOR)
+ {
+ nbkColor = pConInfo->ScreenBackground;
+ hBrush = CreateSolidBrush(nbkColor);
+ ntColor = pConInfo->ScreenText;
+ }
+ else
+ {
+ nbkColor = pConInfo->PopupBackground;
+ hBrush = CreateSolidBrush(nbkColor);
+ ntColor = pConInfo->PopupText;
+ }
+
+ if (!hBrush)
+ {
+ return;
+ }
+
+ FillRect(drawItem->hDC, &drawItem->rcItem, hBrush);
+ DeleteObject((HGDIOBJ)hBrush);
+ 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);
+ }
+ SetTextColor(drawItem->hDC, ptColor);
+ SetBkColor(drawItem->hDC, pbkColor);
+}
+
+
INT_PTR
CALLBACK
@@ -67,22 +130,7 @@
}
case WM_DRAWITEM:
{
- COLORREF bkColor;
- HBRUSH hBrush;
- LPDRAWITEMSTRUCT drawItem;
-
- bkColor = GetSysColor(COLOR_BACKGROUND);
- hBrush = CreateSolidBrush(bkColor);
- drawItem = (LPDRAWITEMSTRUCT) lParam;
-
- 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);
-
- DeleteObject((HGDIOBJ)hBrush);
+ PaintConsole((LPDRAWITEMSTRUCT)lParam, pConInfo);
return TRUE;
}
case WM_COMMAND: