// -*- c++ -*-
/*  Generated by gensig from toolbar.gen_h. DO NOT MODIFY!!! */
#ifndef GTKMM_TOOLBAR_HEADER
#define GTKMM_TOOLBAR_HEADER
/* $Id: toolbar.gen_h,v 1.42.2.2 1999/05/01 18:02:27 terop Exp $ */

/* toolbar.h
 * 
 * Copyright (C) 1998-1999 
 *
 * 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 <gtk--/container.h>
#include <gtk--/button.h>
#include <gtk--/togglebutton.h>
#include <gtk--/radiobutton.h>
#include <gtk--/tooltips.h>
#include <gtk--/pixmap.h>
#include <gtk--/label.h>
#include <gtk/gtktoolbar.h>

class ToolbarConnectorBase
{
protected:
  friend class Gtk_Toolbar;
  virtual void connectTo(Gtk_Button *) const = 0;
  ToolbarConnectorBase() {};
};


template <class T, class DT>
class ToolbarConnector : public ToolbarConnectorBase
{
public:
  ToolbarConnector(T *target_widget,
		   void (T::*target_method)(DT),
		   const DT &target_method_arg) :
    m_widget(target_widget),
    m_method(target_method),
    m_method_no_arg(0),
    m_method_arg(target_method_arg) {}

  ToolbarConnector(T *target_widget,
		   void (T::*target_method)()) :
    m_widget(target_widget),
    m_method(0),
    m_method_no_arg(target_method),
    m_method_arg(0) {}

protected:
  friend class Gtk_Toolbar;
  virtual void connectTo(Gtk_Button *m) const {

    if(Gtk_ToggleButton::isGtkToggleButton(m)) {
      Gtk_ToggleButton *tm = (Gtk_ToggleButton*)m;
      // should be a dynamic_cast<>
       
      if(m_method) {
	Connection_impl* s=new Slot0cb<T,DT>(m_widget,m_method,m_method_arg);
	tm->toggled.sender->insert_connection(s);
	gint conn=tm->toggled.sender->signal_connect(tm->toggled.signal_name, GtkSignalFunc(Slot0cb<T,DT>::callback),s);
	s->setgtkconnection(tm->toggled.sender->gtkobj(),conn);
      } else {
	Connection_impl* s=new Slot0<T>(m_widget,m_method_no_arg);
	tm->toggled.sender->insert_connection(s);
	gint conn=tm->toggled.sender->signal_connect(tm->toggled.signal_name, GtkSignalFunc(Slot0<T>::callback),s);
	s->setgtkconnection(tm->toggled.sender->gtkobj(),conn);
      }
    }
    else if(m_method) {
      Connection_impl* s=new Slot0cb<T,DT>(m_widget,m_method,m_method_arg);
      m->clicked.sender->insert_connection(s);
      gint conn=m->clicked.sender->signal_connect(m->clicked.signal_name, GtkSignalFunc(Slot0cb<T,DT>::callback),s);
      s->setgtkconnection(m->clicked.sender->gtkobj(),conn);
    } else {
      Connection_impl* s=new Slot0<T>(m_widget,m_method_no_arg);
      m->clicked.sender->insert_connection(s);
      gint conn=m->clicked.sender->signal_connect(m->clicked.signal_name, GtkSignalFunc(Slot0<T>::callback),s);
      s->setgtkconnection(m->clicked.sender->gtkobj(),conn);
    }
  }

private:
  T *m_widget;
  void (T::*m_method)(DT);
  void (T::*m_method_no_arg)();
  DT m_method_arg;
};



class Gtk_Toolbar_Class;
#line 101 "toolbar.gen_h"

typedef struct {
  GtkWidget *button;
  GtkWidget *icon;
  GtkWidget *label;
} Child;

class Toolbar_Child : public Gtk_Button
{
public:
  Toolbar_Child(Child *castitem);
  ~Toolbar_Child() { delete icon_; delete label_; }

protected:
  Gtk_Pixmap *icon_;
  Gtk_Label *label_;
};

class Gtk_Toolbar : public Gtk_Container
{
public:
protected:
  typedef Gtk_Toolbar_Class    CppClassType;
  typedef GtkToolbar           BaseObjectType;
  typedef GtkToolbarClass      BaseClassType;

  virtual void *get_parent_class();

private:
  friend CppClassType;
  static CppClassType toolbar_class; 
  GtkType get_type(); 

public:



  Gtk_Toolbar(GtkOrientation orientation = GTK_ORIENTATION_HORIZONTAL,
	      GtkToolbarStyle style = GTK_TOOLBAR_BOTH);
  Gtk_Toolbar(GtkToolbar *castitem);
  ~Gtk_Toolbar();

#ifdef GTKMM_CXX_HAVE_MEMBER_TEMPLATES

  //: All the *_item() and *_element() methods return allocated
  //  Gtk_Widgets.

  //: the "item" here is actually a button. Those should really be
  // named append_button, prepend_button and insert_button. They are
  // equivalent to the *_item() below, with 
  // child_type = GTK_TOOLBAR_CHILD_BUTTON
  template <class RECEIVER, class ARG_TYPE>
  Gtk_Widget* append_item(const _gtk_string &text, 
                          const _gtk_string &tooltip_text,
			  const _gtk_string &tooltip_private_text,
			  const Gtk_Pixmap &icon,
			  RECEIVER *receiver,
			  void (RECEIVER::*method)(ARG_TYPE),
			  ARG_TYPE user_data);

  template <class RECEIVER, class ARG_TYPE>
  Gtk_Widget* prepend_item(const _gtk_string &text, 
                           const _gtk_string &tooltip_text,
			   const _gtk_string &tooltip_private_text,
			   const Gtk_Pixmap &icon,
			   RECEIVER *receiver,
			   void (RECEIVER::*method)(ARG_TYPE),
			   ARG_TYPE user_data);

  template <class RECEIVER, class ARG_TYPE>
  Gtk_Widget* insert_item(const _gtk_string &text, 
                          const _gtk_string &tooltip_text,
			  const _gtk_string &tooltip_private_text,
			  const Gtk_Pixmap &icon,
			  RECEIVER *receiver,
			  void (RECEIVER::*method)(ARG_TYPE),
			  ARG_TYPE user_data,
			  gint position);

  //: These are slightly more restricted than their gtk counterparts :
  // you can't pass a widget, child_type has to be one of
  // GTK_TOOLBAR_CHILD_BUTTON, GTK_TOOLBAR_CHILD_TOGGLEBUTTON,
  // GTK_TOOLBAR_CHILD_RADIOBUTTON, GTK_TOOLBAR_CHILD_SPACE (consider
  // the *_space() methods for the latter)

  // With icon
  template <class RECEIVER, class ARG_TYPE>
  Gtk_Widget* append_element(GtkToolbarChildType child_type,
			     const _gtk_string &text,
			     const _gtk_string &tooltip_text,
			     const _gtk_string &tooltip_private_text,
			     const Gtk_Pixmap &icon,
			     RECEIVER *receiver,
			     void (RECEIVER::*method)(ARG_TYPE),
			     ARG_TYPE user_data);
  
  template <class RECEIVER, class ARG_TYPE>
  Gtk_Widget* prepend_element(GtkToolbarChildType child_type,
			      const _gtk_string &text,
			      const _gtk_string &tooltip_text,
			      const _gtk_string &tooltip_private_text,
			      const Gtk_Pixmap &icon,
			      RECEIVER *receiver,
			      void (RECEIVER::*method)(ARG_TYPE),
			      ARG_TYPE user_data);

  template <class RECEIVER, class ARG_TYPE>
  Gtk_Widget* insert_element(GtkToolbarChildType child_type,
			     const _gtk_string &text,
			     const _gtk_string &tooltip_text,
			     const _gtk_string &tooltip_private_text,
			     const Gtk_Pixmap &icon,
			     RECEIVER *receiver,
			     void (RECEIVER::*method)(ARG_TYPE),
			     ARG_TYPE user_data,
			     gint position);

  // Without icon
  template <class RECEIVER, class ARG_TYPE>
  Gtk_Widget* append_element(GtkToolbarChildType child_type,
			     const _gtk_string &text,
			     const _gtk_string &tooltip_text,
			     const _gtk_string &tooltip_private_text,
			     RECEIVER *receiver,
			     void (RECEIVER::*method)(ARG_TYPE),
			     ARG_TYPE user_data);
  
  template <class RECEIVER, class ARG_TYPE>
  Gtk_Widget* prepend_element(GtkToolbarChildType child_type,
			      const _gtk_string &text,
			      const _gtk_string &tooltip_text,
			      const _gtk_string &tooltip_private_text,
			      RECEIVER *receiver,
			      void (RECEIVER::*method)(ARG_TYPE),
			      ARG_TYPE user_data);

  template <class RECEIVER, class ARG_TYPE>
  Gtk_Widget* insert_element(GtkToolbarChildType child_type,
			     const _gtk_string &text,
			     const _gtk_string &tooltip_text,
			     const _gtk_string &tooltip_private_text,
			     RECEIVER *receiver,
			     void (RECEIVER::*method)(ARG_TYPE),
			     ARG_TYPE user_data,
			     gint position);


#endif

  //: Those are Gtk-- "originals" with no equivalents in the original
  //gtk+ API
  // With icon
  Gtk_Button* append_button(const _gtk_string &text,
			    const _gtk_string &tooltip_text,
			    const _gtk_string &tooltip_private_text,
			    const Gtk_Pixmap &icon,
			    const ToolbarConnectorBase &connector,
			    GtkToolbarChildType button_type = GTK_TOOLBAR_CHILD_BUTTON);
  
  Gtk_Button* prepend_button(const _gtk_string &text,
			     const _gtk_string &tooltip_text,
			     const _gtk_string &tooltip_private_text,
			     const Gtk_Pixmap &icon,
			     const ToolbarConnectorBase &connector,
			     GtkToolbarChildType button_type = GTK_TOOLBAR_CHILD_BUTTON);
  
  Gtk_Button* insert_button(const _gtk_string &text,
			    const _gtk_string &tooltip_text,
			    const _gtk_string &tooltip_private_text,
			    const Gtk_Pixmap &icon,
			    const ToolbarConnectorBase &connector,
			    gint position,
			    GtkToolbarChildType button_type = GTK_TOOLBAR_CHILD_BUTTON);

  // Without icon
  Gtk_Button* append_button(const _gtk_string &text,
			    const _gtk_string &tooltip_text,
			    const _gtk_string &tooltip_private_text,
			    const ToolbarConnectorBase &connector,
			    GtkToolbarChildType button_type = GTK_TOOLBAR_CHILD_BUTTON);
  
  Gtk_Button* prepend_button(const _gtk_string &text,
			     const _gtk_string &tooltip_text,
			     const _gtk_string &tooltip_private_text,
			     const ToolbarConnectorBase &connector,
			     GtkToolbarChildType button_type = GTK_TOOLBAR_CHILD_BUTTON);
  
  Gtk_Button* insert_button(const _gtk_string &text,
			    const _gtk_string &tooltip_text,
			    const _gtk_string &tooltip_private_text,
			    const ToolbarConnectorBase &connector,
			    gint position,
			    GtkToolbarChildType button_type = GTK_TOOLBAR_CHILD_BUTTON);

  void append_widget(const Gtk_Widget &widget,
		     const _gtk_string &tooltip_text = "",
		     const _gtk_string &tooltip_private_text = "");
  
  void prepend_widget(const Gtk_Widget &widget,
		      const _gtk_string &tooltip_text = "",
		      const _gtk_string &tooltip_private_text = "");
  
  void insert_widget(const Gtk_Widget &widget,
		     const _gtk_string &tooltip_text,
		     const _gtk_string &tooltip_private_text, gint position);

  void append_space();
  void prepend_space();
  void insert_space(gint position);

  GtkOrientation get_orientation() const
    {return gtkobj()->orientation;}
  void set_orientation(GtkOrientation orientation);

  GtkToolbarStyle get_style() const
    {return gtkobj()->style;}
  void set_style(GtkToolbarStyle style);

  gint get_space_size() const
    {return gtkobj()->space_size;}
  void set_space_size(gint space_size);

  void set_tooltips(bool enable);
#line 312 "toolbar.gen_h"
  void set_button_relief(GtkReliefStyle relief);
  GtkReliefStyle get_button_relief();

  void set_space_style(GtkToolbarSpaceStyle space_style);
#line 317 "toolbar.gen_h"

  Signal_proxy1<BaseObjectType,GtkOrientation> orientation_changed;
  Signal_proxy1<BaseObjectType,GtkToolbarStyle> style_changed;

protected:
  /* impl functions */
  virtual void orientation_changed_impl(GtkOrientation p1);
  virtual void style_changed_impl(GtkToolbarStyle p1);
