void LIB_EDIT_FRAME::OnAddPartToSchematic( wxCommandEvent& event ) { if( GetCurPart() ) { SCH_EDIT_FRAME* schframe = (SCH_EDIT_FRAME*) Kiway().Player( FRAME_SCH, false ); if( schframe == NULL ) // happens when the schematic editor is not active (or closed) { DisplayErrorMessage( this, _( "No schematic currently open." ) ); return; } SCH_COMPONENT* component = new SCH_COMPONENT( *GetCurPart(), GetCurPart()->GetLibId(), g_CurrentSheet, GetUnit(), GetConvert() ); // Be sure the link to the corresponding LIB_PART is OK: component->Resolve( *Prj().SchSymbolLibTable() ); if( schframe->GetAutoplaceFields() ) component->AutoplaceFields( /* aScreen */ NULL, /* aManual */ false ); schframe->Raise(); schframe->GetToolManager()->RunAction( EE_ACTIONS::placeSymbol, true, component ); } }
bool DIALOG_PRINT_USING_PRINTER::TransferDataFromWindow() { SCH_EDIT_FRAME* parent = GetParent(); GetPrintOptions(); wxPrintDialogData printDialogData( parent->GetPageSetupData().GetPrintData() ); printDialogData.SetMaxPage( g_RootSheet->CountSheets() ); if( g_RootSheet->CountSheets() > 1 ) printDialogData.EnablePageNumbers( true ); wxPrinter printer( &printDialogData ); SCH_PRINTOUT printout( parent, _( "Print Schematic" ) ); // Disable 'Print' button to prevent issuing another print // command before the previous one is finished (causes problems on Windows) m_sdbSizer1OK->Enable( false ); if( !printer.Print( this, &printout, true ) ) { if( wxPrinter::GetLastError() == wxPRINTER_ERROR ) wxMessageBox( _( "An error occurred attempting to print the schematic." ), _( "Printing" ), wxOK ); } else { parent->GetPageSetupData() = printer.GetPrintDialogData().GetPrintData(); } return true; }
void DIALOG_PRINT_USING_PRINTER::GetPrintOptions() { SCH_EDIT_FRAME* parent = GetParent(); parent->SetPrintMonochrome( m_checkMonochrome->IsChecked() ); parent->SetPrintSheetReference( m_checkReference->IsChecked() ); }
/** * Function DeleteItemsInList * delete schematic items in aItemsList * deleted items are put in undo list */ void DeleteItemsInList( EDA_DRAW_PANEL* panel, PICKED_ITEMS_LIST& aItemsList ) { SCH_SCREEN* screen = (SCH_SCREEN*) panel->GetScreen(); SCH_EDIT_FRAME* frame = (SCH_EDIT_FRAME*) panel->GetParent(); PICKED_ITEMS_LIST itemsList; for( unsigned ii = 0; ii < aItemsList.GetCount(); ii++ ) { SCH_ITEM* item = (SCH_ITEM*) aItemsList.GetPickedItem( ii ); ITEM_PICKER itemWrapper( item, UR_DELETED ); if( item->Type() == SCH_SHEET_PIN_T ) { /* this item is depending on a sheet, and is not in global list */ wxMessageBox( wxT( "DeleteItemsInList() err: unexpected SCH_SHEET_PIN_T" ) ); } else { screen->Remove( item ); /* Unlink the structure */ itemsList.PushItem( itemWrapper ); } } frame->SaveCopyInUndoList( itemsList, UR_DELETED ); }
void HIERARCHY_NAVIG_DLG::onSelectSheetPath( wxTreeEvent& event ) { wxTreeItemId ItemSel = m_Tree->GetSelection(); m_SchFrameEditor->SetCurrentSheet(( (TreeItemData*) m_Tree->GetItemData( ItemSel ) )->m_SheetPath ); m_SchFrameEditor->DisplayCurrentSheet(); Close( true ); }
void DIALOG_PRINT_USING_PRINTER::OnPrintButtonClick( wxCommandEvent& event ) { SCH_EDIT_FRAME* parent = GetParent(); GetPrintOptions(); wxPrintDialogData printDialogData( parent->GetPageSetupData().GetPrintData() ); printDialogData.SetMaxPage( g_RootSheet->CountSheets() ); if( g_RootSheet->CountSheets() > 1 ) printDialogData.EnablePageNumbers( true ); wxPrinter printer( &printDialogData ); SCH_PRINTOUT printout( parent, _( "Print Schematic" ) ); if( !printer.Print( this, &printout, true ) ) { if( wxPrinter::GetLastError() == wxPRINTER_ERROR ) wxMessageBox( _( "An error occurred attempting to print the schematic." ), _( "Printing" ), wxOK ); } else { parent->GetPageSetupData() = printer.GetPrintDialogData().GetPrintData(); } }
/* Open a dialog box for printer setup (printer options, page size ...) */ void DIALOG_PRINT_USING_PRINTER::OnPageSetup( wxCommandEvent& event ) { SCH_EDIT_FRAME* parent = GetParent(); wxPageSetupDialog pageSetupDialog( this, &parent->GetPageSetupData() ); pageSetupDialog.ShowModal(); parent->GetPageSetupData() = pageSetupDialog.GetPageSetupDialogData(); }
void LIB_EDIT_FRAME::Process_Config( wxCommandEvent& event ) { int id = event.GetId(); wxFileName fn; SCH_EDIT_FRAME* schFrame = (SCH_EDIT_FRAME*) Kiway().Player( FRAME_SCH, false ); wxASSERT( schFrame ); switch( id ) { case ID_CONFIG_SAVE: schFrame->SaveProjectSettings( true ); break; case ID_CONFIG_READ: { fn = g_RootSheet->GetScreen()->GetFileName(); fn.SetExt( ProjectFileExtension ); wxFileDialog dlg( this, _( "Read Project File" ), fn.GetPath(), fn.GetFullName(), ProjectFileWildcard, wxFD_OPEN | wxFD_FILE_MUST_EXIST ); if( dlg.ShowModal() == wxID_CANCEL ) break; schFrame->LoadProjectFile( dlg.GetPath(), true ); } break; // Hotkey IDs case ID_PREFERENCES_HOTKEY_SHOW_EDITOR: InstallHotkeyFrame( this, s_Eeschema_Hokeys_Descr ); break; case ID_PREFERENCES_HOTKEY_EXPORT_CONFIG: ExportHotkeyConfigToFile( s_Eeschema_Hokeys_Descr ); break; case ID_PREFERENCES_HOTKEY_IMPORT_CONFIG: ImportHotkeyConfigFromFile( s_Eeschema_Hokeys_Descr ); break; case ID_PREFERENCES_HOTKEY_SHOW_CURRENT_LIST: // Display current hotkey list for LibEdit. DisplayHotkeyList( this, s_Libedit_Hokeys_Descr ); break; default: DisplayError( this, wxT( "LIB_EDIT_FRAME::Process_Config error" ) ); } }
/* MacOSX: Needed for file association * http://wiki.wxwidgets.org/WxMac-specific_topics */ void EDA_APP::MacOpenFile( const wxString& aFileName ) { wxFileName filename = aFileName; SCH_EDIT_FRAME* frame = ((SCH_EDIT_FRAME*) GetTopWindow()); if( !frame ) return; if( !filename.FileExists() ) return; frame->LoadOneEEProject( aFileName, false ); }
void DIALOG_PRINT_USING_PRINTER::OnCloseWindow( wxCloseEvent& event ) { SCH_EDIT_FRAME* parent = GetParent(); if( !IsIconized() ) { parent->SetPrintDialogPosition( GetPosition() ); parent->SetPrintDialogSize( GetSize() ); } GetPrintOptions(); EndDialog( wxID_CANCEL ); }
static void abortMoveItem( EDA_DRAW_PANEL* aPanel, wxDC* aDC ) { SCH_SCREEN* screen = (SCH_SCREEN*) aPanel->GetScreen(); SCH_ITEM* item = screen->GetCurItem(); SCH_EDIT_FRAME* parent = ( SCH_EDIT_FRAME* ) aPanel->GetParent(); parent->SetRepeatItem( NULL ); screen->SetCurItem( NULL ); if( item == NULL ) /* no current item */ return; if( item->IsNew() ) { delete item; item = NULL; } else { SCH_ITEM* oldItem = parent->GetUndoItem(); SCH_ITEM* currentItem; // Items that are children of other objects are undone by swapping the contents // of the parent items. if( (item->Type() == SCH_SHEET_PIN_T) || (item->Type() == SCH_FIELD_T) ) { currentItem = (SCH_ITEM*) item->GetParent(); } else { currentItem = item; } wxCHECK_RET( oldItem != NULL && currentItem->Type() == oldItem->Type(), wxT( "Cannot restore undefined or bad last schematic item." ) ); // Never delete existing item, because it can be referenced by an undo/redo command // Just restore its data currentItem->SwapData( oldItem ); // Erase the wire representation before the 'normal' view is drawn. if ( item->IsWireImage() ) item->Draw( aPanel, aDC, wxPoint( 0, 0 ), g_XorMode ); item->ClearFlags(); } aPanel->Refresh(); }
void DIALOG_SYMBOL_REMAP::OnRemapSymbols( wxCommandEvent& aEvent ) { SCH_EDIT_FRAME* parent = dynamic_cast< SCH_EDIT_FRAME* >( GetParent() ); wxCHECK_RET( parent != nullptr, "Parent window is not type SCH_EDIT_FRAME." ); wxBusyCursor busy; if( !backupProject( m_messagePanel->Reporter() ) ) return; // Ignore the never show rescue setting for one last rescue of legacy symbol // libraries before remapping to the symbol library table. This ensures the // best remapping results. parent->RescueLegacyProject( false ); // The schematic is fully loaded, any legacy library symbols have been rescued. Now // check to see if the schematic has not been converted to the symbol library table // method for looking up symbols. wxFileName prjSymLibTableFileName( Prj().GetProjectPath(), SYMBOL_LIB_TABLE::GetSymbolLibTableFileName() ); // Delete the existing project symbol library table. if( prjSymLibTableFileName.FileExists() ) { wxRemoveFile( prjSymLibTableFileName.GetFullPath() ); } createProjectSymbolLibTable( m_messagePanel->Reporter() ); Prj().SetElem( PROJECT::ELEM_SYMBOL_LIB_TABLE, NULL ); Prj().SchSymbolLibTable(); remapSymbolsToLibTable( m_messagePanel->Reporter() ); // Remove all of the libraries from the legacy library list. wxString paths; wxArrayString libNames; PART_LIBS::LibNamesAndPaths( &Prj(), true, &paths, &libNames ); // Reload the the cache symbol library. Prj().SetElem( PROJECT::ELEM_SCH_PART_LIBS, NULL ); Prj().SchLibs(); Raise(); m_remapped = true; }
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 ); }
/* Open and display a previewer frame for printing */ void DIALOG_PRINT_USING_PRINTER::OnPrintPreview( wxCommandEvent& event ) { SCH_EDIT_FRAME* parent = GetParent(); GetPrintOptions(); // Pass two printout objects: for preview, and possible printing. wxString title = _( "Preview" ); wxPrintPreview* preview = new wxPrintPreview( new SCH_PRINTOUT( parent, title ), new SCH_PRINTOUT( parent, title ), &parent->GetPageSetupData().GetPrintData() ); if( preview == NULL ) { DisplayError( this, _( "Print preview error!" ) ); return; } preview->SetZoom( 100 ); SCH_PREVIEW_FRAME* frame = new SCH_PREVIEW_FRAME( preview, this, title ); frame->SetMinSize( wxSize( 550, 350 ) ); // on first invocation in this runtime session, set to 2/3 size of my parent, // but will be changed in Show() if not first time as will position. frame->SetSize( (parent->GetSize() * 2) / 3 ); frame->Center(); // On wxGTK, set the flag wxTOPLEVEL_EX_DIALOG is mandatory, if we want // close the frame using the X box in caption, when the preview frame is run // from a dialog frame->SetExtraStyle( frame->GetExtraStyle() | wxTOPLEVEL_EX_DIALOG ); // We use here wxPreviewFrame_WindowModal option to make the wxPrintPreview frame // modal for its caller only. // An other reason is the fact when closing the frame without this option, // all top level frames are reenabled. // With this option, only the parent is reenabled. // Reenabling all top level frames should be made by the parent dialog. frame->InitializeWithModality( wxPreviewFrame_WindowModal ); frame->Raise(); // Needed on Ubuntu/Unity to display the frame frame->Show( true ); }
/** * Function RunPlugin * run the plugin command line */ void DIALOG_BOM::OnRunPlugin( wxCommandEvent& event ) { wxFileName fn; wxString fileWildcard; wxString title = _( "Save Netlist File" ); // Calculate the xml netlist filename fn = g_RootSheet->GetScreen()->GetFileName(); if( fn.GetPath().IsEmpty() ) fn.SetPath( wxPathOnly( Prj().GetProjectFullName() ) ); fn.ClearExt(); wxString fullfilename = fn.GetFullPath(); m_parent->ClearMsgPanel(); m_parent->SetNetListerCommand( m_textCtrlCommand->GetValue() ); m_parent->CreateNetlist( -1, fullfilename, 0 ); }
/* Abort function for wire, bus or line creation */ static void AbortCreateNewLine( EDA_DRAW_PANEL* aPanel, wxDC* aDC ) { SCH_SCREEN* screen = (SCH_SCREEN*) aPanel->GetScreen(); if( screen->GetCurItem() ) { s_wires.DeleteAll(); // Free the list, for a future usage screen->SetCurItem( NULL ); aPanel->Refresh(); } else { SCH_EDIT_FRAME* parent = ( SCH_EDIT_FRAME* ) aPanel->GetParent(); parent->SetRepeatItem( NULL ); } // Clear flags used in edit functions. screen->ClearDrawingState(); }
void LIB_VIEW_FRAME::DClickOnCmpList( wxCommandEvent& event ) { if( IsModal() ) { ExportToSchematicLibraryPart( event ); // The schematic editor might not be the parent of the library viewer. // It could be a python window. SCH_EDIT_FRAME* schframe = dynamic_cast<SCH_EDIT_FRAME*>( GetParent() ); if( schframe ) { // Prevent the double click from being as a single click in the parent // window which would cause the part to be parked rather than staying // in drag mode. schframe->SkipNextLeftButtonReleaseEvent(); } } }
void DIALOG_EESCHEMA_CONFIG::OnOkClick( wxCommandEvent& event ) { // Recreate the user lib path if( m_LibPathChanged ) { wxString path; for( unsigned ii = 0; ii < m_listUserPaths->GetCount(); ii++ ) { if( ii > 0 ) path << wxT( ";" ); path << m_listUserPaths->GetString( ii ); } m_Parent->SetUserLibraryPath( path ); } /* Set new active library list if the lib list of if default path list * was modified */ if( m_LibListChanged || m_LibPathChanged ) { wxArrayString list; for( unsigned ii = 0; ii < m_ListLibr->GetCount(); ii ++ ) list.Add( m_ListLibr->GetString( ii ) ); // Recreate lib list m_Parent->SetComponentLibraries( list ); // take new list in account m_Parent->LoadLibraries(); // Clear (if needed) the current active library in libedit because it could be // removed from memory LIB_EDIT_FRAME::EnsureActiveLibExists(); } m_Parent->SaveProjectSettings( false ); EndModal( wxID_OK ); }
/** * Mouse capture callback for drawing line segments. */ static void DrawSegment( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosition, bool aErase ) { SCH_LINE* segment; if( s_wires.GetCount() == 0 ) return; segment = (SCH_LINE*) s_wires.begin(); EDA_COLOR_T color = GetLayerColor( segment->GetLayer() ); ColorChangeHighlightFlag( &color, !(color & HIGHLIGHT_FLAG) ); if( aErase ) { while( segment ) { if( !segment->IsNull() ) // Redraw if segment length != 0 segment->Draw( aPanel, aDC, wxPoint( 0, 0 ), g_XorMode, color ); segment = segment->Next(); } } SCH_EDIT_FRAME* frame = (SCH_EDIT_FRAME*) aPanel->GetParent(); wxPoint endpos = frame->GetCrossHairPosition(); if( frame->GetForceHVLines() ) /* Coerce the line to vertical or horizontal one: */ ComputeBreakPoint( (SCH_LINE*) s_wires.GetLast()->Back(), endpos ); else ( (SCH_LINE*) s_wires.GetLast() )->SetEndPoint( endpos ); segment = (SCH_LINE*) s_wires.begin(); while( segment ) { if( !segment->IsNull() ) // Redraw if segment length != 0 segment->Draw( aPanel, aDC, wxPoint( 0, 0 ), g_XorMode, color ); segment = segment->Next(); } }
void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::OnSelectChipName( wxCommandEvent& event ) { wxArrayString dummy; int dummyunit = 1; wxString chipname = m_parent->SelectComponentFromLibrary( NULL, dummy, dummyunit, true, NULL, NULL ); if( chipname.IsEmpty() ) return; chipnameTextCtrl->SetValue( chipname ); }
// Complete sheet move. static void ExitSheet( EDA_DRAW_PANEL* aPanel, wxDC* aDC ) { SCH_SCREEN* screen = (SCH_SCREEN*) aPanel->GetScreen(); SCH_ITEM* item = screen->GetCurItem(); SCH_EDIT_FRAME* parent = (SCH_EDIT_FRAME*) aPanel->GetParent(); if( (item == NULL) || (item->Type() != SCH_SHEET_T) || (parent == NULL) ) return; parent->SetRepeatItem( NULL ); item->Draw( aPanel, aDC, wxPoint( 0, 0 ), g_XorMode ); if( item->IsNew() ) { delete item; } else if( item->IsMoving() || item->IsResized() ) { screen->Remove( item ); delete item; item = parent->GetUndoItem(); wxCHECK_RET( item != NULL, wxT( "Cannot restore undefined last sheet item." ) ); screen->Append( item ); // the owner of item is no more parent, this is the draw list of screen: parent->SetUndoItem( NULL ); item->Draw( aPanel, aDC, wxPoint( 0, 0 ), GR_DEFAULT_DRAWMODE ); item->ClearFlags(); } else { item->ClearFlags(); } screen->SetCurItem( NULL ); }
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_EESCHEMA_CONFIG::Init() { wxString msg; SetFocus(); m_LibListChanged = false; m_LibPathChanged = false; m_UserLibDirBufferImg = m_Parent->GetUserLibraryPath(); m_ListLibr->InsertItems( m_Parent->GetComponentLibraries(), 0 ); // Load user libs paths: wxStringTokenizer tokenizer( m_UserLibDirBufferImg, wxT( ";\n\r" ) ); while( tokenizer.HasMoreTokens() ) { wxString path = tokenizer.GetNextToken(); if( wxFileName::DirExists( path ) ) m_listUserPaths->Append( path ); } // Display actual libraries paths: SEARCH_STACK& libpaths = Prj().SchSearchS(); for( unsigned ii = 0; ii < libpaths.GetCount(); ii++ ) { m_DefaultLibraryPathslistBox->Append( libpaths[ii] ); } // select the first path after the current path project if ( libpaths.GetCount() > 1 ) m_DefaultLibraryPathslistBox->Select( 1 ); m_sdbSizer1OK->SetDefault(); }
bool DIALOG_PRINT_USING_PRINTER::TransferDataToWindow() { SCH_EDIT_FRAME* parent = GetParent(); // Initialize page specific print setup dialog settings. const PAGE_INFO& pageInfo = parent->GetScreen()->GetPageSettings(); wxPageSetupDialogData& pageSetupDialogData = parent->GetPageSetupData(); pageSetupDialogData.SetPaperId( pageInfo.GetPaperId() ); if( pageInfo.IsCustom() ) { if( pageInfo.IsPortrait() ) pageSetupDialogData.SetPaperSize( wxSize( Mils2mm( pageInfo.GetWidthMils() ), Mils2mm( pageInfo.GetHeightMils() ) ) ); else pageSetupDialogData.SetPaperSize( wxSize( Mils2mm( pageInfo.GetHeightMils() ), Mils2mm( pageInfo.GetWidthMils() ) ) ); } pageSetupDialogData.GetPrintData().SetOrientation( pageInfo.GetWxOrientation() ); return true; }
void DIALOG_EESCHEMA_CONFIG::OnCancelClick( wxCommandEvent& event ) { SEARCH_STACK& lib_search = Prj().SchSearchS(); // Recreate the user lib path if( m_LibPathChanged ) { for( unsigned ii = 0; ii < m_listUserPaths->GetCount(); ii++ ) lib_search.RemovePaths( m_listUserPaths->GetString(ii) ); lib_search.AddPaths( m_Parent->GetUserLibraryPath(), 1 ); } EndModal( wxID_CANCEL ); }
void DIALOG_PRINT_USING_PRINTER::initDialog() { SCH_EDIT_FRAME* parent = GetParent(); // Initialize page specific print setup dialog settings. const PAGE_INFO& pageInfo = parent->GetScreen()->GetPageSettings(); wxPageSetupDialogData& pageSetupDialogData = parent->GetPageSetupData(); pageSetupDialogData.SetPaperId( pageInfo.GetPaperId() ); if( pageInfo.IsCustom() ) { if( pageInfo.IsPortrait() ) pageSetupDialogData.SetPaperSize( wxSize( Mils2mm( pageInfo.GetWidthMils() ), Mils2mm( pageInfo.GetHeightMils() ) ) ); else pageSetupDialogData.SetPaperSize( wxSize( Mils2mm( pageInfo.GetHeightMils() ), Mils2mm( pageInfo.GetWidthMils() ) ) ); } pageSetupDialogData.GetPrintData().SetOrientation( pageInfo.GetWxOrientation() ); if ( GetSizer() ) GetSizer()->SetSizeHints( this ); // Rely on the policy in class DIALOG_SHIM, which centers the dialog // initially during a runtime session but gives user the ability to move it in // that session. // This dialog may get moved and resized in Show(), but in case this is // the first time, center it for starters. Center(); m_buttonPrint->SetDefault(); // on linux, this is inadequate to determine // what ENTER does. Must also SetFocus(). m_buttonPrint->SetFocus(); }
bool SCH_PRINTOUT::OnBeginDocument( int startPage, int endPage ) { if( !wxPrintout::OnBeginDocument( startPage, endPage ) ) return false; #ifdef __WXDEBUG__ wxLogDebug( wxT( "Printer name: " ) + m_parent->GetPageSetupData().GetPrintData().GetPrinterName() ); wxLogDebug( wxT( "Paper ID: %d" ), m_parent->GetPageSetupData().GetPrintData().GetPaperId() ); wxLogDebug( wxT( "Color: %d" ), (int)m_parent->GetPageSetupData().GetPrintData().GetColour() ); wxLogDebug( wxT( "Monochrome: %d" ), m_parent->GetPrintMonochrome() ); wxLogDebug( wxT( "Orientation: %d:" ), m_parent->GetPageSetupData().GetPrintData().GetOrientation() ); wxLogDebug( wxT( "Quality: %d"), m_parent->GetPageSetupData().GetPrintData().GetQuality() ); #endif return true; }
bool SCH_PRINTOUT::OnPrintPage( int page ) { SCH_SHEET_LIST sheetList( g_RootSheet ); wxCHECK_MSG( page >= 1 && page <= (int)sheetList.size(), false, wxT( "Cannot print invalid page number." ) ); wxCHECK_MSG( sheetList[ page - 1].LastScreen() != NULL, false, wxT( "Cannot print page with NULL screen." ) ); wxString msg; msg.Printf( _( "Print page %d" ), page ); m_parent->ClearMsgPanel(); m_parent->AppendMsgPanel( msg, wxEmptyString, CYAN ); SCH_SCREEN* screen = m_parent->GetScreen(); SCH_SHEET_PATH oldsheetpath = m_parent->GetCurrentSheet(); m_parent->SetCurrentSheet( sheetList[ page - 1 ] ); m_parent->GetCurrentSheet().UpdateAllScreenReferences(); m_parent->SetSheetNumberAndCount(); screen = m_parent->GetCurrentSheet().LastScreen(); DrawPage( screen ); m_parent->SetCurrentSheet( oldsheetpath ); m_parent->GetCurrentSheet().UpdateAllScreenReferences(); m_parent->SetSheetNumberAndCount(); return true; }
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 ); }