//#define DJ_DBG
#include <djColorWidget.h>
#include <djWindow.h>
#include <djApp.h>

using namespace dj;

class myApp : public App {
public:

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

private:

  DJ_CALLBACK(myApp, widgetCallback, const Color &)
  DJ_CALLBACK(myApp, exitCallback, bool)

  Window * _window;
  ColorWidget * _widget;
};

myApp::myApp(int & argc, char ** argv) :
  App("colorWidget", argc, argv),
  _window(0)
{
  _window = new Window(name());
  _widget = new ColorWidget;
  
  VLayout * layout = new VLayout(_window);
  layout->add(_widget);
  
  _window->closeSig().set(this, exitCallback);
  _widget->sig().set(this, widgetCallback);
  
  _window->size(_window->sizeHint());
  _window->show();
  
  valid(true);
}

myApp::~myApp()
{
  if (_window) delete _window;
}

void myApp::widgetCallback(const Color & in)
{
  djApp->print(Str("value = %1").arg(deflateStr(in)));
}

void myApp::exitCallback(bool) { exit(); }

int main(int argc, char ** argv)
{
  DJ_DBG_LOG();
  return myApp(argc, argv).exec();
}
