"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/Plugins/Qt/QTMWidget.cpp" between
TeXmacs-1.99.4-src.tar.gz and TeXmacs-1.99.5-src.tar.gz

About: GNU TeXmacs is a what-you-see-is-what-you-get scientific text editor, which was both inspired by TeX and GNU Emacs.

QTMWidget.cpp  (TeXmacs-1.99.4-src):QTMWidget.cpp  (TeXmacs-1.99.5-src)
skipping to change at line 13 skipping to change at line 13
* MODULE : QTMWidget.cpp * MODULE : QTMWidget.cpp
* DESCRIPTION: QT Texmacs widget class * DESCRIPTION: QT Texmacs widget class
* COPYRIGHT : (C) 2008 Massimiliano Gubinelli and Joris van der Hoeven * COPYRIGHT : (C) 2008 Massimiliano Gubinelli and Joris van der Hoeven
******************************************************************************* *******************************************************************************
* This software falls under the GNU general public license version 3 or later. * This software falls under the GNU general public license version 3 or later.
* It comes WITHOUT ANY WARRANTY WHATSOEVER. For details, see the file LICENSE * It comes WITHOUT ANY WARRANTY WHATSOEVER. For details, see the file LICENSE
* in the root directory or <http://www.gnu.org/licenses/gpl-3.0.html>. * in the root directory or <http://www.gnu.org/licenses/gpl-3.0.html>.
******************************************************************************/ ******************************************************************************/
#include "QTMWidget.hpp" #include "QTMWidget.hpp"
#include "qt_widget.hpp"
#include "qt_renderer.hpp"
#include "qt_gui.hpp" #include "qt_gui.hpp"
#include "qt_utilities.hpp" #include "qt_utilities.hpp"
#include "qt_simple_widget.hpp" #include "qt_simple_widget.hpp"
#include "converter.hpp" #include "converter.hpp"
#include "config.h" #include "config.h"
#include "message.hpp"
#ifdef USE_CAIRO
#include "Cairo/cairo_renderer.hpp"
#include "Cairo/tm_cairo.hpp"
#if defined (Q_WS_X11)
#include <QX11Info>
extern Drawable qt_x11Handle (const QPaintDevice *pd);
extern const QX11Info *qt_x11Info (const QPaintDevice *pd);
#undef KeyPress // conflict between QEvent::KeyPress and X11 defintion
#endif // Q_WS_X11
#endif // USE_CAIRO
#include <QEvent> #include <QEvent>
#include <QSet>
#include <QResizeEvent> #include <QResizeEvent>
#include <QKeyEvent> #include <QKeyEvent>
#include <QPaintEvent> #include <QPaintEvent>
#include <QMouseEvent> #include <QMouseEvent>
#include <QFocusEvent> #include <QFocusEvent>
#include <QPainter>
#define PIXEL 256
QSet<QTMWidget*> QTMWidget::all_widgets;
hashmap<int,string> qtkeymap (0); hashmap<int,string> qtkeymap (0);
hashmap<int,string> qtdeadmap (0); hashmap<int,string> qtdeadmap (0);
inline void inline void
scale (QPoint& point) {
point.rx() *= PIXEL; point.ry() *= -PIXEL;
}
inline void
map (int code, string name) { map (int code, string name) {
qtkeymap (code) = name; qtkeymap (code) = name;
} }
inline void inline void
deadmap (int code, string name) { deadmap (int code, string name) {
qtdeadmap (code) = name; qtdeadmap (code) = name;
} }
void void
initkeymap () { initkeymap () {
map (Qt::Key_Space , "space"); map (Qt::Key_Space , "space");
map (Qt::Key_Return , "return"); map (Qt::Key_Return , "return");
map (Qt::Key_Tab , "tab"); map (Qt::Key_Tab , "tab");
skipping to change at line 155 skipping to change at line 131
// map (Qt::Key_DeleteLine , "deleteline" ); // map (Qt::Key_DeleteLine , "deleteline" );
// map (Qt::Key_InsertChar , "insert" ); // map (Qt::Key_InsertChar , "insert" );
// map (Qt::Key_DeleteChar , "delete" ); // map (Qt::Key_DeleteChar , "delete" );
// map (Qt::Key_Prev , "prev" ); // map (Qt::Key_Prev , "prev" );
// map (Qt::Key_Next , "next" ); // map (Qt::Key_Next , "next" );
// map (Qt::Key_Undo , "undo" ); // map (Qt::Key_Undo , "undo" );
// map (Qt::Key_Redo , "redo" ); // map (Qt::Key_Redo , "redo" );
// map (Qt::Key_Find , "find" ); // map (Qt::Key_Find , "find" );
// map (Qt::Key_ModeSwitchFunctionKey, "modeswitch" ); // map (Qt::Key_ModeSwitchFunctionKey, "modeswitch" );
} }
#ifdef __MINGW32__
enum WindowsNativeModifiers {
ShiftLeft = 0x00000001,
ControlLeft = 0x00000002,
AltLeft = 0x00000004,
MetaLeft = 0x00000008,
ShiftRight = 0x00000010,
ControlRight = 0x00000020,
AltRight = 0x00000040,
MetaRight = 0x00000080,
CapsLock = 0x00000100,
NumLock = 0x00000200,
ScrollLock = 0x00000400,
ExtendedKey = 0x01000000,
};
#endif
static long int QTMWcounter = 0; // debugging hack static long int QTMWcounter = 0; // debugging hack
/*! Constructor. /*! Constructor.
\param _parent The parent QWidget. \param _parent The parent QWidget.
\param _tmwid the TeXmacs widget who owns this object. \param _tmwid the TeXmacs widget who owns this object.
*/ */
QTMWidget::QTMWidget (QWidget* _parent, qt_widget _tmwid) QTMWidget::QTMWidget (QWidget* _parent, qt_widget _tmwid)
: QTMScrollView (_parent), tmwid (_tmwid), backingPixmap (1,1), imwidget (NULL), : QTMScrollView (_parent), tmwid (_tmwid), imwidget (NULL)
id (QTMWcounter++)
{ {
setObjectName (to_qstring ("QTMWidget" * as_string (id)));// What is this for? setObjectName (to_qstring ("QTMWidget" * as_string (QTMWcounter++)));// What i s this for? (maybe only debugging?)
setFocusPolicy (Qt::StrongFocus); setFocusPolicy (Qt::StrongFocus);
setAttribute (Qt::WA_InputMethodEnabled); setAttribute (Qt::WA_InputMethodEnabled);
all_widgets.insert (this);
backing_pos = origin ();
surface()->setMouseTracking (true); surface()->setMouseTracking (true);
if (DEBUG_QT) if (DEBUG_QT)
debug_qt << "Creating QTMWidget " << as_string (id) << " of widget " debug_qt << "Creating " << from_qstring(objectName()) << " of widget "
<< (tm_widget() ? tm_widget()->type_as_string() : "NULL") << LF; << (tm_widget() ? tm_widget()->type_as_string() : "NULL") << LF;
} }
QTMWidget::~QTMWidget () { QTMWidget::~QTMWidget () {
if (DEBUG_QT) if (DEBUG_QT)
debug_qt << "Destroying QTMWidget " << as_string (id) << " of widget " debug_qt << "Destroying " << from_qstring(objectName()) << " of widget "
<< (tm_widget() ? tm_widget()->type_as_string() : "NULL") << LF; << (tm_widget() ? tm_widget()->type_as_string() : "NULL") << LF;
// remove ourselves from the list of QWidgets to be repainted.
all_widgets.remove (this);
} }
qt_simple_widget_rep* qt_simple_widget_rep*
QTMWidget::tm_widget () const { QTMWidget::tm_widget () const {
return concrete_simple_widget (tmwid); return concrete_simple_widget (tmwid);
} }
void void
QTMWidget::invalidate_rect (int x1, int y1, int x2, int y2) {
#ifdef Q_WS_MAC
//HACK: for unknown reasons we need to enlarge the invalid rect to prevent
//artifacts while moving the cursor (for example at the end of a formula like
// $a+f$. These artifacts seems present only on 64 bit Macs.
rectangle r = rectangle (x1-10, y1-10, x2+10, y2+10);
#else
rectangle r = rectangle (x1, y1, x2, y2);
#endif
// cout << "invalidating " << r << LF;
invalid_regions = invalid_regions | rectangles (r);
}
void
QTMWidget::invalidate_all () {
QSize sz = surface()->size();
// QPoint pt = QAbstractScrollArea::viewport()->pos();
//cout << "invalidate all " << LF;
invalid_regions = rectangles();
invalidate_rect (0, 0, sz.width(), sz.height());
}
bool
QTMWidget::is_invalid () {
return !is_nil (invalid_regions);
}
basic_renderer_rep*
QTMWidget::getRenderer() {
#ifdef USE_CAIRO
cairo_renderer_rep *ren = the_cairo_renderer ();
cairo_surface_t *surf;
#ifdef Q_WS_X11
//const QX11Info & info = x11Info();//qt_x11Info (this);
// Display *dpy = x11Info().display();
//backingPixmap = QPixmap (width(),height());
//cout << backingPixmap.width() << LF;
Display *dpy = QX11Info::display();
Drawable drawable = backingPixmap.handle();
Visual *visual = (Visual*)(backingPixmap.x11Info().visual());
surf = tm_cairo_xlib_surface_create (dpy, drawable, visual,
backingPixmap.width (), backingPixmap.height ());
#elif defined (Q_WS_MAC)
surf = tm_cairo_quartz_surface_create_for_cg_context (
(CGContextRef)(this->macCGHandle()), width(), height());
#endif
cairo_t *ct = tm_cairo_create (surf);
ren->begin (ct);
tm_cairo_surface_destroy (surf);
tm_cairo_destroy (ct);
#else
qt_renderer_rep * ren = the_qt_renderer();
ren->begin (&backingPixmap);
#endif
return ren;
}
/*
This function is called by the qt_gui::update method to keep the backing
store in sync and propagate the changes to the surface on screen.
First we check that the backing store geometry is right and then we
request to the texmacs canvas widget to repaint the regions which were
marked invalid. Subsequently, for each succesfully repainted region, we
propagate its contents from the backing store to the onscreen surface.
If repaint has been interrupted we do not propagate the changes and proceed
to mark the region invalid again.
*/
void
QTMWidget::repaint_invalid_regions () {
QRegion qrgn;
// qrgn is to keep track of the area on the screen which needs to be updated
// update backing store origin wrt. TeXmacs document
if (backing_pos != origin()) {
int dx = origin().x() - backing_pos.x();
int dy = origin().y() - backing_pos.y();
backing_pos = origin();
QPixmap newBackingPixmap (backingPixmap.size());
QPainter p (&newBackingPixmap);
//newBackingPixmap.fill (Qt::black);
p.drawPixmap (-dx,-dy,backingPixmap);
p.end();
backingPixmap = newBackingPixmap;
//cout << "SCROLL CONTENTS BY " << dx << " " << dy << LF;
QSize sz = backingPixmap.size();
rectangles invalid;
while (!is_nil (invalid_regions)) {
rectangle r = invalid_regions->item ;
// rectangle q = rectangle (r->x1+dx,r->y1-dy,r->x2+dx,r->y2-dy);
rectangle q = rectangle (r->x1-dx,r->y1-dy,r->x2-dx,r->y2-dy);
invalid = rectangles (q, invalid);
//cout << r << " ---> " << q << LF;
invalid_regions = invalid_regions->next;
}
invalid_regions= invalid & rectangles (rectangle (0,0,
sz.width(),sz.height()));
if (dy<0)
invalidate_rect (0,0,sz.width(),min (sz.height(),-dy));
else if (dy>0)
invalidate_rect (0,max (0,sz.height()-dy),sz.width(),sz.height());
if (dx<0)
invalidate_rect (0,0,min (-dx,sz.width()),sz.height());
else if (dx>0)
invalidate_rect (max (0,sz.width()-dx),0,sz.width(),sz.height());
// we call update now to allow repainting of invalid regions
// this cannot be done directly since interpose_handler needs
// to be run at least once in some situations
// (for example when scrolling is initiated by TeXmacs itself)
//the_gui->update();
// QAbstractScrollArea::viewport()->scroll (-dx,-dy);
// QAbstractScrollArea::viewport()->update();
qrgn += QRect (QPoint (0,0),sz);
}
//cout << " repaint QPixmap of size " << backingPixmap.width() << " x "
// << backingPixmap.height() << LF;
// update backing store size
{
QSize _oldSize = backingPixmap.size();
QSize _newSize = surface()->size();
//cout << " surface size of " << _newSize.width() << " x "
// << _newSize.height() << LF;
if (_newSize != _oldSize) {
// cout << "RESIZING BITMAP"<< LF;
QPixmap newBackingPixmap (_newSize);
QPainter p (&newBackingPixmap);
p.drawPixmap (0,0,backingPixmap);
//p.fillRect (0, 0, _newSize.width(), _newSize.height(), Qt::red);
if (_newSize.width() >= _oldSize.width()) {
invalidate_rect (_oldSize.width(), 0, _newSize.width(), _newSize.height(
));
p.fillRect (QRect (_oldSize.width(), 0, _newSize.width()-_oldSize.width(
), _newSize.height()), Qt::gray);
}
if (_newSize.height() >= _oldSize.height()) {
invalidate_rect (0,_oldSize.height(), _newSize.width(), _newSize.height(
));
p.fillRect (QRect (0,_oldSize.height(), _newSize.width(), _newSize.heigh
t()-_oldSize.height()), Qt::gray);
}
p.end();
backingPixmap = newBackingPixmap;
}
}
// repaint invalid rectangles
{
rectangles new_regions;
if (!is_nil (invalid_regions)) {
rectangle lub= least_upper_bound (invalid_regions);
if (area (lub) < 1.2 * area (invalid_regions))
invalid_regions= rectangles (lub);
basic_renderer_rep* ren = getRenderer();
SI ox = -backing_pos.x()*PIXEL; // Warning: this is NOT from_qpoint()
SI oy = backing_pos.y()*PIXEL;
rectangles rects = invalid_regions;
invalid_regions = rectangles();
while (!is_nil (rects)) {
rectangle r = copy (rects->item);
rectangle r0 = rects->item;
QRect qr = QRect (r0->x1, r0->y1, r0->x2 - r0->x1, r0->y2 - r0->y1);
//cout << "repainting " << r0 << "\n";
ren->set_origin (ox, oy);
ren->encode (r->x1, r->y1);
ren->encode (r->x2, r->y2);
ren->set_clipping (r->x1, r->y2, r->x2, r->y1);
tm_widget()->handle_repaint (ren, r->x1, r->y2, r->x2, r->y1);
if (gui_interrupted ()) {
//cout << "interrupted repainting of " << r0 << "\n";
//ren->set_pencil (green);
//ren->line (r->x1, r->y1, r->x2, r->y2);
//ren->line (r->x1, r->y2, r->x2, r->y1);
invalidate_rect (r0->x1, r0->y1, r0->x2, r0->y2);
}
qrgn += qr;
rects = rects->next;
}
ren->end();
} // !is_nil (invalid_regions)
}
// propagate immediately the changes to the screen
surface()->repaint (qrgn);
}
void
QTMWidget::scrollContentsBy (int dx, int dy) { QTMWidget::scrollContentsBy (int dx, int dy) {
QTMScrollView::scrollContentsBy (dx,dy); QTMScrollView::scrollContentsBy (dx,dy);
the_gui->force_update(); the_gui->force_update();
// we force an update of the internal state to be in sync with the moving // we force an update of the internal state to be in sync with the moving
// scrollbars // scrollbars
} }
void void
QTMWidget::resizeEvent (QResizeEvent* event) { QTMWidget::resizeEvent (QResizeEvent* event) {
skipping to change at line 438 skipping to change at line 225
to the QRegion marked invalid. to the QRegion marked invalid.
CHECK: Maybe just putting onscreen all the region bounding rectangles might CHECK: Maybe just putting onscreen all the region bounding rectangles might
be less expensive. be less expensive.
*/ */
void void
QTMWidget::paintEvent (QPaintEvent* event) { QTMWidget::paintEvent (QPaintEvent* event) {
QPainter p (surface()); QPainter p (surface());
QVector<QRect> rects = event->region().rects(); QVector<QRect> rects = event->region().rects();
for (int i = 0; i < rects.count(); ++i) { for (int i = 0; i < rects.count(); ++i) {
QRect qr = rects.at (i); QRect qr = rects.at (i);
p.drawPixmap (qr, backingPixmap, qr); p.drawPixmap (QRect (qr.x(), qr.y(), qr.width(), qr.height()),
tm_widget()->backingPixmap,
QRect (retina_factor * qr.x(),
retina_factor * qr.y(),
retina_factor * qr.width(),
retina_factor * qr.height()));
} }
} }
void void
QTMWidget::keyPressEvent (QKeyEvent* event) { QTMWidget::keyPressEvent (QKeyEvent* event) {
if (is_nil (tmwid)) return; if (is_nil (tmwid)) return;
static bool fInit = false; static bool fInit = false;
if (!fInit) { if (!fInit) {
if (DEBUG_QT && DEBUG_KEYBOARD) debug_qt << "Initializing keymap\n"; if (DEBUG_QT && DEBUG_KEYBOARD) debug_qt << "Initializing keymap\n";
initkeymap(); initkeymap();
fInit= true; fInit= true;
} }
if (DEBUG_QT && DEBUG_KEYBOARD) debug_qt << "keypressed\n"; if (DEBUG_QT && DEBUG_KEYBOARD) debug_qt << "keypressed\n";
{ {
int key = event->key(); int key = event->key();
Qt::KeyboardModifiers mods = event->modifiers(); Qt::KeyboardModifiers mods = event->modifiers();
if (DEBUG_QT && DEBUG_KEYBOARD) { if (DEBUG_QT && DEBUG_KEYBOARD) {
debug_qt << "key : " << key << LF; debug_qt << "key : " << key << LF;
debug_qt << "text : " << event->text().toAscii().data() << LF; debug_qt << "text : " << event->text().toLatin1().data() << LF;
debug_qt << "count: " << event->text().count() << LF; debug_qt << "count: " << event->text().count() << LF;
#ifdef __MINGW32__
debug_qt << "nativeScanCode: " << event->nativeScanCode() << LF;
debug_qt << "nativeVirtualKey: " << event->nativeVirtualKey() << LF;
debug_qt << "nativeModifiers: " << event->nativeModifiers() << LF;
#endif
if (mods & Qt::ShiftModifier) debug_qt << "shift\n"; if (mods & Qt::ShiftModifier) debug_qt << "shift\n";
if (mods & Qt::MetaModifier) debug_qt << "meta\n"; if (mods & Qt::MetaModifier) debug_qt << "meta\n";
if (mods & Qt::ControlModifier) debug_qt << "control\n"; if (mods & Qt::ControlModifier) debug_qt << "control\n";
if (mods & Qt::KeypadModifier) debug_qt << "keypad\n"; if (mods & Qt::KeypadModifier) debug_qt << "keypad\n";
if (mods & Qt::AltModifier) debug_qt << "alt\n"; if (mods & Qt::AltModifier) debug_qt << "alt\n";
} }
string r; string r;
#ifdef __MINGW32__ #ifdef __MINGW32__
// denis begin /* "Qt::Key_AltGr On Windows, when the KeyDown event for this key is sent,
if (event->text().count() == 1) { * the Ctrl+Alt modifiers are also set." (excerpt from Qt doc)
QChar c= event->text()[0]; * However the AltGr key is used to obtain many symbols
if (c.isPrint() && event->modifiers() != Qt::MetaModifier) { * which should not be regarded as C-A- shortcuts.
// not a control character or dead key or modifier * (e.g. \ or @ on a French keyboard)
char ac=c.toAscii(); *
if (ac && ac != ' ') { // a true ascii printable * Hence, when "native modifiers" are (ControlLeft | AltRight)
r= ac; * we clear Qt's Ctrl+Alt modifiers
if (DEBUG_QT && DEBUG_KEYBOARD) debug_qt << "ascii key= " <<r << "\n"; */
the_gui->process_keypress (tm_widget(), r, texmacs_time()); if ((event->nativeModifiers() & (ControlLeft | AltRight)) == (ControlLeft |
return; AltRight)){
} if (DEBUG_QT && DEBUG_KEYBOARD) debug_qt << "assuming it's an Alt
} Gr key code"<<LF;
} mods &= ~Qt::AltModifier;
// denis end mods &= ~Qt::ControlModifier;
}
#endif #endif
if (qtkeymap->contains (key)) { if (qtkeymap->contains (key)) {
r = qtkeymap[key]; r = qtkeymap[key];
} }
else if (qtdeadmap->contains (key)) { else if (qtdeadmap->contains (key)) {
mods &=~ Qt::ShiftModifier; mods &=~ Qt::ShiftModifier;
r = qtdeadmap[key]; r = qtdeadmap[key];
} }
else { else {
// We need to use text(): Alt-{5,6,7,8,9} are []|{} under MacOS, etc. // We need to use text(): Alt-{5,6,7,8,9} are []|{} under MacOS, etc.
skipping to change at line 540 skipping to change at line 336
int len= N (tstr); int len= N (tstr);
if (len >= 1 && tstr[0] == '<' && tstr[1] != '#' && tstr[len-1] == ' >') if (len >= 1 && tstr[0] == '<' && tstr[1] != '#' && tstr[len-1] == ' >')
r= tstr (1, len-1); r= tstr (1, len-1);
else else
r= tstr; r= tstr;
if (r == "less") r= "<"; if (r == "less") r= "<";
else if (r == "gtr")r= ">"; else if (r == "gtr")r= ">";
} }
#ifdef Q_WS_MAC #ifdef Q_WS_MAC
// Alt produces many symbols in Mac keyboards: []|{} etc. // Alt produces many symbols in Mac keyboards: []|{} etc.
mods &=~ Qt::AltModifier; mods &= ~Qt::AltModifier; //unset Alt
#endif #endif
mods &=~ Qt::ShiftModifier; mods &= ~Qt::ShiftModifier;
} }
} }
if (r == "") return; if (r == "") return;
if (mods & Qt::ShiftModifier) r= "S-" * r; if (mods & Qt::ShiftModifier) r= "S-" * r;
if (mods & Qt::AltModifier) r= "A-" * r; if (mods & Qt::AltModifier) r= "A-" * r;
//if (mods & Qt::KeypadModifier) r= "K-" * r; //if (mods & Qt::KeypadModifier) r= "K-" * r;
#ifdef Q_WS_MAC #ifdef Q_WS_MAC
if (mods & Qt::MetaModifier) r= "C-" * r; // The "Control" key if (mods & Qt::MetaModifier) r= "C-" * r; // The "Control" key
if (mods & Qt::ControlModifier) r= "M-" * r; // The "Command" key if (mods & Qt::ControlModifier) r= "M-" * r; // The "Command" key
#else #else
skipping to change at line 635 skipping to change at line 431
// imwidget->setAutoFillBackground (false); // imwidget->setAutoFillBackground (false);
imwidget->setAutoFillBackground (true); imwidget->setAutoFillBackground (true);
imwidget->setWindowOpacity (0.5); imwidget->setWindowOpacity (0.5);
imwidget->setFocusPolicy (Qt::NoFocus); imwidget->setFocusPolicy (Qt::NoFocus);
QPalette pal = imwidget->palette(); QPalette pal = imwidget->palette();
// pal.setColor (QPalette::Window, QColor (0,0,255,80)); // pal.setColor (QPalette::Window, QColor (0,0,255,80));
pal.setColor (QPalette::Window, QColor (0,0,255,255)); pal.setColor (QPalette::Window, QColor (0,0,255,255));
pal.setColor (QPalette::WindowText, Qt::white); pal.setColor (QPalette::WindowText, Qt::white);
imwidget->setPalette (pal); imwidget->setPalette (pal);
QFont f = imwidget->font(); QFont f = imwidget->font();
f.setPointSize (30); f.setPointSize (qt_zoom (30));
imwidget->setFont (f); imwidget->setFont (f);
imwidget->setMargin (5); imwidget->setMargin (5);
} }
QString const & preedit_string = event->preeditString(); QString const & preedit_string = event->preeditString();
QString const & commit_string = event->commitString(); QString const & commit_string = event->commitString();
if (preedit_string.isEmpty()) { if (preedit_string.isEmpty()) {
imwidget->hide(); imwidget->hide();
} else { } else {
skipping to change at line 785 skipping to change at line 581
return QWidget::inputMethodQuery (query); return QWidget::inputMethodQuery (query);
} }
} }
#endif // input method variants #endif // input method variants
void void
QTMWidget::mousePressEvent (QMouseEvent* event) { QTMWidget::mousePressEvent (QMouseEvent* event) {
if (is_nil (tmwid)) return; if (is_nil (tmwid)) return;
QPoint point = event->pos() + origin(); QPoint point = event->pos() + origin();
scale (point); coord2 pt = from_qpoint(point);
unsigned int mstate= mouse_state (event, false); unsigned int mstate= mouse_state (event, false);
string s= "press-" * mouse_decode (mstate); string s= "press-" * mouse_decode (mstate);
the_gui -> process_mouse (tm_widget(), s, point.x (), point.y (), the_gui -> process_mouse (tm_widget(), s, pt.x1, pt.x2,
mstate, texmacs_time ()); mstate, texmacs_time ());
event->accept(); event->accept();
} }
void void
QTMWidget::mouseReleaseEvent (QMouseEvent* event) { QTMWidget::mouseReleaseEvent (QMouseEvent* event) {
if (is_nil (tmwid)) return; if (is_nil (tmwid)) return;
QPoint point = event->pos() + origin(); QPoint point = event->pos() + origin();
scale (point); coord2 pt = from_qpoint(point);
unsigned int mstate = mouse_state (event, true); unsigned int mstate = mouse_state (event, true);
string s = "release-" * mouse_decode (mstate); string s = "release-" * mouse_decode (mstate);
the_gui->process_mouse (tm_widget(), s, point.x(), point.y(), the_gui->process_mouse (tm_widget(), s, pt.x1, pt.x2,
mstate, texmacs_time()); mstate, texmacs_time());
event->accept(); event->accept();
} }
void void
QTMWidget::mouseMoveEvent (QMouseEvent* event) { QTMWidget::mouseMoveEvent (QMouseEvent* event) {
if (is_nil (tmwid)) return; if (is_nil (tmwid)) return;
QPoint point = event->pos() + origin(); QPoint point = event->pos() + origin();
scale (point); coord2 pt = from_qpoint(point);
unsigned int mstate = mouse_state (event, false); unsigned int mstate = mouse_state (event, false);
string s = "move"; string s = "move";
the_gui->process_mouse (tm_widget(), s, point.x(), point.y(), the_gui->process_mouse (tm_widget(), s, pt.x1, pt.x2,
mstate, texmacs_time ()); mstate, texmacs_time ());
event->accept(); event->accept();
} }
bool bool
QTMWidget::event (QEvent* event) { QTMWidget::event (QEvent* event) {
// Catch Keypresses to avoid default handling of (Shift+)Tab keys // Catch Keypresses to avoid default handling of (Shift+)Tab keys
if (event->type() == QEvent::KeyPress) { if (event->type() == QEvent::KeyPress) {
QKeyEvent *ke = static_cast<QKeyEvent*> (event); QKeyEvent *ke = static_cast<QKeyEvent*> (event);
keyPressEvent (ke); keyPressEvent (ke);
 End of changes. 27 change blocks. 
265 lines changed or deleted 59 lines changed or added

Home  |  About  |  All  |  Newest  |  Fossies Dox  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTPS