00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef _ugroup_hpp_
00022 #define _ugroup_hpp_
00023
00024 #include <ubit/ucontrol.hpp>
00025 #include <ubit/uargs.hpp>
00026 #include <ubit/ustr.hpp>
00027 namespace ubit {
00028
00029
00047 class UGroup: public UControl {
00048 public:
00049 UBIT_ELEMENT_CLASS(UGroup, UControl)
00057 static UStyle* createStyle();
00062 const UStyle& getStyle(UContext*) const;
00067
00068
00069 UGroup(const UArgs& = UArgs::none);
00071
00072 friend UGroup& ugroup(const UArgs& a = UArgs::none) {return *new UGroup(a);}
00077 virtual ~UGroup();
00083 virtual UGroup* groupCast() {return this;}
00085
00086 virtual unsigned short getNodeType() const {return ELEMENT_NODE;}
00088
00089 virtual const UStr* getNodeName() const;
00091
00092 virtual const UStr* getNodeValue() const {return null;}
00093
00094
00095
00096 virtual void initNode(UDoc* context) {}
00098
00099
00100
00101
00102
00103
00104
00105 virtual bool isParentOf(const UBrick& possible_child) const;
00107
00108 virtual UGroup& addlist(const UArgs& child_list);
00117 virtual UChildIter add(const UChild&);
00123 virtual UChildIter add(const UChild&, int position);
00124
00125
00126
00127
00128
00129
00130 virtual UChildIter add(const UChild&, UChildIter position);
00131
00132
00133
00134
00135
00136
00137 virtual UChildIter remove(UBrick&, bool auto_delete = true);
00150 virtual UChildIter removeNC(UBrick&, bool auto_delete = true);
00156 virtual UChildIter remove(int position, bool auto_delete = true);
00162 virtual UChildIter remove(UChildIter position, bool auto_delete = true);
00167 virtual void removeAll(bool auto_delete = true);
00172 UChildIter cbegin() const {return children().begin();}
00184 UChildIter cend() const {return children().end();}
00186
00187 UChildReverseIter crbegin() const {return children().rbegin();}
00189 UChildReverseIter crend() const {return children().rend();}
00191
00192 virtual UChildren& children() const {return _children;}
00197 UChildIter child(int position) const {return children().at(position);}
00199
00200 UBrick* getChild(int position) const;
00202
00203 virtual UStr retrieveText(bool recursive = true) const;
00204 virtual void retrieveText(UStr& to, bool recursive = true) const;
00210
00211
00212 virtual void addAttr(const UChild& attribute);
00219 virtual void removeAttr(UBrick& attribute, bool auto_delete = true);
00224 virtual void removeAttrNC(UBrick& attr, bool auto_delete = true);
00225
00226 virtual void removeAllAttrs(bool auto_del = true);
00231 UChildIter abegin() const {return attributes().begin();}
00232
00233 UChildIter aend() const {return attributes().end();}
00234
00235 virtual UChildren& attributes() const {return _attributes;}
00236
00237
00238 virtual const UStr* getAttr(const UStr& name, bool ignore_case = true) const;
00240
00241 virtual const UProp* getAttrNode(const UStr& name, bool ignore_case = true) const;
00243
00244 virtual UProp* getAttrNode(const UStr& name, bool ignore_case = true);
00246
00247 virtual UProp* setAttrNode(UProp*);
00249
00250
00251
00252 virtual void repaint() {update(UUpdate::paint);}
00258 virtual void update() {update(UUpdate::layoutAndPaint);}
00264 virtual void update(const UUpdate&);
00270 UGroup& autoUpdate(bool state) {UBrick::autoUpdate(state); return *this;}
00272
00273 virtual void show(bool = true);
00279 void hide() {show(false);}
00281
00282 virtual void close(int status = 0);
00290 virtual void closeWin(int status = 0);
00295 static void closeWinCB(UEvent&, int status);
00296
00297
00298
00299
00300 virtual const UStr* getTextSeparator() const;
00302
00303 enum {REMOVE_FROM_PARENTS=-1};
00304
00305 virtual UChildIter addImpl(UChildren&, const UChild&, UChildIter,
00306 bool update, bool* should_update);
00308
00309 virtual UChildIter removeImpl(UChildren&, UChildIter, int rem_mode,
00310 bool update, bool* should_update);
00312
00313 virtual bool fire(UEvent&, const UOn&) const;
00315
00316 virtual int getRelatedViews(std::vector<UView*>&) const;
00318
00319
00320
00321 #ifndef NO_DOC
00322 friend class UBrick;
00323 friend class UWin;
00324
00325 bool isBrowsingGroup() {return (cmodes & UMode::CAN_BROWSE_CHILDREN) != 0;}
00326 virtual UGroup* getBrowsingGroup() {return (cmodes & UMode::CAN_BROWSE_CHILDREN) ? this : null;}
00328
00329 virtual void highlight(bool state) {};
00330 virtual void initView(UChild* selflink, UView *ancestor_view);
00331 virtual void initChildViews(UGroup*, UChild *childlink);
00332 virtual void updateView(UEvent&, UView*, const UUpdate&);
00334
00335 protected:
00336 mutable UChildren _children;
00337 virtual void destructs();
00338 virtual void deleteRelatedViews(UView* parview, UChild*);
00339 virtual void deleteRelatedViews2(UView* parview);
00340 virtual int getTextLength(bool recursive) const;
00341 virtual char* getTextData(char *ptr, bool recursive) const;
00342 #endif
00343 };
00344
00345 }
00346 #endif
00347
00348