reactos/subsys/system/explorer/taskbar
diff -u -r1.52 -r1.53
--- traynotify.cpp 27 Mar 2004 18:08:42 -0000 1.52
+++ traynotify.cpp 28 Mar 2004 12:00:45 -0000 1.53
@@ -195,6 +195,8 @@
if (pos.go_down("explorer-cfg")) {
if (pos.go_down("notify-icons")) {
+ _show_hidden = XMLBool(pos, "option", "show-hidden");
+
XMLChildrenFilter icons(pos, "icon");
for(XMLChildrenFilter::iterator it=icons.begin(); it!=icons.end(); ++it) {
@@ -227,13 +229,14 @@
void NotifyArea::write_config()
{
- // write notification icon settings to XML configuration
+ // write notification icon settings to XML configuration file
XMLPos pos(&g_Globals._cfg);
- ///@todo pos.create("\\explorer-cfg\\startmenu");
pos.create("explorer-cfg");
pos.create("notify-icons");
+ XMLBoolRef(pos, "option", "show-hidden") = _show_hidden;
+
for(NotifyIconCfgList::iterator it=_cfg.begin(); it!=_cfg.end(); ++it) {
NotifyIconConfig& cfg = *it;
reactos/subsys/system/explorer/utility
diff -u -r1.4 -r1.5
--- xmlstorage.cpp 28 Mar 2004 09:34:43 -0000 1.4
+++ xmlstorage.cpp 28 Mar 2004 12:00:46 -0000 1.5
@@ -133,51 +133,57 @@
}
- /// write node with children tree to output stream
-std::ostream& XMLNode::write_worker(std::ostream& out, WRITE_MODE mode, int indent)
+ /// write node with children tree to output stream using original white space
+void XMLNode::write_worker(std::ostream& out, WRITE_MODE mode, int indent) const
{
- bool format = mode==FORMAT_PRETTY;
-
- if (format)
- for(int i=indent; i--; )
- out << XML_INDENT_SPACE;
-
out << '<' << XMLString(*this);
for(AttributeMap::const_iterator it=_attributes.begin(); it!=_attributes.end(); ++it)
out << ' ' << XMLString(it->first) << "=\"" << XMLString(it->second) << "\"";
if (!_children.empty() || !_content.empty()) {
- out << '>';
-
- if (format)
- out << '\n';
- else
- out << _content;
+ out << '>' << _content;
for(Children::const_iterator it=_children.begin(); it!=_children.end(); ++it)
(*it)->write_worker(out, mode, indent+1);
- if (format)
- for(int i=indent; i--; )
- out << XML_INDENT_SPACE;
-
out << "</" << XMLString(*this) << '>';
- } else {
+ } else
out << "/>";
- }
- if (format)
- out << '\n';
- else
- out << _trailing;
+ out << _trailing;
+}
+
- return out;
+ /// pretty print node with children tree to output stream
+void XMLNode::pretty_write_worker(std::ostream& out, WRITE_MODE mode, int indent) const
+{
+ for(int i=indent; i--; )
+ out << XML_INDENT_SPACE;
+
+ out << '<' << XMLString(*this);
+
+ for(AttributeMap::const_iterator it=_attributes.begin(); it!=_attributes.end(); ++it)
+ out << ' ' << XMLString(it->first) << "=\"" << XMLString(it->second) << "\"";
+
+ if (!_children.empty() || !_content.empty()) {
+ out << ">\n";
+
+ for(Children::const_iterator it=_children.begin(); it!=_children.end(); ++it)
+ (*it)->pretty_write_worker(out, mode, indent+1);
+
+ for(int i=indent; i--; )
+ out << XML_INDENT_SPACE;
+
+ out << "</" << XMLString(*this) << ">\n";
+ } else
+ out << "/>\n";
}
+
/// write node with children tree to output stream using smart formating
-std::ostream& XMLNode::smart_write_worker(std::ostream& out, int indent, bool& next_format)
+bool XMLNode::smart_write_worker(std::ostream& out, int indent, bool next_format) const
{
bool format_pre, format_mid, format_post;
@@ -208,7 +214,7 @@
next_format = (*it)->_content.empty() && (*it)->_trailing.empty();
for(; it!=_children.end(); ++it)
- (*it)->smart_write_worker(out, indent+1, next_format);
+ next_format = (*it)->smart_write_worker(out, indent+1, next_format);
}
if (next_format)
@@ -216,18 +222,15 @@
out << XML_INDENT_SPACE;
out << "</" << XMLString(*this) << '>';
- } else {
+ } else
out << "/>";
- }
if (format_post)
out << '\n';
else
out << _trailing;
- next_format = format_post;
-
- return out;
+ return format_post;
}
reactos/subsys/system/explorer/utility
diff -u -r1.4 -r1.5
--- xmlstorage.h 28 Mar 2004 09:34:43 -0000 1.4
+++ xmlstorage.h 28 Mar 2004 12:00:46 -0000 1.5
@@ -289,15 +289,22 @@
};
/// write node with children tree to output stream
- std::ostream& write(std::ostream& out, WRITE_MODE mode=FORMAT_SMART, int indent=0)
+ std::ostream& write(std::ostream& out, WRITE_MODE mode=FORMAT_SMART, int indent=0) const
{
- if (mode) {
- return write_worker(out, mode, indent);
- } else { // FORMAT_SMART
- bool next_format = _content.empty() && _trailing.empty();
+ switch(mode) {
+ case FORMAT_PRETTY:
+ pretty_write_worker(out, mode, indent);
+ break;
+
+ case FORMAT_ORIGINAL:
+ write_worker(out, mode, indent);
+ break;
- return smart_write_worker(out, indent, next_format);
+ default: // FORMAT_SMART
+ smart_write_worker(out, indent, _content.empty() && _trailing.empty());
}
+
+ return out;
}
protected:
@@ -352,8 +359,9 @@
_children.back()->_trailing.append(s, l);
}
- std::ostream& write_worker(std::ostream& out, WRITE_MODE mode, int indent);
- std::ostream& smart_write_worker(std::ostream& out, int indent, bool& next_format);
+ void write_worker(std::ostream& out, WRITE_MODE mode, int indent) const;
+ void pretty_write_worker(std::ostream& out, WRITE_MODE mode, int indent) const;
+ bool smart_write_worker(std::ostream& out, int indent, bool next_format) const;
};
@@ -520,6 +528,9 @@
return false;
}
+ /// move X-Path like to position in XML tree
+ bool go(const char* path);
+
/// create node if not already existing and move to it
void create(const String& name)
{
@@ -545,7 +556,27 @@
}
}
- bool go(const char* path);
+ String& value(const String& name, const String& attr_name)
+ {
+ XMLNode* node = _cur->find_first(name);
+
+ if (!node) {
+ node = new XMLNode(name);
+ _cur->add_child(node);
+ }
+
+ return (*node)[attr_name];
+ }
+
+ String value(const String& name, const String& attr_name) const
+ {
+ XMLNode* node = _cur->find_first(name);
+
+ if (node)
+ return (*node)[attr_name];
+ else
+ return "";
+ }
protected:
XMLNode* _root;
@@ -561,6 +592,117 @@
};
+struct XMLBool
+{
+ XMLBool(bool value)
+ : _value(value)
+ {
+ }
+
+ XMLBool(LPCTSTR value)
+ {
+ _value = !_tcsicmp(value, TEXT("TRUE"));
+ }
+
+ XMLBool(XMLPos& pos, const String& name, const String& attr_name)
+ {
+ _value = !_tcsicmp(pos.value(name, attr_name), TEXT("TRUE"));
+ }
+
+ operator bool() const
+ {
+ return _value;
+ }
+
+ operator LPCTSTR() const
+ {
+ return _value? TEXT("TRUE"): TEXT("FALSE");
+ }
+
+protected:
+ bool _value;
+
+private:
+ void operator=(const XMLBool&); // disallow assignment operations
+};
+
+struct XMLBoolRef
+{
+ XMLBoolRef(XMLPos& pos, const String& name, const String& attr_name)
+ : _ref(pos.value(name, attr_name))
+ {
+ }
+
+ XMLBoolRef& operator=(bool value)
+ {
+ _ref.assign(value? TEXT("TRUE"): TEXT("FALSE"));
+
+ return *this;
+ }
+
+protected:
+ String& _ref;
+};
+
+
+struct XMLNumber
+{
+ XMLNumber(int value)
+ : _value(value)
+ {
+ }
+
+ XMLNumber(LPCTSTR value)
+ {
+ _value = _ttoi(value);
+ }
+
+ XMLNumber(XMLPos& pos, const String& name, const String& attr_name)
+ {
+ _value = _ttoi(pos.value(name, attr_name));
+ }
+
+ operator int() const
+ {
+ return _value;
+ }
+
+ operator String() const
+ {
+ TCHAR buffer[32];
+ _stprintf(buffer, TEXT("%d"), _value);
+ return buffer;
+ }
+
+protected:
+ int _value;
+
+private:
+ void operator=(const XMLBool&); // disallow assignment operations
+};
+
+struct XMLNumberRef
+{
+ XMLNumberRef(XMLPos& pos, const String& name, const String& attr_name)
+ : _ref(pos.value(name, attr_name))
+ {
+ }
+
+ XMLNumberRef& operator=(int value)
+ {
+ TCHAR buffer[32];
+
+ _stprintf(buffer, TEXT("%d"), value);
+ _ref.assign(buffer);
+
+ return *this;
+ }
+
+protected:
+ String& _ref;
+};
+
+
#ifdef _MSC_VER
#pragma warning(disable: 4355)
#endif
@@ -672,7 +814,7 @@
/// write XML stream preserving previous white space and comments
std::ostream& write(std::ostream& out, WRITE_MODE mode=FORMAT_SMART,
- const std::string& xml_version="1.0", const std::string& encoding="UTF-8")
+ const std::string& xml_version="1.0", const std::string& encoding="UTF-8") const
{
out << "<?xml version=\"" << xml_version << "\" encoding=\"" << encoding << "\"?>\n";
@@ -683,20 +825,20 @@
}
/// write XML stream with formating
- std::ostream& write_formating(std::ostream& out)
+ std::ostream& write_formating(std::ostream& out) const
{
return write(out, FORMAT_PRETTY);
}
void write(const std::string& path, WRITE_MODE mode=FORMAT_SMART,
- const std::string& xml_version="1.0", const std::string& encoding="UTF-8")
+ const std::string& xml_version="1.0", const std::string& encoding="UTF-8") const
{
std::ofstream out(path.c_str());
write(out, mode, xml_version, encoding);
}
- void write_formating(const std::string& path)
+ void write_formating(const std::string& path) const
{
std::ofstream out(path.c_str());