Example #1
0
bool GOrgueProgressDialog::Update(unsigned value, const wxString& msg)
{
	if (!m_dlg)
		return true;
	m_value = value;
	if (m_last == wxGetUTCTime())
		return true;
	m_last = wxGetUTCTime();
	if (!m_dlg->Update(0xffff * (m_value + m_const) / m_max, msg))
		return false;
	return true;
}
Example #2
0
void wxNotificationMessageWindow::OnTimer(wxTimerEvent& WXUNUSED(event))
{
    if ( m_mouseActiveCount > 0 )
    {
        m_timeoutTargetTime = wxGetUTCTime() + m_timeout;
    }
    else if ( m_timeoutTargetTime != -1 &&
        wxGetUTCTime() >= m_timeoutTargetTime )
    {
        m_notificationImpl->Close();
    }
}
/**
 * 現在時刻をUNIX Timeで返す
 */
wxString XrossBoardUtil::GetTimeNow() {

     long unixTime = wxGetUTCTime();
     wxString utc = wxString::Format(_("%ld"), unixTime);

     return utc;
}
void SettingsTemperaments::Save()
{
	ptr_vector<GOrgueTemperamentUser>& list = m_Temperaments.GetUserTemperaments();
	for(unsigned i = 0; i < list.size(); i++)
	{
		bool found = false;
		for(unsigned j = 0; j < m_Ptrs.size(); j++)
			if (m_Ptrs[j] == list[i])
				found = true;

		if (!found)
			delete list[i];
		list[i] = 0;
	}
	list.clear();
	long time = wxGetUTCTime();
	for(unsigned i = 0; i < m_Ptrs.size(); i++)
	{
		if (!m_Ptrs[i])
			m_Ptrs[i] = new GOrgueTemperamentUser(wxString::Format(wxT("UserTemperament%d-%d"), time, i), m_List->GetCellValue(i, 1), m_List->GetCellValue(i, 0));

		m_Ptrs[i]->SetTitle(m_List->GetCellValue(i, 1));
		m_Ptrs[i]->SetGroup(m_List->GetCellValue(i, 0));
		for(unsigned j = 0; j < 12; j++)
			m_Ptrs[i]->SetNoteOffset(j, wxAtof(m_List->GetCellValue(i, 2 + j)));

		list.push_back(m_Ptrs[i]);
	}
}
Example #5
0
// Get local time as milliseconds since 00:00:00, Jan 1st 1970
wxLongLong wxGetUTCTimeMillis()
{
    // If possible, use a function which avoids conversions from
    // broken-up time structures to milliseconds
#if defined(__WINDOWS__)
    FILETIME ft;
    ::GetSystemTimeAsFileTime(&ft);

    // FILETIME is expressed in 100ns (or 0.1us) units since 1601-01-01,
    // transform them to ms since 1970-01-01.
    wxLongLong t(ft.dwHighDateTime, ft.dwLowDateTime);
    t /= 10000;
    t -= wxLL(11644473600000); // Unix - Windows epochs difference in ms.
    return t;
#else // !__WINDOWS__
    wxLongLong val = MILLISECONDS_PER_SECOND;

#if defined(HAVE_GETTIMEOFDAY)
    struct timeval tp;
    if ( wxGetTimeOfDay(&tp) != -1 )
    {
        val *= tp.tv_sec;
        return (val + (tp.tv_usec / MICROSECONDS_PER_MILLISECOND));
    }
    else
    {
        wxLogError(_("wxGetTimeOfDay failed."));
        return 0;
    }
#elif defined(HAVE_FTIME)
    struct timeb tp;

    // ftime() is void and not int in some mingw32 headers, so don't
    // test the return code (well, it shouldn't fail anyhow...)
    (void)::ftime(&tp);
    val *= tp.time;
    return (val + tp.millitm);
#else // no gettimeofday() nor ftime()
    // If your platform/compiler does not support ms resolution please
    // do NOT just shut off these warnings, drop me a line instead at
    // <*****@*****.**>

    #if defined(__VISUALC__)
        #pragma message("wxStopWatch will be up to second resolution!")
    #elif defined(__BORLANDC__)
        #pragma message "wxStopWatch will be up to second resolution!"
    #else
        #warning "wxStopWatch will be up to second resolution!"
    #endif // compiler

    val *= wxGetUTCTime();
    return val;
#endif // time functions

#endif // __WINDOWS__/!__WINDOWS__
}
Example #6
0
void
job_run_dialog::on_end_process(wxProcessEvent &evt) {
  process_input();

  int ndx         = jobs_to_start[current_job];
  int exit_code   = evt.GetExitCode();
  bool remove_job;
  wxString status;

  if (abort) {
    jobs[ndx].status = JOBS_ABORTED;
    status           = Z("aborted");
    remove_job       = false;
  } else if (0 == exit_code) {
    jobs[ndx].status = JOBS_DONE;
    status           = Z("completed OK");
    remove_job       = CJAR_NEVER != mdlg->options.clear_job_after_run_mode;
  } else if (1 == exit_code) {
    jobs[ndx].status = JOBS_DONE_WARNINGS;
    status           = Z("completed with warnings");
    remove_job       = (CJAR_ALWAYS == mdlg->options.clear_job_after_run_mode) || (CJAR_WARNINGS == mdlg->options.clear_job_after_run_mode);
  } else {
    jobs[ndx].status = JOBS_FAILED;
    status           = Z("failed");
    remove_job        = CJAR_ALWAYS == mdlg->options.clear_job_after_run_mode;
  }

  jobs[ndx].finished_on = wxGetUTCTime();

  add_to_log(wxString::Format(Z("Finished job ID %d on %s: status '%s'"), jobs[ndx].id, format_date_time(jobs[ndx].finished_on).c_str(), status.c_str()));

  if (remove_job) {
    jobs.erase(jobs.begin() + ndx, jobs.begin() + ndx + 1);
    for (auto idx = 0u; jobs_to_start.size() > idx; ++idx)
      if (jobs_to_start[idx] >= ndx)
        jobs_to_start[idx]--;
  }

  mdlg->save_job_queue();
  delete process;
  process = nullptr;
  out     = nullptr;

  wxRemoveFile(opt_file_name);

  if (!abort)
    g_jobs->SetValue((current_job + 1) * 100);

  start_next_job();
}
Example #7
0
void wxNotificationMessageWindow::Set(int timeout)
{
    Layout();
    Fit();

    AddVisibleNotification(this);

    if ( timeout != wxGenericNotificationMessage::Timeout_Never )
    {
        // wxTimer uses ms, timeout is in seconds
        m_timer.Start(500);
        m_timeout = timeout;
        m_timeoutTargetTime = wxGetUTCTime() + timeout;
    }
    else if ( m_timer.IsRunning() )
    {
        m_timer.Stop();
    }
}
Example #8
0
long IBattle::GetBattleRunningTime() const
{
	if (!GetInGame()) return 0;
	if (m_start_time == 0 ) return 0;
	return wxGetUTCTime() - m_start_time;
}
Example #9
0
void IBattle::SetInGame(bool ingame)
{
	m_ingame = ingame;
	if (m_ingame) m_start_time = wxGetUTCTime();
	else m_start_time = 0;
}
Example #10
0
mux_dialog::mux_dialog(wxWindow *parent):
    wxDialog(parent, -1, Z("mkvmerge is running"), wxDefaultPosition,
#ifdef SYS_WINDOWS
             wxSize(700, 560),
#else
             wxSize(700, 520),
#endif
             wxDEFAULT_FRAME_STYLE)
