source: ntrip/trunk/BNC/qwt/qwt_widget_overlay.h@ 9573

Last change on this file since 9573 was 9383, checked in by stoecker, 3 years ago

update to qwt verion 6.1.1 to fix build with newer Qt5

File size: 4.0 KB
Line 
1/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
2 * Qwt Widget Library
3 * Copyright (C) 1997 Josef Wilgen
4 * Copyright (C) 2002 Uwe Rathmann
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the Qwt License, Version 1.0
8 *****************************************************************************/
9
10#ifndef QWT_WIDGET_OVERLAY_H
11#define QWT_WIDGET_OVERLAY_H
12
13#include "qwt_global.h"
14#include <qwidget.h>
15#include <qregion.h>
16
17class QPainter;
18
19/*!
20 \brief An overlay for a widget
21
22 The main use case of an widget overlay is to avoid
23 heavy repaint operation of the widget below.
24
25 F.e. in combination with the plot canvas an overlay
26 avoid replots as the content of the canvas can be restored from
27 its backing store.
28
29 QwtWidgetOverlay is an abstract base class. Deriving classes are
30 supposed to reimplement the following methods:
31
32 - drawOverlay()
33 - maskHint()
34
35 Internally QwtPlotPicker uses overlays for displaying
36 the rubber band and the tracker text.
37
38 \sa QwtPlotCanvas::BackingStore
39 */
40class QWT_EXPORT QwtWidgetOverlay: public QWidget
41{
42public:
43 /*!
44 \brief Mask mode
45
46 When using masks the widget below gets paint events for
47 the masked regions of the overlay only. Otherwise
48 Qt triggers full repaints. On less powerful hardware
49 ( f.e embedded systems ) - or when using the raster paint
50 engine on a remote desktop - bit blitting is a noticeable
51 operation, that needs to be avoided.
52
53 If and how to mask depends on how expensive the calculation
54 of the mask is and how many pixels can be excluded by the mask.
55
56 The default setting is MaskHint.
57
58 \sa setMaskMode(), maskMode()
59 */
60 enum MaskMode
61 {
62 //! Don't use a mask.
63 NoMask,
64
65 /*!
66 \brief Use maskHint() as mask
67
68 For many situations a fast approximation is good enough
69 and it is not necessary to build a more detailed mask
70 ( f.e the bounding rectangle of a text ).
71 */
72 MaskHint,
73
74 /*!
75 \brief Calculate a mask by checking the alpha values
76
77 Sometimes it is not possible to give a fast approximation
78 and the mask needs to be calculated by drawing the overlay
79 and testing the result.
80
81 When a valid maskHint() is available
82 only pixels inside this approximation are checked.
83 */
84 AlphaMask
85 };
86
87 /*!
88 \brief Render mode
89
90 For calculating the alpha mask the overlay has already
91 been painted to a temporary QImage. Instead of rendering
92 the overlay twice this buffer can be copied for drawing
93 the overlay.
94
95 On graphic systems using the raster paint engine ( QWS, Windows )
96 it means usually copying some memory only. On X11 it results in an
97 expensive operation building a pixmap and for simple overlays
98 it might not be recommended.
99
100 \note The render mode has no effect, when maskMode() != AlphaMask.
101 */
102 enum RenderMode
103 {
104 //! Copy the buffer, when using the raster paint engine.
105 AutoRenderMode,
106
107 //! Always copy the buffer
108 CopyAlphaMask,
109
110 //! Never copy the buffer
111 DrawOverlay
112 };
113
114 QwtWidgetOverlay( QWidget* );
115 virtual ~QwtWidgetOverlay();
116
117 void setMaskMode( MaskMode );
118 MaskMode maskMode() const;
119
120 void setRenderMode( RenderMode );
121 RenderMode renderMode() const;
122
123 void updateOverlay();
124
125 virtual bool eventFilter( QObject *, QEvent *);
126
127protected:
128 virtual void paintEvent( QPaintEvent* event );
129 virtual void resizeEvent( QResizeEvent* event );
130
131 virtual QRegion maskHint() const;
132
133 /*!
134 Draw the widget overlay
135 \param painter Painter
136 */
137 virtual void drawOverlay( QPainter *painter ) const = 0;
138
139private:
140 void updateMask();
141 void draw( QPainter * ) const;
142
143private:
144 class PrivateData;
145 PrivateData *d_data;
146};
147
148#endif
Note: See TracBrowser for help on using the repository browser.