/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
* Qwt Widget Library
* Copyright (C) 1997 Josef Wilgen
* Copyright (C) 2002 Uwe Rathmann
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the Qwt License, Version 1.0
*****************************************************************************/
#include <qapplication.h>
#include <qevent.h>
#include <qpainter.h>
#include <qframe.h>
#include <qcursor.h>
#include <qbitmap.h>
#include "qwt_math.h"
#include "qwt_painter.h"
#include "qwt_picker_machine.h"
#include "qwt_picker.h"
#if QT_VERSION < 0x040000
#include <qguardedptr.h>
#else
#include <qpointer.h>
#include <qpaintengine.h>
#endif
class QwtPicker::PickerWidget: public QWidget
{
public:
enum Type
{
RubberBand,
Text
};
PickerWidget(QwtPicker *, QWidget *, Type);
virtual void updateMask();
/*
For a tracker text with a background we can use the background
rect as mask. Also for "regular" Qt widgets >= 4.3.0 we
don't need to mask the text anymore.
*/
bool d_hasTextMask;
protected:
virtual void paintEvent(QPaintEvent *);
QwtPicker *d_picker;
Type d_type;
};
class QwtPicker::PrivateData
{
public:
bool enabled;
QwtPickerMachine *stateMachine;
int selectionFlags;
QwtPicker::ResizeMode resizeMode;
QwtPicker::RubberBand rubberBand;
QPen rubberBandPen;
QwtPicker::DisplayMode trackerMode;
QPen trackerPen;
QFont trackerFont;
QwtPolygon selection;
bool isActive;
QPoint trackerPosition;
bool mouseTracking; // used to save previous value
/*
On X11 the widget below the picker widgets gets paint events
with a region that is the bounding rect of the mask, if it is complex.
In case of (f.e) a CrossRubberBand and a text this creates complete
repaints of the widget. So we better use two different widgets.
*/
#if QT_VERSION < 0x040000
QGuardedPtr<PickerWidget> rubberBandWidget;
QGuardedPtr<PickerWidget> trackerWidget;
#else
QPointer<PickerWidget> rubberBandWidget;
QPointer<PickerWidget> trackerWidget;
#endif
};
QwtPicker::PickerWidget::PickerWidget(
QwtPicker *picker, QWidget *parent, Type type):
QWidget(parent),
d_hasTextMask(false),
d_picker(picker),
d_type(type)
{
#if QT_VERSION >= 0x040000
setAttribute(Qt::WA_TransparentForMouseEvents);
setAttribute(Qt::WA_NoSystemBackground);
setFocusPolicy(Qt::NoFocus);
#else
setBackgroundMode(Qt::NoBackground);
setFocusPolicy(QWidget::NoFocus);
setMouseTracking(true);
#endif
}
void QwtPicker::PickerWidget::updateMask()
{
QRegion mask;
if ( d_type == RubberBand )
{
QBitmap bm(width(), height());
bm.fill(Qt::color0);
QPainter painter(&bm);
QPen pen = d_picker->rubberBandPen();
pen.setColor(Qt::color1);
painter.setPen(pen);
d_picker->drawRubberBand(&painter);
mask = QRegion(bm);
}
if ( d_type == Text )
{
d_hasTextMask = true;
#if QT_VERSION >= 0x040300
if ( !parentWidget()->testAttribute(Qt::WA_PaintOnScreen) )
{
#if 0
if ( parentWidget()->paintEngine()->type() != QPaintEngine::OpenGL )
#endif
{
// With Qt >= 4.3 drawing of the tracker can be implemented in an
// easier way, using the textRect as mask.
d_hasTextMask = false;
}
}
#endif
if ( d_hasTextMask )
{
const QwtText label = d_picker->trackerText(
d_picker->trackerPosition());
if ( label.testPaintAttribute(QwtText::PaintBackground)
&& label.backgroundBrush().style() != Qt::NoBrush )
{
#if QT_VERSION >= 0x040300
if ( label.backgroundBrush().color().alpha() > 0 )
#endif
// We don't need a text mask, when we have a background
d_hasTextMask = false;
}
}
if ( d_hasTextMask )
{
QBitmap bm(width(), height());
bm.fill(Qt::color0);
QPainter painter(&bm);
painter.setFont(font());
QPen pen = d_picker->trackerPen();
pen.setColor(Qt::color1);
painter.setPen(pen);
d_picker->drawTracker(&painter);
mask = QRegion(bm);
#if QT_VERSION < 0x040000
const QRect tr = d_picker->trackerRect(font());
if ( mask.boundingRect().x() < tr.left() )
{
/*
Qt Bug: When painting a text into a rectangle on a bitmap
the x position of the rectangle seems to be ignored
So we manually translate the mask into the rectangle.
*/
mask.translate(tr.left(), 0);
}
#endif
}
else
{
mask = d_picker->trackerRect(font());
}
}
#if QT_VERSION < 0x040000
QWidget *w = parentWidget();
const bool doUpdate = w->isUpdatesEnabled();
const Qt::BackgroundMode bgMode = w->backgroundMode();
w->setUpdatesEnabled(false);
if ( bgMode != Qt::NoBackground )
w->setBackgroundMode(Qt::NoBackground);
#endif
setMask(mask);
#if QT_VERSION < 0x040000
if ( bgMode != Qt::NoBackground )
w->setBackgroundMode(bgMode);
w->setUpdatesEnabled(doUpdate);
#endif
setShown(!mask.isEmpty());
}
void QwtPicker::PickerWidget::paintEvent(QPaintEvent *e)
{
QPainter painter(this);
painter.setClipRegion(e->region());
if ( d_type == RubberBand )
{
painter.setPen(d_picker->rubberBandPen());
d_picker->drawRubberBand(&painter);
}
if ( d_type == Text )
{
/*
If we have a text mask we simply fill the region of
the mask. This gives better results for antialiased fonts.
*/
bool doDrawTracker = !d_hasTextMask;
#if QT_VERSION < 0x040000
if ( !doDrawTracker && QPainter::redirect(this) )
{
// setMask + painter redirection doesn't work
doDrawTracker = true;
}
#endif
if ( doDrawTracker )
{
painter.setPen(d_picker->trackerPen());
d_picker->drawTracker(&painter);
}
else
painter.fillRect(e->rect(), QBrush(d_picker->trackerPen().color()));
}
}
/*!
Constructor
Creates an picker that is enabled, but where selection flag
is set to NoSelection, rubberband and tracker are disabled.
\param parent Parent widget, that will be observed
*/
QwtPicker::QwtPicker(QWidget *parent):
QObject(parent)
{
init(parent, NoSelection, NoRubberBand, AlwaysOff);
}
/*!
Constructor
\param selectionFlags Or'd value of SelectionType, RectSelectionType and
SelectionMode
\param rubberBand Rubberband style
\param trackerMode Tracker mode
\param parent Parent widget, that will be observed
*/
QwtPicker::QwtPicker(int selectionFlags, RubberBand rubberBand,
DisplayMode trackerMode, QWidget *parent):
QObject(parent)
{
init(parent, selectionFlags, rubberBand, trackerMode);
}
//! Destructor
QwtPicker::~QwtPicker()
{
setMouseTracking(false);
delete d_data->stateMachine;
delete d_data->rubberBandWidget;
delete d_data->trackerWidget;
delete d_data;
}
//! Init the picker, used by the constructors
void QwtPicker::init(QWidget *parent, int selectionFlags,
RubberBand rubberBand, DisplayMode trackerMode)
{
d_data = new PrivateData;
d_data->rubberB
没有合适的资源?快使用搜索试试~ 我知道了~
qwt.rar_qwt_qwt 6.0.1 xp_qwt qt_qwt_data.h
共138个文件
h:70个
cpp:67个
pro:1个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 42 浏览量
2022-09-22
22:12:41
上传
评论
收藏 295KB RAR 举报
温馨提示
QT编程软件,在XP系统中。包含详细的安装。
资源推荐
资源详情
资源评论
收起资源包目录
qwt.rar_qwt_qwt 6.0.1 xp_qwt qt_qwt_data.h (138个子文件)
qwt_picker.cpp 37KB
qwt_plot_layout.cpp 37KB
qwt_plot_curve.cpp 34KB
qwt_dial.cpp 31KB
qwt_thermo.cpp 24KB
qwt_scale_draw.cpp 24KB
qwt_slider.cpp 23KB
qwt_scale_engine.cpp 22KB
qwt_scale_widget.cpp 22KB
qwt_plot.cpp 22KB
qwt_painter.cpp 20KB
qwt_text.cpp 17KB
qwt_wheel.cpp 17KB
qwt_plot_spectrogram.cpp 17KB
qwt_plot_zoomer.cpp 17KB
qwt_plot_printfilter.cpp 17KB
qwt_dyngrid_layout.cpp 17KB
qwt_dial_needle.cpp 17KB
qwt_legend.cpp 16KB
qwt_plot_axis.cpp 16KB
qwt_plot_print.cpp 16KB
qwt_double_rect.cpp 16KB
qwt_plot_rescaler.cpp 15KB
qwt_counter.cpp 15KB
qwt_panner.cpp 13KB
qwt_clipper.cpp 13KB
qwt_legend_item.cpp 13KB
qwt_abstract_slider.cpp 13KB
qwt_plot_item.cpp 12KB
qwt_knob.cpp 12KB
qwt_raster_data.cpp 12KB
qwt_plot_marker.cpp 12KB
qwt_color_map.cpp 12KB
qwt_magnifier.cpp 11KB
qwt_plot_scaleitem.cpp 11KB
qwt_text_engine.cpp 11KB
qwt_symbol.cpp 11KB
qwt_plot_picker.cpp 10KB
qwt_plot_canvas.cpp 10KB
qwt_abstract_scale_draw.cpp 10KB
qwt_picker_machine.cpp 10KB
qwt_spline.cpp 9KB
qwt_double_range.cpp 9KB
qwt_arrow_button.cpp 9KB
qwt_round_scale_draw.cpp 9KB
qwt_layout_metrics.cpp 9KB
qwt_data.cpp 8KB
qwt_plot_grid.cpp 8KB
qwt_double_interval.cpp 8KB
qwt_plot_rasteritem.cpp 8KB
qwt_compass.cpp 8KB
qwt_compass_rose.cpp 7KB
qwt_event_pattern.cpp 7KB
qwt_text_label.cpp 7KB
qwt_abstract_scale.cpp 7KB
qwt_plot_svgitem.cpp 7KB
qwt_curve_fitter.cpp 6KB
qwt_analog_clock.cpp 5KB
qwt_scale_map.cpp 5KB
qwt_plot_dict.cpp 5KB
qwt_paint_buffer.cpp 5KB
qwt_scale_div.cpp 4KB
qwt_plot_panner.cpp 4KB
qwt_plot_magnifier.cpp 4KB
qwt_interval_data.cpp 2KB
qwt_plot_xml.cpp 1KB
qwt_math.cpp 1KB
qwt_double_rect.h 12KB
qwt_picker.h 11KB
qwt_plot_curve.h 9KB
qwt_plot.h 9KB
qwt_double_interval.h 7KB
qwt_scale_engine.h 6KB
qwt_dial.h 6KB
qwt_text.h 6KB
qwt_abstract_slider.h 6KB
qwt_color_map.h 6KB
qwt_event_pattern.h 5KB
qwt_plot_item.h 5KB
qwt_thermo.h 5KB
qwt_dial_needle.h 5KB
qwt_text_engine.h 5KB
qwt_painter.h 5KB
qwt_layout_metrics.h 5KB
qwt_counter.h 5KB
qwt_scale_map.h 4KB
qwt_math.h 4KB
qwt_picker_machine.h 4KB
qwt_data.h 4KB
qwt_legend.h 4KB
qwt_slider.h 4KB
qwt_plot_rescaler.h 4KB
qwt_abstract_scale_draw.h 4KB
qwt_plot_zoomer.h 4KB
qwt_raster_data.h 3KB
qwt_scale_widget.h 3KB
qwt_plot_rasteritem.h 3KB
qwt_plot_spectrogram.h 3KB
qwt_spline.h 3KB
qwt_plot_marker.h 3KB
共 138 条
- 1
- 2
资源评论
weixin_42653672
- 粉丝: 93
- 资源: 1万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功