Пример #1
0
bool GERBVIEW_FRAME::OpenProjectFiles( const std::vector<wxString>& aFileSet, int aCtl )
{
    // The current project path is also a valid command parameter.  Check if a single path
    // rather than a file name was passed to GerbView and use it as the initial MRU path.
    if( aFileSet.size() > 0 )
    {
        wxString path = aFileSet[0];

        // For some reason wxApp appears to leave the trailing double quote on quoted
        // parameters which are required for paths with spaces.  Maybe this should be
        // pushed back into PGM_SINGLE_TOP::OnPgmInit() but that may cause other issues.
        // We can't buy a break!
        if( path.Last() ==  wxChar( '\"' ) )
            path.RemoveLast();

        if( !wxFileExists( path ) && wxDirExists( path ) )
        {
            wxLogDebug( wxT( "MRU path: %s." ), GetChars( path ) );
            m_mruPath = path;
            return true;
        }

        const unsigned limit = std::min( unsigned( aFileSet.size() ),
                                         unsigned( GERBER_DRAWLAYERS_COUNT ) );

        int layer = 0;

        for( unsigned i=0;  i<limit;  ++i, ++layer )
        {
            setActiveLayer( layer );

            // Try to guess the type of file by its ext
            // if it is .drl (Kicad files), it is a drill file
            wxFileName fn( aFileSet[i] );
            wxString ext = fn.GetExt();

            if( ext == "drl" )
                LoadExcellonFiles( aFileSet[i] );
            else
                LoadGerberFiles( aFileSet[i] );
        }
    }

    Zoom_Automatique( true );        // Zoom fit in frame

    UpdateTitleAndInfo();

    return true;
}
wxString FOOTPRINTS_LISTBOX::GetSelectedFootprint()
{
    wxString footprintName;
    int      ii = GetFirstSelected();

    if( ii >= 0 )
    {
        wxString msg = m_footprintList[ii];
        msg.Trim( true );
        msg.Trim( false );
        footprintName = msg.AfterFirst( wxChar( ' ' ) );
    }

    return footprintName;
}
Пример #3
0
void MenuEditor::OnMenuRight(wxCommandEvent& )
{
    int sel = GetSelectedItem();
    int curIdent = GetItemIdentation(sel) + 1;
    int parentIdent = sel > 0 ? GetItemIdentation(sel - 1) : -1;

    if (parentIdent == -1 || abs(curIdent - parentIdent) > 1)
        return;

    wxString label = m_menuList->GetItemText(sel);
    label.Trim(true);
    label.Trim(false);
    label = wxString(wxChar(' '), curIdent * IDENTATION) + label;
    m_menuList->SetItemText(sel, label);
}
Пример #4
0
void MenuEditor::OnMenuLeft(wxCommandEvent& )
{
    int sel = GetSelectedItem();
    int curIdent = GetItemIdentation(sel) - 1;
    int childIdent = sel < m_menuList->GetItemCount() - 1 ? GetItemIdentation(sel + 1) : -1;

    if (curIdent < 0 || (childIdent != -1 && abs(curIdent - childIdent) > 1))
        return;

    wxString label = m_menuList->GetItemText(sel);
    label.Trim(true);
    label.Trim(false);
    label = wxString(wxChar(' '), curIdent * IDENTATION) + label;
    m_menuList->SetItemText(sel, label);
}
Пример #5
0
TemplateParser::Ident TemplateParser::ParseIdent()
{
	Ident ident = ID_ERROR;

	if (!m_in.Eof())
	{
		wxString macro;
		m_in.GetC();

		wxChar peek( m_in.Peek() );
		while (peek != wxChar(EOF) && !m_in.Eof() && peek != wxT('#') && peek != wxT('$')
			&& ( (peek >= wxT('a') && peek <= wxT('z') ) ||
			(peek >= wxT('A') && peek <= wxT('Z') ) ||
			(peek >= wxT('0') && peek <= wxT('9') ) ))
		{
			macro += wxChar( m_in.GetC() );
			peek = wxChar( m_in.Peek() );
		}

		// Searching the identifier
		ident = SearchIdent( macro );
	}
	return ident;
}
Пример #6
0
void TextCtrlTestCase::LongText()
{
    // This test is only possible under MSW as in the other ports
    // SetMaxLength() can't be used with multi line text controls.
#ifdef __WXMSW__
    delete m_text;
    CreateText(wxTE_MULTILINE|wxTE_DONTWRAP);

    const int numLines = 1000;
    const int lenPattern = 100;
    int i;

    // Pattern for the line.
    wxChar linePattern[lenPattern+1];
    for (i = 0; i < lenPattern - 1; i++)
    {
        linePattern[i] = wxChar('0' + i % 10);
    }
    linePattern[WXSIZEOF(linePattern) - 1] = wxChar('\0');

    // Fill the control.
    m_text->SetMaxLength(15000);
    for (i = 0; i < numLines; i++)
    {
        m_text->AppendText(wxString::Format(wxT("[%3d] %s\n"), i, linePattern));
    }

    // Check the content.
    for (i = 0; i < numLines; i++)
    {
        wxString pattern = wxString::Format(wxT("[%3d] %s"), i, linePattern);
        wxString line = m_text->GetLineText(i);
        CPPUNIT_ASSERT_EQUAL( line, pattern );
    }
#endif // __WXMSW__
}
Пример #7
0
void MenuEditor::AddItem(const wxString& label, const wxString& shortcut,
  const wxString& id, const wxString& name, const wxString &help, const wxString &kind)
{
    int sel = GetSelectedItem();
    int identation = 0;
    if (sel >= 0) identation = GetItemIdentation(sel);
    wxString labelAux = label;
    labelAux.Trim(true);
    labelAux.Trim(false);
    if (sel < 0) sel = m_menuList->GetItemCount() - 1;

    labelAux = wxString(wxChar(' '), identation * IDENTATION) + labelAux;

    long index = InsertItem(sel + 1, labelAux, shortcut, id, name, help, kind);
    m_menuList->SetItemState(index, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED);
}
Пример #8
0
void ServerEvents::OnMutelistItem(const std::string& /*unused*/, const std::string& mutee, const std::string& description)
{
	wxString message = TowxString(mutee);
	wxString desc = TowxString(description);
	wxString mutetime = desc.AfterFirst(wxChar(' '));
	long time;
	if (mutetime == _T("indefinite"))
		message << _(" indefinite time remaining");
	else if (mutetime.ToLong(&time))
		message << wxString::Format(_(" %d minutes remaining"), time / 60 + 1);
	else
		message << mutetime;
	if (!desc.IsEmpty())
		message << _T(", ") << desc;
	mutelistWindow(message);
}
SCH_COMPONENT* NETLIST_EXPORTER::findNextComponent( EDA_ITEM* aItem, SCH_SHEET_PATH* aSheetPath )
{
    wxString    ref;

    // continue searching from the middle of a linked list (the draw list)
    for(  ; aItem;  aItem = aItem->Next() )
    {
        if( aItem->Type() != SCH_COMPONENT_T )
            continue;

        // found next component
        SCH_COMPONENT* comp = (SCH_COMPONENT*) aItem;

        // Power symbols and other components which have the reference starting
        // with "#" are not included in netlist (pseudo or virtual components)
        ref = comp->GetRef( aSheetPath->Last() );

        if( ref[0] == wxChar( '#' ) )
            continue;

        // if( Component->m_FlagControlMulti == 1 )
        //    continue;                                      /* yes */
        // removed because with multiple instances of one schematic
        // (several sheets pointing to 1 screen), this will be erroneously be
        // toggled.

        LIB_PART* part = m_libs->FindLibPart( comp->GetPartName() );
        if( !part )
            continue;

        // If component is a "multi parts per package" type
        if( part->GetUnitCount() > 1 )
        {
            // test if this reference has already been processed, and if so skip
            if( m_ReferencesAlreadyFound.Lookup( ref ) )
                continue;
        }

        // record the usage of this library component entry.
        m_LibParts.insert( part );     // rejects non-unique pointers

        return comp;
    }

    return NULL;
}
Пример #10
0
void CUtils::dump(const wxChar* title, const unsigned char* data, unsigned int length)
{
    wxASSERT(title != NULL);
    wxASSERT(data != NULL);

    wxLogMessage(wxT("%s"), title);

    unsigned int offset = 0U;

    while (length > 0U) {
        wxString output;

        unsigned int bytes = (length > 16U) ? 16U : length;

        for (unsigned i = 0U; i < bytes; i++) {
            wxString temp;
            temp.Printf(wxT("%02X "), data[offset + i]);
            output += temp;
        }

        for (unsigned int i = bytes; i < 16U; i++)
            output += wxT("   ");

        output += wxT("   *");

        for (unsigned i = 0U; i < bytes; i++) {
            unsigned char c = data[offset + i];

            if (::isprint(c))
                output += wxChar(c);
            else
                output += wxT('.');
        }

        output += wxT('*');

        wxLogMessage(wxT("%04X:  %s"), offset, output.c_str());

        offset += 16U;

        if (length >= 16U)
            length -= 16U;
        else
            length = 0U;
    }
}
Пример #11
0
const std::string wxExViMacros::Decode(const std::string& text)
{
  std::string output;

  for (size_t i = 0; i < text.length(); i++)
  {
    if (
      i + 1 < text.length() &&
      text[i]     == '$' &&
      text[i + 1] == '!')
    {
      int skip = 0;
      wxString number;
    
      if (
        i + 3 < text.length() &&
        isdigit(text[i + 2]) && 
        text[i + 3] == '!')
      {
        skip  = 3;
        number = text.substr(i + 2, 1);
      }
      else if (
        i + 4 < text.length() &&
        isdigit(text[i + 2]) &&
        isdigit(text[i + 3]) &&
        text[i + 4] == '!')
      {
        skip = 4;
        number = text.substr(i + 2, 2);
      }
      
      if (!number.empty())
      {
        output += wxChar(atoi(number));
        i += skip;
      }
    }
    else
    {
      output += text[i];
    }
  }
  
  return output;
}
Пример #12
0
bool wxsCorrector::FixVarName(wxString& Name)
{
    wxString Corrected;
    Name.Trim(true);
    Name.Trim(false);

    if ( !Name.empty() )
    {
        // Validating name as C++ ideentifier
        // TODO: Other languages ?

        static wxString FirstChar(
            _T("ABCDEFGHIJKLMNOPQRSTUVWXYZ")
            _T("abcdefghijklmnopqrstuvwxyz")
            _T("_"));

        if ( FirstChar.Find(Name.GetChar(0)) == -1 )
            Manager::Get()->GetLogManager()->DebugLog(F(_T("wxSmith: Variable name : \"%s\" is not a valid c++ identifier (invalid character \"%c\" at position %d)"),Name.wx_str(),wxChar(Name.GetChar(0)),0));
        else
            Corrected.Append(Name.GetChar(0));

        static wxString NextChars(
            _T("0123456789")
            _T("ABCDEFGHIJKLMNOPQRSTUVWXYZ")
            _T("abcdefghijklmnopqrstuvwxyz")
            _T("_"));

        for ( size_t i=1; i<Name.Length(); ++i )
        {
            if ( NextChars.Find(Name.GetChar(i)) == -1 )
            {
                Manager::Get()->GetLogManager()->DebugLog(F(_T("wxSmith: Variable name : \"%s\" is not a valid c++ identifier (invalid character \"%c\" at position %lu)"),
                                                            Name.wx_str(),
                                                            wxChar(Name.GetChar(i)),
                                                            static_cast<unsigned long>(i)));
            }
            else
                Corrected.Append(Name.GetChar(i));
        }
    }

    bool Diff = Name != Corrected;
    Name = Corrected;
    return Diff;
}
Пример #13
0
static wxString Code128PackDigits(const wxString& text, size_t& textIndex, int numDigits)
{
    wxString code = wxEmptyString;
    while (numDigits > 0)
    {
        if (text[textIndex] == CODE128_FNC1)
        {
            code += CODE128_FNC1_INDEX;
            ++textIndex;
            continue;
        }
        numDigits -= 2;
        int c1 = text[textIndex++] - wxT('0');
        int c2 = text[textIndex++] - wxT('0');
        code += wxChar(c1 * 10 + c2);
    }
    return code;
}
Пример #14
0
wxString
wxPdfFontDetails::CreateSubsetPrefix() const
{
  wxString prefix = wxT("WXP");
  int k;
  int code = m_index;
  for (k = 0; k < 3; k++)
  {
#if wxCHECK_VERSION(2,9,0)
    prefix += wxUniChar(wxT('A' + (code % 26)));
#else
    prefix += wxChar(wxT('A' + (code % 26)));
#endif
    code /= 26;
  }
  prefix += wxT("+");
  return prefix;
}
Пример #15
0
strStream::strStream()
{
    static const size_t LEN = 256;
    m_str.reserve(LEN);
#if defined(__INTEL_COMPILER) && 1 /* VDM auto patch */
#   pragma ivdep
#   pragma swp
#   pragma unroll
#   pragma prefetch
#   if 0
#       pragma simd noassert
#   endif
#endif /* VDM auto patch */
    for ( size_t n = 0; n < LEN; n++ )
    {
        m_str += wxChar(wxT('A') + n % (wxT('Z') - wxT('A') + 1));
    }
}
Пример #16
0
bool nwxString::FileNameStringOK(const wxString &s)
{
  const wxString BAD("<>:\"/\\|?*'`");
  size_t nLen = s.Len();
  size_t i;
  wxChar x;
  bool bRtn = true;
  for(i = 0; i < nLen; i++)
  {
    x = s.GetChar(i);
    if( (x & 0x80) || (x < wxChar(' ')) || (BAD.find(x) != (size_t)wxNOT_FOUND) )
    {
      bRtn = false;
      i = nLen;
    }
  }
  return bRtn;
}
Пример #17
0
wxString
wxPdfFontDataCore::ConvertCID2GID(const wxString& s, 
                                  const wxPdfEncoding* encoding,
                                  wxPdfSortedArrayInt* usedGlyphs, 
                                  wxPdfChar2GlyphMap* subsetGlyphs) const
{
  // No conversion from cid to gid
  wxUnusedVar(usedGlyphs);
  wxUnusedVar(subsetGlyphs);
#if wxUSE_UNICODE
  const wxPdfChar2GlyphMap* convMap = FindEncodingMap(encoding);
  wxString t;
  if (convMap != NULL)
  {
    wxPdfChar2GlyphMap::const_iterator charIter;
    wxString::const_iterator ch;
    for (ch = s.begin(); ch != s.end(); ++ch)
    {
      charIter = (*convMap).find(*ch);
      if (charIter != (*convMap).end())
      {
#if wxCHECK_VERSION(2,9,0)
        t.Append(wxUniChar(charIter->second));
#else
        t.Append(wxChar(charIter->second));
#endif
      }
      else
      {
        t += wxT("?");
      }
    }
  }
  else
  {
    t = s;
  }
  return t;
#else
  // Return unchanged string in ANSI build
  wxUnusedVar(encoding);
  return s;
#endif
}
Пример #18
0
PlatformKeyboardEvent::PlatformKeyboardEvent(wxKeyEvent& event)
{
    if (event.GetEventType() == wxEVT_KEY_UP)
        m_type = PlatformEvent::KeyUp;
    else if (event.GetEventType() == wxEVT_KEY_DOWN)
        m_type = PlatformEvent::KeyDown;
    else if (event.GetEventType() == wxEVT_CHAR)
        m_type = PlatformEvent::Char;
    else
        ASSERT_NOT_REACHED();
    if (m_type != PlatformEvent::Char)
        m_keyIdentifier = keyIdentifierForWxKeyCode(event.GetKeyCode());
    else {
        //ENTER is an editing command processed as a char (only Enter and Tab are)
        //unfortunately the unicode key for numpad_enter (370) is NOT what we want here (13)
        //The unicode values for normal enter and tab are the same as the ASCII values, thus ok
        //Note that I think this a wx bug, as the Character Code is actually 13 when
        //numpad_enter is a CHAR event.
        if (event.GetKeyCode() == 13 && event.GetUnicodeKey() == wxChar(370))
            m_text = "\r";
        else
            m_text = wxString(event.GetUnicodeKey());
        m_unmodifiedText = m_text;
    }
    m_autoRepeat = false; // FIXME: not correct.
    m_windowsVirtualKeyCode = windowsKeyCodeForKeyEvent(event.GetKeyCode());
    m_nativeVirtualKeyCode = event.GetKeyCode();
    m_isKeypad = (event.GetKeyCode() >= WXK_NUMPAD_SPACE) && (event.GetKeyCode() <= WXK_NUMPAD_DIVIDE);
    
    m_modifiers = 0;
    if (event.ShiftDown())
        m_modifiers |= ShiftKey;
    
    if (event.CmdDown())
        m_modifiers |= CtrlKey;
    
    if (event.AltDown())
        m_modifiers |= AltKey;
    
    if (event.MetaDown())
        m_modifiers |= MetaKey;
    
    m_timestamp = WTF::currentTime();
}
Пример #19
0
void CUtils::dumpRev(const wxChar* title, const bool* data, unsigned int length)
{
	wxASSERT(title != NULL);
	wxASSERT(data != NULL);

	wxLogMessage(wxT("%s"), title);

	unsigned int offset = 0U;

	while (offset < length) {
		wxString output;

		unsigned char buffer[16];
		unsigned int bytes = 0U;
		for (unsigned int bits = 0U; bits < 128U && (offset + bits) < length; bits += 8U)
			buffer[bytes++] = bitsToByteRev(data + offset + bits);

		for (unsigned i = 0U; i < bytes; i++) {
			wxString temp;
			temp.Printf(wxT("%02X "), buffer[i]);
			output += temp;
		}

		for (unsigned int i = bytes; i < 16U; i++)
			output += wxT("   ");

		output += wxT("   *");

		for (unsigned i = 0U; i < bytes; i++) {
			unsigned char c = buffer[i];

			if (::isprint(c))
				output += wxChar(c);
			else
				output += wxT('.');
		}

		output += wxT('*');

		wxLogMessage(wxT("%04X:  %s"), offset / 8U, output.c_str());

		offset += 128U;
	}
}
Пример #20
0
void MenuEditor::OnModifyMenuItem(wxCommandEvent& )
{
    long index = GetSelectedItem();
    int identation = GetItemIdentation(index);
    wxString kind;
    switch (m_rbItemKind->GetSelection())
    {
        case 0: kind = wxT("wxITEM_NORMAL"); break;
        case 1: kind = wxT("wxITEM_CHECK"); break;
        case 2: kind = wxT("wxITEM_RADIO"); break;
    }

    m_menuList->SetItem(index, 0, wxString(wxChar(' '), identation * IDENTATION) + m_tcLabel->GetValue());
    m_menuList->SetItem(index, 1, m_tcShortcut->GetValue());
    m_menuList->SetItem(index, 2, m_tcId->GetValue());
    m_menuList->SetItem(index, 3, m_tcName->GetValue());
    m_menuList->SetItem(index, 4, m_tcHelpString->GetValue());
    m_menuList->SetItem(index, 5, kind);
}
Пример #21
0
//Replace TABs with needed spaces returning a 'tabulated' string
wxString wxFixWidthImportCtrl::TabsToSpaces(const wxString& str) const
{
    wxString stRes;

    if (m_tabSize < 0)
    {
        stRes = str;
        return stRes;
    }
    if (m_tabSize == 0)
    {
        stRes = str;
        // remove tabs
        stRes.Replace(wxT("\t"), wxEmptyString);
        return stRes;
    }

    size_t pos = 0;
    size_t nSp = 0;
    wxString tabRep;
    wxChar ch;

    for ( wxString::const_iterator i = str.begin(); i != str.end(); ++i )
    {
        ch = *i;
        if ( ch == wxT('\t') )
        {
            tabRep = wxT("");
            nSp = (size_t)m_tabSize - (pos % (size_t)m_tabSize);
            tabRep.Append(wxChar(' '), nSp);
            stRes += tabRep;
            pos += nSp;
        }
        else
        {
            stRes += ch;
            pos++;
        }
    }
    return stRes;
}
Пример #22
0
/*---------------------------------------------------------------------------*/
wxString wxBlobDialog::GetHexaString(wxMemoryBuffer* buffer)
{
   wxString retStr, HexStr, carStr;
   size_t bLen, strLen;
   char c;

   bLen = buffer->GetDataLen();
   bLen = (bLen < 32 ? bLen : 32);
   for (size_t i = 0, count = 0; i < 4; i++)
   {
      if (count >= bLen)
         break;
      HexStr = carStr = wxEmptyString;
      for (size_t j = 0; j < 8; j++, count++)
      {
         if (count >= bLen)
            break;
         c = ((char*)buffer->GetData())[count];
         if (c < 32)
         {
            if (c == 7 || c == '\r' || c == '\n')
               carStr += " ";
            else
            {
               m_FlagBin = true;
               carStr += "?";
            }
         }
         else
            carStr += wxChar(c);
         HexStr += wxString::Format("0x%02X ", (int)c);
      }
      // _("0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 | xxxxxxxx\n")
      strLen = HexStr.Len();
      HexStr += wxString(' ', 40 - strLen);
      retStr += HexStr + "| " + carStr + "\n";
   }

   return retStr;
}
Пример #23
0
wxString
decodeString(const wxString &s)
{
    wxString val = s;
    wxString ret = wxEmptyString;

    if (val.Left(1) == wxT(":") && val.Right(1) == wxT(":") && val.Length() > 1) {
        int idx = 1;
        val.Remove(0, 1);
        while (val.Length()) {
            int p = val.Find(wxT(":"));
            if (p != -1) {
                long l;
                val.Left(p).ToLong(&l);
                ret += wxChar(l - idx++);
            } else
                break;
            val.Remove(0, p + 1);
        }
    }
    return ret;
}
Пример #24
0
void MainFrame::UpdateFrame()
{
	// Actualizamos el título
	wxString date(wxT(__DATE__));
	wxString time(wxT(__TIME__));
	wxString title(wxT("wxFormBuilder (Build on ") + date +wxT(" - ")+ time + wxT(") - "));

	if (GetData()->IsModified())
		title = title + wxChar('*');

	wxString filename = GetData()->GetProjectFileName();

	title = title + ( filename.IsEmpty() ?
		wxT("[untitled]") :
	wxT("[") + filename + wxT("]"));

	SetTitle(title);

	// Actualizamos los menus
	wxMenu *menuEdit = GetMenuBar()->GetMenu(GetMenuBar()->FindMenu(wxT("Edit")));

	menuEdit->Enable(ID_REDO,GetData()->CanRedo());
	menuEdit->Enable(ID_UNDO,GetData()->CanUndo());

	// Actualizamos la barra de herramientas
	GetToolBar()->EnableTool(ID_REDO,GetData()->CanRedo());
	GetToolBar()->EnableTool(ID_UNDO,GetData()->CanUndo());
	GetToolBar()->EnableTool(ID_COPY,GetData()->CanCopyObject());
	GetToolBar()->EnableTool(ID_CUT,GetData()->CanCopyObject());
	GetToolBar()->EnableTool(ID_DELETE,GetData()->CanCopyObject());
	GetToolBar()->EnableTool(ID_PASTE,GetData()->CanPasteObject());

	UpdateLayoutTools();


	// Actualizamos la barra de estado
	// TO-DO: definir un campo...
}
Пример #25
0
size_t nwxProcess::ProcessIO(
  wxInputStream *pIn, 
  wxString &sLine,
  bool bErrStream)
{
  size_t nRtn = 0;
  size_t nLen;
  char *pBuffer;
  char *pEnd;
  const int BUFFER_SIZE = 512;
  char sBuffer[BUFFER_SIZE + 1];
  char EOL = '\n';
  if(pIn->CanRead())
  {
    nRtn = pIn->Read(sBuffer,BUFFER_SIZE).LastRead();
    sBuffer[nRtn] = 0;
    if(nRtn)
    {
      pBuffer = &sBuffer[0];
      for(pEnd = strchr(pBuffer,EOL);
          pEnd != NULL;
          pEnd = strchr(pBuffer,EOL))
      {
        *pEnd = 0;
        sLine.Append(pBuffer);
        sLine.Append(wxChar(EOL));
        *pEnd = EOL; // restore
        nLen = sLine.Len();
        ProcessLine(sLine.utf8_str(), nLen, bErrStream);
        sLine.Empty();
        pBuffer = pEnd;
        pBuffer++;
      }
      sLine += pBuffer;
    }
  }
  return nRtn;
}
Пример #26
0
void EDA_TEXT::TransformTextShapeToSegmentList( std::vector<wxPoint>& aCornerBuffer ) const
{
    wxSize size = GetSize();

    if( IsMirrored() )
        NEGATE( size.x );

    s_cornerBuffer = &aCornerBuffer;
    EDA_COLOR_T color = BLACK;  // not actually used, but needed by DrawGraphicText

    if( IsMultilineAllowed() )
    {
        wxArrayString strings_list;
        wxStringSplit( GetShownText(), strings_list, wxChar('\n') );
        std::vector<wxPoint> positions;
        positions.reserve( strings_list.Count() );
        GetPositionsOfLinesOfMultilineText( positions,strings_list.Count() );

        for( unsigned ii = 0; ii < strings_list.Count(); ii++ )
        {
            wxString txt = strings_list.Item( ii );
            DrawGraphicText( NULL, NULL, positions[ii], color,
                             txt, GetOrientation(), size,
                             GetHorizJustify(), GetVertJustify(),
                             GetThickness(), IsItalic(),
                             true, addTextSegmToBuffer );
        }
    }
    else
    {
        DrawGraphicText( NULL, NULL, GetTextPosition(), color,
                         GetText(), GetOrientation(), size,
                         GetHorizJustify(), GetVertJustify(),
                         GetThickness(), IsItalic(),
                         true, addTextSegmToBuffer );
    }
}
Пример #27
0
const wxChar * const nwxString::TIME_FORMAT(wxS("%Y-%m-%d %I:%M:%S %p"));
#ifdef __WXMSW__
#define __EOL wxS("\r\n")
#else
#define __EOL wxS("\n")
#endif
const wxChar * const nwxString::EOL(__EOL);
#undef __EOL

