kmpropcontainer.cpp
00001 /* 00002 * This file is part of the KDE libraries 00003 * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be> 00004 * 00005 * This library is free software; you can redistribute it and/or 00006 * modify it under the terms of the GNU Library General Public 00007 * License version 2 as published by the Free Software Foundation. 00008 * 00009 * This library is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00012 * Library General Public License for more details. 00013 * 00014 * You should have received a copy of the GNU Library General Public License 00015 * along with this library; see the file COPYING.LIB. If not, write to 00016 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00017 * Boston, MA 02110-1301, USA. 00018 **/ 00019 00020 #include "kmpropcontainer.h" 00021 #include "kmpropwidget.h" 00022 00023 #include <kpushbutton.h> 00024 #include <tqlayout.h> 00025 #include <tdelocale.h> 00026 #include <kseparator.h> 00027 #include <kguiitem.h> 00028 00029 KMPropContainer::KMPropContainer(TQWidget *parent, const char *name) 00030 : TQWidget(parent,name) 00031 { 00032 KSeparator* sep = new KSeparator( KSeparator::HLine, this); 00033 sep->setFixedHeight(5); 00034 00035 m_button = new KPushButton(KGuiItem(i18n("Change..."), "edit"), this); 00036 m_widget = 0; 00037 00038 TQVBoxLayout *main_ = new TQVBoxLayout(this, 0, 10); 00039 TQHBoxLayout *btn_ = new TQHBoxLayout(0, 0, 0); 00040 main_->addWidget(sep,0); 00041 main_->addLayout(btn_,0); 00042 btn_->addStretch(1); 00043 btn_->addWidget(m_button); 00044 } 00045 00046 KMPropContainer::~KMPropContainer() 00047 { 00048 } 00049 00050 void KMPropContainer::setWidget(KMPropWidget *w) 00051 { 00052 if (!m_widget) 00053 { 00054 m_widget = w; 00055 m_widget->reparent(this,TQPoint(0,0)); 00056 connect(m_button,TQT_SIGNAL(clicked()),m_widget,TQT_SLOT(slotChange())); 00057 connect(m_widget,TQT_SIGNAL(enable(bool)),TQT_SIGNAL(enable(bool))); 00058 connect(m_widget,TQT_SIGNAL(enableChange(bool)),TQT_SLOT(slotEnableChange(bool))); 00059 TQVBoxLayout *lay = dynamic_cast<TQVBoxLayout*>(layout()); 00060 if (lay) 00061 { 00062 lay->insertWidget(0,m_widget,1); 00063 } 00064 } 00065 } 00066 00067 void KMPropContainer::setPrinter(KMPrinter *p) 00068 { 00069 if (m_widget) 00070 m_widget->setPrinterBase(p); 00071 } 00072 00073 void KMPropContainer::slotEnableChange(bool on) 00074 { 00075 m_button->setEnabled(on && (m_widget ? m_widget->canChange() : true)); 00076 } 00077 #include "kmpropcontainer.moc"