| 51 |
|
|
| 52 |
/* create search tree */ |
/* create search tree */ |
| 53 |
searchItemRoot = searchTree->AddRoot(wxT(LABEL_ITEM_TREE), -1, -1, NULL); |
searchItemRoot = searchTree->AddRoot(wxT(LABEL_ITEM_TREE), -1, -1, NULL); |
|
newItemRoot = searchTree->AppendItem(searchItemRoot, wxT(LABEL_NEW_ITEM), -1, -1, NULL); |
|
| 54 |
} |
} |
| 55 |
|
|
| 56 |
void mnFrame::set_properties() |
void mnFrame::set_properties() |
| 60 |
SetSize(wxSize(900, 572)); |
SetSize(wxSize(900, 572)); |
| 61 |
searchTextCtrl->SetFocus(); |
searchTextCtrl->SetFocus(); |
| 62 |
// end wxGlade |
// end wxGlade |
| 63 |
|
|
| 64 |
|
wxFont font(12, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL); |
| 65 |
|
wikiHtmlTextCtrl->SetFonts(font.GetFaceName(), font.GetFaceName()); |
| 66 |
} |
} |
| 67 |
|
|
| 68 |
|
|
| 98 |
Layout(); |
Layout(); |
| 99 |
|
|
| 100 |
searchTree->Expand(searchItemRoot); |
searchTree->Expand(searchItemRoot); |
|
searchTree->Expand(newItemRoot); |
|
| 101 |
} |
} |
| 102 |
|
|
| 103 |
void mnFrame::showSearchResult(mnModel* wiki) |
void mnFrame::showSearchResult(mnModel* wiki) |
| 108 |
int i; |
int i; |
| 109 |
|
|
| 110 |
searchTree->DeleteChildren(searchItemRoot); |
searchTree->DeleteChildren(searchItemRoot); |
|
newItemRoot = searchTree->AppendItem(searchItemRoot, wxT(LABEL_NEW_ITEM), -1, -1, NULL); |
|
| 111 |
|
|
| 112 |
searchStrList = wiki->getSearchStrList(); |
searchStrList = wiki->getSearchStrList(); |
| 113 |
for(i = 0; i < searchStrList->Count(); i++) { |
for(i = 0; i < searchStrList->Count(); i++) { |
| 152 |
wxString htmlText(*wikiText); |
wxString htmlText(*wikiText); |
| 153 |
|
|
| 154 |
/* [[ ]] */ |
/* [[ ]] */ |
| 155 |
wxRegEx exp1(wxT("\\[\\[(.+)\\]\\]")); |
wxRegEx exp1(wxT("\\[\\[([^\\}]+)\\]\\]")); |
| 156 |
exp1.Replace(&htmlText, wxT("<a href=mnlink:\\1>\\1</a>")); |
exp1.Replace(&htmlText, wxT("<a href=mnlink:\\1>\\1</a>")); |
| 157 |
|
|
| 158 |
/* http:// */ |
/* http:// */ |
| 159 |
wxRegEx exp2(wxT("(http://[\\.|&|-|%|$|#|=|_|-|~|\\?|/|a-z|A-Z|0-9]+)")); |
wxRegEx exp2(wxT("(http://[\\.|&|%|$|#|=|_|\\-|~|\\?|/|a-z|A-Z|0-9]+)")); |
| 160 |
exp2.Replace(&htmlText, wxT("<a href=\\1>\\1</a>")); |
exp2.Replace(&htmlText, wxT("<a href=\\1>\\1</a>")); |
| 161 |
|
|
| 162 |
/* file:// */ |
/* file:// */ |
| 176 |
exp6.Replace(&htmlText, wxT("<u><b>\\1:\\2</b></u>")); |
exp6.Replace(&htmlText, wxT("<u><b>\\1:\\2</b></u>")); |
| 177 |
|
|
| 178 |
/* ---- */ |
/* ---- */ |
| 179 |
wxRegEx exp7(wxT("^----.+"), wxRE_NEWLINE|wxRE_DEFAULT); |
wxRegEx exp7(wxT("^----.*"), wxRE_NEWLINE|wxRE_DEFAULT); |
| 180 |
exp7.Replace(&htmlText, wxT("<hr>")); |
exp7.Replace(&htmlText, wxT("<hr>")); |
| 181 |
|
|
| 182 |
|
/* {{ }} */ |
| 183 |
|
wxRegEx exp8(wxT("\\{\\{([^\\}]+)\\}\\}")); |
| 184 |
|
exp8.Replace(&htmlText, wxT("<a href=mndoc:\\1>\\1</a>")); |
| 185 |
|
|
| 186 |
/* make HTML document */ |
/* make HTML document */ |
| 187 |
wxString wikiHtml; |
wxString wikiHtml; |
| 188 |
wikiHtml.Append(wxT("<meta http-equiv=\"Content-Type\"content=\"text/html; charset=")); |
wikiHtml.Append(wxT("<meta http-equiv=\"Content-Type\"content=\"text/html; charset=")); |
| 189 |
wikiHtml.Append(wxT(CODE_SET_SYSTEM)); |
wikiHtml.Append(wxT(CODE_SET_SYSTEM)); |
| 190 |
wikiHtml.Append(wxT("\"><pre>")); |
wikiHtml.Append(wxT("\">")); |
| 191 |
|
wikiHtml.Append(wxT("<pre>")); |
| 192 |
wikiHtml.Append(htmlText); |
wikiHtml.Append(htmlText); |
| 193 |
wikiHtml.Append(wxT("</pre>")); |
wikiHtml.Append(wxT("</pre>")); |
| 194 |
|
|
|
|
|
| 195 |
wikiHtmlTextCtrl->SetPage(wikiHtml); |
wikiHtmlTextCtrl->SetPage(wikiHtml); |
| 196 |
} |
} |
| 197 |
|
|
|
void mnFrame::showNewItem(WikiData* data) |
|
|
{ |
|
|
wxTreeItemId itemId; |
|
|
|
|
|
itemId = searchTree->AppendItem(newItemRoot, *(data->getSubject()), -1, -1, (wxTreeItemData*)data); |
|
|
searchTree->Expand(searchItemRoot); |
|
|
searchTree->Expand(newItemRoot); |
|
|
searchTree->SelectItem(itemId); |
|
|
} |
|
| 198 |
|
|
| 199 |
wxTreeItemData* mnFrame::getSelectedItem() |
wxTreeItemData* mnFrame::getSelectedItem() |
| 200 |
{ |
{ |
| 211 |
return !(searchTree->GetItemParent(id) == searchItemRoot || id == searchItemRoot); |
return !(searchTree->GetItemParent(id) == searchItemRoot || id == searchItemRoot); |
| 212 |
} |
} |
| 213 |
|
|
|
bool mnFrame::isNewItem(wxTreeItemId id) |
|
|
{ |
|
|
return (searchTree->GetItemParent(id) == newItemRoot); |
|
|
} |
|
|
|
|