Back to index

texmacs  1.0.7.15
QTMMenuHelper.hpp
Go to the documentation of this file.
00001 
00002 /******************************************************************************
00003 * MODULE     : QTMMenuHelper.hpp
00004 * DESCRIPTION: QT Texmacs menu helper classes
00005 * COPYRIGHT  : (C) 2008 Massimiliano Gubinelli
00006 *******************************************************************************
00007 * This software falls under the GNU general public license version 3 or later.
00008 * It comes WITHOUT ANY WARRANTY WHATSOEVER. For details, see the file LICENSE
00009 * in the root directory or <http://www.gnu.org/licenses/gpl-3.0.html>.
00010 ******************************************************************************/
00011 
00012 #ifndef QTMMENUHELPER_HPP
00013 #define QTMMENUHELPER_HPP
00014 
00015 #include "message.hpp"
00016 #include "promise.hpp"
00017 #include <QObject>
00018 #include <QAction>
00019 #include <QMenu>
00020 #include <QWidgetAction>
00021 #include <QLineEdit>
00022 #include <QTabWidget>
00023 #include <QLayout>
00024 
00025 #include "qt_gui.hpp"
00026 #include "qt_basic_widgets.hpp"
00027 
00028 
00054 class QTMCommand: public QObject {
00055   Q_OBJECT
00056   command cmd;
00057 
00058 public:
00059   inline QTMCommand (command _cmd):
00060     cmd (_cmd) {  }
00061 
00062 public slots:
00063   void apply();
00064 };
00065 
00066 
00070 class QTMLazyMenu: public QMenu {
00071   Q_OBJECT
00072   promise<widget> pm;
00073 
00074 public:
00075   inline QTMLazyMenu (promise<widget> _pm):
00076     pm (_pm) {
00077       QObject::connect (this, SIGNAL (aboutToShow ()), this, SLOT (force ()));
00078     }
00079 
00080 public slots:
00081   void force();
00082 };
00083 
00084 
00093 class QTMAction : public QAction {
00094   Q_OBJECT
00095   
00096   QTimer* _timer;
00097   QPoint    _pos;
00098 public:
00099   string str;
00100   
00101   QTMAction(QObject *parent = NULL);
00102   ~QTMAction();
00103 
00104 public slots:
00105   void doRefresh();
00106   void showToolTip();   //<! Force the display of the tooltip (starts a timer)
00107 
00108 protected slots:
00109   void doShowToolTip();  // Actually show it.
00110 };
00111 
00112 
00113 struct QLineEdit;
00114 class QTMInputTextWidgetHelper : public QObject {
00115   Q_OBJECT
00116 
00117   widget p_wid; 
00119   bool done;
00120   
00121 public:
00122   
00123   QList<QLineEdit*> views;
00124 
00125   QTMInputTextWidgetHelper ( qt_input_text_widget_rep*  _wid ) 
00126     : QObject(NULL), p_wid(abstract(_wid)), done(false) { }
00127   ~QTMInputTextWidgetHelper();
00128 
00129   qt_input_text_widget_rep* wid () 
00130     { return (qt_input_text_widget_rep*) p_wid.rep; }
00131   // useful cast
00132   
00133   void add (QLineEdit *);
00134 
00135 public slots:
00136   void commit ();
00137   void leave ();
00138   void remove (QObject *);
00139   
00140   void doit ();
00141   
00142 };
00143 
00144 class QTMWidgetAction : public QWidgetAction {
00145   Q_OBJECT
00146 
00147   widget wid;
00148   
00149 public:
00150   QTMWidgetAction(widget _wid, QObject *parent = NULL);
00151   ~QTMWidgetAction();
00152   
00153 public slots:
00154   virtual void doRefresh();
00155   
00156 protected:
00157   QWidget * createWidget ( QWidget * parent );
00158   
00159 };
00160 
00162 class QTMTabWidget : public QTabWidget {
00163   Q_OBJECT
00164 public:
00165   QTMTabWidget(QWidget* p=NULL);
00166 public slots:
00167   void resizeOthers(int index);
00168 };
00169 
00170 
00171 
00172 #endif // QTMMENUHELPER_HPP