/**********************************************************************
 *     EPSCAN, an EPSON ES-1200 scanner driver     
 *     Adam P. Jenkins <ajenkins@cs.umass.edu>
 *     
 *     This program is free software; you can redistribute it and/or
 *     modify it under the terms of the GNU General Public License
 *     as published by the Free Software Foundation; either version 2
 *     of the License, or (at your option) any later version.
 *     
 *     This program is distributed in the hope that it will be useful,
 *     but WITHOUT ANY WARRANTY; without even the implied warranty of
 *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *     GNU General Public License for more details.
 *     
 *     You should have received a copy of the GNU General Public License
 *     along with this program; if not, write to the Free Software
 *     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 *
 **********************************************************************/

// -*-c++-*-

#include <qwidget.h>
#include <qlist.h>
#include <qstring.h>

#include "Scanner.h"

class QComboBox;
class QLabel;
class QRect;
class QBoxLayout;

class ValSlider;
class EPGetRegion;
class HelpWindow;

class EPScan : public QWidget
{
  Q_OBJECT;
public:
  EPScan(QWidget *parent=0, const char *name=0);
  ~EPScan();

private slots:
  void setImageType(int id);
  void setDestination(int id);
  void setResolution(int id);
  void setBrightness(int val);
  void setZoom(int val);
  void setArea(const QRect& r);
  void doScan();
  void doPreview();

  void displayDim(int id);

private:
  Scanner *scanner;
  ScanNewSettings Settings;
  ScanNewIdentity Identity;

  struct MenuItem {
    MenuItem(const char *i, int d) { item = i; data = d; }
    QString item;
    int data;
  };

  typedef QList<MenuItem> MenuItemList;
  
  struct Dest {
    enum {
      COLORLASER,
      LASER,
      DOTMAT,
      COLORSCREEN,
      BWSCREEN};
  };

  struct Type {
    enum {
      COLOR,
      GRAY,
      HALFTONE,
      LINEART};
  };

  struct Units {
    enum {
      INCH,
      CM};
  };
  
  // menus items
  MenuItemList imageTypeData;
  MenuItemList destinationData;
  MenuItemList resolutionData;
  MenuItemList unitsData;
  
  // widgets
  HelpWindow *helpWin;
  EPGetRegion *previewWin;

  QComboBox *imageTypeMenu;
  QComboBox *destinationMenu;
  QComboBox *resolutionMenu;

  ValSlider *brightnessCtrl;

  QLabel *widthLabel;
  QLabel *heightLabel;
  QComboBox *unitsMenu;

  ValSlider *zoomCtrl;

  QString lastSavedFile;
  
  // support functions
  void initScanner(const char *device=0);
  void initMenus();		// creates menu data, should be called
				// after initScanner so resolutions
				// will be there.

  void makeMenu(QComboBox *menu, MenuItemList *data);
  // searches for a member of the data list for an item whose ->data
  // member == item, and sets that to be the current menu item
  int setMenu(QComboBox *menu, MenuItemList *data, int item);
  void setDefaultValues();
};
