/* 
 * © 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 _WF_FORM_H_
#define _WF_FORM_H_

#include "mforms/mforms.h"
#include "mforms/form.h"

#include "wf_button.h"
#include "wf_view.h"
#include "wf_mforms.h"

using namespace System;
using namespace Drawing;
using namespace Windows::Forms;

//#pragma make_public(::mforms::Form)

namespace MySQL {
  namespace Forms {

    public ref class FormImpl : public ViewImpl
    {
    protected:
      static bool create(::mforms::Form *self, ::mforms::Form *owner, ::mforms::FormFlag flag);
      static void set_title(::mforms::Form *self, const std::string &title);
      static void show_modal(::mforms::Form *self, ::mforms::Button *accept, ::mforms::Button *cancel);
      static bool run_modal(::mforms::Form *self, ::mforms::Button *accept,::mforms::Button *cancel);
      static void close(::mforms::Form *self);
      static void set_content(::mforms::Form *self, ::mforms::View *view);
      static void disposed(System::Object ^sender, System::EventArgs ^e);
      static void center(::mforms::Form *self);
      static void flush_events(::mforms::Form *self);
    public:
      FormImpl(::mforms::Form *form, ::mforms::Form *owner, ::mforms::FormFlag flag);

      void center();
      void flush_events();

      static void init(Manager ^mgr)
      {
        ::mforms::ControlFactory *f= ::mforms::ControlFactory::get_instance();

        DEF_CALLBACK3(bool, ::mforms::Form*, ::mforms::Form*, ::mforms::FormFlag, mgr, f->_form_impl, FormImpl, create);
        DEF_CALLBACK1(void, ::mforms::Form*, mgr, f->_form_impl, FormImpl, close);
        DEF_CALLBACK2(void, ::mforms::Form*, ::mforms::View*, mgr, f->_form_impl, FormImpl, set_content);
        DEF_CALLBACK2(void, ::mforms::Form*, const std::string&, mgr, f->_form_impl, FormImpl, set_title);
        DEF_CALLBACK3(bool, ::mforms::Form*, ::mforms::Button*, ::mforms::Button*, mgr, f->_form_impl, FormImpl, run_modal);
        DEF_CALLBACK3(void, ::mforms::Form*, ::mforms::Button*, ::mforms::Button*, mgr, f->_form_impl, FormImpl, show_modal);
        DEF_CALLBACK1(void, ::mforms::Form*, mgr, f->_form_impl, FormImpl, center);
        DEF_CALLBACK1(void, ::mforms::Form*, mgr, f->_form_impl, FormImpl, flush_events);
      }
    };

  };
};

#endif
