From 4b474cce5935ccc7491bf686c69921667c84b5a5 Mon Sep 17 00:00:00 2001 From: Eric Kohl Date: Sat, 26 Nov 2011 18:27:42 +0000 Subject: [PATCH] [USETUP] - Enable translations of the language page. Patch by Stefan Fulea. - Simplified the clear text code. - Fixed the german language page. See issue #6637 for more details. svn path=/trunk/; revision=54502 --- reactos/base/setup/usetup/interface/consup.c | 108 +++++++++++++++++++ reactos/base/setup/usetup/interface/consup.h | 6 ++ reactos/base/setup/usetup/interface/usetup.c | 45 +++++--- reactos/base/setup/usetup/lang/de-DE.h | 4 +- reactos/base/setup/usetup/mui.c | 39 +++++-- reactos/base/setup/usetup/mui.h | 5 +- 6 files changed, 183 insertions(+), 24 deletions(-) diff --git a/reactos/base/setup/usetup/interface/consup.c b/reactos/base/setup/usetup/interface/consup.c index 6c74040ec4c..517a289b1a7 100644 --- a/reactos/base/setup/usetup/interface/consup.c +++ b/reactos/base/setup/usetup/interface/consup.c @@ -269,6 +269,25 @@ CONSOLE_SetTextXY( &Written); } +static +VOID +CONSOLE_ClearTextXY(IN SHORT x, + IN SHORT y, + IN SHORT Length) +{ + COORD coPos; + DWORD Written; + + coPos.X = x; + coPos.Y = y; + + FillConsoleOutputCharacterA(StdOutput, + ' ', + Length, + coPos, + &Written); +} + VOID CONSOLE_SetInputTextXY( IN SHORT x, @@ -431,6 +450,25 @@ CONSOLE_SetStatusTextX( &Written); } +static +VOID +CONSOLE_ClearStatusTextX(IN SHORT x, + IN SHORT Length) +{ + COORD coPos; + DWORD Written; + + coPos.X = x; + coPos.Y = yScreen - 1; + + FillConsoleOutputCharacterA(StdOutput, + ' ', + Length, + coPos, + &Written); +} + + VOID CONSOLE_SetStatusTextAutoFitX( IN SHORT x, @@ -670,4 +708,74 @@ CONSOLE_SetStyledText( } } + +VOID +CONSOLE_ClearStyledText(IN SHORT x, + IN SHORT y, + IN INT Flags, + IN SHORT Length) +{ + COORD coPos; + + coPos.X = x; + coPos.Y = y; + + if (Flags & TEXT_TYPE_STATUS) + { + coPos.X = x; + coPos.Y = yScreen - 1; + } + else /* TEXT_TYPE_REGULAR (Default) */ + { + coPos.X = x; + coPos.Y = y; + } + + if (Flags & TEXT_ALIGN_CENTER) + { + coPos.X = (xScreen - Length) /2; + } + else if(Flags & TEXT_ALIGN_RIGHT) + { + coPos.X = coPos.X - Length; + + if (Flags & TEXT_PADDING_SMALL) + { + coPos.X -= 1; + } + else if (Flags & TEXT_PADDING_MEDIUM) + { + coPos.X -= 2; + } + else if (Flags & TEXT_PADDING_BIG) + { + coPos.X -= 3; + } + } + else /* TEXT_ALIGN_LEFT (Default) */ + { + if (Flags & TEXT_PADDING_SMALL) + { + coPos.X += 1; + } + else if (Flags & TEXT_PADDING_MEDIUM) + { + coPos.X += 2; + } + else if (Flags & TEXT_PADDING_BIG) + { + coPos.X += 3; + } + } + + if (Flags & TEXT_TYPE_STATUS) + { + CONSOLE_ClearStatusTextX(coPos.X, Length); + } + else /* TEXT_TYPE_REGULAR (Default) */ + { + CONSOLE_ClearTextXY(coPos.X, coPos.Y, Length); + } +} + /* EOF */ diff --git a/reactos/base/setup/usetup/interface/consup.h b/reactos/base/setup/usetup/interface/consup.h index 98be6dbf435..87ef24e0258 100644 --- a/reactos/base/setup/usetup/interface/consup.h +++ b/reactos/base/setup/usetup/interface/consup.h @@ -186,4 +186,10 @@ CONSOLE_SetStyledText( IN INT Flags, IN LPCSTR Text); +VOID +CONSOLE_ClearStyledText(IN SHORT x, + IN SHORT y, + IN INT Flags, + IN SHORT Length); + /* EOF */ diff --git a/reactos/base/setup/usetup/interface/usetup.c b/reactos/base/setup/usetup/interface/usetup.c index e05483a0690..6bc0e1fc672 100644 --- a/reactos/base/setup/usetup/interface/usetup.c +++ b/reactos/base/setup/usetup/interface/usetup.c @@ -608,6 +608,9 @@ UpdateKBLayout(VOID) static PAGE_NUMBER LanguagePage(PINPUT_RECORD Ir) { + PWCHAR NewLanguageId; + BOOL RefreshPage = FALSE; + /* Initialize the computer settings list */ if (LanguageList == NULL) { @@ -637,36 +640,26 @@ LanguagePage(PINPUT_RECORD Ir) if ((Ir->Event.KeyEvent.uChar.AsciiChar == 0x00) && (Ir->Event.KeyEvent.wVirtualKeyCode == VK_DOWN)) /* DOWN */ { -#if 0 - SelectedLanguageId = (PWCHAR)GetListEntryUserData(GetCurrentListEntry(LanguageList)); - - /* Redraw language selection page in native language */ - MUIDisplayPage(LANGUAGE_PAGE); -#endif - ScrollDownGenericList (LanguageList); + RefreshPage = TRUE; } else if ((Ir->Event.KeyEvent.uChar.AsciiChar == 0x00) && (Ir->Event.KeyEvent.wVirtualKeyCode == VK_UP)) /* UP */ { -#if 0 - SelectedLanguageId = (PWCHAR)GetListEntryUserData(GetCurrentListEntry(LanguageList)); - - /* Redraw language selection page in native language */ - MUIDisplayPage(LANGUAGE_PAGE); -#endif - ScrollUpGenericList(LanguageList); + RefreshPage = TRUE; } if ((Ir->Event.KeyEvent.uChar.AsciiChar == 0x00) && (Ir->Event.KeyEvent.wVirtualKeyCode == VK_NEXT)) /* PAGE DOWN */ { ScrollPageDownGenericList(LanguageList); + RefreshPage = TRUE; } else if ((Ir->Event.KeyEvent.uChar.AsciiChar == 0x00) && (Ir->Event.KeyEvent.wVirtualKeyCode == VK_PRIOR)) /* PAGE UP */ { ScrollPageUpGenericList(LanguageList); + RefreshPage = TRUE; } else if ((Ir->Event.KeyEvent.uChar.AsciiChar == 0x00) && (Ir->Event.KeyEvent.wVirtualKeyCode == VK_F3)) /* F3 */ @@ -685,7 +678,7 @@ LanguagePage(PINPUT_RECORD Ir) UpdateKBLayout(); } - // Load the font + /* Load the font */ SetConsoleCodePage(); return INTRO_PAGE; @@ -694,6 +687,28 @@ LanguagePage(PINPUT_RECORD Ir) { /* a-z */ GenericListKeyPress (LanguageList, Ir->Event.KeyEvent.uChar.AsciiChar); + RefreshPage = TRUE; + } + + if (RefreshPage) + { + NewLanguageId = (PWCHAR)GetListEntryUserData(GetCurrentListEntry(LanguageList)); + + if (SelectedLanguageId != NewLanguageId) + { + /* Clear the language page */ + MUIClearPage(LANGUAGE_PAGE); + + SelectedLanguageId = NewLanguageId; + + /* Load the font */ + SetConsoleCodePage(); + + /* Redraw language selection page in native language */ + MUIDisplayPage(LANGUAGE_PAGE); + } + + RefreshPage = FALSE; } } diff --git a/reactos/base/setup/usetup/lang/de-DE.h b/reactos/base/setup/usetup/lang/de-DE.h index 927a077b852..20b17b346e7 100644 --- a/reactos/base/setup/usetup/lang/de-DE.h +++ b/reactos/base/setup/usetup/lang/de-DE.h @@ -24,13 +24,13 @@ static MUI_ENTRY deDELanguagePageEntries[] = { 8, 10, - "\x07 Bitte w„hlen Sie die Sprache, die Sie w„hrend des Setups verwenden wollen.", + "\x07 Bitte w„hlen Sie die Sprache, die Sie w„hrend des Setups verwenden", TEXT_STYLE_NORMAL }, { 8, 11, - " Dann drcken Sie ENTER.", + "wollen. Dann drcken Sie ENTER.", TEXT_STYLE_NORMAL }, { diff --git a/reactos/base/setup/usetup/mui.c b/reactos/base/setup/usetup/mui.c index 1bf150df884..8c4694acf1e 100644 --- a/reactos/base/setup/usetup/mui.c +++ b/reactos/base/setup/usetup/mui.c @@ -40,7 +40,7 @@ PopupError(IN PCCH Text, static ULONG -FindLanguageIndex() +FindLanguageIndex(VOID) { ULONG lngIndex = 0; @@ -123,6 +123,34 @@ MUIGetLayoutsList(VOID) return LanguageList[lngIndex].MuiLayouts; } +VOID +MUIClearPage(IN ULONG page) +{ + const MUI_ENTRY * entry; + int index; + + entry = FindMUIEntriesOfPage(page); + if (!entry) + { + PopupError("Error: Failed to find translated page", + NULL, + NULL, + POPUP_WAIT_NONE); + return; + } + + index = 0; + do + { + CONSOLE_ClearStyledText(entry[index].X, + entry[index].Y, + entry[index].Flags, + strlen(entry[index].Buffer)); + index++; + } + while (entry[index].Buffer != NULL); +} + VOID MUIDisplayPage(IN ULONG page) { @@ -142,11 +170,10 @@ MUIDisplayPage(IN ULONG page) index = 0; do { - CONSOLE_SetStyledText ( - entry[index].X, - entry[index].Y, - entry[index].Flags, - entry[index].Buffer); + CONSOLE_SetStyledText(entry[index].X, + entry[index].Y, + entry[index].Flags, + entry[index].Buffer); index++; } diff --git a/reactos/base/setup/usetup/mui.h b/reactos/base/setup/usetup/mui.h index cf0f718c2e4..0f9a1e71fcd 100644 --- a/reactos/base/setup/usetup/mui.h +++ b/reactos/base/setup/usetup/mui.h @@ -29,7 +29,7 @@ typedef struct typedef struct { PWCHAR FontName; - PWCHAR SubFontName; + PWCHAR SubFontName; } MUI_SUBFONT; typedef struct @@ -56,6 +56,9 @@ typedef struct VOID MUIDisplayPage (ULONG PageNumber); +VOID +MUIClearPage (ULONG PageNumber); + VOID MUIDisplayError (ULONG ErrorNum, PINPUT_RECORD Ir, ULONG WaitEvent);