00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
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"