/**************************************************************************

    This file is part of explorer95, a file manager for fvwm95.
    Copyright (C) 1996, 1997 David Barth, Hector Peraza.

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program 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 General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

**************************************************************************/

#include <xclass/utils.h>
#include <xclass/ODimension.h>

#include "OXNewWidgets.h"


//-------------------------------------------------------------------

void OXToolBar::AddButtons(_tb_data *tb_data, OXMainFrame *parent) {
  int i, spacing = 0;
    
  for (i=0; tb_data[i].pixmap_name != NULL; ++i) {
    OXPictureButton *button;
    
    if (strlen(tb_data[i].pixmap_name) == 0) {
      spacing = 8;
      continue;
    }
    const OPicture *buttonpic = _client->GetPicture(tb_data[i].pixmap_name,
                                                    tb_data[i].pixmap_data);
    if (!buttonpic)
      FatalError("Bad or missing inlined pixmap: %s", tb_data[i].pixmap_name);
    button = new OXPictureButton(this, buttonpic, tb_data[i].id);
    AddFrame(button, new OLayoutHints(LHINTS_TOP | LHINTS_LEFT,
                                      spacing, 0, 0, 0));
    button->Associate(parent);

    button->AllowStayDown(tb_data[i].type);
    button->SetType(tb_data[i].type);
    button->SetTip(tb_data[i].tip_text);
    tb_data[i].button = button;
    spacing = 0;
  }
}
