⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ncreportdesignerdocument.cpp

📁 基于QT的报表工具
💻 CPP
📖 第 1 页 / 共 2 页
字号:
	else if ( po.pageSize == "B0" ) {		w = 1030.0; h = 1456.0;	}	else if ( po.pageSize == "B1" ) {		w = 728.0; h = 1030.0;	}	else if ( po.pageSize == "B10" ) {		w = 32.0; h = 45.0;	}	else if ( po.pageSize == "B2" ) {		w = 515.0; h = 728.0;	}	else if ( po.pageSize == "B3" ) {		w = 364.0; h = 515.0;	}	else if ( po.pageSize == "B4" ) {		w = 257.0; h = 364.0;	}	else if ( po.pageSize == "B5" ) {		w = 182.0; h = 257.0;	}	else if ( po.pageSize == "B6" ) {		w = 128.0; h = 182.0;	}	else if ( po.pageSize == "B7" ) {		w = 91.0; h = 128.0;	}	else if ( po.pageSize == "B8" ) {		w = 64.0; h = 91.0;	}	else if ( po.pageSize == "B9" ) {		w = 45.0; h = 764.0;	}	else if ( po.pageSize == "C5E" ) {		w = 163.0; h = 229.0;	}	else if ( po.pageSize == "COMM10E" ) {		w = 105.0; h = 241.0;	}	else if ( po.pageSize == "DLE" ) {		w = 110.0; h = 220.0;	}	else if ( po.pageSize == "EXECUTIVE" ) {		w = 191.0; h = 254.0;	}	else if ( po.pageSize == "FOLIO" ) {		w = 210.0; h = 330.0;	}	else if ( po.pageSize == "LEDGER" ) {		w = 432.0; h = 279.0;	}	else if ( po.pageSize == "LEGAL" ) {		w = 216.0; h = 356.0;	}	else if ( po.pageSize == "LETTER" ) {		w = 216.0; h = 279.0;	}	else if ( po.pageSize == "TABLOID" ) {		w = 279.0; h = 432.0;	}	if ( po.orient == ReportPageOptions::Landscape ) {		//change width/heigt		double _w = w;		w = h;		h = _w;	}		if ( sect ) {// set size for only a section		sect->setWidth( w - po.leftMargin - po.rightMargin );	} else { // set size for whole document		setPageWidth( w );	}}///////////////////////////////////// Ruler///////////////////////////////////NCReportDesignerRuler::NCReportDesignerRuler( Qt::Orientation ori, QWidget * parent ) 	: QWidget( parent ){	//zoomlevel = 1.0;	orient = ori;	m = 0;	scStart = 0;	const int rulerH = RULERWEIGHT;	//setPalette( QPalette( Qt::white ) );	//setBackgroundRole( QPalette::Base );	//setFrameStyle( StyledPanel | Raised );	//setFrameStyle( QFrame::Panel | QFrame::Raised);	if ( orient == Qt::Horizontal ) {		setMinimumHeight(rulerH);		setMaximumHeight(rulerH);	} else {		setMinimumWidth(rulerH);		setMaximumWidth(rulerH);	}			resize(rulerH,rulerH);}NCReportDesignerRuler::~ NCReportDesignerRuler( ){}void NCReportDesignerRuler::paintEvent( QPaintEvent * ){	if ( !m )		return;		QPainter p( this );	double incr = 5.00000;	const double lheight_long = 6.0;	const double lheight_short = 3.0;	double h =0.0;	int counter=0;		incr = m->measureUnit();			/*	if ( msr == Metric )		incr = 72.0/25.4*TRIMFACTOR*zoomlevel;	else		incr = 7.2*TRIMFACTOR*zoomlevel;*/		p.setPen(Qt::black);	QFont f;#ifdef Q_WS_WIN	//f.setFamily("MS Sans Serif");	f.setPixelSize( 8 );#else	f.setPixelSize( 8 );#endif	QString lbl;	QFontMetrics fm( f );	p.setFont( f );		int to = ( orient == Qt::Horizontal ? width() : height() );	bool stick = true;	for ( double r=0.0 ; r< to; r+=incr ) {		if ( counter%5 == 0 ) {			h = lheight_long;			stick = true;		} else {			h = lheight_short;			stick = false;		}				if ( counter%10 == 0 ) {			h = 10.0;			lbl.setNum( counter/10 );			if ( orient == Qt::Horizontal )				p.drawText( qRound(scStart + r-fm.width(lbl)/2), 21, lbl );			else				p.drawText( 11, qRound(scStart + 10+r-fm.height()/2), lbl );		}		if ( orient == Qt::Horizontal ) {			//QLineF line( r, 0.0, r, h );			//p.drawLine( line ); 			if ( stick ) p.drawLine( scStart + qRound(r), 0, scStart + qRound(r), (int)h );		} else {			//QLineF line( 0.0, r, h, r );			//p.drawLine( line ); 			if ( stick ) p.drawLine( 0, scStart + qRound(r), (int)h, scStart + qRound(r) );		}		counter++;	}		if ( orient == Qt::Horizontal )		p.drawLine( 0,0,width(),0 );	else		p.drawLine( 0, 0, 0, height() );	//p.drawRect( 0,0,width(),height() );	}void NCReportDesignerRuler::setScaleStartPoint( int p ){	scStart = p;}///////////////////////////////////// Resizer Bar///////////////////////////////////NCReportDesignerResizeBar::NCReportDesignerResizeBar( QWidget * parent ) 	: QWidget( parent ){	//setFrameStyle( WinPanel | Raised);	setMinimumHeight(7);	setMaximumHeight(7);	setCursor( QCursor( Qt::SizeVerCursor) );	resize(7,7);	//setBackgroundRole(QPalette::Button);}NCReportDesignerResizeBar::~ NCReportDesignerResizeBar( ){}void NCReportDesignerResizeBar::mouseMoveEvent(QMouseEvent * e){	e->accept();    //qDebug("%d", e->y());	emit barDragged(e->y());}void NCReportDesignerResizeBar::paintEvent( QPaintEvent * ){	QPainter p( this );	style().drawPrimitive(QStyle::PE_Splitter, &p, rect(), colorGroup() );}///////////////////////////////////// Designer section///////////////////////////////////NCReportDesignerSection::NCReportDesignerSection( NCReportDesignerWindow * mwin, QWidget * parent, const QString& cap, const char* name )	: QWidget( parent, name ){	mainwindow = mwin;	caption = cap;	init();}NCReportDesignerSection::NCReportDesignerSection( SectionType t, NCReportDesignerWindow * mwin, QWidget * parent, const QString& cap, const char * name )	: QWidget( parent, name ){	type = t;	mainwindow = mwin;	caption = cap;	init();}NCReportDesignerSection::~ NCReportDesignerSection( ){}void NCReportDesignerSection::init( ){	QVBoxLayout *layout = new QVBoxLayout( this );	layout->setMargin(0);	layout->setSpacing(0);	footerSection = 0;	//layout->setSizeConstraint( QLayout::SetNoConstraint );/*	title = new QLabel( tr("Title"), this );	title->setFrameStyle( QFrame::WinPanel | QFrame::Raised);*/		title = new NCReportDesignerSectionTitle( this, "title" );	//title->setText( tr("Section:")+" "+caption );	title->setText( caption );	layout->addWidget(title);	//title->setMaximumHeight( 18 );	//title->setBackgroundRole(QPalette::Button);	QHBoxLayout *layMS = new QHBoxLayout( layout );	layMS->setMargin(0);	layMS->setSpacing(0);	ruler = new NCReportDesignerRuler( Qt::Vertical, this );	designarea = new NCReportDesignerDesignArea( mainwindow, this, "designarea", 0 );	layMS->addWidget( ruler );	layMS->addWidget( designarea );	//designarea->setMinimumSize( QSize(640, 5) );		// resizer bar		rbar = new NCReportDesignerResizeBar( this );	connect( rbar, SIGNAL(barDragged(int)), this, SLOT(resizeBarDragged(int) ) );	layout->addWidget(rbar);		//setLayout(layout);		//////////////////////	//setMaximumWidth( qRound(72.0/25.4*210*TRIMFACTOR) );	//test	//resize( qRound(72.0/25.4*210*TRIMFACTOR), 10 );	//test}void NCReportDesignerSection::setTitle( const QString & s, const QPixmap& pm ){	title->setText( s );	title->setPixmap( pm );}void NCReportDesignerSection::setTitle( const QString & s ){	title->setText( s );}void NCReportDesignerSection::resizeBarDragged( int d ){	int h = designarea->height() + d;	if( h < 1) h = 1;/*	if(grid->isSnap()) {		int incr = (int)(grid->yInterval() * dpiY);		int nh = (h / incr) * incr;		if(nh == 0) nh = incr;		h = nh;	}*/	designarea->setMinimumHeight(h);	//designarea->resize(designarea->width(), h);	//if(canvasview->document()) canvasview->document()->setModified(TRUE);}	NCReportDesignerDesignArea * NCReportDesignerSection::designArea( ){	return designarea;}void NCReportDesignerSection::setMeasurement( Measurement* msr ){	m = msr;	ruler->setMeasurement( m );	designarea->setMeasurement( m );}void NCReportDesignerSection::setGroupSettings( const QString & expr, const QString & rvars ){	groupExpr = expr;	resetVars = rvars;}void NCReportDesignerSection::setType( SectionType t ){	type = t;}void NCReportDesignerSection::setWidth( double dw ){	int w = m->measureToPixel( dw );	if ( w != designarea->width() ) 		designarea->setFixedWidth( w );}void NCReportDesignerSection::setHeight( double dh ){	designarea->setMinimumHeight( m->measureToPixel( dh ) );}void NCReportDesignerSection::setFooterSection( NCReportDesignerSection *s ){	footerSection = s;}NCReportDesignerSection * NCReportDesignerSection::getFooterSection( ){	return footerSection;}NCReportDesignerSectionTitle * NCReportDesignerSection::Title(){	return title;}//--------------------------------------------// Title//--------------------------------------------NCReportDesignerSectionTitle::NCReportDesignerSectionTitle( QWidget * parent, const char * name )	: QWidget( parent, name ){	topMargin = 2;	//setFrameStyle( QFrame::WinPanel | QFrame::Raised);	setFixedHeight( 18 );	pm = QPixmap("images/bullet_arrow_down.png");}NCReportDesignerSectionTitle::~ NCReportDesignerSectionTitle( ){}void NCReportDesignerSectionTitle::paintEvent( QPaintEvent * ){	QPainter p( this );		style().drawControl(QStyle::CE_PushButton, &p, this, rect(), colorGroup() );			int tpos = 4;	if ( !pm.isNull() ) {		//p.drawPixmap( 4, topMargin, pm );		p.drawPixmap( 4, 0, pm );		tpos += pm.width()+4;	}	//if ( !text.isEmpty() )	//p.drawText( tpos, height()-topMargin, text );	//QRect r = p.boundingRect( tpos, topMargin, width()-tpos, height(), Qt::AlignLeft, text ); 		p.drawText( tpos, topMargin, width()-2, height()-2, Qt::AlignLeft | Qt::AlignTop, text );		//p.drawText( tpos, height()-topMargin, text );	//p.drawText( tpos, topMargin, text );}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -