ToolBox.cpp

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (c) 2004 Werner Mayer <wmayer[at]users.sourceforge.net>     *
00003  *                                                                         *
00004  *   This file is part of the FreeCAD CAx development system.              *
00005  *                                                                         *
00006  *   This library is free software; you can redistribute it and/or         *
00007  *   modify it under the terms of the GNU Library General Public           *
00008  *   License as published by the Free Software Foundation; either          *
00009  *   version 2 of the License, or (at your option) any later version.      *
00010  *                                                                         *
00011  *   This library  is distributed in the hope that it will be useful,      *
00012  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00013  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00014  *   GNU Library General Public License for more details.                  *
00015  *                                                                         *
00016  *   You should have received a copy of the GNU Library General Public     *
00017  *   License along with this library; see the file COPYING.LIB. If not,    *
00018  *   write to the Free Software Foundation, Inc., 59 Temple Place,         *
00019  *   Suite 330, Boston, MA  02111-1307, USA                                *
00020  *                                                                         *
00021  ***************************************************************************/
00022 
00023 
00024 #include "PreCompiled.h"
00025 #ifndef _PreComp_
00026 # include <QEvent>
00027 # include <QGridLayout>
00028 # include <QToolBox>
00029 #endif
00030 
00031 #include "ToolBox.h"
00032 
00033 using namespace Gui::DockWnd;
00034 
00035 
00039 ToolBox::ToolBox( QWidget *parent )
00040   : QWidget(parent)
00041 {
00042   _pToolBox = new QToolBox( this );
00043   connect( _pToolBox, SIGNAL( currentChanged(int) ), this, SIGNAL( currentChanged(int) ) );
00044 
00045   QGridLayout* pGrid = new QGridLayout(this);
00046   pGrid->addWidget(_pToolBox, 0, 0);
00047 }
00048 
00049 ToolBox::~ToolBox()
00050 {
00051   delete _pToolBox;
00052 }
00053 
00058 int ToolBox::addItem ( QWidget * w, const QString & label )
00059 {
00060   return _pToolBox->addItem( w, label );
00061 }
00062 
00067 int ToolBox::addItem ( QWidget * item, const QIcon & iconSet, const QString & label )
00068 {
00069   return _pToolBox->addItem( item, iconSet, label );
00070 }
00071 
00078 int ToolBox::insertItem ( int index, QWidget * item, const QString & label )
00079 {
00080   return _pToolBox->insertItem( index, item, label );
00081 }
00082 
00088 int ToolBox::insertItem ( int index, QWidget * item, const QIcon & iconSet, const QString & label )
00089 {
00090   return _pToolBox->insertItem( index, item, iconSet, label );
00091 }
00092 
00097 void ToolBox::removeItem ( int index )
00098 {
00099   _pToolBox->removeItem( index );
00100 }
00101 
00105 void ToolBox::setItemEnabled ( int index, bool enabled )
00106 {
00107   _pToolBox->setItemEnabled( index, enabled );
00108 }
00109 
00113 bool ToolBox::isItemEnabled ( int index ) const
00114 {
00115   return _pToolBox->isItemEnabled( index );
00116 }
00117 
00121 void ToolBox::setItemText ( int index, const QString & label )
00122 {
00123   _pToolBox->setItemText( index, label );
00124 }
00125 
00129 QString ToolBox::itemText ( int index ) const
00130 {
00131   return _pToolBox->itemText( index );
00132 }
00133 
00137 void ToolBox::setItemIcon ( int index, const QIcon & iconSet )
00138 {
00139   _pToolBox->setItemIcon( index, iconSet );
00140 }
00141 
00145 QIcon ToolBox::itemIcon ( int index ) const
00146 {
00147   return _pToolBox->itemIcon( index );
00148 }
00149 
00153 void ToolBox::setItemToolTip ( int index, const QString & toolTip )
00154 {
00155   _pToolBox->setItemToolTip( index, toolTip );
00156 }
00157 
00161 QString ToolBox::itemToolTip ( int index ) const
00162 {
00163   return _pToolBox->itemToolTip( index );
00164 }
00165 
00169 QWidget * ToolBox::currentWidget () const
00170 {
00171   return _pToolBox->currentWidget();
00172 }
00173 
00177 void ToolBox::setCurrentWidget ( QWidget * item )
00178 {
00179   _pToolBox->setCurrentWidget( item );
00180 }
00181 
00185 int ToolBox::currentIndex () const
00186 {
00187   return _pToolBox->currentIndex();
00188 }
00189 
00193 QWidget * ToolBox::widget ( int index ) const
00194 {
00195   return _pToolBox->widget( index );
00196 }
00197 
00201 int ToolBox::indexOf ( QWidget * item ) const
00202 {
00203   return _pToolBox->indexOf ( item );
00204 }
00205 
00209 int ToolBox::count () const
00210 {
00211   return _pToolBox->count();
00212 }
00213 
00217 void ToolBox::setCurrentIndex ( int index )
00218 {
00219   _pToolBox->setCurrentIndex( index );
00220 }
00221 
00225 void ToolBox::changeEvent(QEvent *e)
00226 {
00227   if (e->type() == QEvent::LanguageChange) {
00228     QWidget::changeEvent(e);
00229     int ct = count();
00230     for ( int i=0; i<ct; i++ ) {
00231       QWidget* w = widget( i );
00232       if ( w )
00233         setItemText( i, w->windowTitle() );
00234     }
00235   } else {
00236     QWidget::changeEvent(e);
00237   }
00238 }
00239 
00240 #include "moc_ToolBox.cpp"

Generated on Wed Nov 23 19:00:45 2011 for FreeCAD by  doxygen 1.6.1