CheckListBox supports descriptions (bug #4884)

This commit is contained in:
selmer%netscape.com 1999-10-19 20:30:18 +00:00
Родитель 4f0537b0f7
Коммит 07fe097926
5 изменённых файлов: 217 добавлений и 31 удалений

Просмотреть файл

@ -88,8 +88,12 @@ Width=119
Height=76 Height=76
target=CheckListDescription
subsection=Options for CheckListBox11 subsection=Options for CheckListBox11
OptionDescriptions=Option Descriptions for CheckListBox11
[Options for CheckListBox11] [Options for CheckListBox11]
opt1=Address Book sync tool opt1=Address Book sync tool
@ -110,6 +114,25 @@ opt8=Internet Setup
opt9=RealPlayer 5.0 opt9=RealPlayer 5.0
[Option Descriptions for CheckListBox11]
opt1=Description of the Address Book sync tool
opt2=Description of the AIM
opt3=Description of the Audio/Video Playback
opt4=Description of the Beatnik Stub Plug-in
opt5=Description of the Calendar
opt6=Description of the CalendarLink sync tool
opt7=Description of the Import Utility
opt8=Description of the Internet Setup
opt9=Description of the RealPlayer 5.0
[Widget 2] [Widget 2]
@ -476,6 +499,22 @@ Width=118
Height=40 Height=40
[Widget 1307]
Type=Text
Name=CheckListDescription
Value=
Start_x=14
Start_y=184
Width=110
Height=29
[Widget 18] [Widget 18]

Просмотреть файл

@ -1370,46 +1370,72 @@ void CWizardMachineApp::BuildWidget(WIDGET* aWidget, CString iniSection, CString
// As the number of entries in the subsection are not known, a generic loop // As the number of entries in the subsection are not known, a generic loop
// has been created to read all existing name/value pairs in the subsection // has been created to read all existing name/value pairs in the subsection
// and store them in the options component of the control. // and store them in the options component of the control.
int counter = 0;
GetPrivateProfileString(iniSection, "subsection", "", buffer, MAX_SIZE, iniFile); GetPrivateProfileString(iniSection, "subsection", "", buffer, MAX_SIZE, iniFile);
if (strcmp(buffer, "") != 0) { if (strcmp(buffer, "") != 0) {
char* subSection; char* subSection;
subSection = new char[sizeof(buffer)]; subSection = new char[sizeof(buffer)];
strcpy(subSection, buffer); strcpy(subSection, buffer);
/* Don't tie options to functions... int i = 0;
if (aWidget->action.function == "") char* ComponentKey;
char ComponentKeyBuffer[MAX_SIZE];
if (GetPrivateProfileString(subSection, NULL, "", buffer, MAX_SIZE, iniFile) > 0)
{ {
*/ while (counter < 25 && buffer[i] != 0)
int counter = 0;
int i = 0;
char* ComponentKey;
char ComponentKeyBuffer[MAX_SIZE];
if (GetPrivateProfileString(subSection, NULL, "", buffer, MAX_SIZE, iniFile) > 0)
{ {
while (buffer[i] != 0) ComponentKey = &buffer[i];
if (GetPrivateProfileString(subSection, ComponentKey, "", ComponentKeyBuffer, MAX_SIZE, iniFile) > 0)
{ {
ComponentKey = &buffer[i]; aWidget->options.name[counter] = new char[sizeof(ComponentKey)];
if (GetPrivateProfileString(subSection, ComponentKey, "", ComponentKeyBuffer, MAX_SIZE, iniFile) > 0) strcpy(aWidget->options.name[counter],ComponentKey);
{ aWidget->options.value[counter] = new char[sizeof(ComponentKeyBuffer)];
aWidget->options.name[counter] = new char[sizeof(ComponentKey)]; strcpy(aWidget->options.value[counter],ComponentKeyBuffer);
strcpy(aWidget->options.name[counter],ComponentKey); counter++;
aWidget->options.value[counter] = new char[sizeof(ComponentKeyBuffer)];
strcpy(aWidget->options.value[counter],ComponentKeyBuffer);
counter++;
}
while (buffer[i] != 0)
i++;
i++;
} }
while (buffer[i] != 0)
i++;
i++;
} }
aWidget->numOfOptions = counter;
/*
} }
else { delete subSection;
aWidget->numOfOptions = 0;
}
*/
} }
aWidget->numOfOptions = counter;
// As the number of entries in the subsection are not known, a generic loop
// has been created to read all existing name/value pairs in the subsection
// and store them in the options component of the control.
counter = 0;
GetPrivateProfileString(iniSection, "OptionDescriptions", "", buffer, MAX_SIZE, iniFile);
if (strcmp(buffer, "") != 0) {
char* subSection;
subSection = new char[sizeof(buffer)];
strcpy(subSection, buffer);
int i = 0;
char* ComponentKey;
char ComponentKeyBuffer[MAX_SIZE];
if (GetPrivateProfileString(subSection, NULL, "", buffer, MAX_SIZE, iniFile) > 0)
{
while (counter < 25 && buffer[i] != 0)
{
ComponentKey = &buffer[i];
if (GetPrivateProfileString(subSection, ComponentKey, "", ComponentKeyBuffer, MAX_SIZE, iniFile) > 0)
{
aWidget->optDesc.name[counter] = new char[sizeof(ComponentKey)];
strcpy(aWidget->optDesc.name[counter],ComponentKey);
aWidget->optDesc.value[counter] = new char[sizeof(ComponentKeyBuffer)];
strcpy(aWidget->optDesc.value[counter],ComponentKeyBuffer);
counter++;
}
while (buffer[i] != 0)
i++;
i++;
}
}
delete subSection;
}
aWidget->numOfOptDesc = counter;
} }
/* /*
@ -1589,11 +1615,17 @@ void CWizardMachineApp::GenerateList(CString action, WIDGET* targetWidget, CStri
if (curWidget->value && curWidget->value != "") if (curWidget->value && curWidget->value != "")
{ {
char indices[MAX_SIZE]; char indices[MAX_SIZE];
int i;
strcpy(indices, curWidget->value); strcpy(indices, curWidget->value);
char *s = strtok(indices, ","); char *s = strtok(indices, ",");
for (; s; s=strtok(NULL, ",")) for (; s; s=strtok(NULL, ","))
((CCheckListBox*)curWidget->control)->SelectString(0, s); {
i = ((CCheckListBox*)curWidget->control)->FindString(0, s);
if (i != -1)
((CCheckListBox*)curWidget->control)->SetCheck(i, 1);
}
((CCheckListBox*)curWidget->control)->SetCurSel(0);
} }
else else
((CCheckListBox*)curWidget->control)->SetCurSel(0); ((CCheckListBox*)curWidget->control)->SetCurSel(0);

Просмотреть файл

@ -58,6 +58,8 @@ typedef struct WIDGET
ACTIONSET action; ACTIONSET action;
int numOfOptions; int numOfOptions;
OPTIONS options; OPTIONS options;
int numOfOptDesc;
OPTIONS optDesc;
CString items; CString items;
BOOL cached; BOOL cached;
UINT widgetID; UINT widgetID;

Просмотреть файл

@ -304,6 +304,28 @@ BOOL CWizardUI::SortList(WIDGET *curWidget)
return TRUE; return TRUE;
} }
BOOL CWizardUI::SetDescription(WIDGET *w)
{
WIDGET *t = theApp.findWidget((char *) (LPCTSTR) w->target);
if (!t || (t->type != "Text" && t->type != "BoldText"))
return FALSE;
int selected = 0;
if (w->type == "ListBox")
selected = ((CListBox *)w->control)->GetCurSel();
else if (w->type == "CheckListBox")
selected = ((CCheckListBox *)w->control)->GetCurSel();
else if (w->type == "ComboBox")
selected = ((CComboBox *)w->control)->GetCurSel();
if (selected == -1 || selected >= w->numOfOptDesc)
return FALSE;
((CEdit *)t->control)->SetWindowText(w->optDesc.value[selected]);
return TRUE;
}
BOOL CWizardUI::OnCommand(WPARAM wParam, LPARAM lParam) BOOL CWizardUI::OnCommand(WPARAM wParam, LPARAM lParam)
{ {
UINT nID = LOWORD(wParam); UINT nID = LOWORD(wParam);
@ -320,6 +342,9 @@ BOOL CWizardUI::OnCommand(WPARAM wParam, LPARAM lParam)
if (curWidget->action.onCommand) if (curWidget->action.onCommand)
theInterpreter->interpret(curWidget->action.onCommand, curWidget); theInterpreter->interpret(curWidget->action.onCommand, curWidget);
if (curWidget->numOfOptDesc > 0)
SetDescription(curWidget);
break; break;
} }
@ -589,7 +614,6 @@ void CWizardUI::CreateControls()
CString ext = theInterpreter->replaceVars(curWidget->action.parameters,NULL); CString ext = theInterpreter->replaceVars(curWidget->action.parameters,NULL);
theApp.GenerateList(curWidget->action.onInit, curWidget, ext); theApp.GenerateList(curWidget->action.onInit, curWidget, ext);
} }
*/
if (!curWidget->action.onInit.IsEmpty()) if (!curWidget->action.onInit.IsEmpty())
theInterpreter->interpret(curWidget->action.onInit, curWidget); theInterpreter->interpret(curWidget->action.onInit, curWidget);
else else
@ -613,6 +637,7 @@ void CWizardUI::CreateControls()
((CListBox*)curWidget->control)->SelectString(0, s); ((CListBox*)curWidget->control)->SelectString(0, s);
s = strtok( NULL, "," ); s = strtok( NULL, "," );
} }
*/
//GlobalFree(selectedItems); //GlobalFree(selectedItems);
EnableWidget(curWidget); EnableWidget(curWidget);
} }
@ -632,7 +657,6 @@ void CWizardUI::CreateControls()
CString ext = theInterpreter->replaceVars(curWidget->action.parameters, NULL); CString ext = theInterpreter->replaceVars(curWidget->action.parameters, NULL);
theApp.GenerateList(curWidget->action.onInit, curWidget, ext); theApp.GenerateList(curWidget->action.onInit, curWidget, ext);
} }
*/
if (!curWidget->action.onInit.IsEmpty()) if (!curWidget->action.onInit.IsEmpty())
theInterpreter->interpret(curWidget->action.onInit, curWidget); theInterpreter->interpret(curWidget->action.onInit, curWidget);
else else
@ -659,7 +683,10 @@ void CWizardUI::CreateControls()
((CCheckListBox*)curWidget->control)->SetCheck(i, 1); ((CCheckListBox*)curWidget->control)->SetCheck(i, 1);
s = strtok( NULL, "," ); s = strtok( NULL, "," );
} }
if (curWidget->numOfOptDesc > 0)
SetDescription(curWidget);
//GlobalFree(selectedItems); //GlobalFree(selectedItems);
*/
EnableWidget(curWidget); EnableWidget(curWidget);
} }
else if (widgetType == "ComboBox") { else if (widgetType == "ComboBox") {
@ -673,7 +700,6 @@ void CWizardUI::CreateControls()
CString ext = theInterpreter->replaceVars(curWidget->action.parameters,NULL); CString ext = theInterpreter->replaceVars(curWidget->action.parameters,NULL);
theApp.GenerateList(curWidget->action.onInit, curWidget, ext); theApp.GenerateList(curWidget->action.onInit, curWidget, ext);
} }
*/
if (!curWidget->action.onInit.IsEmpty()) if (!curWidget->action.onInit.IsEmpty())
theInterpreter->interpret(curWidget->action.onInit, curWidget); theInterpreter->interpret(curWidget->action.onInit, curWidget);
else else
@ -686,6 +712,7 @@ void CWizardUI::CreateControls()
} }
} }
} }
*/
EnableWidget(curWidget); EnableWidget(curWidget);
//((CComboBox*)curWidget->control)->SelectString(0, selectedCustomization); //((CComboBox*)curWidget->control)->SelectString(0, selectedCustomization);
@ -723,6 +750,91 @@ void CWizardUI::CreateControls()
curWidget->control->SetFont(m_pFont); curWidget->control->SetFont(m_pFont);
} }
} }
// Handle initializations AFTER all controls created...
for (x = 0; x < m_pControlCount; x++)
{
WIDGET* curWidget = CurrentNode->pageWidgets[x];
CString widgetType = curWidget->type;
if (widgetType == "ListBox")
{
if (!curWidget->action.onInit.IsEmpty())
theInterpreter->interpret(curWidget->action.onInit, curWidget);
else
{
for (int i = 0; i < curWidget->numOfOptions; i++)
{
if (curWidget->options.value[i])
{
((CListBox*)curWidget->control)->AddString(curWidget->options.value[i]);
}
}
}
char* selectedItems;
selectedItems = (char *) GlobalAlloc(0, curWidget->value.GetLength()+1);
strcpy(selectedItems, (char *) (LPCTSTR) curWidget->value);
char *s = strtok(selectedItems, ",");
while (s)
{
((CListBox*)curWidget->control)->SelectString(0, s);
s = strtok( NULL, "," );
}
}
else if (widgetType == "CheckListBox")
{
if (!curWidget->action.onInit.IsEmpty())
theInterpreter->interpret(curWidget->action.onInit, curWidget);
else
{
for (int i = 0; i < curWidget->numOfOptions; i++)
{
if (curWidget->options.value[i])
{
((CCheckListBox*)curWidget->control)->AddString(curWidget->options.value[i]);
}
}
}
char* selectedItems;
selectedItems = (char *) GlobalAlloc(0, curWidget->value.GetLength()+1);
strcpy(selectedItems, (char *) (LPCTSTR) curWidget->value);
int i;
BOOL selected = FALSE;
char *s = strtok(selectedItems, ",");
while (s)
{
if (!selected)
{
selected = TRUE;
((CCheckListBox*)curWidget->control)->SelectString(0, s);
}
i = ((CCheckListBox*)curWidget->control)->FindString(0, s);
if (i != -1)
((CCheckListBox*)curWidget->control)->SetCheck(i, 1);
s = strtok( NULL, "," );
}
if (curWidget->numOfOptDesc > 0)
SetDescription(curWidget);
}
else if (widgetType == "ComboBox") {
if (!curWidget->action.onInit.IsEmpty())
theInterpreter->interpret(curWidget->action.onInit, curWidget);
else
{
for (int i = 0; i < curWidget->numOfOptions; i++)
{
if (curWidget->options.value[i])
{
((CComboBox*)curWidget->control)->AddString(curWidget->options.value[i]);
}
}
}
}
}
} }
void CWizardUI::DisplayControls() void CWizardUI::DisplayControls()

Просмотреть файл

@ -75,6 +75,7 @@ public:
int m_pControlID; int m_pControlID;
BOOL containsImage; BOOL containsImage;
BOOL SetDescription(WIDGET *w);
void SortWidgetsForTabOrder(); void SortWidgetsForTabOrder();
void EnableWidget(WIDGET *curWidget); void EnableWidget(WIDGET *curWidget);
void CreateControls(); void CreateControls();