#include <djFileIo.h>
#include <djImage.h>
#include <djWidget.h>
#include <djApp.h>
#include <FL/Fl_Gl_Window.H>

using namespace dj;

class DpxLoad {
public:

  DpxLoad();

  bool open(const Str &);
  const uint8_t * data() const { return _f.mmapP(); }
  const Vec2i & size() const { return _size; }

private:
  FileIo _f;
  Vec2i _size;
};

class ImageWidget : public Fl_Gl_Window, public WidgetBase {
public:

  ImageWidget();

  void set(const uint8_t *, const Vec2i &);

  void resize(int x, int y, int w, int h);
  int visible() const;
  void draw();
  
private:
  const uint8_t * _data;
  Vec2i _size;
};

class myApp : public App {
public:

  myApp(int & argc, char ** argv);

protected:

  DJ_FL_CALLBACK(myApp, timerCallback)

  StrList _input;
  int _frame;
  DpxLoad _load;
  Timer _timer;
  int _timerCount;
  Window * _window;
  ImageWidget * _widget;
};
