Back to index

texmacs  1.0.7.15
QTMInteractivePrompt.cpp
Go to the documentation of this file.
00001 /******************************************************************************
00002  * MODULE     : QTMInteractivePrompt.cpp
00003  * DESCRIPTION: interactive prompt a la emacs
00004  * COPYRIGHT  : (C) 2010 Miguel de Benito Delgado
00005  *******************************************************************************
00006  * This software falls under the GNU general public license version 3 or later.
00007  * It comes WITHOUT ANY WARRANTY WHATSOEVER. For details, see the file LICENSE
00008  * in the root directory or <http://www.gnu.org/licenses/gpl-3.0.html>.
00009  ******************************************************************************/
00010 
00011 #include "QTMInteractivePrompt.hpp"
00012 
00013 #include <QHBoxLayout>
00014 #include "QTMStyle.hpp"
00015 #include <QLabel>
00016 #include <QLineEdit>
00017 
00018 QTMInteractivePrompt::QTMInteractivePrompt(qt_widget int_prompt, 
00019                                            qt_widget int_input, 
00020                                                                                                                                                     QWidget* parent)
00021   : QWidget(parent)
00022 {
00023   QLayoutItem *li = int_prompt->as_qlayoutitem ();
00024   QLayoutItem *li2 = int_input->as_qlayoutitem ();
00025   QHBoxLayout *_hl = new QHBoxLayout ();
00026 
00027        setStyle (qtmstyle ());
00028   setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
00029   
00030        if (QLabel *_la = qobject_cast<QLabel*> (li->widget ()))
00031     _la->setBuddy (li2->widget ());
00032        if (QWidget *w = qobject_cast<QWidget*> (li2->widget ())) 
00033     w->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
00034   _hl->addItem (li);
00035   _hl->addSpacing (6);
00036   _hl->addItem (li2);
00037        _hl->setContentsMargins (3,0,0,0);
00038   setLayout (_hl);
00039        
00040   QFont f = font ();
00041   f.setPointSize (11);
00042   setFont (f);
00043 
00044   
00045 }
00046 
00047 
00048 void QTMInteractivePrompt::start() {
00049   QWidget *_le = findChild<QLineEdit*>();
00050   if (_le) {
00051     _le->show ();
00052     _le->setFocus (Qt::OtherFocusReason);  
00053   }
00054 }
00055 
00056 void QTMInteractivePrompt::end() {
00057 }
00058