dockviewbase.cpp
00001 /* This file is part of the KDE project 00002 Copyright (C) 2002 Anders Lund <anders.lund@lund.tdcadsl.dk> 00003 00004 This library is free software; you can redistribute it and/or 00005 modify it under the terms of the GNU Library General Public 00006 License version 2 as published by the Free Software Foundation. 00007 00008 This library is distributed in the hope that it will be useful, 00009 but WITHOUT ANY WARRANTY; without even the implied warranty of 00010 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00011 Library General Public License for more details. 00012 00013 You should have received a copy of the GNU Library General Public License 00014 along with this library; see the file COPYING.LIB. If not, write to 00015 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00016 Boston, MA 02110-1301, USA. 00017 */ 00018 00019 #include "dockviewbase.h" 00020 #include "dockviewbase.moc" 00021 00022 #include <tqlabel.h> 00023 #include <tqlayout.h> 00024 00025 //#include <kdebug.h> 00026 00027 namespace Kate { 00028 00029 // data storage 00030 class DockViewBasePrivate { 00031 public: 00032 TQWidget *header; 00033 TQLabel *lTitle; 00034 TQLabel *lPrefix; 00035 }; 00036 00037 } 00038 00039 Kate::DockViewBase::DockViewBase( TQWidget* parent, const char* name ) 00040 : TQVBox( parent, name ), 00041 d ( new Kate::DockViewBasePrivate ) 00042 { 00043 init( TQString::null, TQString::null ); 00044 } 00045 00046 Kate::DockViewBase::DockViewBase( const TQString &prefix, const TQString &title, TQWidget* parent, const char* name ) 00047 : TQVBox( parent, name ), 00048 d ( new Kate::DockViewBasePrivate ) 00049 { 00050 init( prefix, title ); 00051 } 00052 00053 Kate::DockViewBase::~DockViewBase() 00054 { 00055 delete d; 00056 } 00057 00058 void Kate::DockViewBase::setTitlePrefix( const TQString &prefix ) 00059 { 00060 d->lPrefix->setText( prefix ); 00061 d->lPrefix->show(); 00062 } 00063 00064 TQString Kate::DockViewBase::titlePrefix() const 00065 { 00066 return d->lPrefix->text(); 00067 } 00068 00069 void Kate::DockViewBase::setTitle( const TQString &title ) 00070 { 00071 d->lTitle->setText( title ); 00072 d->lTitle->show(); 00073 } 00074 00075 TQString Kate::DockViewBase::title() const 00076 { 00077 return d->lTitle->text(); 00078 } 00079 00080 void Kate::DockViewBase::setTitle( const TQString &prefix, const TQString &title ) 00081 { 00082 setTitlePrefix( prefix ); 00083 setTitle( title ); 00084 } 00085 00086 void Kate::DockViewBase::init( const TQString &prefix, const TQString &title ) 00087 { 00088 setSpacing( 4 ); 00089 d->header = new TQWidget( this ); 00090 d->header->setSizePolicy( TQSizePolicy( TQSizePolicy::Expanding, TQSizePolicy::Fixed, true ) ); 00091 TQHBoxLayout *lo = new TQHBoxLayout( d->header ); 00092 lo->setSpacing( 6 ); 00093 lo->insertSpacing( 0, 6 ); 00094 d->lPrefix = new TQLabel( title, d->header ); 00095 lo->addWidget( d->lPrefix ); 00096 d->lTitle = new TQLabel( title, d->header ); 00097 lo->addWidget( d->lTitle ); 00098 lo->setStretchFactor( d->lTitle, 1 ); 00099 lo->insertSpacing( -1, 6 ); 00100 if ( prefix.isEmpty() ) d->lPrefix->hide(); 00101 if ( title.isEmpty() ) d->lTitle->hide(); 00102 }