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.10 by maloninc, Tue Jan 3 23:20:39 2006 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            /* init html window */
26            wxFont font(12, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL);
27            wikiHtmlTextCtrl->SetFonts(font.GetFaceName(), font.GetFaceName());
28    
29          /* create search tree */          /* create search tree */
30          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 39  mnNotePanelController* mnNotePanel::getC
39          return panelController;          return panelController;
40  }  }
41    
 #if 0  
42  void mnNotePanel::updateSearchResult(mnModel* wiki, wxString* searchStr, bool isExpand)  void mnNotePanel::updateSearchResult(mnModel* wiki, wxString* searchStr, bool isExpand)
43  {  {
44          wxTreeItemIdValue cookie1, cookie2;          wxTreeItemIdValue cookie1, cookie2;
# Line 76  void mnNotePanel::updateSearchResult(mnM Line 85  void mnNotePanel::updateSearchResult(mnM
85                  searchTree->Collapse(searchStrId);                  searchTree->Collapse(searchStrId);
86          }          }
87  }  }
 #endif  
88    
89    
90  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 120  void mnNotePanel::addSearchResult(mnMode
120          }          }
121  }  }
122    
 #if 0  
123  void mnNotePanel::makeHtml(WikiData* wikiData, bool isHighlight)  void mnNotePanel::makeHtml(WikiData* wikiData, bool isHighlight)
124  {  {
125          const wxString* fileName = wikiData->getFileName();          const wxString* fileName = wikiData->getFileName();
# Line 126  void mnNotePanel::makeHtml(WikiData* wik Line 133  void mnNotePanel::makeHtml(WikiData* wik
133          /* escape > */          /* escape > */
134          wxRegEx exp02(wxT(">"), wxRE_NEWLINE|wxRE_DEFAULT);          wxRegEx exp02(wxT(">"), wxRE_NEWLINE|wxRE_DEFAULT);
135          exp02.Replace(&htmlText, wxT("\\&gt "));          exp02.Replace(&htmlText, wxT("\\&gt "));
136            
137            /* http://  */  
138            wxRegEx exp2(wxT("((http|https|ftp)://[-_.!~*'a-zA-Z0-9;/?:@&=+$,%#]+)"), wxRE_NEWLINE|wxRE_DEFAULT);
139            exp2.Replace(&htmlText, wxT("<a href=\\1>\\1</a>"));
140                    
141          /* [[ ]] */          /* [[ ]] */
142          wxRegEx exp1(wxT("\\[\\[([^\\}]+)\\]\\]"));          wxRegEx exp1(wxT("\\[\\[([^\\}]+)\\]\\]"));
143          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>"));  
144    
145          /* file://  */            /* file://  */  
146          wxRegEx exp3(wxT("(file://[^ ]+)"), wxRE_NEWLINE|wxRE_DEFAULT);          wxRegEx exp3(wxT("(file://[^ ]+)"), wxRE_NEWLINE|wxRE_DEFAULT);
147          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>"));  
148                    
149          /* **XXXX */          /* **XXXX */
150          wxRegEx exp5(wxT("^\\*\\*([^\\*]+)"), wxRE_NEWLINE|wxRE_DEFAULT);          wxRegEx exp5(wxT("^\\*\\*([^*]+)"), wxRE_NEWLINE|wxRE_DEFAULT);
151          exp5.Replace(&htmlText, wxT("<h4>\\1</h4>"));  #ifdef __WXMAC__
152            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>"));
153    #else
154            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>"));
155    #endif
156    
157            /* *XXXX */
158            wxRegEx exp4(wxT("^\\*([^*]+)"), wxRE_NEWLINE|wxRE_DEFAULT);
159    #ifdef __WXMAC__
160            exp4.Replace(&htmlText, wxT("<TABLE WIDTH=\"100%\" CELLPADDING=5 CELLSPACING=2 BORDER=1><TR><TD BGCOLOR=\"#CCFFFF\"><FONT SIZE=4><B>\\1</B></FONT></TD></TR></TABLE>"));
161    #else
162            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>"));
163    #endif
164                    
165          /* :''XXXX'': */          /* :''XXXX'': */
166          wxRegEx exp6(wxT("^:''(.+)'':(.+)"), wxRE_NEWLINE|wxRE_DEFAULT);          wxRegEx exp6(wxT("^:''(.+)'':(.+)"), wxRE_NEWLINE|wxRE_DEFAULT);
# Line 157  void mnNotePanel::makeHtml(WikiData* wik Line 172  void mnNotePanel::makeHtml(WikiData* wik
172    
173          /* {{ }} */          /* {{ }} */
174          wxRegEx exp8(wxT("\\{\\{([^\\}]+)\\}\\}"));          wxRegEx exp8(wxT("\\{\\{([^\\}]+)\\}\\}"));
175          exp8.Replace(&htmlText, wxT("<a href=mndoc:\\1>\\1</a>"));          exp8.Replace(&htmlText, wxT("<a href=" MNDOC "\\1>\\1</a>"));
176    
177          /* table */          /* table */
178          wxRegEx exp10(wxT(",([^,\n]+)"), wxRE_DEFAULT);          wxRegEx exp10(wxT("^,([^,]+)"), wxRE_NEWLINE|wxRE_DEFAULT);
179          exp10.Replace(&htmlText, wxT("<td>\\1</td>"));          exp10.Replace(&htmlText, wxT("<td> \\1 </td>"));
180            for(int i = 0; i < 10; i++){ // It's not good.  :P
181                    wxRegEx exp16(wxT("</td>,([^,\n]+)"), wxRE_DEFAULT);
182                    exp16.Replace(&htmlText, wxT("</td><td>\\1</td>"));
183            }
184          wxRegEx exp11(wxT("^<td>"), wxRE_NEWLINE|wxRE_DEFAULT);          wxRegEx exp11(wxT("^<td>"), wxRE_NEWLINE|wxRE_DEFAULT);
185          exp11.Replace(&htmlText, wxT("<tr><td>"));          exp11.Replace(&htmlText, wxT("<tr><td>"));
186          wxRegEx exp12(wxT("</td>$"), wxRE_NEWLINE|wxRE_DEFAULT);          wxRegEx exp12(wxT("</td>$"), wxRE_NEWLINE|wxRE_DEFAULT);
# Line 189  void mnNotePanel::makeHtml(WikiData* wik Line 208  void mnNotePanel::makeHtml(WikiData* wik
208                  }                  }
209          }          }
210    
           
