void SCH_BASE_FRAME::UpdateStatusBar()
{
    wxString        line;
    int             dx, dy;
    BASE_SCREEN*    screen = GetScreen();

    if( !screen )
        return;

    EDA_DRAW_FRAME::UpdateStatusBar();

    // Display absolute coordinates:
    double dXpos = To_User_Unit( g_UserUnit, GetCrossHairPosition().x );
    double dYpos = To_User_Unit( g_UserUnit, GetCrossHairPosition().y );

    if ( g_UserUnit == MILLIMETRES )
    {
        dXpos = RoundTo0( dXpos, 100.0 );
        dYpos = RoundTo0( dYpos, 100.0 );
    }

    wxString absformatter;
    wxString locformatter;

    switch( g_UserUnit )
    {
    case INCHES:
        absformatter = wxT( "X %.3f  Y %.3f" );
        locformatter = wxT( "dx %.3f  dy %.3f  dist %.3f" );
        break;

    case MILLIMETRES:
        absformatter = wxT( "X %.2f  Y %.2f" );
        locformatter = wxT( "dx %.2f  dy %.2f  dist %.2f" );
        break;

    case UNSCALED_UNITS:
        absformatter = wxT( "X %f  Y %f" );
        locformatter = wxT( "dx %f  dy %f  dist %f" );
        break;

    case DEGREES:
        wxASSERT( false );
        break;
    }

    line.Printf( absformatter, dXpos, dYpos );
    SetStatusText( line, 2 );

    // Display relative coordinates:
    dx = GetCrossHairPosition().x - screen->m_O_Curseur.x;
    dy = GetCrossHairPosition().y - screen->m_O_Curseur.y;

    dXpos = To_User_Unit( g_UserUnit, dx );
    dYpos = To_User_Unit( g_UserUnit, dy );

    if( g_UserUnit == MILLIMETRES )
    {
        dXpos = RoundTo0( dXpos, 100.0 );
        dYpos = RoundTo0( dYpos, 100.0 );
    }

    // We already decided the formatter above
    line.Printf( locformatter, dXpos, dYpos, hypot( dXpos, dYpos ) );
    SetStatusText( line, 3 );

    // refresh units display
    DisplayUnitsMsg();
}
const TITLE_BLOCK& SCH_BASE_FRAME::GetTitleBlock() const
{
    wxASSERT( GetScreen() );
    return GetScreen()->GetTitleBlock();
}
void SCH_BASE_FRAME::SetTitleBlock( const TITLE_BLOCK& aTitleBlock )
{
    wxASSERT( GetScreen() );
    GetScreen()->SetTitleBlock( aTitleBlock );
}
void SCH_BASE_FRAME::SetAuxOrigin( const wxPoint& aPosition )
{
    wxASSERT( GetScreen() );
    GetScreen()->SetAuxOrigin( aPosition );
}
const wxPoint& SCH_BASE_FRAME::GetAuxOrigin() const
{
    wxASSERT( GetScreen() );
    return GetScreen()->GetAuxOrigin();
}
void CSoundCardRepeaterLogger::DoLogString(const wxChar* msg, time_t timestamp)
{
	wxASSERT(msg != NULL);

	::wxGetApp().showLog(msg);
}
Example #7
0
void StatusBar::OnMouseLeftDown(wxMouseEvent& event) {
	UpdateBarFromActiveEditor();
	wxASSERT(m_editorCtrl);

	const int x = event.GetX();
	const int y = event.GetY();
	wxRect syntaxRect;
	wxRect tabsRect;
	wxRect symbolsRect;
	wxRect encodingRect;
	GetFieldRect(1, syntaxRect);
	GetFieldRect(2, tabsRect);
	GetFieldRect(3, symbolsRect);
	GetFieldRect(4, encodingRect);

	if (syntaxRect.Contains(x, y)) {
		PopupSyntaxMenu(syntaxRect);
	}
	else if (tabsRect.Contains(x, y)) {
		// Create the tabs menu
		wxMenu tabsMenu;
		tabsMenu.Append(MENU_TABS_2, _("2"), wxEmptyString, wxITEM_CHECK);
		tabsMenu.Append(MENU_TABS_3, _("3"), wxEmptyString, wxITEM_CHECK);
		tabsMenu.Append(MENU_TABS_4, _("4"), wxEmptyString, wxITEM_CHECK);
		tabsMenu.Append(MENU_TABS_8, _("8"), wxEmptyString, wxITEM_CHECK);
		tabsMenu.Append(MENU_TABS_OTHER, _("Other..."), wxEmptyString, wxITEM_CHECK);
		tabsMenu.AppendSeparator();
		tabsMenu.Append(MENU_TABS_SOFT, _("Soft Tabs (Spaces)"), wxEmptyString, wxITEM_CHECK);

		const unsigned int tabWidth = m_parentFrame.GetTabWidth();
		if (tabWidth == 2) tabsMenu.Check(MENU_TABS_2, true);
		else if (tabWidth == 3) tabsMenu.Check(MENU_TABS_3, true);
		else if (tabWidth == 4) tabsMenu.Check(MENU_TABS_4, true);
		else if (tabWidth == 8) tabsMenu.Check(MENU_TABS_8, true);
		else {
			tabsMenu.SetLabel(MENU_TABS_OTHER, wxString::Format(wxT("Other (%u) ..."), tabWidth));
			tabsMenu.Check(MENU_TABS_OTHER, true);
		}

		if (m_parentFrame.IsSoftTabs()) tabsMenu.Check(MENU_TABS_SOFT, true);

		PopupMenu(&tabsMenu, tabsRect.x, tabsRect.y);
	}
	else if (symbolsRect.Contains(x, y) && m_editorCtrl) {
		wxMenu symbolsMenu;

		if (!m_symbols.empty()) {
			// Create the symbols menu
			unsigned int id = 5000; // menu range 5000-6000
			bool currentSet = false;
			for (std::vector<SymbolRef>::const_iterator p = m_symbols.begin(); p != m_symbols.end(); ++p) {
				const SymbolRef& sr = *p;
				wxString symbolString = m_editorCtrl->GetSymbolString(sr);
				if (symbolString.empty()) symbolString = wxT(" "); // menu name cannot be empty

				symbolsMenu.Append(id, symbolString, wxEmptyString, wxITEM_CHECK);

				// Select current
				if (!currentSet && m_pos < p->start) {
					if (p != m_symbols.begin()) {
						symbolsMenu.Check(id-1, true);
					}
					currentSet = true;
				}

				++id;
			}

			// Current symbol may be the last and therefore not checked above
			if (!currentSet && m_pos >= m_symbols.back().start) {
				symbolsMenu.Check(id-1, true);
			}
		}
		else {
			symbolsMenu.Append(0, _("No Symbols"), wxEmptyString);
			symbolsMenu.Enable(0, false);
		}

		PopupMenu(&symbolsMenu, symbolsRect.x, symbolsRect.y);
	}
	else if (encodingRect.Contains(x, y) && m_editorCtrl) {
		// Create the tabs menu
		wxMenu encMenu;
		m_parentFrame.CreateEncodingMenu(encMenu);
		m_parentFrame.UpdateEncodingMenu(encMenu);

		PopupMenu(&encMenu, encodingRect.x, encodingRect.y);
	}
	else event.Skip();
}
bool BOARD::CombineAreas( PICKED_ITEMS_LIST* aDeletedList, ZONE_CONTAINER* area_ref,
                          ZONE_CONTAINER* area_to_combine )
{
    if( area_ref == area_to_combine )
    {
        wxASSERT( 0 );
        return false;
    }

    // polygons intersect, combine them
    KI_POLYGON_WITH_HOLES areaRefPoly;
    KI_POLYGON_WITH_HOLES areaToMergePoly;
    area_ref->Outline()->m_CornersList.ExportTo( areaRefPoly );
    area_to_combine->Outline()->m_CornersList.ExportTo(  areaToMergePoly );

    KI_POLYGON_WITH_HOLES_SET mergedOutlines;
    mergedOutlines.push_back( areaRefPoly );
    mergedOutlines |= areaToMergePoly;

    // We should have one polygon with hole
    // We can have 2 polygons with hole, if the 2 initial polygons have only one common corner
    // and therefore cannot be merged (they are dectected as intersecting)
    // but we should never have more than 2 polys
    if( mergedOutlines.size() > 2 )
    {
        wxLogMessage(wxT("BOARD::CombineAreas error: more than 2 polys after merging") );
        return false;
    }

    if( mergedOutlines.size() > 1 )
        return false;

    areaRefPoly = mergedOutlines[0];
    area_ref->Outline()->RemoveAllContours();

    KI_POLYGON_WITH_HOLES::iterator_type corner = areaRefPoly.begin();

    // create area with external contour: Recreate only area edges, NOT holes
    area_ref->Outline()->Start( area_ref->GetLayer(), corner->x(), corner->y(),
                                area_ref->Outline()->GetHatchStyle() );

    while( ++corner != areaRefPoly.end() )
    {
        area_ref->Outline()->AppendCorner( corner->x(), corner->y() );
    }

    area_ref->Outline()->CloseLastContour();

    // add holes (set of polygons)
    KI_POLYGON_WITH_HOLES::iterator_holes_type hole = areaRefPoly.begin_holes();

    while( hole != areaRefPoly.end_holes() )
    {
        KI_POLYGON::iterator_type hole_corner = hole->begin();

        // create area with external contour: Recreate only area edges, NOT holes
        while( hole_corner != hole->end() )
        {
            area_ref->Outline()->AppendCorner( hole_corner->x(), hole_corner->y() );
            hole_corner++;
        }

        area_ref->Outline()->CloseLastContour();
        hole++;
    }

    RemoveArea( aDeletedList, area_to_combine );

    area_ref->SetLocalFlags( 1 );
    area_ref->Outline()->Hatch();

    return true;
}