예제 #1
0
bool BaseDialog::existID( wxWindow* dlg, iONode list, iONode props, wxString  id ) {
  if( StrOp.equals( wItem.getid(props), id.mb_str(wxConvUTF8) ) ) {
    return false;
  }

  if( id.Len() == 0 ) {
    wxMessageDialog( dlg, wxGetApp().getMsg("invalidid"), _T("Rocrail"), wxOK | wxICON_ERROR ).ShowModal();
    return true;
  }
  if( id.Contains(wxT(",")) || id.Contains(wxT(";")) || id.Contains(wxT(":")) ) {
    wxMessageDialog( dlg, wxGetApp().getMsg("invalidchars"), _T("Rocrail"), wxOK | wxICON_ERROR ).ShowModal();
    return true;
  }
  if( list != NULL ) {
    int cnt = NodeOp.getChildCnt( list );
    for( int i = 0; i < cnt; i++ ) {
      iONode child = NodeOp.getChild( list, i );
      if( StrOp.equals( wItem.getid(child), id.mb_str(wxConvUTF8) )) {
        wxMessageDialog( dlg,
            wxString::Format(wxGetApp().getMsg("existingid"), wItem.getx(child), wItem.gety(child)) + _T("\n") + wxString(wItem.getdesc(child),wxConvUTF8),
            _T("Rocrail"), wxOK | wxICON_ERROR ).ShowModal();
        return true;
      }
    }
  }
  return false;
}
예제 #2
0
bool CourseTrainerApp::OnInit()
{
    #ifdef WINDOWS
        CreateMutexA(0, FALSE, "Local\\$myprogram$"); // try to create a named mutex
        if(GetLastError() == ERROR_ALREADY_EXISTS) // did the mutex already exist?
        {
            wxMessageDialog(NULL, "Another process already running.","Error").ShowModal();
            return false;
        }
    #else
        pid_t pid = getpid();
        std::stringstream command;
        command << "ps -eo pid,comm | grep CourseTrainer | grep -v " << pid;
        int isRuning = system(command.str().c_str());

        if (isRuning==0)
        {
            wxMessageDialog(NULL, "Another process already running.","Error").ShowModal();
            return false;
        }
    #endif // WINDOWS
    frame = new CourseTrainerFrame(0L, _("Course Calculatings"));
    WelcomeScreen* dialog=new WelcomeScreen(nullptr,wxID_ANY,"Identification",frame);
    dialog->Show();
    return true;
}
예제 #3
0
void Softwareupdates::OnOkClick( wxCommandEvent& event )
{
  const char* path = wGui.getupdatespath(wxGetApp().getIni());
  if( !FileOp.exist(path) )
    FileOp.mkdir(path);
    
  /* download */
  m_Ready = false;
  iOThread updateLoader = ThreadOp.inst( "update", _updateLoader, this );
  ThreadOp.start( updateLoader );
  
  bool rc = m_Timer->Start( 100, true );
  
  m_Progress = new wxProgressDialog(wxGetApp().getMsg( "softwareupdates" ), wxGetApp().getMsg( "downloadingupdates" ), 
      2, NULL, wxPD_CAN_ABORT | wxPD_AUTO_HIDE | wxPD_APP_MODAL );
  m_Progress->ShowModal();

  if(m_Ready && m_DownloadOK ) {
    wxMessageDialog( this, wxGetApp().getMsg("successfullydownloaded"), 
        wxGetApp().getMsg("softwareupdates"), wxOK | wxICON_INFORMATION ).ShowModal();
  }
  else {
    wxMessageDialog( this, wxGetApp().getMsg("errorondownloading"), 
        wxGetApp().getMsg("softwareupdates"), wxOK | wxICON_ERROR ).ShowModal();
  }
  
  NodeOp.base.del( m_ReleaseNode );
  delete m_Timer;
  EndModal(wxID_OK);
}
예제 #4
0
VlcVideoPlayer::VlcVideoPlayer(wxWindow* win, const VideoID& id, wxPoint pt, wxSize size)
    : wxPanel(win, wxID_ANY, pt, size), videoID_(id), firstPlay_(1)
{
	SetBackgroundColour(axColor(0, 0, 0));

	_DEBUG_ nb_time_callback = 0;

    // Create new VLC instance.
    char const* vlcOptions[] = {"--no-video-title-show"}; //Hide filename.

	vlcInstance = NULL;
	vlcPlayer = NULL;

    // Create VLC instance
	vlcInstance = libvlc_new(1, vlcOptions);

    if( vlcInstance )
	{
		vlcPlayer = libvlc_media_player_new(vlcInstance);

		// Create VLC player
		if( vlcPlayer )
		{
			// Create VLC EventManager
			vlcEventManager = libvlc_media_player_event_manager(vlcPlayer);

			if( !vlcEventManager )
			{
				_DEBUG_ DSTREAM << "Can't create VLC Event Manager" << endl;
				wxMessageDialog (this, "Can't create VLC Event Manager");
			}
		}
		else // vlcPlayer
		{
			_DEBUG_ DSTREAM << "Can't create player from vlcMedia" << endl;
			wxMessageDialog (this, "Can't create player from vlcMedia");
		}
	}

    else // vlcInstance.
	{
		_DEBUG_ DSTREAM << "Can't Open VLC instance" << endl;
		wxMessageDialog (this, "Can't Open VLC instance");
	}

    // libVLC events and callback
	if( vlcInstance && vlcPlayer && vlcEventManager )
	{
		libvlc_event_attach(vlcEventManager, 
							libvlc_MediaPlayerPositionChanged, 
							VlcVideoPlayer::vlcPositionChanged, 
							this);
		
		libvlc_event_attach(vlcEventManager, 
							libvlc_MediaPlayerTimeChanged, 
							VlcVideoPlayer::vlcTimeChanged, 
							this);
	}
}
예제 #5
0
void AccDecDlg::onDelete( wxCommandEvent& event )
{
    TraceOp.trc( "accdecdlg", TRCLEVEL_INFO, __LINE__, 9999, "Delete" );
    if( m_Props != NULL ) {
        int action = wxMessageDialog( this, wxGetApp().getMsg("removewarning"), _T("Rocrail"), wxYES_NO | wxICON_EXCLAMATION ).ShowModal();
        if( action == wxID_NO )
            return;

        wxGetApp().pushUndoItem( (iONode)NodeOp.base.clone( m_Props ) );

        /* Notify RocRail. */
        iONode cmd = NodeOp.inst( wModelCmd.name(), NULL, ELEMENT_NODE );
        wModelCmd.setcmd( cmd, wModelCmd.remove );
        NodeOp.addChild( cmd, (iONode)m_Props->base.clone( m_Props ) );
        wxGetApp().sendToRocrail( cmd );
        cmd->base.del(cmd);

        iONode model = wxGetApp().getModel();
        if( model != NULL ) {
            iONode declist = wPlan.getdeclist( model );
            if( declist != NULL ) {
                NodeOp.removeChild( declist, m_Props );
                m_Props = selectPrev();
            }
        }

        initIndex();
    }
}
예제 #6
0
bool StageDlg::evaluate() {
  if( m_ID->GetValue().Len() == 0 ) {
    wxMessageDialog( this, wxGetApp().getMsg("invalidid"), _T("Rocrail"), wxOK | wxICON_ERROR ).ShowModal();
    m_ID->SetValue( wxString(wStage.getid( m_Props ),wxConvUTF8) );
    return false;
  }
  // evaluate General
  wItem.setprev_id( m_Props, wItem.getid(m_Props) );
  wStage.setid( m_Props, m_ID->GetValue().mb_str(wxConvUTF8) );
  wStage.setdesc( m_Props, m_Description->GetValue().mb_str(wxConvUTF8) );
  wStage.setslen( m_Props, m_SectionLength->GetValue() );
  wStage.setgap( m_Props, m_TrainGap->GetValue() );
  wStage.setfbenterid( m_Props, m_EnterSensor->GetStringSelection().mb_str(wxConvUTF8) );
  wStage.setentersignal( m_Props, m_EnterSignal->GetStringSelection().mb_str(wxConvUTF8) );
  wStage.setexitsignal( m_Props, m_ExitSignal->GetStringSelection().mb_str(wxConvUTF8) );
  wStage.setrandomrate( m_Props, m_RandomRate->GetValue() );

  // Details
  wStage.setdepartdelay( m_Props, m_DepartDelay->GetValue() );
  wStage.setminocc( m_Props, m_MinOcc->GetValue() );


  if( m_WaitType->GetSelection() == 0 )
    wStage.setwaitmode( m_Props, wBlock.wait_random );
  else if( m_WaitType->GetSelection() == 1 )
    wStage.setwaitmode( m_Props, wBlock.wait_fixed );
  else if( m_WaitType->GetSelection() == 1 )
    wStage.setwaitmode( m_Props, wBlock.wait_loc );
  else
    wStage.setwaitmode( m_Props, wBlock.wait_none );

  wStage.setminwaittime( m_Props, m_RandomMin->GetValue() );
  wStage.setmaxwaittime( m_Props, m_RandomMax->GetValue() );
  wStage.setwaittime( m_Props, m_Fixed->GetValue() );

  if( m_ExitSpeed->GetSelection() == 0 )
    wStage.setexitspeed( m_Props, wBlock.min );
  else if( m_ExitSpeed->GetSelection() == 1 )
    wStage.setexitspeed( m_Props, wBlock.mid );
  else if( m_ExitSpeed->GetSelection() == 2 )
    wStage.setexitspeed( m_Props, wBlock.cruise );
  else if( m_ExitSpeed->GetSelection() == 3 )
    wStage.setexitspeed( m_Props, wBlock.max );
  else if( m_ExitSpeed->GetSelection() == 4 )
    wStage.setexitspeed( m_Props, wBlock.percent );

  if( m_ArriveSpeed->GetSelection() == 0 )
    wStage.setstopspeed( m_Props, wBlock.min );
  else if( m_ArriveSpeed->GetSelection() == 1 ) {
    wStage.setstopspeed( m_Props, wBlock.percent );
  }
  wStage.setspeedpercent( m_Props, m_ArriveSpeedPercent->GetValue() );
  wStage.setexitspeedpercent( m_Props, m_DepartSpeedPercent->GetValue() );
  wStage.setsuitswell( m_Props, m_SuitsWell->IsChecked() ? True:False );
  wStage.setinatlen( m_Props, m_InAtLen->IsChecked() ? True:False );
  wStage.setusewd( m_Props, m_UseWD->IsChecked() ? True:False );
  wStage.setelectrified( m_Props, m_Electrified->GetValue()?True:False );

  return true;
}
bool TileSetEditor::switchTileSet(const std::string& newtileset)
{
    saveTileSet();

    delete currenttileset;
    currenttileset = 0;
    tilesetview->setTileSet(0);    
    
    try {
        filename = "/tileset/";
        filename += newtileset;

        currenttileset = new TileSet();
        currenttileset->load(newtileset);

        tilesetview->setTileSet(currenttileset);
    } catch(std::exception& e) {
        std::string errormsg = "Couldn't switch Tileset to '";
        errormsg += newtileset ;
        errormsg += "' : ";
        errormsg += e.what();
        wxMessageDialog(this, errormsg.c_str(),
                "Error", wxOK | wxICON_ERROR).ShowModal();
        return false;
    }

    return true;
}
예제 #8
0
void WeatherDlg::onDeleteWeather( wxCommandEvent& event ) {
  if( m_Props == NULL )
    return;

  int action = wxMessageDialog( this, wxGetApp().getMsg("removewarning"), _T("Rocrail"), wxYES_NO | wxICON_EXCLAMATION ).ShowModal();
  if( action == wxID_NO )
    return;

  wxGetApp().pushUndoItem( (iONode)NodeOp.base.clone( m_Props ) );
  /* Notify RocRail. */
  iONode cmd = NodeOp.inst( wModelCmd.name(), NULL, ELEMENT_NODE );
  wModelCmd.setcmd( cmd, wModelCmd.remove );
  NodeOp.addChild( cmd, (iONode)m_Props->base.clone( m_Props ) );
  wxGetApp().sendToRocrail( cmd );
  cmd->base.del(cmd);

  iONode model = wxGetApp().getModel();
  if( model != NULL ) {
    iONode weatherlist = wPlan.getweatherlist( model );
    if( weatherlist != NULL ) {
      NodeOp.removeChild( weatherlist, m_Props );
      m_Props = NULL;
      m_RGBWPanel->setWeather(m_Props, m_SelectedRow, m_ColorWhite->IsChecked(), m_ColorBrightness->IsChecked(), m_ColorSaturation->IsChecked(), m_ColorWhite2->IsChecked());

    }
  }
  initIndex();
}
예제 #9
0
void CmdRecorder::onExport( wxCommandEvent& event )
{
  const char* l_openpath = wGui.getopenpath( wxGetApp().getIni() );
  wxString ms_FileExt = _T("Commands (*.txt)|*.txt");
  wxFileDialog* fdlg = new wxFileDialog(this, wxGetApp().getMenu("export"), wxString(l_openpath,wxConvUTF8), _T(""), ms_FileExt, wxFD_SAVE);
  if( fdlg->ShowModal() == wxID_OK ) {
    iONode model = wxGetApp().getModel();
    // Check for existence.
    wxString path = fdlg->GetPath();
    if( FileOp.exist( path.mb_str(wxConvUTF8) ) ) {
      int action = wxMessageDialog( this, wxGetApp().getMsg("fileexistwarning"), _T("Rocrail"), wxYES_NO | wxICON_EXCLAMATION ).ShowModal();
      if( action == wxID_NO ) {
        fdlg->Destroy();
        return;
      }
    }
    if( !path.Contains( _T(".txt") ) )
      path.Append( _T(".txt") );

    iOFile f = FileOp.inst( path.mb_str(wxConvUTF8), OPEN_WRITE );
    if( f != NULL ) {
      const char* cmds = ScriptOp.base.toString(wxGetApp().getScript());
      FileOp.writeStr(f, cmds);
      FileOp.base.del( f );
    }

  }

  fdlg->Destroy();
}
예제 #10
0
void VariableDlg::onDelete( wxCommandEvent& event )
{
  if( m_Props == NULL )
    return;

  int action = wxMessageDialog( this, wxGetApp().getMsg("removewarning"), _T("Rocrail"), wxYES_NO | wxICON_EXCLAMATION ).ShowModal();
  if( action == wxID_NO )
    return;

  wxGetApp().pushUndoItem( (iONode)NodeOp.base.clone( m_Props ) );
  /* Notify RocRail. */
  iONode cmd = NodeOp.inst( wModelCmd.name(), NULL, ELEMENT_NODE );
  wModelCmd.setcmd( cmd, wModelCmd.remove );
  NodeOp.addChild( cmd, (iONode)m_Props->base.clone( m_Props ) );
  wxGetApp().sendToRocrail( cmd );
  cmd->base.del(cmd);

  iONode model = wxGetApp().getModel();
  if( model != NULL ) {
    iONode varlist = wPlan.getvrlist( model );
    if( varlist != NULL ) {
      NodeOp.removeChild( varlist, m_Props );
      m_Props = NULL;
    }
  }

  initIndex();
}
예제 #11
0
bool AccDecDlg::evaluate() {
    if( m_Props == NULL )
        return false;

    TraceOp.trc( "accdecdlg", TRCLEVEL_INFO, __LINE__, 9999, "evaluate %s", wDec.getid( m_Props ) );

    if( m_ID->GetValue().Len() == 0 ) {
        wxMessageDialog( this, wxGetApp().getMsg("invalidid"), _T("Rocrail"), wxOK | wxICON_ERROR ).ShowModal();
        m_ID->SetValue( wxString(wDec.getid( m_Props ),wxConvUTF8) );
        return false;
    }
    // evaluate General
    wItem.setprev_id( m_Props, wItem.getid(m_Props) );
    wDec.setiid( m_Props, m_IID->GetValue().mb_str(wxConvUTF8) );
    wDec.setid( m_Props, m_ID->GetValue().mb_str(wxConvUTF8) );
    wDec.setbus( m_Props, atoi(m_Bus->GetValue().mb_str(wxConvUTF8)) );
    wDec.setaddr( m_Props, m_Addr->GetValue() );
    wDec.setdesc( m_Props, m_Desc->GetValue().mb_str(wxConvUTF8) );

    if( m_Protocol->GetSelection() == 1 )
        wDec.setprot( m_Props, wSwitch.prot_M );
    else if( m_Protocol->GetSelection() == 2 )
        wDec.setprot( m_Props, wSwitch.prot_N );
    else
        wDec.setprot( m_Props, wSwitch.prot_DEF );

    wDec.setprotver( m_Props, m_Version->GetValue() );
    wDec.setmanu( m_Props, m_Manu->GetValue().mb_str(wxConvUTF8) );
    wDec.setcatnr( m_Props, m_CatNr->GetValue().mb_str(wxConvUTF8) );
    wDec.setimage( m_Props, m_ImageFile->GetValue().mb_str(wxConvUTF8) );

    return true;
}
예제 #12
0
bool App::OnInit() {
   SetAppName(u8"flutterrust");
   SetAppDisplayName(u8"flutterrust");

   const wxFileName exeFileName{wxStandardPaths::Get().GetExecutablePath()};
   const std::string exePath = exeFileName.GetPath().ToStdString();
   try {
      Creature::loadTypes(exePath + static_cast<char>(wxFileName::GetPathSeparator()) +
                          u8"CreatureTable.txt");
      mainFrame = new MainFrame{exePath};
   } catch (const std::exception& e) {
      wxMessageDialog dialog{nullptr, u8"Exception caught.  Terminating.\n",
                             u8"Fatal error", wxICON_ERROR | wxOK};
      dialog.SetExtendedMessage(std::string{typeid(e).name()} + ": \"" + e.what() + '"');
      dialog.ShowModal();
      return false;  // Exit the application immediately.
   } catch (...) {
      wxMessageDialog(nullptr, u8"Unknown exception caught.  Terminating.",
                      u8"Fatal error", wxICON_ERROR | wxOK)
          .ShowModal();
      return false;
   }

   mainFrame->Show(true);
   SetTopWindow(mainFrame);

   return true;  // Continue processing.
}
예제 #13
0
bool VlcVideoPlayer::loadVideo(const char* path)
{
	if(vlcMedia = libvlc_media_new_path(vlcInstance, path))
	{
        libvlc_media_player_set_media(vlcPlayer, vlcMedia);
        libvlc_media_release(vlcMedia);

        // Needed for mixing VLC and wxWidgets.
        // Needs to be after above calls, or else bug with stop button!
        libvlc_media_player_set_hwnd( vlcPlayer, reinterpret_cast<void *> ( (HWND)this->GetHandle() ) );

		/// @todo ????
        // Stuff
        //libvlc_media_player_next_frame(vlcPlayer);
		//libvlc_video_set_format(vlcPlayer);

        _DEBUG_ DSTREAM << "Loaded video file." << endl;
    }
    else
    {
		_DEBUG_ DSTREAM << "Can't load media from path" << endl;
		wxMessageDialog (this, "Can't load media from path");

        return false;
    }

    return true; // Didn't fails loading.
}
예제 #14
0
bool BlockGroupingDialog::evaluate() {
  if( m_Props == NULL )
    return false;

  if( m_ID->GetValue().Len() == 0 ) {
    wxMessageDialog( this, wxGetApp().getMsg("invalidid"), _T("Rocrail"), wxOK | wxICON_ERROR ).ShowModal();
    m_ID->SetValue( wxString(wLink.getid( m_Props ),wxConvUTF8) );
    return false;
  }
  // General
  wLink.setid( m_Props, m_ID->GetValue().mb_str(wxConvUTF8) );
  wLink.setdesc ( m_Props, m_Desc->GetValue().mb_str(wxConvUTF8) );

  // Properties
  wLink.setsrc( m_Props, m_MainBlock->GetValue().mb_str(wxConvUTF8) );

  wLink.setusage( m_Props, (m_Critical->IsChecked() ? wLink.usage_critsect : wLink.usage_manual ) );
  wLink.setallowfollowup( m_Props, m_AllowFollowUp->IsChecked() ? True:False );
  wLink.setmaxfollowup( m_Props, m_MaxFollowUp->GetValue() );


  int cnt = m_BlockList->GetCount();
  char* dst = NULL;
  for( int i = 0; i < cnt; i++ ) {
    if( i > 0 )
      dst = StrOp.cat( dst, "," );
    dst = StrOp.cat( dst, m_BlockList->GetString(i).mb_str(wxConvUTF8) );
  }
  if( dst != NULL ) {
    wLink.setdst( m_Props, dst );
    StrOp.free( dst );
  }

  return true;
}
	void
	TraceLogPanelLogic::on_load(wxEvent& event)
	{
		wxFileDialog wx_file_dialog(_map_scrolled_window, wxT("Choose a file"), 
			wxT(""), wxT(""), wxT("*"), wxOPEN | wxFILE_MUST_EXIST, wxDefaultPosition);
		
		int dialog_result = wx_file_dialog.ShowModal();
		
		if (dialog_result != wxID_OK) return;
		
		std::ifstream _file_stream(
			(wx_file_dialog.GetDirectory()+ wxT("/") + 
				wx_file_dialog.GetFilename()).mb_str(),
			std::ifstream::in | std::ifstream::binary);
			
		if (_file_stream.good())
		{
			_trace_log.load(_file_stream);
			set_tile_cache(_trace_log.tile_cache());
			_map_scrolled_window->Refresh();
		} else
		{
			wxMessageDialog(_map_scrolled_window, wxT("Could not open file!"),
			wxT("Error!"), wxOK, wxDefaultPosition).ShowModal();
			
		}
		
		_file_stream.close();
	}
