[USETUP] Similarly to what was done for GenLists, factor out the UI code from the partition list code.

This will allow to reuse it for the 1st-stage GUI setup too, while using another UI representation.
Add also two partition iterator functions: GetNextPartition and GetPrevPartition.

svn path=/branches/setup_improvements/; revision=74554
This commit is contained in:
Hermès Bélusca-Maïto 2017-05-15 19:41:18 +00:00
parent 92692eae3d
commit 216f15c675
No known key found for this signature in database
GPG key ID: 3B2539C65E7B93D0
3 changed files with 208 additions and 170 deletions

View file

@ -1419,11 +1419,7 @@ AddDiskToList(
PPARTLIST PPARTLIST
CreatePartitionList( CreatePartitionList(VOID)
SHORT Left,
SHORT Top,
SHORT Right,
SHORT Bottom)
{ {
PPARTLIST List; PPARTLIST List;
OBJECT_ATTRIBUTES ObjectAttributes; OBJECT_ATTRIBUTES ObjectAttributes;
@ -1442,14 +1438,6 @@ CreatePartitionList(
if (List == NULL) if (List == NULL)
return NULL; return NULL;
List->Left = Left;
List->Top = Top;
List->Right = Right;
List->Bottom = Bottom;
List->Line = 0;
List->Offset = 0;
List->CurrentDisk = NULL; List->CurrentDisk = NULL;
List->CurrentPartition = NULL; List->CurrentPartition = NULL;
@ -1466,10 +1454,11 @@ CreatePartitionList(
Status = NtQuerySystemInformation(SystemDeviceInformation, Status = NtQuerySystemInformation(SystemDeviceInformation,
&Sdi, &Sdi,
sizeof(SYSTEM_DEVICE_INFORMATION), sizeof(Sdi),
&ReturnSize); &ReturnSize);
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
{ {
DPRINT1("NtQuerySystemInformation() failed, Status 0x%08lx", Status);
RtlFreeHeap(ProcessHeap, 0, List); RtlFreeHeap(ProcessHeap, 0, List);
return NULL; return NULL;
} }
@ -1593,23 +1582,47 @@ DestroyPartitionList(
} }
VOID
InitPartitionListUi(
IN OUT PPARTLIST_UI ListUi,
IN PPARTLIST List,
IN SHORT Left,
IN SHORT Top,
IN SHORT Right,
IN SHORT Bottom)
{
ListUi->List = List;
// ListUi->FirstShown = NULL;
// ListUi->LastShown = NULL;
ListUi->Left = Left;
ListUi->Top = Top;
ListUi->Right = Right;
ListUi->Bottom = Bottom;
ListUi->Line = 0;
ListUi->Offset = 0;
// ListUi->Redraw = TRUE;
}
static static
VOID VOID
PrintEmptyLine( PrintEmptyLine(
IN PPARTLIST List) IN PPARTLIST_UI ListUi)
{ {
COORD coPos; COORD coPos;
ULONG Written; ULONG Written;
USHORT Width; USHORT Width;
USHORT Height; USHORT Height;
Width = List->Right - List->Left - 1; Width = ListUi->Right - ListUi->Left - 1;
Height = List->Bottom - List->Top - 2; Height = ListUi->Bottom - ListUi->Top - 2;
coPos.X = List->Left + 1; coPos.X = ListUi->Left + 1;
coPos.Y = List->Top + 1 + List->Line; coPos.Y = ListUi->Top + 1 + ListUi->Line;
if (List->Line >= 0 && List->Line <= Height) if (ListUi->Line >= 0 && ListUi->Line <= Height)
{ {
FillConsoleOutputAttribute(StdOutput, FillConsoleOutputAttribute(StdOutput,
FOREGROUND_WHITE | BACKGROUND_BLUE, FOREGROUND_WHITE | BACKGROUND_BLUE,
@ -1624,17 +1637,18 @@ PrintEmptyLine(
&Written); &Written);
} }
List->Line++; ListUi->Line++;
} }
static static
VOID VOID
PrintPartitionData( PrintPartitionData(
IN PPARTLIST List, IN PPARTLIST_UI ListUi,
IN PDISKENTRY DiskEntry, IN PDISKENTRY DiskEntry,
IN PPARTENTRY PartEntry) IN PPARTENTRY PartEntry)
{ {
PPARTLIST List = ListUi->List;
CHAR LineBuffer[128]; CHAR LineBuffer[128];
COORD coPos; COORD coPos;
ULONG Written; ULONG Written;
@ -1644,14 +1658,13 @@ PrintPartitionData(
PCHAR Unit; PCHAR Unit;
UCHAR Attribute; UCHAR Attribute;
CHAR PartTypeString[32]; CHAR PartTypeString[32];
PCHAR PartType; PCHAR PartType = PartTypeString;
PartType = PartTypeString;
Width = List->Right - List->Left - 1; Width = ListUi->Right - ListUi->Left - 1;
Height = List->Bottom - List->Top - 2; Height = ListUi->Bottom - ListUi->Top - 2;
coPos.X = List->Left + 1; coPos.X = ListUi->Left + 1;
coPos.Y = List->Top + 1 + List->Line; coPos.Y = ListUi->Top + 1 + ListUi->Line;
if (PartEntry->IsPartitioned == FALSE) if (PartEntry->IsPartitioned == FALSE)
{ {
@ -1751,7 +1764,7 @@ PrintPartitionData(
FOREGROUND_BLUE | BACKGROUND_WHITE : FOREGROUND_BLUE | BACKGROUND_WHITE :
FOREGROUND_WHITE | BACKGROUND_BLUE; FOREGROUND_WHITE | BACKGROUND_BLUE;
if (List->Line >= 0 && List->Line <= Height) if (ListUi->Line >= 0 && ListUi->Line <= Height)
{ {
FillConsoleOutputCharacterA(StdOutput, FillConsoleOutputCharacterA(StdOutput,
' ', ' ',
@ -1761,7 +1774,7 @@ PrintPartitionData(
} }
coPos.X += 4; coPos.X += 4;
Width -= 8; Width -= 8;
if (List->Line >= 0 && List->Line <= Height) if (ListUi->Line >= 0 && ListUi->Line <= Height)
{ {
FillConsoleOutputAttribute(StdOutput, FillConsoleOutputAttribute(StdOutput,
Attribute, Attribute,
@ -1771,7 +1784,7 @@ PrintPartitionData(
} }
coPos.X++; coPos.X++;
Width -= 2; Width -= 2;
if (List->Line >= 0 && List->Line <= Height) if (ListUi->Line >= 0 && ListUi->Line <= Height)
{ {
WriteConsoleOutputCharacterA(StdOutput, WriteConsoleOutputCharacterA(StdOutput,
LineBuffer, LineBuffer,
@ -1780,16 +1793,17 @@ PrintPartitionData(
&Written); &Written);
} }
List->Line++; ListUi->Line++;
} }
static static
VOID VOID
PrintDiskData( PrintDiskData(
IN PPARTLIST List, IN PPARTLIST_UI ListUi,
IN PDISKENTRY DiskEntry) IN PDISKENTRY DiskEntry)
{ {
// PPARTLIST List = ListUi->List;
PPARTENTRY PrimaryPartEntry, LogicalPartEntry; PPARTENTRY PrimaryPartEntry, LogicalPartEntry;
PLIST_ENTRY PrimaryEntry, LogicalEntry; PLIST_ENTRY PrimaryEntry, LogicalEntry;
CHAR LineBuffer[128]; CHAR LineBuffer[128];
@ -1800,11 +1814,11 @@ PrintDiskData(
ULARGE_INTEGER DiskSize; ULARGE_INTEGER DiskSize;
PCHAR Unit; PCHAR Unit;
Width = List->Right - List->Left - 1; Width = ListUi->Right - ListUi->Left - 1;
Height = List->Bottom - List->Top - 2; Height = ListUi->Bottom - ListUi->Top - 2;
coPos.X = List->Left + 1; coPos.X = ListUi->Left + 1;
coPos.Y = List->Top + 1 + List->Line; coPos.Y = ListUi->Top + 1 + ListUi->Line;
DiskSize.QuadPart = DiskEntry->SectorCount.QuadPart * DiskEntry->BytesPerSector; DiskSize.QuadPart = DiskEntry->SectorCount.QuadPart * DiskEntry->BytesPerSector;
if (DiskSize.QuadPart >= 10737418240) /* 10 GB */ if (DiskSize.QuadPart >= 10737418240) /* 10 GB */
@ -1844,7 +1858,7 @@ PrintDiskData(
DiskEntry->Id); DiskEntry->Id);
} }
if (List->Line >= 0 && List->Line <= Height) if (ListUi->Line >= 0 && ListUi->Line <= Height)
{ {
FillConsoleOutputAttribute(StdOutput, FillConsoleOutputAttribute(StdOutput,
FOREGROUND_WHITE | BACKGROUND_BLUE, FOREGROUND_WHITE | BACKGROUND_BLUE,
@ -1860,7 +1874,7 @@ PrintDiskData(
} }
coPos.X++; coPos.X++;
if (List->Line >= 0 && List->Line <= Height) if (ListUi->Line >= 0 && ListUi->Line <= Height)
{ {
WriteConsoleOutputCharacterA(StdOutput, WriteConsoleOutputCharacterA(StdOutput,
LineBuffer, LineBuffer,
@ -1869,10 +1883,10 @@ PrintDiskData(
&Written); &Written);
} }
List->Line++; ListUi->Line++;
/* Print separator line */ /* Print separator line */
PrintEmptyLine(List); PrintEmptyLine(ListUi);
/* Print partition lines */ /* Print partition lines */
PrimaryEntry = DiskEntry->PrimaryPartListHead.Flink; PrimaryEntry = DiskEntry->PrimaryPartListHead.Flink;
@ -1880,7 +1894,7 @@ PrintDiskData(
{ {
PrimaryPartEntry = CONTAINING_RECORD(PrimaryEntry, PARTENTRY, ListEntry); PrimaryPartEntry = CONTAINING_RECORD(PrimaryEntry, PARTENTRY, ListEntry);
PrintPartitionData(List, PrintPartitionData(ListUi,
DiskEntry, DiskEntry,
PrimaryPartEntry); PrimaryPartEntry);
@ -1891,7 +1905,7 @@ PrintDiskData(
{ {
LogicalPartEntry = CONTAINING_RECORD(LogicalEntry, PARTENTRY, ListEntry); LogicalPartEntry = CONTAINING_RECORD(LogicalEntry, PARTENTRY, ListEntry);
PrintPartitionData(List, PrintPartitionData(ListUi,
DiskEntry, DiskEntry,
LogicalPartEntry); LogicalPartEntry);
@ -1903,14 +1917,15 @@ PrintDiskData(
} }
/* Print separator line */ /* Print separator line */
PrintEmptyLine(List); PrintEmptyLine(ListUi);
} }
VOID VOID
DrawPartitionList( DrawPartitionList(
IN PPARTLIST List) IN PPARTLIST_UI ListUi)
{ {
PPARTLIST List = ListUi->List;
PLIST_ENTRY Entry, Entry2; PLIST_ENTRY Entry, Entry2;
PDISKENTRY DiskEntry; PDISKENTRY DiskEntry;
PPARTENTRY PartEntry = NULL; PPARTENTRY PartEntry = NULL;
@ -2001,37 +2016,37 @@ DrawPartitionList(
} }
/* If it possible, make the disk name visible */ /* If it possible, make the disk name visible */
if (CurrentPartLine < List->Offset) if (CurrentPartLine < ListUi->Offset)
{ {
List->Offset = CurrentPartLine; ListUi->Offset = CurrentPartLine;
} }
else if (CurrentPartLine - List->Offset > List->Bottom - List->Top - 2) else if (CurrentPartLine - ListUi->Offset > ListUi->Bottom - ListUi->Top - 2)
{ {
List->Offset = CurrentPartLine - (List->Bottom - List->Top - 2); ListUi->Offset = CurrentPartLine - (ListUi->Bottom - ListUi->Top - 2);
} }
if (CurrentDiskLine < List->Offset && CurrentPartLine - CurrentDiskLine < List->Bottom - List->Top - 2) if (CurrentDiskLine < ListUi->Offset && CurrentPartLine - CurrentDiskLine < ListUi->Bottom - ListUi->Top - 2)
{ {
List->Offset = CurrentDiskLine; ListUi->Offset = CurrentDiskLine;
} }
/* draw upper left corner */ /* Draw upper left corner */
coPos.X = List->Left; coPos.X = ListUi->Left;
coPos.Y = List->Top; coPos.Y = ListUi->Top;
FillConsoleOutputCharacterA(StdOutput, FillConsoleOutputCharacterA(StdOutput,
0xDA, // '+', 0xDA, // '+',
1, 1,
coPos, coPos,
&Written); &Written);
/* draw upper edge */ /* Draw upper edge */
coPos.X = List->Left + 1; coPos.X = ListUi->Left + 1;
coPos.Y = List->Top; coPos.Y = ListUi->Top;
if (List->Offset == 0) if (ListUi->Offset == 0)
{ {
FillConsoleOutputCharacterA(StdOutput, FillConsoleOutputCharacterA(StdOutput,
0xC4, // '-', 0xC4, // '-',
List->Right - List->Left - 1, ListUi->Right - ListUi->Left - 1,
coPos, coPos,
&Written); &Written);
} }
@ -2039,16 +2054,16 @@ DrawPartitionList(
{ {
FillConsoleOutputCharacterA(StdOutput, FillConsoleOutputCharacterA(StdOutput,
0xC4, // '-', 0xC4, // '-',
List->Right - List->Left - 5, ListUi->Right - ListUi->Left - 5,
coPos, coPos,
&Written); &Written);
coPos.X = List->Right - 5; coPos.X = ListUi->Right - 5;
WriteConsoleOutputCharacterA(StdOutput, WriteConsoleOutputCharacterA(StdOutput,
"(\x18)", // "(up)" "(\x18)", // "(up)"
3, 3,
coPos, coPos,
&Written); &Written);
coPos.X = List->Right - 2; coPos.X = ListUi->Right - 2;
FillConsoleOutputCharacterA(StdOutput, FillConsoleOutputCharacterA(StdOutput,
0xC4, // '-', 0xC4, // '-',
2, 2,
@ -2056,19 +2071,19 @@ DrawPartitionList(
&Written); &Written);
} }
/* draw upper right corner */ /* Draw upper right corner */
coPos.X = List->Right; coPos.X = ListUi->Right;
coPos.Y = List->Top; coPos.Y = ListUi->Top;
FillConsoleOutputCharacterA(StdOutput, FillConsoleOutputCharacterA(StdOutput,
0xBF, // '+', 0xBF, // '+',
1, 1,
coPos, coPos,
&Written); &Written);
/* draw left and right edge */ /* Draw left and right edge */
for (i = List->Top + 1; i < List->Bottom; i++) for (i = ListUi->Top + 1; i < ListUi->Bottom; i++)
{ {
coPos.X = List->Left; coPos.X = ListUi->Left;
coPos.Y = i; coPos.Y = i;
FillConsoleOutputCharacterA(StdOutput, FillConsoleOutputCharacterA(StdOutput,
0xB3, // '|', 0xB3, // '|',
@ -2076,7 +2091,7 @@ DrawPartitionList(
coPos, coPos,
&Written); &Written);
coPos.X = List->Right; coPos.X = ListUi->Right;
FillConsoleOutputCharacterA(StdOutput, FillConsoleOutputCharacterA(StdOutput,
0xB3, //'|', 0xB3, //'|',
1, 1,
@ -2084,23 +2099,23 @@ DrawPartitionList(
&Written); &Written);
} }
/* draw lower left corner */ /* Draw lower left corner */
coPos.X = List->Left; coPos.X = ListUi->Left;
coPos.Y = List->Bottom; coPos.Y = ListUi->Bottom;
FillConsoleOutputCharacterA(StdOutput, FillConsoleOutputCharacterA(StdOutput,
0xC0, // '+', 0xC0, // '+',
1, 1,
coPos, coPos,
&Written); &Written);
/* draw lower edge */ /* Draw lower edge */
coPos.X = List->Left + 1; coPos.X = ListUi->Left + 1;
coPos.Y = List->Bottom; coPos.Y = ListUi->Bottom;
if (LastLine - List->Offset <= List->Bottom - List->Top - 2) if (LastLine - ListUi->Offset <= ListUi->Bottom - ListUi->Top - 2)
{ {
FillConsoleOutputCharacterA(StdOutput, FillConsoleOutputCharacterA(StdOutput,
0xC4, // '-', 0xC4, // '-',
List->Right - List->Left - 1, ListUi->Right - ListUi->Left - 1,
coPos, coPos,
&Written); &Written);
} }
@ -2108,16 +2123,16 @@ DrawPartitionList(
{ {
FillConsoleOutputCharacterA(StdOutput, FillConsoleOutputCharacterA(StdOutput,
0xC4, // '-', 0xC4, // '-',
List->Right - List->Left - 5, ListUi->Right - ListUi->Left - 5,
coPos, coPos,
&Written); &Written);
coPos.X = List->Right - 5; coPos.X = ListUi->Right - 5;
WriteConsoleOutputCharacterA(StdOutput, WriteConsoleOutputCharacterA(StdOutput,
"(\x19)", // "(down)" "(\x19)", // "(down)"
3, 3,
coPos, coPos,
&Written); &Written);
coPos.X = List->Right - 2; coPos.X = ListUi->Right - 2;
FillConsoleOutputCharacterA(StdOutput, FillConsoleOutputCharacterA(StdOutput,
0xC4, // '-', 0xC4, // '-',
2, 2,
@ -2125,9 +2140,9 @@ DrawPartitionList(
&Written); &Written);
} }
/* draw lower right corner */ /* Draw lower right corner */
coPos.X = List->Right; coPos.X = ListUi->Right;
coPos.Y = List->Bottom; coPos.Y = ListUi->Bottom;
FillConsoleOutputCharacterA(StdOutput, FillConsoleOutputCharacterA(StdOutput,
0xD9, // '+', 0xD9, // '+',
1, 1,
@ -2135,7 +2150,7 @@ DrawPartitionList(
&Written); &Written);
/* print list entries */ /* print list entries */
List->Line = - List->Offset; ListUi->Line = - ListUi->Offset;
Entry = List->DiskListHead.Flink; Entry = List->DiskListHead.Flink;
while (Entry != &List->DiskListHead) while (Entry != &List->DiskListHead)
@ -2143,8 +2158,7 @@ DrawPartitionList(
DiskEntry = CONTAINING_RECORD(Entry, DISKENTRY, ListEntry); DiskEntry = CONTAINING_RECORD(Entry, DISKENTRY, ListEntry);
/* Print disk entry */ /* Print disk entry */
PrintDiskData(List, PrintDiskData(ListUi, DiskEntry);
DiskEntry);
Entry = Entry->Flink; Entry = Entry->Flink;
} }
@ -2159,8 +2173,7 @@ SelectPartition(
{ {
PDISKENTRY DiskEntry; PDISKENTRY DiskEntry;
PPARTENTRY PartEntry; PPARTENTRY PartEntry;
PLIST_ENTRY Entry1; PLIST_ENTRY Entry1, Entry2;
PLIST_ENTRY Entry2;
/* Check for empty disks */ /* Check for empty disks */
if (IsListEmpty(&List->DiskListHead)) if (IsListEmpty(&List->DiskListHead))
@ -2181,10 +2194,9 @@ SelectPartition(
if (PartEntry->PartitionNumber == PartitionNumber) if (PartEntry->PartitionNumber == PartitionNumber)
{ {
List->CurrentDisk = DiskEntry; List->CurrentDisk = DiskEntry;
List->CurrentPartition = PartEntry; List->CurrentPartition = PartEntry;
DrawPartitionList(List); return TRUE;
return TRUE;
} }
Entry2 = Entry2->Flink; Entry2 = Entry2->Flink;
@ -2200,8 +2212,8 @@ SelectPartition(
} }
BOOL PPARTENTRY
ScrollDownPartitionList( GetNextPartition(
IN PPARTLIST List) IN PPARTLIST List)
{ {
PLIST_ENTRY DiskListEntry; PLIST_ENTRY DiskListEntry;
@ -2211,7 +2223,7 @@ ScrollDownPartitionList(
/* Fail, if no disks are available */ /* Fail, if no disks are available */
if (IsListEmpty(&List->DiskListHead)) if (IsListEmpty(&List->DiskListHead))
return FALSE; return NULL;
/* Check for next usable entry on current disk */ /* Check for next usable entry on current disk */
if (List->CurrentPartition != NULL) if (List->CurrentPartition != NULL)
@ -2227,7 +2239,7 @@ ScrollDownPartitionList(
PartEntry = CONTAINING_RECORD(PartListEntry, PARTENTRY, ListEntry); PartEntry = CONTAINING_RECORD(PartListEntry, PARTENTRY, ListEntry);
List->CurrentPartition = PartEntry; List->CurrentPartition = PartEntry;
return TRUE; return List->CurrentPartition;
} }
else else
{ {
@ -2237,7 +2249,7 @@ ScrollDownPartitionList(
PartEntry = CONTAINING_RECORD(PartListEntry, PARTENTRY, ListEntry); PartEntry = CONTAINING_RECORD(PartListEntry, PARTENTRY, ListEntry);
List->CurrentPartition = PartEntry; List->CurrentPartition = PartEntry;
return TRUE; return List->CurrentPartition;
} }
} }
} }
@ -2255,7 +2267,7 @@ ScrollDownPartitionList(
PartEntry = CONTAINING_RECORD(PartListEntry, PARTENTRY, ListEntry); PartEntry = CONTAINING_RECORD(PartListEntry, PARTENTRY, ListEntry);
List->CurrentPartition = PartEntry; List->CurrentPartition = PartEntry;
return TRUE; return List->CurrentPartition;
} }
} }
else else
@ -2267,7 +2279,7 @@ ScrollDownPartitionList(
PartEntry = CONTAINING_RECORD(PartListEntry, PARTENTRY, ListEntry); PartEntry = CONTAINING_RECORD(PartListEntry, PARTENTRY, ListEntry);
List->CurrentPartition = PartEntry; List->CurrentPartition = PartEntry;
return TRUE; return List->CurrentPartition;
} }
} }
} }
@ -2286,18 +2298,17 @@ ScrollDownPartitionList(
List->CurrentDisk = DiskEntry; List->CurrentDisk = DiskEntry;
List->CurrentPartition = PartEntry; List->CurrentPartition = PartEntry;
return TRUE; return List->CurrentPartition;
} }
DiskListEntry = DiskListEntry->Flink; DiskListEntry = DiskListEntry->Flink;
} }
return FALSE; return NULL;
} }
PPARTENTRY
BOOL GetPrevPartition(
ScrollUpPartitionList(
IN PPARTLIST List) IN PPARTLIST List)
{ {
PLIST_ENTRY DiskListEntry; PLIST_ENTRY DiskListEntry;
@ -2307,7 +2318,7 @@ ScrollUpPartitionList(
/* Fail, if no disks are available */ /* Fail, if no disks are available */
if (IsListEmpty(&List->DiskListHead)) if (IsListEmpty(&List->DiskListHead))
return FALSE; return NULL;
/* Check for previous usable entry on current disk */ /* Check for previous usable entry on current disk */
if (List->CurrentPartition != NULL) if (List->CurrentPartition != NULL)
@ -2323,12 +2334,12 @@ ScrollUpPartitionList(
} }
else else
{ {
/* Extended partition*/ /* Extended partition */
PartEntry = List->CurrentDisk->ExtendedPartition; PartEntry = List->CurrentDisk->ExtendedPartition;
} }
List->CurrentPartition = PartEntry; List->CurrentPartition = PartEntry;
return TRUE; return List->CurrentPartition;
} }
else else
{ {
@ -2347,9 +2358,8 @@ ScrollUpPartitionList(
} }
List->CurrentPartition = PartEntry; List->CurrentPartition = PartEntry;
return TRUE; return List->CurrentPartition;
} }
} }
} }
@ -2374,21 +2384,39 @@ ScrollUpPartitionList(
List->CurrentDisk = DiskEntry; List->CurrentDisk = DiskEntry;
List->CurrentPartition = PartEntry; List->CurrentPartition = PartEntry;
return TRUE; return List->CurrentPartition;
} }
} }
else else
{ {
List->CurrentDisk = DiskEntry; List->CurrentDisk = DiskEntry;
List->CurrentPartition = PartEntry; List->CurrentPartition = PartEntry;
return TRUE; return List->CurrentPartition;
} }
} }
DiskListEntry = DiskListEntry->Blink; DiskListEntry = DiskListEntry->Blink;
} }
return FALSE; return NULL;
}
VOID
ScrollDownPartitionList(
IN PPARTLIST_UI ListUi)
{
if (GetNextPartition(ListUi->List))
DrawPartitionList(ListUi);
}
VOID
ScrollUpPartitionList(
IN PPARTLIST_UI ListUi)
{
if (GetPrevPartition(ListUi->List))
DrawPartitionList(ListUi);
} }

View file

@ -150,16 +150,9 @@ typedef struct _DISKENTRY
typedef struct _PARTLIST typedef struct _PARTLIST
{ {
/* UI stuff */
SHORT Left;
SHORT Top;
SHORT Right;
SHORT Bottom;
SHORT Line;
SHORT Offset;
/* /*
* Disk & Partition iterators.
*
* NOTE that when CurrentPartition != NULL, then CurrentPartition->DiskEntry * NOTE that when CurrentPartition != NULL, then CurrentPartition->DiskEntry
* must be the same as CurrentDisk. We should however keep the two members * must be the same as CurrentDisk. We should however keep the two members
* separated as we can have a current (selected) disk without any current * separated as we can have a current (selected) disk without any current
@ -237,32 +230,24 @@ GetPartTypeStringFromPartitionType(
IN ULONG cchPartType); IN ULONG cchPartType);
PPARTLIST PPARTLIST
CreatePartitionList( CreatePartitionList(VOID);
SHORT Left,
SHORT Top,
SHORT Right,
SHORT Bottom);
VOID VOID
DestroyPartitionList( DestroyPartitionList(
IN PPARTLIST List); IN PPARTLIST List);
VOID
DrawPartitionList(
IN PPARTLIST List);
ULONG ULONG
SelectPartition( SelectPartition(
IN PPARTLIST List, IN PPARTLIST List,
IN ULONG DiskNumber, IN ULONG DiskNumber,
IN ULONG PartitionNumber); IN ULONG PartitionNumber);
BOOL PPARTENTRY
ScrollDownPartitionList( GetNextPartition(
IN PPARTLIST List); IN PPARTLIST List);
BOOL PPARTENTRY
ScrollUpPartitionList( GetPrevPartition(
IN PPARTLIST List); IN PPARTLIST List);
VOID VOID
@ -328,4 +313,47 @@ GetNextUncheckedPartition(
OUT PDISKENTRY *pDiskEntry OPTIONAL, OUT PDISKENTRY *pDiskEntry OPTIONAL,
OUT PPARTENTRY *pPartEntry); OUT PPARTENTRY *pPartEntry);
typedef struct _PARTLIST_UI
{
PPARTLIST List;
// PLIST_ENTRY FirstShown;
// PLIST_ENTRY LastShown;
SHORT Left;
SHORT Top;
SHORT Right;
SHORT Bottom;
SHORT Line;
SHORT Offset;
// BOOL Redraw;
} PARTLIST_UI, *PPARTLIST_UI;
VOID
InitPartitionListUi(
IN OUT PPARTLIST_UI ListUi,
IN PPARTLIST List,
IN SHORT Left,
IN SHORT Top,
IN SHORT Right,
IN SHORT Bottom);
VOID
ScrollDownPartitionList(
IN PPARTLIST_UI ListUi);
VOID
ScrollUpPartitionList(
IN PPARTLIST_UI ListUi);
VOID
DrawPartitionList(
IN PPARTLIST_UI ListUi);
/* EOF */ /* EOF */

View file

@ -790,39 +790,16 @@ LanguagePage(PINPUT_RECORD Ir)
static PAGE_NUMBER static PAGE_NUMBER
SetupStartPage(PINPUT_RECORD Ir) SetupStartPage(PINPUT_RECORD Ir)
{ {
//SYSTEM_DEVICE_INFORMATION Sdi;
NTSTATUS Status; NTSTATUS Status;
WCHAR FileNameBuffer[MAX_PATH]; WCHAR FileNameBuffer[MAX_PATH];
INFCONTEXT Context; INFCONTEXT Context;
PWCHAR Value; PWCHAR Value;
UINT ErrorLine; UINT ErrorLine;
//ULONG ReturnSize;
PGENERIC_LIST_ENTRY ListEntry; PGENERIC_LIST_ENTRY ListEntry;
INT IntValue; INT IntValue;
CONSOLE_SetStatusText(MUIGetString(STRING_PLEASEWAIT)); CONSOLE_SetStatusText(MUIGetString(STRING_PLEASEWAIT));
#if 0
/* Check whether a harddisk is available */
Status = NtQuerySystemInformation(SystemDeviceInformation,
&Sdi,
sizeof(SYSTEM_DEVICE_INFORMATION),
&ReturnSize);
if (!NT_SUCCESS(Status))
{
CONSOLE_PrintTextXY(6, 15, "NtQuerySystemInformation() failed (Status 0x%08lx)", Status);
MUIDisplayError(ERROR_DRIVE_INFORMATION, Ir, POPUP_WAIT_ENTER);
return QUIT_PAGE;
}
if (Sdi.NumberOfDisks == 0)
{
MUIDisplayError(ERROR_NO_HDD, Ir, POPUP_WAIT_ENTER);
return QUIT_PAGE;
}
#endif
/* Get the source path and source root path */ /* Get the source path and source root path */
Status = GetSourcePaths(&SourcePath, Status = GetSourcePaths(&SourcePath,
&SourceRootPath, &SourceRootPath,
@ -896,7 +873,7 @@ SetupStartPage(PINPUT_RECORD Ir)
RequiredPartitionDiskSpace = (ULONG)IntValue; RequiredPartitionDiskSpace = (ULONG)IntValue;
/* Start PnP thread */ /* Start the PnP thread */
if (hPnpThread != INVALID_HANDLE_VALUE) if (hPnpThread != INVALID_HANDLE_VALUE)
{ {
NtResumeThread(hPnpThread, NULL); NtResumeThread(hPnpThread, NULL);
@ -907,8 +884,7 @@ SetupStartPage(PINPUT_RECORD Ir)
if (IsUnattendedSetup) if (IsUnattendedSetup)
{ {
//TODO // TODO: Read options from inf
//read options from inf
ComputerList = CreateComputerTypeList(SetupInf); ComputerList = CreateComputerTypeList(SetupInf);
DisplayList = CreateDisplayDriverList(SetupInf); DisplayList = CreateDisplayDriverList(SetupInf);
KeyboardList = CreateKeyboardDriverList(SetupInf); KeyboardList = CreateKeyboardDriverList(SetupInf);
@ -993,7 +969,7 @@ IntroPage(PINPUT_RECORD Ir)
{ {
return REPAIR_INTRO_PAGE; return REPAIR_INTRO_PAGE;
} }
else if (toupper(Ir->Event.KeyEvent.uChar.AsciiChar) == 'L') /* R */ else if (toupper(Ir->Event.KeyEvent.uChar.AsciiChar) == 'L') /* L */
{ {
return LICENSE_PAGE; return LICENSE_PAGE;
} }
@ -1533,19 +1509,18 @@ IsDiskSizeValid(PPARTENTRY PartEntry)
static PAGE_NUMBER static PAGE_NUMBER
SelectPartitionPage(PINPUT_RECORD Ir) SelectPartitionPage(PINPUT_RECORD Ir)
{ {
PARTLIST_UI ListUi;
ULONG Error; ULONG Error;
MUIDisplayPage(SELECT_PARTITION_PAGE); MUIDisplayPage(SELECT_PARTITION_PAGE);
if (PartitionList == NULL) if (PartitionList == NULL)
{ {
PartitionList = CreatePartitionList(2, PartitionList = CreatePartitionList();
23,
xScreen - 3,
yScreen - 3);
if (PartitionList == NULL) if (PartitionList == NULL)
{ {
/* FIXME: show an error dialog */ /* FIXME: show an error dialog */
MUIDisplayError(ERROR_DRIVE_INFORMATION, Ir, POPUP_WAIT_ENTER);
return QUIT_PAGE; return QUIT_PAGE;
} }
else if (IsListEmpty(&PartitionList->DiskListHead)) else if (IsListEmpty(&PartitionList->DiskListHead))
@ -1555,7 +1530,12 @@ SelectPartitionPage(PINPUT_RECORD Ir)
} }
} }
DrawPartitionList(PartitionList); InitPartitionListUi(&ListUi, PartitionList,
2,
23,
xScreen - 3,
yScreen - 3);
DrawPartitionList(&ListUi);
if (IsUnattendedSetup) if (IsUnattendedSetup)
{ {
@ -1576,6 +1556,7 @@ SelectPartitionPage(PINPUT_RECORD Ir)
TRUE); TRUE);
} }
// FIXME?? Aren't we going to enter an infinite loop, if this test fails??
if (!IsDiskSizeValid(PartitionList->CurrentPartition)) if (!IsDiskSizeValid(PartitionList->CurrentPartition))
{ {
MUIDisplayError(ERROR_INSUFFICIENT_PARTITION_SIZE, Ir, POPUP_WAIT_ANY_KEY, MUIDisplayError(ERROR_INSUFFICIENT_PARTITION_SIZE, Ir, POPUP_WAIT_ANY_KEY,
@ -1590,6 +1571,9 @@ SelectPartitionPage(PINPUT_RECORD Ir)
} }
else else
{ {
DrawPartitionList(&ListUi);
// FIXME?? Aren't we going to enter an infinite loop, if this test fails??
if (!IsDiskSizeValid(PartitionList->CurrentPartition)) if (!IsDiskSizeValid(PartitionList->CurrentPartition))
{ {
MUIDisplayError(ERROR_INSUFFICIENT_PARTITION_SIZE, Ir, POPUP_WAIT_ANY_KEY, MUIDisplayError(ERROR_INSUFFICIENT_PARTITION_SIZE, Ir, POPUP_WAIT_ANY_KEY,
@ -1657,14 +1641,12 @@ SelectPartitionPage(PINPUT_RECORD Ir)
else if ((Ir->Event.KeyEvent.uChar.AsciiChar == 0x00) && else if ((Ir->Event.KeyEvent.uChar.AsciiChar == 0x00) &&
(Ir->Event.KeyEvent.wVirtualKeyCode == VK_DOWN)) /* DOWN */ (Ir->Event.KeyEvent.wVirtualKeyCode == VK_DOWN)) /* DOWN */
{ {
if (ScrollDownPartitionList(PartitionList)) ScrollDownPartitionList(&ListUi);
DrawPartitionList(PartitionList);
} }
else if ((Ir->Event.KeyEvent.uChar.AsciiChar == 0x00) && else if ((Ir->Event.KeyEvent.uChar.AsciiChar == 0x00) &&
(Ir->Event.KeyEvent.wVirtualKeyCode == VK_UP)) /* UP */ (Ir->Event.KeyEvent.wVirtualKeyCode == VK_UP)) /* UP */
{ {
if (ScrollUpPartitionList(PartitionList)) ScrollUpPartitionList(&ListUi);
DrawPartitionList(PartitionList);
} }
else if (Ir->Event.KeyEvent.wVirtualKeyCode == VK_RETURN) /* ENTER */ else if (Ir->Event.KeyEvent.wVirtualKeyCode == VK_RETURN) /* ENTER */
{ {