예제 #1
0
// convert a Timestring HH:MM into a double
double CDlgAdvPreferences::TimeStringToDouble(wxString timeStr) {
    double hour;
    double minutes;
    timeStr.SubString(0,timeStr.First(':')).ToDouble(&hour);
    timeStr.SubString(timeStr.First(':')+1,timeStr.Length()).ToDouble(&minutes);
    minutes = minutes/60.0;
    return hour + minutes;
}
예제 #2
0
wxString Boat::repeatArea( wxString html )
{
    wxString topHTML;
    wxString bottomHTML;
    wxString middleHTML;

    wxString seperatorTop = wxT( "<!--Repeat -->" );
    wxString seperatorBottom = wxT( "<!--Repeat End -->" );

    int indexTop = html.First( seperatorTop )+seperatorTop.Len();
    int indexBottom = html.First( seperatorBottom )+seperatorBottom.Len();

    topHTML = html.substr( 0,indexTop );
    bottomHTML = html.substr( indexBottom,html.Len()-1 );
    middleHTML = html.substr( indexTop,indexBottom-indexTop );

    topHTML.Replace( _T( "#LETYPE#" ),parent->m_gridEquipment->GetColLabelValue( 0 ) );
    topHTML.Replace( _T( "#LDISCRIPTION#" ),parent->m_gridEquipment->GetColLabelValue( 1 ) );
    topHTML.Replace( _T( "#LSERIAL#" ),parent->m_gridEquipment->GetColLabelValue( 2 ) );
    topHTML.Replace( _T( "#LREMARKS#" ),parent->m_gridEquipment->GetColLabelValue( 3 ) );

    wxString newMiddleHTML = _T( "" );
    for ( int i = 0; i < parent->m_gridEquipment->GetNumberRows(); i++ )
    {
        wxString temp = middleHTML;
        for ( int c = 0; c < parent->m_gridEquipment->GetNumberCols(); c++ )
        {
            wxString text = parent->m_gridEquipment->GetCellValue( i,c );

            switch ( c )
            {
            case 0:
                temp.Replace( _T( "#ETYPE#" ),text );
                break;
            case 1:
                temp.Replace( _T( "#DISCRIPTION#" ),text );
                break;
            case 2:
                temp.Replace( _T( "#SERIAL#" ),text );
                break;
            case 3:
                temp.Replace( _T( "#REMARKS#" ),text );
                break;
            }
        }
        newMiddleHTML += temp;
    }

    html = topHTML + newMiddleHTML + bottomHTML;
    return html;
}
예제 #3
0
파일: mtgui.cpp 프로젝트: nuin/MrMTgui
wxString modeltest::checkBlock(wxString block)
{
	int lsetPos, semiPos;
	wxString fblock;

	if(block.Contains("Lset") || block.Contains("lset") || block.Contains("LSET"))
	{
		int pB = wxMessageBox("LSET command found on your PAUP block.\nDo you want to comment it?", "Paup Block", wxYES | wxNO);
		if(pB == wxYES)
		{
			lsetPos = block.Find("LSET");
			block.Replace("LSET", "[LSET", false);
			if(lsetPos == -1)
			{
				lsetPos = block.Find("Lset");
				block.Replace("Lset", "[Lset", false);
			}
			if(lsetPos == -1)
			{
				lsetPos = block.Find("lset");
				block.Replace("lset", "[lset", false);
			}
			if(lsetPos == 0)
			{
				semiPos = block.First(";");
				block.Replace(";", ";]", false);
			}
		}
	}
	return block;
}
예제 #4
0
int GetSection(wxString& s)
{
    int i, f;
    long r = -1;
    i = s.First('[');
    f = s.Last(']');
    if (f > i)
    {
        s = s.Mid((i + 1), (f - i - 1));
        if (s.IsNumber())
            s.ToLong(&r);
        else
            r = -1;
    }
    return ((int) r);
}
예제 #5
0
bool GetAssociatedDocument( wxWindow* aParent,
                            const wxString& aDocName,
                            const wxPathList* aPaths)

