| 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 */ |
| 22 |
searchTree = XRCCTRL(*this, "searchTree", wxTreeCtrl); |
wxFont font(12, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL); |
| 23 |
wikiHtmlTextCtrl = XRCCTRL(*this, "wikiHtmlTextCtrl", mnHtmlWindow); |
wikiHtmlTextCtrl = XRCCTRL(*this, "wikiHtmlTextCtrl", mnHtmlWindow); |
| 24 |
|
wikiHtmlTextCtrl->SetFonts(font.GetFaceName(), font.GetFaceName()); |
| 25 |
|
#endif |
| 26 |
|
|
| 27 |
|
|
| 28 |
/* create search tree */ |
/* create search tree */ |
| 29 |
searchItemRoot = searchTree->AddRoot(wxT(LABEL_ITEM_TREE), -1, -1, NULL); |
searchItemRoot = searchTree->AddRoot(wxT(LABEL_ITEM_TREE), -1, -1, NULL); |
| 38 |
return panelController; |
return panelController; |
| 39 |
} |
} |
| 40 |
|
|
|
#if 0 |
|
| 41 |
void mnNotePanel::updateSearchResult(mnModel* wiki, wxString* searchStr, bool isExpand) |
void mnNotePanel::updateSearchResult(mnModel* wiki, wxString* searchStr, bool isExpand) |
| 42 |
{ |
{ |
| 43 |
wxTreeItemIdValue cookie1, cookie2; |
wxTreeItemIdValue cookie1, cookie2; |
| 84 |
searchTree->Collapse(searchStrId); |
searchTree->Collapse(searchStrId); |
| 85 |
} |
} |
| 86 |
} |
} |
|
#endif |
|
| 87 |
|
|
| 88 |
|
|
| 89 |
void mnNotePanel::addSearchResult(mnModel* wiki, wxString* searchStr, bool isExpand) |
void mnNotePanel::addSearchResult(mnModel* wiki, wxString* searchStr, bool isExpand) |
| 119 |
} |
} |
| 120 |
} |
} |
| 121 |
|
|
|
#if 0 |
|
| 122 |
void mnNotePanel::makeHtml(WikiData* wikiData, bool isHighlight) |
void mnNotePanel::makeHtml(WikiData* wikiData, bool isHighlight) |
| 123 |
{ |
{ |
| 124 |
const wxString* fileName = wikiData->getFileName(); |
const wxString* fileName = wikiData->getFileName(); |
| 132 |
/* escape > */ |
/* escape > */ |
| 133 |
wxRegEx exp02(wxT(">"), wxRE_NEWLINE|wxRE_DEFAULT); |
wxRegEx exp02(wxT(">"), wxRE_NEWLINE|wxRE_DEFAULT); |
| 134 |
exp02.Replace(&htmlText, wxT("\\> ")); |
exp02.Replace(&htmlText, wxT("\\> ")); |
| 135 |
|
|
| 136 |
|
/* http:// */ |
| 137 |
|
wxRegEx exp2(wxT("((http|https|ftp)://[-_.!~*'a-zA-Z0-9;/?:@&=+$,%#]+)"), wxRE_NEWLINE|wxRE_DEFAULT); |
| 138 |
|
exp2.Replace(&htmlText, wxT("<a href=\\1>\\1</a>")); |
| 139 |
|
|
| 140 |
/* [[ ]] */ |
/* [[ ]] */ |
| 141 |
wxRegEx exp1(wxT("\\[\\[([^\\}]+)\\]\\]")); |
wxRegEx exp1(wxT("\\[\\[([^\\}]+)\\]\\]")); |
| 142 |
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>")); |
|
| 143 |
|
|
| 144 |
/* file:// */ |
/* file:// */ |
| 145 |
wxRegEx exp3(wxT("(file://[^ ]+)"), wxRE_NEWLINE|wxRE_DEFAULT); |
wxRegEx exp3(wxT("(file://[^ ]+)"), wxRE_NEWLINE|wxRE_DEFAULT); |
| 146 |
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>")); |
|
| 147 |
|
|
| 148 |
/* **XXXX */ |
/* **XXXX */ |
| 149 |
wxRegEx exp5(wxT("^\\*\\*([^\\*]+)"), wxRE_NEWLINE|wxRE_DEFAULT); |
wxRegEx exp5(wxT("^\\*\\*([^*]+)"), wxRE_NEWLINE|wxRE_DEFAULT); |
| 150 |
exp5.Replace(&htmlText, wxT("<h4>\\1</h4>")); |
#ifdef __WXMAC__ |
| 151 |
|
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>")); |
| 152 |
|
#else |
| 153 |
|
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>")); |
| 154 |
|
#endif |
| 155 |
|
|
| 156 |
|
/* *XXXX */ |
| 157 |
|
wxRegEx exp4(wxT("^\\*([^*]+)"), wxRE_NEWLINE|wxRE_DEFAULT); |
| 158 |
|
#ifdef __WXMAC__ |
| 159 |
|
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>")); |
| 160 |
|
#else |
| 161 |
|
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>")); |
| 162 |
|
#endif |
| 163 |
|
|
| 164 |
/* :''XXXX'': */ |
/* :''XXXX'': */ |
| 165 |
wxRegEx exp6(wxT("^:''(.+)'':(.+)"), wxRE_NEWLINE|wxRE_DEFAULT); |
wxRegEx exp6(wxT("^:''(.+)'':(.+)"), wxRE_NEWLINE|wxRE_DEFAULT); |
| 171 |
|
|
| 172 |
/* {{ }} */ |
/* {{ }} */ |
| 173 |
wxRegEx exp8(wxT("\\{\\{([^\\}]+)\\}\\}")); |
wxRegEx exp8(wxT("\\{\\{([^\\}]+)\\}\\}")); |
| 174 |
exp8.Replace(&htmlText, wxT("<a href=mndoc:\\1>\\1</a>")); |
exp8.Replace(&htmlText, wxT("<a href=\"" MNDOC "\\1\">\\1</a>")); |
| 175 |
|
|
| 176 |
/* table */ |
/* table */ |
| 177 |
wxRegEx exp10(wxT(",([^,\n]+)"), wxRE_DEFAULT); |
wxRegEx exp10(wxT("^,([^,]+)"), wxRE_NEWLINE|wxRE_DEFAULT); |
| 178 |
exp10.Replace(&htmlText, wxT("<td>\\1</td>")); |
exp10.Replace(&htmlText, wxT("<td> \\1 </td>")); |
| 179 |
|
for(int i = 0; i < 10; i++){ // It's not good. :P |
| 180 |
|
wxRegEx exp16(wxT("</td>,([^,\n]+)"), wxRE_DEFAULT); |
| 181 |
|
exp16.Replace(&htmlText, wxT("</td><td>\\1</td>")); |
| 182 |
|
} |
| 183 |
wxRegEx exp11(wxT("^<td>"), wxRE_NEWLINE|wxRE_DEFAULT); |
wxRegEx exp11(wxT("^<td>"), wxRE_NEWLINE|wxRE_DEFAULT); |
| 184 |
exp11.Replace(&htmlText, wxT("<tr><td>")); |
exp11.Replace(&htmlText, wxT("<tr><td>")); |
| 185 |
wxRegEx exp12(wxT("</td>$"), wxRE_NEWLINE|wxRE_DEFAULT); |
wxRegEx exp12(wxT("</td>$"), wxRE_NEWLINE|wxRE_DEFAULT); |
| 207 |
} |
} |
| 208 |
} |
} |
| 209 |
|
|
|
|
|
| 210 |
/* make HTML document */ |
/* make HTML document */ |
| 211 |
wxString wikiHtml; |
wxString wikiHtml; |
| 212 |
wikiHtml.Append(wxT("<meta http-equiv=\"Content-Type\"content=\"text/html; charset=")); |
wikiHtml.Append(wxT("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=")); |
| 213 |
wikiHtml.Append(wxT(CODE_SET_SYSTEM)); |
wikiHtml.Append(wxT(CODE_SET_SYSTEM)); |
| 214 |
wikiHtml.Append(wxT("\">")); |
wikiHtml.Append(wxT("\">")); |
| 215 |
wikiHtml.Append(wxT("<pre>")); |
wikiHtml.Append(wxT("<pre>")); |
| 216 |
wikiHtml.Append(htmlText); |
wikiHtml.Append(wxT("<html>")); |
| 217 |
|
wikiHtml.Append(htmlText.c_str()); |
| 218 |
wikiHtml.Append(wxT("</pre>")); |
wikiHtml.Append(wxT("</pre>")); |
| 219 |
|
wikiHtml.Append(wxT("</html>")); |
| 220 |
|
|
| 221 |
wikiHtmlTextCtrl->SetPage(wikiHtml); |
wikiHtmlTextCtrl->SetPage(wikiHtml); |
| 222 |
} |
} |
| 230 |
item = searchTree->GetItemData(id); |
item = searchTree->GetItemData(id); |
| 231 |
|
|
| 232 |
if(!id.IsOk() || !isEditableTreeLabel(id) || item == NULL) { /* selection is not memo data */ |
if(!id.IsOk() || !isEditableTreeLabel(id) || item == NULL) { /* selection is not memo data */ |
| 233 |
wikiHtmlTextCtrl->SetPage(wxT("")); |
wikiHtmlTextCtrl->SetPage(wxT("<html></html>")); |
| 234 |
return; |
return; |
| 235 |
} |
} |
| 236 |
makeHtml((WikiData*)item, false); |
makeHtml((WikiData*)item, false); |
| 258 |
} |
} |
| 259 |
} |
} |
| 260 |
|
|
| 261 |
|
|
| 262 |
void mnNotePanel::expandAllTree() |
void mnNotePanel::expandAllTree() |
| 263 |
{ |
{ |
| 264 |
wxTreeItemIdValue cookie; |
wxTreeItemIdValue cookie; |
| 331 |
} |
} |
| 332 |
} |
} |
| 333 |
|
|
|
#endif |
|