/* 
 * © 2007-2008 MySQL AB, 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 _UI_FORM_H_
#define _UI_FORM_H_

#include "wbpublic_public_interface.h"
#include <sigc++/sigc++.h>
#include <vector>
#include <string>


namespace bec {

class Clipboard;


 
enum MenuItemType 
{
  MenuAction,
  MenuSeparator,
  MenuCascade,
  MenuCheck,
  MenuRadio,
  MenuUnavailable
};

struct WBPUBLICBACKEND_PUBLIC_FUNC MenuItem
{
  std::string oid;
  std::string caption;
  std::string shortcut;
  std::string name;
  MenuItemType type;

  bool enabled;
  bool checked;

  MenuItem() : type(MenuAction), enabled(true), checked(false) {}
};
typedef std::vector<MenuItem> MenuItemList;


/** Base class for application forms.
 * 
 * This is the base class for application windows or panel backends that can 
 * receive focus and contain a workarea in the application (eg: canvas, overview panel,
 * query pages etc). It provides some virtual methods for common editing operations. 
 * 
 * @ingroup begrt
 */ 
class WBPUBLICBACKEND_PUBLIC_FUNC UIForm : public sigc::trackable
{

public:
  UIForm();
  virtual ~UIForm();// {}

  void set_owner_data(void *data);// { _owner_data= data; }
  void *get_owner_data();// { return _owner_data; }

  void set_frontend_data(void *data);
  void *get_frontend_data();

  virtual bool is_main_form();// { return false; }
  virtual std::string get_form_context_name() const= 0;

  // target description for cuy/copy/delete menu items and for paste, after a copy is made
  virtual std::string get_edit_target_name();// { return ""; }

  virtual bool can_cut(/*Clipboard *clip*/);// { return can_copy() && can_delete(); }
  virtual bool can_copy(/*Clipboard *clip*/);// { return false; }
  virtual bool can_paste(/*Clipboard *clip*/);// { return false; }
  virtual bool can_delete();// { return false; }
  virtual bool can_select_all();

  virtual void cut(/*Clipboard *clip*/);// {}
  virtual void copy(/*Clipboard *clip*/);// {}
  virtual void paste(/*Clipboard *clip*/);// {}
  virtual void delete_selection();// {}
  virtual void select_all();
  
  //unused? void set_refresh_ui_callback(const sigc::slot<void> &cb);

protected:
  //sigc::slot<void> _refresh_ui;

  void *_owner_data;
  void *_frontend_data;

public:
  sigc::slot<void> slot_destroyed;
};


};

#ifdef _WIN32
#pragma make_public(bec::MenuItem)
#endif

#endif /* _UI_FORM_H_ */
