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.1 by maloninc, Tue Oct 4 12:45:02 2005 UTC revision 1.6 by maloninc, Wed Dec 28 05:41:06 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            searchTree       = XRCCTRL(*this, "searchTree", wxTreeCtrl);
15    
16    #ifdef __WXMAC__
17            wxSplitterWindow* spWindow = XRCCTRL(*this, "splitWindow", wxSplitterWindow);
18            wikiHtmlTextCtrl = new mnHtmlWindow(spWindow, -1, wxT(""), wxDefaultPosition, wxSize(200, 200));
19            spWindow->SplitVertically(searchTree, wikiHtmlTextCtrl, 250);
20    #else
21          /* init members */          /* init members */
         searchTree       = XRCCTRL(*this, "searchTree", wxTreeCtrl);  
22          wikiHtmlTextCtrl = XRCCTRL(*this, "wikiHtmlTextCtrl", mnHtmlWindow);          wikiHtmlTextCtrl = XRCCTRL(*this, "wikiHtmlTextCtrl", mnHtmlWindow);
23    #endif
24    
25          /* create search tree */          /* create search tree */
26          searchItemRoot = searchTree->AddRoot(wxT(LABEL_ITEM_TREE), -1, -1, NULL);          searchItemRoot = searchTree->AddRoot(wxT(LABEL_ITEM_TREE), -1, -1, NULL);
# Line 29  mnNotePanelController* mnNotePanel::getC Line 35  mnNotePanelController* mnNotePanel::getC
35          return panelController;          return panelController;
36  }  }
37    
 #if 0  
38  void mnNotePanel::updateSearchResult(mnModel* wiki, wxString* searchStr, bool isExpand)  void mnNotePanel::updateSearchResult(mnModel* wiki, wxString* searchStr, bool isExpand)
39  {  {
40          wxTreeItemIdValue cookie1, cookie2;          wxTreeItemIdValue cookie1, cookie2;
# Line 76  void mnNotePanel::updateSearchResult(mnM Line 81  void mnNotePanel::updateSearchResult(mnM
81                  searchTree->Collapse(searchStrId);                  searchTree->Collapse(searchStrId);
82          }          }
83  }  }
 #endif  
84    
85    
86  void mnNotePanel::addSearchResult(mnModel* wiki, wxString* searchStr, bool isExpand)  void mnNotePanel::addSearchResult(mnModel* wiki, wxString* searchStr, bool isExpand)
# Line 112  void mnNotePanel::addSearchResult(mnMode Line 116  void mnNotePanel::addSearchResult(mnMode
116          }          }
117  }  }
118    
 #if 0  
119  void mnNotePanel::makeHtml(WikiData* wikiData, bool isHighlight)  void mnNotePanel::makeHtml(WikiData* wikiData, bool isHighlight)
120  {  {
121          const wxString* fileName = wikiData->getFileName();          const wxString* fileName = wikiData->getFileName();
# Line 126  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://[-_.!~*'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>"));
   
         /* *XXXX */  
         wxRegEx exp4(wxT("^\\*([^\\*]+)"), wxRE_NEWLINE|wxRE_DEFAULT);  
         exp4.Replace(&htmlText, wxT("<h3>\\1</h3>"));  
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    
149            /* *XXXX */
150            wxRegEx exp4(wxT("^\\*([^*]+)"), wxRE_NEWLINE|wxRE_DEFAULT);
151            exp4.Replace(&htmlText, wxT("<h3>\\1</h3>"));
152                    
153          /* :''XXXX'': */          /* :''XXXX'': */
154          wxRegEx exp6(wxT("^:''(.+)'':(.+)"), wxRE_NEWLINE|wxRE_DEFAULT);          wxRegEx exp6(wxT("^:''(.+)'':(.+)"), wxRE_NEWLINE|wxRE_DEFAULT);
# Line 157  void mnNotePanel::makeHtml(WikiData* wik Line 160  void mnNotePanel::makeHtml(WikiData* wik
160    
161          /* {{ }} */          /* {{ }} */
162          wxRegEx exp8(wxT("\\{\\{([^\\}]+)\\}\\}"));          wxRegEx exp8(wxT("\\{\\{([^\\}]+)\\}\\}"));
163          exp8.Replace(&htmlText, wxT("<a href=mndoc:\\1>\\1</a>"));          exp8.Replace(&htmlText, wxT("<a href=" MNDOC "\\1>\\1</a>"));
164    
165          /* table */          /* table */
166          wxRegEx exp10(wxT(",([^,\n]+)"), wxRE_DEFAULT);          wxRegEx exp10(wxT("^,([^,]+)"), wxRE_NEWLINE|wxRE_DEFAULT);
167          exp10.Replace(&htmlText, wxT("<td>\\1</td>"));          exp10.Replace(&htmlText, wxT("<td> \\1 </td>"));
168            for(int i = 0; i < 10; i++){ // It's not good.  :P
169                    wxRegEx exp16(wxT("</td>,([^,\n]+)"), wxRE_DEFAULT);
170                    exp16.Replace(&htmlText, wxT("</td><td>\\1</td>"));
171            }
172          wxRegEx exp11(wxT("^<td>"), wxRE_NEWLINE|wxRE_DEFAULT);          wxRegEx exp11(wxT("^<td>"), wxRE_NEWLINE|wxRE_DEFAULT);
173          exp11.Replace(&htmlText, wxT("<tr><td>"));          exp11.Replace(&htmlText, wxT("<tr><td>"));
174          wxRegEx exp12(wxT("</td>$"), wxRE_NEWLINE|wxRE_DEFAULT);          wxRegEx exp12(wxT("</td>$"), wxRE_NEWLINE|wxRE_DEFAULT);
# Line 189  void mnNotePanel::makeHtml(WikiData* wik Line 196  void mnNotePanel::makeHtml(WikiData* wik
196                  }                  }
197          }          }
198    
           
199          /* make HTML document */          /* make HTML document */
200          wxString wikiHtml;          wxString wikiHtml;
201          wikiHtml.Append(wxT("<meta http-equiv=\"Content-Type\"content=\"text/html; charset="));          wikiHtml.Append(wxT("<meta http-equiv=\"Content-Type\" content=\"text/html; charset="));
202          wikiHtml.Append(wxT(CODE_SET_SYSTEM));          wikiHtml.Append(wxT(CODE_SET_SYSTEM));
203          wikiHtml.Append(wxT("\">"));          wikiHtml.Append(wxT("\">"));
204          wikiHtml.Append(wxT("<pre>"));          wikiHtml.Append(wxT("<pre>"));
205          wikiHtml.Append(htmlText);          wikiHtml.Append(wxT("<html>"));
206            wikiHtml.Append(htmlText.c_str());
207          wikiHtml.Append(wxT("</pre>"));          wikiHtml.Append(wxT("</pre>"));
208            wikiHtml.Append(wxT("</html>"));
209    
210          wikiHtmlTextCtrl->SetPage(wikiHtml);          wikiHtmlTextCtrl->SetPage(wikiHtml);
211  }  }
# Line 211  void mnNotePanel::showSelectedItemText(w Line 219  void mnNotePanel::showSelectedItemText(w
219          item = searchTree->GetItemData(id);          item = searchTree->GetItemData(id);
220    
221          if(!id.IsOk() || !isEditableTreeLabel(id) || item == NULL) { /* selection is not memo data */          if(!id.IsOk() || !isEditableTreeLabel(id) || item == NULL) { /* selection is not memo data */
222                  wikiHtmlTextCtrl->SetPage(wxT(""));                  wikiHtmlTextCtrl->SetPage(wxT("<html></html>"));
223                  return;                  return;
224          }          }
225          makeHtml((WikiData*)item, false);          makeHtml((WikiData*)item, false);
# Line 239  void mnNotePanel::highlightSelectedItem( Line 247  void mnNotePanel::highlightSelectedItem(
247          }          }
248  }  }
249    
250    
251  void mnNotePanel::expandAllTree()  void mnNotePanel::expandAllTree()
252  {  {
253          wxTreeItemIdValue cookie;          wxTreeItemIdValue cookie;
# Line 311  bool mnNotePanel::isEditableTreeLabel(wx Line 320  bool mnNotePanel::isEditableTreeLabel(wx
320          }          }
321  }  }
322    
 #endif  

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.6

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