# Generated with `cvs diff -u -R -N -r WX_2_8_0 -r wxPy_2_8_0_1`, and then # trimmed for non-platform-relevant changes # July 26th, 2007 - adapted to wxGTK 2.8.4 by Borromini Index: wxWidgets/configure.in =================================================================== RCS file: /pack/cvsroots/wxwidgets/wxWidgets/configure.in,v retrieving revision 1.1226 retrieving revision 1.1228 diff -u -r1.1226 -r1.1228 --- wxWidgets/configure.in 2006/12/09 23:43:54 1.1226 +++ wxWidgets/configure.in 2006/12/12 01:52:43 1.1228 @@ -35,7 +35,7 @@ wx_major_version_number=2 wx_minor_version_number=8 wx_release_number=4 -wx_subrelease_number=0 +wx_subrelease_number=1 WX_RELEASE=$wx_major_version_number.$wx_minor_version_number WX_VERSION=$WX_RELEASE.$wx_release_number @@ -6945,6 +6950,11 @@ AC_DEFINE(wxUSE_SCROLLBAR) USES_CONTROLS=1 SAMPLES_SUBDIRS="$SAMPLES_SUBDIRS scroll scrollsub" +fi + +if test "$wxUSE_SEARCHCTRL" = "yes"; then + AC_DEFINE(wxUSE_SEARCHCTRL) + USES_CONTROLS=1 fi if test "$wxUSE_SLIDER" = "yes"; then Index: wxWidgets/include/wx/version.h =================================================================== RCS file: /pack/cvsroots/wxwidgets/wxWidgets/include/wx/version.h,v retrieving revision 1.82 retrieving revision 1.83 diff -u -r1.82 -r1.83 --- wxWidgets/include/wx/version.h 2006/11/10 02:27:47 1.82 +++ wxWidgets/include/wx/version.h 2006/12/12 01:52:41 1.83 @@ -29,7 +29,7 @@ #define wxMAJOR_VERSION 2 #define wxMINOR_VERSION 8 #define wxRELEASE_NUMBER 4 -#define wxSUBRELEASE_NUMBER 0 +#define wxSUBRELEASE_NUMBER 1 #define wxVERSION_STRING _T("wxWidgets 2.8.4") /* nothing to update below this line when updating the version */ Index: wxWidgets/src/html/htmlfilter.cpp =================================================================== RCS file: htmlfilter.cpp diff -N htmlfilter.cpp --- /dev/null Thu Dec 14 21:47:46 2006 +++ wxWidgets/src/html/htmlfilter.cpp Thu Dec 14 21:47:50 2006 @@ -0,0 +1,172 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: filter.cpp +// Purpose: wxHtmlFilter - input filter for translating into HTML format +// Author: Vaclav Slavik +// Copyright: (c) 1999 Vaclav Slavik +// Licence: wxWindows Licence +///////////////////////////////////////////////////////////////////////////// + + +#ifdef __GNUG__ +#pragma implementation "htmlfilter.h" +#endif + +#include "wx/wxprec.h" + +#if wxUSE_HTML + +#ifdef __BORDLANDC__ +#pragma hdrstop +#endif + +#ifndef WXPRECOMP +#endif + +#include "wx/html/htmlfilter.h" +#include "wx/html/htmlwin.h" + + +/* + +There is code for several default filters: + +*/ + +IMPLEMENT_ABSTRACT_CLASS(wxHtmlFilter, wxObject) + +//-------------------------------------------------------------------------------- +// wxHtmlFilterPlainText +// filter for text/plain or uknown +//-------------------------------------------------------------------------------- + +IMPLEMENT_DYNAMIC_CLASS(wxHtmlFilterPlainText, wxHtmlFilter) + +bool wxHtmlFilterPlainText::CanRead(const wxFSFile& WXUNUSED(file)) const +{ + return TRUE; +} + + + +wxString wxHtmlFilterPlainText::ReadFile(const wxFSFile& file) const +{ + wxInputStream *s = file.GetStream(); + char *src; + wxString doc, doc2; + + if (s == NULL) return wxEmptyString; + src = new char[s -> GetSize()+1]; + src[s -> GetSize()] = 0; + s -> Read(src, s -> GetSize()); + doc = src; + delete [] src; + + doc.Replace(_T("<"), _T("<"), TRUE); + doc.Replace(_T(">"), _T(">"), TRUE); + doc2 = _T("
\n") + doc + _T("\n
"); + return doc2; +} + + + + + +//-------------------------------------------------------------------------------- +// wxHtmlFilterImage +// filter for image/* +//-------------------------------------------------------------------------------- + +class wxHtmlFilterImage : public wxHtmlFilter +{ + DECLARE_DYNAMIC_CLASS(wxHtmlFilterImage) + + public: + virtual bool CanRead(const wxFSFile& file) const; + virtual wxString ReadFile(const wxFSFile& file) const; +}; + +IMPLEMENT_DYNAMIC_CLASS(wxHtmlFilterImage, wxHtmlFilter) + + + +bool wxHtmlFilterImage::CanRead(const wxFSFile& file) const +{ + return (file.GetMimeType().Left(6) == "image/"); +} + + + +wxString wxHtmlFilterImage::ReadFile(const wxFSFile& file) const +{ + return (""); +} + + + + +//-------------------------------------------------------------------------------- +// wxHtmlFilterPlainText +// filter for text/plain or uknown +//-------------------------------------------------------------------------------- + +class wxHtmlFilterHTML : public wxHtmlFilter +{ + DECLARE_DYNAMIC_CLASS(wxHtmlFilterHTML) + + public: + virtual bool CanRead(const wxFSFile& file) const; + virtual wxString ReadFile(const wxFSFile& file) const; +}; + + +IMPLEMENT_DYNAMIC_CLASS(wxHtmlFilterHTML, wxHtmlFilter) + +bool wxHtmlFilterHTML::CanRead(const wxFSFile& file) const +{ +// return (file.GetMimeType() == "text/html"); +// This is true in most case but some page can return: +// "text/html; char-encoding=...." +// So we use Find instead + return (file.GetMimeType().Find(_T("text/html")) == 0); +} + + + +wxString wxHtmlFilterHTML::ReadFile(const wxFSFile& file) const +{ + wxInputStream *s = file.GetStream(); + char *src; + wxString doc; + + if (s == NULL) return wxEmptyString; + src = new char[s -> GetSize() + 1]; + src[s -> GetSize()] = 0; + s -> Read(src, s -> GetSize()); + doc = src; + delete[] src; + + return doc; +} + + + + +///// Module: + +class wxHtmlFilterModule : public wxModule +{ + DECLARE_DYNAMIC_CLASS(wxHtmlFilterModule) + + public: + virtual bool OnInit() + { + wxHtmlWindow::AddFilter(new wxHtmlFilterHTML); + wxHtmlWindow::AddFilter(new wxHtmlFilterImage); + return TRUE; + } + virtual void OnExit() {} +}; + +IMPLEMENT_DYNAMIC_CLASS(wxHtmlFilterModule, wxModule) + +#endif Index: wxWidgets/src/html/htmlhelp.cpp =================================================================== RCS file: htmlhelp.cpp diff -N htmlhelp.cpp --- /dev/null Thu Dec 14 21:47:46 2006 +++ wxWidgets/src/html/htmlhelp.cpp Thu Dec 14 21:47:50 2006 @@ -0,0 +1,839 @@ +// Name: htmlhelp.cpp +// Purpose: Help controller +// Author: Vaclav Slavik +// Copyright: (c) 1999 Vaclav Slavik +// Licence: wxWindows Licence +///////////////////////////////////////////////////////////////////////////// + +#error This file should not be compiled! Update your build system! \ +(configure users, rerun configure to get a new Makefile) \ +Instead of htmlhelp[_io], use helpdata, helpfrm and helpctrl. This \ +file is only left to point out the problem and will be removed r.s.n. + +#ifdef __GNUG__ +#pragma implementation "htmlhelp.h" +#endif + +#include "wx/wxprec.h" + +#if wxUSE_HTML + +#ifdef __BORDLANDC__ +#pragma hdrstop +#endif + +#ifndef WXPRECOMP +#endif + +#include +#include +#include +#include +#include +#include +#include +#include + +#if !((wxVERSION_NUMBER < 2100) || ((wxVERSION_NUMBER == 2100) && (wxBETA_NUMBER < 7))) +#include +#endif + + +// Bitmaps: + +#ifndef __WXMSW__ + // XPM hack: make the arrays const + #define static static const + + #include "bitmaps/panel.xpm" + #include "bitmaps/back.xpm" + #include "bitmaps/forward.xpm" + #include "bitmaps/book.xpm" + #include "bitmaps/folder.xpm" + #include "bitmaps/page.xpm" + + #undef static +#endif + +#include "search.h" + + + + +#include +WX_DEFINE_OBJARRAY(HtmlBookRecArray) + + + + + + + + + +//----------------------------------------------------------------------------- +// wxHtmlHelpController +//----------------------------------------------------------------------------- + + +IMPLEMENT_DYNAMIC_CLASS(wxHtmlHelpController, wxEvtHandler) + + +wxHtmlHelpController::wxHtmlHelpController() : wxEvtHandler() +{ + m_Frame = NULL; + m_Config = NULL; + m_ConfigRoot = wxEmptyString; + m_TitleFormat = _("Help : %s"); + m_TempPath = wxEmptyString; + + m_Cfg.x = m_Cfg.y = 0; + m_Cfg.w = 700; m_Cfg.h = 480; + m_Cfg.sashpos = 240; + m_Cfg.navig_on = TRUE; + + m_ContentsImageList = new wxImageList(12, 12); + m_ContentsImageList -> Add(wxICON(book)); + m_ContentsImageList -> Add(wxICON(folder)); + m_ContentsImageList -> Add(wxICON(page)); + + m_Contents = NULL; + m_ContentsCnt = 0; + m_Index = NULL; + m_IndexCnt = 0; + + m_IndexBox = NULL; + m_ContentsBox = NULL; + m_SearchList = NULL; + m_SearchText = NULL; + m_SearchButton = NULL; + m_HtmlWin = NULL; + m_Splitter = NULL; + m_NavigPan = NULL; +} + + + +wxHtmlHelpController::~wxHtmlHelpController() +{ + int i; + + m_BookRecords.Empty(); + delete m_ContentsImageList; + if (m_Contents) { + for (i = 0; i < m_ContentsCnt; i++) { + delete[] m_Contents[i].m_Page; + delete[] m_Contents[i].m_Name; + } + free(m_Contents); + } + if (m_Index) { + for (i = 0; i < m_IndexCnt; i++) { + delete[] m_Index[i].m_Page; + delete[] m_Index[i].m_Name; + } + free(m_Index); + } +} + + + +void wxHtmlHelpController::SetTempDir(const wxString& path) +{ + if (path == wxEmptyString) m_TempPath = path; + else { + if (wxIsAbsolutePath(path)) m_TempPath = path; + else m_TempPath = wxGetCwd() + "/" + path; + + if (m_TempPath[m_TempPath.Length() - 1] != '/') + m_TempPath << "/"; + } +} + + + + +// Reads one line, stores it into buf and returns pointer to new line or NULL. +static char* ReadLine(char *line, char *buf) +{ + char *writeptr = buf, *readptr = line; + + while (*readptr != 0 && *readptr != '\r' && *readptr != '\n') *(writeptr++) = *(readptr++); + *writeptr = 0; + while (*readptr == '\r' || *readptr == '\n') readptr++; + if (*readptr == 0) return NULL; + else return readptr; +} + + +static wxString SafeFileName(const wxString& s) +{ + wxString res = s; + res.Replace(_T(":"), _T("_"), TRUE); + res.Replace(_T(" "), _T("_"), TRUE); + res.Replace(_T("/"), _T("_"), TRUE); + res.Replace(_T("\\"), _T("_"), TRUE); + res.Replace(_T("#"), _T("_"), TRUE); + res.Replace(_T("."), _T("_"), TRUE); + return res; +} + + +static int IndexCompareFunc(const void *a, const void *b) +{ + return strcmp(((HtmlContentsItem*)a) -> m_Name, ((HtmlContentsItem*)b) -> m_Name); +} + + + +bool wxHtmlHelpController::AddBook(const wxString& book, bool show_wait_msg) +{ + wxFSFile *fi; + wxFileSystem fsys; + wxInputStream *s; + HtmlBookRecord *bookr; + wxString bookFull; + + int sz; + char *buff, *lineptr; + char linebuf[300]; + + wxString title = _("noname"), + safetitle, + start = wxEmptyString, + contents = wxEmptyString, index = wxEmptyString; + + if (wxIsAbsolutePath(book)) bookFull = book; + else bookFull = wxGetCwd() + "/" + book; + + fi = fsys.OpenFile(bookFull); + if (fi == NULL) return FALSE; + fsys.ChangePathTo(bookFull); + s = fi -> GetStream(); + sz = s -> GetSize(); + buff = new char[sz+1]; + buff[sz] = 0; + s -> Read(buff, sz); + lineptr = buff; + delete fi; + + while ((lineptr = ReadLine(lineptr, linebuf)) != NULL) { + if (strstr(linebuf, "Title=") == linebuf) + title = linebuf + strlen("Title="); + if (strstr(linebuf, "Default topic=") == linebuf) + start = linebuf + strlen("Default topic="); + if (strstr(linebuf, "Index file=") == linebuf) + index = linebuf + strlen("Index file="); + if (strstr(linebuf, "Contents file=") == linebuf) + contents = linebuf + strlen("Contents file="); + } + delete[] buff; + + bookr = new HtmlBookRecord(fsys.GetPath(), title, start); + + if (m_ContentsCnt % HTML_REALLOC_STEP == 0) + m_Contents = (HtmlContentsItem*) realloc(m_Contents, (m_ContentsCnt + HTML_REALLOC_STEP) * sizeof(HtmlContentsItem)); + m_Contents[m_ContentsCnt].m_Level = 0; + m_Contents[m_ContentsCnt].m_ID = 0; + m_Contents[m_ContentsCnt].m_Page = new char[start.Length() + 1]; + strcpy(m_Contents[m_ContentsCnt].m_Page, start.c_str()); + m_Contents[m_ContentsCnt].m_Name = new char [title.Length() + 1]; + strcpy(m_Contents[m_ContentsCnt].m_Name, title.c_str()); + m_Contents[m_ContentsCnt].m_Book = bookr; + m_ContentsCnt++; + + // Try to find cached binary versions: + safetitle = SafeFileName(title); + fi = fsys.OpenFile(safetitle + ".cached"); + if (fi == NULL) fi = fsys.OpenFile(m_TempPath + safetitle + ".cached"); + if ((fi == NULL) || (m_TempPath == wxEmptyString)) { + LoadMSProject(bookr, fsys, index, contents, show_wait_msg); + if (m_TempPath != wxEmptyString) { + wxFileOutputStream *outs = new wxFileOutputStream(m_TempPath + safetitle + ".cached"); + SaveCachedBook(bookr, outs); + delete outs; + } + } + else { + LoadCachedBook(bookr, fi -> GetStream()); + delete fi; + } + + m_BookRecords.Add(bookr); + if (m_IndexCnt > 0) + qsort(m_Index, m_IndexCnt, sizeof(HtmlContentsItem), IndexCompareFunc); + + return TRUE; +} + + + + +void wxHtmlHelpController::Display(const wxString& x) +{ + int cnt; + int i; + wxFileSystem fsys; + wxFSFile *f; + + CreateHelpWindow(); + + /* 1. try to open given file: */ + + cnt = m_BookRecords.GetCount(); + for (i = 0; i < cnt; i++) { + f = fsys.OpenFile(m_BookRecords[i].GetBasePath() + x); + if (f) { + m_HtmlWin -> LoadPage(m_BookRecords[i].GetBasePath() + x); + delete f; + return; + } + } + + + /* 2. try to find a book: */ + + for (i = 0; i < cnt; i++) { + if (m_BookRecords[i].GetTitle() == x) { + m_HtmlWin -> LoadPage(m_BookRecords[i].GetBasePath() + m_BookRecords[i].GetStart()); + return; + } + } + + /* 3. try to find in contents: */ + + cnt = m_ContentsCnt; + for (i = 0; i < cnt; i++) { + if (strcmp(m_Contents[i].m_Name, x) == 0) { + m_HtmlWin -> LoadPage(m_Contents[i].m_Book -> GetBasePath() + m_Contents[i].m_Page); + return; + } + } + + + /* 4. try to find in index: */ + + cnt = m_IndexCnt; + for (i = 0; i < cnt; i++) { + if (strcmp(m_Index[i].m_Name, x) == 0) { + m_HtmlWin -> LoadPage(m_Index[i].m_Book -> GetBasePath() + m_Index[i].m_Page); + return; + } + } + + + /* 5. if everything failed, search the documents: */ + + KeywordSearch(x); +} + + + +void wxHtmlHelpController::Display(const int id) +{ + CreateHelpWindow(); + + for (int i = 0; i < m_ContentsCnt; i++) { + if (m_Contents[i].m_ID == id) { + m_HtmlWin -> LoadPage(m_Contents[i].m_Book -> GetBasePath() + m_Contents[i].m_Page); + return; + } + } +} + + + +void wxHtmlHelpController::DisplayContents() +{ + CreateHelpWindow(); + m_Frame -> Raise(); + if (!m_Splitter -> IsSplit()) { + m_NavigPan -> Show(TRUE); + m_HtmlWin -> Show(TRUE); + m_Splitter -> SplitVertically(m_NavigPan, m_HtmlWin, m_Cfg.sashpos); + } + m_NavigPan -> SetSelection(0); +} + + + +void wxHtmlHelpController::DisplayIndex() +{ + CreateHelpWindow(); + m_Frame -> Raise(); + if (!m_Splitter -> IsSplit()) { + m_NavigPan -> Show(TRUE); + m_HtmlWin -> Show(TRUE); + m_Splitter -> SplitVertically(m_NavigPan, m_HtmlWin, m_Cfg.sashpos); + } + m_NavigPan -> SetSelection(1); +} + + + + +#if (wxVERSION_NUMBER < 2100) || ((wxVERSION_NUMBER == 2100) && (wxBETA_NUMBER < 7)) + +class MyProgressDlg : public wxDialog +{ + public: + bool m_Canceled; + + MyProgressDlg(wxWindow *parent) : wxDialog(parent, -1, + _("Searching..."), + wxPoint(0, 0), +#ifdef __WXGTK__ + wxSize(300, 110) +#else + wxSize(300, 130) +#endif + ) + {m_Canceled = FALSE;} + void OnCancel(wxCommandEvent& event) {m_Canceled = TRUE;} + DECLARE_EVENT_TABLE() +}; +BEGIN_EVENT_TABLE(MyProgressDlg, wxDialog) + EVT_BUTTON(wxID_CANCEL, MyProgressDlg::OnCancel) +END_EVENT_TABLE() + +#endif + + +bool wxHtmlHelpController::KeywordSearch(const wxString& keyword) +{ + int foundcnt = 0; + CreateHelpWindow(); + // if these are not set, we can't continue + if (! (m_SearchList && m_HtmlWin)) + return FALSE; + m_Frame -> Raise(); + if (m_Splitter && m_NavigPan && m_SearchButton) { + if (!m_Splitter -> IsSplit()) { + m_NavigPan -> Show(TRUE); + m_HtmlWin -> Show(TRUE); + m_Splitter -> SplitVertically(m_NavigPan, m_HtmlWin, m_Cfg.sashpos); + } + m_NavigPan -> SetSelection(2); + m_SearchList -> Clear(); + m_SearchText -> SetValue(keyword); + m_SearchButton -> Enable(FALSE); + } + { + int cnt = m_ContentsCnt; + wxSearchEngine engine; + wxFileSystem fsys; + wxFSFile *file; + wxString lastpage = wxEmptyString; + wxString foundstr; + +#if (wxVERSION_NUMBER < 2100) || ((wxVERSION_NUMBER == 2100) && (wxBETA_NUMBER < 7)) + MyProgressDlg progress(m_Frame); + + wxStaticText *prompt = new wxStaticText(&progress, -1, "", wxPoint(20, 50), wxSize(260, 25), wxALIGN_CENTER); + wxGauge *gauge = new wxGauge(&progress, -1, cnt, wxPoint(20, 20), wxSize(260, 25)); + wxButton *btn = new wxButton(&progress, wxID_CANCEL, _("Cancel"), wxPoint(110, 70), wxSize(80, 25)); + btn = btn; /* fool compiler :-) */ + prompt -> SetLabel(_("No matching page found yet")); + + progress.Centre(wxBOTH); + progress.Show(TRUE); +#else + wxProgressDialog progress(_("Searching..."), _("No matching page found yet"), cnt, m_Frame, wxPD_APP_MODAL | wxPD_CAN_ABORT | wxPD_AUTO_HIDE); +#endif + + engine.LookFor(keyword); + + for (int i = 0; i < cnt; i++) { +#if (wxVERSION_NUMBER < 2100) || ((wxVERSION_NUMBER == 2100) && (wxBETA_NUMBER < 7)) + gauge -> SetValue(i); + if (progress.m_Canceled) break; +#else + if (progress.Update(i) == FALSE) break; +#endif + wxYield(); + + file = fsys.OpenFile(m_Contents[i].m_Book -> GetBasePath() + m_Contents[i].m_Page); + if (file) { + if (lastpage != file -> GetLocation()) { + lastpage = file -> GetLocation(); + if (engine.Scan(file -> GetStream())) { + foundstr.Printf(_("Found %i matches"), ++foundcnt); +#if (wxVERSION_NUMBER < 2100) || ((wxVERSION_NUMBER == 2100) && (wxBETA_NUMBER < 7)) + prompt -> SetLabel(foundstr); +#else + progress.Update(i, foundstr); +#endif + wxYield(); + m_SearchList -> Append(m_Contents[i].m_Name, (char*)(m_Contents + i)); + } + } + delete file; + } + } + +#if (wxVERSION_NUMBER < 2100) || ((wxVERSION_NUMBER == 2100) && (wxBETA_NUMBER < 7)) + progress.Close(TRUE); +#endif + } + if (m_SearchButton) + m_SearchButton -> Enable(TRUE); + if (m_SearchText) { + m_SearchText -> SetSelection(0, keyword.Length()); + m_SearchText -> SetFocus(); + } + if (foundcnt) { + HtmlContentsItem *it = (HtmlContentsItem*) m_SearchList -> GetClientData(0); + if (it) m_HtmlWin -> LoadPage(it -> m_Book -> GetBasePath() + it -> m_Page); + } + return (foundcnt > 0); +} + + + + + + +void wxHtmlHelpController::CreateHelpWindow() +{ + wxBusyCursor cur; + wxString oldpath; + wxStatusBar *sbar; + + if (m_Frame) { + m_Frame -> Raise(); + m_Frame -> Show(TRUE); + return; + } + +#if wxUSE_BUSYINFO + wxBusyInfo busyinfo(_("Preparing help window...")); +#endif + + if (m_Config) ReadCustomization(m_Config, m_ConfigRoot); + + m_Frame = new wxFrame(NULL, -1, "", wxPoint(m_Cfg.x, m_Cfg.y), wxSize(m_Cfg.w, m_Cfg.h)); + m_Frame -> PushEventHandler(this); + sbar = m_Frame -> CreateStatusBar(); + + { + wxToolBar *toolBar; + toolBar = m_Frame -> CreateToolBar(wxNO_BORDER | wxTB_HORIZONTAL | wxTB_FLAT | wxTB_DOCKABLE); + toolBar -> SetMargins(2, 2); + wxBitmap* toolBarBitmaps[3]; + +#ifdef __WXMSW__ + toolBarBitmaps[0] = new wxBitmap("panel"); + toolBarBitmaps[1] = new wxBitmap("back"); + toolBarBitmaps[2] = new wxBitmap("forward"); + int width = 24; +#else + toolBarBitmaps[0] = new wxBitmap(panel_xpm); + toolBarBitmaps[1] = new wxBitmap(back_xpm); + toolBarBitmaps[2] = new wxBitmap(forward_xpm); + int width = 16; +#endif + + int currentX = 5; + + toolBar -> AddTool(wxID_HTML_PANEL, *(toolBarBitmaps[0]), wxNullBitmap, FALSE, currentX, -1, (wxObject *) NULL, _("Show/hide navigation panel")); + currentX += width + 5; + toolBar -> AddSeparator(); + toolBar -> AddTool(wxID_HTML_BACK, *(toolBarBitmaps[1]), wxNullBitmap, FALSE, currentX, -1, (wxObject *) NULL, _("Go back to the previous HTML page")); + currentX += width + 5; + toolBar -> AddTool(wxID_HTML_FORWARD, *(toolBarBitmaps[2]), wxNullBitmap, FALSE, currentX, -1, (wxObject *) NULL, _("Go forward to the next HTML page")); + currentX += width + 5; + + toolBar -> Realize(); + + // Can delete the bitmaps since they're reference counted + for (int i = 0; i < 3; i++) delete toolBarBitmaps[i]; + } + + + { + m_Splitter = new wxSplitterWindow(m_Frame); + + m_HtmlWin = new wxHtmlWindow(m_Splitter); + m_HtmlWin -> SetRelatedFrame(m_Frame, m_TitleFormat); + m_HtmlWin -> SetRelatedStatusBar(0); + if (m_Config) m_HtmlWin -> ReadCustomization(m_Config, m_ConfigRoot); + + m_NavigPan = new wxNotebook(m_Splitter, wxID_HTML_NOTEBOOK, wxDefaultPosition, wxDefaultSize); + { + m_ContentsBox = new wxTreeCtrl(m_NavigPan, wxID_HTML_TREECTRL, wxDefaultPosition, wxDefaultSize, wxTR_HAS_BUTTONS | wxSUNKEN_BORDER); + m_ContentsBox -> SetImageList(m_ContentsImageList); + m_NavigPan -> AddPage(m_ContentsBox, _("Contents")); + } + + { + wxWindow *dummy = new wxPanel(m_NavigPan, wxID_HTML_INDEXPAGE); + wxLayoutConstraints *b1 = new wxLayoutConstraints; + b1 -> top.SameAs (dummy, wxTop, 0); + b1 -> left.SameAs (dummy, wxLeft, 0); + b1 -> width.PercentOf (dummy, wxWidth, 100); + b1 -> bottom.SameAs (dummy, wxBottom, 0); + m_IndexBox = new wxListBox(dummy, wxID_HTML_INDEXLIST, wxDefaultPosition, wxDefaultSize, 0); + m_IndexBox -> SetConstraints(b1); + dummy -> SetAutoLayout(TRUE); + m_NavigPan -> AddPage(dummy, _("Index")); + } + + { + wxWindow *dummy = new wxPanel(m_NavigPan, wxID_HTML_SEARCHPAGE); + + wxLayoutConstraints *b1 = new wxLayoutConstraints; + m_SearchText = new wxTextCtrl(dummy, wxID_HTML_SEARCHTEXT); + b1 -> top.SameAs (dummy, wxTop, 0); + b1 -> left.SameAs (dummy, wxLeft, 0); + b1 -> right.SameAs (dummy, wxRight, 0); + b1 -> height.AsIs(); + m_SearchText -> SetConstraints(b1); + + wxLayoutConstraints *b2 = new wxLayoutConstraints; + m_SearchButton = new wxButton(dummy, wxID_HTML_SEARCHBUTTON, _("Search!")); + b2 -> top.Below (m_SearchText, 10); + b2 -> right.SameAs (dummy, wxRight, 10); + b2 -> width.AsIs(); + b2 -> height.AsIs(); + m_SearchButton -> SetConstraints(b2); + + wxLayoutConstraints *b3 = new wxLayoutConstraints; + m_SearchList = new wxListBox(dummy, wxID_HTML_SEARCHLIST, wxDefaultPosition, wxDefaultSize, 0); + b3 -> top.Below (m_SearchButton, 10); + b3 -> left.SameAs (dummy, wxLeft, 0); + b3 -> right.SameAs (dummy, wxRight, 0); + b3 -> bottom.SameAs (dummy, wxBottom, 0); + m_SearchList -> SetConstraints(b3); + + dummy -> SetAutoLayout(TRUE); + dummy -> Layout(); + m_NavigPan -> AddPage(dummy, _("Search")); + } + + RefreshLists(); + m_NavigPan -> Show(TRUE); + m_HtmlWin -> Show(TRUE); + m_Splitter -> SetMinimumPaneSize(20); + m_Splitter -> SplitVertically(m_NavigPan, m_HtmlWin, m_Cfg.sashpos); + if (!m_Cfg.navig_on) m_Splitter -> Unsplit(m_NavigPan); + wxYield(); + } + + m_Frame -> Show(TRUE); + wxYield(); +} + + + +#define MAX_ROOTS 64 + +void wxHtmlHelpController::CreateContents() +{ + HtmlContentsItem *it; + wxTreeItemId roots[MAX_ROOTS]; + bool imaged[MAX_ROOTS]; + int count = m_ContentsCnt; + + m_ContentsBox -> DeleteAllItems(); + roots[0] = m_ContentsBox -> AddRoot(_("(Help)")); + imaged[0] = TRUE; + + for (int i = 0; i < count; i++) { + it = m_Contents + i; + roots[it -> m_Level + 1] = m_ContentsBox -> AppendItem(roots[it -> m_Level], it -> m_Name, IMG_Page, -1, new wxHtmlHelpTreeItemData(it)); + if (it -> m_Level == 0) { + m_ContentsBox -> SetItemBold(roots[1], TRUE); + m_ContentsBox -> SetItemImage(roots[1], IMG_Book); + m_ContentsBox -> SetItemSelectedImage(roots[1], IMG_Book); + imaged[1] = TRUE; + } + else imaged[it -> m_Level + 1] = FALSE; + + if (!imaged[it -> m_Level]) { + m_ContentsBox -> SetItemImage(roots[it -> m_Level], IMG_Folder); + m_ContentsBox -> SetItemSelectedImage(roots[it -> m_Level], IMG_Folder); + imaged[it -> m_Level] = TRUE; + } + } + + m_ContentsBox -> Expand(roots[0]); +} + + + + +void wxHtmlHelpController::CreateIndex() +{ + m_IndexBox -> Clear(); + + for (int i = 0; i < m_IndexCnt; i++) + m_IndexBox -> Append(m_Index[i].m_Name, (char*)(m_Index + i)); +} + + + +void wxHtmlHelpController::RefreshLists() +{ + if (m_Frame) { + CreateContents(); + CreateIndex(); + m_SearchList -> Clear(); + } +} + + + + + + + +void wxHtmlHelpController::ReadCustomization(wxConfigBase *cfg, wxString path) +{ + wxString oldpath; + wxString tmp; + + if (path != wxEmptyString) { + oldpath = cfg -> GetPath(); + cfg -> SetPath(path); + } + + m_Cfg.navig_on = cfg -> Read("hcNavigPanel", m_Cfg.navig_on) != 0; + m_Cfg.sashpos = cfg -> Read("hcSashPos", m_Cfg.sashpos); + m_Cfg.x = cfg -> Read("hcX", m_Cfg.x); + m_Cfg.y = cfg -> Read("hcY", m_Cfg.y); + m_Cfg.w = cfg -> Read("hcW", m_Cfg.w); + m_Cfg.h = cfg -> Read("hcH", m_Cfg.h); + + if (path != wxEmptyString) + cfg -> SetPath(oldpath); +} + + + +void wxHtmlHelpController::WriteCustomization(wxConfigBase *cfg, wxString path) +{ + wxString oldpath; + wxString tmp; + + if (path != wxEmptyString) { + oldpath = cfg -> GetPath(); + cfg -> SetPath(path); + } + + cfg -> Write("hcNavigPanel", m_Cfg.navig_on); + cfg -> Write("hcSashPos", (long)m_Cfg.sashpos); + cfg -> Write("hcX", (long)m_Cfg.x); + cfg -> Write("hcY", (long)m_Cfg.y); + cfg -> Write("hcW", (long)m_Cfg.w); + cfg -> Write("hcH", (long)m_Cfg.h); + + if (path != wxEmptyString) + cfg -> SetPath(oldpath); +} + + + + + +/* +EVENT HANDLING : +*/ + + +void wxHtmlHelpController::OnToolbar(wxCommandEvent& event) +{ + switch (event.GetId()) { + case wxID_HTML_BACK : + m_HtmlWin -> HistoryBack(); + break; + case wxID_HTML_FORWARD : + m_HtmlWin -> HistoryForward(); + break; + case wxID_HTML_PANEL : + if (m_Splitter -> IsSplit()) { + m_Cfg.sashpos = m_Splitter -> GetSashPosition(); + m_Splitter -> Unsplit(m_NavigPan); + } + else { + m_NavigPan -> Show(TRUE); + m_HtmlWin -> Show(TRUE); + m_Splitter -> SplitVertically(m_NavigPan, m_HtmlWin, m_Cfg.sashpos); + } + break; + } +} + + + +void wxHtmlHelpController::OnContentsSel(wxTreeEvent& event) +{ + wxHtmlHelpTreeItemData *pg; + + pg = (wxHtmlHelpTreeItemData*) m_ContentsBox -> GetItemData(event.GetItem()); + if (pg) m_HtmlWin -> LoadPage(pg -> GetPage()); +} + + + +void wxHtmlHelpController::OnIndexSel(wxCommandEvent& event) +{ + HtmlContentsItem *it = (HtmlContentsItem*) m_IndexBox -> GetClientData(m_IndexBox -> GetSelection()); + if (it) m_HtmlWin -> LoadPage(it -> m_Book -> GetBasePath() + it -> m_Page); +} + + + +void wxHtmlHelpController::OnSearchSel(wxCommandEvent& event) +{ + HtmlContentsItem *it = (HtmlContentsItem*) m_SearchList -> GetClientData(m_SearchList -> GetSelection()); + if (it) m_HtmlWin -> LoadPage(it -> m_Book -> GetBasePath() + it -> m_Page); +} + + + +void wxHtmlHelpController::OnCloseWindow(wxCloseEvent& event) +{ + int a, b; + + m_Cfg.navig_on = m_Splitter -> IsSplit(); + if (m_Cfg.navig_on) + m_Cfg.sashpos = m_Splitter -> GetSashPosition(); + m_Frame -> GetPosition(&a, &b); + m_Cfg.x = a, m_Cfg.y = b; + m_Frame -> GetSize(&a, &b); + m_Cfg.w = a, m_Cfg.h = b; + + if (m_Config) { + WriteCustomization(m_Config, m_ConfigRoot); + m_HtmlWin -> WriteCustomization(m_Config, m_ConfigRoot); + } + m_Frame = NULL; + + event.Skip(); +} + + + +void wxHtmlHelpController::OnSearch(wxCommandEvent& event) +{ + wxString sr = m_SearchText -> GetLineText(0); + + if (sr != wxEmptyString) KeywordSearch(sr); +} + + + +BEGIN_EVENT_TABLE(wxHtmlHelpController, wxEvtHandler) + EVT_TOOL_RANGE(wxID_HTML_PANEL, wxID_HTML_FORWARD, wxHtmlHelpController::OnToolbar) + EVT_TREE_SEL_CHANGED(wxID_HTML_TREECTRL, wxHtmlHelpController::OnContentsSel) + EVT_LISTBOX(wxID_HTML_INDEXLIST, wxHtmlHelpController::OnIndexSel) + EVT_LISTBOX(wxID_HTML_SEARCHLIST, wxHtmlHelpController::OnSearchSel) + EVT_CLOSE(wxHtmlHelpController::OnCloseWindow) + EVT_BUTTON(wxID_HTML_SEARCHBUTTON, wxHtmlHelpController::OnSearch) + EVT_TEXT_ENTER(wxID_HTML_SEARCHTEXT, wxHtmlHelpController::OnSearch) +END_EVENT_TABLE() + + + +#endif + Index: wxWidgets/src/html/search.cpp =================================================================== RCS file: search.cpp diff -N search.cpp --- /dev/null Thu Dec 14 21:47:46 2006 +++ wxWidgets/src/html/search.cpp Thu Dec 14 21:47:51 2006 @@ -0,0 +1,72 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: search.cpp +// Purpose: search engine +// Author: Vaclav Slavik +// RCS-ID: +// Copyright: (c) 1999 Vaclav Slavik +// Licence: wxWindows Licence +///////////////////////////////////////////////////////////////////////////// + + + +#ifdef __GNUG__ +#pragma implementation +#endif + +#include "wx/wxprec.h" + +#include "wx/defs.h" +#if wxUSE_HTML + +#ifdef __BORDLANDC__ +#pragma hdrstop +#endif + +#ifndef WXPRECOMP +#endif + +#include "wx/html/helpdata.h" + + +//-------------------------------------------------------------------------------- +// wxSearchEngine +//-------------------------------------------------------------------------------- + +void wxSearchEngine::LookFor(const wxString& keyword) +{ + if (m_Keyword) delete[] m_Keyword; + m_Keyword = new wxChar[keyword.Length() + 1]; + wxStrcpy(m_Keyword, keyword.c_str()); + for (int i = wxStrlen(m_Keyword) - 1; i >= 0; i--) + if ((m_Keyword[i] >= wxT('A')) && (m_Keyword[i] <= wxT('Z'))) + m_Keyword[i] += wxT('a') - wxT('A'); +} + + + +bool wxSearchEngine::Scan(wxInputStream *stream) +{ + wxASSERT_MSG(m_Keyword != NULL, _("wxSearchEngine::LookFor must be called before scanning!")); + + int i, j; + int lng = stream ->GetSize(); + int wrd = wxStrlen(m_Keyword); + bool found = FALSE; + char *buf = new char[lng + 1]; + stream -> Read(buf, lng); + buf[lng] = 0; + + for (i = 0; i < lng; i++) + if ((buf[i] >= 'A') && (buf[i] <= 'Z')) buf[i] += 'a' - 'A'; + + for (i = 0; i < lng - wrd; i++) { + j = 0; + while ((j < wrd) && (buf[i + j] == m_Keyword[j])) j++; + if (j == wrd) {found = TRUE; break;} + } + + delete[] buf; + return found; +} + +#endif Index: wxWidgets/src/unix/net.cpp =================================================================== RCS file: net.cpp diff -N net.cpp --- /dev/null Thu Dec 14 21:48:09 2006 +++ wxWidgets/src/unix/net.cpp Thu Dec 14 21:48:13 2006 @@ -0,0 +1,422 @@ +// -*- c++ -*- /////////////////////////////////////////////////////////////// +// Name: unix/net.cpp +// Purpose: Network related wxWindows classes and functions +// Author: Karsten Ballüder +// Modified by: +// Created: 03.10.99 +// RCS-ID: +// Copyright: (c) Karsten Ballüder +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +#include "wx/setup.h" + +#if wxUSE_DIALUP_MANAGER + +#ifndef WX_PRECOMP +# include "wx/defs.h" +#endif // !PCH + +#include "wx/string.h" +#include "wx/event.h" +#include "wx/net.h" +#include "wx/timer.h" +#include "wx/filefn.h" +#include "wx/utils.h" +#include "wx/log.h" +#include "wx/file.h" + +#include +#include +#include +#include +#define __STRICT_ANSI__ +#include +#include +#include +#include +#include +#include + +// ---------------------------------------------------------------------------- +// A class which groups functions dealing with connecting to the network from a +// workstation using dial-up access to the net. There is at most one instance +// of this class in the program accessed via GetDialUpManager(). +// ---------------------------------------------------------------------------- + +/* TODO + * + * 1. more configurability for Unix: i.e. how to initiate the connection, how + * to check for online status, &c. + * 2. add a "long Dial(long connectionId = -1)" function which asks the user + * about which connection to dial (this may be done using native dialogs + * under NT, need generic dialogs for all others) and returns the identifier + * of the selected connection (it's opaque to the application) - it may be + * reused later to dial the same connection later (or use strings instead of + * longs may be?) + * 3. add an async version of dialing functions which notify the caller about + * the progress (or may be even start another thread to monitor it) + * 4. the static creation/accessor functions are not MT-safe - but is this + * really crucial? I think we may suppose they're always called from the + * main thread? + */ + +class WXDLLEXPORT wxDialUpManagerImpl : public wxDialUpManager +{ +public: + wxDialUpManagerImpl() + { + m_IsOnline = -1; // unknown + m_timer = NULL; + m_CanUseIfconfig = -1; // unknown + m_BeaconHost = WXDIALUP_MANAGER_DEFAULT_BEACONHOST; + m_BeaconPort = 80; + } + + /** Could the dialup manager be initialized correctly? If this function + returns FALSE, no other functions will work neither, so it's a good idea + to call this function and check its result before calling any other + wxDialUpManager methods. + */ + virtual bool IsOk() const + { return TRUE; } + + /** The simplest way to initiate a dial up: this function dials the given + ISP (exact meaning of the parameter depends on the platform), returns + TRUE on success or FALSE on failure and logs the appropriate error + message in the latter case. + @param nameOfISP optional paramater for dial program + @param username unused + @param password unused + */ + virtual bool Dial(const wxString& nameOfISP, + const wxString& WXUNUSED(username), + const wxString& WXUNUSED(password)); + + /// Hang up the currently active dial up connection. + virtual bool HangUp(); + + // returns TRUE if the computer is connected to the network: under Windows, + // this just means that a RAS connection exists, under Unix we check that + // the "well-known host" (as specified by SetWellKnownHost) is reachable + virtual bool IsOnline() const + { + if( (! m_timer) // we are not polling, so test now: + || m_IsOnline == -1 + ) + CheckStatus(); + return m_IsOnline != 0; + } + + // sometimes the built-in logic for determining the online status may fail, + // so, in general, the user should be allowed to override it. This function + // allows to forcefully set the online status - whatever our internal + // algorithm may think about it. + virtual void SetOnlineStatus(bool isOnline = TRUE) + { m_IsOnline = isOnline; } + + // set misc wxDialUpManager options + // -------------------------------- + + // enable automatical checks for the connection status and sending of + // wxEVT_DIALUP_CONNECTED/wxEVT_DIALUP_DISCONNECTED events. The interval + // parameter is only for Unix where we do the check manually: under + // Windows, the notification about the change of connection status is + // instantenous. + // + // Returns FALSE if couldn't set up automatic check for online status. + virtual bool EnableAutoCheckOnlineStatus(size_t nSeconds); + + // disable automatic check for connection status change - notice that the + // wxEVT_DIALUP_XXX events won't be sent any more neither. + virtual void DisableAutoCheckOnlineStatus(); + + // under Unix, the value of well-known host is used to check whether we're + // connected to the internet. It's unused under Windows, but this function + // is always safe to call. The default value is www.yahoo.com. + virtual void SetWellKnownHost(const wxString& hostname, + int portno = 80); + /** Sets the commands to start up the network and to hang up + again. Used by the Unix implementations only. + */ + virtual void SetConnectCommand(const wxString &command, const wxString &hupcmd) + { m_ConnectCommand = command; m_HangUpCommand = hupcmd; } + +private: + /// -1: don´t know, 0 = no, 1 = yes + int m_IsOnline; + + /// Can we use ifconfig to list active devices? + int m_CanUseIfconfig; + /// The path to ifconfig + wxString m_IfconfigPath; + + /// beacon host: + wxString m_BeaconHost; + /// beacon host portnumber for connect: + int m_BeaconPort; + + /// command to connect to network + wxString m_ConnectCommand; + /// command to hang up + wxString m_HangUpCommand; + /// name of ISP + wxString m_ISPname; + /// a timer for regular testing + class AutoCheckTimer *m_timer; + + friend class AutoCheckTimer; + /// determine status + void CheckStatus(void) const; + + /// real status check + void CheckStatusInternal(void); +}; + + +class AutoCheckTimer : public wxTimer +{ +public: + AutoCheckTimer(wxDialUpManagerImpl *dupman) + { + m_dupman = dupman; + m_started = FALSE; + } + + virtual bool Start( int millisecs = -1 ) + { m_started = TRUE; return wxTimer::Start(millisecs, FALSE); } + + virtual void Notify() + { wxLogTrace("Checking dial up network status."); m_dupman->CheckStatus(); } + + virtual void Stop() + { if ( m_started ) wxTimer::Stop(); } +public: + bool m_started; + wxDialUpManagerImpl *m_dupman; +}; + +bool +wxDialUpManagerImpl::Dial(const wxString &isp, + const wxString & WXUNUSED(username), + const wxString & WXUNUSED(password)) +{ + if(m_IsOnline == 1) + return FALSE; + m_IsOnline = -1; + m_ISPname = isp; + wxString cmd; + if(m_ConnectCommand.Find("%s")) + cmd.Printf(m_ConnectCommand,m_ISPname.c_str()); + else + cmd = m_ConnectCommand; + return wxExecute(cmd, /* sync */ TRUE) == 0; +} + +bool +wxDialUpManagerImpl::HangUp(void) +{ + if(m_IsOnline == 0) + return FALSE; + m_IsOnline = -1; + wxString cmd; + if(m_HangUpCommand.Find("%s")) + cmd.Printf(m_HangUpCommand,m_ISPname.c_str()); + else + cmd = m_HangUpCommand; + return wxExecute(cmd, /* sync */ TRUE) == 0; +} + + +bool +wxDialUpManagerImpl::EnableAutoCheckOnlineStatus(size_t nSeconds) +{ + wxASSERT(m_timer == NULL); + m_timer = new AutoCheckTimer(this); + bool rc = m_timer->Start(nSeconds*1000); + if(! rc) + { + delete m_timer; + m_timer = NULL; + } + return rc; +} + +void +wxDialUpManagerImpl::DisableAutoCheckOnlineStatus() +{ + wxASSERT(m_timer != NULL); + m_timer->Stop(); + delete m_timer; + m_timer = NULL; +} + + +void +wxDialUpManagerImpl::SetWellKnownHost(const wxString& hostname, int portno) +{ + /// does hostname contain a port number? + wxString port = hostname.After(':'); + if(port.Length()) + { + m_BeaconHost = hostname.Before(':'); + m_BeaconPort = atoi(port); + } + else + { + m_BeaconHost = hostname; + m_BeaconPort = portno; + } +} + + +void +wxDialUpManagerImpl::CheckStatus(void) const +{ + // This function calls the CheckStatusInternal() helper function + // which is OS - specific and then sends the events. + + int oldIsOnline = m_IsOnline; + ( /* non-const */ (wxDialUpManagerImpl *)this)->CheckStatusInternal(); + + // now send the events as appropriate: + if(m_IsOnline != oldIsOnline) + { + if(m_IsOnline) + ; // send ev + else + ; // send ev + } +} + +/* + We have three methods that we can use: + + 1. test via /sbin/ifconfig and grep for "sl", "ppp", "pl" + --> should be fast enough for regular polling + 2. test if we can reach the well known beacon host + --> too slow for polling + 3. check /proc/net/dev on linux?? + This method should be preferred, if possible. Need to do more + testing. + +*/ + +void +wxDialUpManagerImpl::CheckStatusInternal(void) +{ + m_IsOnline = -1; + + // First time check for ifconfig location. We only use the variant + // which does not take arguments, a la GNU. + if(m_CanUseIfconfig == -1) // unknown + { + if(wxFileExists("/sbin/ifconfig")) + m_IfconfigPath = "/sbin/ifconfig"; + else if(wxFileExists("/usr/sbin/ifconfig")) + m_IfconfigPath = "/usr/sbin/ifconfig"; + } + + wxLogNull ln; // suppress all error messages + // Let´s try the ifconfig method first, should be fastest: + if(m_CanUseIfconfig != 0) // unknown or yes + { + wxASSERT(m_IfconfigPath.length()); + + wxString tmpfile = wxGetTempFileName("_wxdialuptest"); + wxString cmd = "/bin/sh -c \'"; + cmd << m_IfconfigPath << " >" << tmpfile << '\''; + /* I tried to add an option to wxExecute() to not close stdout, + so we could let ifconfig write directly to the tmpfile, but + this does not work. That should be faster, as it doesn´t call + the shell first. I have no idea why. :-( (KB) */ +#if 0 + // temporarily redirect stdout/stderr: + int + new_stdout = dup(STDOUT_FILENO), + new_stderr = dup(STDERR_FILENO); + close(STDOUT_FILENO); + close(STDERR_FILENO); + + int + // new stdout: + output_fd = open(tmpfile, O_CREAT|O_TRUNC, S_IRUSR|S_IWUSR), + // new stderr: + null_fd = open("/dev/null", O_CREAT, S_IRUSR|S_IWUSR); + // verify well behaved unix behaviour: + wxASSERT(output_fd == STDOUT_FILENO); + wxASSERT(null_fd == STDERR_FILENO); + int rc = wxExecute(m_IfconfigPath,TRUE /* sync */,NULL ,wxEXECUTE_DONT_CLOSE_FDS); + close(null_fd); close(output_fd); + // restore old stdout, stderr: + int test; + test = dup(new_stdout); close(new_stdout); wxASSERT(test == STDOUT_FILENO); + test = dup(new_stderr); close(new_stderr); wxASSERT(test == STDERR_FILENO); + if(rc == 0) +#endif + if(wxExecute(cmd,TRUE /* sync */) == 0) + { + m_CanUseIfconfig = 1; + wxFile file; + if( file.Open(tmpfile) ) + { + char *output = new char [file.Length()+1]; + output[file.Length()] = '\0'; + if(file.Read(output,file.Length()) == file.Length()) + { + if(strstr(output,"ppp") // ppp + || strstr(output,"sl") // slip + || strstr(output,"pl") // plip + ) + m_IsOnline = 1; + else + m_IsOnline = 0; + } + file.Close(); + delete [] output; + } + // else m_IsOnline remains -1 as we don't know for sure + } + else // could not run ifconfig correctly + m_CanUseIfconfig = 0; // don´t try again + (void) wxRemoveFile(tmpfile); + if(m_IsOnline != -1) // we are done + return; + } + + // second method: try to connect to well known host: + // This can be used under Win 9x, too! + struct hostent *hp; + struct sockaddr_in serv_addr; + int sockfd; + + m_IsOnline = 0; // assume false + if((hp = gethostbyname(m_BeaconHost)) == NULL) + return; // no DNS no net + + serv_addr.sin_family = hp->h_addrtype; + memcpy(&serv_addr.sin_addr,hp->h_addr, hp->h_length); + serv_addr.sin_port = htons(m_BeaconPort); + if( ( sockfd = socket(hp->h_addrtype, SOCK_STREAM, 0)) < 0) + { + // sys_error("cannot create socket for gw"); + return; + } + if( connect(sockfd, (struct sockaddr *) &serv_addr, sizeof(serv_addr)) < 0) + { + //sys_error("cannot connect to server"); + return; + } + //connected! + close(sockfd); +} + + +/* static */ +wxDialUpManager * +wxDialUpManager::wxDialUpManager::Create(void) +{ + return new wxDialUpManagerImpl; +} + +#endif // wxUSE_DIALUP_MANAGER Index: wxWidgets/utils/wxprop/src/prop.cpp =================================================================== RCS file: prop.cpp diff -N prop.cpp --- /dev/null Thu Dec 14 21:48:56 2006 +++ wxWidgets/utils/wxprop/src/prop.cpp Thu Dec 14 21:48:57 2006 @@ -0,0 +1,1119 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: prop.cpp +// Purpose: Propert sheet classes implementation +// Author: Julian Smart +// Modified by: +// Created: 04/01/98 +// RCS-ID: +// Copyright: (c) Julian Smart +// Licence: wxWindows license +///////////////////////////////////////////////////////////////////////////// + +#ifdef __GNUG__ +#pragma implementation "prop.h" +#endif + +// For compilers that support precompilation, includes "wx/wx.h". +#include "wx/wxprec.h" + +#ifdef __BORLANDC__ +#pragma hdrstop +#endif + +#ifndef WX_PRECOMP +#include "wx/wx.h" +#endif + +#include +#include +#include +#include + +#if wxUSE_IOSTREAMH +#if defined(__WXMSW__) && !defined(__GNUWIN32__) +#include +#else +#include +#endif +#else +#include +#endif + +#include "wx/window.h" +#include "wx/utils.h" +#include "wx/list.h" +#include "prop.h" + +IMPLEMENT_DYNAMIC_CLASS(wxPropertyValue, wxObject) + +wxPropertyValue::wxPropertyValue(void) +{ + m_type = wxPropertyValueNull; + m_next = NULL; + m_last = NULL; + m_value.first = NULL; + m_clientData = NULL; + m_modifiedFlag = FALSE; +} + +wxPropertyValue::wxPropertyValue(const wxPropertyValue& copyFrom) +{ + m_modifiedFlag = FALSE; + Copy((wxPropertyValue& )copyFrom); +} + +wxPropertyValue::wxPropertyValue(const char *val) +{ + m_modifiedFlag = FALSE; + m_type = wxPropertyValueString; + + m_value.string = copystring(val); + m_clientData = NULL; + m_next = NULL; + m_last = NULL; +} + +wxPropertyValue::wxPropertyValue(const wxString& val) +{ + m_modifiedFlag = FALSE; + m_type = wxPropertyValueString; + + m_value.string = copystring((const char *)val); + m_clientData = NULL; + m_next = NULL; + m_last = NULL; +} + +wxPropertyValue::wxPropertyValue(long the_integer) +{ + m_modifiedFlag = FALSE; + m_type = wxPropertyValueInteger; + m_value.integer = the_integer; + m_clientData = NULL; + m_next = NULL; +} + +wxPropertyValue::wxPropertyValue(bool val) +{ + m_modifiedFlag = FALSE; + m_type = wxPropertyValuebool; + m_value.integer = val; + m_clientData = NULL; + m_next = NULL; +} + +wxPropertyValue::wxPropertyValue(float the_real) +{ + m_modifiedFlag = FALSE; + m_type = wxPropertyValueReal; + m_value.real = the_real; + m_clientData = NULL; + m_next = NULL; +} + +wxPropertyValue::wxPropertyValue(double the_real) +{ + m_modifiedFlag = FALSE; + m_type = wxPropertyValueReal; + m_value.real = (float)the_real; + m_clientData = NULL; + m_next = NULL; +} + +// Pointer versions: we have a pointer to the real C++ value. +wxPropertyValue::wxPropertyValue(char **val) +{ + m_modifiedFlag = FALSE; + m_type = wxPropertyValueStringPtr; + + m_value.stringPtr = val; + m_clientData = NULL; + m_next = NULL; + m_last = NULL; +} + +wxPropertyValue::wxPropertyValue(long *val) +{ + m_modifiedFlag = FALSE; + m_type = wxPropertyValueIntegerPtr; + m_value.integerPtr = val; + m_clientData = NULL; + m_next = NULL; +} + +wxPropertyValue::wxPropertyValue(bool *val) +{ + m_modifiedFlag = FALSE; + m_type = wxPropertyValueboolPtr; + m_value.boolPtr = val; + m_clientData = NULL; + m_next = NULL; +} + +wxPropertyValue::wxPropertyValue(float *val) +{ + m_modifiedFlag = FALSE; + m_type = wxPropertyValueRealPtr; + m_value.realPtr = val; + m_clientData = NULL; + m_next = NULL; +} + +wxPropertyValue::wxPropertyValue(wxList *the_list) +{ + m_modifiedFlag = FALSE; + m_type = wxPropertyValueList; + m_clientData = NULL; + m_last = NULL; + m_value.first = NULL; + + wxNode *node = the_list->First(); + while (node) + { + wxPropertyValue *expr = (wxPropertyValue *)node->Data(); + Append(expr); + node = node->Next(); + } + + delete the_list; +} + +wxPropertyValue::wxPropertyValue(wxStringList *the_list) +{ + m_modifiedFlag = FALSE; + m_type = wxPropertyValueList; + m_clientData = NULL; + m_last = NULL; + m_value.first = NULL; + + wxNode *node = the_list->First(); + while (node) + { + char *s = (char *)node->Data(); + Append(new wxPropertyValue(s)); + node = node->Next(); + } + delete the_list; +} + +wxPropertyValue::~wxPropertyValue(void) +{ + switch (m_type) + { + case wxPropertyValueInteger: + case wxPropertyValuebool: + case wxPropertyValueReal: + { + break; + } + case wxPropertyValueString: + { + delete[] m_value.string; + break; + } + case wxPropertyValueList: + { + wxPropertyValue *expr = m_value.first; + while (expr) + { + wxPropertyValue *expr1 = expr->m_next; + + delete expr; + expr = expr1; + } + break; + } + default: + case wxPropertyValueNull: break; + } +} + +void wxPropertyValue::Append(wxPropertyValue *expr) +{ + m_modifiedFlag = TRUE; + if (!m_value.first) + m_value.first = expr; + + if (m_last) + m_last->m_next = expr; + m_last = expr; +} + +void wxPropertyValue::Insert(wxPropertyValue *expr) +{ + m_modifiedFlag = TRUE; + expr->m_next = m_value.first; + m_value.first = expr; + + if (!m_last) + m_last = expr; +} + +// Delete from list +void wxPropertyValue::Delete(wxPropertyValue *node) +{ + wxPropertyValue *expr = GetFirst(); + + wxPropertyValue *previous = NULL; + while (expr && (expr != node)) + { + previous = expr; + expr = expr->GetNext(); + } + + if (expr) + { + if (previous) + previous->m_next = expr->m_next; + + // If node was the first in the list, + // make the list point to the NEXT one. + if (GetFirst() == expr) + { + m_value.first = expr->m_next; + } + + // If node was the last in the list, + // make the list 'last' pointer point to the PREVIOUS one. + if (GetLast() == expr) + { + if (previous) + m_last = previous; + else + m_last = NULL; + } + m_modifiedFlag = TRUE; + delete expr; + } + +} + +void wxPropertyValue::ClearList(void) +{ + wxPropertyValue *val = GetFirst(); + if (val) + m_modifiedFlag = TRUE; + + while (val) + { + wxPropertyValue *next = val->GetNext(); + delete val; + val = next; + } + m_value.first = NULL; + m_last = NULL; +} + +wxPropertyValue *wxPropertyValue::NewCopy(void) const +{ + switch (m_type) + { + case wxPropertyValueInteger: + return new wxPropertyValue(m_value.integer); + case wxPropertyValuebool: + return new wxPropertyValue((bool) (m_value.integer != 0)); + case wxPropertyValueReal: + return new wxPropertyValue(m_value.real); + case wxPropertyValueString: + return new wxPropertyValue(m_value.string); + case wxPropertyValueList: + { + wxPropertyValue *expr = m_value.first; + wxPropertyValue *new_list = new wxPropertyValue; + new_list->SetType(wxPropertyValueList); + while (expr) + { + wxPropertyValue *expr2 = expr->NewCopy(); + new_list->Append(expr2); + expr = expr->m_next; + } + return new_list; + } + case wxPropertyValueIntegerPtr: + return new wxPropertyValue(m_value.integerPtr); + case wxPropertyValueRealPtr: + return new wxPropertyValue(m_value.realPtr); + case wxPropertyValueboolPtr: + return new wxPropertyValue(m_value.boolPtr); + case wxPropertyValueStringPtr: + return new wxPropertyValue(m_value.stringPtr); + + case wxPropertyValueNull: +#ifdef __X__ + cerr << "Should never get here!\n"; +#endif + break; + } + return NULL; +} + +void wxPropertyValue::Copy(wxPropertyValue& copyFrom) +{ + m_type = copyFrom.Type(); + + switch (m_type) + { + case wxPropertyValueInteger: + (*this) = copyFrom.IntegerValue(); + return ; + + case wxPropertyValueReal: + (*this) = copyFrom.RealValue(); + return ; + + case wxPropertyValueString: + (*this) = wxString(copyFrom.StringValue()); + return ; + + case wxPropertyValuebool: + (*this) = copyFrom.BoolValue(); + return ; + + // Pointers + case wxPropertyValueboolPtr: + (*this) = copyFrom.BoolValuePtr(); + return ; + case wxPropertyValueRealPtr: + (*this) = copyFrom.RealValuePtr(); + return ; + case wxPropertyValueIntegerPtr: + (*this) = copyFrom.IntegerValuePtr(); + return ; + case wxPropertyValueStringPtr: + { + char** s = copyFrom.StringValuePtr(); + (*this) = s != 0; + return ; + } + + case wxPropertyValueList: + { + m_value.first = NULL; + m_next = NULL; + m_last = NULL; + wxPropertyValue *expr = copyFrom.m_value.first; + while (expr) + { + wxPropertyValue *expr2 = expr->NewCopy(); + Append(expr2); + expr = expr->m_next; + } + return; + } + case wxPropertyValueNull: +#ifdef __X__ + cerr << "Should never get here!\n"; +#endif + break; + } +} + +// Return nth argument of a clause (starting from 1) +wxPropertyValue *wxPropertyValue::Arg(wxPropertyValueType type, int arg) const +{ + wxPropertyValue *expr = m_value.first; + for (int i = 1; i < arg; i++) + if (expr) + expr = expr->m_next; + + if (expr && (expr->m_type == type)) + return expr; + else + return NULL; +} + +// Return nth argument of a list expression (starting from zero) +wxPropertyValue *wxPropertyValue::Nth(int arg) const +{ + if (m_type != wxPropertyValueList) + return NULL; + + wxPropertyValue *expr = m_value.first; + for (int i = 0; i < arg; i++) + if (expr) + expr = expr->m_next; + else return NULL; + + if (expr) + return expr; + else + return NULL; +} + + // Returns the number of elements in a list expression +int wxPropertyValue::Number(void) const +{ + if (m_type != wxPropertyValueList) + return 0; + + int i = 0; + wxPropertyValue *expr = m_value.first; + while (expr) + { + expr = expr->m_next; + i ++; + } + return i; +} + +void wxPropertyValue::WritePropertyClause(ostream& stream) // Write this expression as a top-level clause +{ + if (m_type != wxPropertyValueList) + return; + + wxPropertyValue *node = m_value.first; + if (node) + { + node->WritePropertyType(stream); + stream << "("; + node = node->m_next; + bool first = TRUE; + while (node) + { + if (!first) + stream << " "; + node->WritePropertyType(stream); + node = node->m_next; + if (node) stream << ",\n"; + first = FALSE; + } + stream << ").\n\n"; + } +} + +void wxPropertyValue::WritePropertyType(ostream& stream) // Write as any other subexpression +{ + switch (m_type) + { + case wxPropertyValueInteger: + { + stream << m_value.integer; + break; + } + case wxPropertyValueIntegerPtr: + { + stream << *m_value.integerPtr; + break; + } + case wxPropertyValuebool: + { + if (m_value.integer) + stream << "True"; + else + stream << "False"; + break; + } + case wxPropertyValueboolPtr: + { + if (*m_value.integerPtr) + stream << "True"; + else + stream << "False"; + break; + } + case wxPropertyValueReal: + { + float f = m_value.real; + sprintf(wxBuffer, "%.6g", (double)f); + stream << wxBuffer; + break; + } + case wxPropertyValueRealPtr: + { + float f = *m_value.realPtr; +/* Now the parser can cope with this. + // Prevent printing in 'e' notation. Any better way? + if (fabs(f) < 0.00001) + f = 0.0; +*/ + sprintf(wxBuffer, "%.6g", f); + stream << wxBuffer; + break; + } + case wxPropertyValueString: + { +// stream << "\""; + int i; + int len = strlen(m_value.string); + for (i = 0; i < len; i++) + { + char ch = m_value.string[i]; +// if (ch == '"' || ch == '\\') +// stream << "\\"; + stream << ch; + } + +// stream << "\""; + break; + } + case wxPropertyValueStringPtr: + { + int i; + int len = strlen(*(m_value.stringPtr)); + for (i = 0; i < len; i++) + { + char ch = *(m_value.stringPtr)[i]; + + } + break; + } + case wxPropertyValueList: + { + if (!m_value.first) + stream << "[]"; + else + { + wxPropertyValue *expr = m_value.first; + + stream << "["; + while (expr) + { + expr->WritePropertyType(stream); + expr = expr->m_next; + if (expr) stream << ", "; + } + stream << "]"; + } + break; + } + case wxPropertyValueNull: break; + } +} + +wxString wxPropertyValue::GetStringRepresentation(void) +{ + char buf[500]; + buf[0] = 0; + + ostrstream str((char *)buf, (int)500, ios::out); + WritePropertyType(str); + str << '\0'; + str.flush(); + + wxString theString(buf); + return theString; +} + +void wxPropertyValue::operator=(const wxPropertyValue& val) +{ + m_modifiedFlag = TRUE; + Copy((wxPropertyValue&)val); +} + +// void wxPropertyValue::operator=(const char *val) +void wxPropertyValue::operator=(const wxString& val1) +{ + const char *val = (const char *)val1; + + m_modifiedFlag = TRUE; + if (m_type == wxPropertyValueNull) + m_type = wxPropertyValueString; + + if (m_type == wxPropertyValueString) + { + if (val) + m_value.string = copystring(val); + else + m_value.string = NULL; + } + else if (m_type == wxPropertyValueStringPtr) + { + if (*m_value.stringPtr) + delete[] *m_value.stringPtr; + if (val) + *m_value.stringPtr = copystring(val); + else + *m_value.stringPtr = NULL; + } + + m_clientData = NULL; + m_next = NULL; + m_last = NULL; + +} + +void wxPropertyValue::operator=(const long val) +{ + m_modifiedFlag = TRUE; + if (m_type == wxPropertyValueNull) + m_type = wxPropertyValueInteger; + + if (m_type == wxPropertyValueInteger) + m_value.integer = val; + else if (m_type == wxPropertyValueIntegerPtr) + *m_value.integerPtr = val; + else if (m_type == wxPropertyValueReal) + m_value.real = (float)val; + else if (m_type == wxPropertyValueRealPtr) + *m_value.realPtr = (float)val; + + m_clientData = NULL; + m_next = NULL; +} + +void wxPropertyValue::operator=(const bool val) +{ + m_modifiedFlag = TRUE; + if (m_type == wxPropertyValueNull) + m_type = wxPropertyValuebool; + + if (m_type == wxPropertyValuebool) + m_value.integer = (long)val; + else if (m_type == wxPropertyValueboolPtr) + *m_value.boolPtr = val; + + m_clientData = NULL; + m_next = NULL; +} + +void wxPropertyValue::operator=(const float val) +{ + m_modifiedFlag = TRUE; + if (m_type == wxPropertyValueNull) + m_type = wxPropertyValueReal; + + if (m_type == wxPropertyValueInteger) + m_value.integer = (long)val; + else if (m_type == wxPropertyValueIntegerPtr) + *m_value.integerPtr = (long)val; + else if (m_type == wxPropertyValueReal) + m_value.real = val; + else if (m_type == wxPropertyValueRealPtr) + *m_value.realPtr = val; + + m_clientData = NULL; + m_next = NULL; +} + +void wxPropertyValue::operator=(const char **val) +{ + m_modifiedFlag = TRUE; + m_type = wxPropertyValueStringPtr; + + if (val) + m_value.stringPtr = (char **)val; + else + m_value.stringPtr = NULL; + m_clientData = NULL; + m_next = NULL; + m_last = NULL; + +} + +void wxPropertyValue::operator=(const long *val) +{ + m_modifiedFlag = TRUE; + m_type = wxPropertyValueIntegerPtr; + m_value.integerPtr = (long *)val; + m_clientData = NULL; + m_next = NULL; +} + +void wxPropertyValue::operator=(const bool *val) +{ + m_modifiedFlag = TRUE; + m_type = wxPropertyValueboolPtr; + m_value.boolPtr = (bool *)val; + m_clientData = NULL; + m_next = NULL; +} + +void wxPropertyValue::operator=(const float *val) +{ + m_modifiedFlag = TRUE; + m_type = wxPropertyValueRealPtr; + m_value.realPtr = (float *)val; + m_clientData = NULL; + m_next = NULL; +} + +long wxPropertyValue::IntegerValue(void) const + { + if (m_type == wxPropertyValueInteger) + return m_value.integer; + else if (m_type == wxPropertyValueReal) + return (long)m_value.real; + else if (m_type == wxPropertyValueIntegerPtr) + return *m_value.integerPtr; + else if (m_type == wxPropertyValueRealPtr) + return (long)(*m_value.realPtr); + else return 0; + } + +long *wxPropertyValue::IntegerValuePtr(void) const +{ + return m_value.integerPtr; +} + +float wxPropertyValue::RealValue(void) const { + if (m_type == wxPropertyValueReal) + return m_value.real; + else if (m_type == wxPropertyValueRealPtr) + return *m_value.realPtr; + else if (m_type == wxPropertyValueInteger) + return (float)m_value.integer; + else if (m_type == wxPropertyValueIntegerPtr) + return (float)*(m_value.integerPtr); + else return 0.0; + } + +float *wxPropertyValue::RealValuePtr(void) const +{ + return m_value.realPtr; +} + +bool wxPropertyValue::BoolValue(void) const { + if (m_type == wxPropertyValueReal) + return (m_value.real != 0.0); + if (m_type == wxPropertyValueRealPtr) + return (*(m_value.realPtr) != 0.0); + else if (m_type == wxPropertyValueInteger) + return (m_value.integer != 0); + else if (m_type == wxPropertyValueIntegerPtr) + return (*(m_value.integerPtr) != 0); + else if (m_type == wxPropertyValuebool) + return (m_value.integer != 0); + else if (m_type == wxPropertyValueboolPtr) + return (*(m_value.boolPtr) != 0); + else return FALSE; + } + +bool *wxPropertyValue::BoolValuePtr(void) const +{ + return m_value.boolPtr; +} + +char *wxPropertyValue::StringValue(void) const { + if (m_type == wxPropertyValueString) + return m_value.string; + else if (m_type == wxPropertyValueStringPtr) + return *(m_value.stringPtr); + else return NULL; + } + +char **wxPropertyValue::StringValuePtr(void) const +{ + return m_value.stringPtr; +} + +/* + * A property (name plus value) + */ + +IMPLEMENT_DYNAMIC_CLASS(wxProperty, wxObject) + +wxProperty::wxProperty(void) +{ + m_propertyRole = (char *)NULL; + m_propertyValidator = NULL; + m_propertyWindow = NULL; + m_enabled = TRUE; +} + +wxProperty::wxProperty(wxProperty& copyFrom) +{ + m_value = copyFrom.GetValue(); + m_name = copyFrom.GetName(); + m_propertyRole = copyFrom.GetRole(); + m_propertyValidator = copyFrom.GetValidator(); + m_enabled = copyFrom.IsEnabled(); + m_propertyWindow = NULL; +} + +wxProperty::wxProperty(wxString nm, wxString role, wxPropertyValidator *ed):m_name(nm), m_propertyRole(role) +{ + m_propertyValidator = ed; + m_propertyWindow = NULL; + m_enabled = TRUE; +} + +wxProperty::wxProperty(wxString nm, const wxPropertyValue& val, wxString role, wxPropertyValidator *ed): + m_name(nm), m_value(val), m_propertyRole(role) +{ + m_propertyValidator = ed; + m_propertyWindow = NULL; + m_enabled = TRUE; +} + +wxProperty::~wxProperty(void) +{ + if (m_propertyValidator) + delete m_propertyValidator; +} + +wxPropertyValue& wxProperty::GetValue(void) const +{ + return (wxPropertyValue&) m_value; +} + +wxPropertyValidator *wxProperty::GetValidator(void) const +{ + return m_propertyValidator; +} + +wxString& wxProperty::GetName(void) const +{ + return (wxString&) m_name; +} + +wxString& wxProperty::GetRole(void) const +{ + return (wxString&) m_propertyRole; +} + +void wxProperty::SetValue(const wxPropertyValue& val) +{ + m_value = val; +} + +void wxProperty::SetValidator(wxPropertyValidator *ed) +{ + m_propertyValidator = ed; +} + +void wxProperty::SetRole(wxString& role) +{ + m_propertyRole = role; +} + +void wxProperty::SetName(wxString& nm) +{ + m_name = nm; +} + +void wxProperty::operator=(const wxPropertyValue& val) +{ + m_value = val; +} + +/* + * Base property view class + */ + +IMPLEMENT_DYNAMIC_CLASS(wxPropertyView, wxEvtHandler) + +wxPropertyView::wxPropertyView(long flags) +{ + m_buttonFlags = flags; + m_propertySheet = NULL; + m_currentValidator = NULL; + m_currentProperty = NULL; +} + +wxPropertyView::~wxPropertyView(void) +{ +} + +void wxPropertyView::AddRegistry(wxPropertyValidatorRegistry *registry) +{ + m_validatorRegistryList.Append(registry); +} + +wxPropertyValidator *wxPropertyView::FindPropertyValidator(wxProperty *property) +{ + if (property->GetValidator()) + return property->GetValidator(); + + wxNode *node = m_validatorRegistryList.First(); + while (node) + { + wxPropertyValidatorRegistry *registry = (wxPropertyValidatorRegistry *)node->Data(); + wxPropertyValidator *validator = registry->GetValidator(property->GetRole()); + if (validator) + return validator; + node = node->Next(); + } + return NULL; +/* + if (!wxDefaultPropertyValidator) + wxDefaultPropertyValidator = new wxPropertyListValidator; + return wxDefaultPropertyValidator; +*/ +} + +/* + * Property sheet + */ + +IMPLEMENT_DYNAMIC_CLASS(wxPropertySheet, wxObject) + +wxPropertySheet::wxPropertySheet(void):m_properties(wxKEY_STRING) +{ +} + +wxPropertySheet::~wxPropertySheet(void) +{ + Clear(); +} + +bool wxPropertySheet::Save( ostream& WXUNUSED(str) ) +{ + return FALSE; +} + +bool wxPropertySheet::Load( ostream& WXUNUSED(str) ) +{ + return FALSE; +} + +void wxPropertySheet::UpdateAllViews( wxPropertyView *WXUNUSED(thisView) ) +{ +} + +// Add a property +void wxPropertySheet::AddProperty(wxProperty *property) +{ + m_properties.Append((const char*) property->GetName(), property); +} + +// Get property by name +wxProperty *wxPropertySheet::GetProperty(wxString name) +{ + wxNode *node = m_properties.Find((const char*) name); + if (!node) + return NULL; + else + return (wxProperty *)node->Data(); +} + +// Clear all properties +void wxPropertySheet::Clear(void) +{ + wxNode *node = m_properties.First(); + while (node) + { + wxProperty *prop = (wxProperty *)node->Data(); + wxNode *next = node->Next(); + delete prop; + delete node; + node = next; + } +} + +// Sets/clears the modified flag for each property value +void wxPropertySheet::SetAllModified(bool flag) +{ + wxNode *node = m_properties.First(); + while (node) + { + wxProperty *prop = (wxProperty *)node->Data(); + prop->GetValue().SetModified(flag); + node = node->Next(); + } +} + +/* + * Property validator registry + * + */ + +IMPLEMENT_DYNAMIC_CLASS(wxPropertyValidatorRegistry, wxHashTable) + +wxPropertyValidatorRegistry::wxPropertyValidatorRegistry(void):wxHashTable(wxKEY_STRING) +{ +} + +wxPropertyValidatorRegistry::~wxPropertyValidatorRegistry(void) +{ + ClearRegistry(); +} + +void wxPropertyValidatorRegistry::RegisterValidator(const wxString& typeName, wxPropertyValidator *validator) +{ + Put((const char*) typeName, validator); +} + +wxPropertyValidator *wxPropertyValidatorRegistry::GetValidator(const wxString& typeName) +{ + return (wxPropertyValidator *)Get((const char*) typeName); +} + +void wxPropertyValidatorRegistry::ClearRegistry(void) +{ + BeginFind(); + wxNode *node; + while (node = Next()) + { + delete (wxPropertyValidator *)node->Data(); + } +} + + /* + * Property validator + */ + + +IMPLEMENT_ABSTRACT_CLASS(wxPropertyValidator, wxEvtHandler) + +wxPropertyValidator::wxPropertyValidator(long flags) +{ + m_validatorFlags = flags; + m_validatorProperty = NULL; +} + +wxPropertyValidator::~wxPropertyValidator(void) +{} + +bool wxPropertyValidator::StringToFloat (char *s, float *number) { + double num; + bool ok = StringToDouble (s, &num); + *number = (float) num; + return ok; +} + +bool wxPropertyValidator::StringToDouble (char *s, double *number) { + bool ok = TRUE; + char *value_ptr; + *number = strtod (s, &value_ptr); + if (value_ptr) { + int len = strlen (value_ptr); + for (int i = 0; i < len; i++) { + ok = (isspace (value_ptr[i]) != 0); + if (!ok) return FALSE; + } + } + return ok; +} + +bool wxPropertyValidator::StringToInt (char *s, int *number) { + long num; + bool ok = StringToLong (s, &num); + *number = (int) num; + return ok; +} + +bool wxPropertyValidator::StringToLong (char *s, long *number) { + bool ok = TRUE; + char *value_ptr; + *number = strtol (s, &value_ptr, 10); + if (value_ptr) { + int len = strlen (value_ptr); + for (int i = 0; i < len; i++) { + ok = (isspace (value_ptr[i]) != 0); + if (!ok) return FALSE; + } + } + return ok; +} + +char *wxPropertyValidator::FloatToString (float number) { + static char buf[20]; + sprintf (buf, "%.6g", number); + return buf; +} + +char *wxPropertyValidator::DoubleToString (double number) { + static char buf[20]; + sprintf (buf, "%.6g", number); + return buf; +} + +char *wxPropertyValidator::IntToString (int number) { + return ::IntToString (number); +} + +char *wxPropertyValidator::LongToString (long number) { + return ::LongToString (number); + } + +