211          /* make HTML document */          /* make HTML document */
212          wxString wikiHtml;          wxString wikiHtml;
213          wikiHtml.Append(wxT("<meta http-equiv=\"Content-Type\"content=\"text/html; charset="));          wikiHtml.Append(wxT("<meta http-equiv=\"Content-Type\" content=\"text/html; charset="));
214          wikiHtml.Append(wxT(CODE_SET_SYSTEM));          wikiHtml.Append(wxT(CODE_SET_SYSTEM));
215          wikiHtml.Append(wxT("\">"));          wikiHtml.Append(wxT("\">"));
216          wikiHtml.Append(wxT("<pre>"));          wikiHtml.Append(wxT("<pre>"));
217          wikiHtml.Append(htmlText);          wikiHtml.Append(wxT("<html>"));
218            wikiHtml.Append(htmlText.c_str());
219          wikiHtml.Append(wxT("</pre>"));          wikiHtml.Append(wxT("</pre>"));
220            wikiHtml.Append(wxT("</html>"));
221    
222          wikiHtmlTextCtrl->SetPage(wikiHtml);          wikiHtmlTextCtrl->SetPage(wikiHtml);
223  }  }
# Line 211  void mnNotePanel::showSelectedItemText(w Line 231  void mnNotePanel::showSelectedItemText(w
231          item = searchTree->GetItemData(id);          item = searchTree->GetItemData(id);
232    
233          if(!id.IsOk() || !isEditableTreeLabel(id) || item == NULL) { /* selection is not memo data */          if(!id.IsOk() || !isEditableTreeLabel(id) || item == NULL) { /* selection is not memo data */
234                  wikiHtmlTextCtrl->SetPage(wxT(""));                  wikiHtmlTextCtrl->SetPage(wxT("<html></html>"));
235                  return;                  return;
236          }          }
237          makeHtml((WikiData*)item, false);          makeHtml((WikiData*)item, false);
# Line 239  void mnNotePanel::highlightSelectedItem( Line 259  void mnNotePanel::highlightSelectedItem(
259          }          }
260  }  }
261    
262    
263  void mnNotePanel::expandAllTree()  void mnNotePanel::expandAllTree()
264  {  {
265          wxTreeItemIdValue cookie;          wxTreeItemIdValue cookie;
# Line 311  bool mnNotePanel::isEditableTreeLabel(wx Line 332  bool mnNotePanel::isEditableTreeLabel(wx
332          }          }
333  }  }
334    
 #endif  

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

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