Author: hpoussin
Date: Sun May 11 16:17:57 2008
New Revision: 33450
URL:
http://svn.reactos.org/svn/reactos?rev=33450&view=rev
Log:
Better encapsulation of generic list
Modified:
trunk/reactos/base/setup/usetup/genlist.c
trunk/reactos/base/setup/usetup/genlist.h
trunk/reactos/base/setup/usetup/interface/usetup.c
trunk/reactos/base/setup/usetup/settings.c
Modified: trunk/reactos/base/setup/usetup/genlist.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/setup/usetup/genlist.…
==============================================================================
--- trunk/reactos/base/setup/usetup/genlist.c [iso-8859-1] (original)
+++ trunk/reactos/base/setup/usetup/genlist.c [iso-8859-1] Sun May 11 16:17:57 2008
@@ -33,6 +33,28 @@
/* FUNCTIONS ****************************************************************/
+typedef struct _GENERIC_LIST_ENTRY
+{
+ LIST_ENTRY Entry;
+ PGENERIC_LIST List;
+ PVOID UserData;
+ CHAR Text[1];
+} GENERIC_LIST_ENTRY;
+
+
+typedef struct _GENERIC_LIST
+{
+ LIST_ENTRY ListHead;
+
+ SHORT Left;
+ SHORT Top;
+ SHORT Right;
+ SHORT Bottom;
+
+ PGENERIC_LIST_ENTRY CurrentEntry;
+ PGENERIC_LIST_ENTRY BackupEntry;
+} GENERIC_LIST;
+
PGENERIC_LIST
CreateGenericList(VOID)
{
@@ -98,6 +120,7 @@
return FALSE;
strcpy (Entry->Text, Text);
+ Entry->List = List;
Entry->UserData = UserData;
InsertTailList(&List->ListHead,
@@ -313,6 +336,59 @@
}
}
+
+VOID
+SetCurrentListEntry(PGENERIC_LIST List, PGENERIC_LIST_ENTRY Entry)
+{
+ if (Entry->List != List)
+ return;
+ List->CurrentEntry = Entry;
+}
+
+
+PGENERIC_LIST_ENTRY
+GetCurrentListEntry(PGENERIC_LIST List)
+{
+ return List->CurrentEntry;
+}
+
+
+PGENERIC_LIST_ENTRY
+GetFirstListEntry(PGENERIC_LIST List)
+{
+ PLIST_ENTRY Entry = List->ListHead.Flink;
+
+ if (Entry == &List->ListHead)
+ return NULL;
+ return CONTAINING_RECORD(Entry, GENERIC_LIST_ENTRY, Entry);
+}
+
+
+PGENERIC_LIST_ENTRY
+GetNextListEntry(PGENERIC_LIST_ENTRY Entry)
+{
+ PLIST_ENTRY Next = Entry->Entry.Flink;
+
+ if (Next == &Entry->List->ListHead)
+ return NULL;
+ return CONTAINING_RECORD(Next, GENERIC_LIST_ENTRY, Entry);
+}
+
+
+PVOID
+GetListEntryUserData(PGENERIC_LIST_ENTRY List)
+{
+ return List->UserData;
+}
+
+
+LPCSTR
+GetListEntryText(PGENERIC_LIST_ENTRY List)
+{
+ return List->Text;
+}
+
+
VOID
GenericListKeyPress (PGENERIC_LIST GenericList, CHAR AsciChar)
{
@@ -355,12 +431,6 @@
DrawListEntries(GenericList);
}
-PGENERIC_LIST_ENTRY
-GetGenericListEntry(PGENERIC_LIST List)
-{
- return List->CurrentEntry;
-}
-
VOID
SaveGenericListState(PGENERIC_LIST List)
Modified: trunk/reactos/base/setup/usetup/genlist.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/setup/usetup/genlist.…
==============================================================================
--- trunk/reactos/base/setup/usetup/genlist.h [iso-8859-1] (original)
+++ trunk/reactos/base/setup/usetup/genlist.h [iso-8859-1] Sun May 11 16:17:57 2008
@@ -27,28 +27,10 @@
#ifndef __GENLIST_H__
#define __GENLIST_H__
-typedef struct _GENERIC_LIST_ENTRY
-{
- LIST_ENTRY Entry;
- PVOID UserData;
- CHAR Text[1];
-} GENERIC_LIST_ENTRY, *PGENERIC_LIST_ENTRY;
-
-
-typedef struct _GENERIC_LIST
-{
- LIST_ENTRY ListHead;
-
- SHORT Left;
- SHORT Top;
- SHORT Right;
- SHORT Bottom;
-
- PGENERIC_LIST_ENTRY CurrentEntry;
- PGENERIC_LIST_ENTRY BackupEntry;
-} GENERIC_LIST, *PGENERIC_LIST;
-
-
+struct _GENERIC_LIST_ENTRY;
+typedef struct _GENERIC_LIST_ENTRY *PGENERIC_LIST_ENTRY;
+struct _GENERIC_LIST;
+typedef struct _GENERIC_LIST *PGENERIC_LIST;
PGENERIC_LIST
CreateGenericList(VOID);
@@ -76,8 +58,23 @@
VOID
ScrollUpGenericList(PGENERIC_LIST List);
+VOID
+SetCurrentListEntry(PGENERIC_LIST List, PGENERIC_LIST_ENTRY Entry);
+
PGENERIC_LIST_ENTRY
-GetGenericListEntry(PGENERIC_LIST List);
+GetCurrentListEntry(PGENERIC_LIST List);
+
+PGENERIC_LIST_ENTRY
+GetFirstListEntry(PGENERIC_LIST List);
+
+PGENERIC_LIST_ENTRY
+GetNextListEntry(PGENERIC_LIST_ENTRY Entry);
+
+PVOID
+GetListEntryUserData(PGENERIC_LIST_ENTRY List);
+
+LPCSTR
+GetListEntryText(PGENERIC_LIST_ENTRY List);
VOID
SaveGenericListState(PGENERIC_LIST List);
Modified: trunk/reactos/base/setup/usetup/interface/usetup.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/setup/usetup/interfac…
==============================================================================
--- trunk/reactos/base/setup/usetup/interface/usetup.c [iso-8859-1] (original)
+++ trunk/reactos/base/setup/usetup/interface/usetup.c [iso-8859-1] Sun May 11 16:17:57
2008
@@ -563,7 +563,6 @@
VOID
UpdateKBLayout(VOID)
{
- PLIST_ENTRY Entry;
PGENERIC_LIST_ENTRY ListEntry;
LPCWSTR pszNewLayout;
@@ -574,22 +573,20 @@
LayoutList = CreateKeyboardLayoutList(SetupInf, DefaultKBLayout);
}
- Entry = LayoutList->ListHead.Flink;
+ ListEntry = GetFirstListEntry(LayoutList);
/* Search for default layout (if provided) */
if (pszNewLayout != NULL)
{
- while (Entry != &LayoutList->ListHead)
- {
- ListEntry = CONTAINING_RECORD (Entry, GENERIC_LIST_ENTRY, Entry);
-
- if (!wcscmp(pszNewLayout, ListEntry->UserData))
- {
- LayoutList->CurrentEntry = ListEntry;
+ while (ListEntry != NULL)
+ {
+ if (!wcscmp(pszNewLayout, GetListEntryUserData(ListEntry)))
+ {
+ SetCurrentListEntry(LayoutList, ListEntry);
break;
}
- Entry = Entry->Flink;
+ ListEntry = GetNextListEntry(ListEntry);
}
}
}
@@ -647,7 +644,7 @@
}
else if (Ir->Event.KeyEvent.uChar.AsciiChar == 0x0D) /* ENTER */
{
- SelectedLanguageId = (PWCHAR)LanguageList->CurrentEntry->UserData;
+ SelectedLanguageId =
(PWCHAR)GetListEntryUserData(GetCurrentListEntry(LanguageList));
if (wcscmp(SelectedLanguageId, DefaultLanguage))
{
@@ -1019,10 +1016,10 @@
MUIDisplayPage(DEVICE_SETTINGS_PAGE);
- CONSOLE_SetTextXY(25, 11, GetGenericListEntry(ComputerList)->Text);
- CONSOLE_SetTextXY(25, 12, GetGenericListEntry(DisplayList)->Text);
- CONSOLE_SetTextXY(25, 13, GetGenericListEntry(KeyboardList)->Text);
- CONSOLE_SetTextXY(25, 14, GetGenericListEntry(LayoutList)->Text);
+ CONSOLE_SetTextXY(25, 11, GetListEntryText(GetCurrentListEntry((ComputerList))));
+ CONSOLE_SetTextXY(25, 12, GetListEntryText(GetCurrentListEntry((DisplayList))));
+ CONSOLE_SetTextXY(25, 13, GetListEntryText(GetCurrentListEntry((KeyboardList))));
+ CONSOLE_SetTextXY(25, 14, GetListEntryText(GetCurrentListEntry((LayoutList))));
CONSOLE_InvertTextXY(24, Line, 48, 1);
Modified: trunk/reactos/base/setup/usetup/settings.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/setup/usetup/settings…
==============================================================================
--- trunk/reactos/base/setup/usetup/settings.c [iso-8859-1] (original)
+++ trunk/reactos/base/setup/usetup/settings.c [iso-8859-1] Sun May 11 16:17:57 2008
@@ -485,15 +485,15 @@
DPRINT("ProcessComputerFiles() called\n");
- Entry = GetGenericListEntry(List);
+ Entry = GetCurrentListEntry(List);
if (Entry == NULL)
{
- DPRINT("GetGenericListEntry() failed\n");
+ DPRINT("GetCurrentListEntry() failed\n");
return FALSE;
}
wcscpy(SectionName, L"Files.");
- wcscat(SectionName, (const wchar_t*) Entry->UserData);
+ wcscat(SectionName, (const wchar_t*)GetListEntryUserData(Entry));
*AdditionalSectionName = SectionName;
return TRUE;
@@ -514,14 +514,14 @@
DPRINT("ProcessDisplayRegistry() called\n");
- Entry = GetGenericListEntry(List);
+ Entry = GetCurrentListEntry(List);
if (Entry == NULL)
{
- DPRINT("GetGenericListEntry() failed\n");
- return FALSE;
- }
-
- if (!SetupFindFirstLineW(InfFile, L"Display", (WCHAR*) Entry->UserData,
&Context))
+ DPRINT("GetCurrentListEntry() failed\n");
+ return FALSE;
+ }
+
+ if (!SetupFindFirstLineW(InfFile, L"Display",
(WCHAR*)GetListEntryUserData(Entry), &Context))
{
DPRINT("SetupFindFirstLineW() failed\n");
return FALSE;
@@ -629,11 +629,11 @@
HANDLE KeyHandle;
NTSTATUS Status;
- Entry = GetGenericListEntry(List);
+ Entry = GetCurrentListEntry(List);
if (Entry == NULL)
return FALSE;
- LanguageId = (PWCHAR)Entry->UserData;
+ LanguageId = (PWCHAR)GetListEntryUserData(Entry);
if (LanguageId == NULL)
return FALSE;
@@ -877,11 +877,11 @@
NTSTATUS Status;
PKEY_VALUE_PARTIAL_INFORMATION ValueInfo;
- Entry = GetGenericListEntry(List);
+ Entry = GetCurrentListEntry(List);
if (Entry == NULL)
return FALSE;
- LanguageId = (PWCHAR)Entry->UserData;
+ LanguageId = (PWCHAR)GetListEntryUserData(Entry);
if (LanguageId == NULL)
return FALSE;