UPLOAD - DOSUIT07.ZIP - GROUP.HPP

 
Output of file : GROUP.HPP contained in archive : DOSUIT07.ZIP

// Groups of VObjects
#ifndef GROUP_HPP
#define GROUP_HPP

#ifndef VOBJECT_HPP
#include "vobject.hpp"
#endif
#ifndef COLLECT_HPP
#include "collect.hpp"
#endif

/*
The basic VObject containing a group of other VObjects. This is
subclassed for Window, Cluster, List, Menu etc. etc. It takes care
of painting all its contents, passing events between them,
determining its own dimensions from the dimensions of its contents
and so on.
*/
class Group : public VObject {
public:
Group(const Rectangle &r,const char *n = "Group")/*!*/;

Group(const char *n = "Group");
Group(const coord l,const coord t,const coord r,const coord b,const char *n = "Group");
Group(const coord width,const coord height,const char *n = "Group");
~Group();

int count() const { return objects.size(); }
// Number of items in the Group.

virtual void contentsSet(VObject* o,ControlFlag f);
// Method called by objects inside this one if their flags have changed.
// f is the flags that have CHANGED.

virtual void contentsDeleted(VObject* v);
// Method called by objects inside this one if they are deleted.

virtual void setwindow(Window *w); // Sets windows for contents too.

virtual void move(coord x,coord y); // Moves contents too.

//~ Add & remove VObjects
void add(VObject *v) { add1(v); addDone(); }
void add(const ObjectCollection &c);
// Expands contents collection, then calls add1 for each
// element in c. Finally, calls addDone.
Group& operator+ (const ObjectCollection &c) { add(c); return *this; }
Group& operator+ (const ObjectCollection *c) { return operator+(*c); }
Group& operator+ (VObject *c) { add(c); return *this; }
int remove(VObject *v) { return remove1(v) ? removeDone(), 1 : 0; }

//~ Remaining methods
virtual void update();

virtual coord minwidth() const;
virtual coord minheight() const;
virtual coord maxwidth() const;
virtual coord maxheight() const;

virtual void paint(Rectangle r);
void paintcontents(Rectangle &r);

virtual int setfocus(int tabstop = 1); // 1 if will accept focus, else 0
virtual void resetfocus();
virtual void clearfocus(VObject *v = 0);

virtual int incfocus(int tabstop = 1,int decrement = 0);
virtual int nextTabstop(int decrement = 0,int wrap = 0);

virtual VObject *containingObject(const Point &p);
// Determine the topmost (smallest) object containing a point

virtual int dohotkey(KeyboardEvent& e);

virtual char *inspectinfo(char *buffer = 0,const char *s = 0) const;
protected:
ObjectCollection objects;
VObject *kbdfocus;
virtual void add1(VObject *v);
// Add an item to the Group.
virtual void addDone();
// After adding 1 or more items, this is called to do any tidying up/
// resizing/updating etc. needed.
virtual int remove1(VObject *v);
// Remove an item from the Group. Returns 0 if item not in Group.
virtual void removeDone();
// After removing 1 or more items, this is called to do any tidying up/
// resizing/updating etc. needed. The default version calls addDone.

// va_list methods are obsolete
void addvalist(VObject *v,va_list l)/*!*/;
};

#endif