public:
  GtkToolbar* gtkobj() { return GTK_TOOLBAR(gtkobject); }
  const GtkToolbar* gtkobj() const { return GTK_TOOLBAR(gtkobject); }
  static bool isGtkToolbar(Gtk_Object *checkcast);
#line 321 "toolbar.gen_h"


protected:
  //: This list is used to store the Gtk_Widgets constructed from the
  //: created items so they can be properly destroyed
  G_List<Gtk_Widget> *children_;
  
};


#ifdef GTKMM_CXX_HAVE_MEMBER_TEMPLATES

template <class RECEIVER, class ARG_TYPE>
Gtk_Widget* Gtk_Toolbar::append_item(const _gtk_string &text,
				     const _gtk_string &tooltip_text,
				     const _gtk_string &tooltip_private_text,
				     const Gtk_Pixmap &icon,
				     RECEIVER *receiver,
				     void (RECEIVER::*method)(ARG_TYPE),
				     ARG_TYPE user_data)
{
  return insert_item(text, tooltip_text,
		     tooltip_private_text,
		     icon, receiver, method, user_data,
		     gtkobj()->num_children);
}

template <class RECEIVER, class ARG_TYPE>
Gtk_Widget* Gtk_Toolbar::prepend_item(const _gtk_string &text,
				      const _gtk_string &tooltip_text,
				      const _gtk_string &tooltip_private_text,
				      const Gtk_Pixmap &icon,
				      RECEIVER *receiver,
				      void (RECEIVER::*method)(ARG_TYPE),
				      ARG_TYPE user_data)
{
  return insert_item(text, tooltip_text,
		     tooltip_private_text, 
		     icon, receiver, method, user_data, 0);
}