예제 #16
0
bool TopedApp::LoadFontFile(std::string fontname)
{
    wxString fontFile;
    fontFile << tpdFontDir << wxString(fontname.c_str(), wxConvUTF8) << wxT(".glf");
    wxFileName fontFN(fontFile);
    fontFN.Normalize();
    if (!(fontFN.IsOk() && (-1 != glfLoadFont(fontFN.GetFullPath().mb_str()))))
    {
        wxString errmsg;
        bool wbox_status = true;
        errmsg << wxT("Font library \"") << fontFN.GetFullPath() << wxT("\" not found or corrupted. \n") <<
               wxT("Toped will be unstable.\n Continue?");
        wxMessageDialog* dlg1 = DEBUG_NEW  wxMessageDialog(Toped,
                                errmsg,
                                wxT("Toped"),
                                wxYES_NO | wxICON_WARNING);
        if (wxID_NO == dlg1->ShowModal())
            wbox_status = false;
        dlg1->Destroy();
        if (wbox_status)
        {
            std::string info("Font library is not loaded. All text objects will not be properly processed");
            tell_log(console::MT_ERROR,info);
        }
        return wbox_status;
    }
    else
        return true;
}
예제 #17
0
void ABoxDlg::onOK( wxCommandEvent& event ) {
  if( StrOp.len(m_AddedFilename) > 0 ) {
    char* tip = StrOp.fmt( wxGetApp().getCMsg("uploadingfile"), m_AddedFilename );
    int action = wxMessageDialog( this, wxString(tip,wxConvUTF8), _T("Rocrail"), wxOK | wxCANCEL | wxICON_EXCLAMATION ).ShowModal();
    StrOp.free(tip);
    if( action == wxID_OK )
      return;
  }
  if( StrOp.len(m_DownloadFilename) > 0 ) {
    char* tip = StrOp.fmt( wxGetApp().getCMsg("downloadingfile"), m_DownloadFilename );
    int action = wxMessageDialog( this, wxString(tip,wxConvUTF8), _T("Rocrail"), wxOK | wxCANCEL | wxICON_EXCLAMATION ).ShowModal();
    StrOp.free(tip);
    if( action == wxID_OK )
      return;
  }
  EndModal( wxID_OK );
}
bool TREEPROJECT_ITEM::Rename( const wxString& name, bool check )
{
    // this is broken & unsafe to use on linux.
    if( m_Type == TREE_DIRECTORY )
        return false;

    if( name.IsEmpty() )
        return false;

    const wxString  sep = wxFileName().GetPathSeparator();
    wxString        newFile;
    wxString        dirs = GetDir();

    if( !dirs.IsEmpty() && GetType() != TREE_DIRECTORY )
        newFile = dirs + sep + name;
    else
        newFile = name;

    if( newFile == GetFileName() )
        return false;

    wxString    ext = TREE_PROJECT_FRAME::GetFileExt( GetType() );

    wxRegEx     reg( wxT( "^.*\\" ) + ext + wxT( "$" ), wxRE_ICASE );

    if( check && !ext.IsEmpty() && !reg.Matches( newFile ) )
    {
        wxMessageDialog dialog( m_parent, _(
            "Changing file extension will change file type.\n Do you want to continue ?" ),
            _( "Rename File" ),
            wxYES_NO | wxICON_QUESTION );

        if( wxID_YES != dialog.ShowModal() )
            return false;
    }

#if ( ( wxMAJOR_VERSION < 2 ) || ( ( wxMAJOR_VERSION == 2 ) \
    && ( wxMINOR_VERSION < 7 )  ) )

    if( !wxRenameFile( GetFileName(), newFile ) )
