void ChaosConnectFrm::CreateGUIControls() { /** * Creates all of the GUI controls on the main form. * * GUI layout consists of a menu bar and status bar on the main form * A wxFlexGrid sizer with one column is created to hold the controls * Four plots are then layed out in another wxFlexGridSizer so that * in the first row of the overall sizer. A horizontal wxBoxSizer is * then created for the bottom row so that we can add a stretchable * panel down there for additional controls. */ // Create sizer overallSizer = new wxFlexGridSizer(1); flexSizer = new wxFlexGridSizer(2, 2, 0, 0); bottomRowSizer = new wxBoxSizer(wxHORIZONTAL); panel5Sizer = new wxBoxSizer(wxHORIZONTAL); // Overall Sizer overallSizer->Add(flexSizer, 0, wxEXPAND | wxALL); overallSizer->AddGrowableRow(0); overallSizer->AddGrowableCol(0); // Make the Flex Sizer grow flexSizer->AddGrowableRow(0); flexSizer->AddGrowableRow(1); flexSizer->AddGrowableCol(0); flexSizer->AddGrowableCol(1); // Create 4 ChaosPanel displays display1 = new ChaosPanel(this, ID_DISPLAY1, wxPoint(0, 0), wxSize(200, 100), wxTAB_TRAVERSAL, wxT("display1"), ChaosPanel::CHAOS_XT); flexSizer->Add(display1,0,wxEXPAND | wxALL,0); display2 = new ChaosPanel(this, ID_DISPLAY2, wxPoint(200, 0), wxSize(200, 100), wxTAB_TRAVERSAL, wxT("display2"), ChaosPanel::CHAOS_XY); flexSizer->Add(display2,0,wxEXPAND | wxALL,0); display3 = new ChaosPanel(this, ID_DISPLAY3, wxPoint(0, 100), wxSize(200, 100), wxTAB_TRAVERSAL, wxT("display3"), ChaosPanel::CHAOS_BIFURCATION); flexSizer->Add(display3,0,wxEXPAND | wxALL,0); display4 = new ChaosPanel(this, ID_DISPLAY4, wxPoint(200, 100), wxSize(200, 100), wxTAB_TRAVERSAL, wxT("display4"), ChaosPanel::CHAOS_RETURN1); flexSizer->Add(display4,0,wxEXPAND | wxALL,0); // Sizer for the controls along the bottom display5 = new wxPanel(this, ID_DISPLAY5, wxPoint(200, 100), wxSize(200, 100), wxTAB_TRAVERSAL, wxT("display5")); overallSizer->Add(panel5Sizer, 0, wxEXPAND | wxALL); panel5Sizer->Add(display5, 1, wxEXPAND | wxALL); display5->SetSizer(bottomRowSizer); // Create pause button startStopButton = new wxButton(display5, ID_START_STOP_BTN, wxT("Pause")); // Settings to adjust how many bifurcation steps are taken stepsLabel = new wxStaticText(display5, wxID_ANY, wxT("Bifurcation Steps: ")); stepsSpinner = new wxSpinCtrl(display5, ID_STEPS_SPINNER, wxT("100"), wxDefaultPosition, wxSize(60, -1), wxSP_ARROW_KEYS, 0, 4095, 100); // Settings to adjust how many peaks are taken at each step peaksLabel = new wxStaticText(display5, wxID_ANY, wxT("Bifurcation Peaks: ")); peaksSpinner = new wxSpinCtrl(display5, ID_PEAKS_SPINNER, wxT("10"), wxDefaultPosition, wxSize(60, -1), wxSP_ARROW_KEYS, 0, 100, 10); // Buttons settingsApplyButton = new wxButton(display5, ID_SETTINGS_APPLY_BTN, wxT("Apply")); bifEraseButton = new wxButton(display5, ID_BIF_ERASE_BTN, wxT("Redraw Bifurcation")); bottomRowSizer->Add(stepsLabel, 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL | wxALL, 2); bottomRowSizer->Add(stepsSpinner, 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL | wxALL, 2); bottomRowSizer->Add(peaksLabel, 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL | wxALL, 2); bottomRowSizer->Add(peaksSpinner, 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL | wxALL, 2); bottomRowSizer->Add(settingsApplyButton, 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL | wxALL, 2); bottomRowSizer->Add(bifEraseButton, 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL | wxALL, 2); bottomRowSizer->AddStretchSpacer(1); bottomRowSizer->Add(startStopButton, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL | wxALL, 2); // Create status bar // Create fields statusBar = new wxStatusBar(this, ID_STATUSBAR); statusBar->SetFieldsCount(5); statusBar->SetStatusText(wxT("Connected: ?"),0); statusBar->SetStatusText(wxT("MDAC Value: ????"),1); statusBar->SetStatusText(wxT("Resistance: ????"),2); statusBar->SetStatusText(wxT("(X,Y)"),3); statusBar->SetStatusText(wxT("Updating"),4); // Set field sizes int statusBar_Widths[5]; statusBar_Widths[0] = 100; statusBar_Widths[1] = 100; statusBar_Widths[2] = 100; statusBar_Widths[3] = 150; statusBar_Widths[4] = -1; // Auto scale to the rest of the size statusBar->SetStatusWidths(5,statusBar_Widths); // Set status bar SetStatusBar(statusBar); // Create menu bar menuBar = new wxMenuBar(); // File menu wxMenu *fileMenu = new wxMenu(0); fileMenu->Append(ID_MNU_SAMPLE_TO_FILE, wxT("Sample To File..."), wxT(""), wxITEM_NORMAL); fileMenu->Append(ID_MNU_SETTINGS, wxT("Settings..."), wxT(""), wxITEM_NORMAL); fileMenu->Append(ID_MNU_SHOW_LOG, wxT("Show Log"), wxT(""), wxITEM_NORMAL); fileMenu->Append(ID_MNU_FILE_EXIT, wxT("Exit"), wxT(""), wxITEM_NORMAL); menuBar->Append(fileMenu, wxT("File")); // View menu wxMenu *viewMenu = new wxMenu(0); viewMenu->Append(ID_MNU_VIEW_FULLSCREEN, wxT("Fullscreen"), wxT(""), wxITEM_CHECK); viewMenu->Append(ID_MNU_VIEW_SPLITSCREEN, wxT("Split Screen"), wxT(""), wxITEM_CHECK); viewMenu->Append(ID_MNU_VIEW_QUADVIEW, wxT("Quad View"), wxT(""), wxITEM_CHECK); menuBar->Append(viewMenu, wxT("View")); menuBar->Check(ID_MNU_VIEW_FULLSCREEN, true); // Help menu wxMenu *helpMenu = new wxMenu(0); helpMenu->Append(ID_MNU_ABOUT, wxT("About"), wxT("")); menuBar->Append(helpMenu, wxT("Help")); SetMenuBar(menuBar); // Create timer timer1 = new wxTimer(); timer1->SetOwner(this, ID_TIMER1); timer1->Start(ChaosSettings::UpdatePeriod); // Set window properties and title bar SetTitle(wxT("ChaosConnect 1.0")); SetIcon(wxNullIcon); SetMinSize(wxSize(600,400)); // Set up the sizer this->SetSizer(overallSizer); this->SetAutoLayout(true); // Set fullscreen mode flexSizer->Show(display2, false, true); flexSizer->Show(display3, false, true); flexSizer->Show(display4, false, true); display1->Show(); flexSizer->Fit(this); // Adjust window size to min flexSizer->Layout(); // Layout items in the sizer Center(); // Give plots access to the status bar display1->setStatusBar(statusBar); display2->setStatusBar(statusBar); display3->setStatusBar(statusBar); display4->setStatusBar(statusBar); }
//~~ void DrawDiamond(wxDC& dc) [glRelation] ~~ glVector end = absGetStartPoint(); glVector endcenter = absCalculateCenterPoint() ; glVector diff = end - endcenter; glVector diff2 = diff.RotateDegree(40*30/diff.Mod()); glVector orto = diff.Dir(); orto *= 6; diff = diff.Rotate90Degree().Dir(); diff *= 10; glVector u = end + diff - orto; glVector v = end + diff + orto; glVector w = endcenter + diff2; wxPoint points[4] = { wxPoint(v.xCoord(),v.yCoord()), wxPoint(w.xCoord(),w.yCoord()), wxPoint(u.xCoord(),u.yCoord()), wxPoint(end.xCoord(),end.yCoord()) }; dc.DrawPolygon(4, points);
GridFrame::GridFrame() : wxFrame( (wxFrame *)NULL, wxID_ANY, _T("wxWidgets grid class demo"), wxDefaultPosition, wxDefaultSize ) { wxMenu *fileMenu = new wxMenu; fileMenu->Append( ID_VTABLE, _T("&Virtual table test\tCtrl-V")); fileMenu->Append( ID_BUGS_TABLE, _T("&Bugs table test\tCtrl-B")); fileMenu->Append( ID_SMALL_GRID, _T("&Small Grid test\tCtrl-S")); fileMenu->AppendSeparator(); fileMenu->Append( wxID_EXIT, _T("E&xit\tAlt-X") ); wxMenu *viewMenu = new wxMenu; viewMenu->Append( ID_TOGGLEROWLABELS, _T("&Row labels"), wxEmptyString, wxITEM_CHECK ); viewMenu->Append( ID_TOGGLECOLLABELS, _T("&Col labels"), wxEmptyString, wxITEM_CHECK ); viewMenu->Append( ID_TOGGLEEDIT, _T("&Editable"), wxEmptyString, wxITEM_CHECK ); viewMenu->Append( ID_TOGGLEROWSIZING, _T("Ro&w drag-resize"), wxEmptyString, wxITEM_CHECK ); viewMenu->Append( ID_TOGGLECOLSIZING, _T("C&ol drag-resize"), wxEmptyString, wxITEM_CHECK ); viewMenu->Append( ID_TOGGLEGRIDSIZING, _T("&Grid drag-resize"), wxEmptyString, wxITEM_CHECK ); viewMenu->Append( ID_TOGGLEGRIDDRAGCELL, _T("&Grid drag-cell"), wxEmptyString, wxITEM_CHECK ); viewMenu->Append( ID_TOGGLEGRIDLINES, _T("&Grid Lines"), wxEmptyString, wxITEM_CHECK ); viewMenu->Append( ID_SET_HIGHLIGHT_WIDTH, _T("&Set Cell Highlight Width...") ); viewMenu->Append( ID_SET_RO_HIGHLIGHT_WIDTH, _T("&Set Cell RO Highlight Width...") ); viewMenu->Append( ID_AUTOSIZECOLS, _T("&Auto-size cols") ); viewMenu->Append( ID_CELLOVERFLOW, _T("&Overflow cells"), wxEmptyString, wxITEM_CHECK ); viewMenu->Append( ID_RESIZECELL, _T("&Resize cell (7,1)"), wxEmptyString, wxITEM_CHECK ); wxMenu *rowLabelMenu = new wxMenu; viewMenu->Append( ID_ROWLABELALIGN, _T("R&ow label alignment"), rowLabelMenu, _T("Change alignment of row labels") ); rowLabelMenu->Append( ID_ROWLABELHORIZALIGN, _T("&Horizontal") ); rowLabelMenu->Append( ID_ROWLABELVERTALIGN, _T("&Vertical") ); wxMenu *colLabelMenu = new wxMenu; viewMenu->Append( ID_COLLABELALIGN, _T("Col l&abel alignment"), colLabelMenu, _T("Change alignment of col labels") ); colLabelMenu->Append( ID_COLLABELHORIZALIGN, _T("&Horizontal") ); colLabelMenu->Append( ID_COLLABELVERTALIGN, _T("&Vertical") ); wxMenu *colMenu = new wxMenu; colMenu->Append( ID_SETLABELCOLOUR, _T("Set &label colour...") ); colMenu->Append( ID_SETLABELTEXTCOLOUR, _T("Set label &text colour...") ); colMenu->Append( ID_SETLABEL_FONT, _T("Set label fo&nt...") ); colMenu->Append( ID_GRIDLINECOLOUR, _T("&Grid line colour...") ); colMenu->Append( ID_SET_CELL_FG_COLOUR, _T("Set cell &foreground colour...") ); colMenu->Append( ID_SET_CELL_BG_COLOUR, _T("Set cell &background colour...") ); wxMenu *editMenu = new wxMenu; editMenu->Append( ID_INSERTROW, _T("Insert &row") ); editMenu->Append( ID_INSERTCOL, _T("Insert &column") ); editMenu->Append( ID_DELETEROW, _T("Delete selected ro&ws") ); editMenu->Append( ID_DELETECOL, _T("Delete selected co&ls") ); editMenu->Append( ID_CLEARGRID, _T("Cl&ear grid cell contents") ); wxMenu *selectMenu = new wxMenu; selectMenu->Append( ID_SELECT_UNSELECT, _T("Add new cells to the selection"), _T("When off, old selection is deselected before ") _T("selecting the new cells"), wxITEM_CHECK ); selectMenu->Append( ID_SELECT_ALL, _T("Select all")); selectMenu->Append( ID_SELECT_ROW, _T("Select row 2")); selectMenu->Append( ID_SELECT_COL, _T("Select col 2")); selectMenu->Append( ID_SELECT_CELL, _T("Select cell (3, 1)")); selectMenu->Append( ID_DESELECT_ALL, _T("Deselect all")); selectMenu->Append( ID_DESELECT_ROW, _T("Deselect row 2")); selectMenu->Append( ID_DESELECT_COL, _T("Deselect col 2")); selectMenu->Append( ID_DESELECT_CELL, _T("Deselect cell (3, 1)")); wxMenu *selectionMenu = new wxMenu; selectMenu->Append( ID_CHANGESEL, _T("Change &selection mode"), selectionMenu, _T("Change selection mode") ); selectionMenu->Append( ID_SELCELLS, _T("Select &Cells") ); selectionMenu->Append( ID_SELROWS, _T("Select &Rows") ); selectionMenu->Append( ID_SELCOLS, _T("Select C&ols") ); wxMenu *helpMenu = new wxMenu; helpMenu->Append( wxID_ABOUT, _T("&About wxGrid demo") ); wxMenuBar *menuBar = new wxMenuBar; menuBar->Append( fileMenu, _T("&File") ); menuBar->Append( viewMenu, _T("&View") ); menuBar->Append( colMenu, _T("&Colours") ); menuBar->Append( editMenu, _T("&Edit") ); menuBar->Append( selectMenu, _T("&Select") ); menuBar->Append( helpMenu, _T("&Help") ); SetMenuBar( menuBar ); m_addToSel = false; grid = new wxGrid( this, wxID_ANY, wxPoint( 0, 0 ), wxSize( 400, 300 ) ); #if wxUSE_LOG int gridW = 600, gridH = 300; int logW = gridW, logH = 100; logWin = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxPoint( 0, gridH + 20 ), wxSize( logW, logH ), wxTE_MULTILINE ); logger = new wxLogTextCtrl( logWin ); m_logOld = wxLog::SetActiveTarget( logger ); wxLog::SetTimestamp( NULL ); #endif // wxUSE_LOG // this will create a grid and, by default, an associated grid // table for strings grid->CreateGrid( 0, 0 ); grid->AppendRows(100); grid->AppendCols(100); int ir = grid->GetNumberRows(); grid->DeleteRows(0, ir); grid->AppendRows(ir); grid->SetRowSize( 0, 60 ); grid->SetCellValue( 0, 0, _T("Ctrl+Home\nwill go to\nthis cell") ); grid->SetCellValue( 0, 1, _T("A long piece of text to demonstrate wrapping.") ); grid->SetCellRenderer(0 , 1, new wxGridCellAutoWrapStringRenderer); grid->SetCellEditor( 0, 1 , new wxGridCellAutoWrapStringEditor); grid->SetCellValue( 0, 2, _T("Blah") ); grid->SetCellValue( 0, 3, _T("Read only") ); grid->SetReadOnly( 0, 3 ); grid->SetCellValue( 0, 4, _T("Can veto edit this cell") ); grid->SetCellValue( 0, 5, _T("Press\nCtrl+arrow\nto skip over\ncells") ); grid->SetRowSize( 99, 60 ); grid->SetCellValue( 99, 99, _T("Ctrl+End\nwill go to\nthis cell") ); grid->SetCellValue( 1, 0, _T("This default cell will overflow into neighboring cells, but not if you turn overflow off.")); grid->SetCellTextColour(1, 2, *wxRED); grid->SetCellBackgroundColour(1, 2, *wxGREEN); grid->SetCellValue( 1, 4, _T("I'm in the middle")); grid->SetCellValue(2, 2, _T("red")); grid->SetCellTextColour(2, 2, *wxRED); grid->SetCellValue(3, 3, _T("green on grey")); grid->SetCellTextColour(3, 3, *wxGREEN); grid->SetCellBackgroundColour(3, 3, *wxLIGHT_GREY); grid->SetCellValue(4, 4, _T("a weird looking cell")); grid->SetCellAlignment(4, 4, wxALIGN_CENTRE, wxALIGN_CENTRE); grid->SetCellRenderer(4, 4, new MyGridCellRenderer); grid->SetCellValue(3, 0, _T("0")); grid->SetCellRenderer(3, 0, new wxGridCellBoolRenderer); grid->SetCellEditor(3, 0, new wxGridCellBoolEditor); wxGridCellAttr *attr; attr = new wxGridCellAttr; attr->SetTextColour(*wxBLUE); grid->SetColAttr(5, attr); attr = new wxGridCellAttr; attr->SetBackgroundColour(*wxRED); grid->SetRowAttr(5, attr); grid->SetCellValue(2, 4, _T("a wider column")); grid->SetColSize(4, 120); grid->SetColMinimalWidth(4, 120); grid->SetCellTextColour(5, 8, *wxGREEN); grid->SetCellValue(5, 8, _T("Bg from row attr\nText col from cell attr")); grid->SetCellValue(5, 5, _T("Bg from row attr Text col from col attr and this text is so long that it covers over many many empty cells but is broken by one that isn't")); grid->SetColFormatFloat(6); grid->SetCellValue(0, 6, _T("3.1415")); grid->SetCellValue(1, 6, _T("1415")); grid->SetCellValue(2, 6, _T("12345.67890")); grid->SetColFormatFloat(7, 6, 2); grid->SetCellValue(0, 7, _T("3.1415")); grid->SetCellValue(1, 7, _T("1415")); grid->SetCellValue(2, 7, _T("12345.67890")); const wxString choices[] = { _T("Please select a choice"), _T("This takes two cells"), _T("Another choice"), }; grid->SetCellEditor(4, 0, new wxGridCellChoiceEditor(WXSIZEOF(choices), choices)); grid->SetCellSize(4, 0, 1, 2); grid->SetCellValue(4, 0, choices[0]); grid->SetCellOverflow(4, 0, false); grid->SetCellSize(7, 1, 3, 4); grid->SetCellAlignment(7, 1, wxALIGN_CENTRE, wxALIGN_CENTRE); grid->SetCellValue(7, 1, _T("Big box!")); wxBoxSizer *topSizer = new wxBoxSizer( wxVERTICAL ); topSizer->Add( grid, 1, wxEXPAND ); #if wxUSE_LOG topSizer->Add( logWin, 0, wxEXPAND ); #endif // wxUSE_LOG SetAutoLayout(true); SetSizer( topSizer ); topSizer->Fit( this ); Centre(); SetDefaults(); }
bool wxRibbonPanel::ShowExpanded() { if(!IsMinimised()) { return false; } if(m_expanded_dummy != NULL || m_expanded_panel != NULL) { return false; } wxSize size = GetBestSize(); // Special case for flexible panel layout, where GetBestSize doesn't work if (GetFlags() & wxRIBBON_PANEL_FLEXIBLE) { size = GetBestSizeForParentSize(wxSize(400, 1000)); } wxPoint pos = GetExpandedPosition(wxRect(GetScreenPosition(), GetSize()), size, m_preferred_expand_direction).GetTopLeft(); // Need a top-level frame to contain the expanded panel wxFrame *container = new wxFrame(NULL, wxID_ANY, GetLabel(), pos, size, wxFRAME_NO_TASKBAR | wxBORDER_NONE); m_expanded_panel = new wxRibbonPanel(container, wxID_ANY, GetLabel(), m_minimised_icon, wxPoint(0, 0), size, (m_flags /* & ~wxRIBBON_PANEL_FLEXIBLE */)); m_expanded_panel->SetArtProvider(m_art); m_expanded_panel->m_expanded_dummy = this; // Move all children to the new panel. // Conceptually it might be simpler to reparent this entire panel to the // container and create a new panel to sit in its place while expanded. // This approach has a problem though - when the panel is reinserted into // its original parent, it'll be at a different position in the child list // and thus assume a new position. // NB: Children iterators not used as behaviour is not well defined // when iterating over a container which is being emptied while(!GetChildren().IsEmpty()) { wxWindow *child = GetChildren().GetFirst()->GetData(); child->Reparent(m_expanded_panel); child->Show(); } // Move sizer to new panel if(GetSizer()) { wxSizer* sizer = GetSizer(); SetSizer(NULL, false); m_expanded_panel->SetSizer(sizer); } m_expanded_panel->Realize(); Refresh(); container->SetMinClientSize(size); container->Show(); m_expanded_panel->SetFocus(); return true; }
/* This function is used by Retrace and read the autorouting matrix data cells to create * the real track on the physical board */ static void OrCell_Trace( BOARD* pcb, int col, int row, int side, int orient, int current_net_code ) { int dx0, dy0, dx1, dy1; TRACK* newTrack; if( orient == HOLE ) // placement of a via { newTrack = new SEGVIA( pcb ); g_CurrentTrackList.PushBack( newTrack ); g_CurrentTrackSegment->SetState( TRACK_AR, true ); g_CurrentTrackSegment->SetLayer( 0x0F ); g_CurrentTrackSegment->SetStart(wxPoint( pcb->GetBoundingBox().GetX() + ( RoutingMatrix.m_GridRouting * row ), pcb->GetBoundingBox().GetY() + ( RoutingMatrix.m_GridRouting * col ))); g_CurrentTrackSegment->SetEnd( g_CurrentTrackSegment->GetStart() ); g_CurrentTrackSegment->SetWidth( pcb->GetCurrentViaSize() ); g_CurrentTrackSegment->SetShape( pcb->GetDesignSettings().m_CurrentViaType ); g_CurrentTrackSegment->SetNet( current_net_code ); } else // placement of a standard segment { newTrack = new TRACK( pcb ); g_CurrentTrackList.PushBack( newTrack ); g_CurrentTrackSegment->SetLayer( g_Route_Layer_BOTTOM ); if( side == TOP ) g_CurrentTrackSegment->SetLayer( g_Route_Layer_TOP ); g_CurrentTrackSegment->SetState( TRACK_AR, true ); g_CurrentTrackSegment->SetEnd( wxPoint( pcb->GetBoundingBox().GetX() + ( RoutingMatrix.m_GridRouting * row ), pcb->GetBoundingBox().GetY() + ( RoutingMatrix.m_GridRouting * col ))); g_CurrentTrackSegment->SetNet( current_net_code ); if( g_CurrentTrackSegment->Back() == NULL ) /* Start trace. */ { g_CurrentTrackSegment->SetStart( wxPoint( segm_fX, segm_fY ) ); /* Placement on the center of the pad if outside grid. */ dx1 = g_CurrentTrackSegment->GetEnd().x - g_CurrentTrackSegment->GetStart().x; dy1 = g_CurrentTrackSegment->GetEnd().y - g_CurrentTrackSegment->GetStart().y; dx0 = pt_cur_ch->m_PadEnd->GetPosition().x - g_CurrentTrackSegment->GetStart().x; dy0 = pt_cur_ch->m_PadEnd->GetPosition().y - g_CurrentTrackSegment->GetStart().y; /* If aligned, change the origin point. */ if( abs( dx0 * dy1 ) == abs( dx1 * dy0 ) ) { g_CurrentTrackSegment->SetStart( pt_cur_ch->m_PadEnd->GetPosition() ); } else // Creation of a supplemental segment { g_CurrentTrackSegment->SetStart( pt_cur_ch->m_PadEnd->GetPosition() ); newTrack = (TRACK*)g_CurrentTrackSegment->Clone(); newTrack->SetStart( g_CurrentTrackSegment->GetEnd()); g_CurrentTrackList.PushBack( newTrack ); } } else { if( g_CurrentTrackSegment->Back() ) { g_CurrentTrackSegment->SetStart( g_CurrentTrackSegment->Back()->GetEnd() ); } } g_CurrentTrackSegment->SetWidth( pcb->GetCurrentTrackWidth() ); if( g_CurrentTrackSegment->GetStart() != g_CurrentTrackSegment->GetEnd() ) { /* Reduce aligned segments by one. */ TRACK* oldTrack = g_CurrentTrackSegment->Back(); if( oldTrack && oldTrack->Type() != PCB_VIA_T ) { dx1 = g_CurrentTrackSegment->GetEnd().x - g_CurrentTrackSegment->GetStart().x; dy1 = g_CurrentTrackSegment->GetEnd().y - g_CurrentTrackSegment->GetStart().y; dx0 = oldTrack->GetEnd().x - oldTrack->GetStart().x; dy0 = oldTrack->GetEnd().y - oldTrack->GetStart().y; if( abs( dx0 * dy1 ) == abs( dx1 * dy0 ) ) { oldTrack->SetEnd( g_CurrentTrackSegment->GetEnd() ); delete g_CurrentTrackList.PopBack(); } } } } }
MODULE* PCB_EDIT_FRAME::Create_MuWaveComponent( int shape_type ) { int oX; D_PAD* pad; MODULE* module; wxString msg, cmp_name; int pad_count = 2; int angle = 0; // Enter the size of the gap or stub int gap_size = GetBoard()->GetCurrentTrackWidth(); switch( shape_type ) { case 0: msg = _( "Gap" ); cmp_name = wxT( "GAP" ); break; case 1: msg = _( "Stub" ); cmp_name = wxT( "STUB" ); pad_count = 2; break; case 2: msg = _( "Arc Stub" ); cmp_name = wxT( "ASTUB" ); pad_count = 1; break; default: msg = wxT( "???" ); break; } wxString value = StringFromValue( g_UserUnit, gap_size ); wxTextEntryDialog dlg( this, msg, _( "Create microwave module" ), value ); if( dlg.ShowModal() != wxID_OK ) { m_canvas->MoveCursorToCrossHair(); return NULL; // cancelled by user } value = dlg.GetValue(); gap_size = ValueFromString( g_UserUnit, value ); bool abort = false; if( shape_type == 2 ) { double fcoeff = 10.0, fval; msg.Printf( wxT( "%3.1f" ), angle / fcoeff ); wxTextEntryDialog angledlg( this, _( "Angle (0.1deg):" ), _( "Create microwave module" ), msg ); if( angledlg.ShowModal() != wxID_OK ) { m_canvas->MoveCursorToCrossHair(); return NULL; // cancelled by user } msg = angledlg.GetValue(); if( !msg.ToDouble( &fval ) ) { DisplayError( this, _( "Incorrect number, abort" ) ); abort = true; } angle = std::abs( KiROUND( fval * fcoeff ) ); if( angle > 1800 ) angle = 1800; } if( abort ) { m_canvas->MoveCursorToCrossHair(); return NULL; } module = Create_MuWaveBasicShape( cmp_name, pad_count ); pad = module->Pads(); switch( shape_type ) { case 0: //Gap : oX = -( gap_size + pad->GetSize().x ) / 2; pad->SetX0( oX ); pad->SetX( pad->GetPos0().x + pad->GetPosition().x ); pad = pad->Next(); pad->SetX0( oX + gap_size + pad->GetSize().x ); pad->SetX( pad->GetPos0().x + pad->GetPosition().x ); break; case 1: //Stub : pad->SetPadName( wxT( "1" ) ); pad = pad->Next(); pad->SetY0( -( gap_size + pad->GetSize().y ) / 2 ); pad->SetSize( wxSize( pad->GetSize().x, gap_size ) ); pad->SetY( pad->GetPos0().y + pad->GetPosition().y ); break; case 2: // Arc Stub created by a polygonal approach: { EDGE_MODULE* edge = new EDGE_MODULE( module ); module->GraphicalItems().PushFront( edge ); edge->SetShape( S_POLYGON ); edge->SetLayer( LAYER_N_FRONT ); int numPoints = angle / 50 + 3; // Note: angles are in 0.1 degrees std::vector<wxPoint> polyPoints = edge->GetPolyPoints(); polyPoints.reserve( numPoints ); edge->m_Start0.y = -pad->GetSize().y / 2; polyPoints.push_back( wxPoint( 0, 0 ) ); int theta = -angle / 2; for( int ii = 1; ii<numPoints - 1; ii++ ) { wxPoint pt( 0, -gap_size ); RotatePoint( &pt.x, &pt.y, theta ); polyPoints.push_back( pt ); theta += 50; if( theta > angle / 2 ) theta = angle / 2; } // Close the polygon: polyPoints.push_back( polyPoints[0] ); } break; default: break; } module->CalculateBoundingBox(); GetBoard()->m_Status_Pcb = 0; OnModify(); return module; }
void DIALOG_SET_GRID::OnResetGridOrgClick( wxCommandEvent& event ) { setGridOrigin( wxPoint( 0, 0 ) ); }
bool OnInit() { #if DEBUG wxLogWarning("MODO DEBUG"); #else wxSetAssertHandler(NULL); #endif //i18n/l10n: //20120603: Change suggested by Juan Pizarro to solve the i18n bug in some Windows and Linux machines: //if ( !locale.Init(wxLANGUAGE_DEFAULT, wxLOCALE_CONV_ENCODING) ) #if !defined(linux) wxLogWarning("Esta version esta desarrollada exclusivamente para Linux"); return true; #endif /* #if defined (linux) wxLogNull logNo; #endif */ /* if ( !locale.Init(wxLANGUAGE_ENGLISH, wxLOCALE_CONV_ENCODING) ) wxLogWarning(_("Error #1: This language is not supported by the system.")); */ /* wxString lanPath(wxStandardPaths::Get().GetExecutablePath().BeforeLast(wxFileName::GetPathSeparator()) + wxFileName::GetPathSeparator() + wxString("GUI") + wxFileName::GetPathSeparator() + wxString("Texts") //##Unhardcode this in the future? I'm not sure... ); */ //wxString lanPath = wxStandardPaths::Get().GetExecutablePath().BeforeLast(wxFileName::GetPathSeparator()) + "/../../GUI/Texts/"; //wxLocale::AddCatalogLookupPathPrefix(lanPath); wxString lanPath = "/usr/share"; locale.AddCatalogLookupPathPrefix(lanPath); //Por defecto debe levantar en Castellano //wxString initialCatalogName("es.mo"); wxString initialCatalogName = "Minibloq.mo"; //wxString initialCatalogName("es.mo"); //##Debug... if (!locale.AddCatalog(initialCatalogName)) { //##Future: See if future wxLocale implementations solve this problem: wxLogWarning( _("Error #1: The installation path\n\n\"") + wxStandardPaths::Get().GetExecutablePath() + _("\"\n\ncontains non-English chars.\n") + _("Please try to install Minibloq on a location without this kind of chars. ") + _("Otherwise, the program will run, but the translation system will not work properly.") ); //wxLogWarning(_("Error #2: Can't load ") + initialCatalogName); printf("NO ENCUENTRO EL CATALOGO\n"); } MainFrame* frame = NULL; wxString caption = wxString(wxString("miniBloq ") + MINIBLOQ_VERSION); wxPoint framePosition = wxDefaultPosition; wxSize frameSize = wxDefaultSize; long style = wxDEFAULT_FRAME_STYLE; //Default values: initialFrameX = 0; initialFrameY = 0; initialFrameHeight = 600; initialFrameWidth = 800; maximized = true; centered = true; strBoard = wxString(""); //Try to read the configuration file: readConfig(); //Priorities: // maximized has priority over all the other pos and size settings. // centered has priority over x and y settings. if (maximized) style = style | wxMAXIMIZE; if ( (initialFrameWidth > 0) && (initialFrameHeight > 0) ) { framePosition = wxPoint(initialFrameX, initialFrameY); frameSize = wxSize(initialFrameWidth, initialFrameHeight); } //TODO: Chequeo de errores wxString execPath = wxStandardPaths::Get().GetExecutablePath().BeforeLast(wxFileName::GetPathSeparator()); wxString splashImg = execPath + "/../../GUI/Images/minibloqSplash.png"; wxBitmap splashPng; splashPng.LoadFile(splashImg); wxSplashScreen* splash = new wxSplashScreen(splashPng, wxSPLASH_CENTRE_ON_SCREEN|wxSPLASH_TIMEOUT, 3000, NULL, -1, wxDefaultPosition, wxDefaultSize, wxBORDER_SIMPLE|wxSTAY_ON_TOP); wxYield(); frame = new MainFrame( NULL, wxID_ANY, locale, lanPath, initialCatalogName, caption, strBoard, framePosition, frameSize, style ); /*## Future: Full screen: wxFrame* frame = new MainFrame(NULL, wxID_ANY, wxString("Minibloq v1.0"), wxDefaultPosition, wxSize(1280, 800), wxCLIP_CHILDREN); */ if (frame) { if (centered) frame->Centre(); frame->setCentered(centered); SetTopWindow(frame); frame->Show(); if (maximized) { frame->Maximize(); } if (argc > 0) { wxString fileName = argv[1]; if (wxFile::Exists(fileName)) { frame->loadFileComponent(fileName); } } } return true; }
void PlotLayerOutlines( BOARD *aBoard, PLOTTER* aPlotter, LAYER_MSK aLayerMask, const PCB_PLOT_PARAMS& aPlotOpt ) { BRDITEMS_PLOTTER itemplotter( aPlotter, aBoard, aPlotOpt ); itemplotter.SetLayerMask( aLayerMask ); CPOLYGONS_LIST outlines; for( LAYER_NUM layer = FIRST_LAYER; layer < NB_PCB_LAYERS; layer++ ) { LAYER_MSK layer_mask = GetLayerMask( layer ); if( (aLayerMask & layer_mask ) == 0 ) continue; outlines.RemoveAllContours(); aBoard->ConvertBrdLayerToPolygonalContours( layer, outlines ); // Merge all overlapping polygons. KI_POLYGON_SET kpolygons; KI_POLYGON_SET ktmp; outlines.ExportTo( ktmp ); kpolygons += ktmp; // Plot outlines std::vector< wxPoint > cornerList; for( unsigned ii = 0; ii < kpolygons.size(); ii++ ) { KI_POLYGON polygon = kpolygons[ii]; // polygon contains only one polygon, but it can have holes linked by // overlapping segments. // To plot clean outlines, we have to break this polygon into more polygons with // no overlapping segments, using Clipper, because boost::polygon // does not allow that ClipperLib::Path raw_polygon; ClipperLib::Paths normalized_polygons; for( unsigned ic = 0; ic < polygon.size(); ic++ ) { KI_POLY_POINT corner = *(polygon.begin() + ic); raw_polygon.push_back( ClipperLib::IntPoint( corner.x(), corner.y() ) ); } ClipperLib::SimplifyPolygon( raw_polygon, normalized_polygons ); // Now we have one or more basic polygons: plot each polygon for( unsigned ii = 0; ii < normalized_polygons.size(); ii++ ) { ClipperLib::Path& polygon = normalized_polygons[ii]; cornerList.clear(); for( unsigned jj = 0; jj < polygon.size(); jj++ ) cornerList.push_back( wxPoint( polygon[jj].X , polygon[jj].Y ) ); // Ensure the polygon is closed if( cornerList[0] != cornerList[cornerList.size()-1] ) cornerList.push_back( cornerList[0] ); aPlotter->PlotPoly( cornerList, NO_FILL ); } } // Plot pad holes if( aPlotOpt.GetDrillMarksType() != PCB_PLOT_PARAMS::NO_DRILL_SHAPE ) { for( MODULE* module = aBoard->m_Modules; module; module = module->Next() ) { for( D_PAD* pad = module->Pads(); pad; pad = pad->Next() ) { wxSize hole = pad->GetDrillSize(); if( hole.x == 0 || hole.y == 0 ) continue; if( hole.x == hole.y ) aPlotter->Circle( pad->GetPosition(), hole.x, NO_FILL ); else { wxPoint drl_start, drl_end; int width; pad->GetOblongDrillGeometry( drl_start, drl_end, width ); aPlotter->ThickSegment( pad->GetPosition() + drl_start, pad->GetPosition() + drl_end, width, SKETCH ); } } } } // Plot vias holes for( TRACK* track = aBoard->m_Track; track; track = track->Next() ) { const VIA* via = dyn_cast<const VIA*>( track ); if( via && via->IsOnLayer( layer ) ) // via holes can be not through holes { aPlotter->Circle( via->GetPosition(), via->GetDrillValue(), NO_FILL ); } } } }
void timedMessageBoxNoModal(int whichIcon, const wxString& message, const wxString& caption, unsigned int delay, // miliseconds long style, const int x, const int y) { wxWindow* parent = getParent(whichIcon); s_timedMessageBox = new TimedMessageBox(whichIcon, parent, message, caption, delay, style, wxPoint(x, y)); s_timedMessageBox->Show(true); }
void mutelistWindow(const wxString& message, const wxString& caption, long style, const int x, const int y) { wxWindow* parent = getParent(SL_MAIN_ICON); wxIcon icon = getIcon(SL_MAIN_ICON); if (s_mutelistWindow != 0 && s_mutelistWindow->IsShown()) { s_mutelistWindow->AppendMessage(message); } else { s_mutelistWindow = new MutelistWindow(&icon, parent, wxEmptyString, caption, style, wxPoint(x, y)); s_mutelistWindow->AppendMessage(message); s_mutelistWindow->Show(true); } }
Frame::Frame(const wxString& title, const wxPoint& pos, const wxSize& size) : wxFrame(NULL, wxID_ANY, title, pos, size) { //Read the url for the api from the API_URL file char url[256]; bool fileread = false; FILE * file = fopen("API_URL", "r"); if (file != NULL){ if (fgets(url, 256, file) != NULL){ int i = 0; while (i < 256 && url[i] != '\0'){ if (url[i] == '\n' || url[i] == '\r' || url[i] == ' '){ url[i] = '\0'; break; } else i++; } fileread = true; } else { fileread = false; } fclose(file); } if (fileread) server_com = new ServerCommunication(url); else server_com = new ServerCommunication("http://se.putman.pw/api.php"); //Create the menu bar for the login screen wxMenu *menuFile_login = new wxMenu; //The login File menu menuFile_login->Append(wxID_EXIT); menubar_login = new wxMenuBar(); menubar_login->Append(menuFile_login, "&File"); SetMenuBar(menubar_login); //Create the menu bar for the overview screen wxMenu *menuFile_overview = new wxMenu; //The overview File menu menuFile_overview->Append(ID_EXPORT, wxT("&Export")); menuFile_overview->Append(ID_LOGOUT, wxT("&Logout")); menuFile_overview->Append(wxID_EXIT); wxMenu *menuNew = new wxMenu; menuNew->Append(ID_NEW_COURSE, wxT("New course")); menuNew->Append(ID_NEW_CURRICULUM, wxT("New study program")); menuNew->Append(ID_NEW_YEAR, wxT("New year")); wxMenu *menuDelete = new wxMenu; menuDelete->Append(ID_DELETE_YEAR, wxT("Delete year")); menuDelete->Append(ID_DELETE_CURRICULUM, wxT("Delete study program")); menuDelete->Append(ID_RESET, wxT("Delete all")); menubar_overview = new wxMenuBar(); menubar_overview->Append(menuFile_overview, "&File"); menubar_overview->Append(menuNew, "&New"); menubar_overview->Append(menuDelete, "&Delete"); CreateStatusBar(1); SetStatusText(""); //Create the error message that is displayed on a failed login attempt GetStatusBar()->SetForegroundColour(wxColour(wxT("RED"))); failed_login_txt = new wxStaticText(GetStatusBar(), wxID_ANY,wxT("Login failed: incorrect username and/or password"), wxPoint(3, 5), wxDefaultSize, 0 ); failed_login_txt->Show(false); GetStatusBar()->SetForegroundColour(wxColour(wxT("BLACK"))); if (!fileread){ failed_login_txt->SetLabel("Error reading API_URL, using the default url instead"); failed_login_txt->Show(true); } //Create the program title bar at the top of the screen wxPanel *title_panel = new wxPanel(this); title_panel->SetBackgroundColour(wxColour(0xFF,0x55,0x33)); wxStaticText *program_title_text = new wxStaticText(title_panel, wxID_ANY, "Curriculum Builder", wxPoint(10,10), wxSize(100,60) ); wxFont font = program_title_text->GetFont(); font.Scale(4); program_title_text->SetFont(font); program_title_text->SetForegroundColour(wxColour(wxT("WHITE"))); wxStaticBoxSizer *program_title = new wxStaticBoxSizer(wxHORIZONTAL,this,""); program_title->Add(title_panel, 1, wxEXPAND); //Create the bar at the bottom of the screen wxPanel *info_panel = new wxPanel(this); info_panel->SetBackgroundColour(wxColour(0xB6,0xB6,0xB6)); wxStaticText *group_info_text = new wxStaticText(info_panel, wxID_ANY, L"\u00a9 2014 Genius@Work\nPowered by Group8", wxPoint(1,1), wxSize(100, 20)); font = group_info_text->GetFont(); font.SetWeight(wxFONTWEIGHT_BOLD); group_info_text->SetFont(font); group_info_text->SetForegroundColour(wxColour(wxT("WHITE"))); wxStaticBoxSizer *group_info = new wxStaticBoxSizer(wxHORIZONTAL,this,""); group_info->Add(info_panel, 1, wxEXPAND); //Initiate the login and overview panels panel_login = new Login(this, 300, 400, 200, 300); panel_overview = new Overview(this, 50, 50, 1000, 800); panel_overview->Hide(); //Arrangement of panels and bars onscreen. wxBoxSizer *panels = new wxBoxSizer(wxVERTICAL); panels->Add(program_title, 0, wxEXPAND | wxALIGN_LEFT); panels->Add(panel_login, 1, wxEXPAND); panels->Add(panel_overview, 1, wxEXPAND); panels->Add(group_info, 0, wxEXPAND); SetSizer(panels); }//Frame
// Construtor of Dialog Dialog::Dialog() : wxDialog(NULL, // Parent wxID_ANY, // ID _T("OnePad configuration"), // Title wxDefaultPosition, // Position wxSize(DEFAULT_WIDTH, DEFAULT_HEIGHT), // Width + Length // Style wxSYSTEM_MENU | wxCAPTION | wxCLOSE_BOX | wxCLIP_CHILDREN) { /* * Define the size and the position of each button : * padding[ButtonID][0] : Width * padding[ButtonID][1] : Height * padding[ButtonID][2] : x position * padding[ButtonID][3] : y position */ int padding[BUTTONS_LENGTH][4]; // L1 padding[PAD_L1][0] = 218; // Width padding[PAD_L1][1] = 28; // Height padding[PAD_L1][2] = 50; // X padding[PAD_L1][3] = 175; // Y // L2 padding[PAD_L2][0] = 218; // Width padding[PAD_L2][1] = 28; // Height padding[PAD_L2][2] = 50; // X padding[PAD_L2][3] = 104; // Y // R1 padding[PAD_R1][0] = 218; // Width padding[PAD_R1][1] = 28; // Height padding[PAD_R1][2] = 726; // X padding[PAD_R1][3] = 175; // Y // R2 padding[PAD_R2][0] = 218; // Width padding[PAD_R2][1] = 28; // Height padding[PAD_R2][2] = 726; // X padding[PAD_R2][3] = 104; // Y // Triangle padding[PAD_TRIANGLE][0] = 218; // Width padding[PAD_TRIANGLE][1] = 28; // Height padding[PAD_TRIANGLE][2] = 726; // X padding[PAD_TRIANGLE][3] = 246; // Y // Circle padding[PAD_CIRCLE][0] = 218; // Width padding[PAD_CIRCLE][1] = 28; // Height padding[PAD_CIRCLE][2] = 726; // X padding[PAD_CIRCLE][3] = 319; // Y // Cross padding[PAD_CROSS][0] = 218; // Width padding[PAD_CROSS][1] = 28; // Height padding[PAD_CROSS][2] = 726; // X padding[PAD_CROSS][3] = 391; // Y // Square padding[PAD_SQUARE][0] = 218; // Width padding[PAD_SQUARE][1] = 28; // Height padding[PAD_SQUARE][2] = 726; // X padding[PAD_SQUARE][3] = 463; // Y // Directional pad up padding[PAD_UP][0] = 100; // Width padding[PAD_UP][1] = 25; // Height padding[PAD_UP][2] = 108; // X padding[PAD_UP][3] = 290; // Y // Directional pad down padding[PAD_DOWN][0] = 100; // Width padding[PAD_DOWN][1] = 25; // Height padding[PAD_DOWN][2] = 108; // X padding[PAD_DOWN][3] = 340; // Y // Directional pad right padding[PAD_RIGHT][0] = 109; // Width padding[PAD_RIGHT][1] = 25; // Height padding[PAD_RIGHT][2] = 159; // X padding[PAD_RIGHT][3] = 315; // Y // Directional pad left padding[PAD_LEFT][0] = 109; // Width padding[PAD_LEFT][1] = 25; // Height padding[PAD_LEFT][2] = 50; // X padding[PAD_LEFT][3] = 315; // Y // Left Joystick up padding[PAD_L_UP][0] = 100; // Width padding[PAD_L_UP][1] = 25; // Height padding[PAD_L_UP][2] = 325; // X padding[PAD_L_UP][3] = 527; // Y // Left Joystick down padding[PAD_L_DOWN][0] = 100; // Width padding[PAD_L_DOWN][1] = 25; // Height padding[PAD_L_DOWN][2] = 325; // X padding[PAD_L_DOWN][3] = 577; // Y // Left Joystick right padding[PAD_L_RIGHT][0] = 109; // Width padding[PAD_L_RIGHT][1] = 25; // Height padding[PAD_L_RIGHT][2] = 377; // X padding[PAD_L_RIGHT][3] = 552; // Y // Left Joystick left padding[PAD_L_LEFT][0] = 109; // Width padding[PAD_L_LEFT][1] = 25; // Height padding[PAD_L_LEFT][2] = 268; // X padding[PAD_L_LEFT][3] = 552; // Y // L3 padding[PAD_L3][0] = 218; // Width padding[PAD_L3][1] = 28; // Height padding[PAD_L3][2] = 268; // X padding[PAD_L3][3] = 641; // Y // Right Joystick up padding[PAD_R_UP][0] = 100; // Width padding[PAD_R_UP][1] = 25; // Height padding[PAD_R_UP][2] = 555; // X padding[PAD_R_UP][3] = 527; // Y // Right Joystick down padding[PAD_R_DOWN][0] = 100; // Width padding[PAD_R_DOWN][1] = 25; // Height padding[PAD_R_DOWN][2] = 555; // X padding[PAD_R_DOWN][3] = 577; // Y // Right Joystick right padding[PAD_R_RIGHT][0] = 109; // Width padding[PAD_R_RIGHT][1] = 25; // Height padding[PAD_R_RIGHT][2] = 607; // X padding[PAD_R_RIGHT][3] = 552; // Y // Right Joystick left padding[PAD_R_LEFT][0] = 109; // Width padding[PAD_R_LEFT][1] = 25; // Height padding[PAD_R_LEFT][2] = 498; // X padding[PAD_R_LEFT][3] = 552; // Y // R3 padding[PAD_R3][0] = 218; // Width padding[PAD_R3][1] = 28; // Height padding[PAD_R3][2] = 498; // X padding[PAD_R3][3] = 641; // Y // Start padding[PAD_START][0] = 218; // Width padding[PAD_START][1] = 28; // Height padding[PAD_START][2] = 503; // X padding[PAD_START][3] = 34; // Y // Select padding[PAD_SELECT][0] = 218; // Width padding[PAD_SELECT][1] = 28; // Height padding[PAD_SELECT][2] = 273; // X padding[PAD_SELECT][3] = 34; // Y // Analog padding[Analog][0] = 218; // Width padding[Analog][1] = 28; // Height padding[Analog][2] = 50; // X padding[Analog][3] = 452; // Y // Left Joystick Configuration padding[JoyL_config][0] = 180; // Width padding[JoyL_config][1] = 28; // Height padding[JoyL_config][2] = 50; // X padding[JoyL_config][3] = 550; // Y // Right Joystick Configuration padding[JoyR_config][0] = 180; // Width padding[JoyR_config][1] = 28; // Height padding[JoyR_config][2] = 764; // X padding[JoyR_config][3] = 550; // Y // Gamepad Configuration padding[Gamepad_config][0] = 180; // Width padding[Gamepad_config][1] = 28; // Height padding[Gamepad_config][2] = 50; // X padding[Gamepad_config][3] = 585; // Y // Set All Buttons padding[Set_all][0] = 180; // Width padding[Set_all][1] = 28; // Height padding[Set_all][2] = 764; // X padding[Set_all][3] = 585; // Y // Apply modifications without exit padding[Apply][0] = 70; // Width padding[Apply][1] = 28; // Height padding[Apply][2] = 833; // X padding[Apply][3] = 642; // Y // Ok button padding[Ok][0] = 70; // Width padding[Ok][1] = 28; // Height padding[Ok][2] = 913; // X padding[Ok][3] = 642; // Y // Cancel button padding[Cancel][0] = 70; // Width padding[Cancel][1] = 28; // Height padding[Cancel][2] = 753; // X padding[Cancel][3] = 642; // Y // create a new Notebook m_tab_gamepad = new wxNotebook(this, wxID_ANY); for (int i = 0; i < GAMEPAD_NUMBER; ++i) { // Tabs panels m_pan_tabs[i] = new opPanel( m_tab_gamepad, wxID_ANY, wxDefaultPosition, wxSize(DEFAULT_WIDTH, DEFAULT_HEIGHT)); // Add new page // Define label std::stringstream sstm; std::string label = "Gamepad "; sstm << label << i; // New page creation m_tab_gamepad->AddPage( m_pan_tabs[i], // Parent wxString(sstm.str().c_str(), wxConvUTF8) // Title ); for (int j = 0; j < BUTTONS_LENGTH; ++j) { // Gamepad buttons m_bt_gamepad[i][j] = new wxButton( m_pan_tabs[i], // Parent wxID_HIGHEST + j + 1, // ID _T("Undefined"), // Label wxPoint(padding[j][2], padding[j][3]), // Position wxSize(padding[j][0], padding[j][1]) // Size ); } // Redefine others gui buttons label m_bt_gamepad[i][JoyL_config]->SetLabel(_T("&Left Joystick Config")); m_bt_gamepad[i][JoyR_config]->SetLabel(_T("&Right Joystick Config")); m_bt_gamepad[i][Gamepad_config]->SetLabel(_T("&Gamepad Configuration")); m_bt_gamepad[i][Set_all]->SetLabel(_T("&Set All Buttons")); m_bt_gamepad[i][Cancel]->SetLabel(_T("&Cancel")); m_bt_gamepad[i][Apply]->SetLabel(_T("&Apply")); m_bt_gamepad[i][Ok]->SetLabel(_T("&Ok")); // Disable analog button (not yet supported) m_bt_gamepad[i][Analog]->Disable(); } Bind(wxEVT_BUTTON, &Dialog::OnButtonClicked, this); m_time_update_gui.SetOwner(this); Bind(wxEVT_TIMER, &Dialog::JoystickEvent, this); m_time_update_gui.Start(UPDATE_TIME, wxTIMER_CONTINUOUS); for (int i = 0; i < GAMEPAD_NUMBER; ++i) { for (int j = 0; j < NB_IMG; ++j) { m_pressed[i][j] = false; } } }
MaxSashWindow::MaxSashWindow(BBObject * handle, wxWindow* parent, wxWindowID id, int x, int y, int w, int h, long style) : wxSashWindow(parent, id, wxPoint(x, y), wxSize(w, h), style) { wxbind(this, handle); }
void MyFrame::OnPrintPreviewPS(wxCommandEvent& WXUNUSED(event)) { // Pass two printout objects: for preview, and possible printing. wxPrintDialogData printDialogData(* g_printData); wxPrintPreview *preview = new wxPrintPreview(new MyPrintout, new MyPrintout, & printDialogData); wxPreviewFrame *frame = new wxPreviewFrame(preview, this, _T("Demo Print Preview"), wxPoint(100, 100), wxSize(600, 650)); frame->Centre(wxBOTH); frame->Initialize(); frame->Show(); }
bool DRAWING_TOOL::drawArc( DRAWSEGMENT*& aGraphic ) { bool clockwise = true; // drawing direction of the arc double startAngle = 0.0f; // angle of the first arc line VECTOR2I cursorPos = m_controls->GetCursorPosition(); DRAWSEGMENT helperLine; helperLine.SetShape( S_SEGMENT ); helperLine.SetLayer( Dwgs_User ); helperLine.SetWidth( 1 ); // Add a VIEW_GROUP that serves as a preview for the new item SELECTION preview( m_view ); m_view->Add( &preview ); m_toolMgr->RunAction( COMMON_ACTIONS::selectionClear, true ); m_controls->ShowCursor( true ); m_controls->SetSnapping( true ); Activate(); enum ARC_STEPS { SET_ORIGIN = 0, SET_END, SET_ANGLE, FINISHED }; int step = SET_ORIGIN; // Main loop: keep receiving events while( OPT_TOOL_EVENT evt = Wait() ) { cursorPos = m_controls->GetCursorPosition(); if( evt->IsCancel() || evt->IsActivate() ) { preview.Clear(); delete aGraphic; aGraphic = NULL; break; } else if( evt->IsClick( BUT_RIGHT ) ) { showContextMenu(); } else if( evt->IsClick( BUT_LEFT ) ) { switch( step ) { case SET_ORIGIN: { LAYER_ID layer = m_frame->GetScreen()->m_Active_Layer; if( IsCopperLayer( layer ) ) { DisplayInfoMessage( NULL, _( "Graphic not allowed on Copper layers" ) ); --step; } else { // Init the new item attributes aGraphic->SetShape( S_ARC ); aGraphic->SetAngle( 0.0 ); aGraphic->SetWidth( getSegmentWidth( layer ) ); aGraphic->SetCenter( wxPoint( cursorPos.x, cursorPos.y ) ); aGraphic->SetLayer( layer ); helperLine.SetStart( aGraphic->GetCenter() ); helperLine.SetEnd( aGraphic->GetCenter() ); preview.Add( aGraphic ); preview.Add( &helperLine ); m_controls->SetAutoPan( true ); m_controls->CaptureCursor( true ); } } break; case SET_END: { if( wxPoint( cursorPos.x, cursorPos.y ) != aGraphic->GetCenter() ) { VECTOR2D startLine( aGraphic->GetArcStart() - aGraphic->GetCenter() ); startAngle = startLine.Angle(); aGraphic->SetArcStart( wxPoint( cursorPos.x, cursorPos.y ) ); } else --step; // one another chance to draw a proper arc } break; case SET_ANGLE: { if( wxPoint( cursorPos.x, cursorPos.y ) != aGraphic->GetArcStart() && aGraphic->GetAngle() != 0 ) { assert( aGraphic->GetArcStart() != aGraphic->GetArcEnd() ); assert( aGraphic->GetWidth() > 0 ); m_view->Add( aGraphic ); preview.Remove( aGraphic ); preview.Remove( &helperLine ); } else --step; // one another chance to draw a proper arc } break; } if( ++step == FINISHED ) break; } else if( evt->IsMotion() ) { switch( step ) { case SET_END: helperLine.SetEnd( wxPoint( cursorPos.x, cursorPos.y ) ); aGraphic->SetArcStart( wxPoint( cursorPos.x, cursorPos.y ) ); break; case SET_ANGLE: { VECTOR2D endLine( wxPoint( cursorPos.x, cursorPos.y ) - aGraphic->GetCenter() ); double newAngle = RAD2DECIDEG( endLine.Angle() - startAngle ); // Adjust the new angle to (counter)clockwise setting if( clockwise && newAngle < 0.0 ) newAngle += 3600.0; else if( !clockwise && newAngle > 0.0 ) newAngle -= 3600.0; aGraphic->SetAngle( newAngle ); } break; } // Show a preview of the item m_view->Update( &preview ); } else if( evt->IsAction( &COMMON_ACTIONS::incWidth ) ) { aGraphic->SetWidth( aGraphic->GetWidth() + WIDTH_STEP ); m_view->Update( &preview ); } else if( evt->IsAction( &COMMON_ACTIONS::decWidth ) ) { int width = aGraphic->GetWidth(); if( width > WIDTH_STEP ) { aGraphic->SetWidth( width - WIDTH_STEP ); m_view->Update( &preview ); } } else if( evt->IsAction( &COMMON_ACTIONS::arcPosture ) ) { if( clockwise ) aGraphic->SetAngle( aGraphic->GetAngle() - 3600.0 ); else aGraphic->SetAngle( aGraphic->GetAngle() + 3600.0 ); clockwise = !clockwise; m_view->Update( &preview ); } } m_controls->ShowCursor( false ); m_controls->SetSnapping( false ); m_controls->SetAutoPan( false ); m_controls->CaptureCursor( false ); m_view->Remove( &preview ); return ( step > SET_ORIGIN ); }
bool MyApp::OnInit(void) { wxInitAllImageHandlers(); // Set the font path and working directory wxFileName exePath = wxStandardPaths::Get().GetExecutablePath(); #ifdef __WXMAC__ wxString fontPath = exePath.GetPathWithSep() + wxT("../../../../../lib/fonts"); wxString cwdPath = exePath.GetPathWithSep() + wxT("../../.."); #else wxString fontPath = exePath.GetPathWithSep() + wxT("../../lib/fonts"); wxString cwdPath = exePath.GetPath(); #endif wxPdfFontManager::GetFontManager()->AddSearchPath(fontPath); wxSetWorkingDirectory(cwdPath); #if wxCHECK_VERSION(2,9,0) m_testFont.Create(10, wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL); #else m_testFont.Create(10, wxSWISS, wxNORMAL, wxNORMAL); #endif g_printData = new wxPrintData; // You could set an initial paper size here // g_printData->SetPaperId(wxPAPER_LETTER); // for Americans // g_printData->SetPaperId(wxPAPER_A4); // for everyone else g_pageSetupData = new wxPageSetupDialogData; // copy over initial paper size from print record (*g_pageSetupData) = *g_printData; // Set some initial page margins in mm. g_pageSetupData->SetMarginTopLeft(wxPoint(15, 15)); g_pageSetupData->SetMarginBottomRight(wxPoint(15, 15)); // Create the main frame window frame = new MyFrame((wxFrame *) NULL, _T("wxWidgets Printing Demo"), wxPoint(0, 0), wxSize(400, 400)); #if wxUSE_STATUSBAR // Give it a status line frame->CreateStatusBar(2); #endif // wxUSE_STATUSBAR // Load icon and bitmap frame->SetIcon( wxICON( mondrian) ); // Make a menubar wxMenu *file_menu = new wxMenu; file_menu->Append(WXPRINT_PRINT, _T("&Print..."), _T("Print")); file_menu->Append(WXPRINT_PDF, _T("PDF..."), _T("PDF")); file_menu->Append(WXPRINT_PAGE_SETUP, _T("Page Set&up..."), _T("Page setup")); #ifdef __WXMAC__ file_menu->Append(WXPRINT_PAGE_MARGINS, _T("Page Margins..."), _T("Page margins")); #endif file_menu->Append(WXPRINT_PREVIEW, _T("Print Pre&view"), _T("Preview")); #if wxUSE_ACCEL // Accelerators wxAcceleratorEntry entries[1]; entries[0].Set(wxACCEL_CTRL, (int) 'V', WXPRINT_PREVIEW); wxAcceleratorTable accel(1, entries); frame->SetAcceleratorTable(accel); #endif #if defined(__WXMSW__) && wxTEST_POSTSCRIPT_IN_MSW file_menu->AppendSeparator(); file_menu->Append(WXPRINT_PRINT_PS, _T("Print PostScript..."), _T("Print (PostScript)")); file_menu->Append(WXPRINT_PAGE_SETUP_PS, _T("Page Setup PostScript..."), _T("Page setup (PostScript)")); file_menu->Append(WXPRINT_PREVIEW_PS, _T("Print Preview PostScript"), _T("Preview (PostScript)")); #endif file_menu->AppendSeparator(); file_menu->Append(WXPRINT_ANGLEUP, _T("Angle up\tAlt-U"), _T("Raise rotated text angle")); file_menu->Append(WXPRINT_ANGLEDOWN, _T("Angle down\tAlt-D"), _T("Lower rotated text angle")); file_menu->AppendSeparator(); file_menu->Append(WXPRINT_QUIT, _T("E&xit"), _T("Exit program")); wxMenu *help_menu = new wxMenu; help_menu->Append(WXPRINT_ABOUT, _T("&About"), _T("About this demo")); wxMenuBar *menu_bar = new wxMenuBar; menu_bar->Append(file_menu, _T("&File")); menu_bar->Append(help_menu, _T("&Help")); // Associate the menu bar with the frame frame->SetMenuBar(menu_bar); MyCanvas *canvas = new MyCanvas(frame, wxPoint(0, 0), wxSize(100, 100), wxRETAINED|wxHSCROLL|wxVSCROLL); // Give it scrollbars: the virtual canvas is 20 * 50 = 1000 pixels in each direction canvas->SetScrollbars(20, 20, 50, 50); frame->canvas = canvas; frame->Centre(wxBOTH); frame->Show(); #if wxUSE_STATUSBAR frame->SetStatusText(_T("Printing demo")); #endif // wxUSE_STATUSBAR SetTopWindow(frame); return true; }
int DRAWING_TOOL::drawZone( bool aKeepout ) { ZONE_CONTAINER* zone = NULL; DRAWSEGMENT line45; DRAWSEGMENT* helperLine = NULL; // we will need more than one helper line BOARD_COMMIT commit( m_frame ); // Add a VIEW_GROUP that serves as a preview for the new item SELECTION preview( m_view ); m_view->Add( &preview ); m_toolMgr->RunAction( COMMON_ACTIONS::selectionClear, true ); m_controls->ShowCursor( true ); m_controls->SetSnapping( true ); Activate(); VECTOR2I origin; int numPoints = 0; bool direction45 = false; // 45 degrees only mode // Main loop: keep receiving events while( OPT_TOOL_EVENT evt = Wait() ) { bool updatePreview = false; // should preview be updated VECTOR2I cursorPos = m_controls->GetCursorPosition(); // Enable 45 degrees lines only mode by holding control if( direction45 != ( evt->Modifier( MD_CTRL ) && numPoints > 0 ) ) { direction45 = evt->Modifier( MD_CTRL ); if( direction45 ) { preview.Add( &line45 ); make45DegLine( helperLine, &line45 ); } else { preview.Remove( &line45 ); helperLine->SetEnd( wxPoint( cursorPos.x, cursorPos.y ) ); } updatePreview = true; } if( evt->IsCancel() || evt->IsActivate() ) { if( numPoints > 0 ) // cancel the current zone { delete zone; zone = NULL; m_controls->SetAutoPan( false ); m_controls->CaptureCursor( false ); if( direction45 ) { preview.Remove( &line45 ); direction45 = false; } preview.FreeItems(); updatePreview = true; numPoints = 0; } else // there is no zone currently drawn - just stop the tool break; if( evt->IsActivate() ) // now finish unconditionally break; } else if( evt->IsClick( BUT_RIGHT ) ) { showContextMenu(); } else if( evt->IsClick( BUT_LEFT ) || evt->IsDblClick( BUT_LEFT ) ) { // Check if it is double click / closing line (so we have to finish the zone) if( evt->IsDblClick( BUT_LEFT ) || ( numPoints > 0 && cursorPos == origin ) ) { if( numPoints > 2 ) // valid zone consists of more than 2 points { assert( zone->GetNumCorners() > 2 ); // Finish the zone if( direction45 ) zone->AppendCorner( cursorPos == origin ? line45.GetStart() : line45.GetEnd() ); zone->Outline()->CloseLastContour(); zone->Outline()->RemoveNullSegments(); if( !aKeepout ) static_cast<PCB_EDIT_FRAME*>( m_frame )->Fill_Zone( zone ); commit.Add( zone ); commit.Push( _( "Draw a zone" ) ); zone = NULL; } else { delete zone; zone = NULL; } numPoints = 0; m_controls->SetAutoPan( false ); m_controls->CaptureCursor( false ); if( direction45 ) { preview.Remove( &line45 ); direction45 = false; } preview.FreeItems(); updatePreview = true; } else { if( numPoints == 0 ) // it's the first click { // Get the current default settings for zones ZONE_SETTINGS zoneInfo = m_frame->GetZoneSettings(); zoneInfo.m_CurrentZone_Layer = m_frame->GetScreen()->m_Active_Layer; zoneInfo.SetIsKeepout( aKeepout ); m_controls->SetAutoPan( true ); m_controls->CaptureCursor( true ); // Show options dialog ZONE_EDIT_T dialogResult; if( aKeepout ) dialogResult = InvokeKeepoutAreaEditor( m_frame, &zoneInfo ); else { if( IsCopperLayer( zoneInfo.m_CurrentZone_Layer ) ) dialogResult = InvokeCopperZonesEditor( m_frame, &zoneInfo ); else dialogResult = InvokeNonCopperZonesEditor( m_frame, NULL, &zoneInfo ); } if( dialogResult == ZONE_ABORT ) { m_controls->SetAutoPan( false ); m_controls->CaptureCursor( false ); continue; } // Apply the selected settings zone = new ZONE_CONTAINER( m_board ); zoneInfo.ExportSetting( *zone ); m_frame->GetGalCanvas()->SetTopLayer( zoneInfo.m_CurrentZone_Layer ); // Add the first point zone->Outline()->Start( zoneInfo.m_CurrentZone_Layer, cursorPos.x, cursorPos.y, zone->GetHatchStyle() ); origin = cursorPos; // Helper line represents the currently drawn line of the zone polygon helperLine = new DRAWSEGMENT; helperLine->SetShape( S_SEGMENT ); helperLine->SetWidth( 1 ); helperLine->SetLayer( zoneInfo.m_CurrentZone_Layer ); helperLine->SetStart( wxPoint( cursorPos.x, cursorPos.y ) ); helperLine->SetEnd( wxPoint( cursorPos.x, cursorPos.y ) ); line45 = *helperLine; preview.Add( helperLine ); } else { zone->AppendCorner( helperLine->GetEnd() ); helperLine = new DRAWSEGMENT( *helperLine ); helperLine->SetStart( helperLine->GetEnd() ); preview.Add( helperLine ); } ++numPoints; updatePreview = true; } } else if( evt->IsMotion() && numPoints > 0 ) { // 45 degree lines if( direction45 ) make45DegLine( helperLine, &line45 ); else helperLine->SetEnd( wxPoint( cursorPos.x, cursorPos.y ) ); // Show a preview of the item updatePreview = true; } if( updatePreview ) m_view->Update( &preview ); } m_controls->ShowCursor( false ); m_controls->SetSnapping( false ); m_controls->SetAutoPan( false ); m_controls->CaptureCursor( false ); m_view->Remove( &preview ); m_frame->SetToolID( ID_NO_TOOL_SELECTED, wxCURSOR_DEFAULT, wxEmptyString ); return 0; }
/* Plot outlines of copper, for copper layer */ void PlotLayerOutlines( BOARD* aBoard, PLOTTER* aPlotter, LSET aLayerMask, const PCB_PLOT_PARAMS& aPlotOpt ) { BRDITEMS_PLOTTER itemplotter( aPlotter, aBoard, aPlotOpt ); itemplotter.SetLayerSet( aLayerMask ); SHAPE_POLY_SET outlines; for( LSEQ seq = aLayerMask.Seq( plot_seq, DIM( plot_seq ) ); seq; ++seq ) { LAYER_ID layer = *seq; outlines.RemoveAllContours(); aBoard->ConvertBrdLayerToPolygonalContours( layer, outlines ); outlines.Simplify(); // Plot outlines std::vector< wxPoint > cornerList; // Now we have one or more basic polygons: plot each polygon for( int ii = 0; ii < outlines.OutlineCount(); ii++ ) { for(int kk = 0; kk <= outlines.HoleCount (ii); kk++ ) { cornerList.clear(); const SHAPE_LINE_CHAIN& path = (kk == 0) ? outlines.COutline( ii ) : outlines.CHole( ii, kk - 1 ); for( int jj = 0; jj < path.PointCount(); jj++ ) cornerList.push_back( wxPoint( path.CPoint( jj ).x , path.CPoint( jj ).y ) ); // Ensure the polygon is closed if( cornerList[0] != cornerList[cornerList.size() - 1] ) cornerList.push_back( cornerList[0] ); aPlotter->PlotPoly( cornerList, NO_FILL ); } } // Plot pad holes if( aPlotOpt.GetDrillMarksType() != PCB_PLOT_PARAMS::NO_DRILL_SHAPE ) { for( MODULE* module = aBoard->m_Modules; module; module = module->Next() ) { for( D_PAD* pad = module->Pads(); pad; pad = pad->Next() ) { wxSize hole = pad->GetDrillSize(); if( hole.x == 0 || hole.y == 0 ) continue; if( hole.x == hole.y ) aPlotter->Circle( pad->GetPosition(), hole.x, NO_FILL ); else { wxPoint drl_start, drl_end; int width; pad->GetOblongDrillGeometry( drl_start, drl_end, width ); aPlotter->ThickSegment( pad->GetPosition() + drl_start, pad->GetPosition() + drl_end, width, SKETCH ); } } } } // Plot vias holes for( TRACK* track = aBoard->m_Track; track; track = track->Next() ) { const VIA* via = dyn_cast<const VIA*>( track ); if( via && via->IsOnLayer( layer ) ) // via holes can be not through holes { aPlotter->Circle( via->GetPosition(), via->GetDrillValue(), NO_FILL ); } } } }
int DRAWING_TOOL::PlaceText( const TOOL_EVENT& aEvent ) { BOARD_ITEM* text = NULL; const BOARD_DESIGN_SETTINGS& dsnSettings = m_frame->GetDesignSettings(); BOARD_COMMIT commit( m_frame ); // Add a VIEW_GROUP that serves as a preview for the new item SELECTION preview( m_view ); m_view->Add( &preview ); m_toolMgr->RunAction( COMMON_ACTIONS::selectionClear, true ); m_controls->ShowCursor( true ); m_controls->SetSnapping( true ); // do not capture or auto-pan until we start placing some text SCOPED_DRAW_MODE scopedDrawMode( m_mode, MODE::TEXT ); Activate(); m_frame->SetToolID( m_editModules ? ID_MODEDIT_TEXT_TOOL : ID_PCB_ADD_TEXT_BUTT, wxCURSOR_PENCIL, _( "Add text" ) ); // Main loop: keep receiving events while( OPT_TOOL_EVENT evt = Wait() ) { VECTOR2I cursorPos = m_controls->GetCursorPosition(); if( evt->IsCancel() || evt->IsActivate() ) { if( text ) { // Delete the old text and have another try delete text; text = NULL; preview.Clear(); m_controls->SetAutoPan( false ); m_controls->CaptureCursor( false ); m_controls->ShowCursor( true ); } else break; if( evt->IsActivate() ) // now finish unconditionally break; } else if( text && evt->Category() == TC_COMMAND ) { if( evt->IsAction( &COMMON_ACTIONS::rotate ) ) { text->Rotate( text->GetPosition(), m_frame->GetRotationAngle() ); m_view->Update( &preview ); } // TODO rotate CCW else if( evt->IsAction( &COMMON_ACTIONS::flip ) ) { text->Flip( text->GetPosition() ); m_view->Update( &preview ); } } else if ( evt->IsClick( BUT_RIGHT ) ) { showContextMenu(); } else if( evt->IsClick( BUT_LEFT ) ) { if( !text ) { // Init the new item attributes if( m_editModules ) { TEXTE_MODULE* textMod = new TEXTE_MODULE( (MODULE*) m_frame->GetModel() ); textMod->SetLayer( m_frame->GetActiveLayer() ); textMod->SetSize( dsnSettings.m_ModuleTextSize ); textMod->SetThickness( dsnSettings.m_ModuleTextWidth ); textMod->SetTextPosition( wxPoint( cursorPos.x, cursorPos.y ) ); DialogEditModuleText textDialog( m_frame, textMod, NULL ); bool placing; RunMainStack( [&]() { placing = textDialog.ShowModal() && ( textMod->GetText().Length() > 0 ); } ); if( placing ) text = textMod; else delete textMod; } else { TEXTE_PCB* textPcb = new TEXTE_PCB( m_frame->GetModel() ); // TODO we have to set IS_NEW, otherwise InstallTextPCB.. creates an undo entry :| LEGACY_CLEANUP textPcb->SetFlags( IS_NEW ); LAYER_ID layer = m_frame->GetActiveLayer(); textPcb->SetLayer( layer ); // Set the mirrored option for layers on the BACK side of the board if( IsBackLayer( layer ) ) textPcb->SetMirrored( true ); textPcb->SetSize( dsnSettings.m_PcbTextSize ); textPcb->SetThickness( dsnSettings.m_PcbTextWidth ); textPcb->SetTextPosition( wxPoint( cursorPos.x, cursorPos.y ) ); RunMainStack( [&]() { getEditFrame<PCB_EDIT_FRAME>()->InstallTextPCBOptionsFrame( textPcb, NULL ); } ); if( textPcb->GetText().IsEmpty() ) delete textPcb; else text = textPcb; } if( text == NULL ) continue; m_controls->CaptureCursor( true ); m_controls->SetAutoPan( true ); //m_controls->ShowCursor( false ); preview.Add( text ); } else { //assert( text->GetText().Length() > 0 ); //assert( text->GetSize().x > 0 && text->GetSize().y > 0 ); text->ClearFlags(); preview.Remove( text ); commit.Add( text ); commit.Push( _( "Place a text" ) ); m_controls->CaptureCursor( false ); m_controls->SetAutoPan( false ); m_controls->ShowCursor( true ); text = NULL; } } else if( text && evt->IsMotion() ) { text->SetPosition( wxPoint( cursorPos.x, cursorPos.y ) ); // Show a preview of the item m_view->Update( &preview ); } } m_controls->ShowCursor( false ); m_controls->SetSnapping( false ); m_controls->SetAutoPan( false ); m_controls->CaptureCursor( false ); m_view->Remove( &preview ); m_frame->SetToolID( ID_NO_TOOL_SELECTED, wxCURSOR_DEFAULT, wxEmptyString ); return 0; }
void EDA_Printout::DrawPage(void) /********************************/ /* Routine effective d'impression */ { int tmpzoom; wxPoint tmp_startvisu; wxSize PageSize_in_mm; wxSize SheetSize; // Sheet size in internal units wxSize PlotAreaSize; // Taille de la surface utile de trace (pixels) float scaleX, scaleY, scale; wxPoint old_org; wxPoint DrawOffset; // Offset de trace float userscale = 1.0; wxDC * dc = GetDC(); wxBusyCursor dummy; GetPageSizeMM(&PageSize_in_mm.x, &PageSize_in_mm.y); /* modification des cadrages et reglages locaux */ tmp_startvisu = ActiveScreen->m_StartVisu; tmpzoom = ActiveScreen->GetZoom(); old_org = ActiveScreen->m_DrawOrg; ActiveScreen->m_DrawOrg.x = ActiveScreen->m_DrawOrg.y = 0; ActiveScreen->m_StartVisu.x = ActiveScreen->m_StartVisu.y = 0; // Get margins float marginX0 = (float) g_PageSetupData->GetMarginTopLeft().x; // in mm float marginY0 = (float) g_PageSetupData->GetMarginTopLeft().y; float marginX1 = (float) g_PageSetupData->GetMarginBottomRight().x; float marginY1 = (float) g_PageSetupData->GetMarginBottomRight().y; SheetSize = ActiveScreen->m_CurrentSheet->m_Size; // size in 1/1000 inch SheetSize.x *= m_Parent->m_InternalUnits / 1000; SheetSize.y *= m_Parent->m_InternalUnits / 1000; // size in pixels // Get the size of the DC in pixels dc->GetSize(&PlotAreaSize.x, &PlotAreaSize.y); // Calcul des marges marginX0 *= (float) PlotAreaSize.x / PageSize_in_mm.x; /* margin est en pixels */ marginY0 *= (float) PlotAreaSize.y / PageSize_in_mm.y; marginX1 *= (float) PlotAreaSize.x / PageSize_in_mm.x; marginY1 *= (float) PlotAreaSize.y / PageSize_in_mm.y; PlotAreaSize.x -= (int)( marginX0 + marginX1); PlotAreaSize.y -= (int)( marginY0 + marginY1); #ifdef PCBNEW WinEDA_BasePcbFrame * pcbframe = (WinEDA_BasePcbFrame*) m_Parent; pcbframe->m_Pcb->ComputeBoundaryBox(); /* calcul des dimensions du PCB */ if (s_ScaleList[s_Scale_Select] == 0) // fit in page { SheetSize.x = pcbframe->m_Pcb->m_BoundaryBox.GetWidth(); SheetSize.y = pcbframe->m_Pcb->m_BoundaryBox.GetHeight(); } else userscale = s_ScaleList[s_Scale_Select]; if ( (s_ScaleList[s_Scale_Select] > 1.0) || // scale > 1 -> Recadrage (s_ScaleList[s_Scale_Select] == 0) ) // fit in page { DrawOffset.x += pcbframe->m_Pcb->m_BoundaryBox.GetX(); DrawOffset.y += pcbframe->m_Pcb->m_BoundaryBox.GetY(); } #endif // Calculate a suitable scaling factor scaleX = (float)SheetSize.x / PlotAreaSize.x; scaleY = (float)SheetSize.y / PlotAreaSize.y; scale = wxMax(scaleX,scaleY) / userscale; // Use x or y scaling factor, whichever fits on the DC int zoom = 1; ActiveScreen->SetZoom(zoom); // ajustage de l'echelle de trace #ifdef PCBNEW dc->SetUserScale(zoom / scale * m_PrintFrame->m_XScaleAdjust, zoom / scale * m_PrintFrame->m_YScaleAdjust); #else dc->SetUserScale(zoom / scale, zoom / scale); #endif DrawOffset.x -= (int)(marginX0 * scale); // margin est désiré en absolu! DrawOffset.y -= (int)(marginY0 * scale); #ifdef PCBNEW DrawOffset.x += (int)( (SheetSize.x/2) * (m_PrintFrame->m_XScaleAdjust -1.0)); DrawOffset.y += (int)( (SheetSize.y/2) * (m_PrintFrame->m_YScaleAdjust -1.0)); #endif ActiveScreen->m_DrawOrg = DrawOffset; GRResetPenAndBrush(dc); if( s_Print_Black_and_White ) GRForceBlackPen(TRUE); #ifdef EESCHEMA /* set Pen min width */ float ftmp; // PenMinWidth est donné en 1/100 mm, a convertir en pixels ftmp = (float)PenMinWidth / 100; // ftmp est en mm ftmp *= (float)PlotAreaSize.x / PageSize_in_mm.x; /* ftmp est en pixels */ SetPenMinWidth((int)ftmp); #else SetPenMinWidth(1); #endif WinEDA_DrawPanel * panel = m_Parent->DrawPanel; EDA_Rect tmp = panel->m_ClipBox; panel->m_ClipBox.SetOrigin(wxPoint(0,0)); panel->m_ClipBox.SetSize(wxSize(0x7FFFFF0, 0x7FFFFF0)); #ifdef EESCHEMA if( s_Print_Black_and_White ) g_PrintFillMask = FILLED_WITH_BG_BODYCOLOR; #endif g_IsPrinting = TRUE; panel->PrintPage(dc, m_Print_Sheet_Ref, s_PrintMaskLayer); g_IsPrinting = FALSE; #ifdef EESCHEMA g_PrintFillMask = 0; #endif panel->m_ClipBox = tmp; SetPenMinWidth(1); GRForceBlackPen(FALSE); ActiveScreen->m_StartVisu = tmp_startvisu; ActiveScreen->m_DrawOrg = old_org; ActiveScreen->SetZoom(tmpzoom); }
int DRAWING_TOOL::DrawDimension( const TOOL_EVENT& aEvent ) { DIMENSION* dimension = NULL; BOARD_COMMIT commit( m_frame ); int maxThickness; // Add a VIEW_GROUP that serves as a preview for the new item SELECTION preview( m_view ); m_view->Add( &preview ); m_toolMgr->RunAction( COMMON_ACTIONS::selectionClear, true ); m_controls->ShowCursor( true ); m_controls->SetSnapping( true ); SCOPED_DRAW_MODE scopedDrawMode( m_mode, MODE::DIMENSION ); Activate(); m_frame->SetToolID( ID_PCB_DIMENSION_BUTT, wxCURSOR_PENCIL, _( "Add dimension" ) ); enum DIMENSION_STEPS { SET_ORIGIN = 0, SET_END, SET_HEIGHT, FINISHED }; int step = SET_ORIGIN; // Main loop: keep receiving events while( OPT_TOOL_EVENT evt = Wait() ) { VECTOR2I cursorPos = m_controls->GetCursorPosition(); if( evt->IsCancel() || evt->IsActivate() ) { if( step != SET_ORIGIN ) // start from the beginning { preview.Clear(); delete dimension; step = SET_ORIGIN; } else break; if( evt->IsActivate() ) // now finish unconditionally break; } else if( evt->IsAction( &COMMON_ACTIONS::incWidth ) && step != SET_ORIGIN ) { dimension->SetWidth( dimension->GetWidth() + WIDTH_STEP ); m_view->Update( &preview ); } else if( evt->IsAction( &COMMON_ACTIONS::decWidth ) && step != SET_ORIGIN ) { int width = dimension->GetWidth(); if( width > WIDTH_STEP ) { dimension->SetWidth( width - WIDTH_STEP ); m_view->Update( &preview ); } } else if ( evt->IsClick( BUT_RIGHT ) ) { showContextMenu(); } else if( evt->IsClick( BUT_LEFT ) ) { switch( step ) { case SET_ORIGIN: { LAYER_ID layer = m_frame->GetScreen()->m_Active_Layer; if( IsCopperLayer( layer ) || layer == Edge_Cuts ) { DisplayInfoMessage( NULL, _( "Dimension not allowed on Copper or Edge Cut layers" ) ); --step; } else { // Init the new item attributes dimension = new DIMENSION( m_board ); dimension->SetLayer( layer ); dimension->SetOrigin( wxPoint( cursorPos.x, cursorPos.y ) ); dimension->SetEnd( wxPoint( cursorPos.x, cursorPos.y ) ); dimension->Text().SetSize( m_board->GetDesignSettings().m_PcbTextSize ); int width = m_board->GetDesignSettings().m_PcbTextWidth; maxThickness = Clamp_Text_PenSize( width, dimension->Text().GetSize() ); if( width > maxThickness ) width = maxThickness; dimension->Text().SetThickness( width ); dimension->SetWidth( width ); dimension->AdjustDimensionDetails(); preview.Add( dimension ); m_controls->SetAutoPan( true ); m_controls->CaptureCursor( true ); } } break; case SET_END: dimension->SetEnd( wxPoint( cursorPos.x, cursorPos.y ) ); // Dimensions that have origin and end in the same spot are not valid if( dimension->GetOrigin() == dimension->GetEnd() ) --step; break; case SET_HEIGHT: { if( wxPoint( cursorPos.x, cursorPos.y ) != dimension->GetPosition() ) { assert( dimension->GetOrigin() != dimension->GetEnd() ); assert( dimension->GetWidth() > 0 ); preview.Remove( dimension ); commit.Add( dimension ); commit.Push( _( "Draw a dimension" ) ); } } break; } if( ++step == FINISHED ) { step = SET_ORIGIN; m_controls->SetAutoPan( false ); m_controls->CaptureCursor( false ); } } else if( evt->IsMotion() ) { switch( step ) { case SET_END: dimension->SetEnd( wxPoint( cursorPos.x, cursorPos.y ) ); break; case SET_HEIGHT: { // Calculating the direction of travel perpendicular to the selected axis double angle = dimension->GetAngle() + ( M_PI / 2 ); wxPoint pos( cursorPos.x, cursorPos.y ); wxPoint delta( pos - dimension->m_featureLineDO ); double height = ( delta.x * cos( angle ) ) + ( delta.y * sin( angle ) ); dimension->SetHeight( height ); } break; } // Show a preview of the item m_view->Update( &preview ); } } if( step != SET_ORIGIN ) delete dimension; m_controls->ShowCursor( false ); m_controls->SetSnapping( false ); m_controls->SetAutoPan( false ); m_controls->CaptureCursor( false ); m_view->Remove( &preview ); m_frame->SetToolID( ID_NO_TOOL_SELECTED, wxCURSOR_DEFAULT, wxEmptyString ); return 0; }
vtkFrame::vtkFrame( Dataset **dataset ) : vtkFrameUI( (wxFrame *)NULL, VTK_FRAME, _T("OpenEBSD"), wxPoint(50,50), wxSize(450,340) ) { grainProp->Show(false); ds = dataset; }
int DRAWING_TOOL::PlaceDXF( const TOOL_EVENT& aEvent ) { if( !m_frame->GetModel() ) return 0; DIALOG_DXF_IMPORT dlg( m_frame ); int dlgResult = dlg.ShowModal(); const std::list<BOARD_ITEM*>& list = dlg.GetImportedItems(); if( dlgResult != wxID_OK || list.empty() ) return 0; VECTOR2I cursorPos = m_controls->GetCursorPosition(); VECTOR2I delta = cursorPos - list.front()->GetPosition(); // Add a VIEW_GROUP that serves as a preview for the new item SELECTION preview( m_view ); BOARD_COMMIT commit( m_frame ); // Build the undo list & add items to the current view for( auto item : list ) { assert( item->Type() == PCB_LINE_T || item->Type() == PCB_TEXT_T ); preview.Add( item ); } BOARD_ITEM* firstItem = preview.Front(); m_view->Add( &preview ); m_toolMgr->RunAction( COMMON_ACTIONS::selectionClear, true ); m_controls->ShowCursor( true ); m_controls->SetSnapping( true ); SCOPED_DRAW_MODE scopedDrawMode( m_mode, MODE::DXF ); Activate(); // Main loop: keep receiving events while( OPT_TOOL_EVENT evt = Wait() ) { cursorPos = m_controls->GetCursorPosition(); if( evt->IsMotion() ) { delta = cursorPos - firstItem->GetPosition(); for( auto item : preview ) item->Move( wxPoint( delta.x, delta.y ) ); m_view->Update( &preview ); } else if( evt->Category() == TC_COMMAND ) { // TODO it should be handled by EDIT_TOOL, so add items and select? if( evt->IsAction( &COMMON_ACTIONS::rotate ) ) { for( auto item : preview ) item->Rotate( wxPoint( cursorPos.x, cursorPos.y ), m_frame->GetRotationAngle() ); m_view->Update( &preview ); } else if( evt->IsAction( &COMMON_ACTIONS::flip ) ) { for( auto item : preview ) item->Flip( wxPoint( cursorPos.x, cursorPos.y ) ); m_view->Update( &preview ); } else if( evt->IsCancel() || evt->IsActivate() ) { preview.FreeItems(); break; } } else if ( evt->IsClick( BUT_RIGHT ) ) { showContextMenu(); } else if( evt->IsClick( BUT_LEFT ) ) { // Place the drawing BOARD_ITEM_CONTAINER* parent = m_frame->GetModel(); for( auto item : preview ) { if( m_editModules ) { // Modules use different types for the same things, // so we need to convert imported items to appropriate classes. BOARD_ITEM* converted = NULL; switch( item->Type() ) { case PCB_TEXT_T: { TEXTE_PCB* text = static_cast<TEXTE_PCB*>( item ); TEXTE_MODULE* textMod = new TEXTE_MODULE( (MODULE*) parent ); // Assignment operator also copies the item PCB_TEXT_T type, // so it cannot be added to a module which handles PCB_MODULE_TEXT_T textMod->SetPosition( text->GetPosition() ); textMod->SetText( text->GetText() ); textMod->SetSize( text->GetSize() ); textMod->SetThickness( text->GetThickness() ); textMod->SetOrientation( text->GetOrientation() ); textMod->SetTextPosition( text->GetTextPosition() ); textMod->SetSize( text->GetSize() ); textMod->SetMirrored( text->IsMirrored() ); textMod->SetAttributes( text->GetAttributes() ); textMod->SetItalic( text->IsItalic() ); textMod->SetBold( text->IsBold() ); textMod->SetHorizJustify( text->GetHorizJustify() ); textMod->SetVertJustify( text->GetVertJustify() ); textMod->SetMultilineAllowed( text->IsMultilineAllowed() ); converted = textMod; break; } case PCB_LINE_T: { DRAWSEGMENT* seg = static_cast<DRAWSEGMENT*>( item ); EDGE_MODULE* modSeg = new EDGE_MODULE( (MODULE*) parent ); // Assignment operator also copies the item PCB_LINE_T type, // so it cannot be added to a module which handles PCB_MODULE_EDGE_T modSeg->SetWidth( seg->GetWidth() ); modSeg->SetStart( seg->GetStart() ); modSeg->SetEnd( seg->GetEnd() ); modSeg->SetAngle( seg->GetAngle() ); modSeg->SetShape( seg->GetShape() ); modSeg->SetType( seg->GetType() ); modSeg->SetBezControl1( seg->GetBezControl1() ); modSeg->SetBezControl2( seg->GetBezControl2() ); modSeg->SetBezierPoints( seg->GetBezierPoints() ); modSeg->SetPolyPoints( seg->GetPolyPoints() ); converted = modSeg; break; } default: assert( false ); break; } if( converted ) converted->SetLayer( item->GetLayer() ); delete item; item = converted; } if( item ) commit.Add( item ); } commit.Push( _( "Place a DXF drawing" ) ); break; } } preview.Clear(); m_controls->ShowCursor( false ); m_controls->SetSnapping( false ); m_controls->SetAutoPan( false ); m_controls->CaptureCursor( false ); m_view->Remove( &preview ); return 0; }
wxPoint wxJoystick::GetPosition() const { // TODO return wxPoint(0, 0); }
bool DRAWING_TOOL::drawSegment( int aShape, DRAWSEGMENT*& aGraphic, boost::optional<VECTOR2D> aStartingPoint ) { // Only two shapes are currently supported assert( aShape == S_SEGMENT || aShape == S_CIRCLE ); DRAWSEGMENT line45; // Add a VIEW_GROUP that serves as a preview for the new item SELECTION preview( m_view ); m_view->Add( &preview ); m_toolMgr->RunAction( COMMON_ACTIONS::selectionClear, true ); m_controls->ShowCursor( true ); m_controls->SetSnapping( true ); Activate(); bool direction45 = false; // 45 degrees only mode bool started = false; VECTOR2I cursorPos = m_controls->GetCursorPosition(); if( aStartingPoint ) { LAYER_ID layer = m_frame->GetScreen()->m_Active_Layer; // Init the new item attributes aGraphic->SetShape( (STROKE_T) aShape ); aGraphic->SetWidth( m_lineWidth ); aGraphic->SetStart( wxPoint( aStartingPoint->x, aStartingPoint->y ) ); aGraphic->SetEnd( wxPoint( cursorPos.x, cursorPos.y ) ); aGraphic->SetLayer( layer ); if( aShape == S_SEGMENT ) line45 = *aGraphic; // used only for direction 45 mode with lines preview.Add( aGraphic ); m_controls->SetAutoPan( true ); m_controls->CaptureCursor( true ); started = true; } // Main loop: keep receiving events while( OPT_TOOL_EVENT evt = Wait() ) { bool updatePreview = false; // should preview be updated cursorPos = m_controls->GetCursorPosition(); // 45 degree angle constraint enabled with an option and toggled with Ctrl const bool limit45 = ( g_Segments_45_Only != !!( evt->Modifier( MD_CTRL ) ) ); if( direction45 != limit45 && started && aShape == S_SEGMENT ) { direction45 = limit45; if( direction45 ) { preview.Add( &line45 ); make45DegLine( aGraphic, &line45 ); } else { preview.Remove( &line45 ); aGraphic->SetEnd( wxPoint( cursorPos.x, cursorPos.y ) ); } updatePreview = true; } if( evt->IsCancel() || evt->IsActivate() || evt->IsAction( &COMMON_ACTIONS::layerChanged ) ) { preview.Clear(); updatePreview = true; delete aGraphic; aGraphic = NULL; break; } else if( evt->IsClick( BUT_RIGHT ) ) { showContextMenu(); } else if( evt->IsClick( BUT_LEFT ) || evt->IsDblClick( BUT_LEFT ) ) { if( !started ) { LAYER_ID layer = m_frame->GetScreen()->m_Active_Layer; if( IsCopperLayer( layer ) ) { DisplayInfoMessage( NULL, _( "Graphic not allowed on Copper layers" ) ); } else { // Init the new item attributes aGraphic->SetShape( (STROKE_T) aShape ); m_lineWidth = getSegmentWidth( layer ); aGraphic->SetWidth( m_lineWidth ); aGraphic->SetStart( wxPoint( cursorPos.x, cursorPos.y ) ); aGraphic->SetEnd( wxPoint( cursorPos.x, cursorPos.y ) ); aGraphic->SetLayer( layer ); if( aShape == S_SEGMENT ) line45 = *aGraphic; // used only for direction 45 mode with lines preview.Add( aGraphic ); m_controls->SetAutoPan( true ); m_controls->CaptureCursor( true ); started = true; } } else { if( aGraphic->GetEnd() == aGraphic->GetStart() || ( evt->IsDblClick( BUT_LEFT ) && aShape == S_SEGMENT ) ) // User has clicked twice in the same spot { // a clear sign that the current drawing is finished // Now we have to add the helper line as well if( direction45 ) { BOARD_ITEM_CONTAINER* parent = m_frame->GetModel(); DRAWSEGMENT* l = m_editModules ? new EDGE_MODULE( (MODULE*) parent ) : new DRAWSEGMENT; // Copy coordinates, layer, etc. *static_cast<DRAWSEGMENT*>( l ) = line45; l->SetEnd( aGraphic->GetStart() ); BOARD_COMMIT commit( m_frame ); commit.Add( l ); commit.Push( _( "Draw a line" ) ); } delete aGraphic; aGraphic = NULL; } preview.Clear(); break; } } else if( evt->IsMotion() ) { // 45 degree lines if( direction45 && aShape == S_SEGMENT ) make45DegLine( aGraphic, &line45 ); else aGraphic->SetEnd( wxPoint( cursorPos.x, cursorPos.y ) ); updatePreview = true; } else if( evt->IsAction( &COMMON_ACTIONS::incWidth ) ) { m_lineWidth += WIDTH_STEP; aGraphic->SetWidth( m_lineWidth ); updatePreview = true; } else if( evt->IsAction( &COMMON_ACTIONS::decWidth ) ) { if( m_lineWidth > (unsigned) WIDTH_STEP ) { m_lineWidth -= WIDTH_STEP; aGraphic->SetWidth( m_lineWidth ); updatePreview = true; } } if( updatePreview ) m_view->Update( &preview ); } m_controls->ShowCursor( false ); m_controls->SetSnapping( false ); m_controls->SetAutoPan( false ); m_controls->CaptureCursor( false ); m_view->Remove( &preview ); return started; }
bool CTimeServerApp::OnInit() { SetVendorName(VENDOR_NAME); if (!wxApp::OnInit()) return false; if (!m_nolog) { wxString logBaseName = LOG_BASE_NAME; if (!m_name.IsEmpty()) { logBaseName.Append(wxT("_")); logBaseName.Append(m_name); } #if defined(__WINDOWS__) if (m_logDir.IsEmpty()) m_logDir = wxFileName::GetHomeDir(); #else if (m_logDir.IsEmpty()) m_logDir = wxT(LOG_DIR); #endif wxLog* log = new CLogger(m_logDir, logBaseName); wxLog::SetActiveTarget(log); } else { new wxLogNull; } m_logChain = new wxLogChain(new CTimeServerLogRedirect); #if defined(__WINDOWS__) m_config = new CTimeServerConfig(new wxConfig(APPLICATION_NAME), m_name); #else if (m_confDir.IsEmpty()) m_confDir = wxT(CONF_DIR); m_config = new CTimeServerConfig(m_confDir, m_name); #endif wxString frameName = APPLICATION_NAME + wxT(" - "); if (!m_name.IsEmpty()) { frameName.Append(m_name); frameName.Append(wxT(" - ")); } frameName.Append(VERSION); wxPoint position = wxDefaultPosition; int x, y; getPosition(x, y); if (x >= 0 && y >= 0) position = wxPoint(x, y); m_frame = new CTimeServerFrame(frameName, position, m_gui); m_frame->Show(); SetTopWindow(m_frame); wxLogInfo(wxT("Starting ") + APPLICATION_NAME + wxT(" - ") + VERSION); // Log the version of wxWidgets and the Operating System wxLogInfo(wxT("Using wxWidgets %d.%d.%d on %s"), wxMAJOR_VERSION, wxMINOR_VERSION, wxRELEASE_NUMBER, ::wxGetOsDescription().c_str()); createThread(); return true; }
void MyFrame::OnPrintPreview(wxCommandEvent& WXUNUSED(event)) { // Pass two printout objects: for preview, and possible printing. wxPrintDialogData printDialogData(* g_printData); wxPrintPreview *preview = new wxPrintPreview(new MyPrintout, new MyPrintout, & printDialogData); if (!preview->Ok()) { delete preview; wxMessageBox(_T("There was a problem previewing.\nPerhaps your current printer is not set correctly?"), _T("Previewing"), wxOK); return; } wxPreviewFrame *frame = new wxPreviewFrame(preview, this, _T("Demo Print Preview"), wxPoint(100, 100), wxSize(600, 650)); frame->Centre(wxBOTH); frame->Initialize(); frame->Show(); }
EWXWEXPORT(void,wxSizerItem_SetDimension)(wxSizerItem* self,int _x,int _y,int _w,int _h) { self->SetDimension(wxPoint(_x, _y), wxSize(_w, _h)); }
void ExportMixerPanel::OnMouseEvent(wxMouseEvent & event) { if( event.ButtonDown() ) { CaptureMouse(); bool reset = true; //check tracks for( int i = 0; i < mMixerSpec->GetNumTracks(); i++ ) if( mTrackRects[ i ].Inside( event.m_x, event.m_y ) ) { reset = false; if( mSelectedTrack == i ) mSelectedTrack = -1; else { mSelectedTrack = i; if( mSelectedChannel != -1 ) mMixerSpec->mMap[ mSelectedTrack ][ mSelectedChannel ] = !mMixerSpec->mMap[ mSelectedTrack ][ mSelectedChannel ]; } goto found; } //check channels for( int i = 0; i < mMixerSpec->GetNumChannels(); i++ ) if( mChannelRects[ i ].Inside( event.m_x, event.m_y ) ) { reset = false; if( mSelectedChannel == i ) mSelectedChannel = -1; else { mSelectedChannel = i; if( mSelectedTrack != -1 ) mMixerSpec->mMap[ mSelectedTrack ][ mSelectedChannel ] = !mMixerSpec->mMap[ mSelectedTrack ][ mSelectedChannel ]; } goto found; } //check links for( int i = 0; i < mMixerSpec->GetNumTracks(); i++ ) for( int j = 0; j < mMixerSpec->GetNumChannels(); j++ ) if( mMixerSpec->mMap[ i ][ j ] && IsOnLine( wxPoint( event.m_x, event.m_y ), wxPoint( mTrackRects[ i ].x + mBoxWidth, mTrackRects[ i ].y + mTrackHeight / 2 ), wxPoint( mChannelRects[ j ].x, mChannelRects[ j ].y + mChannelHeight / 2 ) ) ) mMixerSpec->mMap[ i ][ j ] = false; found: if( reset ) mSelectedTrack = mSelectedChannel = -1; Refresh( false ); } if( event.ButtonUp() ) { if( HasCapture() ) ReleaseMouse(); } }