template <class RECEIVER, class ARG_TYPE>
Gtk_Widget* Gtk_Toolbar::insert_item(const _gtk_string &text,
				     const _gtk_string &tooltip_text,
				     const _gtk_string &tooltip_private_text,
				     const Gtk_Pixmap &icon,
				     RECEIVER *receiver,
				     void (RECEIVER::*method)(ARG_TYPE),
				     ARG_TYPE user_data,
				     gint position)
{
  return insert_element(GTK_TOOLBAR_CHILD_BUTTON,
			text, tooltip_text,
			tooltip_private_text, icon,
			receiver, method, user_data, position);
}



template <class RECEIVER, class ARG_TYPE>
Gtk_Widget* Gtk_Toolbar::append_element(GtkToolbarChildType child_typex,
					const _gtk_string &text,
					const _gtk_string &tooltip_text,
					const _gtk_string &tooltip_private_text,
					const Gtk_Pixmap &icon,
					RECEIVER *receiver,
					void (RECEIVER::*method)(ARG_TYPE),
					ARG_TYPE user_data)
{
  return insert_element(child_typex,
			text, tooltip_text,
			tooltip_private_text, icon,
			receiver, method, user_data,
			gtkobj()->num_children);
}

template <class RECEIVER, class ARG_TYPE>
Gtk_Widget* Gtk_Toolbar::prepend_element(GtkToolbarChildType child_typex,
					 const _gtk_string &text,
					 const _gtk_string &tooltip_text,
					 const _gtk_string &tooltip_private_text,
					 const Gtk_Pixmap &icon,
					 RECEIVER *receiver,
					 void (RECEIVER::*method)(ARG_TYPE),
					 ARG_TYPE user_data)
{
  return insert_element(child_typex,
			text, tooltip_text,
			tooltip_private_text, icon,
			receiver, method, user_data, 0);
}

