Skip to content
Permalink
Browse files
Add composer rulers to composer graphics view
  • Loading branch information
mhugent committed Jan 28, 2013
1 parent 7c2c73b commit 6ef3c2a8c8384669639bb1d0abdd14d2d36ef960
Showing with 22 additions and 1 deletion.
  1. +1 −1 src/gui/qgscomposerruler.cpp
  2. +17 −0 src/gui/qgscomposerview.cpp
  3. +4 −0 src/gui/qgscomposerview.h
@@ -3,7 +3,7 @@

const int RULER_MIN_SIZE = 20;

QgsComposerRuler::QgsComposerRuler( QgsComposerRuler::Direction d ): mDirection( d )
QgsComposerRuler::QgsComposerRuler( QgsComposerRuler::Direction d ): QWidget( 0 ), mDirection( d )
{
}

@@ -21,6 +21,7 @@
#include <QKeyEvent>
#include <QClipboard>
#include <QMimeData>
#include <QGridLayout>

#include "qgscomposerview.h"
#include "qgscomposerarrow.h"
@@ -31,6 +32,7 @@
#include "qgscomposermap.h"
#include "qgscomposeritemgroup.h"
#include "qgscomposerpicture.h"
#include "qgscomposerruler.h"
#include "qgscomposerscalebar.h"
#include "qgscomposershape.h"
#include "qgscomposerattributetable.h"
@@ -48,6 +50,21 @@ QgsComposerView::QgsComposerView( QWidget* parent, const char* name, Qt::WFlags
Q_UNUSED( f );
Q_UNUSED( name );


QGridLayout* gridLayout = new QGridLayout();
gridLayout->setSpacing( 0 );
gridLayout->setMargin( 0 );
mHorizontalRuler = new QgsComposerRuler( QgsComposerRuler::Horizontal );
mVerticalRuler = new QgsComposerRuler( QgsComposerRuler::Vertical );
QWidget* fake = new QWidget();
fake->setBackgroundRole( QPalette::Window );
fake->setFixedSize( 20, 20 );
gridLayout->addWidget( fake, 0, 0 );
gridLayout->addWidget( mHorizontalRuler, 0, 1 );
gridLayout->addWidget( mVerticalRuler, 1, 0 );
gridLayout->addWidget( this->viewport(), 1, 1 );
this->setLayout( gridLayout );

setResizeAnchor( QGraphicsView::AnchorViewCenter );
setMouseTracking( true );
viewport()->setMouseTracking( true );
@@ -32,6 +32,7 @@ class QgsComposerLabel;
class QgsComposerLegend;
class QgsComposerMap;
class QgsComposerPicture;
class QgsComposerRuler;
class QgsComposerScaleBar;
class QgsComposerShape;
class QgsComposerAttributeTable;
@@ -123,6 +124,9 @@ class GUI_EXPORT QgsComposerView: public QGraphicsView

bool mPaintingEnabled;

QgsComposerRuler* mHorizontalRuler;
QgsComposerRuler* mVerticalRuler;

/** Draw a shape on the canvas */
void addShape( Tool currentTool );

0 comments on commit 6ef3c2a

Please sign in to comment.