[USETUP] Factor out the UI-specific code from the GenList code, and wrap it inside a GENERIC_LIST_UI structure.

The aim here is to decouple the UI-specific code from code that can be used by both the text-mode USETUP and a future 1st-stage GUI setup.
Indeed, the GenLists can actually be used in the 1st-stage GUI; and their contents be displayed inside ListBoxes/ListViews... (this is just one example amongst others).

Additionally (in usetup.c):
- Make both FormatPartitionPage and CheckFileSystemPage return PAGE_NUMBERs.
- Improve a couple of comments.

svn path=/branches/setup_improvements/; revision=74553
This commit is contained in:
Hermès Bélusca-Maïto 2017-05-15 16:22:18 +00:00
parent 199fb91939
commit 92692eae3d
No known key found for this signature in database
GPG Key ID: 3B2539C65E7B93D0
3 changed files with 299 additions and 254 deletions

View File

@ -38,7 +38,7 @@ typedef struct _GENERIC_LIST_ENTRY
LIST_ENTRY Entry;
PGENERIC_LIST List;
PVOID UserData;
CHAR Text[1];
CHAR Text[1]; // FIXME: UI stuff
} GENERIC_LIST_ENTRY;
@ -47,18 +47,11 @@ typedef struct _GENERIC_LIST
LIST_ENTRY ListHead;
ULONG NumOfEntries;
PLIST_ENTRY FirstShown;
PLIST_ENTRY LastShown;
SHORT Left;
SHORT Top;
SHORT Right;
SHORT Bottom;
BOOL Redraw;
PGENERIC_LIST_ENTRY CurrentEntry;
PGENERIC_LIST_ENTRY BackupEntry;
} GENERIC_LIST;
PGENERIC_LIST
CreateGenericList(VOID)
{
@ -73,23 +66,16 @@ CreateGenericList(VOID)
InitializeListHead(&List->ListHead);
List->NumOfEntries = 0;
List->Left = 0;
List->Top = 0;
List->Right = 0;
List->Bottom = 0;
List->Redraw = TRUE;
List->CurrentEntry = NULL;
List->BackupEntry = NULL;
return List;
}
VOID
DestroyGenericList(
PGENERIC_LIST List,
BOOLEAN FreeUserData)
IN OUT PGENERIC_LIST List,
IN BOOLEAN FreeUserData)
{
PGENERIC_LIST_ENTRY ListEntry;
PLIST_ENTRY Entry;
@ -112,13 +98,12 @@ DestroyGenericList(
RtlFreeHeap (ProcessHeap, 0, List);
}
BOOLEAN
AppendGenericListEntry(
PGENERIC_LIST List,
PCHAR Text,
PVOID UserData,
BOOLEAN Current)
IN OUT PGENERIC_LIST List,
IN PCHAR Text,
IN PVOID UserData,
IN BOOLEAN Current)
{
PGENERIC_LIST_ENTRY Entry;
@ -145,18 +130,34 @@ AppendGenericListEntry(
}
VOID
InitGenericListUi(
IN OUT PGENERIC_LIST_UI ListUi,
IN PGENERIC_LIST List)
{
ListUi->List = List;
ListUi->FirstShown = NULL;
ListUi->LastShown = NULL;
ListUi->Left = 0;
ListUi->Top = 0;
ListUi->Right = 0;
ListUi->Bottom = 0;
ListUi->Redraw = TRUE;
}
static
VOID
DrawListFrame(
PGENERIC_LIST GenericList)
IN PGENERIC_LIST_UI ListUi)
{
COORD coPos;
DWORD Written;
SHORT i;
/* Draw upper left corner */
coPos.X = GenericList->Left;
coPos.Y = GenericList->Top;
coPos.X = ListUi->Left;
coPos.Y = ListUi->Top;
FillConsoleOutputCharacterA (StdOutput,
0xDA, // '+',
1,
@ -164,17 +165,17 @@ DrawListFrame(
&Written);
/* Draw upper edge */
coPos.X = GenericList->Left + 1;
coPos.Y = GenericList->Top;
coPos.X = ListUi->Left + 1;
coPos.Y = ListUi->Top;
FillConsoleOutputCharacterA (StdOutput,
0xC4, // '-',
GenericList->Right - GenericList->Left - 1,
ListUi->Right - ListUi->Left - 1,
coPos,
&Written);
/* Draw upper right corner */
coPos.X = GenericList->Right;
coPos.Y = GenericList->Top;
coPos.X = ListUi->Right;
coPos.Y = ListUi->Top;
FillConsoleOutputCharacterA (StdOutput,
0xBF, // '+',
1,
@ -182,9 +183,9 @@ DrawListFrame(
&Written);
/* Draw left and right edge */
for (i = GenericList->Top + 1; i < GenericList->Bottom; i++)
for (i = ListUi->Top + 1; i < ListUi->Bottom; i++)
{
coPos.X = GenericList->Left;
coPos.X = ListUi->Left;
coPos.Y = i;
FillConsoleOutputCharacterA (StdOutput,
0xB3, // '|',
@ -192,7 +193,7 @@ DrawListFrame(
coPos,
&Written);
coPos.X = GenericList->Right;
coPos.X = ListUi->Right;
FillConsoleOutputCharacterA (StdOutput,
0xB3, //'|',
1,
@ -201,8 +202,8 @@ DrawListFrame(
}
/* Draw lower left corner */
coPos.X = GenericList->Left;
coPos.Y = GenericList->Bottom;
coPos.X = ListUi->Left;
coPos.Y = ListUi->Bottom;
FillConsoleOutputCharacterA (StdOutput,
0xC0, // '+',
1,
@ -210,17 +211,17 @@ DrawListFrame(
&Written);
/* Draw lower edge */
coPos.X = GenericList->Left + 1;
coPos.Y = GenericList->Bottom;
coPos.X = ListUi->Left + 1;
coPos.Y = ListUi->Bottom;
FillConsoleOutputCharacterA (StdOutput,
0xC4, // '-',
GenericList->Right - GenericList->Left - 1,
ListUi->Right - ListUi->Left - 1,
coPos,
&Written);
/* Draw lower right corner */
coPos.X = GenericList->Right;
coPos.Y = GenericList->Bottom;
coPos.X = ListUi->Right;
coPos.Y = ListUi->Bottom;
FillConsoleOutputCharacterA (StdOutput,
0xD9, // '+',
1,
@ -232,29 +233,30 @@ DrawListFrame(
static
VOID
DrawListEntries(
PGENERIC_LIST GenericList)
IN PGENERIC_LIST_UI ListUi)
{
PGENERIC_LIST List = ListUi->List;
PGENERIC_LIST_ENTRY ListEntry;
PLIST_ENTRY Entry;
COORD coPos;
DWORD Written;
USHORT Width;
coPos.X = GenericList->Left + 1;
coPos.Y = GenericList->Top + 1;
Width = GenericList->Right - GenericList->Left - 1;
coPos.X = ListUi->Left + 1;
coPos.Y = ListUi->Top + 1;
Width = ListUi->Right - ListUi->Left - 1;
Entry = GenericList->FirstShown;
while (Entry != &GenericList->ListHead)
Entry = ListUi->FirstShown;
while (Entry != &List->ListHead)
{
ListEntry = CONTAINING_RECORD (Entry, GENERIC_LIST_ENTRY, Entry);
if (coPos.Y == GenericList->Bottom)
if (coPos.Y == ListUi->Bottom)
break;
GenericList->LastShown = Entry;
ListUi->LastShown = Entry;
FillConsoleOutputAttribute (StdOutput,
(GenericList->CurrentEntry == ListEntry) ?
(List->CurrentEntry == ListEntry) ?
FOREGROUND_BLUE | BACKGROUND_WHITE :
FOREGROUND_WHITE | BACKGROUND_BLUE,
Width,
@ -279,7 +281,7 @@ DrawListEntries(
Entry = Entry->Flink;
}
while (coPos.Y < GenericList->Bottom)
while (coPos.Y < ListUi->Bottom)
{
FillConsoleOutputAttribute (StdOutput,
FOREGROUND_WHITE | BACKGROUND_BLUE,
@ -300,15 +302,16 @@ DrawListEntries(
static
VOID
DrawScrollBarGenericList(
PGENERIC_LIST GenericList)
IN PGENERIC_LIST_UI ListUi)
{
PGENERIC_LIST List = ListUi->List;
COORD coPos;
DWORD Written;
coPos.X = GenericList->Right + 1;
coPos.Y = GenericList->Top;
coPos.X = ListUi->Right + 1;
coPos.Y = ListUi->Top;
if (GenericList->FirstShown != GenericList->ListHead.Flink)
if (ListUi->FirstShown != List->ListHead.Flink)
{
FillConsoleOutputCharacterA (StdOutput,
'\x18',
@ -325,8 +328,8 @@ DrawScrollBarGenericList(
&Written);
}
coPos.Y = GenericList->Bottom;
if (GenericList->LastShown != GenericList->ListHead.Blink)
coPos.Y = ListUi->Bottom;
if (ListUi->LastShown != List->ListHead.Blink)
{
FillConsoleOutputCharacterA (StdOutput,
'\x19',
@ -348,18 +351,22 @@ DrawScrollBarGenericList(
static
VOID
CenterCurrentListItem(
PGENERIC_LIST List)
IN PGENERIC_LIST_UI ListUi)
{
PGENERIC_LIST List = ListUi->List;
PLIST_ENTRY Entry;
ULONG MaxVisibleItems, ItemCount, i;
if ((List->Top == 0 && List->Bottom == 0) ||
if ((ListUi->Top == 0 && ListUi->Bottom == 0) ||
IsListEmpty(&List->ListHead) ||
List->CurrentEntry == NULL)
{
return;
}
MaxVisibleItems = (ULONG)(List->Bottom - List->Top - 1);
MaxVisibleItems = (ULONG)(ListUi->Bottom - ListUi->Top - 1);
/*****************************************
ItemCount = 0;
Entry = List->ListHead.Flink;
while (Entry != &List->ListHead)
@ -367,6 +374,8 @@ CenterCurrentListItem(
ItemCount++;
Entry = Entry->Flink;
}
*****************************************/
ItemCount = List->NumOfEntries; // GetNumberOfListEntries(List);
if (ItemCount > MaxVisibleItems)
{
@ -377,7 +386,7 @@ CenterCurrentListItem(
Entry = Entry->Blink;
}
List->FirstShown = Entry;
ListUi->FirstShown = Entry;
for (i = 0; i < MaxVisibleItems; i++)
{
@ -385,87 +394,90 @@ CenterCurrentListItem(
Entry = Entry->Flink;
}
List->LastShown = Entry;
ListUi->LastShown = Entry;
}
}
VOID
DrawGenericList(
PGENERIC_LIST List,
SHORT Left,
SHORT Top,
SHORT Right,
SHORT Bottom)
IN PGENERIC_LIST_UI ListUi,
IN SHORT Left,
IN SHORT Top,
IN SHORT Right,
IN SHORT Bottom)
{
List->FirstShown = List->ListHead.Flink;
List->Left = Left;
List->Top = Top;
List->Right = Right;
List->Bottom = Bottom;
PGENERIC_LIST List = ListUi->List;
DrawListFrame(List);
ListUi->FirstShown = List->ListHead.Flink;
ListUi->Left = Left;
ListUi->Top = Top;
ListUi->Right = Right;
ListUi->Bottom = Bottom;
DrawListFrame(ListUi);
if (IsListEmpty(&List->ListHead))
return;
CenterCurrentListItem(List);
CenterCurrentListItem(ListUi);
DrawListEntries(List);
DrawScrollBarGenericList(List);
DrawListEntries(ListUi);
DrawScrollBarGenericList(ListUi);
}
VOID
ScrollPageDownGenericList(
PGENERIC_LIST List)
IN PGENERIC_LIST_UI ListUi)
{
SHORT i;
/* Suspend auto-redraw */
List->Redraw = FALSE;
ListUi->Redraw = FALSE;
for (i = List->Top + 1; i < List->Bottom - 1; i++)
for (i = ListUi->Top + 1; i < ListUi->Bottom - 1; i++)
{
ScrollDownGenericList (List);
ScrollDownGenericList(ListUi);
}
/* Update user interface */
DrawListEntries(List);
DrawScrollBarGenericList(List);
DrawListEntries(ListUi);
DrawScrollBarGenericList(ListUi);
/* Re enable auto-redraw */
List->Redraw = TRUE;
ListUi->Redraw = TRUE;
}
VOID
ScrollPageUpGenericList(
PGENERIC_LIST List)
IN PGENERIC_LIST_UI ListUi)
{
SHORT i;
/* Suspend auto-redraw */
List->Redraw = FALSE;
ListUi->Redraw = FALSE;
for (i = List->Bottom - 1; i > List->Top + 1; i--)
for (i = ListUi->Bottom - 1; i > ListUi->Top + 1; i--)
{
ScrollUpGenericList (List);
ScrollUpGenericList(ListUi);
}
/* Update user interface */
DrawListEntries(List);
DrawScrollBarGenericList(List);
DrawListEntries(ListUi);
DrawScrollBarGenericList(ListUi);
/* Re enable auto-redraw */
List->Redraw = TRUE;
ListUi->Redraw = TRUE;
}
VOID
ScrollDownGenericList(
PGENERIC_LIST List)
IN PGENERIC_LIST_UI ListUi)
{
PGENERIC_LIST List = ListUi->List;
PLIST_ENTRY Entry;
if (List->CurrentEntry == NULL)
@ -474,17 +486,17 @@ ScrollDownGenericList(
if (List->CurrentEntry->Entry.Flink != &List->ListHead)
{
Entry = List->CurrentEntry->Entry.Flink;
if (List->LastShown == &List->CurrentEntry->Entry)
if (ListUi->LastShown == &List->CurrentEntry->Entry)
{
List->FirstShown = List->FirstShown->Flink;
List->LastShown = List->LastShown->Flink;
ListUi->FirstShown = ListUi->FirstShown->Flink;
ListUi->LastShown = ListUi->LastShown->Flink;
}
List->CurrentEntry = CONTAINING_RECORD (Entry, GENERIC_LIST_ENTRY, Entry);
List->CurrentEntry = CONTAINING_RECORD(Entry, GENERIC_LIST_ENTRY, Entry);
if (List->Redraw)
if (ListUi->Redraw)
{
DrawListEntries(List);
DrawScrollBarGenericList(List);
DrawListEntries(ListUi);
DrawScrollBarGenericList(ListUi);
}
}
}
@ -492,9 +504,10 @@ ScrollDownGenericList(
VOID
ScrollToPositionGenericList(
PGENERIC_LIST List,
ULONG uIndex)
IN PGENERIC_LIST_UI ListUi,
IN ULONG uIndex)
{
PGENERIC_LIST List = ListUi->List;
PLIST_ENTRY Entry;
ULONG uCount = 0;
@ -506,29 +519,30 @@ ScrollToPositionGenericList(
if (List->CurrentEntry->Entry.Flink != &List->ListHead)
{
Entry = List->CurrentEntry->Entry.Flink;
if (List->LastShown == &List->CurrentEntry->Entry)
if (ListUi->LastShown == &List->CurrentEntry->Entry)
{
List->FirstShown = List->FirstShown->Flink;
List->LastShown = List->LastShown->Flink;
ListUi->FirstShown = ListUi->FirstShown->Flink;
ListUi->LastShown = ListUi->LastShown->Flink;
}
List->CurrentEntry = CONTAINING_RECORD (Entry, GENERIC_LIST_ENTRY, Entry);
List->CurrentEntry = CONTAINING_RECORD(Entry, GENERIC_LIST_ENTRY, Entry);
}
uCount++;
}
while (uIndex != uCount);
if (List->Redraw)
if (ListUi->Redraw)
{
DrawListEntries(List);
DrawScrollBarGenericList(List);
DrawListEntries(ListUi);
DrawScrollBarGenericList(ListUi);
}
}
VOID
ScrollUpGenericList(
PGENERIC_LIST List)
IN PGENERIC_LIST_UI ListUi)
{
PGENERIC_LIST List = ListUi->List;
PLIST_ENTRY Entry;
if (List->CurrentEntry == NULL)
@ -537,17 +551,17 @@ ScrollUpGenericList(
if (List->CurrentEntry->Entry.Blink != &List->ListHead)
{
Entry = List->CurrentEntry->Entry.Blink;
if (List->FirstShown == &List->CurrentEntry->Entry)
if (ListUi->FirstShown == &List->CurrentEntry->Entry)
{
List->FirstShown = List->FirstShown->Blink;
List->LastShown = List->LastShown->Blink;
ListUi->FirstShown = ListUi->FirstShown->Blink;
ListUi->LastShown = ListUi->LastShown->Blink;
}
List->CurrentEntry = CONTAINING_RECORD (Entry, GENERIC_LIST_ENTRY, Entry);
List->CurrentEntry = CONTAINING_RECORD(Entry, GENERIC_LIST_ENTRY, Entry);
if (List->Redraw)
if (ListUi->Redraw)
{
DrawListEntries(List);
DrawScrollBarGenericList(List);
DrawListEntries(ListUi);
DrawScrollBarGenericList(ListUi);
}
}
}
@ -555,23 +569,24 @@ ScrollUpGenericList(
VOID
RedrawGenericList(
PGENERIC_LIST List)
IN PGENERIC_LIST_UI ListUi)
{
if (List->CurrentEntry == NULL)
if (ListUi->List->CurrentEntry == NULL)
return;
if (List->Redraw)
if (ListUi->Redraw)
{
DrawListEntries(List);
DrawScrollBarGenericList(List);
DrawListEntries(ListUi);
DrawScrollBarGenericList(ListUi);
}
}
VOID
SetCurrentListEntry(
PGENERIC_LIST List,
PGENERIC_LIST_ENTRY Entry)
IN PGENERIC_LIST List,
IN PGENERIC_LIST_ENTRY Entry)
{
if (Entry->List != List)
return;
@ -581,7 +596,7 @@ SetCurrentListEntry(
PGENERIC_LIST_ENTRY
GetCurrentListEntry(
PGENERIC_LIST List)
IN PGENERIC_LIST List)
{
return List->CurrentEntry;
}
@ -589,7 +604,7 @@ GetCurrentListEntry(
PGENERIC_LIST_ENTRY
GetFirstListEntry(
PGENERIC_LIST List)
IN PGENERIC_LIST List)
{
PLIST_ENTRY Entry = List->ListHead.Flink;
@ -601,7 +616,7 @@ GetFirstListEntry(
PGENERIC_LIST_ENTRY
GetNextListEntry(
PGENERIC_LIST_ENTRY Entry)
IN PGENERIC_LIST_ENTRY Entry)
{
PLIST_ENTRY Next = Entry->Entry.Flink;
@ -613,7 +628,7 @@ GetNextListEntry(
PVOID
GetListEntryUserData(
PGENERIC_LIST_ENTRY Entry)
IN PGENERIC_LIST_ENTRY Entry)
{
return Entry->UserData;
}
@ -621,7 +636,7 @@ GetListEntryUserData(
LPCSTR
GetListEntryText(
PGENERIC_LIST_ENTRY Entry)
IN PGENERIC_LIST_ENTRY Entry)
{
return Entry->Text;
}
@ -629,40 +644,42 @@ GetListEntryText(
ULONG
GetNumberOfListEntries(
PGENERIC_LIST List)
IN PGENERIC_LIST List)
{
return List->NumOfEntries;
}
VOID
GenericListKeyPress(
PGENERIC_LIST GenericList,
CHAR AsciiChar)
IN PGENERIC_LIST_UI ListUi,
IN CHAR AsciiChar)
{
PGENERIC_LIST List = ListUi->List;
PGENERIC_LIST_ENTRY ListEntry;
PGENERIC_LIST_ENTRY OldListEntry;
BOOLEAN Flag = FALSE;
ListEntry = GenericList->CurrentEntry;
OldListEntry = GenericList->CurrentEntry;
ListEntry = List->CurrentEntry;
OldListEntry = List->CurrentEntry;
GenericList->Redraw = FALSE;
ListUi->Redraw = FALSE;
if ((strlen(ListEntry->Text) > 0) && (tolower(ListEntry->Text[0]) == AsciiChar) &&
(GenericList->CurrentEntry->Entry.Flink != &GenericList->ListHead))
(List->CurrentEntry->Entry.Flink != &List->ListHead))
{
ScrollDownGenericList(GenericList);
ListEntry = GenericList->CurrentEntry;
ScrollDownGenericList(ListUi);
ListEntry = List->CurrentEntry;
if ((strlen(ListEntry->Text) > 0) && (tolower(ListEntry->Text[0]) == AsciiChar))
goto End;
}
while (GenericList->CurrentEntry->Entry.Blink != &GenericList->ListHead)
ScrollUpGenericList(GenericList);
while (List->CurrentEntry->Entry.Blink != &List->ListHead)
ScrollUpGenericList(ListUi);
ListEntry = GenericList->CurrentEntry;
ListEntry = List->CurrentEntry;
for (;;)
{
@ -672,34 +689,35 @@ GenericListKeyPress(
break;
}
if (GenericList->CurrentEntry->Entry.Flink == &GenericList->ListHead)
if (List->CurrentEntry->Entry.Flink == &List->ListHead)
break;
ScrollDownGenericList(GenericList);
ListEntry = GenericList->CurrentEntry;
ScrollDownGenericList(ListUi);
ListEntry = List->CurrentEntry;
}
if (!Flag)
{
while (GenericList->CurrentEntry->Entry.Blink != &GenericList->ListHead)
while (List->CurrentEntry->Entry.Blink != &List->ListHead)
{
if (GenericList->CurrentEntry != OldListEntry)
ScrollUpGenericList(GenericList);
if (List->CurrentEntry != OldListEntry)
ScrollUpGenericList(ListUi);
else
break;
}
}
End:
DrawListEntries(GenericList);
DrawScrollBarGenericList(GenericList);
GenericList->Redraw = TRUE;
End:
DrawListEntries(ListUi);
DrawScrollBarGenericList(ListUi);
ListUi->Redraw = TRUE;
}
VOID
SaveGenericListState(
PGENERIC_LIST List)
IN PGENERIC_LIST List)
{
List->BackupEntry = List->CurrentEntry;
}
@ -707,15 +725,15 @@ SaveGenericListState(
VOID
RestoreGenericListState(
PGENERIC_LIST List)
IN PGENERIC_LIST List)
{
List->CurrentEntry = List->BackupEntry;
}
BOOL
BOOLEAN
GenericListHasSingleEntry(
PGENERIC_LIST List)
IN PGENERIC_LIST List)
{
if (!IsListEmpty(&List->ListHead) && List->ListHead.Flink == List->ListHead.Blink)
return TRUE;

View File

@ -36,93 +36,115 @@ CreateGenericList(VOID);
VOID
DestroyGenericList(
PGENERIC_LIST List,
BOOLEAN FreeUserData);
IN OUT PGENERIC_LIST List,
IN BOOLEAN FreeUserData);
BOOLEAN
AppendGenericListEntry(
PGENERIC_LIST List,
PCHAR Text,
PVOID UserData,
BOOLEAN Current);
VOID
DrawGenericList(
PGENERIC_LIST List,
SHORT Left,
SHORT Top,
SHORT Right,
SHORT Bottom);
VOID
ScrollDownGenericList(
PGENERIC_LIST List);
VOID
ScrollUpGenericList(
PGENERIC_LIST List);
VOID
ScrollPageDownGenericList(
PGENERIC_LIST List);
VOID
ScrollPageUpGenericList(
PGENERIC_LIST List);
VOID
ScrollToPositionGenericList(
PGENERIC_LIST List,
ULONG uIndex);
VOID
RedrawGenericList(
PGENERIC_LIST List);
IN OUT PGENERIC_LIST List,
IN PCHAR Text,
IN PVOID UserData,
IN BOOLEAN Current);
VOID
SetCurrentListEntry(
PGENERIC_LIST List,
PGENERIC_LIST_ENTRY Entry);
IN PGENERIC_LIST List,
IN PGENERIC_LIST_ENTRY Entry);
PGENERIC_LIST_ENTRY
GetCurrentListEntry(
PGENERIC_LIST List);
IN PGENERIC_LIST List);
PGENERIC_LIST_ENTRY
GetFirstListEntry(
PGENERIC_LIST List);
IN PGENERIC_LIST List);
PGENERIC_LIST_ENTRY
GetNextListEntry(
PGENERIC_LIST_ENTRY Entry);
IN PGENERIC_LIST_ENTRY Entry);
PVOID
GetListEntryUserData(
PGENERIC_LIST_ENTRY Entry);
IN PGENERIC_LIST_ENTRY Entry);
LPCSTR
GetListEntryText(
PGENERIC_LIST_ENTRY Entry);
IN PGENERIC_LIST_ENTRY Entry);
ULONG
GetNumberOfListEntries(
PGENERIC_LIST List);
IN PGENERIC_LIST List);
VOID
SaveGenericListState(
PGENERIC_LIST List);
IN PGENERIC_LIST List);
VOID
RestoreGenericListState(
PGENERIC_LIST List);
IN PGENERIC_LIST List);
BOOLEAN
GenericListHasSingleEntry(
IN PGENERIC_LIST List);
typedef struct _GENERIC_LIST_UI
{
PGENERIC_LIST List;
PLIST_ENTRY FirstShown;
PLIST_ENTRY LastShown;
SHORT Left;
SHORT Top;
SHORT Right;
SHORT Bottom;
BOOL Redraw;
} GENERIC_LIST_UI, *PGENERIC_LIST_UI;
VOID
InitGenericListUi(
IN OUT PGENERIC_LIST_UI ListUi,
IN PGENERIC_LIST List);
VOID
DrawGenericList(
IN PGENERIC_LIST_UI ListUi,
IN SHORT Left,
IN SHORT Top,
IN SHORT Right,
IN SHORT Bottom);
VOID
ScrollDownGenericList(
IN PGENERIC_LIST_UI ListUi);
VOID
ScrollUpGenericList(
IN PGENERIC_LIST_UI ListUi);
VOID
ScrollPageDownGenericList(
IN PGENERIC_LIST_UI ListUi);
VOID
ScrollPageUpGenericList(
IN PGENERIC_LIST_UI ListUi);
VOID
ScrollToPositionGenericList(
IN PGENERIC_LIST_UI ListUi,
IN ULONG uIndex);
VOID
RedrawGenericList(
IN PGENERIC_LIST_UI ListUi);
VOID
GenericListKeyPress(
PGENERIC_LIST GenericList,
CHAR AsciiChar);
BOOL
GenericListHasSingleEntry(
PGENERIC_LIST List);
IN PGENERIC_LIST_UI ListUi,
IN CHAR AsciiChar);
/* EOF */

View File

@ -640,6 +640,7 @@ UpdateKBLayout(VOID)
static PAGE_NUMBER
LanguagePage(PINPUT_RECORD Ir)
{
GENERIC_LIST_UI ListUi;
PWCHAR NewLanguageId;
BOOL RefreshPage = FALSE;
@ -647,7 +648,6 @@ LanguagePage(PINPUT_RECORD Ir)
if (LanguageList == NULL)
{
LanguageList = CreateLanguageList(SetupInf, DefaultLanguage);
if (LanguageList == NULL)
{
PopupError("Setup failed to initialize available translations", NULL, NULL, POPUP_WAIT_NONE);
@ -668,13 +668,14 @@ LanguagePage(PINPUT_RECORD Ir)
return INTRO_PAGE;
}
DrawGenericList(LanguageList,
InitGenericListUi(&ListUi, LanguageList);
DrawGenericList(&ListUi,
2,
18,
xScreen - 3,
yScreen - 3);
ScrollToPositionGenericList(LanguageList, GetDefaultLanguageIndex());
ScrollToPositionGenericList(&ListUi, GetDefaultLanguageIndex());
MUIDisplayPage(LANGUAGE_PAGE);
@ -685,25 +686,25 @@ LanguagePage(PINPUT_RECORD Ir)
if ((Ir->Event.KeyEvent.uChar.AsciiChar == 0x00) &&
(Ir->Event.KeyEvent.wVirtualKeyCode == VK_DOWN)) /* DOWN */
{
ScrollDownGenericList(LanguageList);
ScrollDownGenericList(&ListUi);
RefreshPage = TRUE;
}
else if ((Ir->Event.KeyEvent.uChar.AsciiChar == 0x00) &&
(Ir->Event.KeyEvent.wVirtualKeyCode == VK_UP)) /* UP */
{
ScrollUpGenericList(LanguageList);
ScrollUpGenericList(&ListUi);
RefreshPage = TRUE;
}
if ((Ir->Event.KeyEvent.uChar.AsciiChar == 0x00) &&
(Ir->Event.KeyEvent.wVirtualKeyCode == VK_NEXT)) /* PAGE DOWN */
{
ScrollPageDownGenericList(LanguageList);
ScrollPageDownGenericList(&ListUi);
RefreshPage = TRUE;
}
else if ((Ir->Event.KeyEvent.uChar.AsciiChar == 0x00) &&
(Ir->Event.KeyEvent.wVirtualKeyCode == VK_PRIOR)) /* PAGE UP */
{
ScrollPageUpGenericList(LanguageList);
ScrollPageUpGenericList(&ListUi);
RefreshPage = TRUE;
}
else if ((Ir->Event.KeyEvent.uChar.AsciiChar == 0x00) &&
@ -712,7 +713,7 @@ LanguagePage(PINPUT_RECORD Ir)
if (ConfirmQuit(Ir) != FALSE)
return QUIT_PAGE;
else
RedrawGenericList(LanguageList);
RedrawGenericList(&ListUi);
}
else if (Ir->Event.KeyEvent.uChar.AsciiChar == 0x0D) /* ENTER */
{
@ -733,7 +734,7 @@ LanguagePage(PINPUT_RECORD Ir)
else if ((Ir->Event.KeyEvent.uChar.AsciiChar > 0x60) && (Ir->Event.KeyEvent.uChar.AsciiChar < 0x7b))
{
/* a-z */
GenericListKeyPress(LanguageList, Ir->Event.KeyEvent.uChar.AsciiChar);
GenericListKeyPress(&ListUi, Ir->Event.KeyEvent.uChar.AsciiChar);
RefreshPage = TRUE;
}
@ -915,12 +916,11 @@ SetupStartPage(PINPUT_RECORD Ir)
LanguageList = CreateLanguageList(SetupInf, DefaultLanguage);
/* new part */
wcscpy(SelectedLanguageId,LocaleID);
wcscpy(SelectedLanguageId, LocaleID);
LanguageId = (LANGID)(wcstol(SelectedLanguageId, NULL, 16) & 0xFFFF);
/* first we hack LanguageList */
ListEntry = GetFirstListEntry(LanguageList);
while (ListEntry != NULL)
{
if (!wcsicmp(LocaleID, GetListEntryUserData(ListEntry)))
@ -935,7 +935,6 @@ SetupStartPage(PINPUT_RECORD Ir)
/* now LayoutList */
ListEntry = GetFirstListEntry(LayoutList);
while (ListEntry != NULL)
{
if (!wcsicmp(LocaleID, GetListEntryUserData(ListEntry)))
@ -1319,7 +1318,7 @@ DeviceSettingsPage(PINPUT_RECORD Ir)
* Ir: The PINPUT_RECORD
*/
static PAGE_NUMBER
HandleGenericList(PGENERIC_LIST GenericList,
HandleGenericList(PGENERIC_LIST_UI ListUi,
PAGE_NUMBER nextPage,
PINPUT_RECORD Ir)
{
@ -1330,36 +1329,36 @@ HandleGenericList(PGENERIC_LIST GenericList,
if ((Ir->Event.KeyEvent.uChar.AsciiChar == 0x00) &&
(Ir->Event.KeyEvent.wVirtualKeyCode == VK_DOWN)) /* DOWN */
{
ScrollDownGenericList(GenericList);
ScrollDownGenericList(ListUi);
}
else if ((Ir->Event.KeyEvent.uChar.AsciiChar == 0x00) &&
(Ir->Event.KeyEvent.wVirtualKeyCode == VK_UP)) /* UP */
{
ScrollUpGenericList(GenericList);
ScrollUpGenericList(ListUi);
}
else if ((Ir->Event.KeyEvent.uChar.AsciiChar == 0x00) &&
(Ir->Event.KeyEvent.wVirtualKeyCode == VK_NEXT)) /* PAGE DOWN */
{
ScrollPageDownGenericList(GenericList);
ScrollPageDownGenericList(ListUi);
}
else if ((Ir->Event.KeyEvent.uChar.AsciiChar == 0x00) &&
(Ir->Event.KeyEvent.wVirtualKeyCode == VK_PRIOR)) /* PAGE UP */
{
ScrollPageUpGenericList(GenericList);
ScrollPageUpGenericList(ListUi);
}
else if ((Ir->Event.KeyEvent.uChar.AsciiChar == 0x00) &&
(Ir->Event.KeyEvent.wVirtualKeyCode == VK_F3)) /* F3 */
{
if (ConfirmQuit(Ir) != FALSE)
return QUIT_PAGE;
continue;
else
RedrawGenericList(ListUi);
}
else if ((Ir->Event.KeyEvent.uChar.AsciiChar == 0x00) &&
(Ir->Event.KeyEvent.wVirtualKeyCode == VK_ESCAPE)) /* ESC */
{
RestoreGenericListState(GenericList);
return nextPage;
RestoreGenericListState(ListUi->List);
return nextPage; // Use some "prevPage;" instead?
}
else if (Ir->Event.KeyEvent.uChar.AsciiChar == 0x0D) /* ENTER */
{
@ -1368,7 +1367,7 @@ HandleGenericList(PGENERIC_LIST GenericList,
else if ((Ir->Event.KeyEvent.uChar.AsciiChar > 0x60) && (Ir->Event.KeyEvent.uChar.AsciiChar < 0x7b))
{
/* a-z */
GenericListKeyPress(GenericList, Ir->Event.KeyEvent.uChar.AsciiChar);
GenericListKeyPress(ListUi, Ir->Event.KeyEvent.uChar.AsciiChar);
}
}
}
@ -1387,9 +1386,11 @@ HandleGenericList(PGENERIC_LIST GenericList,
static PAGE_NUMBER
ComputerSettingsPage(PINPUT_RECORD Ir)
{
GENERIC_LIST_UI ListUi;
MUIDisplayPage(COMPUTER_SETTINGS_PAGE);
DrawGenericList(ComputerList,
InitGenericListUi(&ListUi, ComputerList);
DrawGenericList(&ListUi,
2,
18,
xScreen - 3,
@ -1397,7 +1398,7 @@ ComputerSettingsPage(PINPUT_RECORD Ir)
SaveGenericListState(ComputerList);
return HandleGenericList(ComputerList, DEVICE_SETTINGS_PAGE, Ir);
return HandleGenericList(&ListUi, DEVICE_SETTINGS_PAGE, Ir);
}
@ -1414,9 +1415,11 @@ ComputerSettingsPage(PINPUT_RECORD Ir)
static PAGE_NUMBER
DisplaySettingsPage(PINPUT_RECORD Ir)
{
GENERIC_LIST_UI ListUi;
MUIDisplayPage(DISPLAY_SETTINGS_PAGE);
DrawGenericList(DisplayList,
InitGenericListUi(&ListUi, DisplayList);
DrawGenericList(&ListUi,
2,
18,
xScreen - 3,
@ -1424,7 +1427,7 @@ DisplaySettingsPage(PINPUT_RECORD Ir)
SaveGenericListState(DisplayList);
return HandleGenericList(DisplayList, DEVICE_SETTINGS_PAGE, Ir);
return HandleGenericList(&ListUi, DEVICE_SETTINGS_PAGE, Ir);
}
@ -1441,9 +1444,11 @@ DisplaySettingsPage(PINPUT_RECORD Ir)
static PAGE_NUMBER
KeyboardSettingsPage(PINPUT_RECORD Ir)
{
GENERIC_LIST_UI ListUi;
MUIDisplayPage(KEYBOARD_SETTINGS_PAGE);
DrawGenericList(KeyboardList,
InitGenericListUi(&ListUi, KeyboardList);
DrawGenericList(&ListUi,
2,
18,
xScreen - 3,
@ -1451,7 +1456,7 @@ KeyboardSettingsPage(PINPUT_RECORD Ir)
SaveGenericListState(KeyboardList);
return HandleGenericList(KeyboardList, DEVICE_SETTINGS_PAGE, Ir);
return HandleGenericList(&ListUi, DEVICE_SETTINGS_PAGE, Ir);
}
@ -1468,9 +1473,11 @@ KeyboardSettingsPage(PINPUT_RECORD Ir)
static PAGE_NUMBER
LayoutSettingsPage(PINPUT_RECORD Ir)
{
GENERIC_LIST_UI ListUi;
MUIDisplayPage(LAYOUT_SETTINGS_PAGE);
DrawGenericList(LayoutList,
InitGenericListUi(&ListUi, LayoutList);
DrawGenericList(&ListUi,
2,
18,
xScreen - 3,
@ -1478,7 +1485,7 @@ LayoutSettingsPage(PINPUT_RECORD Ir)
SaveGenericListState(LayoutList);
return HandleGenericList(LayoutList, DEVICE_SETTINGS_PAGE, Ir);
return HandleGenericList(&ListUi, DEVICE_SETTINGS_PAGE, Ir);
}
@ -2945,7 +2952,7 @@ SelectFileSystemPage(PINPUT_RECORD Ir)
* RETURNS
* Number of the next page.
*/
static ULONG
static PAGE_NUMBER
FormatPartitionPage(PINPUT_RECORD Ir)
{
UNICODE_STRING PartitionRootPath;
@ -3135,7 +3142,7 @@ FormatPartitionPage(PINPUT_RECORD Ir)
* RETURNS
* Number of the next page.
*/
static ULONG
static PAGE_NUMBER
CheckFileSystemPage(PINPUT_RECORD Ir)
{
PFILE_SYSTEM_ITEM CurrentFileSystem;
@ -3996,8 +4003,7 @@ FileCopyCallback(PVOID Context,
* RETURNS
* Number of the next page.
*/
static
PAGE_NUMBER
static PAGE_NUMBER
FileCopyPage(PINPUT_RECORD Ir)
{
COPYCONTEXT CopyContext;
@ -4194,7 +4200,6 @@ RegistryPage(PINPUT_RECORD Ir)
}
/* Set GeoID */
if (!SetGeoID(MUIGetGeoID()))
{
MUIDisplayError(ERROR_UPDATE_GEOID, Ir, POPUP_WAIT_ENTER);
@ -4428,7 +4433,7 @@ BootLoaderFloppyPage(PINPUT_RECORD Ir)
MUIDisplayPage(BOOT_LOADER_FLOPPY_PAGE);
// SetStatusText(" Please wait...");
// CONSOLE_SetStatusText(MUIGetString(STRING_PLEASEWAIT));
while (TRUE)
{
@ -4592,48 +4597,49 @@ QuitPage(PINPUT_RECORD Ir)
{
MUIDisplayPage(QUIT_PAGE);
/* Destroy partition list */
/* Destroy the partition list */
if (PartitionList != NULL)
{
DestroyPartitionList(PartitionList);
PartitionList = NULL;
}
/* Destroy filesystem list */
/* Destroy the filesystem list */
if (FileSystemList != NULL)
{
DestroyFileSystemList(FileSystemList);
FileSystemList = NULL;
}
/* Destroy computer settings list */
/* Destroy the computer settings list */
if (ComputerList != NULL)
{
DestroyGenericList(ComputerList, TRUE);
ComputerList = NULL;
}
/* Destroy display settings list */
/* Destroy the display settings list */
if (DisplayList != NULL)
{
DestroyGenericList(DisplayList, TRUE);
DisplayList = NULL;
}
/* Destroy keyboard settings list */
/* Destroy the keyboard settings list */
if (KeyboardList != NULL)
{
DestroyGenericList(KeyboardList, TRUE);
KeyboardList = NULL;
}
/* Destroy keyboard layout list */
/* Destroy the keyboard layout list */
if (LayoutList != NULL)
{
DestroyGenericList(LayoutList, TRUE);
LayoutList = NULL;
}
/* Destroy the languages list */
if (LanguageList != NULL)
{
DestroyGenericList(LanguageList, FALSE);
@ -4723,6 +4729,7 @@ RunUSetup(VOID)
NtQuerySystemTime(&Time);
/* Create the PnP thread in suspended state */
Status = RtlCreateUserThread(NtCurrentProcess(),
NULL,
TRUE,
@ -4800,9 +4807,7 @@ RunUSetup(VOID)
case SCSI_CONTROLLER_PAGE:
Page = ScsiControllerPage(&Ir);
break;
#endif
#if 0
case OEM_DRIVER_PAGE:
Page = OemDriverPage(&Ir);
break;
@ -4857,11 +4862,11 @@ RunUSetup(VOID)
break;
case FORMAT_PARTITION_PAGE:
Page = (PAGE_NUMBER) FormatPartitionPage(&Ir);
Page = FormatPartitionPage(&Ir);
break;
case CHECK_FILE_SYSTEM_PAGE:
Page = (PAGE_NUMBER) CheckFileSystemPage(&Ir);
Page = CheckFileSystemPage(&Ir);
break;
case INSTALL_DIRECTORY_PAGE: