Develop and Download Open Source Software

Browse CVS Repository

Diff of /malonnote/mnFrame.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.12 by maloninc, Mon Aug 8 03:50:22 2005 UTC revision 1.13 by maloninc, Fri Aug 26 11:17:51 2005 UTC
# Line 1  Line 1 
1  // -*- C++ -*- generated by wxGlade 0.3.5.1 on Wed Jun 29 12:57:38 2005  // -*- C++ -*- generated by wxGlade 0.3.5.1 on Wed Jun 29 12:57:38 2005
2  #include <wx/regex.h>  #include <wx/regex.h>
3    #include <wx/tokenzr.h>
4  #include "mnID.h"  #include "mnID.h"
5  #include "mnDef.h"  #include "mnDef.h"
6  #include "mnFrame.h"  #include "mnFrame.h"
# Line 28  mnFrame::mnFrame(wxWindow* parent, int i Line 29  mnFrame::mnFrame(wxWindow* parent, int i
29      tmp_menu_1->Append(ID_MenuFileNew, _("New\tCtrl+N"), wxT(""), wxITEM_NORMAL);      tmp_menu_1->Append(ID_MenuFileNew, _("New\tCtrl+N"), wxT(""), wxITEM_NORMAL);
30      tmp_menu_1->Append(ID_MenuFileEdit, _("Edit\tCtrl+E"), wxT(""), wxITEM_NORMAL);      tmp_menu_1->Append(ID_MenuFileEdit, _("Edit\tCtrl+E"), wxT(""), wxITEM_NORMAL);
31      tmp_menu_1->Append(ID_MenuFileRemove, _("Remove\tCtrl+R"), wxT(""), wxITEM_NORMAL);      tmp_menu_1->Append(ID_MenuFileRemove, _("Remove\tCtrl+R"), wxT(""), wxITEM_NORMAL);
32        tmp_menu_1->Append(ID_MenuFileHighlight, _("Highlight\tCtrl+L"), wxT(""), wxITEM_NORMAL);
33          tmp_menu_1->AppendSeparator();          tmp_menu_1->AppendSeparator();
34      tmp_menu_1->Append(ID_MenuFileConfig, _("Configure..."), wxT(""), wxITEM_NORMAL);      tmp_menu_1->Append(ID_MenuFileConfig, _("Configure..."), wxT(""), wxITEM_NORMAL);
35          tmp_menu_1->AppendSeparator();          tmp_menu_1->AppendSeparator();
# Line 139  void mnFrame::addSearchResult(wxString* Line 141  void mnFrame::addSearchResult(wxString*
141          searchTree->Expand(searchItem);          searchTree->Expand(searchItem);
142  }  }
143    
144  void mnFrame::showSelectedItemText(wxTreeEvent& event)  void mnFrame::makeHtml(WikiData* wikiData, bool isHighlight)
145  {  {
146          wxTreeItemData* item    = searchTree->GetItemData(event.GetItem());          const wxString* fileName = wikiData->getFileName();
147          if(item == NULL) {          const wxString* wikiText = wikiData->getText();
                 wikiHtmlTextCtrl->SetPage(wxT(""));  
                 return;  
         }  
   
         const wxString* fileName = ((WikiData*)(item))->getFileName();  
         const wxString* wikiText = ((WikiData*)(item))->getText();  
148          wxString htmlText(*wikiText);          wxString htmlText(*wikiText);
149    
150          /* escape < */          /* escape < */
# Line 158  void mnFrame::showSelectedItemText(wxTre Line 154  void mnFrame::showSelectedItemText(wxTre
154          /* escape > */          /* escape > */
155          wxRegEx exp02(wxT(">"), wxRE_NEWLINE|wxRE_DEFAULT);          wxRegEx exp02(wxT(">"), wxRE_NEWLINE|wxRE_DEFAULT);
156          exp02.Replace(&htmlText, wxT("\\&gt "));          exp02.Replace(&htmlText, wxT("\\&gt "));
157            
158          /* [[ ]] */          /* [[ ]] */
159          wxRegEx exp1(wxT("\\[\\[([^\\}]+)\\]\\]"));          wxRegEx exp1(wxT("\\[\\[([^\\}]+)\\]\\]"));
160          exp1.Replace(&htmlText, wxT("<a href=mnlink:\\1>\\1</a>"));          exp1.Replace(&htmlText, wxT("<a href=mnlink:\\1>\\1</a>"));
# Line 191  void mnFrame::showSelectedItemText(wxTre Line 187  void mnFrame::showSelectedItemText(wxTre
187          wxRegEx exp8(wxT("\\{\\{([^\\}]+)\\}\\}"));          wxRegEx exp8(wxT("\\{\\{([^\\}]+)\\}\\}"));
188          exp8.Replace(&htmlText, wxT("<a href=mndoc:\\1>\\1</a>"));          exp8.Replace(&htmlText, wxT("<a href=mndoc:\\1>\\1</a>"));
189    
190            /* Highlight search text */
191            highlight = isHighlight;
192            if(isHighlight) {
193            wxTreeItemId parentId = searchTree->GetItemParent(searchTree->GetSelection());
194                    wxString     searchWords = searchTree->GetItemText(parentId);
195                    wxStringTokenizer tkz(searchWords, wxT(" "));
196                    while ( tkz.HasMoreTokens() )
197                    {
198                            wxString token = tkz.GetNextToken();
199                            wxRegEx exp9(wxT("(?!<[^>]+)(") + token + wxT(")(?![^<]+>)"), wxRE_ADVANCED|wxRE_ICASE|wxRE_NEWLINE);
200                            exp9.Replace(&htmlText, wxT("<b><font color=\"red\">\\1</font></b>"));
201                    }
202            }
203    
204            
205          /* make HTML document */          /* make HTML document */
206          wxString wikiHtml;          wxString wikiHtml;
207          wikiHtml.Append(wxT("<meta http-equiv=\"Content-Type\"content=\"text/html; charset="));          wikiHtml.Append(wxT("<meta http-equiv=\"Content-Type\"content=\"text/html; charset="));
# Line 203  void mnFrame::showSelectedItemText(wxTre Line 214  void mnFrame::showSelectedItemText(wxTre
214          wikiHtmlTextCtrl->SetPage(wikiHtml);          wikiHtmlTextCtrl->SetPage(wikiHtml);
215  }  }
216    
217    void mnFrame::showSelectedItemText(wxTreeEvent& event)
218    {
219            wxTreeItemData* item    = searchTree->GetItemData(event.GetItem());
220            if(item == NULL) {
221                    wikiHtmlTextCtrl->SetPage(wxT(""));
222                    return;
223            }
224    
225            makeHtml((WikiData*)item, false);
226    }
227    
228    void mnFrame::highlightSelectedItem()
229    {
230            wxTreeItemData* item    = getSelectedItem();
231            if(item == NULL) {
232                    wikiHtmlTextCtrl->SetPage(wxT(""));
233                    return;
234            }
235    
236            if(highlight){
237                    makeHtml((WikiData*)item, false);
238            }
239            else {
240                    makeHtml((WikiData*)item, true);
241            }
242    }
243    
244  wxTreeItemData* mnFrame::getSelectedItem()  wxTreeItemData* mnFrame::getSelectedItem()
245  {  {

Legend:
Removed from v.1.12  
changed lines
  Added in v.1.13

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26