#define DJ_DBG
#include <djApp.h>
#include <djWindow.h>
#include <djButtonWidget.h>

using namespace dj;

class myApp : public App {
public:

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

private:

  DJ_CALLBACK(myApp, buttonCallback, bool)
  DJ_CALLBACK(myApp, exitCallback, bool)

  Window * _window;
};

myApp::myApp(int & argc, char ** argv) :
  App("buttonWidget", argc, argv),
  _window(0)
{
  _window = new Window(name());
  PushButtonWidget * buttonWidget = new PushButtonWidget("Button");
  
  VLayout * layout = new VLayout(_window);
  layout->add(buttonWidget);
  layout->stretch(buttonWidget);
  
  _window->closeSig().set(this, exitCallback);
  buttonWidget->sig().set(this, buttonCallback);

  _window->size(_window->sizeHint());
  _window->show();
  
  valid(true);
}

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

void myApp::buttonCallback(bool) { print("value"); }
void myApp::exitCallback(bool) { exit(); }

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