Logo Search packages:      
Sourcecode: ardour version File versions  Download package

toolbar.cc

// -*- c++ -*-
//  Generated by gtkmmproc from ./../toolbar.gen_h -- DO NOT MODIFY!
#include <gtk--/toolbar.h>
#include <gtk--/private/toolbar_p.h>
#include <glib.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>
namespace Gtk
{

Toolbar::Toolbar(GtkOrientation orientation, GtkToolbarStyle style)
  : Container((GtkContainer*)(gtk_object_new(get_type(),0)))
{
  initialize_class();
  GtkToolbar *toolbar = gtkobj();
  toolbar->orientation = orientation;
  toolbar->style = style;
}

/*********************************************************************
***** Item classes (This should be an easy and cool interface)
*********************************************************************/

Toolbar_Helpers::Element::Element(const Element& p)
   :type_(p.type_),widget_(p.widget_),text_(p.text_),
    tooltip_text_(p.tooltip_text_),
    tooltip_private_text_(p.tooltip_private_text_),
    content_(p.content_),callback_(p.callback_), group_(0)
  {}

Toolbar_Helpers::Element::Element(GtkToolbarChildType type,
                Widget*         widget,
                const nstring   &text,
                const nstring   &tooltip_text,
                const nstring   &tooltip_private_text,
                Widget*         content,
                SigC::Slot0<void>         callback)
   :type_(type),widget_(widget),text_(text),
    tooltip_text_(tooltip_text),
    tooltip_private_text_(tooltip_private_text),
    content_(content),callback_(callback),group_(0)
  {}

Toolbar_Helpers::Element::Element
                        (Widget          &w,
                         const nstring  &tooltip_text,
                         const nstring  &tooltip_private_text)
    :type_(GTK_TOOLBAR_CHILD_WIDGET),widget_(&w),text_((char*)0),
     tooltip_text_(tooltip_text),
     tooltip_private_text_(tooltip_private_text),
     content_(0),callback_(0),group_(0)
  {}

Toolbar_Helpers::Space::Space()
    :Element(GTK_TOOLBAR_CHILD_SPACE,0,(char*)0,
             (char*)0,(char*)0,0,0)
  {}

Toolbar_Helpers::ButtonElem::ButtonElem
                        (const nstring  &text,
                         Widget          &content,
                         SigC::Slot0<void>         callback,
                         const nstring  &tooltip_text,
                         const nstring  &tooltip_private_text)
    :Element(GTK_TOOLBAR_CHILD_BUTTON,0,text,
             tooltip_text,tooltip_private_text,&content,callback)
  {}

Toolbar_Helpers::ButtonElem::ButtonElem
                        (const nstring  &text,
                         SigC::Slot0<void>         callback,
                         const nstring  &tooltip_text,
                         const nstring  &tooltip_private_text)
    :Element(GTK_TOOLBAR_CHILD_BUTTON,0,text,
             tooltip_text,tooltip_private_text,0,callback)
  {}

Toolbar_Helpers::ButtonElem::ButtonElem
                        (Widget          &content,
                         SigC::Slot0<void>         callback,
                         const nstring  &tooltip_text,
                         const nstring  &tooltip_private_text)
    :Element(GTK_TOOLBAR_CHILD_BUTTON,0,0,
             tooltip_text,tooltip_private_text,&content,callback)
  {}


Toolbar_Helpers::ToggleElem::ToggleElem
                        (const nstring  &text,
                         Widget          &content,
                         SigC::Slot0<void>         callback,
                         const nstring  &tooltip_text,
                         const nstring  &tooltip_private_text)
    :Element(GTK_TOOLBAR_CHILD_TOGGLEBUTTON,0,text,
             tooltip_text,tooltip_private_text,&content,callback)
  {}

Toolbar_Helpers::ToggleElem::ToggleElem
                        (const nstring  &text,
                         SigC::Slot0<void>         callback,
                         const nstring  &tooltip_text,
                         const nstring  &tooltip_private_text)
    :Element(GTK_TOOLBAR_CHILD_TOGGLEBUTTON,0,text,
             tooltip_text,tooltip_private_text,0,callback)
  {}

Toolbar_Helpers::ToggleElem::ToggleElem
                        (Widget          &content,
                         SigC::Slot0<void>         callback,
                         const nstring  &tooltip_text,
                         const nstring  &tooltip_private_text)
    :Element(GTK_TOOLBAR_CHILD_TOGGLEBUTTON,0,0,
             tooltip_text,tooltip_private_text,&content,callback)
  {}


Toolbar_Helpers::RadioElem::RadioElem
                        (RadioButton::Group &group,
                         const nstring &text,
                         Widget         &content,
                         SigC::Slot0<void>        callback,
                         const nstring &tooltip_text,
                         const nstring &tooltip_private_text)
    :Element(GTK_TOOLBAR_CHILD_RADIOBUTTON,0,text,
             tooltip_text,tooltip_private_text,&content,callback)
  { group_=&group; }

Toolbar_Helpers::RadioElem::RadioElem
                        (RadioButton::Group &group,
                         const nstring &text,
                         SigC::Slot0<void>        callback,
                         const nstring &tooltip_text,
                         const nstring &tooltip_private_text)
    :Element(GTK_TOOLBAR_CHILD_RADIOBUTTON,0,text,
             tooltip_text,tooltip_private_text,0,callback)
  { group_=&group; }

Toolbar_Helpers::RadioElem::RadioElem
                        (RadioButton::Group &group,
                         Widget        &content,
                         SigC::Slot0<void>        callback,
                         const nstring &tooltip_text,
                         const nstring &tooltip_private_text)
    :Element(GTK_TOOLBAR_CHILD_RADIOBUTTON,0,0,
             tooltip_text,tooltip_private_text,&content,callback)
  { group_=&group; }


/*********************************************************************
***** List properties
*********************************************************************/
typedef G_List_Iterator<Toolbar_Helpers::Tool*> tool_iterator;

tool_iterator Toolbar_Helpers::ToolList::insert(tool_iterator position,const Element& e)
  {
    gint pos=parent_->gtkobj()->num_children;

    // locate the items desired position
    if (position.node)
      pos=g_list_position(glist(),position.node);

    // give item to gtk+
    Widget* w=wrap(gtk_toolbar_insert_element(
                               parent_->gtkobj(),
                               e.type_,
                               ((e.widget_)?e.widget_->gtkobj():0),
                               e.text_.gc_str(),
                               e.tooltip_text_.gc_str(),
                               e.tooltip_private_text_.gc_str(),
                               ((e.content_)?e.content_->gtkobj():0),
                               0,
                               0,pos));

    if (e.group_&&w)
      {
        RadioButton* rb=dynamic_cast<RadioButton*>(w);
        rb->set_group(*e.group_);
        *(e.group_)=rb->group();
      }

    // connect slot
    if (e.callback_&&Button::isA(w))
      dynamic_cast<Button*>(w)->clicked.connect(e.callback_);

    // return the right iterator
    if (pos==0)
      return begin();
    if (!position.node)
      return --end();
    return --position;
  }


tool_iterator Toolbar_Helpers::ToolList::erase(tool_iterator position)
  {
    if (!position.node) return end();
    iterator next=position;
    next++;

    if ((*position)->get_type()==GTK_TOOLBAR_CHILD_SPACE)
      {
        // gtk+ lacks this functionality. Good luck!
        parent_->gtkobj()->children=
          g_list_remove_link(glist(),position.node);
        g_list_free_1(position.node);
        if (parent_->is_visible())
          parent_->queue_resize();
        return next;
      }

    gtk_container_remove(parent_->Container::gtkobj(),
        (*position)->get_widget()->gtkobj());

    return next;
  }

void Toolbar_Helpers::ToolList::remove(const_reference t)
  {
    erase(find(t));
  }

void Toolbar_Helpers::ToolList::remove(Widget& w)
  {
   gtk_container_remove(parent_->Container::gtkobj(),w.gtkobj());
  }

Widget* Toolbar_Helpers::Tool::get_widget()
  {return wrap(((GtkToolbarChild*)this)->widget);}
Widget* Toolbar_Helpers::Tool::get_content()
  {return wrap(((GtkToolbarChild*)this)->icon);}
Label* Toolbar_Helpers::Tool::get_label()
  {return wrap(GTK_LABEL(((GtkToolbarChild*)this)->label));}

}

