EventIterators.h
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #ifndef ROCKETCOREEVENTITERATORS_H
00029 #define ROCKETCOREEVENTITERATORS_H
00030
00031 #include <Rocket/Core/ElementReference.h>
00032 #include <Rocket/Core/Element.h>
00033
00034 namespace Rocket {
00035 namespace Core {
00036
00043 class RKTEventFunctor
00044 {
00045 public:
00046 RKTEventFunctor(const String& event, const Dictionary& parameters, bool interruptible)
00047 {
00048 this->event = event;
00049 this->parameters = ¶meters;
00050 this->interruptible = interruptible;
00051 }
00052
00053 void operator()(ElementReference& element)
00054 {
00055 element->DispatchEvent(event, *parameters, interruptible);
00056 }
00057
00058 private:
00059 String event;
00060 const Dictionary* parameters;
00061 bool interruptible;
00062 };
00063
00070 class PseudoClassFunctor
00071 {
00072 public:
00073 PseudoClassFunctor(const String& pseudo_class, bool set) : pseudo_class(pseudo_class)
00074 {
00075 this->set = set;
00076 }
00077
00078 void operator()(ElementReference& element)
00079 {
00080 element->SetPseudoClass(pseudo_class, set);
00081 }
00082
00083 private:
00084 String pseudo_class;
00085 bool set;
00086 };
00087
00093 template<typename T>
00094 class RKTOutputIterator : public std::iterator< std::output_iterator_tag, void, void, void, void >
00095 {
00096 public:
00097 RKTOutputIterator(T& _elements) : elements(_elements)
00098 {
00099 }
00100
00101 RKTOutputIterator &operator=(const typename T::value_type &v)
00102 {
00103
00104 elements.push_back(v);
00105 return *this;
00106 }
00107
00108 RKTOutputIterator &operator *()
00109 {
00110
00111 return *this;
00112 }
00113
00114 RKTOutputIterator &operator ++()
00115 {
00116
00117 return *this;
00118 }
00119
00120 RKTOutputIterator operator ++(int)
00121 {
00122
00123 return *this;
00124 }
00125 private:
00126 T& elements;
00127 };
00128
00129 }
00130 }
00131
00132 #endif