template <class RECEIVER, class ARG_TYPE>
Gtk_Widget*
Gtk_Toolbar::insert_element(GtkToolbarChildType child_typex,
			    const _gtk_string &text,
			    const _gtk_string &tooltip_text,
			    const _gtk_string &tooltip_private_text,
			    const Gtk_Pixmap &icon,
			    RECEIVER *receiver,
			    void (RECEIVER::*method)(ARG_TYPE),
			    ARG_TYPE user_data,
			    gint position)
{
  Gtk_Widget *child;

  g_return_val_if_fail(child_typex != GTK_TOOLBAR_CHILD_WIDGET, 0);
  
  child = new Gtk_Widget(gtk_toolbar_insert_element(gtkobj(), // GtkToolbar *
						    child_typex, // GtkToolbarChildType
						    0, // no widget 
						    text.gc_str(), // const char *
						    tooltip_text.gc_str(), // const char *
						    tooltip_private_text.gc_str(), // const char *
						    GTK_WIDGET(icon.gtkobj()), // GtkWidget *
						    0, 0, position)); // GtkSignalFunc, gpointer, gint
  
  if(Gtk_Button::isGtkButton(child)) {
    Gtk_Button *bchild = new Gtk_Button(GTK_BUTTON(child->gtkobj()));
    connect_to_method(bchild->clicked, receiver, method, user_data);
    delete child;
    // insert it in our own children list
    children_->insert(bchild, position);
    return bchild;
  }
  
  children_->insert(child, position);
  return child;
}


