Update of /cvsroot/libufo/ufo-0.5/src/xml
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12978/src/xml
Modified Files:
uxul.cpp
Log Message:
Added accesskey support and added genericButton method. Fixed error handling.
Index: uxul.cpp
===================================================================
RCS file: /cvsroot/libufo/ufo-0.5/src/xml/uxul.cpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** uxul.cpp 12 Jul 2005 13:40:24 -0000 1.4
--- uxul.cpp 2 Sep 2005 13:24:07 -0000 1.5
***************
*** 178,182 ****
}
! UDimension prefSize;
element->QueryIntAttribute("width", &(prefSize.w));
element->QueryIntAttribute("height", &(prefSize.h));
--- 178,182 ----
}
! UDimension prefSize(UDimension::invalid);
element->QueryIntAttribute("width", &(prefSize.w));
element->QueryIntAttribute("height", &(prefSize.h));
***************
*** 210,213 ****
--- 210,232 ----
}
+ void
+ genericButton(TiXmlElement * element, UButton * button) {
+ genericWidget(element, button);
+ if (element->Attribute("label")) {
+ button->setText(element->Attribute("label"));
+ }
+ if (element->Attribute("accesskey")) {
+ std::string accel("Alt+");
+ accel.append(element->Attribute("accesskey"));
+ button->setAccelerator(accel);
+ }
+ if (isTrue(element->Attribute("checked"))) {
+ button->setSelected(true);
+ }
+ if (element->Attribute("image")) {
+ button->setIcon(new UImageIcon(element->Attribute("image")));
+ }
+ }
+
UMenu *
createMenu(TiXmlElement * elem) {
***************
*** 216,222 ****
//}
UMenu * menu = new UMenu();
! if (elem->Attribute("label"))
! menu->setText(elem->Attribute("label"));
! genericWidget(elem, menu);
TiXmlElement* popupElement = elem->FirstChildElement();
--- 235,239 ----
//}
UMenu * menu = new UMenu();
! genericButton(elem, menu);
TiXmlElement* popupElement = elem->FirstChildElement();
***************
*** 237,249 ****
// FIXME:
}
- if (isTrue(menuElement->Attribute("checked"))) {
- item->setSelected(true);
- }
} else {
item = new UMenuItem();
}
! genericWidget(menuElement, item);
! if (menuElement->Attribute("label"))
! item->setText(menuElement->Attribute("label"));
menu->add(item);
} else if ("menuseparator" == value) {
--- 254,261 ----
// FIXME:
}
} else {
item = new UMenuItem();
}
! genericButton(menuElement, item);
menu->add(item);
} else if ("menuseparator" == value) {
***************
*** 263,267 ****
UMenuBar * mbar = new UMenuBar();
genericWidget(elem, mbar);
- UMenu * menu;
TiXmlElement* menuElement = elem->FirstChildElement();
for(; menuElement; menuElement = menuElement->NextSiblingElement()) {
--- 275,278 ----
***************
*** 286,295 ****
if ("radio" == value) {
URadioButton * radioButton = new URadioButton();
! genericWidget(radioElement, radioButton);
! if (radioElement->Attribute("label"))
! radioButton->setText(radioElement->Attribute("label"));
! if (isTrue(radioElement->Attribute("checked"))) {
! radioButton->setSelected(true);
! }
radioButton->setButtonGroup(buttonGroup);
container->add(radioButton);
--- 297,301 ----
if ("radio" == value) {
URadioButton * radioButton = new URadioButton();
! genericButton(radioElement, radioButton);
radioButton->setButtonGroup(buttonGroup);
container->add(radioButton);
***************
*** 361,387 ****
} else if ("button" == value) {
UButton * button = new UButton();
! genericWidget(widgetElement, button);
! if (widgetElement->Attribute("label"))
! button->setText(widgetElement->Attribute("label"));
! if (widgetElement->Attribute("image"))
! button->setIcon(new UImageIcon(widgetElement->Attribute("image")));
container->add(button);
} else if ("checkbox" == value) {
UCheckBox * checkBox = new UCheckBox();
! genericWidget(widgetElement, checkBox);
! if (widgetElement->Attribute("label"))
! checkBox->setText(widgetElement->Attribute("label"));
! if (isTrue(widgetElement->Attribute("checked"))) {
! checkBox->setSelected(true);
! }
container->add(checkBox);
} else if ("radio" == value) {
URadioButton * radioButton = new URadioButton();
! genericWidget(widgetElement, radioButton);
! if (widgetElement->Attribute("label"))
! radioButton->setText(widgetElement->Attribute("label"));
! if (isTrue(widgetElement->Attribute("checked"))) {
! radioButton->setSelected(true);
! }
container->add(radioButton);
} else if ("label" == value) {
--- 367,379 ----
} else if ("button" == value) {
UButton * button = new UButton();
! genericButton(widgetElement, button);
container->add(button);
} else if ("checkbox" == value) {
UCheckBox * checkBox = new UCheckBox();
! genericButton(widgetElement, checkBox);
container->add(checkBox);
} else if ("radio" == value) {
URadioButton * radioButton = new URadioButton();
! genericButton(widgetElement, radioButton);
container->add(radioButton);
} else if ("label" == value) {
***************
*** 485,491 ****
bool loadOkay = m_doc->LoadFile();
if (!loadOkay) {
! //sprintf(m_error, "Could not load test file 'demotest.xml'. Error='%s'. Exiting.\n",
! //doc.ErrorDesc( );
! //exit( 1 );
}
}
--- 477,484 ----
bool loadOkay = m_doc->LoadFile();
if (!loadOkay) {
! uError() << "Couldn't load file: " << guiFile << "\n"
! << m_doc->ErrorDesc() << "\n";
! delete (m_doc);
! m_doc = NULL;
}
}
***************
*** 493,496 ****
--- 486,493 ----
URootPane *
UXul::createRootPane() {
+ if (!m_doc) {
+ uError() << "no XML document loaded.\n";
+ return NULL;
+ }
if (!m_root) {
m_root = new URootPane();
***************
*** 561,564 ****
--- 558,565 ----
UXFrame *
UXul::createFrame() {
+ if (!m_doc) {
+ uError() << "no XML document loaded.\n";
+ return NULL;
+ }
UXFrame * frame = static_cast<UXDisplay*>(UXDisplay::getDefault())->createFrame();
|