/*------------------------------------------------------------------------------
 src/bin/djvlut/aboutDialog.cxx

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

//#define DJ_DBG
#include "aboutDialog.h"
#include "app.h"
#include <djLabelWidget.h>
#include <djButtonWidget.h>
#include <FL/Fl_Pixmap.H>
#include "goldfish.xpm"

namespace djvlut {

AboutDialog::AboutDialog() :
  DialogBase("About")
{
  // Widgets.
  //
  Widget * frameWidget = new Widget;
  frameWidget->box(FL_THIN_UP_BOX);
  Widget * dialogFrameWidget = new Widget;
  LabelWidget * textLabel = new LabelWidget(djvlutApp->aboutStr());
  textLabel->sizePolicy(STRETCH, STRETCH);
  textLabel->alignPolicy(CENTER, CENTER);
  _image = new Fl_Pixmap((const char **)goldfish_xpm);
  ImageLabelWidget * imageLabel = new ImageLabelWidget(_image);
  dialogFrameWidget->box(FL_THIN_UP_BOX);
  PushButtonWidget * closeWidget = new PushButtonWidget("Clos&e");

  // Layout.
  //
  VLayout * windowLayout = new VLayout(this);
  windowLayout->margin(0);
  windowLayout->spacing(0);
  windowLayout->add(frameWidget);
  windowLayout->stretch(frameWidget);
  HLayout * layout = new HLayout(frameWidget);
  layout->add(imageLabel);
  layout->add(textLabel);
  windowLayout->add(dialogFrameWidget);
  HLayout * dialogLayout = new HLayout(dialogFrameWidget);
  dialogLayout->stretchAdd();
  dialogLayout->add(closeWidget);
  
  // Initialize.
  //
  size(max(sizeHint(), dialogSize()));
  
  // Callbacks.
  //
  closeWidget->sig().set(this, closeCallback);
}

AboutDialog::~AboutDialog()
{
  delete _image;
}

void AboutDialog::closeCallback(bool)
{
  hide();
}

}