#if defined(SYS_WINDOWS)
    , pid(0)
    , m_taskbar_progress(NULL)
    , m_abort_button_changed(false)
#endif  // SYS_WINDOWS
    , m_exit_code(0)
    , m_progress(0)
{
    char c;
    std::string arg_utf8, line;
    long value;
    wxString wx_line, tmp;
    wxInputStream *out;
    wxFile *opt_file;
    uint32_t i;
    wxArrayString *arg_list;
    wxBoxSizer *siz_all, *siz_buttons, *siz_line;
    wxStaticBoxSizer *siz_status, *siz_output;

    m_window_disabler = new wxWindowDisabler(this);

    c = 0;
    siz_status = new wxStaticBoxSizer(new wxStaticBox(this, -1, Z("Status and progress")), wxVERTICAL);
    st_label = new wxStaticText(this, -1, wxEmptyString);
    st_remaining_time_label = new wxStaticText(this, -1, Z("Remaining time:"));
    st_remaining_time       = new wxStaticText(this, -1, Z("is being estimated"));
    siz_line = new wxBoxSizer(wxHORIZONTAL);
    siz_line->Add(st_label);
    siz_line->AddSpacer(5);
    siz_line->Add(st_remaining_time_label);
    siz_line->AddSpacer(5);
    siz_line->Add(st_remaining_time);
    siz_status->Add(siz_line, 0, wxGROW | wxALIGN_LEFT | wxALL, 5);
    g_progress = new wxGauge(this, -1, 100, wxDefaultPosition, wxSize(250, 15));
    siz_status->Add(g_progress, 1, wxALL | wxGROW, 5);

    siz_output = new wxStaticBoxSizer(new wxStaticBox(this, -1, Z("Output")), wxVERTICAL);
    siz_output->Add(new wxStaticText(this, -1, Z("mkvmerge output:")), 0, wxALIGN_LEFT | wxALL, 5);
    tc_output = new wxTextCtrl(this, -1, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_READONLY | wxTE_BESTWRAP | wxTE_MULTILINE);
    siz_output->Add(tc_output, 2, wxGROW | wxALL, 5);
    siz_output->Add(new wxStaticText(this, -1, Z("Warnings:")), 0, wxALIGN_LEFT | wxALL, 5);
    tc_warnings = new wxTextCtrl(this, -1, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_READONLY | wxTE_BESTWRAP | wxTE_MULTILINE);
    siz_output->Add(tc_warnings, 1, wxGROW | wxALL, 5);
    siz_output->Add(new wxStaticText(this, -1, Z("Errors:")), 0, wxALIGN_LEFT | wxALL, 5);
    tc_errors = new wxTextCtrl(this, -1, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_READONLY | wxTE_BESTWRAP | wxTE_MULTILINE);
    siz_output->Add(tc_errors, 1, wxGROW | wxALL, 5);

    siz_buttons = new wxBoxSizer(wxHORIZONTAL);
    siz_buttons->AddStretchSpacer();
    b_ok = new wxButton(this, ID_B_MUX_OK, Z("Ok"));
    b_ok->Enable(false);
    siz_buttons->Add(b_ok, 0, wxGROW);
    siz_buttons->AddStretchSpacer();
    b_abort = new wxButton(this, ID_B_MUX_ABORT, Z("Abort"));
    siz_buttons->Add(b_abort, 0, wxGROW);
    siz_buttons->AddStretchSpacer();
    b_save_log = new wxButton(this, ID_B_MUX_SAVELOG, Z("Save log"));
    siz_buttons->Add(b_save_log, 0, wxGROW);
    siz_buttons->AddStretchSpacer();

    siz_all = new wxBoxSizer(wxVERTICAL);
    siz_all->Add(siz_status, 0, wxGROW | wxALL, 5);
    siz_all->Add(siz_output, 1, wxGROW | wxALL, 5);
    siz_all->Add(siz_buttons, 0, wxGROW | wxALL, 10);
    SetSizer(siz_all);

    update_window(Z("Muxing in progress."));
    Show(true);

    process = new mux_process(this);

    opt_file_name.Printf(wxT("%smmg-mkvmerge-options-%d-%d"), get_temp_dir().c_str(), (int)wxGetProcessId(), (int)wxGetUTCTime());
    try {
        const unsigned char utf8_bom[3] = {0xef, 0xbb, 0xbf};
        opt_file = new wxFile(opt_file_name, wxFile::write);
        opt_file->Write(utf8_bom, 3);
    } catch (...) {
        wxString error;
        error.Printf(Z("Could not create a temporary file for mkvmerge's command line option called '%s' (error code %d, %s)."), opt_file_name.c_str(), errno, wxUCS(strerror(errno)));
        wxMessageBox(error, Z("File creation failed"), wxOK | wxCENTER | wxICON_ERROR);
        throw 0;
    }
    arg_list = &static_cast<mmg_dialog *>(parent)->get_command_line_args();
    for (i = 1; i < arg_list->Count(); i++) {
        if ((*arg_list)[i].Length() == 0)
            opt_file->Write(wxT("#EMPTY#"));
        else {
            arg_utf8 = escape(wxMB((*arg_list)[i]));
            opt_file->Write(arg_utf8.c_str(), arg_utf8.length());
        }
        opt_file->Write(wxT("\n"));
    }
    delete opt_file;

#if defined(SYS_WINDOWS)
    if (get_windows_version() >= WINDOWS_VERSION_7) {
        m_taskbar_progress = new taskbar_progress_c(mdlg);
        m_taskbar_progress->set_state(TBPF_NORMAL);
        m_taskbar_progress->set_value(0, 100);
    }
#endif  // SYS_WINDOWS

    m_start_time                 = get_current_time_millis();
    m_next_remaining_time_update = m_start_time + 8000;

    wxString command_line = wxString::Format(wxT("\"%s\" \"@%s\""), (*arg_list)[0].c_str(), opt_file_name.c_str());
    pid = wxExecute(command_line, wxEXEC_ASYNC, process);
    if (0 == pid) {
        wxLogError(wxT("Execution of '%s' failed."), command_line.c_str());
        done(2);
        return;
    }
    out = process->GetInputStream();

    line = "";
    log = wxEmptyString;
    while (1) {
        while (app->Pending())
            app->Dispatch();

        if (!out->CanRead() && !out->Eof()) {
            wxMilliSleep(5);
            continue;
        }

        if (!out->Eof())
            c = out->GetC();
        else
            c = '\n';

        if ((c == '\n') || (c == '\r') || out->Eof()) {
            wx_line = wxU(line);
            log += wx_line;
            if (c != '\r')
                log += wxT("\n");
            if (wx_line.Find(Z("Warning:")) == 0)
                tc_warnings->AppendText(wx_line + wxT("\n"));
            else if (wx_line.Find(Z("Error:")) == 0)
                tc_errors->AppendText(wx_line + wxT("\n"));
            else if (wx_line.Find(Z("Progress")) == 0) {
                if (wx_line.Find(wxT("%")) != 0) {
                    wx_line.Remove(wx_line.Find(wxT("%")));
                    tmp = wx_line.AfterLast(wxT(' '));
                    tmp.ToLong(&value);
                    if ((value >= 0) && (value <= 100))
                        update_gauge(value);
                }
            } else if (wx_line.Length() > 0)
                tc_output->AppendText(wx_line + wxT("\n"));
            line = "";

            update_remaining_time();

        } else if ((unsigned char)c != 0xff)
            line += c;

        if (out->Eof())
            break;
    }
}
Example #11
0
void
mux_dialog::run() {
    auto &arg_list = static_cast<mmg_dialog *>(GetParent())->get_command_line_args();

    opt_file_name.Printf(wxT("%smmg-mkvmerge-options-%d-%d"), get_temp_dir().c_str(), (int)wxGetProcessId(), (int)wxGetUTCTime());
    try {
        const unsigned char utf8_bom[3] = {0xef, 0xbb, 0xbf};
        wxFile opt_file{opt_file_name, wxFile::write};
        opt_file.Write(utf8_bom, 3);

        for (size_t i = 1; i < arg_list.Count(); i++) {
            if (arg_list[i].IsEmpty())
                opt_file.Write(wxT("#EMPTY#"));
            else {
                auto arg_utf8 = escape(to_utf8(arg_list[i]));
                opt_file.Write(arg_utf8.c_str(), arg_utf8.length());
            }
            opt_file.Write(wxT("\n"));
        }
    } catch (mtx::mm_io::exception &ex) {
        wxString error;
        error.Printf(Z("Could not create a temporary file for mkvmerge's command line option called '%s' (error code %d, %s)."), opt_file_name.c_str(), errno, wxUCS(ex.error()));
        wxMessageBox(error, Z("File creation failed"), wxOK | wxCENTER | wxICON_ERROR);
        throw 0;
    }

#if defined(SYS_WINDOWS)
    if (get_windows_version() >= WINDOWS_VERSION_7) {
        m_taskbar_progress = new taskbar_progress_c(mdlg);
        m_taskbar_progress->set_state(TBPF_NORMAL);
        m_taskbar_progress->set_value(0, 100);
    }
#endif  // SYS_WINDOWS

    update_label(Z("Muxing in progress."));

    m_start_time                 = get_current_time_millis();
    m_next_remaining_time_update = m_start_time + 8000;

    m_process                    = new mux_process{this};
    m_pid                        = wxExecute(wxString::Format(wxT("\"%s\" \"@%s\""), arg_list[0].c_str(), opt_file_name.c_str()), wxEXEC_ASYNC, m_process);

    if (0 == m_pid) {
        wxCommandEvent evt(mux_process::event, mux_process::process_terminated);
        evt.SetInt(2);
        wxPostEvent(this, evt);

    } else {
        m_read_input_timer.SetOwner(this, ID_T_READ_INPUT);
        m_read_input_timer.Start(100);
    }

    ShowModal();
}
Example #12
0
void RgbEffects::RenderText(int Position1, const wxString& Line1, const wxString& FontString1,int dir1,int TextRotation1,bool COUNTDOWN1,
                            int Position2, const wxString& Line2, const wxString& FontString2,int dir2,int TextRotation2,bool COUNTDOWN2)
{
    wxColour c;
    wxString vertMsg;
    wxBitmap bitmap(BufferWi,BufferHt);
    wxMemoryDC dc(bitmap);

    wxFont font;
    int ColorIdx,itmp,i;
    long L1,longsecs1,longsecs2,seconds;
    bool COUNTDOWN=true;
    int days,hours,minutes;
    bool DAYS_STRING=true;


    size_t colorcnt=GetColorCount();
    srand(1); // always have the same random numbers for each frame (state)
    wxImage::HSVValue hsv; //   we will define an hsv color model. The RGB colot model would have been "wxColour color;"
    ColorIdx=rand() % colorcnt; // Select random numbers from 0 up to number of colors the user has checked. 0-5 if 6 boxes checked
    palette.GetHSV(ColorIdx, hsv); // Now go and get the hsv value for this ColorIdx

    font.SetNativeFontInfoUserDesc(FontString1);
    dc.SetFont(font);


    palette.GetColor(0,c);
    dc.SetTextForeground(c);
    wxString msg;
    wxSize sz1 = dc.GetTextExtent(Line1);
    int maxwidth=sz1.GetWidth();
    int maxht=sz1.GetHeight();

    L1=0;
    if(state==0 and COUNTDOWN1 and Line1.ToLong(&L1))
    {
        timer_countdown1=L1+1; // set their counter one higher since teh first thing we do it subtract one from it.
    }
    if(state==0 and COUNTDOWN2 and Line2.ToLong(&L1))
    {
        timer_countdown2=L1+1; // we can have concurrent timers, one for each line of text
    }



    if(dir1==4)
    {
        maxht = maxht*Line1.length();
        for(i=0; i<Line1.length(); i++)
        {
            msg = msg + Line1.GetChar(i) + "\n";
        }
    }
    else if(dir1==5)
    {
        maxht = maxht*Line1.length();
        for(i=0; i<Line1.length(); i++)
        {
            msg = msg + Line1.GetChar(Line1.length()-i-1) + "\n";
        }
    }
    else
    {
        msg = Line1;
        if(COUNTDOWN1)
        {
            longsecs1=wxGetUTCTime	()	;
            if(longsecs1 != old_longsecs1)  timer_countdown1--;
            old_longsecs1=longsecs1;
            if(timer_countdown1 < 0) timer_countdown1=0;
            msg=wxString::Format(wxT("%i"),timer_countdown1);

        }
        if(TextRotation1==1)
        {
            itmp=maxwidth;
            maxwidth=maxht;
            maxht=itmp;
        }
    }


    int dctop= Position1 * BufferHt / 50 - BufferHt/2;
    int xlimit=(BufferWi+maxwidth)*8 + 1;
    int ylimit=(BufferHt+maxht)*8 + 1;
//  int xcentered=(BufferWi-maxwidth)/2;  // original way
    int xcentered=Position1 * BufferWi / 50 - BufferWi/2;


    TextRotation1 *=90.0;
    switch (dir1)
    {
    case 0:
        // left
        //dc.DrawText(msg,BufferWi-state % xlimit/8,dctop);

        dc.DrawRotatedText(msg,BufferWi-state % xlimit/8,dctop,TextRotation1);
        break;
    case 1:
        // right
        //dc.DrawText(msg,state % xlimit/8-BufferWi,dctop);
        dc.DrawRotatedText(msg,state % xlimit/8-BufferWi,dctop,TextRotation1);
        break;
    case 2:
        // up
        //  dc.DrawText(msg,xcentered,BufferHt-state % ylimit/8);
        dc.DrawRotatedText(msg,xcentered,BufferHt-state % ylimit/8,TextRotation1);
        break;
    case 3:
        // down
        //  dc.DrawText(msg,xcentered,state % ylimit / 8 - BufferHt);
        dc.DrawRotatedText(msg,xcentered,state % ylimit / 8 - BufferHt,TextRotation1);
        break;
    case 4:
        // vertical text up
        dc.DrawText(msg,xcentered,BufferHt-(state % ylimit/8));
        break;
    case 5:
        // vertical text down
        dc.DrawText(msg,xcentered,(state % ylimit/8) - maxht);
        break;
    default:
        // no movement - centered
        //   dc.DrawText(msg,xcentered,dctop);
        dc.DrawRotatedText(msg,xcentered,dctop,TextRotation1);
        break;
    }


    // Line2
    msg="";
    font.SetNativeFontInfoUserDesc(FontString2);
    dc.SetFont(font);
    if(colorcnt>1) palette.GetColor(1,c); // scm 7-18-13. added if,. only pull color if we have at least two colors checked in palette
    dc.SetTextForeground(c);
    wxSize sz2 = dc.GetTextExtent(Line2);
    maxwidth=sz2.GetWidth();
    maxht=sz2.GetHeight();

    if(dir2==4)
    {
        maxht = maxht*Line2.length();
        for(i=0; i<Line2.length(); i++)
        {
            msg = msg + Line2.GetChar(i) + "\n";
        }
    }
    else if(dir2==5)
    {
        maxht = maxht*Line2.length();
        for(i=0; i<Line2.length(); i++)
        {
            msg = msg + Line2.GetChar(Line2.length()-i-1) + "\n";
        }
    }
    else
    {
        msg = Line2;
        if(COUNTDOWN2)
        {
            longsecs2=wxGetUTCTime	()	;
            if(longsecs2 != old_longsecs2)  timer_countdown2--;
            old_longsecs2=longsecs2;
            if(timer_countdown2 < 0) timer_countdown2=0;
            if(DAYS_STRING)
            {
                days = timer_countdown2 / 60 / 60 / 24;
                hours = (timer_countdown2 / 60 / 60) % 24;
                minutes = (timer_countdown2 / 60) % 60;
                seconds = timer_countdown2 % 60;
                msg=wxString::Format(wxT("%i d %i h %i m %i s"),days,hours,minutes,seconds);
            }
            else
                {
                    msg=wxString::Format(wxT("%i"),timer_countdown2);
                }
        }
        if(TextRotation2==1)
        {
            itmp=maxwidth;
            maxwidth=maxht;
            maxht=itmp;
        }
    }


    dctop= Position2 * BufferHt / 50 - BufferHt/2;
    xlimit=(BufferWi+maxwidth)*8 + 1;
    ylimit=(BufferHt+maxht)*8 + 1;
//  int xcentered=(BufferWi-maxwidth)/2;  // original way
    xcentered=Position2 * BufferWi / 50 - BufferWi/2;


    TextRotation2 *=90.0;
    switch (dir2)
    {
    case 0:
        // left
        //dc.DrawText(msg,BufferWi-state % xlimit/8,dctop);

        dc.DrawRotatedText(msg,BufferWi-state % xlimit/8,dctop,TextRotation2);
        break;
    case 1:
        // right
        //dc.DrawText(msg,state % xlimit/8-BufferWi,dctop);
        dc.DrawRotatedText(msg,state % xlimit/8-BufferWi,dctop,TextRotation2);
        break;
    case 2:
        // up
        //  dc.DrawText(msg,xcentered,BufferHt-state % ylimit/8);
        dc.DrawRotatedText(msg,xcentered,BufferHt-state % ylimit/8,TextRotation2);
        break;
    case 3:
        // down
        //  dc.DrawText(msg,xcentered,state % ylimit / 8 - BufferHt);
        dc.DrawRotatedText(msg,xcentered,state % ylimit / 8 - BufferHt,TextRotation2);
        break;
    case 4:
        // vertical text up
        dc.DrawText(msg,xcentered,BufferHt-(state % ylimit/8));
        break;
    case 5:
        // vertical text down
        dc.DrawText(msg,xcentered,(state % ylimit/8) - maxht);
        break;
    default:
        // no movement - centered
        //   dc.DrawText(msg,xcentered,dctop);
        dc.DrawRotatedText(msg,xcentered,dctop,TextRotation2);
        break;
    }


    // copy dc to buffer
    for(wxCoord x=0; x<BufferWi; x++)
    {
        for(wxCoord y=0; y<BufferHt; y++)
        {
            dc.GetPixel(x,BufferHt-y-1,&c);
            SetPixel(x,y,c);

//        ColorIdx=(n % BlockHt) / BarHt;
//        palette.GetHSV(ColorIdx, hsv);

        }
    }
}
Example #13
0
void
job_run_dialog::start_next_job() {
  t_update->Stop();

  ++current_job;

  if ((static_cast<int>(jobs_to_start.size()) <= current_job) || cb_abort_after_current->IsChecked() || abort) {
    if (   abort
        || (   cb_abort_after_current->IsChecked()
            && (current_job < static_cast<int>(jobs_to_start.size()))))
      add_to_log(wxString::Format(Z("Aborted processing on %s"), format_date_time(wxGetUTCTime()).c_str()));
    else
      add_to_log(wxString::Format(Z("Finished processing on %s"), format_date_time(wxGetUTCTime()).c_str()));

    b_abort->Enable(false);
    cb_abort_after_current->Enable(false);
    b_ok->Enable(true);
    b_ok->SetFocus();
    SetTitle(Z("mkvmerge has finished"));

    st_remaining_time->SetLabel(wxT("---"));
    st_remaining_time_total->SetLabel(wxT("---"));

#if defined(SYS_WINDOWS)
    if (m_taskbar_progress)
      m_taskbar_progress->set_state(TBPF_NOPROGRESS);
#endif

    return;
  }

  m_start_time                 = mtx::sys::get_current_time_millis();
  m_next_remaining_time_update = m_start_time + 8000;
  st_remaining_time->SetLabel(Z("is being estimated"));

#if defined(SYS_WINDOWS)
  if (m_taskbar_progress) {
    m_taskbar_progress->set_state(TBPF_NORMAL);
    m_taskbar_progress->set_value(current_job * 100, jobs_to_start.size() * 100);
  }
#endif

  int ndx = jobs_to_start[current_job];
  st_jobs->SetLabel(wxString::Format(Z("Processing job %d/%d"), current_job + 1, (int)jobs_to_start.size()));
  st_current->SetLabel(wxString::Format(Z("Current job ID %d:"), jobs[ndx].id));

  mdlg->load(wxString::Format(wxT("%s/%d.mmg"), app->get_jobs_folder().c_str(), jobs[ndx].id), true);

  opt_file_name = get_temp_settings_file_name();

  wxFile *opt_file;
  try {
    opt_file = new wxFile(opt_file_name, wxFile::write);
  } catch (...) {
    jobs[ndx].log->Printf(Z("Could not create a temporary file for mkvmerge's command line option called '%s' (error code %d, %s)."),
                          opt_file_name.c_str(), errno, wxUCS(strerror(errno)));
    jobs[ndx].status = JOBS_FAILED;
    mdlg->save_job_queue();
    if (process) {
      delete process;
      process = nullptr;
    }
    start_next_job();
    return;
  }

  static const unsigned char utf8_bom[3] = {0xef, 0xbb, 0xbf};
  opt_file->Write(utf8_bom, 3);
  opt_file->Write(wxT("--gui-mode\n"));

  mdlg->update_command_line();
  wxArrayString *arg_list = &mdlg->get_command_line_args();

  size_t i;
  for (i = 1; i < arg_list->Count(); i++) {
    if ((*arg_list)[i].Length() == 0)
      opt_file->Write(wxT("#EMPTY#"));
    else {
      std::string arg_utf8 = escape(wxMB((*arg_list)[i]));
      opt_file->Write(arg_utf8.c_str(), arg_utf8.length());
    }
    opt_file->Write(wxT("\n"));
  }
  delete opt_file;

  process = new wxProcess(this, 1);
  process->Redirect();
  wxString command_line = wxString::Format(wxT("\"%s\" \"@%s\""), (*arg_list)[0].c_str(), opt_file_name.c_str());
  pid = wxExecute(command_line, wxEXEC_ASYNC, process);
  if (0 == pid) {
    wxLogError(wxT("Execution of '%s' failed."), command_line.c_str());
    return;
  }
  out = process->GetInputStream();

  *jobs[ndx].log        = wxEmptyString;
  jobs[ndx].started_on  = wxGetUTCTime();
  jobs[ndx].finished_on = -1;

  add_to_log(wxString::Format(Z("Starting job ID %d (%s) on %s"), jobs[ndx].id, jobs[ndx].description->c_str(), format_date_time(jobs[ndx].started_on).c_str()));

  t_update->Start(100);
}