#else

    if( !wxRenameFile( GetFileName(), newFile, false ) )
#endif
    {
        wxMessageDialog( m_parent, _( "Unable to rename file ... " ),
                         _( "Permission error ?" ), wxICON_ERROR | wxOK );
        return false;
    }

#ifndef KICAD_USE_FILES_WATCHER
    SetFileName( newFile );
#endif

    return true;
}
예제 #19
0
void ABoxDlg::executeStub(const char* filepath) {
  wxFileType *filetype=wxTheMimeTypesManager->GetFileTypeFromExtension(wxString(StrOp.getExtension(filepath),wxConvUTF8));
  if( filetype == NULL ) {
    char* tip = StrOp.fmt( wxGetApp().getCMsg("nodefaultapplicationfound"), filepath );
    int action = wxMessageDialog( this, wxString(tip,wxConvUTF8), _T("Rocrail"), wxOK | wxICON_EXCLAMATION ).ShowModal();
    StrOp.free(tip);
    return;
  }
  wxString command=filetype->GetOpenCommand(wxString(filepath,wxConvUTF8));
  TraceOp.trc( "aboxdlg", TRCLEVEL_INFO, __LINE__, 9999, "execute [%s]", (const char*)command.mb_str(wxConvUTF8) );
  if( command.IsEmpty() ) {
    // No default application...
    char* tip = StrOp.fmt( wxGetApp().getCMsg("nodefaultapplicationfound"), filepath );
    int action = wxMessageDialog( this, wxString(tip,wxConvUTF8), _T("Rocrail"), wxOK | wxICON_EXCLAMATION ).ShowModal();
    StrOp.free(tip);
  }
  else {
    wxExecute(command);
  }
}
예제 #20
0
void pnlRepeater::OnbtnLoadCoeffsRXClick(wxCommandEvent& event)
{
    wxFileDialog dlg(this, _("Open coefficients file"), "", "", "FIR Coeffs (*.fir)|*.fir", wxFD_OPEN|wxFD_FILE_MUST_EXIST);
    if(dlg.ShowModal() == wxID_CANCEL)
        return;

    int cbuf[200];
    int coefCount = Parser::getcoeffs((const char*)dlg.GetPath().ToStdString().c_str(), cbuf, 200);

    switch(coefCount)
    {
    case -2:
        wxMessageDialog(this, "syntax error within the file", "Warning");
        break;
    case -3:
        wxMessageDialog(this, "filename is empty string", "Warning");
        break;
    case -4:
        wxMessageDialog(this, "can not open the file", "Warning");
        break;
    case -5:
        wxMessageDialog(this, "too many coefficients in the file", "Warning");
        break;
    }
    if(coefCount < 0)
        return;

    if(coefCount > 15)
        coefCount = 15;

    GenericPacket pkt;
    pkt.cmd = CMD_BRDSPI16_WR;
    pkt.outLen = 2*coefCount*sizeof(unsigned short);
    short* shortBuf = (short*)&pkt.outBuffer[0];
    for(int i=0; i<coefCount; ++i)
    {
        shortBuf[2*i] = 0x300+i; //address
        shortBuf[2*i+1] = cbuf[i]; //value
    }
    mSerPort->TransferPacket(pkt);
}
예제 #21
0
파일: assdraw.cpp 프로젝트: Aegisub/assdraw
void ASSDrawFrame::OnClose(wxCloseEvent &event)
{
	if (event.CanVeto() && behaviors.confirmquit)
	{
		if (wxMessageDialog(this, _T("Do you want to close ASSDraw3 now?"), _T("Confirmation"), wxOK | wxCANCEL).ShowModal() == wxID_OK)
			Destroy();
		else
			event.Veto();
	}
	else
		Destroy();
}
예제 #22
0
void dlgGFIR_Coefficients::OnbtnLoadFileClick(wxCommandEvent& event)
{
    wxFileDialog dlg(this, _("Open coefficients file"), "", "", "FIR Coeffs (*.fir)|*.fir", wxFD_OPEN|wxFD_FILE_MUST_EXIST);
    if(dlg.ShowModal() == wxID_CANCEL)
        return;

    int cbuf[200];
    int iVal = Parser::getcoeffs((const char*)dlg.GetPath().ToStdString().c_str(), cbuf, 200);

    switch(iVal)
    {
    case -2:
        wxMessageDialog(this, "syntax error within the file", "Warning");
        break;
    case -3:
        wxMessageDialog(this, "filename is empty string", "Warning");
        break;
    case -4:
        wxMessageDialog(this, "can not open the file", "Warning");
        break;
    case -5:
        wxMessageDialog(this, "too many coefficients in the file", "Warning");
        break;
    }
    if(iVal < 0)
        return;

    txtFilename->SetLabel(dlg.GetPath());

    spinCoefCount->SetValue(iVal);
    if(gridCoef->GetTable()->GetRowsCount() > 0)
        gridCoef->GetTable()->DeleteRows(0, gridCoef->GetTable()->GetRowsCount());
    gridCoef->GetTable()->AppendRows( spinCoefCount->GetValue());
    for(int i=0; i<iVal; ++i)
    {
        gridCoef->SetCellValue(i, 0, wxString::Format("%i", cbuf[i]));
    }
}
예제 #23
0
void CServerConsole::OnClose(wxCloseEvent& event){
	if(!mapClients.empty()){
		if(event.CanVeto() && wxMessageDialog(this, wxString::FromAscii("Do you really want to quit?"),
                                wxString::FromAscii("Warning!"), 
								wxYES_NO | wxYES_DEFAULT | wxCENTRE).ShowModal() == wxID_NO){
			event.Veto();
			return;
		}else{
			HashMapClients::iterator	it;
			for (it = this->mapClients.begin(); it != this->mapClients.end(); it++)
				this->CloseClient(it->first);
		}
	}
	Destroy();
}
void TileSetEditor::saveTileSet()
{
    try {
        if(currenttileset) {
            currenttileset->save();
        }                                                                 
    } catch(std::exception& e) {
        std::string errormsg = "Couldn't save Tileset to '";
        errormsg += filename ;
        errormsg += "' : ";
        errormsg += e.what();
        wxMessageDialog(this, errormsg.c_str(),
                "Error", wxOK | wxICON_ERROR).ShowModal();
    }
}
예제 #25
0
void ABoxDlg::onDelete( wxCommandEvent& event ) {
  if( m_SelectedStub != wxNOT_FOUND ) {
    int action = wxMessageDialog( this, wxGetApp().getMsg("removewarning"), _T("Rocrail"), wxYES_NO | wxICON_EXCLAMATION ).ShowModal();
    if( action == wxID_NO )
      return;
    iONode stub = (iONode)m_Stubs->GetItemData(m_SelectedStub);
    iONode cmd = NodeOp.inst( wDataReq.name(), NULL, ELEMENT_NODE );
    wDataReq.setcmd( cmd, wDataReq.abox_deletelink );
    NodeOp.addChild(cmd, (iONode)NodeOp.base.clone(stub));
    wxGetApp().sendToRocrail( cmd );
    cmd->base.del(cmd);

    onFind(event);
  }
}
예제 #26
0
bool CServerConsole::CommandMessage(ClientIDData *pClient, CParametersMap &paramsIn, CParametersMap &paramsOut, CServerConsole *pThis)
{
	wxString	strMsg;

	if (!paramsIn.GetString(wxString::FromAscii("message"), &strMsg))
	{
		paramsOut.SetString(wxString::FromAscii("error"),
                            wxString::FromAscii("No 'message' field"));
		return false;
	}

	pClient->pWindow->Raise();
	wxMessageDialog(pClient->pWindow, strMsg, wxString::FromAscii("Message"), wxOK | wxCENTRE).ShowModal();
	
	return true;
}
예제 #27
0
void CClientFrame::OnClose(wxCloseEvent& event)
{
	if (event.CanVeto())
	{
		if (wxMessageDialog(this, _T("Client didn't request to close the window."
			"Do you really want to close it now?"), _T("Warning!"),
			wxYES_NO | wxYES_DEFAULT | wxCENTRE).ShowModal() == wxID_NO)
		{
			event.Veto();
			return;
		}
	}

	Destroy();
	((CServerConsole*)m_pConsole)->OnClientFrameClosed(m_iClientID);
}
예제 #28
0
bool pgDatabase::DropObject(wxFrame *frame, ctlTree *browser, bool cascaded)
{
	if (useServerConnection)
	{
		wxMessageDialog(frame, _("Maintenance database can't be dropped."),
		                _("Dropping database not allowed"), wxICON_EXCLAMATION | wxOK).ShowModal();

		return false;
	}
	Disconnect();

	bool done = server->ExecuteVoid(wxT("DROP DATABASE ") + GetQuotedIdentifier() + wxT(";"));
	if (!done)
		Connect();

	return done;
}
예제 #29
0
void StageDlg::OnFreeAll( wxCommandEvent& event ) {
  int action = wxMessageDialog( this, wxGetApp().getMsg("freeallwarning"), _T("Rocrail"), wxYES_NO | wxICON_EXCLAMATION ).ShowModal();
  if( action == wxID_NO )
    return;

  iONode section = wStage.getsection(m_Props);
  while( section != NULL ) {
    wStageSection.setlcid(section, NULL);
    section = wStage.nextsection(m_Props, section);
  }
  initSections();

  m_SectionLocoId->SetSelection(0);
  iONode cmd = NodeOp.inst( wStage.name(), NULL, ELEMENT_NODE );
  wStage.setid( cmd, wStage.getid( m_Props ) );
  wStage.setcmd( cmd, wBlock.loc );
  wxGetApp().sendToRocrail( cmd );
  cmd->base.del(cmd);
}
예제 #30
0
bool VariableDlg::evaluate() {
  if( m_Props == NULL )
    return false;

  TraceOp.trc( "vardlg", TRCLEVEL_INFO, __LINE__, 9999, "Evaluate %s", wVariable.getid( m_Props ) );

  if( m_ID->GetValue().Len() == 0 ) {
    wxMessageDialog( this, wxGetApp().getMsg("invalidid"), _T("Rocrail"), wxOK | wxICON_ERROR ).ShowModal();
    m_ID->SetValue( wxString(wVariable.getid( m_Props ),wxConvUTF8) );
    return false;
  }
  // evaluate General
  wVariable.setid( m_Props, m_ID->GetValue().mb_str(wxConvUTF8) );
  wVariable.setgroup( m_Props, m_Group->GetValue().mb_str(wxConvUTF8) );
  wVariable.setdesc( m_Props, m_Desc->GetValue().mb_str(wxConvUTF8) );
  wVariable.setmin( m_Props, m_MinValue->GetValue() );
  wVariable.setmax( m_Props, m_MaxValue->GetValue() );
  wVariable.settext( m_Props, m_Text->GetValue().mb_str(wxConvUTF8) );
  wVariable.setvalue( m_Props, m_Value->GetValue() );
  return true;
}