void DIALOG_LABEL_EDITOR::TextPropertiesAccept( wxCommandEvent& aEvent ) { wxString text; int value; /* save old text in undo list if not already in edit */ /* or the label to be edited is part of a block */ if( m_CurrentText->GetFlags() == 0 || m_Parent->GetScreen()->m_BlockLocate.GetState() != STATE_NO_BLOCK ) m_Parent->SaveCopyInUndoList( m_CurrentText, UR_CHANGED ); m_Parent->GetCanvas()->RefreshDrawingRect( m_CurrentText->GetBoundingBox() ); text = m_textLabel->GetValue(); if( !text.IsEmpty() ) m_CurrentText->m_Text = text; else if( !m_CurrentText->IsNew() ) { DisplayError( this, _( "Empty Text!" ) ); return; } m_CurrentText->SetOrientation( m_TextOrient->GetSelection() ); text = m_TextSize->GetValue(); value = ReturnValueFromString( g_UserUnit, text ); m_CurrentText->m_Size.x = m_CurrentText->m_Size.y = value; if( m_TextShape ) m_CurrentText->SetShape( m_TextShape->GetSelection() ); int style = m_TextStyle->GetSelection(); if( ( style & 1 ) ) m_CurrentText->m_Italic = 1; else m_CurrentText->m_Italic = 0; if( ( style & 2 ) ) { m_CurrentText->m_Bold = true; m_CurrentText->m_Thickness = GetPenSizeForBold( m_CurrentText->m_Size.x ); } else { m_CurrentText->m_Bold = false; m_CurrentText->m_Thickness = 0; } m_Parent->OnModify(); /* Make the text size as new default size if it is a new text */ if( m_CurrentText->IsNew() ) m_Parent->SetDefaultLabelSize( m_CurrentText->m_Size.x ); m_Parent->GetCanvas()->RefreshDrawingRect( m_CurrentText->GetBoundingBox() ); m_Parent->GetCanvas()->MoveCursorToCrossHair(); EndModal( wxID_OK ); }
void DIALOG_LABEL_EDITOR::TextPropertiesAccept( wxCommandEvent& aEvent ) { wxString text; int value; /* save old text in undo list if not already in edit */ /* or the label to be edited is part of a block */ if( m_CurrentText->GetFlags() == 0 || m_Parent->GetScreen()->m_BlockLocate.GetState() != STATE_NO_BLOCK ) m_Parent->SaveCopyInUndoList( m_CurrentText, UR_CHANGED ); m_Parent->GetCanvas()->RefreshDrawingRect( m_CurrentText->GetBoundingBox() ); text = m_textLabel->GetValue(); if( !text.IsEmpty() ) m_CurrentText->SetText( text ); else if( !m_CurrentText->IsNew() ) { DisplayError( this, _( "Empty Text!" ) ); return; } m_CurrentText->SetOrientation( m_TextOrient->GetSelection() ); text = m_TextSize->GetValue(); value = ValueFromString( g_UserUnit, text ); m_CurrentText->SetSize( wxSize( value, value ) ); if( m_TextShape ) /// @todo move cast to widget m_CurrentText->SetShape( static_cast<PINSHEETLABEL_SHAPE>( m_TextShape->GetSelection() ) ); int style = m_TextStyle->GetSelection(); m_CurrentText->SetItalic( ( style & 1 ) ); if( ( style & 2 ) ) { m_CurrentText->SetBold( true ); m_CurrentText->SetThickness( GetPenSizeForBold( m_CurrentText->GetSize().x ) ); } else { m_CurrentText->SetBold( false ); m_CurrentText->SetThickness( 0 ); } m_Parent->OnModify(); // Make the text size the new default size ( if it is a new text ): if( m_CurrentText->IsNew() ) SetDefaultTextSize( m_CurrentText->GetSize().x ); m_Parent->GetCanvas()->RefreshDrawingRect( m_CurrentText->GetBoundingBox() ); m_Parent->GetCanvas()->MoveCursorToCrossHair(); EndModal( wxID_OK ); }
void DIALOG_LABEL_EDITOR::OnCancelClick( wxCommandEvent& aEvent ) { m_Parent->GetCanvas()->MoveCursorToCrossHair(); EndModal( wxID_CANCEL ); }
/* * This is the real print function: print the active screen */ void SCH_PRINTOUT::DrawPage( SCH_SCREEN* aScreen ) { int oldZoom; wxPoint tmp_startvisu; wxSize pageSizeIU; // Page size in internal units wxPoint old_org; EDA_RECT oldClipBox; wxRect fitRect; wxDC* dc = GetDC(); auto panel = m_parent->GetCanvas(); wxBusyCursor dummy; // Save current scale factor, offsets, and clip box. tmp_startvisu = aScreen->m_StartVisu; oldZoom = aScreen->GetZoom(); old_org = aScreen->m_DrawOrg; oldClipBox = *panel->GetClipBox(); // Change clip box to print the whole page. #define MAX_VALUE (INT_MAX/2) // MAX_VALUE is the max we can use in an integer // and that allows calculations without overflow panel->SetClipBox( EDA_RECT( wxPoint( 0, 0 ), wxSize( MAX_VALUE, MAX_VALUE ) ) ); // Change scale factor and offset to print the whole page. bool printReference = m_parent->GetPrintSheetReference(); pageSizeIU = aScreen->GetPageSettings().GetSizeIU(); FitThisSizeToPaper( pageSizeIU ); fitRect = GetLogicalPaperRect(); wxLogDebug( wxT( "Fit rectangle: x = %d, y = %d, w = %d, h = %d" ), fitRect.x, fitRect.y, fitRect.width, fitRect.height ); // When is the actual paper size does not match the schematic page // size, the drawing is not perfectly centered on X or Y axis. // Give a draw offset centers the schematic page on the paper draw area // Because the sizes are fitted, only an Y or X offset is needed // and both are 0 when sizes are identical. // Y or Y offset is not null when the X/Y size ratio differs between // the actual paper size and the schematic page int xoffset = ( fitRect.width - pageSizeIU.x ) / 2; // For an obscure reason, OffsetLogicalOrigin creates issues, // under some circumstances, when yoffset is not always null // and changes from a page to another page // This is only a workaround, not a fix // see https://bugs.launchpad.net/kicad/+bug/1464773 // xoffset does not create issues. #if 0 // FIX ME int yoffset = ( fitRect.height - pageSizeIU.y ) / 2; #else // the Y centering will be not perfect, but this is less annoying // than a blank page or a buggy centering int yoffset = 0; #endif OffsetLogicalOrigin( xoffset, yoffset ); GRResetPenAndBrush( dc ); if( m_parent->GetPrintMonochrome() ) GRForceBlackPen( true ); aScreen->m_IsPrinting = true; COLOR4D bgColor = m_parent->GetDrawBgColor(); aScreen->Draw( panel, dc, (GR_DRAWMODE) 0 ); if( printReference ) m_parent->DrawWorkSheet( dc, aScreen, GetDefaultLineThickness(), IU_PER_MILS, aScreen->GetFileName() ); m_parent->SetDrawBgColor( bgColor ); aScreen->m_IsPrinting = false; panel->SetClipBox( oldClipBox ); GRForceBlackPen( false ); aScreen->m_StartVisu = tmp_startvisu; aScreen->m_DrawOrg = old_org; aScreen->SetZoom( oldZoom ); }
bool EDA_APP::OnInit() { wxFileName filename; SCH_EDIT_FRAME* frame = NULL; bool fileReady = false; InitEDA_Appl( wxT( "Eeschema" ), APP_EESCHEMA_T ); if( argc > 1 ) filename = argv[1]; if( filename.IsOk() ) { if( filename.GetExt() != SchematicFileExtension ) filename.SetExt( SchematicFileExtension ); if( !wxGetApp().LockFile( filename.GetFullPath() ) ) { DisplayError( NULL, _( "This file is already open." ) ); return false; } fileReady = true; } if( m_Checker && m_Checker->IsAnotherRunning() ) { if( !IsOK( NULL, _( "Eeschema is already running, Continue?" ) ) ) return false; } // Give a default colour for all layers // (actual color will be initialized by config) for( int ii = 0; ii < NB_SCH_LAYERS; ii++ ) SetLayerColor( DARKGRAY, ii ); // read current setup and reopen last directory if no filename to open in // command line bool reopenLastUsedDirectory = argc == 1; GetSettings( reopenLastUsedDirectory ); /* Must be called before creating the main frame in order to * display the real hotkeys in menus or tool tips */ ReadHotkeyConfig( wxT("SchematicFrame"), s_Eeschema_Hokeys_Descr ); // Create main frame (schematic frame) : frame = new SCH_EDIT_FRAME( NULL, wxT( "Eeschema" ), wxPoint( 0, 0 ), wxSize( 600, 400 ) ); SetTopWindow( frame ); frame->Show( true ); CreateServer( frame, KICAD_SCH_PORT_SERVICE_NUMBER ); frame->Zoom_Automatique( true ); // Load file specified in the command line: if( fileReady ) { if( !filename.GetPath().IsEmpty() ) // wxSetWorkingDirectory does not like empty paths wxSetWorkingDirectory( filename.GetPath() ); if( frame->LoadOneEEProject( filename.GetFullName(), false ) ) frame->GetCanvas()->Refresh( true ); } else { // Read a default config file if no file to load. frame->LoadProjectFile( wxEmptyString, true ); frame->GetCanvas()->Refresh( true ); } return true; }