Example #1
0
CSQLiteAddressbook::CSQLiteAddressbook(CGUID id,
                                       const wxString& strName,
                                       const wxString& strDBFile)
  : m_id(id)
  , m_is_ok(false)
  , m_nSortOrder(C_SORT_SN)
  , m_bSortAsc(true)
  , m_conn_pool(connection_pool_size)
  , m_strName(strName)
  , m_strPath(strDBFile)
  , m_bMarkedForDeletion(false)
{
  try
  {
    for (int i = 0; i < connection_pool_size; ++i) {
      soci::session& session = m_conn_pool.at(i);
      session.open(soci::sqlite3, strDBFile.ToStdString());
      session << "PRAGMA foreign_keys = ON";
    }
    initSchema();
  }
  catch (const soci_error& e) {
    m_strLastError = e.what();
  }
  catch (const std::exception& e) {
    m_strLastError = e.what();
  }
}
Example #2
0
std::string stf::wx2std(const wxString& wxs) {
#if (wxCHECK_VERSION(2, 9, 0) || defined(MODULE_ONLY))
    return wxs.ToStdString();
#else
    return std::string(wxs.mb_str());
#endif
}
Example #3
0
void JGridTable::SetValue(const int row, const int col, const wxString & value) {
	if (row < GetNumberRows()) {
		if (col < table_[row].size()) {
			table_[row][col] = value.ToStdString();
		}
	}
}
Example #4
0
void PrintContinuityEditorView::DoSetPrintContinuity(int which_sheet,
    const wxString& number,
    const wxString& cont)
{
    std::map<int, std::pair<std::string, std::string>> data{ { which_sheet, { number.ToStdString(), cont.ToStdString() } } };
    auto cmd = static_cast<CalChartDoc*>(GetDocument())->Create_SetPrintableContinuity(data);
    GetDocument()->GetCommandProcessor()->Submit(cmd.release());
}
Example #5
0
void clean_dir(const wxString& dir) {
	namespace fs = boost::filesystem;
	fs::path path(dir.ToStdString());
	fs::directory_iterator end_dir_it;
	for (fs::directory_iterator it(path); it != end_dir_it; ++it) {
		if (fs::is_directory(it->path())) continue;
		fs::remove_all(it->path());
	}
}
Example #6
0
bool GdaJson::hasName(const json_spirit::Object& obj, const wxString& name)
{
	std::string std_name(name.ToStdString());
	for (json_spirit::Object::const_iterator i=obj.begin(); i!=obj.end(); ++i)
	{
		if (i->name_ == std_name) return true;
	}
	return false;
}
Example #7
0
TileMapImporter::TileMapImporter(const wxString &filePath)
    : m_filePath(filePath),
      m_map(new Tmx::Map())
{
    m_map->ParseFile(filePath.ToStdString());

    if(m_map->HasError())
    {
        throw std::runtime_error("Error when loading the .tmx file");
    }
}
Example #8
0
ValueCurveButton::ValueCurveButton(wxWindow *parent,
    wxWindowID id,
    const wxBitmap& bitmap,
    const wxPoint& pos,
    const wxSize& size,
    long style,
    const wxValidator& validator,
    const wxString& name) : wxBitmapButton(parent, id, bitmap, pos, size, style, validator, name)
{
    _vc = new ValueCurve(name.ToStdString());
}
Example #9
0
static void HttpGet(const wxString& url, std::shared_ptr<wxString>& str)
{
	CURL *curl = curl_easy_init();

	curl_easy_setopt(curl, CURLOPT_URL, url.ToStdString().c_str());
	curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, HttpGet_WriteStr);
	curl_easy_setopt(curl, CURLOPT_WRITEDATA, reinterpret_cast<wxString *>(str.get()));

	curl_easy_setopt(curl, CURLOPT_USERAGENT, ua.ToStdString().c_str());
	//curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
	curl_easy_setopt(curl, CURLOPT_TIMEOUT, 10L); // 10 sek

	CURLcode result = curl_easy_perform(curl);

	if (result != CURLE_OK) {
		//wxLogError("Błąd połączenia z URL %s (%s)", url.c_str(), curl_easy_strerror(result));
	}

	curl_easy_cleanup(curl);
}
Example #10
0
SectionInfo::SectionInfo(const wxString& _name)
{
	name = _name.ToStdString();
	memset(&shdr, 0, sizeof(Elf64_Shdr));

	section_num = sections_list.Add(this);

	shdr.sh_offset = section_offs;
	shdr.sh_name = section_name_offs;

	section_name_offs += name.length() + 1;
}
bool OCP_DataStreamInput_Thread::OpenComPortPhysical(const wxString &com_name, int baud_rate)
{
    try {
        m_serial.setPort(com_name.ToStdString());
        m_serial.setBaudrate(baud_rate);
        m_serial.open();
        m_serial.setTimeout(250, 250, 0, 250, 0);
    } catch (std::exception &e) {
        //std::cerr << "Unhandled Exception while opening serial port: " << e.what() << std::endl;
    }
    return m_serial.isOpen();
}
Example #12
0
// -----------------------------------------------------------------------------
// Sets the texture to display
// -----------------------------------------------------------------------------
void FlatTexCanvas::setTexture(const wxString& tex)
{
	texname_ = tex;
	if (tex.empty() || tex == "-")
		texture_ = 0;
	else
		texture_ = MapEditor::textureManager()
					   .flat(tex.ToStdString(), Game::configuration().featureSupported(Game::Feature::MixTexFlats))
					   .gl_id;

	Refresh();
}
Example #13
0
bool RebrandingHelper::ShouldRename(wxString scope) const
{
	if (rename.find(scope) != rename.end())
		return true;

	for(auto & it : renameRegex)
	{
		if (std::regex_match(scope.ToStdString(), it.first))
			return true;
	}

	return false;
}
Example #14
0
/**
 * Exporting OGR layer in project to another datasource name
 * This function will be called by OnOKClick (When user clicks OK)
 */
