beautify
This commit is contained in:
parent
2a0fd4efd6
commit
2caad6b121
|
@ -1,4 +1,5 @@
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
// Name: copy_to_clipboard.cpp
|
// Name: copy_to_clipboard.cpp
|
||||||
// Author: jean-pierre Charras
|
// Author: jean-pierre Charras
|
||||||
// Created: 18 aug 2006
|
// Created: 18 aug 2006
|
||||||
|
@ -23,64 +24,69 @@
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
#include "id.h"
|
#include "id.h"
|
||||||
|
|
||||||
extern BASE_SCREEN * ActiveScreen;
|
extern BASE_SCREEN* ActiveScreen;
|
||||||
|
|
||||||
static const bool s_PlotBlackAndWhite = FALSE;
|
static const bool s_PlotBlackAndWhite = FALSE;
|
||||||
static const bool Print_Sheet_Ref = TRUE;
|
static const bool Print_Sheet_Ref = TRUE;
|
||||||
|
|
||||||
static bool DrawPage(WinEDA_DrawPanel * panel);
|
static bool DrawPage( WinEDA_DrawPanel* panel );
|
||||||
|
|
||||||
/************************************************************/
|
/************************************************************/
|
||||||
void WinEDA_DrawFrame::CopyToClipboard(wxCommandEvent& event)
|
void WinEDA_DrawFrame::CopyToClipboard( wxCommandEvent& event )
|
||||||
/************************************************************/
|
/************************************************************/
|
||||||
|
|
||||||
/* calls the function to copy the current page or the current bock to the clipboard
|
/* calls the function to copy the current page or the current bock to the clipboard
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
DrawPage(DrawPanel);
|
DrawPage( DrawPanel );
|
||||||
|
|
||||||
if( event.GetId() == ID_GEN_COPY_BLOCK_TO_CLIPBOARD )
|
if( event.GetId() == ID_GEN_COPY_BLOCK_TO_CLIPBOARD )
|
||||||
{
|
{
|
||||||
if (GetScreen()->BlockLocate.m_Command != BLOCK_IDLE)
|
if( GetScreen()->BlockLocate.m_Command != BLOCK_IDLE )
|
||||||
DrawPanel->SetCursor(wxCursor(DrawPanel->m_PanelCursor = DrawPanel->m_PanelDefaultCursor) );
|
DrawPanel->SetCursor( wxCursor( DrawPanel->m_PanelCursor =
|
||||||
|
DrawPanel->m_PanelDefaultCursor ) );
|
||||||
|
|
||||||
if( DrawPanel->ManageCurseur && DrawPanel->ForceCloseManageCurseur )
|
if( DrawPanel->ManageCurseur && DrawPanel->ForceCloseManageCurseur )
|
||||||
{
|
{
|
||||||
wxClientDC dc(DrawPanel);
|
wxClientDC dc( DrawPanel );
|
||||||
DrawPanel->PrepareGraphicContext(&dc);
|
|
||||||
DrawPanel->ForceCloseManageCurseur(DrawPanel, &dc);
|
DrawPanel->PrepareGraphicContext( &dc );
|
||||||
|
DrawPanel->ForceCloseManageCurseur( DrawPanel, &dc );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*****************************************************************/
|
/*****************************************************************/
|
||||||
bool DrawPage(WinEDA_DrawPanel * panel)
|
bool DrawPage( WinEDA_DrawPanel* panel )
|
||||||
/*****************************************************************/
|
/*****************************************************************/
|
||||||
|
|
||||||
/* copy the current page or block to the clipboard ,
|
/* copy the current page or block to the clipboard ,
|
||||||
to export drawings to other applications (word processing ...)
|
* to export drawings to other applications (word processing ...)
|
||||||
Thi is not suitable for copy command within eeschema or pcbnew
|
* Thi is not suitable for copy command within eeschema or pcbnew
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
bool success = TRUE;
|
bool success = TRUE;
|
||||||
|
|
||||||
#ifdef __WINDOWS__
|
#ifdef __WINDOWS__
|
||||||
int tmpzoom;
|
int tmpzoom;
|
||||||
wxPoint tmp_startvisu;
|
wxPoint tmp_startvisu;
|
||||||
wxPoint old_org;
|
wxPoint old_org;
|
||||||
wxPoint DrawOffset; // Offset de trace
|
wxPoint DrawOffset; // Offset de trace
|
||||||
int ClipboardSizeX, ClipboardSizeY;
|
int ClipboardSizeX, ClipboardSizeY;
|
||||||
bool DrawBlock = FALSE;
|
bool DrawBlock = FALSE;
|
||||||
wxRect DrawArea;
|
wxRect DrawArea;
|
||||||
|
|
||||||
/* scale is the ratio resolution/internal units */
|
/* scale is the ratio resolution/internal units */
|
||||||
float scale = 82.0 / panel->m_Parent->m_InternalUnits;
|
float scale = 82.0 / panel->m_Parent->m_InternalUnits;
|
||||||
|
|
||||||
if ( ActiveScreen->BlockLocate.m_Command != BLOCK_IDLE )
|
if( ActiveScreen->BlockLocate.m_Command != BLOCK_IDLE )
|
||||||
{
|
{
|
||||||
DrawBlock = TRUE;
|
DrawBlock = TRUE;
|
||||||
DrawArea.SetX((int)(ActiveScreen->BlockLocate.GetX()) );
|
DrawArea.SetX( (int) ( ActiveScreen->BlockLocate.GetX() ) );
|
||||||
DrawArea.SetY((int)(ActiveScreen->BlockLocate.GetY()));
|
DrawArea.SetY( (int) ( ActiveScreen->BlockLocate.GetY() ) );
|
||||||
DrawArea.SetWidth((int)(ActiveScreen->BlockLocate.GetWidth()));
|
DrawArea.SetWidth( (int) ( ActiveScreen->BlockLocate.GetWidth() ) );
|
||||||
DrawArea.SetHeight((int)(ActiveScreen->BlockLocate.GetHeight()));
|
DrawArea.SetHeight( (int) ( ActiveScreen->BlockLocate.GetHeight() ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
/* modification des cadrages et reglages locaux */
|
/* modification des cadrages et reglages locaux */
|
||||||
|
@ -90,52 +96,50 @@ wxRect DrawArea;
|
||||||
ActiveScreen->m_DrawOrg.x = ActiveScreen->m_DrawOrg.y = 0;
|
ActiveScreen->m_DrawOrg.x = ActiveScreen->m_DrawOrg.y = 0;
|
||||||
ActiveScreen->m_StartVisu.x = ActiveScreen->m_StartVisu.y = 0;
|
ActiveScreen->m_StartVisu.x = ActiveScreen->m_StartVisu.y = 0;
|
||||||
|
|
||||||
ActiveScreen->SetZoom(1);
|
ActiveScreen->SetZoom( 1 );
|
||||||
|
|
||||||
wxMetafileDC dc/*(wxT(""), DrawArea.GetWidth(), DrawArea.GetHeight())*/;
|
wxMetafileDC dc /*(wxT(""), DrawArea.GetWidth(), DrawArea.GetHeight())*/;
|
||||||
|
|
||||||
if ( ! dc.Ok() )
|
if( !dc.Ok() )
|
||||||
{
|
{
|
||||||
DisplayError(NULL, wxT("CopyToClipboard: DrawPage error: wxMetafileDC not OK"));
|
DisplayError( NULL, wxT( "CopyToClipboard: DrawPage error: wxMetafileDC not OK" ) );
|
||||||
success = FALSE;
|
success = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
EDA_Rect tmp = panel->m_ClipBox;
|
EDA_Rect tmp = panel->m_ClipBox;
|
||||||
GRResetPenAndBrush(&dc);
|
GRResetPenAndBrush( &dc );
|
||||||
GRForceBlackPen(s_PlotBlackAndWhite);
|
GRForceBlackPen( s_PlotBlackAndWhite );
|
||||||
g_IsPrinting = TRUE;
|
g_IsPrinting = TRUE;
|
||||||
dc.SetUserScale(scale, scale);
|
dc.SetUserScale( scale, scale );
|
||||||
ClipboardSizeX = dc.MaxX() + 10;
|
ClipboardSizeX = dc.MaxX() + 10;
|
||||||
ClipboardSizeY = dc.MaxY() + 10;
|
ClipboardSizeY = dc.MaxY() + 10;
|
||||||
panel->m_ClipBox.SetX(0);panel->m_ClipBox.SetY(0);
|
panel->m_ClipBox.SetX( 0 ); panel->m_ClipBox.SetY( 0 );
|
||||||
panel->m_ClipBox.SetWidth(0x7FFFFF0); panel->m_ClipBox.SetHeight(0x7FFFFF0);
|
panel->m_ClipBox.SetWidth( 0x7FFFFF0 ); panel->m_ClipBox.SetHeight( 0x7FFFFF0 );
|
||||||
|
|
||||||
if ( DrawBlock )
|
if( DrawBlock )
|
||||||
{
|
{
|
||||||
dc.SetClippingRegion( DrawArea );
|
dc.SetClippingRegion( DrawArea );
|
||||||
}
|
}
|
||||||
panel->PrintPage(&dc, Print_Sheet_Ref, -1);
|
panel->PrintPage( &dc, Print_Sheet_Ref, -1 );
|
||||||
g_IsPrinting = FALSE;
|
g_IsPrinting = FALSE;
|
||||||
panel->m_ClipBox = tmp;
|
panel->m_ClipBox = tmp;
|
||||||
wxMetafile *mf = dc.Close();
|
wxMetafile* mf = dc.Close();
|
||||||
if (mf)
|
if( mf )
|
||||||
{
|
{
|
||||||
success = mf->SetClipboard(ClipboardSizeX, ClipboardSizeY);
|
success = mf->SetClipboard( ClipboardSizeX, ClipboardSizeY );
|
||||||
delete mf;
|
delete mf;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
GRForceBlackPen(FALSE);
|
GRForceBlackPen( FALSE );
|
||||||
SetPenMinWidth(1);
|
SetPenMinWidth( 1 );
|
||||||
|
|
||||||
ActiveScreen->m_StartVisu = tmp_startvisu;
|
ActiveScreen->m_StartVisu = tmp_startvisu;
|
||||||
ActiveScreen->m_DrawOrg = old_org;
|
ActiveScreen->m_DrawOrg = old_org;
|
||||||
ActiveScreen->SetZoom(tmpzoom);
|
ActiveScreen->SetZoom( tmpzoom );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue