Skip to content

Commit 7c2c73b

Browse files
committed
Add class QgsComposerRuler
1 parent 4cbec18 commit 7c2c73b

File tree

3 files changed

+55
-0
lines changed

3 files changed

+55
-0
lines changed

src/gui/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ qgslegendinterface.cpp
5151
qgscharacterselectdialog.cpp
5252
qgscolorbutton.cpp
5353
qgscomposerview.cpp
54+
qgscomposerruler.cpp
5455
qgscursors.cpp
5556
qgsdetaileditemdelegate.cpp
5657
qgsdetaileditemwidget.cpp

src/gui/qgscomposerruler.cpp

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#include "qgscomposerruler.h"
2+
#include <QPainter>
3+
4+
const int RULER_MIN_SIZE = 20;
5+
6+
QgsComposerRuler::QgsComposerRuler( QgsComposerRuler::Direction d ): mDirection( d )
7+
{
8+
}
9+
10+
QgsComposerRuler::~QgsComposerRuler()
11+
{
12+
}
13+
14+
QSize QgsComposerRuler::minimumSizeHint() const
15+
{
16+
return QSize( RULER_MIN_SIZE, RULER_MIN_SIZE );
17+
}
18+
19+
void QgsComposerRuler::paintEvent( QPaintEvent* event )
20+
{
21+
Q_UNUSED( event );
22+
23+
//draw blue rectangle for a test
24+
QPainter p( this );
25+
p.fillRect( rect(), QColor( 0, 0, 255 ) );
26+
}

src/gui/qgscomposerruler.h

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#ifndef QGSCOMPOSERRULER_H
2+
#define QGSCOMPOSERRULER_H
3+
4+
#include <QWidget>
5+
6+
/**A class to show paper scale and the current cursor position*/
7+
class QgsComposerRuler: public QWidget
8+
{
9+
public:
10+
enum Direction
11+
{
12+
Horizontal = 0,
13+
Vertical
14+
};
15+
16+
QgsComposerRuler( QgsComposerRuler::Direction d );
17+
~QgsComposerRuler();
18+
19+
QSize minimumSizeHint() const;
20+
21+
protected:
22+
void paintEvent( QPaintEvent* event );
23+
24+
private:
25+
Direction mDirection;
26+
};
27+
28+
#endif // QGSCOMPOSERRULER_H

0 commit comments

Comments
 (0)