void ExportDataDlg::ExportOGRLayer(wxString& ds_name, bool is_update)
{
    // Exporting layer in multi-layer cases will not use OGRTable anymore,
    // we will use OGRDataAdapter to get ogr layer by layer name
    OGRTable* tbl = dynamic_cast<OGRTable*>(project_p->GetTableInt());
	if (!tbl) {
		// DBFTable case, try to read into
        wxString msg = "Only OGR datasource can be exported now.";
		throw GdaException(msg.mb_str());
	}

    OGRLayerProxy* layer = tbl->GetOGRLayer();
    
    layer->T_Export(ds_format.ToStdString(), ds_name.ToStdString(),
                    layer_name.ToStdString(), is_update);
    int prog_n_max = project_p->GetNumRecords();
    wxProgressDialog prog_dlg("Export data source progress dialog",
                              "Exporting data...",
                              prog_n_max, // range
                              this,
                              wxPD_CAN_ABORT|wxPD_AUTO_HIDE|wxPD_APP_MODAL);
    bool cont = true;
    while (layer->export_progress < prog_n_max) {
        wxSleep(1);
        cont = prog_dlg.Update(layer->export_progress);
        
        if (!cont ) {
            layer->T_StopExport();
            return;
        }
        if (layer->export_progress == -1){
            ostringstream msg;
            msg << "Exporting to data source (" << ds_name.ToStdString()
            << ") failed." << "\n\nDetails:" 
            << layer->error_message.str();
            throw GdaException(msg.str().c_str());
        }
    }
}
Example #15
0
wxString RebrandingHelper::GetNewName(wxString scope) const
{
	if (rename.find(scope) != rename.end())
		return rename.find(scope)->second;

	for(auto & it : renameRegex)
	{
		if (std::regex_match(scope.ToStdString(), it.first))
			return it.second;
	}

	return "";
}
Example #16
0
bool RebrandingHelper::ShouldDelete(wxString scope) const
{
	if (deletions.find(scope) != deletions.end())
		return true;

	for(auto & regex : deletionsRegex)
	{
		if (std::regex_match(scope.ToStdString(), regex))
			return true;
	}

	return false;
}
Example #17
0
u32 CompilePPUProgram::GetBranchValue(const wxString& branch)
{
	for(u32 i=0; i<m_branches.GetCount(); ++i)
	{
		if(branch.ToStdString() != m_branches[i].m_name)
			continue;
		if(m_branches[i].m_pos >= 0) return m_text_addr + m_branches[i].m_pos * 4;

		return m_branches[i].m_addr;
	}

	return 0;
}
bool MapDocument::DoOpenDocument(const wxString& file)
{
    try
    {
        MapHandlerManager().Load(file.ToStdString(), map);
    }
    catch (const char* str)
    {
        wxMessageBox(str, _("Error"));
        return false;
    }
    return true;
}
Example #19
0
void LogMessageQueue::DoLogRecord(wxLogLevel level, const wxString& msg, const wxLogRecordInfo& info){
    //Discard verbose output, they should only be output to a file
    if(level >= wxLOG_Info)
        return;

    std::string out =  msg.ToStdString();
    try{
        message_queue eq(open_only, "error");
        eq.send(out.data(), out.size(), 5);
    }
    catch(std::exception &ex){
        wxLogError("%s", ex.what());
    }
}
Example #20
0
void xLightsFrame::SetChoicebook(wxChoicebook* cb, const wxString& PageName)
{
    RenderableEffect *reff = effectManager.GetEffect(PageName.ToStdString());
    if (reff != nullptr) {
        for(size_t i=0; i<cb->GetPageCount(); i++)
        {
            if (cb->GetPageText(i) == reff->ToolTip())
            {
                cb->ChangeSelection(i);
                return;
            }
        }
    }
}
Example #21
0
bool GdaJson::findValue(const json_spirit::Object& input,
						json_spirit::Value& output,
						const wxString& name)
{
	std::string std_name(name.ToStdString());
	const json_spirit::Object o=input;
	for (json_spirit::Object::const_iterator i=o.begin(); i!=o.end(); ++i)
	{
		if (i->name_ == std_name) {
			output = i->value_;
			return true;
		}
	}
	return false;
}
Example #22
0
wxString GdaJson::getStrValFromObj(const json_spirit::Object& obj,
								   const wxString& name)
{
	std::string std_name(name.ToStdString());
	for (json_spirit::Object::const_iterator i=obj.begin(); i!=obj.end(); ++i)
	{
		if (i->name_ == std_name) {
			if (i->value_.type() == json_spirit::str_type) {
				return wxString(i->value_.get_str());
			}
			return "";
		}
	}
	return "";
}
Example #23
0
void CompilePPUProgram::SetSp(const wxString& name, u32 addr, bool create)
{
	if(create)
	{
		m_branches.Move(new Branch(name, -1, addr));
		return;
	}

	GetBranch(name);

	for(u32 i=0; i<m_branches.GetCount(); ++i)
	{
		if(name.ToStdString() != m_branches[i].m_name)
			continue;
		m_branches[i].m_addr = addr;
	}
}
Example #24
0
void MainWindow::OnNameItemTree(wxCommandEvent& WXUNUSED(event))
{
	wxTreeItemId itemId  = tree->GetSelection();
	NodeTree *itemData = itemId .IsOk() ? (NodeTree *)tree->GetItemData(itemId ):NULL;
    static wxString s_text;
    s_text = wxGetTextFromUser(wxT("New name:"), wxT("Change Name Item Tree"),s_text, this);
	char text[100];
	strcpy(text,(const char*)s_text.mb_str(wxConvUTF8));
	if(!s_text.empty() && itemData->menus.menu_world)
	{
		tree->SetItemText(itemId, s_text);
		itemData->getSimu()->setName(s_text.ToStdString());
	}
    else if ( !s_text.empty() && itemData->pointer.positionableentity)
    {
		itemData->pointer.positionableentity->setName(text);
		tree->SetItemText(itemId, s_text);
    }
}
Example #25
0
/** ComplxFrame
  *
  * Constructor
  */
