void SCH_EDIT_FRAME::OnFindReplace( wxFindDialogEvent& aEvent ) { SCH_FIND_COLLECTOR_DATA data; bool warpCursor = !( aEvent.GetFlags() & FR_NO_WARP_CURSOR ); SCH_ITEM* item = (SCH_ITEM*) m_foundItems.GetItem( data ); wxCHECK_RET( item != NULL, wxT( "Invalid replace item in find collector list." ) ); wxLogTrace( traceFindReplace, wxT( "Replacing %s with %s in item %s" ), GetChars( aEvent.GetFindString() ), GetChars( aEvent.GetReplaceString() ), GetChars( m_foundItems.GetText() ) ); SCH_ITEM* undoItem = data.GetParent(); if( undoItem == NULL ) undoItem = item; SetUndoItem( undoItem ); if( m_foundItems.ReplaceItem() ) { OnModify(); SaveUndoItemInUndoList( undoItem ); RedrawScreen( data.GetPosition(), warpCursor ); } OnFindSchematicItem( aEvent ); if( aEvent.GetEventType() == wxEVT_COMMAND_FIND_REPLACE_ALL ) { while( ( item = (SCH_ITEM*) m_foundItems.GetItem( data ) ) != NULL ) { wxLogTrace( traceFindReplace, wxT( "Replacing %s with %s in item %s" ), GetChars( aEvent.GetFindString() ), GetChars( aEvent.GetReplaceString() ), GetChars( m_foundItems.GetText() ) ); SCH_ITEM* undoItem = data.GetParent(); // Don't save child items in undo list. if( undoItem == NULL ) undoItem = item; SetUndoItem( undoItem ); if( m_foundItems.ReplaceItem() ) { OnModify(); SaveUndoItemInUndoList( undoItem ); RedrawScreen( data.GetPosition(), warpCursor ); } OnFindSchematicItem( aEvent ); } } }
void EDA_DRAW_FRAME::OnSelectZoom( wxCommandEvent& event ) { if( m_zoomSelectBox == NULL ) return; // Should not happen! int id = m_zoomSelectBox->GetCurrentSelection(); if( id < 0 || !( id < (int)m_zoomSelectBox->GetCount() ) ) return; if( id == 0 ) // Auto zoom (Fit in Page) { Zoom_Automatique( true ); } else { id--; double selectedZoom = GetScreen()->m_ZoomList[id]; if( GetScreen()->GetZoom() == selectedZoom ) return; GetScreen()->SetZoom( selectedZoom ); RedrawScreen( GetScrollCenterPosition(), false ); } // Notify GAL TOOL_MANAGER* mgr = GetToolManager(); if( mgr && IsGalCanvasActive() ) mgr->RunAction( "common.Control.zoomPreset", true, id ); }
void PL_EDITOR_FRAME::MoveItem( WORKSHEET_DATAITEM* aItem ) { wxCHECK_RET( aItem != NULL, wxT( "Cannot move NULL item" ) ); initialPosition = aItem->GetStartPos(); initialPositionUi = aItem->GetStartPosUi(); initialCursorPosition = GetCrossHairPosition(); if( (aItem->GetFlags() & LOCATE_ENDPOINT) ) { initialPosition = aItem->GetEndPos(); initialPositionUi = aItem->GetEndPosUi(); } if( aItem->GetFlags() & (LOCATE_STARTPOINT|LOCATE_ENDPOINT) ) { SetCrossHairPosition( initialPositionUi, false ); initialCursorPosition = GetCrossHairPosition(); if( m_canvas->IsPointOnDisplay( initialCursorPosition ) ) { m_canvas->MoveCursorToCrossHair(); m_canvas->Refresh(); } else { RedrawScreen( initialCursorPosition, true ); } } m_canvas->SetMouseCapture( moveItem, abortMoveItem ); GetScreen()->SetCurItem( aItem ); }
void ChangeNumTracks(int total) { int i; if (total>0 && total <= TotalTracks) { /* scrap everything */ DestroyTracks(); NumTracks= total; lowTrkIndex= 0; highTrkIndex= total - 1; tracks= (Track **)Malloc(sizeof(Track*)*NumTracks); if (tracks==NULL) return; /* not enuff mem */ CreateTracks(tracesFrame); for(i=0; i <= LastTrack; i++) { Trace *trc= traces[i]; /* resize? */ if (trc && trc->wave) { /* cp from ``trackmgr.c'' */ ScaleYAxis(&trc->axis, tracks[0]->height); /* lazy-- taxis is the same */ } } AdjustSbar(); RedrawScreen(); } }
void PCB_BASE_FRAME::CursorGoto( const wxPoint& aPos, bool aWarp ) { // factored out of pcbnew/find.cpp PCB_SCREEN* screen = (PCB_SCREEN*)GetScreen(); INSTALL_UNBUFFERED_DC( dc, m_canvas ); // There may be need to reframe the drawing. if( !m_canvas->IsPointOnDisplay( aPos ) ) { screen->SetCrossHairPosition( aPos ); RedrawScreen( aPos, aWarp ); } else { // Put cursor on item position m_canvas->CrossHairOff( &dc ); screen->SetCrossHairPosition( aPos ); if( aWarp ) m_canvas->MoveCursorToCrossHair(); } m_canvas->CrossHairOn( &dc ); m_canvas->CrossHairOn( &dc ); }
/*! \fn swDesktop::Resize( const Size& newSize ) */ void swDesktop::Resize( const Size& newSize ) { swUiControl::Resize( newSize ); _wr = StartWrite(); _wr->Clear(); _wr->Fill( Geometry(), swTAttr(4, 6, 0), ACS_CKBOARD); // ------------------------------------------------- TESTS RedrawScreen(); }
static void status_OnPaint( HWND hwnd) { HDC hdc; PAINTSTRUCT ps; hdc = BeginPaint(hwnd,&ps); SetMapMode(hdc,MM_TEXT);; RedrawScreen(hwnd,hdc); ValidateRect(hwnd,NULL); EndPaint(hwnd, &ps) ; }
void EDA_DRAW_FRAME::UseGalCanvas( bool aEnable ) { KIGFX::VIEW* view = GetGalCanvas()->GetView(); KIGFX::GAL* gal = GetGalCanvas()->GetGAL(); double zoomFactor = gal->GetWorldScale() / gal->GetZoomFactor(); // Display the same view after canvas switching if( aEnable ) { BASE_SCREEN* screen = GetScreen(); // Switch to GAL rendering if( !IsGalCanvasActive() ) { // Set up viewport double zoom = 1.0 / ( zoomFactor * m_canvas->GetZoom() ); view->SetScale( zoom ); view->SetCenter( VECTOR2D( m_canvas->GetScreenCenterLogicalPosition() ) ); } // Set up grid settings gal->SetGridVisibility( IsGridVisible() ); gal->SetGridSize( VECTOR2D( screen->GetGridSize().x, screen->GetGridSize().y ) ); gal->SetGridOrigin( VECTOR2D( GetGridOrigin() ) ); } else { // Switch to standard rendering if( IsGalCanvasActive() ) { // Change view settings only if GAL was active previously double zoom = 1.0 / ( zoomFactor * view->GetScale() ); m_canvas->SetZoom( zoom ); VECTOR2D center = view->GetCenter(); RedrawScreen( wxPoint( center.x, center.y ), false ); } } m_canvas->SetEvtHandlerEnabled( !aEnable ); GetGalCanvas()->SetEvtHandlerEnabled( aEnable ); // Switch panes m_auimgr.GetPane( wxT( "DrawFrame" ) ).Show( !aEnable ); m_auimgr.GetPane( wxT( "DrawFrameGal" ) ).Show( aEnable ); m_auimgr.Update(); // Reset current tool on switch(); SetToolID( ID_NO_TOOL_SELECTED, wxCURSOR_DEFAULT, wxEmptyString ); m_galCanvasActive = aEnable; }
void ClipTracksRight(int x) { int i,idx, idx1, n_val, len; Trace *trc; double sdiff; if (Mode_align) { /* get secs offset */ trc=traces[lowTrkIndex]; /* don't use 0! it might not get scaled if not exposed */ len= tracks[0]->width-x; sdiff= (trc->axis.hs*len)/trc->wave->info.sample_rate; /* adjust Total Seconds */ TotalSeconds-=sdiff; late_time = st_add_dtime(earl_time, TotalSeconds * USECS_PER_SEC); for(i=0; i <= LastTrack; i++) { trc= traces[i]; n_val=trc->wave->info.n_values-1; idx= coordToIndex(&trc->axis, x, 1); trc->axis.ix2=idx; idx1= trc->axis.ix1; if (auto_demean) { demean_trace(trc->wave,&trc->axis,idx1,idx); } RescaleTrace(trc, tracks[0]->height, tracks[0]->width); trc->zaxis_needScale= 1; trc->zaxis.ymax= trc->zaxis.y1= trc->axis.ymax; trc->zaxis.ymin= trc->zaxis.y2= trc->axis.ymin; #if 0 trc->zaxis.vs= trc->zaxis.hs= 0; #endif } }else { for(i=0; i <= LastTrack; i++) { trc= traces[i]; n_val=trc->wave->info.n_values-1; idx= coordToIndex(&trc->axis, x, 1); trc->axis.ix2= idx; RescaleTrace(trc, tracks[0]->height, tracks[0]->width); trc->zaxis_needScale= 1; } } if(ZoomWindowMapped) { for(i=lowZTrkIndex; i<= highZTrkIndex; i++) { Trace *trc=traces[i]; fixZtrkBounds(trc, trc->zaxis.ix2-trc->zaxis.ix1); } RedrawZoomWindow("ClipTracksRight"); } RedrawScreen(); }
void SCH_EDIT_FRAME::OnFindDrcMarker( wxFindDialogEvent& event ) { static SCH_MARKER* lastMarker = NULL; wxString msg; SCH_SHEET_LIST schematic; SCH_SHEET_PATH* sheetFoundIn = NULL; bool wrap = ( event.GetFlags() & FR_SEARCH_WRAP ) != 0; wxRect clientRect( wxPoint( 0, 0 ), GetClientSize() ); bool warpCursor = ( ( event.GetId() == wxEVT_COMMAND_FIND_CLOSE ) || !( event.GetFlags() & FR_NO_WARP_CURSOR ) ); if( event.GetFlags() & FR_CURRENT_SHEET_ONLY ) { sheetFoundIn = m_CurrentSheet; lastMarker = (SCH_MARKER*) m_CurrentSheet->FindNextItem( SCH_MARKER_T, lastMarker, wrap ); } else { lastMarker = (SCH_MARKER*) schematic.FindNextItem( SCH_MARKER_T, &sheetFoundIn, lastMarker, wrap ); } if( lastMarker != NULL ) { if( *sheetFoundIn != *m_CurrentSheet ) { sheetFoundIn->LastScreen()->SetZoom( GetScreen()->GetZoom() ); *m_CurrentSheet = *sheetFoundIn; m_CurrentSheet->UpdateAllScreenReferences(); } sheetFoundIn->LastScreen()->SetCrossHairPosition( lastMarker->GetPosition() ); RedrawScreen( lastMarker->GetPosition(), warpCursor ); wxString path = sheetFoundIn->Path(); wxString units = GetAbbreviatedUnitsLabel(); double x = To_User_Unit( g_UserUnit, (double) lastMarker->GetPosition().x, m_internalUnits ); double y = To_User_Unit( g_UserUnit, (double) lastMarker->GetPosition().y, m_internalUnits ); msg.Printf( _( "Design rule check marker found in sheet %s at %0.3f%s, %0.3f%s" ), GetChars( path ), x, GetChars( units ), y, GetChars( units) ); SetStatusText( msg ); } else { SetStatusText( _( "No more markers were found." ) ); } }
int HandleEvents() { XEvent event; int ret = 0; if (XPending(dpy)) { do { XNextEvent(dpy, &event); switch(event.type) { case KeyPress: keyboard_handler(XKeycodeToKeysym(dpy, event.xkey.keycode, 0), 1); ret = 1; break; case KeyRelease: keyboard_handler(XKeycodeToKeysym(dpy, event.xkey.keycode, 0), 0); ret = 0; break; case Expose: RedrawScreen(); break; case ConfigureNotify: glViewport(0, 0, event.xconfigure.width, event.xconfigure.height); glPixelZoom(1.0f, -1.0f); glRasterPos2f(-1.0f, 1.0f); RedrawScreen(); break; case ClientMessage: if (event.xclient.data.l[0] == wmDeleteWindow) Quit(NULL); break; default: break; } } while (XPending(dpy)); } return ret; }
void SCH_EDIT_FRAME::DisplayCurrentSheet() { SetRepeatItem( NULL ); ClearMsgPanel(); SCH_SCREEN* screen = m_CurrentSheet->LastScreen(); // Switch to current sheet, // and update the grid size, because it can be modified in latest screen SetScreen( screen ); GetScreen()->SetGrid( m_LastGridSizeId + ID_POPUP_GRID_LEVEL_1000 ); // update the References m_CurrentSheet->UpdateAllScreenReferences(); SetSheetNumberAndCount(); m_canvas->SetCanStartBlock( -1 ); if( screen->m_FirstRedraw ) { Zoom_Automatique( false ); screen->m_FirstRedraw = false; SetCrossHairPosition( GetScrollCenterPosition() ); m_canvas->MoveCursorToCrossHair(); // Ensure the schematic is fully segmented on first display BreakSegmentsOnJunctions(); SchematicCleanUp( true ); screen->ClearUndoORRedoList( screen->m_UndoList, 1 ); screen->TestDanglingEnds(); } else { RedrawScreen( GetScrollCenterPosition(), true ); } // Some items (wires, labels) can be highlighted. So prepare the highlight flag: SetCurrentSheetHighlightFlags(); // Now refresh m_canvas. Should be not necessary, but because screen has changed // the previous refresh has set all new draw parameters (scroll position ..) // but most of time there were some inconsitencies about cursor parameters // ( previous position of cursor ...) and artefacts can happen // mainly when sheet size has changed // This second refresh clears artefacts because at this point, // all parameters are now updated m_canvas->Refresh(); }
void LIB_EDIT_FRAME::PlaceAnchor() { if( LIB_PART* part = GetCurPart() ) { const wxPoint& cross_hair = GetCrossHairPosition(); wxPoint offset( -cross_hair.x, cross_hair.y ); OnModify( ); part->SetOffset( offset ); // Redraw the symbol RedrawScreen( wxPoint( 0 , 0 ), true ); m_canvas->Refresh(); } }
/********************************************************************** * Clipping * **********************************************************************/ void ClipTracksLeft(int x) { int i,idx, idx2; Trace *trc; double sdiff; if (Mode_align) { /* get secs offset */ trc=traces[lowTrkIndex]; /* don't use trace 0, might not scaled */ sdiff= (double)(trc->axis.hs*x)/trc->wave->info.sample_rate; earl_time = st_add_dtime(earl_time, sdiff * USECS_PER_SEC); /* adjust Total Seconds */ TotalSeconds = st_tdiff(late_time,earl_time); for(i=0; i <= LastTrack; i++) { trc= traces[i]; idx = coordToIndex(&trc->axis, x, 1); trc->axis.ix1=idx; idx2= trc->axis.ix2; if(idx2<trc->wave->info.n_values && auto_demean) { demean_trace(trc->wave,&trc->axis,idx,idx2); } RescaleTrace(trc, tracks[0]->height, tracks[0]->width); trc->zaxis_needScale= 1; trc->zaxis.ymax= trc->zaxis.y1= trc->axis.ymax; trc->zaxis.ymin= trc->zaxis.y2= trc->axis.ymin; #if 0 trc->zaxis.vs= trc->zaxis.hs= 0; #endif } }else { for(i=0; i <= LastTrack; i++) { trc= traces[i]; idx= coordToIndex(&trc->axis, x, 1); trc->axis.ix1=idx; RescaleTrace(trc, tracks[0]->height, tracks[0]->width); } } if(ZoomWindowMapped) { for(i=lowZTrkIndex; i<= highZTrkIndex; i++) { Trace *trc=traces[i]; fixZtrkBounds(trc, trc->zaxis.ix2-trc->zaxis.ix1); } RedrawZoomWindow("ClipTracksLeft"); } RedrawScreen(); }
void EDA_DRAW_FRAME::OnSelectZoom( wxCommandEvent& event ) { if( m_zoomSelectBox == NULL ) return; // Should not happen! int id = m_zoomSelectBox->GetCurrentSelection(); if( id < 0 || !( id < (int)m_zoomSelectBox->GetCount() ) ) return; if( id == 0 ) // Auto zoom (Fit in Page) { Zoom_Automatique( true ); } else { id--; double selectedZoom = GetScreen()->m_ZoomList[id]; if( GetScreen()->GetZoom() == selectedZoom ) return; GetScreen()->SetZoom( selectedZoom ); if( IsGalCanvasActive() ) { // Apply computed view settings to GAL KIGFX::VIEW* view = GetGalCanvas()->GetView(); KIGFX::GAL* gal = GetGalCanvas()->GetGAL(); double zoomFactor = gal->GetWorldScale() / gal->GetZoomFactor(); double zoom = 1.0 / ( zoomFactor * GetZoom() ); view->SetScale( zoom ); GetGalCanvas()->Refresh(); } else RedrawScreen( GetScrollCenterPosition(), false ); } }
void restore_orig_order() { int i; RestoreLoadOrder(); lowTrkIndex= 0; highTrkIndex= NumTracks-1; lowZTrkIndex= 0; highZTrkIndex= NumZTracks-1; for(i=0; i < TotalTracks; i++) { if (traces[i]) { traces[i]->zaxis.hs=0; } } /* rescale zoomed traces, if necessary */ if (ZoomWindowMapped) { for(i=lowZTrkIndex; i<=highZTrkIndex; i++) { ScaleZTrack(traces[i], traces[lowZTrkIndex]); } RedrawZoomWindow("restore_orig_order"); } RedrawScreen(); }
void PCB_BASE_FRAME::CursorGoto( const wxPoint& aPos ) { // factored out of pcbnew/find.cpp PCB_SCREEN* screen = (PCB_SCREEN*)GetScreen(); wxClientDC dc( m_canvas ); // There may be need to reframe the drawing. if( !m_canvas->IsPointOnDisplay( aPos ) ) { screen->SetCrossHairPosition( aPos ); RedrawScreen( aPos, true ); } else { // Put cursor on item position m_canvas->CrossHairOff( &dc ); screen->SetCrossHairPosition( aPos ); m_canvas->MoveCursorToCrossHair(); m_canvas->CrossHairOn( &dc ); } }
void EDA_DRAW_FRAME::Process_PageSettings( wxCommandEvent& event ) { FRAME_T smallSizeFrames[] = { FRAME_PCB, FRAME_PCB_MODULE_EDITOR, FRAME_PCB_MODULE_VIEWER, FRAME_PCB_MODULE_VIEWER_MODAL, FRAME_PCB_FOOTPRINT_WIZARD, FRAME_PCB_FOOTPRINT_PREVIEW, FRAME_CVPCB_DISPLAY }; // Fix the max page size: it is MAX_PAGE_SIZE_EDITORS // or MAX_PAGE_SIZE_PCBNEW for Pcbnew draw frames, due to the small internal // units that do not allow too large draw areas wxSize maxPageSize( MAX_PAGE_SIZE_EDITORS_MILS, MAX_PAGE_SIZE_EDITORS_MILS ); for( unsigned ii = 0; ii < arrayDim( smallSizeFrames ); ii++ ) { if( IsType( smallSizeFrames[ii] ) ) { maxPageSize.x = maxPageSize.y = MAX_PAGE_SIZE_PCBNEW_MILS; break; } } DIALOG_PAGES_SETTINGS dlg( this, maxPageSize ); dlg.SetWksFileName( BASE_SCREEN::m_PageLayoutDescrFileName ); if( dlg.ShowModal() == wxID_OK ) { #ifdef EESCHEMA RedrawScreen( wxPoint( 0, 0 ), false ); #else GetCanvas()->Refresh(); #endif } }
void FullScale() { int i; Trace *trc; if (Mode_align) { if (Mode_align==1) { UnifyTimeScale(); } else if (Mode_align==2) { timescale_noalign(); } for(i=0; i <=LastTrack; i++) { trc= traces[i]; if (auto_demean) { demean_trace(trc->wave,&trc->axis,0,trc->wave->info.n_values-1); } RescaleTrace(trc, tracks[0]->height, tracks[0]->width); trc->zaxis_needScale= 1; trc->zaxis.ymax= trc->zaxis.y1= trc->axis.ymax; trc->zaxis.ymin= trc->zaxis.y2= trc->axis.ymin; } }else { float sps; for(i=0; i <=LastTrack; i++) { trc= traces[i]; trc->axis.ix1=0; trc->axis.ix2=trc->wave->info.n_values-1; sps= trc->wave->info.sample_rate; ScaleTAxis(&trc->axis, sps, tracks[0]->width); } } /* Should this redraw be controlled? */ RedrawScreen(); if(ZoomWindowMapped) RedrawZoomWindow("FullScale"); }
void PermanentClip() { int i; Trace *trc; float *data, *newd; int nsamp; int j, k, ix1, ix2, pidx; STI_TIME ntm; double trimmed; BIS3_HEADER *bh; Pick *p, *t, *newp; Amp *pa, *ta, *newa; for(i=0; i<= LastTrack; i++) { trc=traces[i]; if(trc->wave) { bh = &trc->wave->info; ix1= trc->axis.ix1; ix2= trc->axis.ix2; if(ix1>0) { trc->axis.ix1-= ix1; trc->axis.ix2-= ix1; } if (!fixIxBounds(&ix1,&ix2,trc->wave->info.n_values)) { /* can discard this one */ cleanTrace(trc); continue; } /* ix1, ix2 fixed */ nsamp= ix2-ix1+1; newd= (float *)Malloc(sizeof(float)*nsamp); data= trc->wave->data; trimmed = ((double)ix1)/bh->sample_rate; ntm = st_add_dtime(bh->start_it, trimmed * USECS_PER_SEC); for(j=0,k= ix1; j< nsamp; j++, k++) { newd[j]= data[k]; } trc->wave->data= newd; free(data); bh->n_values= nsamp; trc->zaxis_needScale= 1; /* adjust picks */ newp=p= NULL; t= trc->picks; while(t) { /* discard picks outside the retained region */ /* note that bh->start_it must NOT be changed yet */ pidx = pick_index(t, trc, 1); if(pidx >= ix1 && pidx <= ix2) { t->secOffset -= trimmed ; /* add to the list to retain */ if (p==NULL) { newp=p= t; }else { p->next= t; p= p->next; } } t= t->next; } if(p!=NULL) p->next= NULL; trc->picks= newp; bh->start_it = ntm; /* do similar for regions */ { Reg_select *cur_reg=trc->sel_reg; Reg_select *pre_reg=NULL; int remove=0; while (cur_reg != NULL) { if (cur_reg->right_index<ix1 || cur_reg->left_index>ix2) remove=1; /* adjust region to be in the new region */ cur_reg->right_index -= ix1; cur_reg->left_index -= ix1; /* ie adjust clipped off edges */ if (cur_reg->left_index<0) cur_reg->left_index=0; if (cur_reg->right_index>=nsamp) cur_reg->right_index=nsamp; pre_reg=cur_reg; cur_reg=cur_reg->next; if (remove) RemoveSRegion(pre_reg,trc); remove=0; } } if (ix1<0) ix1= -ix1; /* note we flip ix1 if < 0 */ trc->zaxis.ix1-= ix1; #if 0 if(trc->zaxis.ix1<0) trc->zaxis.ix1=0; #endif trc->zaxis.ix2-= ix1; #if 0 if(trc->zaxis.ix2>=nsamp) trc->zaxis.ix1=nsamp-1; #endif /* what about triplets?? -- sovrlap, etc. */ /* what about amplitdes??? */ } } RedrawScreen(); if(ZoomWindowMapped) RedrawZoomWindow("permanentClip"); }
long FAR PASCAL StatusWndProc( HWND hWnd, unsigned message, WPARAM wParam, LONG lParam) { extern SCREEN WinFact, WinAgenda, WinInst, WinGlobal, WinFocus; SCREEN *Window; void (*GetPPForm)(char*,int,void*) = NULL; void *(*GetNextValue)(void*) = NULL; /*---------------------------------------------------+ | Determine which Window the message is intended for | +---------------------------------------------------*/ #if DEFTEMPLATE_CONSTRUCT if ( hWnd == WinFact.hWnd ) { Window = &WinFact; GetNextValue = GetNextFactInScope; GetPPForm = GetFactPPForm; } #endif #if OBJECT_SYSTEM if ( hWnd == WinInst.hWnd ) { Window = &WinInst; GetNextValue = GetNextInstanceInScope; GetPPForm = GetInstancePPForm; } #endif #if DEFGLOBAL_CONSTRUCT if ( hWnd == WinGlobal.hWnd ) { Window = &WinGlobal; GetNextValue = GetNextDefglobalInScope; GetPPForm = GetDefglobalValueForm; } #endif #if DEFRULE_CONSTRUCT if ( hWnd == WinAgenda.hWnd ) { Window = &WinAgenda; GetNextValue = GetNextActivation; GetPPForm = GetActivationPPForm; } if ( hWnd == WinFocus.hWnd ) { Window = &WinFocus; GetNextValue = GetNextFocus; GetPPForm = GetFocusPPForm; } #endif switch (message) { case WM_VSCROLL: return ( ProcessScrollMsg ( Window, LOWORD(wParam), lParam, SB_VERT )); case WM_HSCROLL: return ( ProcessScrollMsg ( Window, LOWORD(wParam), lParam, SB_HORZ )); case WM_SIZE: { /*-----------------------+ | Window Changes in Size | +-----------------------*/ (*Window).NoLines = HIWORD (lParam) / (*Window).LineSize; UpdateWnd ( Window ); break; } case WM_KEYDOWN: { /*----------------------------------------------------+ | Key input was detected in window send to Dialog Wnd | +----------------------------------------------------*/ extern SCREEN WinDialog; PostMessage ( WinDialog.hWnd, message, wParam, lParam); SetFocus ( WinDialog.hWnd ); break; } case WM_PAINT: { /*---------------------+ | Screen Update Needed | +---------------------*/ PAINTSTRUCT ps; HDC hDC; BeginPaint (hWnd, (LPPAINTSTRUCT)&ps); hDC = ps.hdc; SetMapMode (hDC, MM_TEXT); RedrawScreen ( Window, GetPPForm, GetNextValue, hDC ); ValidateRect (hWnd, (LPRECT)NULL); EndPaint (hWnd, (LPPAINTSTRUCT)&ps); return (TRUE); } default: return (DefWindowProc(hWnd, message, wParam, lParam)); } return ( TRUE ); }
SCH_ITEM* SCH_EDIT_FRAME::FindComponentAndItem( const wxString& aReference, bool aSearchHierarchy, SCH_SEARCH_T aSearchType, const wxString& aSearchText, bool aWarpMouse ) { SCH_SHEET_PATH* sheet = NULL; SCH_SHEET_PATH* sheetWithComponentFound = NULL; SCH_ITEM* item = NULL; SCH_COMPONENT* Component = NULL; wxPoint pos; bool centerAndRedraw = false; bool notFound = true; LIB_PIN* pin; SCH_SHEET_LIST sheetList( g_RootSheet ); if( !aSearchHierarchy ) sheetList.push_back( *m_CurrentSheet ); else sheetList.BuildSheetList( g_RootSheet ); for( SCH_SHEET_PATHS_ITER it = sheetList.begin(); it != sheetList.end(); ++it ) { sheet = &(*it); item = (*it).LastDrawList(); for( ; ( item != NULL ) && ( notFound == true ); item = item->Next() ) { if( item->Type() != SCH_COMPONENT_T ) continue; SCH_COMPONENT* pSch = (SCH_COMPONENT*) item; if( aReference.CmpNoCase( pSch->GetRef( sheet ) ) == 0 ) { Component = pSch; sheetWithComponentFound = sheet; switch( aSearchType ) { default: case FIND_COMPONENT_ONLY: // Find component only notFound = false; pos = pSch->GetPosition(); break; case FIND_PIN: // find a pin pos = pSch->GetPosition(); // temporary: will be changed if the pin is found. pin = pSch->GetPin( aSearchText ); if( pin == NULL ) break; notFound = false; pos += pin->GetPosition(); break; case FIND_REFERENCE: // find reference notFound = false; pos = pSch->GetField( REFERENCE )->GetPosition(); break; case FIND_VALUE: // find value pos = pSch->GetPosition(); if( aSearchText.CmpNoCase( pSch->GetField( VALUE )->GetShownText() ) != 0 ) break; notFound = false; pos = pSch->GetField( VALUE )->GetPosition(); break; } } } if( notFound == false ) break; } if( Component ) { sheet = sheetWithComponentFound; if( *sheet != *m_CurrentSheet ) { sheet->LastScreen()->SetZoom( GetScreen()->GetZoom() ); *m_CurrentSheet = *sheet; m_CurrentSheet->UpdateAllScreenReferences(); centerAndRedraw = true; } wxPoint delta; pos -= Component->GetPosition(); delta = Component->GetTransform().TransformCoordinate( pos ); pos = delta + Component->GetPosition(); /* There may be need to reframe the drawing */ if( ! m_canvas->IsPointOnDisplay( pos ) ) { centerAndRedraw = true; } if( centerAndRedraw ) { SetCrossHairPosition( pos ); RedrawScreen( pos, aWarpMouse ); } else { INSTALL_UNBUFFERED_DC( dc, m_canvas ); m_canvas->CrossHairOff( &dc ); if( aWarpMouse ) m_canvas->MoveCursor( pos ); SetCrossHairPosition( pos ); m_canvas->CrossHairOn( &dc ); } } /* Print diag */ wxString msg_item; wxString msg; switch( aSearchType ) { default: case FIND_COMPONENT_ONLY: // Find component only msg_item = _( "component" ); break; case FIND_PIN: // find a pin msg_item.Printf( _( "pin %s" ), GetChars( aSearchText ) ); break; case FIND_REFERENCE: // find reference msg_item.Printf( _( "reference %s" ), GetChars( aSearchText ) ); break; case FIND_VALUE: // find value msg_item.Printf( _( "value %s" ), GetChars( aSearchText ) ); break; case FIND_FIELD: // find field. todo msg_item.Printf( _( "field %s" ), GetChars( aSearchText ) ); break; } if( Component ) { if( !notFound ) { msg.Printf( _( "%s %s found" ), GetChars( aReference ), GetChars( msg_item ) ); } else { msg.Printf( _( "%s found but %s not found" ), GetChars( aReference ), GetChars( msg_item ) ); } } else { msg.Printf( _( "Component %s not found" ), GetChars( aReference ) ); } SetStatusText( msg ); return item; }
void FOOTPRINT_EDIT_FRAME::OnLeftClick( wxDC* DC, const wxPoint& MousePos ) { BOARD_ITEM* item = GetCurItem(); m_canvas->CrossHairOff( DC ); if( GetToolId() == ID_NO_TOOL_SELECTED ) { if( item && item->GetFlags() ) // Move item command in progress { switch( item->Type() ) { case PCB_MODULE_TEXT_T: PlaceTexteModule( (TEXTE_MODULE*) item, DC ); break; case PCB_MODULE_EDGE_T: SaveCopyInUndoList( GetBoard()->m_Modules, UR_MODEDIT ); Place_EdgeMod( (EDGE_MODULE*) item ); break; case PCB_PAD_T: PlacePad( (D_PAD*) item, DC ); break; default: { wxString msg; msg.Printf( wxT( "WinEDA_ModEditFrame::OnLeftClick err:Struct %d, m_Flag %X" ), item->Type(), item->GetFlags() ); DisplayError( this, msg ); item->ClearFlags(); break; } } } else { if( !wxGetKeyState( WXK_SHIFT ) && !wxGetKeyState( WXK_ALT ) && !wxGetKeyState( WXK_CONTROL ) ) item = ModeditLocateAndDisplay(); SetCurItem( item ); } } item = GetCurItem(); bool no_item_edited = item == NULL || item->GetFlags() == 0; switch( GetToolId() ) { case ID_NO_TOOL_SELECTED: break; case ID_MODEDIT_CIRCLE_TOOL: case ID_MODEDIT_ARC_TOOL: case ID_MODEDIT_LINE_TOOL: if( no_item_edited ) { STROKE_T shape = S_SEGMENT; if( GetToolId() == ID_MODEDIT_CIRCLE_TOOL ) shape = S_CIRCLE; if( GetToolId() == ID_MODEDIT_ARC_TOOL ) shape = S_ARC; SetCurItem( Begin_Edge_Module( (EDGE_MODULE*) NULL, DC, shape ) ); } else if( item->IsNew() ) { if( ( (EDGE_MODULE*) item )->GetShape() == S_CIRCLE ) { End_Edge_Module( (EDGE_MODULE*) item ); SetCurItem( NULL ); m_canvas->Refresh(); } else if( ( (EDGE_MODULE*) item )->GetShape() == S_ARC ) { End_Edge_Module( (EDGE_MODULE*) item ); SetCurItem( NULL ); m_canvas->Refresh(); } else if( ( (EDGE_MODULE*) item )->GetShape() == S_SEGMENT ) { SetCurItem( Begin_Edge_Module( (EDGE_MODULE*) item, DC, S_SEGMENT ) ); } else { DisplayError( this, wxT( "ProcessCommand error: item flags error" ) ); } } break; case ID_MODEDIT_DELETE_TOOL: if( ! no_item_edited ) // Item in edit, cannot delete it break; item = ModeditLocateAndDisplay(); if( item->Type() != PCB_MODULE_T ) // Cannot delete the module itself { SaveCopyInUndoList( GetBoard()->m_Modules, UR_MODEDIT ); RemoveStruct( item ); SetCurItem( NULL ); } break; case ID_MODEDIT_ANCHOR_TOOL: { MODULE* module = GetBoard()->m_Modules; if( module == NULL // No module loaded || (module->GetFlags() != 0) ) break; module->ClearFlags(); SaveCopyInUndoList( module, UR_MODEDIT ); Place_Ancre( module ); // set the new relatives internal coordinates of items RedrawScreen( wxPoint( 0, 0 ), true ); // Replace the module in position 0, to recalculate absolutes coordinates of items module->SetPosition( wxPoint( 0, 0 ) ); SetToolID( ID_NO_TOOL_SELECTED, m_canvas->GetDefaultCursor(), wxEmptyString ); SetCurItem( NULL ); m_canvas->Refresh(); } break; case ID_MODEDIT_PLACE_GRID_COORD: m_canvas->DrawGridAxis( DC, GR_XOR ); GetScreen()->m_GridOrigin = GetScreen()->GetCrossHairPosition(); m_canvas->DrawGridAxis( DC, GR_COPY ); GetScreen()->SetModify(); break; case ID_MODEDIT_TEXT_TOOL: if( GetBoard()->m_Modules == NULL ) break; SaveCopyInUndoList( GetBoard()->m_Modules, UR_MODEDIT ); CreateTextModule( GetBoard()->m_Modules, DC ); break; case ID_MODEDIT_PAD_TOOL: if( GetBoard()->m_Modules ) { SaveCopyInUndoList( GetBoard()->m_Modules, UR_MODEDIT ); AddPad( GetBoard()->m_Modules, true ); } break; default: DisplayError( this, wxT( "FOOTPRINT_EDIT_FRAME::ProcessCommand error" ) ); SetToolID( ID_NO_TOOL_SELECTED, m_canvas->GetDefaultCursor(), wxEmptyString ); } m_canvas->CrossHairOn( DC ); }
void ResizeScreen(Xv_Window window, Event *event) { int newht, cfght, neww, cfgw; char *s; int tsht= 30; int panel_width = top_panel_width; if (event_action(event)==WIN_REPAINT) { if(Mode_noBorder) { GC gc= DefaultGC(theDisp, DefaultScreen(theDisp)); XFillRectangle(theDisp, xv_get(window,XV_XID), gc, TXTCANV_WIDTH-2,0,5,FrmHeight); } return; } /* only handles RESIZE events for this event_proc */ if (event_action(event)!=WIN_RESIZE) return; newht= (int)xv_get(tracesFrame, XV_HEIGHT); neww= (int)xv_get(tracesFrame, XV_WIDTH); /* ignore synthetic events from window manager */ if (event_xevent(event)->xconfigure.send_event!=TRUE) { int y, i, newtrkht; Track *trk; FrmHeight=newht; FrmWidth=neww; if((newht-panel_width-tsht)/NumTracks<30) tsht= 15; if(Mode_align) { newtrkht= (float)(newht-panel_width-tsht)/NumTracks; tsht= newht-panel_width-newtrkht*NumTracks; }else { newtrkht= (float)(newht-panel_width)/NumTracks; } y=panel_width; xv_set(tracesScvs, XV_X, neww-XVSBARWIDTH, XV_Y, panel_width, NULL); for(i=0; i < NumTracks; i++) { trk= tracks[i]; trk->height=newtrkht; trk->width=neww-TXTCANV_WIDTH-XVSBARWIDTH; if (trk->TxtCanvas) { if(Mode_noBorder) { xv_set(trk->TxtCanvas, XV_X, 0, XV_Y, y, XV_WIDTH, TXTCANV_WIDTH-2, XV_HEIGHT, newtrkht, NULL); }else { xv_set(trk->TxtCanvas, XV_X, 0, XV_Y, y, XV_WIDTH, TXTCANV_WIDTH, XV_HEIGHT, newtrkht, NULL); } } if (trk->canvas) { xv_set(trk->canvas, XV_X, TXTCANV_WIDTH, XV_Y, y, XV_WIDTH, neww-TXTCANV_WIDTH-19, XV_HEIGHT, newtrkht, NULL); } y+=newtrkht; } AdjustSbar(); SetSbarPosition(); for(i=0; i <= LastTrack; i++) { /* can't do this: clipping won't work * traces[i]->axis_needScale= 1; */ RescaleTrace(traces[i], newtrkht, tracks[0]->width); } if (Mode_align) { ResizeTScale(y, neww-19, tsht); } /* don't trust all the canvas being auto-repainted, known to fail user's expectations: here's the forbidden fix, but let the user control it. */ if (Mode_Auto_redraw) RedrawScreen(); } return; }
void SCH_EDIT_FRAME::updateFindReplaceView( wxFindDialogEvent& aEvent ) { wxString msg; SCH_SHEET_LIST schematic( g_RootSheet ); SCH_FIND_COLLECTOR_DATA data; SCH_FIND_REPLACE_DATA searchCriteria; bool warpCursor = !( aEvent.GetFlags() & FR_NO_WARP_CURSOR ); searchCriteria.SetFlags( aEvent.GetFlags() ); searchCriteria.SetFindString( aEvent.GetFindString() ); searchCriteria.SetReplaceString( aEvent.GetReplaceString() ); if( m_foundItems.GetItem( data ) != NULL ) { wxLogTrace( traceFindReplace, wxT( "Found " ) + m_foundItems.GetText() ); SCH_SHEET_PATH* sheet = schematic.GetSheetByPath( data.GetSheetPath() ); wxCHECK_RET( sheet != NULL, wxT( "Could not find sheet path " ) + data.GetSheetPath() ); SCH_ITEM* item = (SCH_ITEM*)m_foundItems.GetItem( data ); // Make the item temporarily visible just in case it's hide flag is set. This // has no effect on objects that don't support hiding. If this is a close find // dialog event, clear the temporary visibility flag. if( item ) { if( aEvent.GetEventType() == wxEVT_COMMAND_FIND_CLOSE ) item->SetForceVisible( false ); else if( item->Type() == SCH_FIELD_T && !( (SCH_FIELD*) item )->IsVisible() ) item->SetForceVisible( true ); } if( sheet->PathHumanReadable() != m_CurrentSheet->PathHumanReadable() ) { sheet->LastScreen()->SetZoom( GetScreen()->GetZoom() ); *m_CurrentSheet = *sheet; m_CurrentSheet->UpdateAllScreenReferences(); SetScreen( sheet->LastScreen() ); } // careful here SetCrossHairPosition( data.GetPosition() ); RedrawScreen( data.GetPosition(), warpCursor ); msg = m_foundItems.GetText(); if( aEvent.GetFlags() & FR_SEARCH_REPLACE ) aEvent.SetFlags( aEvent.GetFlags() | FR_REPLACE_ITEM_FOUND ); } else { if( aEvent.GetFlags() & FR_SEARCH_REPLACE ) aEvent.SetFlags( aEvent.GetFlags() & ~FR_REPLACE_ITEM_FOUND ); msg.Printf( _( "No item found matching %s." ), GetChars( aEvent.GetFindString() ) ); } SetStatusText( msg ); }
void SCH_EDIT_FRAME::OnFindSchematicItem( wxFindDialogEvent& aEvent ) { static wxPoint itemPosition; // the actual position of the matched item. SCH_SHEET_LIST schematic; wxString msg; SCH_FIND_REPLACE_DATA searchCriteria; bool warpCursor = !( aEvent.GetFlags() & FR_NO_WARP_CURSOR ); SCH_FIND_COLLECTOR_DATA data; searchCriteria.SetFlags( aEvent.GetFlags() ); searchCriteria.SetFindString( aEvent.GetFindString() ); searchCriteria.SetReplaceString( aEvent.GetReplaceString() ); if( aEvent.GetEventType() == wxEVT_COMMAND_FIND_CLOSE ) { if( m_foundItems.GetCount() == 0 ) return; } else if( m_foundItems.IsSearchRequired( searchCriteria ) ) { if( aEvent.GetFlags() & FR_CURRENT_SHEET_ONLY && g_RootSheet->CountSheets() > 1 ) { m_foundItems.Collect( searchCriteria, m_CurrentSheet ); } else { m_foundItems.Collect( searchCriteria ); } } else { EDA_ITEM* currentItem = m_foundItems.GetItem( data ); if( currentItem != NULL ) currentItem->SetForceVisible( false ); m_foundItems.UpdateIndex(); } if( m_foundItems.GetItem( data ) != NULL ) { wxLogTrace( traceFindReplace, wxT( "Found " ) + m_foundItems.GetText() ); SCH_SHEET_PATH* sheet = schematic.GetSheet( data.GetSheetPath() ); wxCHECK_RET( sheet != NULL, wxT( "Could not find sheet path " ) + data.GetSheetPath() ); // Make the item temporarily visible just in case it's hide flag is set. This // has no effect on objects that don't support hiding. If this is a close find // dialog event, clear the temporary visibility flag. if( aEvent.GetEventType() == wxEVT_COMMAND_FIND_CLOSE ) m_foundItems.GetItem( data )->SetForceVisible( false ); else m_foundItems.GetItem( data )->SetForceVisible( true ); if( sheet->PathHumanReadable() != m_CurrentSheet->PathHumanReadable() ) { sheet->LastScreen()->SetZoom( GetScreen()->GetZoom() ); *m_CurrentSheet = *sheet; m_CurrentSheet->UpdateAllScreenReferences(); SetScreen( sheet->LastScreen() ); } sheet->LastScreen()->SetCrossHairPosition( data.GetPosition() ); RedrawScreen( data.GetPosition(), warpCursor ); msg = m_foundItems.GetText(); if( aEvent.GetFlags() & FR_SEARCH_REPLACE ) aEvent.SetFlags( aEvent.GetFlags() | FR_REPLACE_ITEM_FOUND ); } else { if( aEvent.GetFlags() & FR_SEARCH_REPLACE ) aEvent.SetFlags( aEvent.GetFlags() & ~FR_REPLACE_ITEM_FOUND ); msg.Printf( _( "No item found matching %s." ), GetChars( aEvent.GetFindString() ) ); } SetStatusText( msg ); }
SCH_ITEM* SCH_EDIT_FRAME::FindComponentAndItem( const wxString& aReference, bool aSearchHierarchy, SCH_SEARCH_T aSearchType, const wxString& aSearchText, bool aWarpMouse ) { SCH_SHEET_PATH* sheet; SCH_SHEET_PATH* sheetWithComponentFound = NULL; SCH_ITEM* item = NULL; SCH_COMPONENT* Component = NULL; wxPoint pos, curpos; bool centerAndRedraw = false; bool notFound = true; wxString msg; LIB_PIN* pin; SCH_SHEET_LIST sheetList; sheet = sheetList.GetFirst(); if( !aSearchHierarchy ) sheet = m_CurrentSheet; for( ; sheet != NULL; sheet = sheetList.GetNext() ) { item = (SCH_ITEM*) sheet->LastDrawList(); for( ; ( item != NULL ) && ( notFound == true ); item = item->Next() ) { if( item->Type() != SCH_COMPONENT_T ) continue; SCH_COMPONENT* pSch = (SCH_COMPONENT*) item; if( aReference.CmpNoCase( pSch->GetRef( sheet ) ) == 0 ) { Component = pSch; sheetWithComponentFound = sheet; switch( aSearchType ) { default: case FIND_COMPONENT_ONLY: // Find component only notFound = false; pos = pSch->GetPosition(); break; case FIND_PIN: // find a pin pos = pSch->GetPosition(); // temporary: will be changed if the pin is found. pin = pSch->GetPin( aSearchText ); if( pin == NULL ) break; notFound = false; pos += pin->GetPosition(); break; case FIND_REFERENCE: // find reference notFound = false; pos = pSch->GetField( REFERENCE )->GetPosition(); break; case FIND_VALUE: // find value pos = pSch->GetPosition(); if( aSearchText.CmpNoCase( pSch->GetField( VALUE )->m_Text ) != 0 ) break; notFound = false; pos = pSch->GetField( VALUE )->GetPosition(); break; } } } if( (aSearchHierarchy == false) || (notFound == false) ) break; } if( Component ) { sheet = sheetWithComponentFound; if( *sheet != *m_CurrentSheet ) { sheet->LastScreen()->SetZoom( GetScreen()->GetZoom() ); *m_CurrentSheet = *sheet; m_CurrentSheet->UpdateAllScreenReferences(); centerAndRedraw = true; } wxPoint delta; pos -= Component->GetPosition(); delta = Component->GetTransform().TransformCoordinate( pos ); pos = delta + Component->GetPosition(); /* There may be need to reframe the drawing */ if( ! m_canvas->IsPointOnDisplay( pos ) ) { centerAndRedraw = true; } if( centerAndRedraw ) { GetScreen()->SetCrossHairPosition(pos); RedrawScreen( pos, aWarpMouse ); } else { INSTALL_UNBUFFERED_DC( dc, m_canvas ); m_canvas->CrossHairOff( &dc ); if( aWarpMouse ) m_canvas->MoveCursor( pos ); GetScreen()->SetCrossHairPosition(pos); m_canvas->CrossHairOn( &dc ); } } /* Print diag */ wxString msg_item; msg = aReference; switch( aSearchType ) { default: case FIND_COMPONENT_ONLY: // Find component only break; case FIND_PIN: // find a pin msg_item = _( "Pin " ) + aSearchText; break; case FIND_REFERENCE: // find reference msg_item = _( "Ref " ) + aSearchText; break; case FIND_VALUE: // find value msg_item = _( "Value " ) + aSearchText; break; case FIND_FIELD: // find field. todo msg_item = _( "Field " ) + aSearchText; break; } if( Component ) { if( !notFound ) { if( !msg_item.IsEmpty() ) msg += wxT( " " ) + msg_item; msg += _( " found" ); } else { msg += _( " found" ); if( !msg_item.IsEmpty() ) { msg += wxT( " but " ) + msg_item + _( " not found" ); } } } else { if( !msg_item.IsEmpty() ) msg += wxT( " " ) + msg_item; msg += _( " not found" ); } SetStatusText( msg ); return item; }
/* Execute a remote command send by Eeschema via a socket, * port KICAD_PCB_PORT_SERVICE_NUMBER * cmdline = received command from Eeschema * Commands are * $PART: "reference" put cursor on component * $PIN: "pin name" $PART: "reference" put cursor on the footprint pin */ void PCB_EDIT_FRAME::ExecuteRemoteCommand( const char* cmdline ) { char line[1024]; wxString msg; wxString modName; char* idcmd; char* text; MODULE* module = 0; BOARD* pcb = GetBoard(); wxPoint pos; strncpy( line, cmdline, sizeof(line) - 1 ); idcmd = strtok( line, " \n\r" ); text = strtok( NULL, " \n\r" ); if( !idcmd || !text ) return; if( strcmp( idcmd, "$PART:" ) == 0 ) { modName = FROM_UTF8( text ); module = pcb->FindModuleByReference( modName ); if( module ) msg.Printf( _( "%s found" ), GetChars( modName ) ); else msg.Printf( _( "%s not found" ), GetChars( modName ) ); SetStatusText( msg ); if( module ) pos = module->GetPosition(); } else if( strcmp( idcmd, "$PIN:" ) == 0 ) { wxString pinName; D_PAD* pad = NULL; int netcode = -1; pinName = FROM_UTF8( text ); text = strtok( NULL, " \n\r" ); if( text && strcmp( text, "$PART:" ) == 0 ) text = strtok( NULL, "\n\r" ); modName = FROM_UTF8( text ); module = pcb->FindModuleByReference( modName ); if( module ) pad = module->FindPadByName( pinName ); if( pad ) { netcode = pad->GetNetCode(); // put cursor on the pad: pos = pad->GetPosition(); } if( netcode > 0 ) // highlight the pad net { pcb->HighLightON(); pcb->SetHighLightNet( netcode ); } else { pcb->HighLightOFF(); pcb->SetHighLightNet( -1 ); } if( module == NULL ) { msg.Printf( _( "%s not found" ), GetChars( modName ) ); } else if( pad == NULL ) { msg.Printf( _( "%s pin %s not found" ), GetChars( modName ), GetChars( pinName ) ); SetCurItem( module ); } else { msg.Printf( _( "%s pin %s found" ), GetChars( modName ), GetChars( pinName ) ); SetCurItem( pad ); } SetStatusText( msg ); } if( module ) // if found, center the module on screen, and redraw the screen. { SetCrossHairPosition( pos ); RedrawScreen( pos, false ); } }
/* Handles the selection of tools, menu, and popup menu commands. */ void PL_EDITOR_FRAME::Process_Special_Functions( wxCommandEvent& event ) { int id = event.GetId(); int idx; wxString msg; WORKSHEET_LAYOUT& pglayout = WORKSHEET_LAYOUT::GetTheInstance(); WORKSHEET_DATAITEM* item = NULL; wxCommandEvent cmd( wxEVT_COMMAND_MENU_SELECTED ); cmd.SetEventObject( this ); switch( id ) { case ID_NO_TOOL_SELECTED: SetNoToolSelected(); break; case ID_MENU_ZOOM_SELECTION: case ID_ZOOM_SELECTION: // This tool is located on the main toolbar: switch it on or off on click if( GetToolId() != ID_ZOOM_SELECTION ) SetToolID( ID_ZOOM_SELECTION, wxCURSOR_MAGNIFIER, _( "Zoom to selection" ) ); else SetNoToolSelected(); break; case ID_SELECT_PAGE_NUMBER: m_canvas->Refresh(); break; case ID_SHEET_SET: { DIALOG_PAGES_SETTINGS dlg( this ); dlg.SetWksFileName( GetCurrFileName() ); dlg.EnableWksFileNamePicker( false ); dlg.ShowModal(); cmd.SetId( ID_ZOOM_PAGE ); wxPostEvent( this, cmd ); } break; case ID_POPUP_CANCEL_CURRENT_COMMAND: if( m_canvas->IsMouseCaptured() ) { m_canvas->EndMouseCapture(); SetToolID( GetToolId(), m_canvas->GetCurrentCursor(), wxEmptyString ); } else { SetNoToolSelected(); } break; case ID_POPUP_DESIGN_TREE_ITEM_DELETE: case ID_POPUP_ITEM_DELETE: case wxID_CUT: // Delete item, and select the previous item item = m_treePagelayout->GetPageLayoutSelectedItem(); if( item == NULL ) break; SaveCopyInUndoList(); idx = pglayout.GetItemIndex( item ); pglayout.Remove( item ); RebuildDesignTree(); if( id == ID_POPUP_DESIGN_TREE_ITEM_DELETE ) { item = pglayout.GetItem( (unsigned) (idx-1) ); if( item ) m_treePagelayout->SelectCell( item ); } item = NULL; OnModify(); m_canvas->Refresh(); break; case ID_POPUP_ITEM_ADD_LINE: SaveCopyInUndoList(); idx = m_treePagelayout->GetSelectedItemIndex(); item = AddPageLayoutItem( WORKSHEET_DATAITEM::WS_SEGMENT, idx ); if( InvokeDialogNewItem( this, item ) == wxID_CANCEL ) { RemoveLastCommandInUndoList(); pglayout.Remove( item ); RebuildDesignTree(); item = NULL; } else { // Put the new item in move mode, after putting the cursor // on the start point: wxPoint position = item->GetStartPosUi(); SetCrossHairPosition( position, false ); position = GetCrossHairPosition(); if( m_canvas->IsPointOnDisplay( position ) ) m_canvas->MoveCursorToCrossHair(); else RedrawScreen( position, true ); item->SetFlags( NEW_ITEM ); MoveItem( item ); } break; case ID_POPUP_ITEM_ADD_RECT: SaveCopyInUndoList(); idx = m_treePagelayout->GetSelectedItemIndex(); item = AddPageLayoutItem( WORKSHEET_DATAITEM::WS_RECT, idx ); if( InvokeDialogNewItem( this, item ) == wxID_CANCEL ) { RemoveLastCommandInUndoList(); pglayout.Remove( item ); RebuildDesignTree(); item = NULL; } else { // Put the new item in move mode, after putting the cursor // on the start point: wxPoint position = item->GetStartPosUi(); SetCrossHairPosition( position, false ); position = GetCrossHairPosition(); if( m_canvas->IsPointOnDisplay( position ) ) m_canvas->MoveCursorToCrossHair(); else RedrawScreen( position, true ); item->SetFlags( NEW_ITEM ); MoveItem( item ); } break; case ID_POPUP_ITEM_ADD_TEXT: SaveCopyInUndoList(); idx = m_treePagelayout->GetSelectedItemIndex(); item = AddPageLayoutItem( WORKSHEET_DATAITEM::WS_TEXT, idx ); if( InvokeDialogNewItem( this, item ) == wxID_CANCEL ) { RemoveLastCommandInUndoList(); pglayout.Remove( item ); RebuildDesignTree(); item = NULL; } else { // Put the new text in move mode: item->SetFlags( NEW_ITEM | LOCATE_STARTPOINT ); MoveItem( item ); } break; case ID_POPUP_ITEM_ADD_BITMAP: SaveCopyInUndoList(); idx = m_treePagelayout->GetSelectedItemIndex(); item = AddPageLayoutItem( WORKSHEET_DATAITEM::WS_BITMAP, idx ); if( item && InvokeDialogNewItem( this, item ) == wxID_CANCEL ) { RemoveLastCommandInUndoList(); pglayout.Remove( item ); RebuildDesignTree(); item = NULL; } if( item ) { // Put the new text in move mode: item->SetFlags( NEW_ITEM | LOCATE_STARTPOINT ); MoveItem( item ); } break; case ID_POPUP_ITEM_APPEND_PAGE_LAYOUT: cmd.SetId( ID_APPEND_DESCR_FILE ); wxPostEvent( this, cmd ); break; case ID_POPUP_ITEM_PLACE: item = GetScreen()->GetCurItem(); PlaceItem( item ); break; case ID_POPUP_ITEM_PLACE_CANCEL: if( m_canvas->IsMouseCaptured() ) m_canvas->EndMouseCapture(); break; case ID_POPUP_ITEM_MOVE_START_POINT: item = m_treePagelayout->GetPageLayoutSelectedItem(); // Ensure flags are properly set item->ClearFlags( LOCATE_ENDPOINT ); item->SetFlags( LOCATE_STARTPOINT ); MoveItem( item ); break; case ID_POPUP_ITEM_MOVE_END_POINT: item = m_treePagelayout->GetPageLayoutSelectedItem(); // Ensure flags are properly set item->ClearFlags( LOCATE_STARTPOINT ); item->SetFlags( LOCATE_ENDPOINT ); MoveItem( item ); break; case ID_POPUP_ITEM_MOVE: item = m_treePagelayout->GetPageLayoutSelectedItem(); item->ClearFlags( LOCATE_ENDPOINT|LOCATE_STARTPOINT ); MoveItem( item ); break; default: wxMessageBox( wxT( "PL_EDITOR_FRAME::Process_Special_Functions error" ) ); break; } if( item ) { OnModify(); m_propertiesPagelayout->CopyPrmsFromItemToPanel( item ); m_treePagelayout->SelectCell( item ); } }