/*
 * ViewerApp.h
 *
 * (c) 2002 by Thorsten Scheuermann <tscheuermann@gmx.net>
 *
 * 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.
 */

#include <qmainwindow.h>

class QWidgetStack;
class ImageCanvas;
class DocLnk;
class Image;
class ImageReader;
class QToolBar;
class QToolButton;
class QPopupMenu;
class ViewerSettings;
class ImageListView;
class ImageSet;
class ImageInfo;
class BookmarkMenu;
class Bookmark;
class QCopChannel;
class QLabel;

class ViewerApp : public QMainWindow
{
  Q_OBJECT

public:
  ViewerApp();
  virtual ~ViewerApp();

  virtual bool eventFilter(QObject *o, QEvent *e);

signals:
  void cardStatusChanged();
  void settingsChanged();

public slots:
  void setDocument(const QString& appLnkFileName);
  void loadImage(const QString& fileName);    // should not be a slot!!!
  void showImage(ImageInfo *imgInfo);
  void showSettingsDialog();
  void showAboutDialog();
  void showBookmarkMenu();
  void changeDirectory(const Bookmark& bm);
  void changeToDocuments();
  void cardMessage(const QCString &, const QByteArray &);

protected:
  // UI elements
  QWidgetStack *stack;
  ImageListView *imgListView;
  ImageCanvas *imgCanvas;
  QToolBar *toolBar;
  QToolButton *bookmarkButton;
  BookmarkMenu *bookmarkMenu;
  QLabel *statusLabel;

  ImageSet *imgSet;
  ImageInfo *currentInfo;
  int currentIndex;
  Image *currentImage;
  ViewerSettings *settings;
  QCopChannel *channel;
  bool startedFromDocTab;

  void showNewImage();
  void updateListViewSelection();
  void optImageSize(int bbWidth, int bbHeight, ImageReader *reader, bool allowRot,
                    int &imgWidth, int &imgHeight, bool &scale, bool &rotate);

private:
  void maxBBFit(int bWidth, int bHeight, int oWidth, int oHeight,
                int &maxWidth, int &maxHeight);

};
