#include "radiobox.h"
#include "prdialog.h"
#include "frame.h"

@implementation WDCRadioBox


- initWithName:(char*)aName managedBy:anObject
{
  if (![anObject isKindOfClassNamed:"WDCWindow"]
      && ![anObject isKindOfClassNamed:"WDCFrame"])
    {
      [self setPopupShell : [[WDCPromptDialog alloc]
			     initWithName : aName 
			     managedBy : anObject]];
      [self setWidget:XmCreateRadioBox([[self getPopupShell] getWidget],
				       aName,
				       [self getArgList],
				       [self getNumArgs])];
      /*
      [self setPopupShell : [[WDCPopupShell alloc]
			     initWithName : aName 
			     managedBy : [anObject getTopShellObject]]];
      [self setPopupWindow : [[WDCFrame alloc]
			      initWithName : aName
			      managedBy : [self getPopupShell]]];
      [self setWidget:XmCreateRadioBox([[self getPopupWindow] getWidget],
				       aName,
				       [self getArgList],
				       [self getNumArgs])];
				       */
    /*  
    [self setWidget:XmCreateRadioBox([[anObject getTopShellObject] getWidget],
				     aName,
				     [self getArgList],
				     [self getNumArgs])];      
				     */
    }
  else
    [self setWidget:XmCreateRadioBox([anObject getWidget],
				     aName,
				     [self getArgList],
				     [self getNumArgs])];
  [self setParentObject: anObject];

  // this need to be managed before its parent. So, just do this for now.
     

  [super manage];
  return [self setAction];
}

- setAction
{
  return self;
}

- setPopupShell:shell
{
  _popupShell=shell;
  return self;
}

- setPopupWindow:window
{
  _popupWindow=window;
  return self;
}

- getPopupShell
{
  return _popupShell;
}

- getPopupWindow
{
  return _popupWindow;
}

- (BOOL)isManaged
{
  id object;
  return (object=[self getPopupShell])? [object isManaged]:[super isManaged];
}  

- manage
{
  id object;
  if (object=[self getPopupShell])
    [object manage];
  else
    [super manage];
  return self;
}

- unManage
{
  id object;
  if (object=[self getPopupShell])
    [object unManage];
  else
    [super unManage];
  return self;
}

- setArg:(char*)aName to:(char*)aValue
{
  id object;
  if (object=[self getPopupShell])
    [object setArg:aName to:aValue];
  else
    [super setArg:aName to:aValue];
  return self;
}

- (char*)getArgValue:(char*)aName
{
  id object;
  return (object=[self getPopupShell]) ? 
    [object getArgValue:aName] : [super getArgValue : aName];
}


@end


