Update of /cvsroot/libufo/ufo-0.5/src/xml
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22137/src/xml
Modified Files:
uxul.cpp
Log Message:
Added action map to UXul to automatically connect slots to sigActivated signals. Fixed setting size via XUL and CSS commands.
Index: uxul.cpp
===================================================================
RCS file: /cvsroot/libufo/ufo-0.5/src/xml/uxul.cpp,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** uxul.cpp 3 Sep 2005 10:07:30 -0000 1.6
--- uxul.cpp 15 Sep 2005 10:15:23 -0000 1.7
***************
*** 76,79 ****
--- 76,82 ----
: m_doc(NULL)
, m_root(NULL)
+ , m_title()
+ , m_map()
+ , m_actionMap()
{}
***************
*** 81,84 ****
--- 84,99 ----
: m_doc(NULL)
, m_root(NULL)
+ , m_title()
+ , m_map()
+ , m_actionMap()
+ {
+ load(guiFile);
+ }
+ UXul::UXul(const std::string & guiFile, std::map<std::string, UActionSlot> map)
+ : m_doc(NULL)
+ , m_root(NULL)
+ , m_title()
+ , m_map()
+ , m_actionMap(map)
{
load(guiFile);
***************
*** 154,157 ****
--- 169,173 ----
// ugh, very ugly
static std::map<std::string, UWidget*> * s_map = NULL;
+ static std::map<std::string, UActionSlot> * s_actionMap = NULL;
void
***************
*** 177,182 ****
widget->setStyleHints(hints);
}
!
! UDimension prefSize(UDimension::invalid);
element->QueryIntAttribute("width", &(prefSize.w));
element->QueryIntAttribute("height", &(prefSize.h));
--- 193,198 ----
widget->setStyleHints(hints);
}
! /*
! UDimension prefSize;//widget->getPreferredSize());
element->QueryIntAttribute("width", &(prefSize.w));
element->QueryIntAttribute("height", &(prefSize.h));
***************
*** 184,188 ****
widget->setPreferredSize(prefSize);
}
!
if (s_map) {
if (element->Attribute("id")) {
--- 200,204 ----
widget->setPreferredSize(prefSize);
}
! */
if (s_map) {
if (element->Attribute("id")) {
***************
*** 221,224 ****
--- 237,241 ----
button->setAccelerator(accel);
}
+
if (isTrue(element->Attribute("checked"))) {
button->setSelected(true);
***************
*** 227,230 ****
--- 244,260 ----
button->setIcon(new UImageIcon(element->Attribute("image")));
}
+
+ if (element->Attribute("oncommand")) {
+ std::string command(element->Attribute("oncommand"));
+
+ // search in the action map
+ for (std::map<std::string, UActionSlot>::iterator iter = s_actionMap->begin();
+ iter != s_actionMap->end();
+ ++iter) {
+ if ((*iter).first == command) {
+ button->sigActivated().connect((*s_actionMap)[command]);
+ }
+ }
+ }
}
***************
*** 380,385 ****
ULabel * label = new ULabel();
genericWidget(widgetElement, label);
! if (widgetElement->Attribute("value"))
! label->setText(widgetElement->Attribute("value"));
if (widgetElement->Attribute("control")) {
std::string ctrl = widgetElement->Attribute("control");
--- 410,425 ----
ULabel * label = new ULabel();
genericWidget(widgetElement, label);
! char accesskey = 0;
! if (widgetElement->Attribute("accesskey")) {
! accesskey = (widgetElement->Attribute("accesskey"))[0];
! }
! if (widgetElement->Attribute("value")) {
! std::string text = widgetElement->Attribute("value");
! std::string::size_type index = text.find(accesskey);
! if (index < text.length()) {
! text.insert(index, 1, '&');
! }
! label->setText(text);
! }
if (widgetElement->Attribute("control")) {
std::string ctrl = widgetElement->Attribute("control");
***************
*** 484,487 ****
--- 524,532 ----
}
+ void
+ UXul::setActionMap(std::map<std::string, UActionSlot> map) {
+ m_actionMap = map;
+ }
+
URootPane *
UXul::createRootPane() {
***************
*** 547,550 ****
--- 592,596 ----
// oops, this is tricky
s_map = &m_map;
+ s_actionMap = &m_actionMap;
genericWidget(windowElement, m_root);
genericWidget(windowElement, content);
|