/* 
 * © 2008-2009 Sun Microsystems, Inc.
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 * Boston, MA 02111-1307, USA.
 */
#ifndef _LF_IMAGEBOX_H_
#define _LF_IMAGEBOX_H_

#include "mforms/label.h"

#include "lf_view.h"

namespace mforms {
namespace gtk {

class ImageBoxImpl : public ViewImpl
{
protected:
  Gtk::Image *_image;
  virtual Gtk::Widget *get_outer() const { return _image; }

  ImageBoxImpl(::mforms::ImageBox *self)
    : ViewImpl(self)
  {
    _image = Gtk::manage(new Gtk::Image());
    _image->set_alignment(0, 0.5);

    setup();
  }

  static bool create(::mforms::ImageBox *self)
  {
    return new ImageBoxImpl(self) != 0;
  }

  static void set_image(::mforms::ImageBox *self, const std::string &file)
  {
    ImageBoxImpl* image = self->get_data<ImageBoxImpl>();

    if (image)
    {
      image->_image->set(file);
    }
  }

 public:
  static void init()
  {
    ::mforms::ControlFactory *f = ::mforms::ControlFactory::get_instance();

    f->_imagebox_impl.create         = &ImageBoxImpl::create;
    f->_imagebox_impl.set_image      = &ImageBoxImpl::set_image;
  }
};

};
};


#endif /* _LF_IMAGEBOX_H_ */
