Skip to content

Commit

Permalink
Add class QgsComposerRuler
Browse files Browse the repository at this point in the history
  • Loading branch information
mhugent committed Jan 28, 2013
1 parent 4cbec18 commit 7c2c73b
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/gui/CMakeLists.txt
Expand Up @@ -51,6 +51,7 @@ qgslegendinterface.cpp
qgscharacterselectdialog.cpp
qgscolorbutton.cpp
qgscomposerview.cpp
qgscomposerruler.cpp
qgscursors.cpp
qgsdetaileditemdelegate.cpp
qgsdetaileditemwidget.cpp
Expand Down
26 changes: 26 additions & 0 deletions src/gui/qgscomposerruler.cpp
@@ -0,0 +1,26 @@
#include "qgscomposerruler.h"
#include <QPainter>

const int RULER_MIN_SIZE = 20;

QgsComposerRuler::QgsComposerRuler( QgsComposerRuler::Direction d ): mDirection( d )
{
}

QgsComposerRuler::~QgsComposerRuler()
{
}

QSize QgsComposerRuler::minimumSizeHint() const
{
return QSize( RULER_MIN_SIZE, RULER_MIN_SIZE );
}

void QgsComposerRuler::paintEvent( QPaintEvent* event )
{
Q_UNUSED( event );

//draw blue rectangle for a test
QPainter p( this );
p.fillRect( rect(), QColor( 0, 0, 255 ) );
}
28 changes: 28 additions & 0 deletions src/gui/qgscomposerruler.h
@@ -0,0 +1,28 @@
#ifndef QGSCOMPOSERRULER_H
#define QGSCOMPOSERRULER_H

#include <QWidget>

/**A class to show paper scale and the current cursor position*/
class QgsComposerRuler: public QWidget
{
public:
enum Direction
{
Horizontal = 0,
Vertical
};

QgsComposerRuler( QgsComposerRuler::Direction d );
~QgsComposerRuler();

QSize minimumSizeHint() const;

protected:
void paintEvent( QPaintEvent* event );

private:
Direction mDirection;
};

#endif // QGSCOMPOSERRULER_H

0 comments on commit 7c2c73b

Please sign in to comment.