diff options
Diffstat (limited to 'graphics/qt_qpainter/graphics_qt_qpainter.cpp')
-rw-r--r-- | graphics/qt_qpainter/graphics_qt_qpainter.cpp | 93 |
1 files changed, 55 insertions, 38 deletions
diff --git a/graphics/qt_qpainter/graphics_qt_qpainter.cpp b/graphics/qt_qpainter/graphics_qt_qpainter.cpp index 68ce605c..31b1e894 100644 --- a/graphics/qt_qpainter/graphics_qt_qpainter.cpp +++ b/graphics/qt_qpainter/graphics_qt_qpainter.cpp @@ -42,6 +42,7 @@ #include "window.h" #include "keys.h" #include "navit/font/freetype/font_freetype.h" +#include "navit.h" #include <qglobal.h> #if QT_VERSION < 0x040000 @@ -72,6 +73,45 @@ #include <QtGui> #endif +class RenderArea; + +//############################################################################################################## +//# Description: +//# Comment: +//# Authors: Martin Schaller (04/2008) +//############################################################################################################## +struct graphics_gc_priv { + QPen *pen; + QBrush *brush; + struct color c; +}; + +//############################################################################################################## +//# Description: +//# Comment: +//# Authors: Martin Schaller (04/2008) +//############################################################################################################## +struct graphics_priv { +#ifdef HAVE_QPE + QPEApplication *app; +#else + QApplication *app; +#endif + RenderArea *widget; + QPainter *painter; + struct graphics_gc_priv *background_gc; + unsigned char rgba[4]; + enum draw_mode_num mode; + struct graphics_priv *parent,*overlays,*next; + struct point p,pclean; + int cleanup; + int overlay_disable; + int wraparound; + struct font_priv * (*font_freetype_new)(void *meth); + struct font_freetype_methods freetype_methods; + int w,h; + struct navit* nav; +}; //############################################################################################################## //# Description: RenderArea (QWidget) class for the main window (map, menu, ...) @@ -103,6 +143,7 @@ class RenderArea : public QWidget void mouseMoveEvent(QMouseEvent *event); void wheelEvent(QWheelEvent *event); void keyPressEvent(QKeyEvent *event); + void closeEvent(QCloseEvent *event); #if QT_VERSION < 0x040000 void timerEvent(QTimerEvent *event); #endif @@ -110,46 +151,8 @@ class RenderArea : public QWidget void watchEvent(int fd); }; - #include "graphics_qt_qpainter.moc" -//############################################################################################################## -//# Description: -//# Comment: -//# Authors: Martin Schaller (04/2008) -//############################################################################################################## -struct graphics_gc_priv { - QPen *pen; - QBrush *brush; - struct color c; -}; - -//############################################################################################################## -//# Description: -//# Comment: -//# Authors: Martin Schaller (04/2008) -//############################################################################################################## -struct graphics_priv { -#ifdef HAVE_QPE - QPEApplication *app; -#else - QApplication *app; -#endif - RenderArea *widget; - QPainter *painter; - struct graphics_gc_priv *background_gc; - unsigned char rgba[4]; - enum draw_mode_num mode; - struct graphics_priv *parent,*overlays,*next; - struct point p,pclean; - int cleanup; - int overlay_disable; - int wraparound; - struct font_priv * (*font_freetype_new)(void *meth); - struct font_freetype_methods freetype_methods; - int w,h; -}; - static void overlay_rect(struct graphics_priv *parent, struct graphics_priv *overlay, int clean, QRect *r) { @@ -260,6 +263,19 @@ RenderArea::RenderArea(struct graphics_priv *priv, QWidget *parent, int w, int h } //############################################################################################################## +//# Description: QWidget:closeEvent +//# Comment: Deletes navit object and stops event loop on graphics shutdown +//############################################################################################################## +void RenderArea::closeEvent(QCloseEvent* event) +{ + struct attr navit; + navit.type=attr_navit; + navit.u.navit=this->gra->nav; + navit_destroy(navit.u.navit); + event_main_loop_quit(); + event->accept(); +} +//############################################################################################################## //# Description: QWidget:sizeHint //# Comment: This property holds the recommended size for the widget //# Authors: Martin Schaller (04/2008) @@ -1177,6 +1193,7 @@ static struct graphics_priv * graphics_qt_qpainter_new(struct navit *nav, struct ret=g_new0(struct graphics_priv, 1); ret->font_freetype_new=font_freetype_new; *meth=graphics_methods; + ret->nav=nav; #if 1 font_freetype_new(&ret->freetype_methods); meth->font_new=(struct graphics_font_priv *(*)(struct graphics_priv *, struct graphics_font_methods *, char *, int, int))ret->freetype_methods.font_new; |