#include <stdio.h>
#include <Xm/RowColumn.h>
#include <Xm/Label.h>
#include <Xm/TextF.h>
#include <Vk/VkApp.h>
#include "tfTest.h"
#include "TextField.h"

TestPanel::TestPanel(const char *name, Widget parent)
  : VkComponent(name)
{
  static char *rowNames[] = 
  {
    "Name:", "Phone:", "Address:", "Shoe Size:"
  };
  
  _baseWidget = XtVaCreateWidget(name, xmRowColumnWidgetClass, parent, 
				 XmNorientation, XmHORIZONTAL,
				 XmNpacking, XmPACK_COLUMN,
				 XmNnumColumns, XtNumber(rowNames),
				 XmNisAligned, True,
				 XmNentryAlignment, XmALIGNMENT_BEGINNING,
				 NULL);
  installDestroyHandler();

  char buf[100];
  for (int i = 0; i < XtNumber(rowNames); i++)
  {
    sprintf(buf, "label%d", i);
    XmString xmstr = XmStringCreateSimple(rowNames[i]);
    
    XtVaCreateManagedWidget(buf, xmLabelWidgetClass, _baseWidget,
			    XmNlabelString, xmstr, 
			    NULL);
    XmStringFree(xmstr);
    
    sprintf(buf, "text%d", i);

    TextField *tf = new TextField(buf, _baseWidget);
    tf->show();
    
/* ***    
    XtVaCreateManagedWidget(buf, xmTextFieldWidgetClass, _baseWidget,
			    NULL);
*** */
  }
}


TestWindow::TestWindow(const char *name) :
  VkSimpleWindow(name)
{
  TestPanel *panel = 
    new TestPanel("panel", mainWindowWidget());
  
  addView(panel->baseWidget());
}

#ifdef ZILCH
main(int argc, char **argv)
{
  VkApp *app = new VkApp("tfTest", &argc, argv);
  TestWindow *win = new TestWindow("window");
  win->show();
  app->run();
}

#endif







