// This may look like C code, but it is really -*- C++ -*-

/***********************************************************
Copyright 1991 by the Massachusetts Institute of Technology

Permission to use, copy, modify, distribute, and sell this software and its
documentation for any purpose is hereby granted without fee, provided that
the above copyright notice appear in all copies and that both that
copyright notice and this permission notice appear in supporting
documentation, and that the name of M.I.T. not be used in advertising or
publicity pertaining to distribution of the software without specific,
written prior permission.  M.I.T. makes no representations about the
suitability of this software for any purpose.  It is provided "as is"
without express or implied warranty.

Author: Roman J. Budzianowski - Project Athena MIT

******************************************************************/

#include "WidgetFactory.h"

#include <xt++/Xaw/Box.h>
#include <xt++/Xaw/Form.h>
#include <xt++/Xaw/Label.h>
#include <xt++/Xaw/Command.h>
#include <X11/StringDefs.h>

#include "Widgets.h"

extern String GetObjectName();

// for now simple: hard coded

void AddTrueCB(Core*, XtPointer w, XtPointer)
{
   ObjectEditor * ws = (ObjectEditor*)w;
   String name = GetObjectName();

   new TrueButton(name);
}

void AddBooleanCB(Core*, XtPointer w, XtPointer)
{
   ObjectEditor * ws = (ObjectEditor*)w;
   String name = GetObjectName();

   new BooleanButton(name);
}

void AddNumberTextCB(Core*, XtPointer w, XtPointer)
{
   ObjectEditor * ws = (ObjectEditor*)w;
   String name = GetObjectName();

   new NumberText(name);
}

void AddNumberLeverCB(Core*, XtPointer w, XtPointer)
{
   ObjectEditor * ws = (ObjectEditor*)w;
   String name = GetObjectName();

   new NumberLever(name);
}

WidgetFactory::WidgetFactory(ApplicationShellWidget& aw)
: TopLevelShellWidget(Core::Unmanaged,"widget_factory", aw)
{
   Widget w;

   Widget form = new FormWidget("form", this);

   w = new LabelWidget("create", form);

   box = new BoxWidget("box", form);

   w = new CommandWidget("create_true_button", box);
   w->AddCallback(XtNcallback, AddTrueCB, (XtPointer)workspace);

   w = new CommandWidget("create_boolean_button", box);
   w->AddCallback(XtNcallback, AddBooleanCB, (XtPointer)workspace);

   w = new CommandWidget("create_container", box);
//   w->AddCallback(XtNcallback, AddBooleanCB, (XtPointer)workspace);

   w = new CommandWidget("create_number_text_io", box);
   w->AddCallback(XtNcallback, AddNumberTextCB, (XtPointer)workspace);

   w = new CommandWidget("create_number_lever_io", box);
   w->AddCallback(XtNcallback, AddNumberLeverCB, (XtPointer)workspace);

   Popup();
}

WidgetFactory::~WidgetFactory()
{

}



