Esempio n. 1
0
/* Contract Paths to be build upon an environment variable
   component:

   example: "/usr/openwin/lib", OPENWINHOME --> ${OPENWINHOME}/lib

   The call wxExpandPath can convert these back!
 */
wxChar *
wxContractPath (const wxString& filename,
                const wxString& envname,
                const wxString& user)
{
  static wxChar dest[_MAXPATHLEN];

  if (filename.empty())
    return NULL;

  wxStrcpy (dest, filename);
#ifdef __WINDOWS__
  wxUnix2DosFilename(dest);
#endif

  // Handle environment
  wxString val;
  wxChar *tcp;
  if (!envname.empty() && !(val = wxGetenv (envname)).empty() &&
     (tcp = wxStrstr (dest, val)) != NULL)
    {
        wxStrcpy (wxFileFunctionsBuffer, tcp + val.length());
        *tcp++ = wxT('$');
        *tcp++ = wxT('{');
        wxStrcpy (tcp, envname);
        wxStrcat (tcp, wxT("}"));
        wxStrcat (tcp, wxFileFunctionsBuffer);
    }

  // Handle User's home (ignore root homes!)
  val = wxGetUserHome (user);
  if (val.empty())
    return dest;

  const size_t len = val.length();
  if (len <= 2)
    return dest;

  if (wxStrncmp(dest, val, len) == 0)
  {
    wxStrcpy(wxFileFunctionsBuffer, wxT("~"));
    if (!user.empty())
           wxStrcat(wxFileFunctionsBuffer, user);
    wxStrcat(wxFileFunctionsBuffer, dest + len);
    wxStrcpy (dest, wxFileFunctionsBuffer);
  }

  return dest;
}
Esempio n. 2
0
void StringTestCase::PChar()
{
    wxChar a [128];
    wxChar b [128];
    wxChar c [128];

    for (int i = 0; i < 2; ++i)
    {
        wxStrcpy (a, wxT("Hello"));
        wxStrcpy (b, wxT(" world"));
        wxStrcpy (c, wxT("! How'ya doin'?"));
        wxStrcat (a, b);
        wxStrcat (a, c);
        wxStrcpy (c, wxT("Hello world! What's up?"));
        CPPUNIT_ASSERT( wxStrcmp (c, a) != 0 );
    }
}
Esempio n. 3
0
void ChooseOutputFile(bool force)
{
    wxChar extensionBuf[10];
    wxChar wildBuf[10];
    wxStrcpy(wildBuf, _T("*."));
    wxString path;
    if (!OutputFile.empty())
        path = wxPathOnly(OutputFile);
    else if (!InputFile.empty())
        path = wxPathOnly(InputFile);

    switch (convertMode)
    {
        case TEX_RTF:
        {
            wxStrcpy(extensionBuf, _T("rtf"));
            wxStrcat(wildBuf, _T("rtf"));
            break;
        }
        case TEX_XLP:
        {
            wxStrcpy(extensionBuf, _T("xlp"));
            wxStrcat(wildBuf, _T("xlp"));
            break;
        }
        case TEX_HTML:
        {
            wxStrcpy(extensionBuf, _T("html"));
            wxStrcat(wildBuf, _T("html"));
            break;
        }
    }
#if wxUSE_FILEDLG
    if (force || OutputFile.empty())
    {
        wxString s = wxFileSelector(_T("Choose output file"), path, wxFileNameFromPath(OutputFile),
                                    extensionBuf, wildBuf);
        if (!s.empty())
            OutputFile = s;
    }
#else
    wxUnusedVar(force);
#endif // wxUSE_FILEDLG
}
Esempio n. 4
0
bool SHGToMap(wxChar *filename, wxChar *defaultFile)
{
  // Test the SHG parser
  HotSpot *hotspots = NULL;
  int n = ParseSHG(filename, &hotspots);
  if (n == 0)
    return false;

  wxChar buf[100];
  wxSnprintf(buf, sizeof(buf), _T("Converting .SHG file to HTML map file: there are %d hotspots in %s."), n, filename);
  OnInform(buf);

  wxChar outBuf[256];
  wxStrcpy(outBuf, filename);
  StripExtension(outBuf);
  wxStrcat(outBuf, _T(".map"));

  FILE *fd = wxFopen(outBuf, _T("w"));
  if (!fd)
  {
    OnError(_T("Could not open .map file for writing."));
    delete[] hotspots;
    return false;
  }

  wxFprintf(fd, _T("default %s\n"), defaultFile);
  for (int i = 0; i < n; i++)
  {
    wxChar *refFilename = _T("??");
    
    TexRef *texRef = FindReference(hotspots[i].szHlpTopic_Macro);
    if (texRef)
      refFilename = texRef->refFile;
    else
    {
      wxChar buf[300];
      wxSnprintf(buf, sizeof(buf), _T("Warning: could not find hotspot reference %s"), hotspots[i].szHlpTopic_Macro);
      OnInform(buf);
    }
    wxFprintf(fd, _T("rect %s %d %d %d %d\n"), refFilename, (int)hotspots[i].left, (int)hotspots[i].top,
      (int)hotspots[i].right, (int)hotspots[i].bottom);
  }
  wxFprintf(fd, _T("\n"));

  fclose(fd);

  delete[] hotspots;
  return true;
}
Esempio n. 5
0
 virtual bool OnInit() { wxStrcat(g_strLoadOrder, GetClassInfo()->GetClassName()); return true; }