namespace Gtk {
Gtk::Toolbar *wrap (GtkToolbar *o)
  {
    return static_cast<Gtk::Toolbar *> (Gtk::wrap_auto ((GtkObject *) (o)));
  }
}

namespace Gtk {
Toolbar_Class Toolbar::toolbar_class = {0};

Object* Toolbar_Class::wrap_new(GtkObject* o)
  {
    Object* cpp=manage(new Toolbar((GtkToolbar*)(o)));
    return cpp;
  }

bool Toolbar::isA( Object *checkcast)
  {
    return GTK_IS_TOOLBAR(checkcast->gtkobj());
  }

GtkType Toolbar::get_type()
  {
    return toolbar_class.get_type();
  }

GtkType Toolbar_Class::get_type()
  {
    if (!type)
      {
        CppClassParent::CppObjectType::get_type();
        GtkTypeInfo info =
          {
            "Gtk__Toolbar",
            sizeof(BaseObjectType),
            sizeof(BaseClassType),
            (GtkClassInitFunc) class_init_function,
            (GtkObjectInitFunc) object_init_function,
            /* reserved_1 */ NULL,
            /* reserved_2 */ NULL,
            /*base_class_init_func */ (GtkClassInitFunc) NULL
          };
        type=gtk_type_unique(gtk_toolbar_get_type(), &info);
      }
    return type;
  }

const char* const Toolbar::signal_names[]={
   "orientation_changed",
   "style_changed",
   0};

void Toolbar::initialize_class()
  {

     toolbar_self=this;

  }

void Toolbar_Class::class_init_function(GtkToolbarClass *klass)
  {
    CppClassParent::class_init_function((BaseClassParent*)klass);
    klass->orientation_changed=orientation_changed_callback;
    klass->style_changed=style_changed_callback;
  }

void Toolbar_Class::object_init_function(GtkToolbar *)
  {}

}

