// Set the value in the textbox void setArgValue(long val) { if (val < 0) text_control->ChangeValue(""); else text_control->ChangeValue(S_FMT("%ld", val)); }
void log(agi::log::SinkMessage *sm) override { #ifndef _WIN32 tm tmtime; localtime_r(&sm->tv.tv_sec, &tmtime); auto log = wxString::Format("%c %02d:%02d:%02d %-6ld <%-25s> [%s:%s:%d] %s\n", agi::log::Severity_ID[sm->severity], (int)tmtime.tm_hour, (int)tmtime.tm_min, (int)tmtime.tm_sec, (long)sm->tv.tv_usec, sm->section, sm->file, sm->func, sm->line, to_wx(sm->message)); #else auto log = wxString::Format("%c %-6ld <%-25s> [%s:%s:%d] %s\n", agi::log::Severity_ID[sm->severity], sm->tv.tv_usec, sm->section, sm->file, sm->func, sm->line, to_wx(sm->message)); #endif if (wxIsMainThread()) text_ctrl->AppendText(log); else agi::dispatch::Main().Async([=]{ text_ctrl->AppendText(log); }); }
RunConfigDialog(wxWindow* parent, string title, string name, string params, bool custom = true) : wxDialog(parent, -1, title) { // Setup sizer wxBoxSizer* sizer = new wxBoxSizer(wxVERTICAL); SetSizer(sizer); wxGridBagSizer* gb_sizer = new wxGridBagSizer(8, 4); sizer->Add(gb_sizer, 1, wxEXPAND|wxALL, 10); // Config name gb_sizer->Add(new wxStaticText(this, -1, "Config Name:"), wxGBPosition(0, 0), wxDefaultSpan, wxALIGN_CENTER_VERTICAL); text_name = new wxTextCtrl(this, -1, name); text_name->Enable(custom); gb_sizer->Add(text_name, wxGBPosition(0, 1), wxDefaultSpan, wxEXPAND); // Config params gb_sizer->Add(new wxStaticText(this, -1, "Parameters:"), wxGBPosition(1, 0), wxDefaultSpan, wxALIGN_CENTER_VERTICAL); text_params = new wxTextCtrl(this, -1, params); gb_sizer->Add(text_params, wxGBPosition(1, 1), wxDefaultSpan, wxEXPAND); wxStaticText* label_help = new wxStaticText(this, -1, ""); gb_sizer->Add(label_help, wxGBPosition(2, 0), wxGBSpan(1, 2), wxEXPAND); gb_sizer->Add(CreateStdDialogButtonSizer(wxOK|wxCANCEL), wxGBPosition(3, 0), wxGBSpan(1, 2), wxALIGN_RIGHT); gb_sizer->AddGrowableCol(1); gb_sizer->AddGrowableRow(2); label_help->SetLabel("%i - Base resource archive\n%r - Resource archive(s)\n%a - Current archive\n%mn - Map name\n%mw - Map number (eg. E1M1 = 1 1, MAP02 = 02)"); label_help->Wrap(300); text_params->SetInsertionPoint(0); }
void MyFrame::DoChangeFont(const wxFont& font, const wxColour& col) { m_canvas->SetTextFont(font); if ( col.IsOk() ) m_canvas->SetColour(col); m_canvas->Refresh(); m_textctrl->SetFont(font); if ( col.IsOk() ) m_textctrl->SetForegroundColour(col); m_textctrl->Refresh(); // update the state of the bold/italic/underlined menu items wxMenuBar *mbar = GetMenuBar(); if ( mbar ) { mbar->Check(Font_Light, font.GetWeight() == wxFONTWEIGHT_LIGHT); mbar->Check(Font_Bold, font.GetWeight() == wxFONTWEIGHT_BOLD); mbar->Check(Font_Italic, font.GetStyle() == wxFONTSTYLE_ITALIC); #ifndef __WXMSW__ mbar->Check(Font_Slant, font.GetStyle() == wxFONTSTYLE_SLANT); #endif mbar->Check(Font_Underlined, font.GetUnderlined()); mbar->Check(Font_Strikethrough, font.GetStrikethrough()); } }
void wxMiniApp::download_file(wxString filename) { try { text = wxT("Downloading ") + filename + wxT("..."); status->AppendText(text); WebForm http_connection; http_connection.setHost(update_server.mb_str()); http_connection.setScriptFile(filename.mb_str()); http_connection.sendRequest(); wxString complete_path = wxT(""); complete_path += local_path; complete_path += filename; bool success = http_connection.downloadBigFile(complete_path.mb_str()); // Downloaded succesfully? if(success) { // Yes :) text = wxT(" Done"); status->AppendText(text); status->AppendText(wxT("\n")); } else { // No :( text = wxT(" Error"); status->AppendText(text); status->AppendText(wxT("\n")); } } catch(WebFormException ex) { /*cout << ex.getMessage() << endl;*/ } }
void MyFrame::OnCalc(wxCommandEvent& event) { std::string text = invoice_list->GetValue().ToStdString(); std::string target = target_input->GetValue().ToStdString(); Finder f = Finder(); int n; Finder::readToInt(&n,target.c_str()); f.setTarget(n); f.setValues(text); f.make(); std::vector<int> result = f.getResult(); if (result.size() == 0) { result_list->SetValue(L"拼凑失败!"); return; } double sum = 0; std::stringstream result_str; for (std::vector<int>::size_type i = 0; i != result.size(); ++i) { double v = result[i] / 100.0; result_str << v; if (i != result.size() -1) result_str << " + "; sum += v; } result_str << " = "; result_str << sum; result_list->SetValue(result_str.str()); }
virtual bool TransferDataFromWindow() { wxFileName fileName = m_filePicker->GetFileName(); if (fileName.FileExists()) { alertDlg("Project file is already exist.\nSelect other filename.", this); m_filePicker->SetFocus(); return false; } if (!fileName.IsOk()) { alertDlg("Project file name is empty or invalid.", this); m_filePicker->SetFocus(); return false; } if (m_textName->GetLabelText().IsEmpty()) { alertDlg("Project name is empty.", this); m_textName->SetFocus(); return false; } return true; }
void DisplayProcess::Execute(const wxString& command) { if (!tctrl) { return; } wxProcess *process = new wxProcess(wxPROCESS_REDIRECT); //long pid = wxExecute(command, wxEXEC_ASYNC, process); process->Redirect(); if (process) { wxString log; wxInputStream *msg = process->GetInputStream(); wxTextInputStream tStream(*msg); while (!msg->Eof()) { log = tStream.ReadLine(); tctrl->AppendText(log + wxT("\n")); tctrl->ShowPosition(tctrl->GetLastPosition()); } tctrl->AppendText(wxT("Finished!\n")); } else { tctrl->AppendText(wxT("FAIL: Command" + command + " could not be run!\n")); } }
void MyFrame::OnRun(wxCommandEvent &event) { ostringstream stream; text->Clear(); unique_ptr<eph::nominate_abstract> nsl; switch (methods->GetCurrentSelection()) { case 0: nsl = make_unique<eph::nominate_pal>(stream, lines); break; case 1: nsl = make_unique<eph::nominate_sdv_lpe>(stream, lines); break; case 2: nsl = make_unique<eph::nominate_sdv_lpe>(stream, lines, eph::ENABLE_SL::YES); break; } auto result = nsl->nominate(finalists->GetCurrentSelection()+1, noms_per_ballot->GetCurrentSelection()+1); if (verbose->GetValue()) { text->AppendText(stream.str()); } text->AppendText(result); }
// Select the currently actively field. void HighlightCurrentField() { m_text->SetFocus(); const CharRange range = GetFieldRange(m_currentField); m_text->SetSelection(range.from, range.to); }
void MyFrame::OnTestTextValue(wxCommandEvent& WXUNUSED(event)) { wxString value = m_textctrl->GetValue(); m_textctrl->SetValue(value); if ( m_textctrl->GetValue() != value ) { wxLogError(wxT("Text value changed after getting and setting it")); } }
void onPlistCheckboxPressed(wxCommandEvent& evt) { const bool on = m_info_plist_cb->IsChecked(); m_get_info_string->Enable(on); m_version->Enable(on); m_icon_file->Enable(on); m_identifier->Enable(on); m_signature->Enable(on); }
// Log messages to the text control void MyFrame::Log(const wxString& text) { if (m_textCtrl) { wxString text2(text); text2.Replace(wxT("\n"), wxT(" ")); text2.Replace(wxT("\r"), wxT(" ")); m_textCtrl->SetInsertionPointEnd(); m_textCtrl->WriteText(text2 + wxT("\n")); } }
//read messages from buffer and write them to the screen void write(wxCommandEvent &) { if (messages.size() > 0) { messages.lockGet(); size_t size = messages.size(); std::vector<char> local_messages(size); messages.popN(&local_messages.front(), size); messages.unlockGet(); newLog = false; u32 cursor = 0; u32 removed = 0; while (cursor < local_messages.size()) { Log::LogMessage msg = Log::LogMessage::deserialize(local_messages.data() + cursor, &removed); cursor += removed; if (removed <= 0) { break; } wxTextCtrl *llogcon = (msg.mType == Log::TTY) ? m_tty : m_log; if (llogcon) { switch (msg.mServerity) { case Log::LogSeverityNotice: llogcon->SetDefaultStyle(m_color_white); break; case Log::LogSeverityWarning: llogcon->SetDefaultStyle(m_color_yellow); break; case Log::LogSeverityError: llogcon->SetDefaultStyle(m_color_red); break; case Log::LogSeveritySuccess: llogcon->SetDefaultStyle(m_color_green); break; default: break; } llogcon->AppendText(fmt::FromUTF8(msg.mText)); } } if (m_log->GetLastPosition() > GUI_BUFFER_MAX_SIZE) { m_log->Remove(0, m_log->GetLastPosition() - (GUI_BUFFER_MAX_SIZE/2)); } } }
void WebFrame::OnFind(wxCommandEvent& WXUNUSED(evt)) { wxString value = m_browser->GetSelectedText(); if(value.Len() > 150) { value.Truncate(150); } m_find_ctrl->SetValue(value); if(!m_find_toolbar->IsShown()){ m_find_toolbar->Show(true); SendSizeEvent(); } m_find_ctrl->SelectAll(); }
void MyFrame::OnWriteClipboardContents(wxCommandEvent& WXUNUSED(event)) { if (wxTheClipboard->Open()) { if (wxTheClipboard->IsSupported( wxDF_UNICODETEXT )) { wxTextDataObject data; wxTheClipboard->GetData( data ); m_textctrl->Clear(); m_textctrl->SetValue( data.GetText() ); } wxTheClipboard->Close(); } }
void MyFrame::OnJustifyUpdateUI(wxUpdateUIEvent& evt) { switch(evt.GetId()) { case wxID_JUSTIFY_LEFT: evt.Check(!m_logwindow->HasFlag(wxTE_CENTER | wxTE_RIGHT)); break; case wxID_JUSTIFY_CENTER: evt.Check(m_logwindow->HasFlag(wxTE_CENTER)); break; case wxID_JUSTIFY_RIGHT: evt.Check(m_logwindow->HasFlag(wxTE_RIGHT)); break; } }
void NumValidatorTestCase::ZeroAsBlank() { long value = 0; m_text->SetValidator( wxMakeIntegerValidator(&value, wxNUM_VAL_ZERO_AS_BLANK)); wxValidator * const val = m_text->GetValidator(); CPPUNIT_ASSERT( val->TransferToWindow() ); CPPUNIT_ASSERT_EQUAL( "", m_text->GetValue() ); value++; CPPUNIT_ASSERT( val->TransferFromWindow() ); CPPUNIT_ASSERT_EQUAL( 0, value ); }
void log(agi::log::SinkMessage *sm) { #ifndef _WIN32 tm tmtime; localtime_r(&sm->tv.tv_sec, &tmtime); wxString log = wxString::Format("%c %02d:%02d:%02d %-6ld <%-25s> [%s:%s:%d] %s\n", agi::log::Severity_ID[sm->severity], (int)tmtime.tm_hour, (int)tmtime.tm_min, (int)tmtime.tm_sec, (long)sm->tv.tv_usec, sm->section, sm->file, sm->func, sm->line, wxString::FromUTF8(sm->message, sm->len)); #else wxString log = wxString::Format("%c %-6ld <%-25s> [%s:%s:%d] %s\n", agi::log::Severity_ID[sm->severity], sm->tv.tv_usec, sm->section, sm->file, sm->func, sm->line, wxString::FromUTF8(sm->message, sm->len)); #endif text_ctrl->AppendText(log); }
void MyFrame::OnSolveButton(wxCommandEvent& evt) { Solver solver; if(!solver.set_goal(goalEntry->GetValue().ToStdString())) { wxMessageBox(wxT("Неверный формат целевой функции"), wxT("Ошибка"), wxOK|wxCENTER|wxICON_ERROR); return; } for(auto const& entry : restrEntries) { bool restrSet = solver.add_restriction(entry->GetValue().ToStdString()); if(!restrSet) { wxMessageBox(wxT("Неверный формат ограничения"), wxT("Ошибка"), wxOK|wxCENTER|wxICON_ERROR); return; } } Solver invSolver = solver; invSolver.invert_to_dual(); auto steps = solver.solve(); auto invSteps = invSolver.solve(); if(!steps.back().valid()) { wxMessageBox(wxT("Неразрешимая система"), wxT("Ошибка"), wxOK|wxCENTER|wxICON_ERROR); return; } ClearNotebooks(); FillNotebook(steps, directStepsBook); FillNotebook(invSteps, invertStepsBook); }
void MyFrame::OnDaytime(wxCommandEvent& event) { try { boost::asio::io_context io_context; udp::resolver resolver(io_context); udp::endpoint receiver_endpoint(udp::v4(), GetPort()); udp::socket socket(io_context); socket.open(udp::v4()); boost::array<char, 1> send_buf = {{0}}; socket.send_to(boost::asio::buffer(send_buf), receiver_endpoint); boost::array<char, 128> recv_buf; memset(recv_buf.data(), 0, recv_buf.size()); udp::endpoint sender_endpoint; size_t len = socket.receive_from(boost::asio::buffer(recv_buf), sender_endpoint); m_daytime->SetValue(recv_buf.data()); // std::cout.write(recv_buf.data(), len); } catch (std::exception& e) { std::cerr << e.what() << std::endl; } }
void MyFrame::OnStateChanged(wxWebKitStateChangedEvent& myEvent) { if (GetStatusBar() != NULL) { if (myEvent.GetState() == wxWEBKIT_STATE_NEGOTIATING) { GetStatusBar()->SetStatusText(_("Contacting ") + myEvent.GetURL()); urlText->SetValue(myEvent.GetURL()); } else if (myEvent.GetState() == wxWEBKIT_STATE_TRANSFERRING) { GetStatusBar()->SetStatusText(_("Loading ") + myEvent.GetURL()); } else if (myEvent.GetState() == wxWEBKIT_STATE_STOP) { GetStatusBar()->SetStatusText(_("Load complete.")); SetTitle(mySafari->GetTitle()); } else if (myEvent.GetState() == wxWEBKIT_STATE_FAILED) { GetStatusBar()->SetStatusText(_("Failed to load ") + myEvent.GetURL()); } } }
void DIALOG_LABEL_EDITOR::TextPropertiesAccept( wxCommandEvent& aEvent ) { wxString text; int value; /* save old text in undo list if not already in edit */ /* or the label to be edited is part of a block */ if( m_CurrentText->GetFlags() == 0 || m_Parent->GetScreen()->m_BlockLocate.GetState() != STATE_NO_BLOCK ) m_Parent->SaveCopyInUndoList( m_CurrentText, UR_CHANGED ); m_Parent->GetCanvas()->RefreshDrawingRect( m_CurrentText->GetBoundingBox() ); text = m_textLabel->GetValue(); if( !text.IsEmpty() ) m_CurrentText->m_Text = text; else if( !m_CurrentText->IsNew() ) { DisplayError( this, _( "Empty Text!" ) ); return; } m_CurrentText->SetOrientation( m_TextOrient->GetSelection() ); text = m_TextSize->GetValue(); value = ReturnValueFromString( g_UserUnit, text ); m_CurrentText->m_Size.x = m_CurrentText->m_Size.y = value; if( m_TextShape ) m_CurrentText->SetShape( m_TextShape->GetSelection() ); int style = m_TextStyle->GetSelection(); if( ( style & 1 ) ) m_CurrentText->m_Italic = 1; else m_CurrentText->m_Italic = 0; if( ( style & 2 ) ) { m_CurrentText->m_Bold = true; m_CurrentText->m_Thickness = GetPenSizeForBold( m_CurrentText->m_Size.x ); } else { m_CurrentText->m_Bold = false; m_CurrentText->m_Thickness = 0; } m_Parent->OnModify(); /* Make the text size as new default size if it is a new text */ if( m_CurrentText->IsNew() ) m_Parent->SetDefaultLabelSize( m_CurrentText->m_Size.x ); m_Parent->GetCanvas()->RefreshDrawingRect( m_CurrentText->GetBoundingBox() ); m_Parent->GetCanvas()->MoveCursorToCrossHair(); EndModal( wxID_OK ); }
void MyFrame::OnJustify(wxRibbonToolBarEvent& evt) { long style = m_logwindow->GetWindowStyle() & ~(wxTE_LEFT | wxTE_CENTER | wxTE_RIGHT); switch(evt.GetId()) { case wxID_JUSTIFY_LEFT: m_logwindow->SetWindowStyle(style | wxTE_LEFT); break; case wxID_JUSTIFY_CENTER: m_logwindow->SetWindowStyle(style | wxTE_CENTER); break; case wxID_JUSTIFY_RIGHT: m_logwindow->SetWindowStyle(style | wxTE_RIGHT); break; } }
void NumValidatorTestCase::TransferUnsigned() { unsigned value = 0; wxIntegerValidator<unsigned> valUnsigned(&value); valUnsigned.SetWindow(m_text); CPPUNIT_ASSERT( valUnsigned.TransferToWindow() ); CPPUNIT_ASSERT_EQUAL( "0", m_text->GetValue() ); value = 17; CPPUNIT_ASSERT( valUnsigned.TransferToWindow() ); CPPUNIT_ASSERT_EQUAL( "17", m_text->GetValue() ); m_text->ChangeValue("foobar"); CPPUNIT_ASSERT( !valUnsigned.TransferFromWindow() ); m_text->ChangeValue("-234"); CPPUNIT_ASSERT( !valUnsigned.TransferFromWindow() ); m_text->ChangeValue("234"); CPPUNIT_ASSERT( valUnsigned.TransferFromWindow() ); CPPUNIT_ASSERT_EQUAL( 234, value ); m_text->ChangeValue("18446744073709551616"); // == ULLONG_MAX + 1 CPPUNIT_ASSERT( !valUnsigned.TransferFromWindow() ); m_text->Clear(); CPPUNIT_ASSERT( !valUnsigned.TransferFromWindow() ); }
void DIALOG_LABEL_EDITOR::TextPropertiesAccept( wxCommandEvent& aEvent ) { wxString text; int value; /* save old text in undo list if not already in edit */ /* or the label to be edited is part of a block */ if( m_CurrentText->GetFlags() == 0 || m_Parent->GetScreen()->m_BlockLocate.GetState() != STATE_NO_BLOCK ) m_Parent->SaveCopyInUndoList( m_CurrentText, UR_CHANGED ); m_Parent->GetCanvas()->RefreshDrawingRect( m_CurrentText->GetBoundingBox() ); text = m_textLabel->GetValue(); if( !text.IsEmpty() ) m_CurrentText->SetText( text ); else if( !m_CurrentText->IsNew() ) { DisplayError( this, _( "Empty Text!" ) ); return; } m_CurrentText->SetOrientation( m_TextOrient->GetSelection() ); text = m_TextSize->GetValue(); value = ValueFromString( g_UserUnit, text ); m_CurrentText->SetSize( wxSize( value, value ) ); if( m_TextShape ) /// @todo move cast to widget m_CurrentText->SetShape( static_cast<PINSHEETLABEL_SHAPE>( m_TextShape->GetSelection() ) ); int style = m_TextStyle->GetSelection(); m_CurrentText->SetItalic( ( style & 1 ) ); if( ( style & 2 ) ) { m_CurrentText->SetBold( true ); m_CurrentText->SetThickness( GetPenSizeForBold( m_CurrentText->GetSize().x ) ); } else { m_CurrentText->SetBold( false ); m_CurrentText->SetThickness( 0 ); } m_Parent->OnModify(); // Make the text size the new default size ( if it is a new text ): if( m_CurrentText->IsNew() ) SetDefaultTextSize( m_CurrentText->GetSize().x ); m_Parent->GetCanvas()->RefreshDrawingRect( m_CurrentText->GetBoundingBox() ); m_Parent->GetCanvas()->MoveCursorToCrossHair(); EndModal( wxID_OK ); }
void NumValidatorTestCase::NoTrailingZeroes() { // We need a locale with point as decimal separator. wxLocale loc(wxLANGUAGE_ENGLISH_UK, wxLOCALE_DONT_LOAD_DEFAULT); double value = 1.2; m_text->SetValidator( wxMakeFloatingPointValidator(3, &value, wxNUM_VAL_NO_TRAILING_ZEROES)); wxValidator * const val = m_text->GetValidator(); CPPUNIT_ASSERT( val->TransferToWindow() ); CPPUNIT_ASSERT_EQUAL( "1.2", m_text->GetValue() ); value = 1.234; CPPUNIT_ASSERT( val->TransferToWindow() ); CPPUNIT_ASSERT_EQUAL( "1.234", m_text->GetValue() ); }
int ValueFromTextCtrl( const wxTextCtrl& aTextCtr ) { int value; wxString msg = aTextCtr.GetValue(); value = ValueFromString( g_UserUnit, msg ); return value; }
// Update the text value to correspond to the current time. By default also // generate an event but this can be avoided by calling the "WithoutEvent" // variant. void UpdateText() { UpdateTextWithoutEvent(); wxWindow* const ctrl = m_text->GetParent(); wxDateEvent event(ctrl, m_time, wxEVT_TIME_CHANGED); ctrl->HandleWindowEvent(event); }
void PrivateImportDailyFrame::OnOK(wxCommandEvent& ev) { m_filename = file_path_input->GetValue().ToAscii(); m_symbol = symbol_input->GetValue().ToAscii(); //if (m_symbol.length() && m_filename.length()) // Show(false); //else Destroy(); //Destroy(); }