Back to index

texmacs  1.0.7.15
QTMWidget.hpp
Go to the documentation of this file.
00001 
00002 /******************************************************************************
00003 * MODULE     : QTMWidget.hpp
00004 * DESCRIPTION: QT Texmacs widget class
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 QTMWIDGET_HPP
00013 #define QTMWIDGET_HPP
00014 
00015 #include "QTMScrollView.hpp"
00016 #include "rectangles.hpp"
00017 #include <QVariant>
00018 #include <QTimer>
00019 #include <QSet>
00020 #include <QLabel>
00021 
00022 class simple_widget_rep;
00023 class basic_renderer_rep;
00024 
00025 class QTMWidget: public QTMScrollView {
00026   Q_OBJECT
00027 
00028   rectangles invalid_regions;
00029   QPixmap backingPixmap;
00030   
00031 public:
00032 
00033   static QSet<QTMWidget*> all_widgets;
00034   QPoint backing_pos;
00035 
00036   
00037   QLabel *imwidget;
00038   QPoint cursor_pos;
00039   
00040   QTMWidget(simple_widget_rep *_wid) ;
00041   ~QTMWidget();
00042 
00043   inline simple_widget_rep*
00044   tm_widget() {
00045     QVariant v= property("texmacs_widget");
00046     return (simple_widget_rep *)
00047       (v.canConvert<void*> ()? v.value<void*> (): NULL);
00048   }
00049 
00050   
00051   void invalidate_rect (int x1, int y1, int x2, int y2);
00052   void invalidate_all ();
00053   void repaint_invalid_regions ();
00054 
00055   void scrollContentsBy(int dx, int dy);
00056   void setCursorPos(QPoint pos) { cursor_pos = pos; };
00057 
00058 protected:
00059   virtual void paintEvent (QPaintEvent* event);
00060   virtual void focusInEvent (QFocusEvent* event);
00061   virtual void focusOutEvent (QFocusEvent* event);
00062   virtual void keyPressEvent (QKeyEvent* event);
00063   virtual void inputMethodEvent (QInputMethodEvent* event);
00064   virtual void mousePressEvent (QMouseEvent* event);
00065   virtual void mouseReleaseEvent (QMouseEvent* event);
00066   virtual void mouseMoveEvent (QMouseEvent* event);
00067   virtual bool event (QEvent *event);
00068   virtual void resizeEvent (QResizeEvent *event);
00069 
00070   virtual QVariant inputMethodQuery ( Qt::InputMethodQuery query ) const ;
00071 private:
00072   basic_renderer_rep *getRenderer();
00073 };
00074 
00075 #endif // QTMWIDGET_HPP