Gtk::Toolbar_Helpers::ToolList::iterator Gtk::Toolbar_Helpers::ToolList::find(const_reference w)
{
  iterator i=begin();
  for (i=begin();i!=end()&&*i!=w;i++);
  return i;
}

Gtk::Toolbar_Helpers::ToolList::iterator Gtk::Toolbar_Helpers::ToolList::find(Widget& w)
{
  iterator i;
  for (i=begin();i!=end()&&(*i)->get_widget()!=&w;i++);
  return i;
}

Gtk::Toolbar_Helpers::ToolList::value_type Gtk::Toolbar_Helpers::ToolList::operator[](size_type l) const
          { size_type j; iterator i; for (i=begin(),j=0;i!=end(),j<l;++i,++j);
            return (*i);
          }

GList*& Gtk::Toolbar_Helpers::ToolList::glist() const
{ return parent_->gtkobj()->children; }

Gtk::Toolbar_Helpers::ToolList::iterator Gtk::Toolbar_Helpers::ToolList::begin_() const
{return iterator(glist(),glist());}

Gtk::Toolbar_Helpers::ToolList::iterator Gtk::Toolbar_Helpers::ToolList::end_() const
{return iterator(glist(),(GList*)0);}

Gtk::Toolbar_Helpers::ToolList::size_type Gtk::Toolbar_Helpers::ToolList::size() const
  { return g_list_length(glist()); }

