/* $Id: menuitem.hg,v 1.6 2006/04/12 11:11:25 murrayc Exp $ */


/* menuitem.h
 * 
 * Copyright (C) 1998-2002 The gtkmm Development Team
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library 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
 * Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public
 * License along with this library; if not, write to the Free
 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */
 
#include <gtkmm/item.h>
#include <gtkmm/accelkey.h>
#include <gtkmm/accellabel.h>
_DEFS(gtkmm,gtk)
_PINCLUDE(gtkmm/private/item_p.h)


namespace Gtk
{

class Menu;
namespace Menu_Helpers { class Element; }

/** Child item for menus.
 * Handle highlighting, alignment, events and submenus.
 * As it derives from Gtk::Bin it can hold any valid child widget, altough only a few are really useful.
 * @ingroup Widgets
 * @ingroup Menus
 */
class MenuItem : public Item
{
  _CLASS_GTKOBJECT(MenuItem,GtkMenuItem,GTK_MENU_ITEM,Gtk::Item,GtkItem)
public:

  /// Create an empty menu item
  _CTOR_DEFAULT

  /// Create a menu item with widget
  explicit MenuItem(Widget& widget);

  /// Create a menu item with label
  explicit MenuItem(const Glib::ustring& label, bool mnemonic = false);

  _WRAP_METHOD(void set_submenu(Menu& submenu), gtk_menu_item_set_submenu)
  _WRAP_METHOD(Menu* get_submenu(), gtk_menu_item_get_submenu)
  _WRAP_METHOD(const Menu* get_submenu() const, gtk_menu_item_get_submenu, constversion)
  bool has_submenu() const;

  _WRAP_METHOD(void remove_submenu(), gtk_menu_item_remove_submenu)
  _WRAP_METHOD(void select(), gtk_menu_item_select)
  _WRAP_METHOD(void deselect(), gtk_menu_item_deselect)
  _WRAP_METHOD(void activate(), gtk_menu_item_activate)
  _WRAP_METHOD(void toggle_size_request(int& requisition), gtk_menu_item_toggle_size_request)
  _WRAP_METHOD(void toggle_size_allocate(int allocation), gtk_menu_item_toggle_size_allocate)
  _WRAP_METHOD(void set_right_justified(bool right_justified = true), gtk_menu_item_set_right_justified)
  _WRAP_METHOD(bool get_right_justified() const, gtk_menu_item_get_right_justified)
  _WRAP_METHOD(void set_accel_path(const Glib::ustring& accel_path), gtk_menu_item_set_accel_path)
  void unset_accel_path();

  _WRAP_SIGNAL(void activate(), "activate")
  _WRAP_SIGNAL(void activate_item(), "activate_item")
  _WRAP_SIGNAL(void toggle_size_request(int* requisition), "toggle_size_request")
  _WRAP_SIGNAL(void toggle_size_allocate(int allocation), "toggle_size_allocate")

  void accelerate(Window& window);

protected:

  void add_accel_label(const Glib::ustring& label, bool mnemonic = true);

  void set_accel_key(const AccelKey& accel_key);

private:

  friend class Menu_Helpers::Element;

  //This data is set by MenuElem, and will be used in on_realize(), in the call to add_accelerator().
  AccelKey accel_key_;
};

} /* namespace Gtk */

