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 | // vim: expandtab
|
---|
11 |
|
---|
12 | #ifndef QWT_LEGEND_H
|
---|
13 | #define QWT_LEGEND_H
|
---|
14 |
|
---|
15 | #include <qframe.h>
|
---|
16 | #include "qwt_global.h"
|
---|
17 | #if QT_VERSION < 0x040000
|
---|
18 | #include <qvaluelist.h>
|
---|
19 | #else
|
---|
20 | #include <qlist.h>
|
---|
21 | #endif
|
---|
22 |
|
---|
23 | class QScrollBar;
|
---|
24 | class QwtLegendItemManager;
|
---|
25 |
|
---|
26 | /*!
|
---|
27 | \brief The legend widget
|
---|
28 |
|
---|
29 | The QwtLegend widget is a tabular arrangement of legend items. Legend
|
---|
30 | items might be any type of widget, but in general they will be
|
---|
31 | a QwtLegendItem.
|
---|
32 |
|
---|
33 | \sa QwtLegendItem, QwtLegendItemManager QwtPlot
|
---|
34 | */
|
---|
35 |
|
---|
36 | class QWT_EXPORT QwtLegend : public QFrame
|
---|
37 | {
|
---|
38 | Q_OBJECT
|
---|
39 |
|
---|
40 | public:
|
---|
41 | /*!
|
---|
42 | \brief Display policy
|
---|
43 |
|
---|
44 | - NoIdentifier\n
|
---|
45 | The client code is responsible how to display of each legend item.
|
---|
46 | The Qwt library will not interfere.
|
---|
47 |
|
---|
48 | - FixedIdentifier\n
|
---|
49 | All legend items are displayed with the QwtLegendItem::IdentifierMode
|
---|
50 | to be passed in 'mode'.
|
---|
51 |
|
---|
52 | - AutoIdentifier\n
|
---|
53 | Each legend item is displayed with a mode that is a bitwise or of
|
---|
54 | - QwtLegendItem::ShowLine (if its curve is drawn with a line) and
|
---|
55 | - QwtLegendItem::ShowSymbol (if its curve is drawn with symbols) and
|
---|
56 | - QwtLegendItem::ShowText (if the has a title).
|
---|
57 |
|
---|
58 | Default is AutoIdentifier.
|
---|
59 | \sa setDisplayPolicy(), displayPolicy(), QwtLegendItem::IdentifierMode
|
---|
60 | */
|
---|
61 |
|
---|
62 | enum LegendDisplayPolicy
|
---|
63 | {
|
---|
64 | NoIdentifier = 0,
|
---|
65 | FixedIdentifier = 1,
|
---|
66 | AutoIdentifier = 2
|
---|
67 | };
|
---|
68 |
|
---|
69 | /*!
|
---|
70 | \brief Interaction mode for the legend items
|
---|
71 |
|
---|
72 | - ReadOnlyItem\n
|
---|
73 | The legend item is not interactive, like a label
|
---|
74 |
|
---|
75 | - ClickableItem\n
|
---|
76 | The legend item is clickable, like a push button
|
---|
77 |
|
---|
78 | - CheckableItem\n
|
---|
79 | The legend item is checkable, like a checkable button
|
---|
80 |
|
---|
81 | Default is ReadOnlyItem.
|
---|
82 | \sa setItemMode(), itemMode(), QwtLegendItem::IdentifierMode
|
---|
83 | QwtLegendItem::clicked(), QwtLegendItem::checked(),
|
---|
84 | QwtPlot::legendClicked(), QwtPlot::legendChecked()
|
---|
85 | */
|
---|
86 |
|
---|
87 | enum LegendItemMode
|
---|
88 | {
|
---|
89 | ReadOnlyItem,
|
---|
90 | ClickableItem,
|
---|
91 | CheckableItem
|
---|
92 | };
|
---|
93 |
|
---|
94 | explicit QwtLegend(QWidget *parent = NULL);
|
---|
95 | virtual ~QwtLegend();
|
---|
96 |
|
---|
97 | void setDisplayPolicy(LegendDisplayPolicy policy, int mode);
|
---|
98 | LegendDisplayPolicy displayPolicy() const;
|
---|
99 |
|
---|
100 | void setItemMode(LegendItemMode);
|
---|
101 | LegendItemMode itemMode() const;
|
---|
102 |
|
---|
103 | int identifierMode() const;
|
---|
104 |
|
---|
105 | QWidget *contentsWidget();
|
---|
106 | const QWidget *contentsWidget() const;
|
---|
107 |
|
---|
108 | void insert(const QwtLegendItemManager *, QWidget *);
|
---|
109 | void remove(const QwtLegendItemManager *);
|
---|
110 |
|
---|
111 | QWidget *find(const QwtLegendItemManager *) const;
|
---|
112 | QwtLegendItemManager *find(const QWidget *) const;
|
---|
113 |
|
---|
114 | #if QT_VERSION < 0x040000
|
---|
115 | virtual QValueList<QWidget *> legendItems() const;
|
---|
116 | #else
|
---|
117 | virtual QList<QWidget *> legendItems() const;
|
---|
118 | #endif
|
---|
119 |
|
---|
120 | void clear();
|
---|
121 |
|
---|
122 | bool isEmpty() const;
|
---|
123 | uint itemCount() const;
|
---|
124 |
|
---|
125 | virtual bool eventFilter(QObject *, QEvent *);
|
---|
126 |
|
---|
127 | virtual QSize sizeHint() const;
|
---|
128 | virtual int heightForWidth(int w) const;
|
---|
129 |
|
---|
130 | QScrollBar *horizontalScrollBar() const;
|
---|
131 | QScrollBar *verticalScrollBar() const;
|
---|
132 |
|
---|
133 | protected:
|
---|
134 | virtual void resizeEvent(QResizeEvent *);
|
---|
135 | virtual void layoutContents();
|
---|
136 |
|
---|
137 | private:
|
---|
138 | class PrivateData;
|
---|
139 | PrivateData *d_data;
|
---|
140 | };
|
---|
141 |
|
---|
142 | #endif // QWT_LEGEND_H
|
---|