void Gtk::Toolbar_Helpers::ToolList::clear()
{ erase(begin(),end()); }

void Gtk::Toolbar_Helpers::ToolList::erase(iterator start, iterator stop)
{ while(start != stop) start=erase(start); }


Gtk::Toolbar::Toolbar(GtkToolbar *castitem)
  :     Gtk::Container((GtkContainer*)(castitem))
  {
    initialize_class();
  }

Gtk::Toolbar::~Toolbar() { destroy_(); }

void Gtk::Toolbar::set_orientation(GtkOrientation orientation)
  {
    gtk_toolbar_set_orientation(gtkobj(),orientation);
  }

void Gtk::Toolbar::set_style(GtkToolbarStyle style)
  {
    gtk_toolbar_set_style(gtkobj(),style);
  }

void Gtk::Toolbar::set_space_size(gint space_size)
  {
    gtk_toolbar_set_space_size(gtkobj(),space_size);
  }

void Gtk::Toolbar::set_space_style(GtkToolbarSpaceStyle space_style)
  {
    gtk_toolbar_set_space_style(gtkobj(),space_style);
  }

void Gtk::Toolbar::set_tooltips(bool enable)
  {
    gtk_toolbar_set_tooltips(gtkobj(),enable);
  }

void Gtk::Toolbar::set_button_relief(GtkReliefStyle relief)
  {
    gtk_toolbar_set_button_relief(gtkobj(),relief);
  }

void Gtk::Toolbar_Class::orientation_changed_callback(GtkToolbar* o_,GtkOrientation p0)
  {
    CppObjectType *obj=
      static_cast<CppObjectType *>(static_cast<Gtk::Object *>(
        gtk_object_get_data_by_id((GtkObject*)o_,Gtk::quark_)));

    if (obj)
      obj->orientation_changed_impl(p0);
    else
      {
        BaseClassType* base=
          static_cast<BaseClassType*>(
            gtk_type_parent_class(((GtkObject*)o_)->klass->type));
        if (base->orientation_changed)
          (base->orientation_changed)(o_,p0);
      }

  }

void Gtk::Toolbar::orientation_changed_impl(GtkOrientation p0)
  {
    BaseClassType* base=
      static_cast<BaseClassType*>(
        gtk_type_parent_class(gtkobject->klass->type));
    if (base->orientation_changed)
      (base->orientation_changed)(gtkobj(),p0);

  }

void Gtk::Toolbar_Class::style_changed_callback(GtkToolbar* o_,GtkToolbarStyle p0)
  {
    CppObjectType *obj=
      static_cast<CppObjectType *>(static_cast<Gtk::Object *>(
        gtk_object_get_data_by_id((GtkObject*)o_,Gtk::quark_)));

    if (obj)
      obj->style_changed_impl(p0);
    else
      {
        BaseClassType* base=
          static_cast<BaseClassType*>(
            gtk_type_parent_class(((GtkObject*)o_)->klass->type));
        if (base->style_changed)
          (base->style_changed)(o_,p0);
      }

  }

void Gtk::Toolbar::style_changed_impl(GtkToolbarStyle p0)
  {
    BaseClassType* base=
      static_cast<BaseClassType*>(
        gtk_type_parent_class(gtkobject->klass->type));
    if (base->style_changed)
      (base->style_changed)(gtkobj(),p0);

  }

GtkOrientation Gtk::Toolbar::get_orientation() const
  { return gtkobj()->orientation; }

GtkToolbarStyle Gtk::Toolbar::get_style() const
  { return gtkobj()->style; }

gint Gtk::Toolbar::get_space_size() const
  { return gtkobj()->space_size; }

GtkToolbarSpaceStyle Gtk::Toolbar::get_space_style() const
  { return gtkobj()->space_style; }

GtkReliefStyle Gtk::Toolbar::get_button_relief() const
  { return gtkobj()->relief; }

Generated by  Doxygen 1.6.0   Back to index