#include "wx/string.h"
#include "wx/filefn.h"
-class wxStringTokenizer : public wxObject {
+class WXDLLEXPORT wxStringTokenizer : public wxObject
+{
public:
- wxStringTokenizer(const wxString& to_tokenize,
- const wxString& delims = " \t\r\n",
- bool ret_delim = FALSE);
- wxStringTokenizer() { m_string = ""; m_delims = ""; m_retdelims = FALSE;}
- ~wxStringTokenizer();
-
- int CountTokens();
- bool HasMoreToken();
- inline bool HasMoreTokens() { return HasMoreToken(); };
- wxString NextToken();
- // A better name!
- inline wxString GetNextToken() { return NextToken(); };
- wxString GetString() { return m_string; }
-
- void SetString(const wxString& to_tokenize,
- const wxString& delims = " \t\r\n",
- bool ret_delim = FALSE)
- {
- m_string = to_tokenize;
- m_delims = delims;
- m_retdelims = ret_delim;
- }
+ wxStringTokenizer(const wxString& to_tokenize,
+ const wxString& delims = " \t\r\n",
+ bool ret_delim = FALSE);
+ wxStringTokenizer() { m_retdelims = FALSE;}
+ virtual ~wxStringTokenizer();
+
+ int CountTokens() count;
+ bool HasMoreTokens();
+
+ wxString NextToken();
+ wxString GetNextToken() { return NextToken(); };
+
+ wxString GetString() const { return m_string; }
+
+ void SetString(const wxString& to_tokenize,
+ const wxString& delims = " \t\r\n",
+ bool ret_delim = FALSE)
+ {
+ m_string = to_tokenize;
+ m_delims = delims;
+ m_retdelims = ret_delim;
+ }
protected:
- off_t FindDelims(const wxString& str, const wxString& delims);
- void EatLeadingDelims(); // AVS - added to fix leading whitespace /
- // mult. delims bugs
-protected:
- wxString m_string, m_delims;
- bool m_retdelims;
+ off_t FindDelims(const wxString& str, const wxString& delims);
+ void EatLeadingDelims();
+
+ wxString m_string, m_delims;
+ bool m_retdelims;
};
-#endif
+#endif // _WX_TOKENZRH
/////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__
-#pragma implementation "tokenzr.h"
+ #pragma implementation "tokenzr.h"
#endif
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#ifdef __BORLANDC__
-#pragma hdrstop
+ #pragma hdrstop
#endif
-#ifndef WX_PRECOMP
-#endif
-
-#include "wx/object.h"
-#include "wx/string.h"
#include "wx/tokenzr.h"
wxStringTokenizer::wxStringTokenizer(const wxString& to_tokenize,
const wxString& delims,
- bool ret_delims)
- : wxObject()
+ bool ret_delims)
{
- m_string = to_tokenize;
- m_delims = delims;
- m_retdelims = ret_delims;
+ m_string = to_tokenize;
+ m_delims = delims;
+ m_retdelims = ret_delims;
}
wxStringTokenizer::~wxStringTokenizer()
off_t wxStringTokenizer::FindDelims(const wxString& str, const wxString& delims)
{
- int i, j;
- register int s_len = str.Length(),
- len = delims.Length();
-
- for (i=0;i<s_len;i++) {
- register char c = str[i];
-
- for (j=0;j<len;j++)
- if (delims[j] == c)
- return i;
- }
- return -1;
+ for ( int i = 0; i < str.Length(); i++ )
+ {
+ char c = str[i];
+
+ for ( int j = 0; j < delims.Length() ; j++ )
+ {
+ if ( delims[j] == c )
+ return i;
+ }
+ }
+
+ return -1;
}
-int wxStringTokenizer::CountTokens()
+int wxStringTokenizer::CountTokens() const
{
- wxString p_string = m_string;
- bool found = TRUE;
- int pos, count = 1;
-
- if (p_string.Length() == 0)
- return 0;
-
- while (found) {
- pos = FindDelims(p_string, m_delims);
- if (pos != -1) {
- count++;
- p_string = p_string(0, pos);
- } else
- found = FALSE;
- }
- return count;
+ wxString p_string = m_string;
+ bool found = TRUE;
+ int pos, count = 1;
+
+ if (p_string.Length() == 0)
+ return 0;
+
+ while (found)
+ {
+ pos = FindDelims(p_string, m_delims);
+ if (pos != -1)
+ {
+ count++;
+ p_string = p_string(0, pos);
+ }
+ else
+ {
+ found = FALSE;
+ }
+ }
+
+ return count;
}
bool wxStringTokenizer::HasMoreToken()
{
- return (m_string.Length() != 0);
+ return !m_string.IsEmpty();
}
-// AVS - added to fix leading whitespace / mult. delims bugs
+// needed to fix leading whitespace / mult. delims bugs
void wxStringTokenizer::EatLeadingDelims()
{
- int pos;
+ int pos;
- while ((pos=FindDelims(m_string, m_delims))==0) { // while leading delims
- m_string = m_string.Mid((size_t)1); // trim 'em from the left
- }
+ // while leading delims trim 'em from the left
+ while ( ( pos = FindDelims(m_string, m_delims)) == 0 )
+ {
+ m_string = m_string.Mid((size_t)1);
+ }
}
wxString wxStringTokenizer::NextToken()
{
- register off_t pos, pos2;
- wxString r_string;
-
- if (m_string.IsNull())
- return m_string;
-
- if (!m_retdelims)
- EatLeadingDelims(); // AVS - added to fix leading whitespace /
- // mult. delims bugs
+ off_t pos, pos2;
+ wxString r_string;
+
+ if ( m_string.IsEmpty() )
+ return m_string;
+
+ if ( !m_retdelims )
+ EatLeadingDelims();
+
+ pos = FindDelims(m_string, m_delims);
+ if (pos == -1)
+ {
+ r_string = m_string;
+ m_string = wxEmptyString;
+
+ return r_string;
+ }
+
+ if (m_retdelims)
+ {
+ if (!pos)
+ {
+ pos++;
+ pos2 = 1;
+ }
+ else
+ {
+ pos2 = pos;
+ }
+ }
+ else
+ {
+ pos2 = pos + 1;
+ }
+
+ r_string = m_string.Left((size_t)pos);
+ m_string = m_string.Mid((size_t)pos2);
- pos = FindDelims(m_string, m_delims);
- if (pos == -1) {
- r_string = m_string;
- m_string = wxEmptyString;
-
return r_string;
- }
-
- if (m_retdelims) {
- if (!pos) {
- pos++;
- pos2 = 1;
- } else
- pos2 = pos;
- } else
- pos2 = pos + 1;
-
- r_string = m_string.Left((size_t)pos);
- m_string = m_string.Mid((size_t)pos2);
-
- return r_string;
}
};
IMPLEMENT_ABSTRACT_CLASS(wxHTMLHelpControllerBase, wxHelpControllerBase)
-
+
/**
This class implements help via an external browser.
It requires the name of a directory containing the documentation
and a file mapping numerical Section numbers to relative URLS.
*/
-wxHTMLHelpControllerBase::wxHTMLHelpControllerBase(void)
+wxHTMLHelpControllerBase::wxHTMLHelpControllerBase()
{
m_MapList = (wxList*) NULL;
m_NumOfEntries = 0;
}
void
-wxHTMLHelpControllerBase::DeleteList(void)
+wxHTMLHelpControllerBase::DeleteList()
{
if(m_MapList)
{
}
}
-wxHTMLHelpControllerBase::~wxHTMLHelpControllerBase(void)
+wxHTMLHelpControllerBase::~wxHTMLHelpControllerBase()
{
DeleteList();
}
wxString mapFile, file, url, doc;
int id,i,len;
char buffer[WXEXTHELP_BUFLEN];
-
+
wxBusyCursor b; // display a busy cursor
if(! ifile.IsEmpty())
file = newfile;
}
}
-
+
if(! wxDirExists(file))
return FALSE;
-
+
mapFile << file << WXEXTHELP_SEPARATOR << WXEXTHELP_MAPFILE;
}
else // try to reload old file
DeleteList();
m_MapList = new wxList;
m_NumOfEntries = 0;
-
+
FILE *input = fopen(mapFile.fn_str(),"rt");
if(! input)
return FALSE;
}
}while(! feof(input));
fclose(input);
-
+
m_MapFile = file; // now it's valid
return TRUE;
}
bool
-wxHTMLHelpControllerBase::DisplayContents(void)
+wxHTMLHelpControllerBase::DisplayContents()
{
if(! m_NumOfEntries)
return FALSE;
wxBusyCursor b; // display a busy cursor
return KeywordSearch("");
}
-
+
bool
wxHTMLHelpControllerBase::DisplaySection(int sectionNo)
{
wxString *choices = new wxString[m_NumOfEntries];
wxString *urls = new wxString[m_NumOfEntries];
wxString compA, compB;
-
+
int idx = 0, j;
bool rc;
bool showAll = k.IsEmpty();
wxNode *node = m_MapList->First();
wxExtHelpMapEntry *entry;
-
+
compA = k; compA.LowerCase(); // we compare case insensitive
while(node)
{
entry = (wxExtHelpMapEntry *)node->Data();
compB = entry->doc; compB.LowerCase();
- if((showAll || compB.Contains(k)) && ! compB.IsEmpty())
+ if((showAll || compB.Contains(k)) && ! compB.IsEmpty())
{
urls[idx] = entry->url;
// doesn't work:
}
delete[] urls;
delete[] choices;
-
+
return rc;
}
bool
-wxHTMLHelpControllerBase::Quit(void)
+wxHTMLHelpControllerBase::Quit()
{
return TRUE;
}
void
-wxHTMLHelpControllerBase::OnQuit(void)
+wxHTMLHelpControllerBase::OnQuit()
{
}
// So we store a list of windows for which we already have the DC and not
// just one single hDC. This seems to work, but I'm really not sure about
// the usefullness of the whole idea - IMHO it's much better to not call
-// base class OnPaint() at all, or, if we realyl want to allow it, add a
+// base class OnPaint() at all, or, if we really want to allow it, add a
// "wxPaintDC *" parameter to wxPaintEvent which should be used if it's
// !NULL instead of creating a new DC.