template <class RECEIVER, class ARG_TYPE>
Gtk_Widget* Gtk_Toolbar::append_element(GtkToolbarChildType child_typex,
					const _gtk_string &text,
					const _gtk_string &tooltip_text,
					const _gtk_string &tooltip_private_text,
					RECEIVER *receiver,
					void (RECEIVER::*method)(ARG_TYPE),
					ARG_TYPE user_data)
{
  return insert_element(child_typex,
			text, tooltip_text,
			tooltip_private_text,
			receiver, method, user_data,
			gtkobj()->num_children);
}

template <class RECEIVER, class ARG_TYPE>
Gtk_Widget* Gtk_Toolbar::prepend_element(GtkToolbarChildType child_typex,
					 const _gtk_string &text,
					 const _gtk_string &tooltip_text,
					 const _gtk_string &tooltip_private_text,
					 RECEIVER *receiver,
					 void (RECEIVER::*method)(ARG_TYPE),
					 ARG_TYPE user_data)
{
  return insert_element(child_typex,
			text, tooltip_text,
			tooltip_private_text, 
			receiver, method, user_data, 0);
}

template <class RECEIVER, class ARG_TYPE>
Gtk_Widget* Gtk_Toolbar::insert_element(GtkToolbarChildType child_typex,
					const _gtk_string &text, const _gtk_string &tooltip_text,
					const _gtk_string &tooltip_private_text,
					RECEIVER *receiver,
					void (RECEIVER::*method)(ARG_TYPE),
					ARG_TYPE user_data,
					gint position)
{
  Gtk_Widget *child;

  g_return_val_if_fail(child_typex != GTK_TOOLBAR_CHILD_WIDGET, 0);
  
  child = new Gtk_Widget(gtk_toolbar_insert_element(gtkobj(),
						    child_typex,
						    0, // no widget
						    text.gc_str(),
						    tooltip_text.gc_str(),
						    tooltip_private_text.gc_str(),
						    0, // no icon
						    0, 0, position));
  
  if(Gtk_Button::isGtkButton(child)) {
    Gtk_Button *bchild = new Gtk_Button(GTK_BUTTON(child->gtkobj()));
    connect_to_method(bchild->clicked, receiver, method, user_data);
    delete child;
    // insert it in our own children list
    children_->insert(bchild, position);
    return bchild;
  }
  
  children_->insert(child, position);
  return child;
}


#endif


#endif
