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

#ifndef DJ_IMAGE_IO_WIDGET_H
#define DJ_IMAGE_IO_WIDGET_H
#include <djImageIo.h>
#include <djWidget.h>

namespace dj {

// Image load widget base.
//
class ImageLoadWidget : public Widget, public Plugin {
public:

  ImageLoadWidget();
  virtual ~ImageLoadWidget() = 0;
  
  virtual void set(ImageLoad *);
  Signal<bool> & sig() { return _sig; }
  virtual void widgetUpdate() {}

protected:

  ImageLoad * _load;
  Signal<bool> _sig;
};

// Image save widget base.
//
class ImageSaveWidget : public Widget, public Plugin {
public:

  ImageSaveWidget();
  virtual ~ImageSaveWidget() = 0;
  
  virtual void set(ImageSave *);
  Signal<bool> & sig() { return _sig; }
  virtual void widgetUpdate() {}

protected:

  ImageSave * _save;
  Signal<bool> _sig;
};

// Plugin entry points.
//
typedef const List<ImageLoadWidget *> (ImageLoadWidgetFnc)();
typedef const List<ImageSaveWidget *> (ImageSaveWidgetFnc)();

// Widget factories.
//
class ImageLoadWidgetFactory : public PluginFactory {
public:

  ~ImageLoadWidgetFactory();
  
  const List<ImageLoadWidget *> & pluginList() const { return _pluginList; }
  ImageLoadWidget * pluginCopy(const Str &);
  void pluginAdd(const List<ImageLoadWidget *> &);
  
protected:

  const Str pluginPrefix() const { return Str("djImageIo"); }
  bool init(void *);
  void del();
  
private:

  List<ImageLoadWidget *> _pluginList;
};

class ImageSaveWidgetFactory : public PluginFactory {
public:

  ~ImageSaveWidgetFactory();
  
  const List<ImageSaveWidget *> & pluginList() const { return _pluginList; }
  ImageSaveWidget * pluginCopy(const Str &);
  void pluginAdd(const List<ImageSaveWidget *> &);
  
protected:

  const Str pluginPrefix() const { return Str("djImageIo"); }
  bool init(void *);
  void del();
  
private:

  List<ImageSaveWidget *> _pluginList;
};

}

#endif
