//////////////////////////////////////////////////////////////////////////////
//
//  Author      : Josh Grant
//  Date        : November 12th, 2001
//  File        : ExaminerViewerPlus.h
//  Description : Header file defining the ExaminerViewerPlus Open Inventor
//                viewer class
//
//////////////////////////////////////////////////////////////////////////////

#ifndef _EXAMINER_VIEWER_PLUS_
#define _EXAMINER_VIEWER_PLUS_

#include <Inventor/SbLinear.h>
#include <Inventor/Xt/viewers/SoXtExaminerViewer.h>

//////////////////////////////////////////////////////////////////////////////
//
//  Class: ExaminerViewerPlus
//
//  A subclass of SoXtExaminerViewer used to add a snapshot feature.  An
//  additional button is placed on the righthand side of viewer buttons for
//  capturing a scene to file.  The snapshot button is a camera and when
//  clicked brings up a file dialog selection box widget.  From here the user
//  can select an output type and the dimensions if the output is an image.
//
//////////////////////////////////////////////////////////////////////////////

class ExaminerViewerPlus : public SoXtExaminerViewer {
public:

  // same constructor as the ExaminerViewer
                 ExaminerViewerPlus (Widget parent = NULL,
				     const char *name = NULL,
				     SbBool buildInsideParent = TRUE,
				     SoXtFullViewer::BuildFlag flag = BUILD_ALL,
				     SoXtViewer::Type type = BROWSER);

                 ~ExaminerViewerPlus ();

protected:
  // same constructor as the ExaminerViewer
                 ExaminerViewerPlus  (Widget parent,
		                      const char *name,
				      SbBool buildInsideParent,
				      SoXtFullViewer::BuildFlag flag,
				      SoXtViewer::Type type,
				      SbBool buildNow);

  // overloaded so the snapshot button can be added
  virtual void   createViewerButtons (Widget parent);
  
private:
  // points to the button
  Widget         snapshot;
  // points to the text field used to input the desired image output size
  Widget         width, height;
  Widget         fileDialog;
  // points to the current selected output type
  char          *type;
  char          existingFile[256];

  // called when a valid file has been chosen to save to.
  void           writeImage          (const char *filename);

  // each constructor calls this 
  void           constructorCommon   (SbBool buildNow);

  // creates the file dialog popup selection
  void           createFileDialog    (Widget parent);

  // creates the option menu used to select between output types
  Widget         createOptionMenu    (Widget parent, char *options[],
				      Arg args[], int num);

  // called when the snapshot button is pressed on the viewer
  void static    snapshotCB          (Widget wdg,
			              ExaminerViewerPlus *v,
			              XtPointer wdgData);
  
  // called everytime the pulldown menu is modified
  void static    optionCB            (Widget widget,
			              ExaminerViewerPlus *viewer,
			              XmRowColumnCallbackStruct *data);

  // called when the 'Save' button on the file dialog is selected
  void static    fileSelectedCB      (Widget widget,
			              ExaminerViewerPlus *viewer,
			              XmFileSelectionBoxCallbackStruct
				      *selection);

  // called when the 'Cancel' button on the file dialog is selected
  void static    cancelCB            (Widget widget,
                                      XtPointer client_data,
                                      XmFileSelectionBoxCallbackStruct
                                      *selection);

  void static    overwriteCB         (Widget widget,
				      ExaminerViewerPlus *viewer,
				      XmFileSelectionBoxCallbackStruct
				      *selection);

};

#endif /* _EXAMINER_VIEWER_PLUS_ */
