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

📄 wxcasprint.cpp

📁 电驴的MAC源代码
💻 CPP
字号:
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// Name:         wxCasPrint Class////// Purpose:      Manage statistics image printing////// Author:       ThePolish <thepolish@vipmail.ru>////// Copyright (C) 2004 by ThePolish////// Derived from CAS by Pedro de Oliveira <falso@rdk.homeip.net>////// Pixmats from aMule http://www.amule.org////// This program is free software; you can redistribute it and/or modify///  it under the terms of the GNU General Public License as published by/// the Free Software Foundation; either version 2 of the License, or/// (at your option) any later version.////// This program is distributed in the hope that it will be useful,/// but WITHOUT ANY WARRANTY; without even the implied warranty of/// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the/// GNU General Public License for more details.////// You should have received a copy of the GNU General Public License/// along with this program; if not, write to the/// Free Software Foundation, Inc.,/// 51 Franklin St, Fifth Floor, Boston, MA  02110-1301, USA//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////#ifdef __BORLANDC__ #pragma hdrstop#endif// For all others, include the necessary headers#ifndef WX_PRECOMP #include "wx/wx.h"#endif#include <wx/image.h>#include "wxcas.h"#include "wxcasframe.h"#include "wxcasprint.h"// ConstructorWxCasPrint::WxCasPrint ( const wxString& title ) : wxPrintout ( title ){}// DestructorWxCasPrint::~WxCasPrint (){}boolWxCasPrint::OnPrintPage ( int page ){	wxDC * dc = GetDC ();	if ( dc ) {		if ( page == 1 ) {			DrawPageOne ( dc );		}		dc->SetDeviceOrigin ( 0, 0 );		dc->SetUserScale ( 1.0, 1.0 );		return TRUE;	} else {		return FALSE;	}}boolWxCasPrint::OnBeginDocument ( int startPage, int endPage ){	if ( !wxPrintout::OnBeginDocument ( startPage, endPage ) ) {		return FALSE;	} else {		return TRUE;	}}voidWxCasPrint::GetPageInfo ( int *minPage, int *maxPage, int *selPageFrom,                          int *selPageTo ){	*minPage = 1;	*maxPage = 1;	*selPageFrom = 1;	*selPageTo = 1;}boolWxCasPrint::HasPage ( int pageNum ){	return ( pageNum == 1 );}voidWxCasPrint::DrawPageOne ( wxDC * dc ){	wxInt32 dc_w, dc_h;	// Get the size of the DC in pixels	dc->GetSize ( &dc_w, &dc_h );	// Get the size of the image in pixels	wxImage *statImage = wxGetApp ().GetMainFrame () ->GetStatImage ();	wxUint32 marginX = 50;	wxUint32 marginY = 50;	wxUint32 sizeX = statImage->GetWidth () + 2 * marginX;	wxUint32 sizeY = statImage->GetHeight () + 2 * marginY;	// Calculate a suitable scaling factor	float scale = wxMin ( ( float ) ( dc_w ) / sizeX, ( float ) ( dc_h ) / sizeY );	// Calculate the position on the DC for centring the graphic	float posX = marginX + ( dc_w - sizeX * scale ) / 2.0;	float posY = marginY + ( dc_h - sizeY * scale ) / 2.0;	// Set the scale and origin	dc->SetUserScale ( scale, scale );	dc->SetDeviceOrigin ( ( wxCoord ) posX, ( wxCoord ) posY );	// Draw image	dc->DrawBitmap ( wxBitmap( *statImage ), 0, 0, FALSE );}// File_checked_for_headers

⌨️ 快捷键说明

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