ComplxFrame::ComplxFrame(long decimal, long disassemble, long stack_size, long true_traps, long interrupts, long highlight,
                         wxString address_str, wxString state_file, wxArrayString files) : ComplxFrameDecl(NULL), console(NULL), memoryView(NULL)
{
    InitImages();

    menuStateTrueTraps->Check(true_traps == 1);
    menuStateInterrupts->Check(interrupts == 1);
    menuViewInstructionHighlighting->Check(highlight != 0);
    menuViewUnsignedDecimal->Check(decimal == 1);

    this->stack_size = stack_size;
    OnInit();

    if (!address_str.IsEmpty())
    {
        int addr;
        lc3_calculate(state, address_str.ToStdString(), addr);
        state.pc = addr;
    }

    if (!state_file.IsEmpty()) DoLoadMachine(wxFileName(state_file));
    if (files.size() > 0) DoLoadFile(wxFileName(files[0]));

    memoryView = new MemoryView();
    memory->SetView(memoryView);
    memory->SetDisassembleLevel(disassemble > 2 ? 2 : disassemble);
    memory->SetUnsignedMode(decimal > 1 ? 0 : decimal);
    memory->SetHighlight(highlight > 1 ? 1 : highlight);

    int widths[3] = {-7, -3, -3};
    int styles[3] = {wxSB_NORMAL, wxSB_NORMAL, wxSB_NORMAL};
    statusBar->SetStatusWidths(3, widths);
    statusBar->SetStatusStyles(3, styles);

    UpdateMemory();
    UpdateStatus();

    Connect(wxID_ANY, wxEVT_COMMAND_RUNTHREAD_COMPLETED, wxThreadEventHandler(ComplxFrame::OnRunComplete));
    Connect(wxID_ANY, wxEVT_COMMAND_RUNTHREAD_UPDATE, wxThreadEventHandler(ComplxFrame::OnRunUpdate));
    Connect(wxID_ANY, wxEVT_COMMAND_RUNTHREAD_IO, wxThreadEventHandler(ComplxFrame::OnIo));
    Connect(wxID_ANY, wxEVT_COMMAND_RUNTHREAD_NOIO, wxThreadEventHandler(ComplxFrame::OnNoIo));
    Connect(wxID_ANY, wxEVT_COMMAND_RUNTHREAD_OUTPUT, wxThreadEventHandler(ComplxFrame::OnOutput));
}
Example #26
0
// -----------------------------------------------------------------------------
// SIconButton class constructor
// -----------------------------------------------------------------------------
SIconButton::SIconButton(wxWindow* parent, Icons::Type icon_type, const wxString& icon, const wxString& tooltip) :
	wxBitmapButton{ parent, -1, wxNullBitmap }
{
	// Create icon
	auto bmp = Icons::getIcon(icon_type, icon.ToStdString(), UI::scaleFactor() > 1.);

	// Scale icon if required
	auto size = UI::scalePx(16);
	if (bmp.GetWidth() != size)
	{
		auto img = bmp.ConvertToImage();
		img.Rescale(size, size, wxIMAGE_QUALITY_BICUBIC);
		bmp = wxBitmap(img);
	}

	// Set button image and tooltip
	SetBitmap(bmp);
	if (!tooltip.empty())
		SetToolTip(tooltip);
}
Example #27
0
bool DirProperty::ValidateValue(wxVariant& value,
		wxPGValidationInfo& validationinfo) const {
	const wxString dir = value.GetString();
	namespace fs = boost::filesystem;
	return fs::exists(fs::path(dir.ToStdString()));
}
Example #28
0
void PlotXY::SaveToFile(const wxString& path)
{
    plotLua_->saveToFile(path.ToStdString());
}
Example #29
0
void PlotXY::ExportToCSV(const wxString& filepath)
{
    plotLua_->saveCSV(filepath.ToStdString());
}
Example #30
0
/** process_str
  *
  * Unescapes and removes quotes from string (see lc3_parser.cpp if you change this)
  */
std::string process_str(wxString str, int& error)
{
    return process_str(str.ToStdString(), error);
}