/************************************************************************/
/* Copyright 1998 MBARI							*/
/************************************************************************/
#ifndef _LAYOUT_H
#define _LAYOUT_H
static char Layout_h_id[] = "$Header: /u/oreilly/rov/tmacs/RCS/Layout.h,v 1.3 1998/12/18 21:07:21 oreilly Exp $";

/*
$Log: Layout.h,v $
Revision 1.3  1998/12/18 21:07:21  oreilly
Added documentation

Revision 1.2  1997/03/20 12:34:08  oreilly
*** empty log message ***

 * Revision 1.1  96/10/28  09:13:45  09:13:45  oreilly (Thomas C. O'Reilly)
 * Initial revision
 * 
*/

#include "DmGuiObject.h"

#define AttachToOpposite TRUE

/* NOTE: altering the order of this enum may have impacts
   elsewhere in the code (e.g. statically defined arrays)! */
typedef enum
{
  Top = 0, Bottom, Left, Right

} Side;


/*
CLASS 
Layout

DESCRIPTION
Encapsulates Form Widget positioning constraints; used when adding
widgets or DmGuiObject components to a View.

AUTHOR
Tom O'Reilly
*/
class Layout
{
  public:
  Layout();
  
  ///////////////////////////////////////////////////////////////////
  // Attach side to specified DmGuiObject
  void attach(
	      Side side,               // i: side to be attached
	      DmGuiObject *obj,        // i: attach to this object 
	      int offset = 0,          // i: offset to object
	      MBool opposite = FALSE // i: offset is to opposite side of obj
	      );

  ///////////////////////////////////////////////////////////////////
  // Attach side to specified Widget
  void attach(
	      Side side,               // i: side to be attached
	      Widget w,                // i: attach to this Widget
	      int offset = 0,          // i: offset to object
	      MBool opposite = FALSE // i: offset is to opposite side of obj
	      );

  ///////////////////////////////////////////////////////////////////
  // Attach side to edge of form
  void attachToEdge(
		    Side side,                // i: side to be attached
		    int offset = 0,           // i: offset to edge
		    MBool opposite = FALSE  // i: offset is to opposite edge
		    );  

  ///////////////////////////////////////////////////////////////////
  // Attach side to specified position on a segmented form 
  void position(
		Side side,        // i: side to be positioned
		int position      // i: position on segmented form
		);

  ///////////////////////////////////////////////////////////////////
  // Side is not attached to anything
  void free(
	    Side side            // i: free-floating side
	    );

  ///////////////////////////////////////////////////////////////////
  // Set absolute position
  void absolutePosition(
			int x,   // i: x coordinate
			int y    // i: y coordinate
			);

  ///////////////////////////////////////////////////////////////////
  // Set layout to default
  void defaults();

  ///////////////////////////////////////////////////////////////////
  // Set layout to default
  void reset()
  {
    defaults();
  }
  

  ///////////////////////////////////////////////////////////////////
  // Set args array for use with Motif; return number of args set 
  int setArgs(
	      Arg *args    // o: Args array filled in
	      );
  
  protected:

  ///////////////////////////////////////////////////////////////////
  // Parameters for each side of widget 
  unsigned char _attachment[4];
  int _offset[4];
  int _position[4];
  Widget _widget[4];
  
  MBool _absolute;
  int _x;
  int _y;

};


#endif
