
#ifndef _ui_factory_h_
#define _ui_factory_h_

#include "ui/viewdesc.h"
#include "ui/rectangl.h"

#include "base/strgset.h"

class YACL_UI UI_VisualObject;

class YACL_UI UI_VObjFactory {

public:
    UI_VObjFactory ();

    virtual ~UI_VObjFactory () {};

    CL_StringSet ObjectNames () const {return _objectSet;};
    // Return the set of names of visual objects available (i.e., that the
    // factory knows about).
    
    UI_VisualObject* Create (UI_VisualObject* parent,
			     const UI_ViewDescriptor& desc);

    UI_VisualObject* Create (UI_ViewType type,
			     UI_VisualObject* parent,
			     const UI_Rectangle& shape,
			     UI_ViewID id,
			     const char* title = "",
			     UI_ViewDescriptor* enclosed = NULL)
	{return _DoCreate (type, parent, shape, id, title, enclosed);};


protected:
    virtual UI_VisualObject* _DoCreate (UI_ViewType type,
					UI_VisualObject* parent,
					const UI_Rectangle& shape,
					UI_ViewID id,
					const char* title,
					UI_ViewDescriptor* enclosed);

    CL_StringSet _objectSet;

};




inline UI_VisualObject* UI_VObjFactory::Create (UI_VisualObject* parent,
                                                const UI_ViewDescriptor& desc)
{
    UI_Rectangle r (desc.shape.x, desc.shape.y, desc.shape.w, 
                     desc.shape.h);
    return _DoCreate (desc.type, parent, r, desc.id,
                      desc.title, desc.enclosed);
}

#endif