wxString nwxString::TIME_0("Original");

const wxString nwxString::ALPHA_UPPER("ABCDEFGHIJKLMNOPQRSTUVWXYZ");
const wxString nwxString::ALPHA_lower("abcdefghijklmnopqrstuvwxyz");
const wxString nwxString::NUMERIC("0123456789");
const wxString nwxString::EMPTY(wxEmptyString);
const wxChar nwxString::TO_LOWER(wxChar('a') - wxChar('A'));

bool nwxString::IsNumber(const wxString &s, bool bAllowExp)
{
  const wxChar *p = s.wc_str();
  bool bFoundDigit = false;
  bool bRtn = true;
  if(IsSign(*p))
  {
    // optional sign
    p++;
  }
  while(IsNumeric(*p))
  {
    // digits
    bFoundDigit = true;
Пример #28
0
/* wxHTTP randomly crashes when called on a worker thread, this must be called from main thread ! */
wxString CXLXHostsFileDownloader::Download(const wxString & xlxHostsFileURL)
{
#ifdef XLX_USE_WGET
	wxString xlxHostsFileName = wxFileName::CreateTempFileName(_T("XLX_Hosts_"));
	wxString commandLine = _T("wget -q -O ") + xlxHostsFileName + _T(" ") + xlxHostsFileURL;
	bool execResult = wxShell(commandLine);
	
	if(!execResult) {
		wxLogError(_T("Unable do download XLX host file, make sure wget is installed"));
		return wxEmptyString;
	}
	
	return xlxHostsFileName;
#else
	wxHTTP http;
	http.SetNotify(false);
	http.SetFlags(wxSOCKET_WAITALL);
	http.SetHeader( _T("Accept") , _T("text/*") );
	http.SetHeader( _T("User-Agent"), _T("ircddbGateway") );
	http.SetTimeout(5); // seconds

	wxLogMessage(_T("Downloading XLX reflector list from %s"), xlxHostsFileURL.c_str());

	// remove "http://" from the url, i.e. minus 7 chars
	size_t len = xlxHostsFileURL.length();
	wxString path = xlxHostsFileURL.Right(len-7);
	
	// find the first forward slash
	int slash = path.Find(wxChar('/'));
	len = path.length();
	wxString server = path.Left(slash);
	path = path.Right(len-slash);

	// Note that Connect() wants a host address, not an URL. 80 is the server's port.
	if(!http.Connect(server, 80 )) {
		wxLogError(_T("Failed to connect to %s"), server);
		return wxEmptyString;
	}
	
	wxInputStream* in = NULL;
	if((in = http.GetInputStream(path)) && in->IsOk()) {
		wxFile file;
		wxString xlxHostsFileName = wxFileName::CreateTempFileName(_T("XLX_Hosts_"), &file);
		wxLogMessage(_T("Created temporary file %s"), xlxHostsFileName);
		if(!file.IsOpened()) {
			wxLogError(_T("Failed to open temporary file %s"), xlxHostsFileName);
			wxDELETE(in);
			return wxEmptyString;
		}
		
		//in->Read(fileStream);
		//fileStream.Write(*in);
		//in->Read(tempFileStream);
		//Both call above seem to not work when run in a separate thread, hence the old fashion loop below
		unsigned char buffer[2048];
		while(!in->Eof()) {
			in->Read(buffer, 2048);
			int readCount = in->LastRead();
			if(readCount <= 0)
				break;

			file.Write(buffer, readCount);
		}
		wxLogMessage(_T("XLX Successfuly downloaded to %s"), xlxHostsFileName);
		file.Close();
		http.Close();
		wxDELETE(in);
		return xlxHostsFileName;
	}
	
	wxLogError(_T("Failed to get HTTP stream"));
	if(in) wxDELETE(in);

	return wxEmptyString;
#endif
}
Пример #29
0
void CVPCB_MAINFRAME::OnSelectComponent( wxListEvent& event )
{
    if( m_skipComponentSelect )
        return;

    wxString   libraryName;
    COMPONENT* component = NULL;
    int        filter = FOOTPRINTS_LISTBOX::UNFILTERED;

    if( m_mainToolBar->GetToolToggled( ID_CVPCB_FOOTPRINT_DISPLAY_FILTERED_LIST ) )
        filter |= FOOTPRINTS_LISTBOX::BY_COMPONENT;

    if( m_mainToolBar->GetToolToggled( ID_CVPCB_FOOTPRINT_DISPLAY_PIN_FILTERED_LIST ) )
        filter |= FOOTPRINTS_LISTBOX::BY_PIN_COUNT;

    if( m_mainToolBar->GetToolToggled( ID_CVPCB_FOOTPRINT_DISPLAY_BY_LIBRARY_LIST ) )
        filter |= FOOTPRINTS_LISTBOX::BY_LIBRARY;

    component = GetSelectedComponent();
    libraryName = m_libListBox->GetSelectedLibrary();
    m_footprintListBox->SetFootprints( m_footprints, libraryName, component, filter );

    // Tell AuiMgr that objects are changed !
    if( m_auimgr.GetManagedWindow() )   // Be sure Aui Manager is initialized
        // (could be not the case when starting CvPcb
        m_auimgr.Update();

    if( component == NULL )
        return;

    // Preview of the already assigned footprint.
    // Find the footprint that was already chosen for this component and select it,
    // but only if the selection is made from the component list or the library list.
    // If the selection is made from the footprint list, do not change the current
    // selected footprint.
    if( FindFocus() == m_compListBox || FindFocus() == m_libListBox )
    {
        wxString module = FROM_UTF8( component->GetFPID().Format().c_str() );

        bool found = false;

        for( int ii = 0; ii < m_footprintListBox->GetCount(); ii++ )
        {
            wxString footprintName;
            wxString msg = m_footprintListBox->OnGetItemText( ii, 0 );
            msg.Trim( true );
            msg.Trim( false );
            footprintName = msg.AfterFirst( wxChar( ' ' ) );

            if( module.Cmp( footprintName ) == 0 )
            {
                m_footprintListBox->SetSelection( ii, true );
                found = true;
                break;
            }
        }

        if( !found )
        {
            int ii = m_footprintListBox->GetSelection();

            if ( ii >= 0 )
                m_footprintListBox->SetSelection( ii, false );

            if( GetFpViewerFrame() )
            {
                CreateScreenCmp();
            }
        }
    }

    SendMessageToEESCHEMA();
    DisplayStatus();
}
void DIALOG_MODULE_BOARD_EDITOR::Browse3DLib( wxCommandEvent& event )
{
    wxString fullfilename, shortfilename;
    wxString fullpath;

    fullpath = wxGetApp().ReturnLastVisitedLibraryPath( LIB3D_PATH );
#ifdef __WINDOWS__
    fullpath.Replace( wxT( "/" ), wxT( "\\" ) );
#endif

    wxString fileFilters;
    fileFilters = wxGetTranslation( Shapes3DFileWildcard );
    fileFilters += wxChar(  '|' );
    fileFilters += wxGetTranslation( IDF3DFileWildcard );

    fullfilename = EDA_FileSelector( _( "3D Shape:" ),
                                     fullpath,
                                     wxEmptyString,
                                     wxEmptyString,
                                     wxGetTranslation( fileFilters ),
                                     this,
                                     wxFD_OPEN,
                                     true
                                     );

    if( fullfilename.IsEmpty() )
        return;

    wxFileName fn = fullfilename;
    wxGetApp().SaveLastVisitedLibraryPath( fn.GetPath() );

    /* If the file path is already in the default search path
     * list, just add the name to the list.  Otherwise, add
     * the name with the full or relative path.
     * the relative path, when possible is preferable,
     * because it preserve use of default search path, when the path is a
     * sub path
     */

    wxString default_path;
    wxGetEnv( wxT( KISYS3DMOD ), &default_path );
    fn.MakeRelativeTo( default_path );

    // Here, we want a path relative only to the default_path
    if( fn.GetPathWithSep().StartsWith( wxT("..") ) )
        fn = fullfilename;  // keep the full file name

    shortfilename = fn.GetFullPath();

    if( fn.IsAbsolute() )
    {   // Absolute path, ask if the user wants a relative one
        int diag = wxMessageBox(
            _( "Use a relative path?" ),
            _( "Path type" ),
            wxYES_NO | wxICON_QUESTION, this );

        if( diag == wxYES )
        {   // Make it relative
            fn.MakeRelativeTo( wxT(".") );
            shortfilename = fn.GetFullPath();
        }
    }

    S3D_MASTER* new3DShape = new S3D_MASTER( NULL );
#ifdef __WINDOWS__
    // Store filename in Unix notation
    shortfilename.Replace( wxT( "\\" ), wxT( "/" ) );
#endif
    new3DShape->SetShape3DName( shortfilename );
    m_Shapes3D_list.push_back( new3DShape );
    m_3D_ShapeNameListBox->Append( shortfilename );

    if( m_LastSelected3DShapeIndex >= 0 )
        TransfertDisplayTo3DValues( m_LastSelected3DShapeIndex );

    m_LastSelected3DShapeIndex = m_3D_ShapeNameListBox->GetCount() - 1;
    m_3D_ShapeNameListBox->SetSelection( m_LastSelected3DShapeIndex );
    Transfert3DValuesToDisplay( m_Shapes3D_list[m_LastSelected3DShapeIndex] );
}