Example #1
0
wsArgInfo::wsArgInfo( const wxString &argName, const wxString &argType, const wxString &argMode, const wxString &argTypeOid)
	: m_name( argName.Strip( wxString::both )),
	  m_type( argType.Strip( wxString::both )),
	  m_mode( argMode == wxT( "" ) ? wxT( "i" ) : argMode.Strip( wxString::both )),
	  m_value()
{
	long oid;
	argTypeOid.ToLong(&oid);
	m_typeOid = (Oid)oid;
}
Example #2
0
void Identifier::setText(const wxString& source)
{
    // although it may not be completely correct we right-trim everything we
    // get. This means that users can't use quoted identifiers which end with
    // a space - but who does that anyway
    textM = source.Strip();
}
Example #3
0
double
wxPdfUtility::String2Double(const wxString& str)
{
  wxString value = str.Strip(wxString::both);
  double result = 0;
  double sign = 1;
  int scale = 0;
  int exponent = 0;
  int expsign = 1;
  int j = 0;
  int jMax = (int) value.Length();
  if (jMax > 0)
  {
    if (value[j] == wxT('+'))
    {
      j++;
    }
    else if (value[j] == wxT('-'))
    {
      sign = -1;
      j++;
    }
    while (j < jMax && wxIsdigit(value[j]))
    {
      result = result*10 + (value[j] - wxT('0'));
      j++;
    }
    if (j < jMax && value[j] == wxT('.'))
    {
      j++;
      while (j < jMax && wxIsdigit(value[j]))
      {
        result = result*10 + (value[j] - wxT('0'));
        scale++;
        j++;
      }
    }
    if (j < jMax && (value[j] == wxT('E') || value[j] == wxT('e')))
    {
      j++;
      if (value[j] == wxT('+'))
      {
        j++;
      }
      else if (value[j] == wxT('-'))
      {
        expsign = -1;
        j++;
      }
      while (j < jMax && wxIsdigit(value[j]))
      {
        exponent = exponent*10 + (value[j] - wxT('0'));
        j++;
      }
      exponent *= expsign;
    }
    result = sign * result * pow(10.0, exponent-scale);
  }
  return result;
}
void EventWatcherFrame::addEvents(wxString& s)
{
    // deselect all items so user can cleanly see what is added
    for (int ix = 0; ix < (int)listbox_monitored->GetCount(); ++ix)
    {
        if (listbox_monitored->IsSelected(ix))
            listbox_monitored->Deselect(ix);
    }
    while (true)
    {
        int p = s.Find("\n");
        wxString s2;
        if (p == -1)
            s2 = s.Strip();
        else
        {
            s2 = s.Left(p).Strip(wxString::both);
            s.Remove(0, p);
            s.Trim(false);
        }
        if (!s2.IsEmpty() && listbox_monitored->FindString(s2) == wxNOT_FOUND)
            listbox_monitored->Select(listbox_monitored->Append(s2));
        if (p == -1)
            break;
    }
    updateControls();
}
int ValueFromString( EDA_UNITS_T aUnits, const wxString& aTextValue )
{
    double value;
    double dtmp = 0;

    // Acquire the 'right' decimal point separator
    const struct lconv* lc = localeconv();

    wxChar      decimal_point = lc->decimal_point[0];
    wxString    buf( aTextValue.Strip( wxString::both ) );

    // Convert the period in decimal point
    buf.Replace( wxT( "." ), wxString( decimal_point, 1 ) );

    // An ugly fix needed by WxWidgets 2.9.1 that sometimes
    // back to a point as separator, although the separator is the comma
    // TODO: remove this line if WxWidgets 2.9.2 fixes this issue
    buf.Replace( wxT( "," ), wxString( decimal_point, 1 ) );

    // Find the end of the numeric part
    unsigned brk_point = 0;

    while( brk_point < buf.Len() )
    {
        wxChar ch = buf[brk_point];

        if( !( (ch >= '0' && ch <='9') || (ch == decimal_point) || (ch == '-') || (ch == '+') ) )
        {
            break;
        }

        ++brk_point;
    }

    // Extract the numeric part
    buf.Left( brk_point );

    buf.ToDouble( &dtmp );

    // Check the optional unit designator (2 ch significant)
    wxString unit( buf.Mid( brk_point ).Strip( wxString::leading ).Left( 2 ).Lower() );

    if( unit == wxT( "in" ) || unit == wxT( "\"" ) )
    {
        aUnits = INCHES;
    }
    else if( unit == wxT( "mm" ) )
    {
        aUnits = MILLIMETRES;
    }
    else if( unit == wxT( "mi" ) || unit == wxT( "th" ) ) // Mils or thous
    {
        aUnits = INCHES;
        dtmp /= 1000;
    }

    value = From_User_Unit( aUnits, dtmp );

    return KiROUND( value );
}
Example #6
0
void
SliderBar::set_units (const wxString & units)
{
    _units_str = units.Strip(wxString::both);
    if (!_units_str.empty()) {
        _units_str = wxT(" ") + _units_str;
    }
    update_value_str();
    do_redraw();
}
Example #7
0
void ColumnBase::initialize(const wxString& source, bool nullable,
    const wxString& defaultValue, bool hasDefault, bool hasDescription)
{
    bool changed = false;
    setIfChanged(sourceM, source.Strip(wxString::both), changed);
    setIfChanged(defaultM, Domain::trimDefaultValue(defaultValue), changed);
    setIfChanged(hasDefaultM, hasDefault, changed);
    setIfChanged(nullableM, nullable, changed);
    if (!hasDescription)
        setDescriptionIsEmpty();
    if (changed)
        notifyObservers();
}
Example #8
0
void wxSVGLength::SetValueAsString(const wxString& n)
{
  m_valueInSpecifiedUnits = 0;
  m_unitType = wxSVG_LENGTHTYPE_NUMBER;
  wxString value = n.Strip(wxString::both);
  wxString unit;
  if (value.length()>=2)
  {
	const wxString s_numeric = wxT("0123456789");
	const wxString s_numericFirst = wxT("+-.Ee") + s_numeric;
	if (!s_numeric.Contains(value.Right(1)))
	{
	  if (s_numericFirst.Contains(value.Mid(value.Length()-2,1)))
	  {
		unit = value.Right(1);
		value = value.Left(value.Length()-1);
	  }
	  else
	  {
		unit = value.Right(2);
		value = value.Left(value.Length()-2);
	  }
	}
  }
  
  double d;
  if (!value.ToDouble(&d))
	return;
  m_valueInSpecifiedUnits = d;
  
  if (unit.length() == 0);
  else if (unit == wxT("px"))
	m_unitType = wxSVG_LENGTHTYPE_PX;
  else if (unit.Right(1) == wxT("%"))
	m_unitType = wxSVG_LENGTHTYPE_PERCENTAGE;
  else if (unit == wxT("em"))
	m_unitType = wxSVG_LENGTHTYPE_EMS;
  else if (unit == wxT("ex"))
	m_unitType = wxSVG_LENGTHTYPE_EXS;
  else if (unit == wxT("cm"))
	m_unitType = wxSVG_LENGTHTYPE_CM;
  else if (unit == wxT("mm"))
	m_unitType = wxSVG_LENGTHTYPE_MM;
  else if (unit == wxT("in"))
	m_unitType = wxSVG_LENGTHTYPE_IN;
  else if (unit == wxT("pt"))
	m_unitType = wxSVG_LENGTHTYPE_PT;
  else if (unit == wxT("pc"))
	m_unitType = wxSVG_LENGTHTYPE_PC;
  SetValueInSpecifiedUnits(m_valueInSpecifiedUnits);
}
Example #9
0
USHORT pgsRecord::get_column(wxString name) const
{
	name = name.Strip(wxString::both).Lower();
	if (name.IsEmpty())
	{
		return count_columns();
	}
	for (USHORT i = 0; i < count_columns(); i++)
	{
		if (m_columns[i] == name)
			return i;
	}
	return count_columns();
}
Example #10
0
void Column::initialize(const wxString& source, const wxString& computedSource,
    const wxString& collation, bool nullable,
    const wxString& defaultValue, bool hasDefault, bool hasDescription)
{
    SubjectLocker lock(this);

    ColumnBase::initialize(source, nullable, defaultValue, hasDefault,
        hasDescription);

    bool changed = false;
    setIfChanged(computedSourceM, computedSource, changed);
    setIfChanged(collationM, collation.Strip(wxString::both), changed);
    if (changed)
        notifyObservers();
}
Example #11
0
void CommandCache::AppendCommand(const wxString& cmd)
{
	wxString cmdStrip = cmd.Strip(wxString::both);
	if (cmdStrip.IsEmpty())
	{
		return;
	}

	m_vecCachedCommand.push_back(std::make_pair(cmdStrip, cmdStrip.size()));
	if (m_vecCachedCommand.size() > m_nCachedMaxCount)
	{
		m_vecCachedCommand.pop_front();
		return;
	}

	m_nCachedCursor = m_vecCachedCommand.size() - 1;
	assert(m_nCachedCursor <= m_nCachedMaxCount - 1);
}
Example #12
0
void StatementHistory::add(const wxString& str)
{
    if (str.Strip().IsEmpty() ||    // empty or too big string
        (config().get("limitHistoryItemSize", false) &&
        int(str.Length()) > 1024 * config().get("statementHistoryItemSize", 500)))
    {
        return;
    }

    if (sizeM == 0 || get(sizeM-1) != str)
    {
        wxFFile f(getFilename(sizeM), "wb+");
        if (f.IsOpened())
        {
            f.Write(str);
            f.Close();
            sizeM++;
        }
    }
}
Example #13
0
bool pgsRecord::set_column_name(const USHORT &column, wxString name)
{
	// Column number must be valid
	if (column >= count_columns())
	{
		return false;
	}

	// Column name must not exist
	// Column name must not be empty
	name = name.Strip(wxString::both).Lower();
	if (m_columns.Index(name) != wxNOT_FOUND || name.IsEmpty())
	{
		return false;
	}

	// Set the column name
	m_columns[column] = name;

	return true;
}
// When the string param given has string quotes around it
// we remove them and we pass back the string. If not, we 
// simply pass back the string as-is
wxString cmCommandLineInfo::GetStringParam(const wxString &str)
{
    wxString mystr = str.Strip(wxString::both);

    // if we have only one (or no chars return the current string)
    if(mystr.Len() < 2)
        return str;

    // if we have quotes
    if(mystr.GetChar(0) == '\"' && mystr.Last() == '\"')
    {
        // when we only have 2 in size, return empty string
        if(mystr.Len() == 2)
            return wxEmptyString;

        // now remove the outer and inner, and return
        return mystr.Mid(1, mystr.Len()-1);
    }

    return str;
}
Example #15
0
pgsNumber::pgsNumber(const wxString &data, const bool &is_real) :
	pgsVariable(!is_real ? pgsVariable::pgsTInt : pgsVariable::pgsTReal),
	m_data(data.Strip(wxString::both))
{
	wxASSERT(is_valid());
}