mirror of
https://port.numenaute.org/aleajactaest/khanat-opennel-code.git
synced 2024-11-18 21:26:12 +00:00
Add radio button type to CGroupHTML (issue 237)
This commit is contained in:
parent
276692c155
commit
95e4f93256
2 changed files with 100 additions and 8 deletions
|
@ -163,6 +163,9 @@ namespace NLGUI
|
||||||
std::string DefaultCheckBoxBitmapNormal;
|
std::string DefaultCheckBoxBitmapNormal;
|
||||||
std::string DefaultCheckBoxBitmapPushed;
|
std::string DefaultCheckBoxBitmapPushed;
|
||||||
std::string DefaultCheckBoxBitmapOver;
|
std::string DefaultCheckBoxBitmapOver;
|
||||||
|
std::string DefaultRadioButtonBitmapNormal;
|
||||||
|
std::string DefaultRadioButtonBitmapPushed;
|
||||||
|
std::string DefaultRadioButtonBitmapOver;
|
||||||
std::string DefaultBackgroundBitmapView;
|
std::string DefaultBackgroundBitmapView;
|
||||||
std::string CurrentLinkTitle;
|
std::string CurrentLinkTitle;
|
||||||
|
|
||||||
|
|
|
@ -1445,30 +1445,71 @@ namespace NLGUI
|
||||||
_Forms.back().Entries.push_back (entry);
|
_Forms.back().Entries.push_back (entry);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (type == "checkbox")
|
else if (type == "checkbox" || type == "radio")
|
||||||
{
|
{
|
||||||
// The submit button
|
CCtrlButton::EType btnType;
|
||||||
string name;
|
string name;
|
||||||
string normal = DefaultCheckBoxBitmapNormal;
|
string normal;
|
||||||
string pushed = DefaultCheckBoxBitmapPushed;
|
string pushed;
|
||||||
string over = DefaultCheckBoxBitmapOver;
|
string over;
|
||||||
|
ucstring ucValue = ucstring("on");
|
||||||
bool checked = false;
|
bool checked = false;
|
||||||
|
|
||||||
|
if (type == "radio")
|
||||||
|
{
|
||||||
|
btnType = CCtrlButton::RadioButton;
|
||||||
|
normal = DefaultRadioButtonBitmapNormal;
|
||||||
|
pushed = DefaultRadioButtonBitmapPushed;
|
||||||
|
over = DefaultRadioButtonBitmapOver;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
btnType = CCtrlButton::ToggleButton;
|
||||||
|
normal = DefaultCheckBoxBitmapNormal;
|
||||||
|
pushed = DefaultCheckBoxBitmapPushed;
|
||||||
|
over = DefaultCheckBoxBitmapOver;
|
||||||
|
}
|
||||||
|
|
||||||
if (present[MY_HTML_INPUT_NAME] && value[MY_HTML_INPUT_NAME])
|
if (present[MY_HTML_INPUT_NAME] && value[MY_HTML_INPUT_NAME])
|
||||||
name = value[MY_HTML_INPUT_NAME];
|
name = value[MY_HTML_INPUT_NAME];
|
||||||
if (present[MY_HTML_INPUT_SRC] && value[MY_HTML_INPUT_SRC])
|
if (present[MY_HTML_INPUT_SRC] && value[MY_HTML_INPUT_SRC])
|
||||||
normal = value[MY_HTML_INPUT_SRC];
|
normal = value[MY_HTML_INPUT_SRC];
|
||||||
|
if (present[MY_HTML_INPUT_VALUE] && value[MY_HTML_INPUT_VALUE])
|
||||||
|
ucValue.fromUtf8(value[MY_HTML_INPUT_VALUE]);
|
||||||
checked = (present[MY_HTML_INPUT_CHECKED] && value[MY_HTML_INPUT_CHECKED]);
|
checked = (present[MY_HTML_INPUT_CHECKED] && value[MY_HTML_INPUT_CHECKED]);
|
||||||
|
|
||||||
// Add the ctrl button
|
// Add the ctrl button
|
||||||
CCtrlButton *checkbox = addButton (CCtrlButton::ToggleButton, name, normal, pushed, over,
|
CCtrlButton *checkbox = addButton (btnType, name, normal, pushed, over,
|
||||||
globalColor, "", "", tooltip);
|
globalColor, "", "", tooltip);
|
||||||
if (checkbox)
|
if (checkbox)
|
||||||
{
|
{
|
||||||
|
if (btnType == CCtrlButton::RadioButton)
|
||||||
|
{
|
||||||
|
// group together buttons with same name
|
||||||
|
CForm &form = _Forms.back();
|
||||||
|
bool notfound = true;
|
||||||
|
for (uint i=0; i<form.Entries.size(); i++)
|
||||||
|
{
|
||||||
|
if (form.Entries[i].Name == name && form.Entries[i].Checkbox->getType() == CCtrlButton::RadioButton)
|
||||||
|
{
|
||||||
|
checkbox->initRBRefFromRadioButton(form.Entries[i].Checkbox);
|
||||||
|
notfound = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (notfound)
|
||||||
|
{
|
||||||
|
// this will start a new group (initRBRef() would take first button in group container otherwise)
|
||||||
|
checkbox->initRBRefFromRadioButton(checkbox);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
checkbox->setPushed (checked);
|
checkbox->setPushed (checked);
|
||||||
|
|
||||||
// Add the text area to the form
|
// Add the button to the form
|
||||||
CGroupHTML::CForm::CEntry entry;
|
CGroupHTML::CForm::CEntry entry;
|
||||||
entry.Name = name;
|
entry.Name = name;
|
||||||
|
entry.Value = decodeHTMLEntities(ucValue);
|
||||||
entry.Checkbox = checkbox;
|
entry.Checkbox = checkbox;
|
||||||
_Forms.back().Entries.push_back (entry);
|
_Forms.back().Entries.push_back (entry);
|
||||||
}
|
}
|
||||||
|
@ -2040,6 +2081,9 @@ namespace NLGUI
|
||||||
DefaultCheckBoxBitmapNormal = "checkbox_normal.tga";
|
DefaultCheckBoxBitmapNormal = "checkbox_normal.tga";
|
||||||
DefaultCheckBoxBitmapPushed = "checkbox_pushed.tga";
|
DefaultCheckBoxBitmapPushed = "checkbox_pushed.tga";
|
||||||
DefaultCheckBoxBitmapOver = "checkbox_over.tga";
|
DefaultCheckBoxBitmapOver = "checkbox_over.tga";
|
||||||
|
DefaultRadioButtonBitmapNormal = "w_radiobutton.png";
|
||||||
|
DefaultRadioButtonBitmapPushed = "w_radiobutton_pushed.png";
|
||||||
|
DefaultRadioButtonBitmapOver = "";
|
||||||
DefaultBackgroundBitmapView = "bg";
|
DefaultBackgroundBitmapView = "bg";
|
||||||
clearContext();
|
clearContext();
|
||||||
|
|
||||||
|
@ -2275,6 +2319,21 @@ namespace NLGUI
|
||||||
return DefaultCheckBoxBitmapOver;
|
return DefaultCheckBoxBitmapOver;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
if( name == "radiobutton_bitmap_normal" )
|
||||||
|
{
|
||||||
|
return DefaultRadioButtonBitmapNormal;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
if( name == "radiobutton_bitmap_pushed" )
|
||||||
|
{
|
||||||
|
return DefaultRadioButtonBitmapPushed;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
if( name == "radiobutton_bitmap_over" )
|
||||||
|
{
|
||||||
|
return DefaultRadioButtonBitmapOver;
|
||||||
|
}
|
||||||
|
else
|
||||||
if( name == "background_bitmap_view" )
|
if( name == "background_bitmap_view" )
|
||||||
{
|
{
|
||||||
return DefaultBackgroundBitmapView;
|
return DefaultBackgroundBitmapView;
|
||||||
|
@ -2618,6 +2677,24 @@ namespace NLGUI
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
if( name == "radiobutton_bitmap_normal" )
|
||||||
|
{
|
||||||
|
DefaultRadioButtonBitmapNormal = value;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
if( name == "radiobutton_bitmap_pushed" )
|
||||||
|
{
|
||||||
|
DefaultRadioButtonBitmapPushed = value;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
if( name == "radiobutton_bitmap_over" )
|
||||||
|
{
|
||||||
|
DefaultRadioButtonBitmapOver = value;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else
|
||||||
if( name == "background_bitmap_view" )
|
if( name == "background_bitmap_view" )
|
||||||
{
|
{
|
||||||
DefaultBackgroundBitmapView = value;
|
DefaultBackgroundBitmapView = value;
|
||||||
|
@ -2731,6 +2808,9 @@ namespace NLGUI
|
||||||
xmlSetProp( node, BAD_CAST "checkbox_bitmap_normal", BAD_CAST DefaultCheckBoxBitmapNormal.c_str() );
|
xmlSetProp( node, BAD_CAST "checkbox_bitmap_normal", BAD_CAST DefaultCheckBoxBitmapNormal.c_str() );
|
||||||
xmlSetProp( node, BAD_CAST "checkbox_bitmap_pushed", BAD_CAST DefaultCheckBoxBitmapPushed.c_str() );
|
xmlSetProp( node, BAD_CAST "checkbox_bitmap_pushed", BAD_CAST DefaultCheckBoxBitmapPushed.c_str() );
|
||||||
xmlSetProp( node, BAD_CAST "checkbox_bitmap_over", BAD_CAST DefaultCheckBoxBitmapOver.c_str() );
|
xmlSetProp( node, BAD_CAST "checkbox_bitmap_over", BAD_CAST DefaultCheckBoxBitmapOver.c_str() );
|
||||||
|
xmlSetProp( node, BAD_CAST "radiobutton_bitmap_normal", BAD_CAST DefaultRadioButtonBitmapNormal.c_str() );
|
||||||
|
xmlSetProp( node, BAD_CAST "radiobutton_bitmap_pushed", BAD_CAST DefaultRadioButtonBitmapPushed.c_str() );
|
||||||
|
xmlSetProp( node, BAD_CAST "radiobutton_bitmap_over", BAD_CAST DefaultRadioButtonBitmapOver.c_str() );
|
||||||
xmlSetProp( node, BAD_CAST "background_bitmap_view", BAD_CAST DefaultBackgroundBitmapView.c_str() );
|
xmlSetProp( node, BAD_CAST "background_bitmap_view", BAD_CAST DefaultBackgroundBitmapView.c_str() );
|
||||||
xmlSetProp( node, BAD_CAST "home", BAD_CAST Home.c_str() );
|
xmlSetProp( node, BAD_CAST "home", BAD_CAST Home.c_str() );
|
||||||
xmlSetProp( node, BAD_CAST "browse_next_time", BAD_CAST toString( _BrowseNextTime ).c_str() );
|
xmlSetProp( node, BAD_CAST "browse_next_time", BAD_CAST toString( _BrowseNextTime ).c_str() );
|
||||||
|
@ -2888,6 +2968,15 @@ namespace NLGUI
|
||||||
ptr = xmlGetProp (cur, (xmlChar*)"checkbox_bitmap_over");
|
ptr = xmlGetProp (cur, (xmlChar*)"checkbox_bitmap_over");
|
||||||
if (ptr)
|
if (ptr)
|
||||||
DefaultCheckBoxBitmapOver = (const char*)(ptr);
|
DefaultCheckBoxBitmapOver = (const char*)(ptr);
|
||||||
|
ptr = xmlGetProp (cur, (xmlChar*)"radiobutton_bitmap_normal");
|
||||||
|
if (ptr)
|
||||||
|
DefaultRadioButtonBitmapNormal = (const char*)(ptr);
|
||||||
|
ptr = xmlGetProp (cur, (xmlChar*)"radiobutton_bitmap_pushed");
|
||||||
|
if (ptr)
|
||||||
|
DefaultRadioButtonBitmapPushed = (const char*)(ptr);
|
||||||
|
ptr = xmlGetProp (cur, (xmlChar*)"radiobutton_bitmap_over");
|
||||||
|
if (ptr)
|
||||||
|
DefaultRadioButtonBitmapOver = (const char*)(ptr);
|
||||||
ptr = xmlGetProp (cur, (xmlChar*)"background_bitmap_view");
|
ptr = xmlGetProp (cur, (xmlChar*)"background_bitmap_view");
|
||||||
if (ptr)
|
if (ptr)
|
||||||
DefaultBackgroundBitmapView = (const char*)(ptr);
|
DefaultBackgroundBitmapView = (const char*)(ptr);
|
||||||
|
@ -3966,7 +4055,7 @@ namespace NLGUI
|
||||||
// todo handle unicode POST here
|
// todo handle unicode POST here
|
||||||
if (form.Entries[i].Checkbox->getPushed ())
|
if (form.Entries[i].Checkbox->getPushed ())
|
||||||
{
|
{
|
||||||
entryData = ucstring ("on");
|
entryData = form.Entries[i].Value;
|
||||||
addEntry = true;
|
addEntry = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue