/************************************************************************/
/* Copyright 1998 MBARI							*/
/************************************************************************/
#ifndef _VIEW_H
#define _VIEW_H
static char View_h_id[] = "$Header: /u/oreilly/rov/tmacs/RCS/View.h,v 1.6 1998/12/18 21:07:21 oreilly Exp $";

/*
$Log: View.h,v $
Revision 1.6  1998/12/18 21:07:21  oreilly
Added documentation

Revision 1.5  1998/02/23 16:12:15  oreilly
*** empty log message ***

Revision 1.4  1997/10/03 09:34:45  oreilly
*** empty log message ***

 * Revision 1.3  97/09/10  08:54:16  08:54:16  oreilly (Thomas C. O'Reilly)
 * *** empty log message ***
 * 
 * Revision 1.2  97/03/20  12:38:53  12:38:53  oreilly (Thomas C. O'Reilly)
 * *** empty log message ***
 * 
 * Revision 1.1  96/10/28  09:14:17  09:14:17  oreilly (Thomas C. O'Reilly)
 * Initial revision
 * 
*/

#include <Vk/VkComponentList.h>
#include "Layout.h"
#include "array.h"

/*
CLASS 
View

DESCRIPTION
Contains an XmForm Widget, which manages GUI components 
(Widgets, VkComponents, DmGuiObjects). GUI components are added to a View by 
first setting constraints on a Layout object, then calling View::add(). 
View can be made visible or hidden, to implement "paging" of multiple Views. 
As the View is made visible or hidden (with show() and hide()), consumer 
Data Manager items within contained DmGuiObjects are started and
stopped accordingly.

Multiple View displays can be "swapped" in and out of RovMainWindow.

AUTHOR
Tom O'Reilly
*/
class View : public VkComponent
{
  public:

  View(
       const char *name,     // i: Name of view
       Widget parent,        // i: parent widget
       int segments = 100    // i: View is divided into segments along x and y
       );

  ~View();
  
  virtual const char *className()
  {
    return "View";
  }

  ///////////////////////////////////////////////////////////////////
  // Show view, and start constituent consumers
  virtual void show();

  ///////////////////////////////////////////////////////////////////
  // Hide view, and stop constituent consumers
  virtual void hide();
  
  ///////////////////////////////////////////////////////////////////
  // Add VkComponent to View, and add it to internal list
  void add(
	   VkComponent *obj,    // i: object to be added
	   Layout *layout       // i: constraints on object position
	   );
  

  ///////////////////////////////////////////////////////////////////
  // Add standalone widget to View 
  void add(
	   Widget w,            // i: Widget to be added
	   Layout *layout       // i: constraints on widget position
	   );

  ///////////////////////////////////////////////////////////////////
  // Add DmGuiObject to View 
  void add(
	   DmGuiObject *obj,    // i: object to be added
	   Layout *layout       // i: constraints on object position
	   );

  ///////////////////////////////////////////////////////////////////
  // Determine if View contains specified DmGuiObject
  virtual Boolean manages(DmGuiObject *obj);
  
  protected:

  ///////////////////////////////////////////////////////////////////
  // Manage children
  void manage()
  {
    XtManageChild(_baseWidget);
  }

  Widget _parent;
  int _segments;

  ///////////////////////////////////////////////////////////////////
  // List of VkComponents contained in view
  VkComponentList *_vkComponents;
  
  /* Dynamic array is only used locally; keep a static object for all
     instances, to avoid creation overhead. */ 
  static DynArray<DmGuiObject *> *_children;

  Boolean _isParentView;
};


/*
CLASS 
ParentView

DESCRIPTION
A single instance of ParentView contains and manages all
other View objects in TMACS. ParentView is always visible.

AUTHOR
Tom O'Reilly
*/
class ParentView : public View
{
  public:

  ParentView(
	     const char *name,     // i: Name of view
	     Widget parent,        // i: parent widget
	     int segments = 100    // i: View is divided into segments 
                                   // along x and y
	     );

  ~ParentView();
  
  virtual Boolean manages(DmGuiObject *);

  ///////////////////////////////////////////////////////////////////
  // Add a "child" View
  virtual void addChildView(View *view);

  virtual const char *className()
  {
    return "ParentView";
  }

  protected:
  
  ///////////////////////////////////////////////////////////////////
  // List of "child" views contained in ParentView
  SList<View *> _childViews;
};


#endif
