/* Implementation of  Control class Motif WidgetSet category
 *
 * Copyright (C)  1995  The Board of Trustees of  
 * The Leland Stanford Junior University.  All Rights Reserved.
 *
 * Authors: Paul Kunz
 *
 * This file is part of an Objective-C class library for Motif
 *
 * xmControl.m,v 1.1 1995/04/22 23:12:39 pfkeb Exp
 */

#include "Control.h"
#include "xtResponder.h"

#include "ActionCell.h"
#include "appkit/Motif.h"

char *ControlInstanceName(void)
{
    return "Control";
}

@implementation Control(WidgetSet)

- _setAdjustedFrame:(const NXRect *)aFrame
{
  /* This method adjusts the position and size of the control
   * view's frame to accomodate widgets that need a larger frame
   * due to the selection border
   */

    NXRect	rect;

    rect = *aFrame;
    if ( cell ) {
	NXSize	adjust;

	[cell _getSizeAdjust:&adjust];
        rect.origin.x    -= adjust.width/2;
	rect.origin.y    -= adjust.height/2;
	rect.size.width  += adjust.width;
	rect.size.height += adjust.height;
    }
    [self _setArg:XmNx      to:rect.origin.x];
    [self _setArg:XmNy      to:rect.origin.y];
    [self _setArg:XmNwidth  to:rect.size.width];
    [self _setArg:XmNheight to:rect.size.height];
    return self;
}

- _sizeTo:(NXCoord)width :(NXCoord)height
{
  /* Make the frame larger to allow for widget's outline if needed */
    NXCoord	w, h;

    w = width;
    h = height;
    if ( cell )  {
	NXSize	adjust;

	[cell _getSizeAdjust:&adjust];
        w += adjust.width;
	h += adjust.height;
    }
    [self _setArg:XmNwidth  to:w];
    [self _setArg:XmNheight to:h];
    return self;
}

@end


