Develop and Download Open Source Software

Browse CVS Repository

Diff of /malonnote/mnNotePanel.cpp

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

revision 1.4 by maloninc, Thu Dec 22 10:48:29 2005 UTC revision 1.8 by maloninc, Fri Dec 30 03:50:38 2005 UTC
# Line 11  Line 11 
11  mnNotePanel::mnNotePanel(wxWindow* parent, wxString* dirName)  mnNotePanel::mnNotePanel(wxWindow* parent, wxString* dirName)
12  {  {
13          wxXmlResource::Get()->LoadPanel(this, parent, wxT("notePanel"));          wxXmlResource::Get()->LoadPanel(this, parent, wxT("notePanel"));
14          wxSplitterWindow* spWindow = XRCCTRL(*this, "splitWindow", wxSplitterWindow);          searchTree       = XRCCTRL(*this, "searchTree", wxTreeCtrl);
         searchTree       = XRCCTRL(*spWindow, "searchTree", wxTreeCtrl);  
15    
16  #ifdef __WXMAC__  #ifdef __WXMAC__
17          wikiHtmlTextCtrl = new mnHtmlWindow(spWindow, -1, wxT(""), wxPoint(0,-100), wxSize(200, 200));          wxSplitterWindow* spWindow = XRCCTRL(*this, "splitWindow", wxSplitterWindow);
18            wikiHtmlTextCtrl = new mnHtmlWindow(spWindow, -1, wxT(""), wxDefaultPosition, wxSize(200, 200));
19          spWindow->SplitVertically(searchTree, wikiHtmlTextCtrl, 250);          spWindow->SplitVertically(searchTree, wikiHtmlTextCtrl, 250);
20  #else  #else
21          /* init members */          /* init members */
22          wikiHtmlTextCtrl = XRCCTRL(*spWindow, "wikiHtmlTextCtrl", mnHtmlWindow);          wikiHtmlTextCtrl = XRCCTRL(*this, "wikiHtmlTextCtrl", mnHtmlWindow);
23  #endif  #endif
24    
25          /* create search tree */          /* create search tree */
# Line 129  void mnNotePanel::makeHtml(WikiData* wik Line 129  void mnNotePanel::makeHtml(WikiData* wik
129          /* escape > */          /* escape > */
130          wxRegEx exp02(wxT(">"), wxRE_NEWLINE|wxRE_DEFAULT);          wxRegEx exp02(wxT(">"), wxRE_NEWLINE|wxRE_DEFAULT);
131          exp02.Replace(&htmlText, wxT("\\&gt "));          exp02.Replace(&htmlText, wxT("\\&gt "));
132            
133            /* http://  */  
134            wxRegEx exp2(wxT("((http|https|ftp)://[-_.!~*'a-zA-Z0-9;/?:@&=+$,%#]+)"), wxRE_NEWLINE|wxRE_DEFAULT);
135            exp2.Replace(&htmlText, wxT("<a href=\\1>\\1</a>"));
136                    
137          /* [[ ]] */          /* [[ ]] */
138          wxRegEx exp1(wxT("\\[\\[([^\\}]+)\\]\\]"));          wxRegEx exp1(wxT("\\[\\[([^\\}]+)\\]\\]"));
139          exp1.Replace(&htmlText, wxT("<a href=mnlink:\\1> \\1 </a>"));          exp1.Replace(&htmlText, wxT("<a href=" MNLINK "\\1>\\1</a>"));
   
         /* http://  */    
         wxRegEx exp2(wxT("(http://[-_.!~*'a-zA-Z0-9;/?:@&=+$,%#]+)"), wxRE_NEWLINE|wxRE_DEFAULT);  
         exp2.Replace(&htmlText, wxT("<a href=\\1> \\1 </a>"));  
140    
141          /* file://  */            /* file://  */  
142          wxRegEx exp3(wxT("(file://[^ ]+)"), wxRE_NEWLINE|wxRE_DEFAULT);          wxRegEx exp3(wxT("(file://[^ ]+)"), wxRE_NEWLINE|wxRE_DEFAULT);
143          exp3.Replace(&htmlText, wxT("<a href=\\1> \\1 </a>"));          exp3.Replace(&htmlText, wxT("<a href=\\1>\\1</a>"));
144                    
145          /* **XXXX */          /* **XXXX */
146          wxRegEx exp5(wxT("^\\*\\*([^*]+)"), wxRE_NEWLINE|wxRE_DEFAULT);          wxRegEx exp5(wxT("^\\*\\*([^*]+)"), wxRE_NEWLINE|wxRE_DEFAULT);
147          exp5.Replace(&htmlText, wxT("<h4> \\1 </h4>"));          //exp5.Replace(&htmlText, wxT("<h4>\\1</h4>"));
148            exp5.Replace(&htmlText, wxT("<TABLE WIDTH=\"100%\" CELLPADDING=2 CELLSPACING=1 BORDER=0><TR><TD BGCOLOR=\"#CCFFFF\"><FONT SIZE=3><B>\\1</B></FONT></TD></TR></TABLE><BR>"));
149    
150          /* *XXXX */          /* *XXXX */
151          wxRegEx exp4(wxT("^\\*([^*]+)"), wxRE_NEWLINE|wxRE_DEFAULT);          wxRegEx exp4(wxT("^\\*([^*]+)"), wxRE_NEWLINE|wxRE_DEFAULT);
152          //wxRegEx exp4(wxT("^\\*(..*)"), wxRE_NEWLINE|wxRE_DEFAULT);          //exp4.Replace(&htmlText, wxT("<h3>\\1</h3>"));
153          exp4.Replace(&htmlText, wxT("<h3> \\1 </h3>"));          exp4.Replace(&htmlText, wxT("<TABLE WIDTH=\"100%\" CELLPADDING=5 CELLSPACING=2 BORDER=1><TR><TD BGCOLOR=\"#CCFFFF\"><FONT SIZE=5><B>\\1</B></FONT></TD></TR></TABLE><BR>"));
154                    
155          /* :''XXXX'': */          /* :''XXXX'': */
156          wxRegEx exp6(wxT("^:''(.+)'':(.+)"), wxRE_NEWLINE|wxRE_DEFAULT);          wxRegEx exp6(wxT("^:''(.+)'':(.+)"), wxRE_NEWLINE|wxRE_DEFAULT);
157          exp6.Replace(&htmlText, wxT("<u><b> \\1:\\2 </b></u>"));          exp6.Replace(&htmlText, wxT("<u><b>\\1:\\2</b></u>"));
158    
159          /* ---- */          /* ---- */
160          wxRegEx exp7(wxT("^----.*"), wxRE_NEWLINE|wxRE_DEFAULT);          wxRegEx exp7(wxT("^----.*"), wxRE_NEWLINE|wxRE_DEFAULT);
# Line 161  void mnNotePanel::makeHtml(WikiData* wik Line 162  void mnNotePanel::makeHtml(WikiData* wik
162    
163          /* {{ }} */          /* {{ }} */
164          wxRegEx exp8(wxT("\\{\\{([^\\}]+)\\}\\}"));          wxRegEx exp8(wxT("\\{\\{([^\\}]+)\\}\\}"));
165          exp8.Replace(&htmlText, wxT("<a href=mndoc:\\1> \\1 </a>"));          exp8.Replace(&htmlText, wxT("<a href=" MNDOC "\\1>\\1</a>"));
166    
167          /* table */          /* table */
168          wxRegEx exp10(wxT("^,([^,]+)"), wxRE_NEWLINE|wxRE_DEFAULT);          wxRegEx exp10(wxT("^,([^,]+)"), wxRE_NEWLINE|wxRE_DEFAULT);
169          exp10.Replace(&htmlText, wxT("<td> \\1 </td>"));          exp10.Replace(&htmlText, wxT("<td> \\1 </td>"));
170          for(int i = 0; i < 10; i++){ // It's not good.  :P          for(int i = 0; i < 10; i++){ // It's not good.  :P
171                  wxRegEx exp16(wxT("</td>,([^,\n]+)"), wxRE_DEFAULT);                  wxRegEx exp16(wxT("</td>,([^,\n]+)"), wxRE_DEFAULT);
172                  exp16.Replace(&htmlText, wxT("</td><td> \\1 </td>"));                  exp16.Replace(&htmlText, wxT("</td><td>\\1</td>"));
173          }          }
174          wxRegEx exp11(wxT("^<td>"), wxRE_NEWLINE|wxRE_DEFAULT);          wxRegEx exp11(wxT("^<td>"), wxRE_NEWLINE|wxRE_DEFAULT);
175          exp11.Replace(&htmlText, wxT("<tr><td>"));          exp11.Replace(&htmlText, wxT("<tr><td>"));
# Line 193  void mnNotePanel::makeHtml(WikiData* wik Line 194  void mnNotePanel::makeHtml(WikiData* wik
194                  {                  {
195                          wxString token = tkz.GetNextToken();                          wxString token = tkz.GetNextToken();
196                          wxRegEx exp9(wxT("(?!<[^>]+)(") + token + wxT(")(?![^<]+>)"), wxRE_ADVANCED|wxRE_ICASE|wxRE_NEWLINE);                          wxRegEx exp9(wxT("(?!<[^>]+)(") + token + wxT(")(?![^<]+>)"), wxRE_ADVANCED|wxRE_ICASE|wxRE_NEWLINE);
197                          exp9.Replace(&htmlText, wxT("<b><font color=\"red\"> \\1 </font></b>"));                          exp9.Replace(&htmlText, wxT("<b><font color=\"red\">\\1</font></b>"));
198                  }                  }
199          }          }
200    
201          /* make HTML document */          /* make HTML document */
202          wxString wikiHtml;          wxString wikiHtml;
203          wikiHtml.Append(wxT("<meta http-equiv=\"Content-Type\"content=\"text/html; charset="));          wikiHtml.Append(wxT("<meta http-equiv=\"Content-Type\" content=\"text/html; charset="));
204          wikiHtml.Append(wxT(CODE_SET_SYSTEM));          wikiHtml.Append(wxT(CODE_SET_SYSTEM));
205          wikiHtml.Append(wxT("\">"));          wikiHtml.Append(wxT("\">"));
206          wikiHtml.Append(wxT("<pre>"));          wikiHtml.Append(wxT("<pre>"));
# Line 220  void mnNotePanel::showSelectedItemText(w Line 221  void mnNotePanel::showSelectedItemText(w
221          item = searchTree->GetItemData(id);          item = searchTree->GetItemData(id);
222    
223          if(!id.IsOk() || !isEditableTreeLabel(id) || item == NULL) { /* selection is not memo data */          if(!id.IsOk() || !isEditableTreeLabel(id) || item == NULL) { /* selection is not memo data */
224                  wikiHtmlTextCtrl->SetPage(wxT(""));                  wikiHtmlTextCtrl->SetPage(wxT("<html></html>"));
225                  return;                  return;
226          }          }
227          makeHtml((WikiData*)item, false);          makeHtml((WikiData*)item, false);

Legend:
Removed from v.1.4  
changed lines
  Added in v.1.8

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