/*------------------------------------------------------------------------------
 src/bin/djview/app.h

 Copyright (c) 2004-2006 Darby Johnston.
 All rights reserved.
 Use is subject to license terms.
------------------------------------------------------------------------------*/

#ifndef DJVIEW_APP_H
#define DJVIEW_APP_H
#include "imageCache.h"
#include <djImageOpStack.h>
#include <djApp.h>

namespace djview {

class Window;
class MagnifyTool;
class ColorSampleTool;
class ImageInfoTool;
class ImageOpTool;
class PrefsDialog;
class AboutDialog;

// Application.
//
class App : public dj::App {
public:

  App(int & argc, char ** argv);
  ~App();
  
  // Images.
  //
  const StrList & imageOpList() { return _imageOpList; }
  ImageOpStack & imageOpStack() { return _imageOpStack; }
  ImageCache & imageCache() { return _imageCache; }
  void imageCacheEnabled(bool);
  bool imageCacheEnabled() const { return _imageCacheEnabled; }
  
  // Files.
  //
  void fileReload(const Str &);
  void fileRecentList(const Str &);
  void filePixelFormat(int);
  void filePixelType(int);
  const StrList & fileRecentList() const { return _fileRecentList; }
  int filePixelFormat() const { return _filePixelFormat; }
  int filePixelType() const { return _filePixelType; }
  
  // Windows.
  // 
  void windowNew(const Str & fileName = Str());
  void windowCopy(Window *);
  void windowDel(Window *);
  void windowFileFit(bool);
  void windowFullscreenFit(bool);
  bool windowFileFit() const { return _windowFileFit; }
  bool windowFullscreenFit() const { return _windowFullscreenFit; }
  
  // Views.
  //
  void viewBg(const Color &);
  const Color & viewBg() const { return _viewBg; }

  // Playback.
  //
  void playbackFile(bool);
  void playbackFileSpeed(bool);
  void playbackEveryFrame(bool);
  bool playbackFile() const { return _playbackFile; }
  bool playbackFileSpeed() const { return _playbackFileSpeed; }
  bool playbackEveryFrame() const { return _playbackEveryFrame; }
  
  // Tools.
  //
  MagnifyTool * magnifyTool() { return _magnifyTool; }
  ColorSampleTool * colorSampleTool() { return _colorSampleTool; }
  ImageInfoTool * imageInfoTool() { return _imageInfoTool; }
  ImageOpTool * imageOpTool() { return _imageOpTool; }
  
  // Dialogs.
  //
  void prefsDialog();
  void aboutDialog();
  
private:

  DJ_CALLBACK(App, imageOpToolCallback, bool);
  DJ_CALLBACK(App, imageOpToolCallback, int);
  void imageOpToolUpdate();
  void imageOpToolUpdate(int);
  
  void prefsSet();
  void prefsGet();
  const Str cmdln(StrList &);
  void help();

  StrList _inputList;
  StrList _imageOpList;
  ImageOpStack _imageOpStack;
  ImageCache _imageCache;
  bool _imageCacheEnabled;
  StrList _fileRecentList;
  int _filePixelFormat, _filePixelType;
  bool _windowFileFit, _windowFullscreenFit;
  Color _viewBg;
  bool _playbackFile, _playbackFileSpeed, _playbackEveryFrame;
  
  List<Window *> _windowList;
  MagnifyTool * _magnifyTool;
  ColorSampleTool * _colorSampleTool;
  ImageInfoTool * _imageInfoTool;
  ImageOpTool * _imageOpTool;
  PrefsDialog * _prefsDialog;
  AboutDialog * _aboutDialog;
  bool _callbacks;
};

#define djviewApp (static_cast<djview::App *>(djApp))

}

#endif