Esempio n. 6
0
bool Tex2RTFConnection::OnExecute(const wxString& WXUNUSED(topic), wxChar *data, int WXUNUSED(size), wxIPCFormat WXUNUSED(format))
{
  wxStrcpy(Tex2RTFLastStatus, _T("OK"));

  wxChar firstArg[50];
  wxChar secondArg[300];
  if (SplitCommand(data, firstArg, secondArg))
  {
    bool hasArg = (wxStrlen(secondArg) > 0);
    if (wxStrcmp(firstArg, _T("INPUT")) == 0 && hasArg)
    {
        InputFile = secondArg;
        if (frame)
        {
            wxChar buf[100];
            wxString str = wxFileNameFromPath(InputFile);
            wxSnprintf(buf, sizeof(buf), _T("Tex2RTF [%s]"), (const wxChar*) str);
            frame->SetTitle(buf);
        }
    }
    else if (wxStrcmp(firstArg, _T("OUTPUT")) == 0 && hasArg)
    {
        OutputFile = secondArg;
    }
    else if (wxStrcmp(firstArg, _T("GO")) == 0)
    {
      wxStrcpy(Tex2RTFLastStatus, _T("WORKING"));
      if (!Go())
        wxStrcpy(Tex2RTFLastStatus, _T("CONVERSION ERROR"));
      else
        wxStrcpy(Tex2RTFLastStatus, _T("OK"));
    }
    else if (wxStrcmp(firstArg, _T("EXIT")) == 0)
    {
      if (frame) frame->Close();
    }
    else if (wxStrcmp(firstArg, _T("MINIMIZE")) == 0 || wxStrcmp(firstArg, _T("ICONIZE")) == 0)
    {
      if (frame)
        frame->Iconize(true);
    }
    else if (wxStrcmp(firstArg, _T("SHOW")) == 0 || wxStrcmp(firstArg, _T("RESTORE")) == 0)
    {
      if (frame)
      {
        frame->Iconize(false);
        frame->Show(true);
      }
    }
    else
    {
      // Try for a setting
      wxStrcpy(Tex2RTFLastStatus, RegisterSetting(firstArg, secondArg, false));
#if !defined(NO_GUI) && wxUSE_STATUSBAR
      if (frame && wxStrcmp(firstArg, _T("conversionMode")) == 0)
      {
        wxChar buf[100];
        wxStrcpy(buf, _T("In "));

        if (winHelp && (convertMode == TEX_RTF))
          wxStrcat(buf, _T("WinHelp RTF"));
        else if (!winHelp && (convertMode == TEX_RTF))
          wxStrcat(buf, _T("linear RTF"));
        else if (convertMode == TEX_HTML) wxStrcat(buf, _T("HTML"));
        else if (convertMode == TEX_XLP) wxStrcat(buf, _T("XLP"));
          wxStrcat(buf, _T(" mode."));
        frame->SetStatusText(buf, 1);
      }
#endif
    }
  }
  return true;
}