#include <QCursor>
#include <QGraphicsSceneMouseEvent>
+#include <QGridLayout>
#include <QLabel>
#include <QMoveEvent>
#include <QRectF>
#include <QRubberBand>
#include <QScrollBar>
-#include <QVBoxLayout>
#include <math.h>
GraphicsView_ViewPort::GraphicsView_ViewPort( QWidget* theParent )
: QGraphicsView( theParent ),
myNameLabel( 0 ),
+ myNamePosition( NP_None ),
+ myNameLayout( 0 ),
myForegroundItem( 0 ),
myIsTransforming( false ),
myHighlightedObject( 0 ),
// Function : setViewNameEnabled
// Purpose :
//================================================================
-void GraphicsView_ViewPort::setViewNameEnabled( bool theState,
- bool theIsForced )
+void GraphicsView_ViewPort::setViewNamePosition( NamePosition thePosition,
+ bool theIsForced )
{
if( theIsForced && !myNameLabel )
- {
myNameLabel = new NameLabel( viewport() );
- QBoxLayout* aLayout = new QVBoxLayout( viewport() );
- aLayout->setMargin( 10 );
- aLayout->setSpacing( 0 );
- aLayout->addStretch();
- aLayout->addWidget( myNameLabel );
+ if( !myNameLabel )
+ return;
+
+ if( thePosition == NP_None )
+ {
+ myNameLabel->setVisible( false );
+ return;
}
- if( myNameLabel )
- myNameLabel->setVisible( theState );
+ if( myNameLayout )
+ delete myNameLayout;
+
+ myNameLayout = new QGridLayout( viewport() );
+ myNameLayout->setMargin( 10 );
+ myNameLayout->setSpacing( 0 );
+
+ int aRow = 0, aColumn = 0;
+ switch( thePosition )
+ {
+ case NP_TopLeft: aRow = 0; aColumn = 0; break;
+ case NP_TopRight: aRow = 0; aColumn = 1; break;
+ case NP_BottomLeft: aRow = 1; aColumn = 0; break;
+ case NP_BottomRight: aRow = 1; aColumn = 1; break;
+ default: break;
+ }
+
+ myNameLayout->addWidget( myNameLabel, aRow, aColumn );
+ myNameLayout->setRowStretch( 1 - aRow, 1 );
+ myNameLayout->setColumnStretch( 1 - aColumn, 1 );
+
+ myNameLabel->setVisible( true );
}
//================================================================
#include <QGraphicsView>
+class QGridLayout;
class QRubberBand;
class GraphicsView_Object;
BS_Dragging = 0x0002 // currently unused
};
+ enum NamePosition
+ {
+ NP_None = 0,
+ NP_TopLeft = 1,
+ NP_TopRight = 2,
+ NP_BottomLeft = 3,
+ NP_BottomRight = 4
+ };
+
public:
GraphicsView_ViewPort( QWidget* theParent );
~GraphicsView_ViewPort();
void setFitAllGap( double theFitAllGap );
// view name
- void setViewNameEnabled( bool theState, bool theIsForced = false );
+ void setViewNamePosition( NamePosition thePosition,
+ bool theIsForced = false );
void setViewName( const QString& theName );
// background / foreground
// view name
NameLabel* myNameLabel;
+ NamePosition myNamePosition;
+ QGridLayout* myNameLayout;
// foreground
bool myIsForegroundEnabled;