{
    wxString docname, fullfilename;
    wxString msg;
    wxString command;
    bool     success = false;

    // Is an internet url
    static const wxChar* url_header[3] = {
        wxT( "http:" ),
        wxT( "ftp:" ),
        wxT( "www." )
    };

    for( unsigned ii = 0; ii < DIM(url_header); ii++ )
    {
        if( aDocName.First( url_header[ii] ) == 0 )   //. seems an internet url
        {
            wxLaunchDefaultBrowser( aDocName );
            return true;
        }
    }

    docname = aDocName;

#ifdef __WINDOWS__
    docname.Replace( UNIX_STRING_DIR_SEP, WIN_STRING_DIR_SEP );
#else
    docname.Replace( WIN_STRING_DIR_SEP, UNIX_STRING_DIR_SEP );
#endif


    /* Compute the full file name */
    if( wxIsAbsolutePath( aDocName ) || aPaths == NULL)
        fullfilename = aDocName;
    /* If the file exists, this is a trivial case: return the filename
     * "as this".  the name can be an absolute path, or a relative path
     * like ./filename or ../<filename>
     */
    else if( wxFileName::FileExists( aDocName ) )
        fullfilename = aDocName;
    else
    {
        fullfilename = aPaths->FindValidPath( aDocName );
    }

    wxString mask( wxT( "*" ) ), extension;

#ifdef __WINDOWS__
    mask     += wxT( ".*" );
    extension = wxT( ".*" );
#endif

    if( wxIsWild( fullfilename ) )
    {
        fullfilename = EDA_FILE_SELECTOR( _( "Doc Files" ),
                                          wxPathOnly( fullfilename ),
                                          fullfilename,
                                          extension,
                                          mask,
                                          aParent,
                                          wxFD_OPEN,
                                          true,
                                          wxPoint( -1, -1 ) );
        if( fullfilename.IsEmpty() )
            return false;
    }

    if( !wxFileExists( fullfilename ) )
    {
        msg.Printf( _( "Doc File '%s' not found" ), GetChars( aDocName ) );
        DisplayError( aParent, msg );
        return false;
    }

    wxFileName currentFileName( fullfilename );

    wxString file_ext = currentFileName.GetExt();

    if( file_ext == wxT( "pdf" ) )
    {
        success = OpenPDF( fullfilename );
        return success;
    }

    /* Try to launch some browser (useful under linux) */
    wxFileType* filetype;

    wxString    type;
    filetype = wxTheMimeTypesManager->GetFileTypeFromExtension( file_ext );

    if( !filetype )       // 2nd attempt.
    {
        mimeDatabase = new wxMimeTypesManager;
        mimeDatabase->AddFallbacks( EDAfallbacks );
        filetype = mimeDatabase->GetFileTypeFromExtension( file_ext );
        delete mimeDatabase;
        mimeDatabase = NULL;
    }

    if( filetype )
    {
        wxFileType::MessageParameters params( fullfilename, type );

        success = filetype->GetOpenCommand( &command, params );
        delete filetype;

        if( success )
            success = ProcessExecute( command );
    }

    if( !success )
    {
        msg.Printf( _( "Unknown MIME type for doc file <%s>" ), GetChars( fullfilename ) );
        DisplayError( aParent, msg );
    }

    return success;
}
void CDB_driver::ParseOutput(const wxString& output)
{
    m_Cursor.changed = false;
    static wxString buffer;
    buffer << output << _T('\n');

    m_pDBG->DebugLog(output);

    if (rePrompt.Matches(buffer))
    {
        int idx = buffer.First(rePrompt.GetMatch(buffer));
        cbAssert(idx != wxNOT_FOUND);
        m_ProgramIsStopped = true;
        m_QueueBusy = false;
        DebuggerCmd* cmd = CurrentCommand();
        if (cmd)
        {
            RemoveTopCommand(false);
            buffer.Remove(idx);
            if (buffer[buffer.Length() - 1] == _T('\n'))
                buffer.Remove(buffer.Length() - 1);
            cmd->ParseOutput(buffer.Left(idx));
            delete cmd;
            RunQueue();
        }
    }
    else
        return; // come back later

    bool notifyChange = false;

    // non-command messages (e.g. breakpoint hits)
    // break them up in lines
    wxArrayString lines = GetArrayFromString(buffer, _T('\n'));
    for (unsigned int i = 0; i < lines.GetCount(); ++i)
    {
//            Log(_T("DEBUG: ") + lines[i]); // write it in the full debugger log

        if (lines[i].StartsWith(_T("Cannot execute ")))
        {
            Log(lines[i]);
        }
        else if (lines[i].Contains(_T("Access violation")))
        {
            m_ProgramIsStopped = true;
            Log(lines[i]);
            m_pDBG->BringCBToFront();

            Manager::Get()->GetDebuggerManager()->ShowBacktraceDialog();
            DoBacktrace(true);
            InfoWindow::Display(_("Access violation"), lines[i]);
            break;
        }
        else if (notifyChange)
            continue;

        // Breakpoint 0 hit
        // >   38:     if (!RegisterClassEx (&wincl))
        else if (reBP.Matches(lines[i]))
        {
            m_ProgramIsStopped = true;
            Log(lines[i]);
            // Code breakpoint / assert
            m_pDBG->BringCBToFront();
            Manager::Get()->GetDebuggerManager()->ShowBacktraceDialog();
            DoBacktrace(true);
            break;
        }
        else if (lines[i].Contains(_T("Break instruction exception")) && !m_pDBG->IsTemporaryBreak())
        {
            m_ProgramIsStopped = true;
        	// Code breakpoint / assert
            m_pDBG->BringCBToFront();
            Manager::Get()->GetDebuggerManager()->ShowBacktraceDialog();
            DoBacktrace(true);
            break;
        }
    }

    if (notifyChange)
        NotifyCursorChanged();

    buffer.Clear();
}
예제 #7
0
wxString Boat::repeatAreaODT( wxString odt )
{
    wxString topODT;
    wxString bottomODT;
    wxString middleODT;

    wxString seperatorTop = wxT( "{{" );
    wxString seperatorBottom = wxT( "}}" );

    int indexTop = odt.First( seperatorTop )+seperatorTop.Len();
    int indexBottom = odt.First( seperatorBottom )+seperatorBottom.Len();

    topODT = odt.substr( 0,indexTop );
    middleODT = odt.substr( indexTop+9 );
    indexTop = topODT.find_last_of( '<' );
    topODT = odt.substr( 0,indexTop );
    bottomODT = odt.substr( indexBottom,odt.Len()-1 );
    indexBottom = bottomODT.find_first_of( '>' )+1;
    bottomODT = bottomODT.substr( indexBottom,odt.Len()-1 );

    middleODT.Replace( bottomODT,_T( "" ) );
    indexBottom = middleODT.First( seperatorBottom )+seperatorBottom.Len();
    middleODT = middleODT.substr( 0,indexBottom-1 );
    indexBottom = middleODT.find_last_of( '<' );
    middleODT = middleODT.substr( 0,indexBottom );

    topODT.Replace( _T( "#LEQUIP#" ),parent->sbSizer12->GetStaticBox()->GetLabel() );
    topODT.Replace( _T( "#LETYPE#" ),parent->m_gridEquipment->GetColLabelValue( 0 ) );
    topODT.Replace( _T( "#LDISCRIPTION#" ),parent->m_gridEquipment->GetColLabelValue( 1 ) );
    topODT.Replace( _T( "#LSERIAL#" ),parent->m_gridEquipment->GetColLabelValue( 2 ) );
    topODT.Replace( _T( "#LREMARKS#" ),parent->m_gridEquipment->GetColLabelValue( 3 ) );

    wxString newMiddleODT = _T( "" );
    for ( int i = 0; i < parent->m_gridEquipment->GetNumberRows(); i++ )
    {
        wxString temp = middleODT;
        for ( int c = 0; c < parent->m_gridEquipment->GetNumberCols(); c++ )
        {
            wxString text = parent->m_gridEquipment->GetCellValue( i,c );

            switch ( c )
            {
            case 0:
                temp.Replace( _T( "#ETYPE#" ),text );
                break;
            case 1:
                temp.Replace( _T( "#DISCRIPTION#" ),text );
                break;
            case 2:
                temp.Replace( _T( "#SERIAL#" ),text );
                break;
            case 3:
                temp.Replace( _T( "#REMARKS#" ),text );
                break;
            }
        }
        newMiddleODT += temp;
    }

    odt = topODT + newMiddleODT + bottomODT;
    return odt;
}