| 13 |
EVT_TREE_END_LABEL_EDIT(ID_SearchTree, mnController::handleEndLabelEdit) |
EVT_TREE_END_LABEL_EDIT(ID_SearchTree, mnController::handleEndLabelEdit) |
| 14 |
EVT_MENU(ID_MenuFileNew, mnController::handleNewButton) |
EVT_MENU(ID_MenuFileNew, mnController::handleNewButton) |
| 15 |
EVT_MENU(ID_MenuFileRemove, mnController::handleRemoveButton) |
EVT_MENU(ID_MenuFileRemove, mnController::handleRemoveButton) |
| 16 |
|
EVT_MENU(ID_MenuFileEdit, mnController::handleEditButton) |
| 17 |
EVT_MENU(ID_MenuFileExit, mnController::handleExit) |
EVT_MENU(ID_MenuFileExit, mnController::handleExit) |
| 18 |
EVT_MENU(ID_MenuFileConfig, mnController::handleConfig) |
EVT_MENU(ID_MenuFileConfig, mnController::handleConfig) |
| 19 |
EVT_MENU(wxID_ABOUT, mnController::handleAbout) |
EVT_MENU(wxID_ABOUT, mnController::handleAbout) |
| 104 |
|
|
| 105 |
void mnController::handleNewButton(wxCommandEvent& event) |
void mnController::handleNewButton(wxCommandEvent& event) |
| 106 |
{ |
{ |
| 107 |
if(isEditing) return; |
int ans; |
|
|
|
| 108 |
WikiData* wikiData = wiki->newWikiData(); |
WikiData* wikiData = wiki->newWikiData(); |
| 109 |
frame->showNewItem(wikiData); |
wxString plainTextStr; |
| 110 |
saveData(); |
wxString newSubjectStr; |
| 111 |
isEditing = TRUE; |
mnWikiDataEntryDialog* dlg = new mnWikiDataEntryDialog(frame, -1, wxT("Malon Note")); |
| 112 |
|
const wxString* wikiText = wikiData->getText(); |
| 113 |
|
const wxString* subject = wikiData->getSubject(); |
| 114 |
|
|
| 115 |
|
dlg->setSubject(*subject); |
| 116 |
|
dlg->setPlainText(*wikiText); |
| 117 |
|
ans = dlg->ShowModal(); |
| 118 |
|
|
| 119 |
|
if(ans != wxID_OK) return ; |
| 120 |
|
|
| 121 |
|
plainTextStr = dlg->getPlainText(); |
| 122 |
|
newSubjectStr = dlg->getSubject(); |
| 123 |
|
wikiData->modText(&plainTextStr); |
| 124 |
|
wikiData->save(); |
| 125 |
|
|
| 126 |
|
wikiData->modSubject(&newSubjectStr); |
| 127 |
|
|
| 128 |
|
frame->showSearchResult(wiki); |
| 129 |
|
delete dlg; |
| 130 |
} |
} |
| 131 |
|
|
| 132 |
void mnController::handleRemoveButton(wxCommandEvent& event) |
void mnController::handleRemoveButton(wxCommandEvent& event) |
| 170 |
wxString newSubject = event.GetLabel(); |
wxString newSubject = event.GetLabel(); |
| 171 |
wxTreeItemData* item = frame->getSelectedItem(); |
wxTreeItemData* item = frame->getSelectedItem(); |
| 172 |
|
|
|
event.Veto(); |
|
|
|
|
| 173 |
saveData(); |
saveData(); |
| 174 |
|
|
| 175 |
if(item == NULL) return ; |
if(item == NULL) return ; |
| 176 |
|
|
| 177 |
if(newSubject.Len() == 0) { |
if(newSubject.Len() == 0) { |
| 178 |
|
event.Veto(); |
| 179 |
frame->showSearchResult(wiki); |
frame->showSearchResult(wiki); |
| 180 |
return; |
return; |
| 181 |
} |
} |
| 182 |
|
|
| 183 |
((WikiData*)(item))->modSubject(&newSubject); |
((WikiData*)(item))->modSubject(&newSubject); |
| 184 |
|
if(frame->isNewItem(event.GetItem())){ |
| 185 |
|
return; |
| 186 |
|
} |
| 187 |
|
|
| 188 |
|
event.Veto(); |
| 189 |
frame->showSearchResult(wiki); |
frame->showSearchResult(wiki); |
| 190 |
} |
} |
| 191 |
|
|
| 203 |
|
|
| 204 |
void mnController::handleAbout(wxCommandEvent& event) |
void mnController::handleAbout(wxCommandEvent& event) |
| 205 |
{ |
{ |
| 206 |
wxMessageBox(wxT("MalonNote Ver0.9"), wxT("Abount MalonNote"), wxOK|wxICON_INFORMATION); |
wxMessageBox(wxT(MN_APP_VERSION), wxT("Abount MalonNote"), wxOK|wxICON_INFORMATION); |
| 207 |
} |
} |
| 208 |
|
|
| 209 |
|
|
| 210 |
|
void mnController::handleEditButton(wxCommandEvent& event) |
| 211 |
|
{ |
| 212 |
|
wxString plainTextStr; |
| 213 |
|
wxString newSubjectStr; |
| 214 |
|
wxTreeItemData* itemData = frame->getSelectedItem(); |
| 215 |
|
wxString subject = frame->getSelectedLabel(); |
| 216 |
|
mnWikiDataEntryDialog* dlg = new mnWikiDataEntryDialog(frame, -1, wxT("Malon Note")); |
| 217 |
|
int ans; |
| 218 |
|
|
| 219 |
|
if(itemData == NULL) return; |
| 220 |
|
const wxString* wikiText = ((WikiData*)(itemData))->getText(); |
| 221 |
|
|
| 222 |
|
dlg->setSubject(subject); |
| 223 |
|
dlg->setPlainText(*wikiText); |
| 224 |
|
ans = dlg->ShowModal(); |
| 225 |
|
|
| 226 |
|
if(ans != wxID_OK) return ; |
| 227 |
|
if(itemData == NULL) return ; |
| 228 |
|
|
| 229 |
|
plainTextStr = dlg->getPlainText(); |
| 230 |
|
newSubjectStr = dlg->getSubject(); |
| 231 |
|
((WikiData*)(itemData))->modText(&plainTextStr); |
| 232 |
|
((WikiData*)(itemData))->save(); |
| 233 |
|
|
| 234 |
|
((WikiData*)(itemData))->modSubject(&newSubjectStr); |
| 235 |
|
|
| 236 |
|
frame->showSearchResult(wiki); |
| 237 |
|
delete dlg; |
| 238 |
|
} |
| 239 |
|
|
| 240 |
void mnController::saveData() |
void mnController::saveData() |
| 241 |
{ |
{ |
| 242 |
|
#if 0 |
| 243 |
wxTreeItemData* item = frame->getSelectedItem(); |
wxTreeItemData* item = frame->getSelectedItem(); |
| 244 |
wxString plainTextStr = frame->getPlainText(); |
wxString plainTextStr = frame->getPlainText(); |
| 245 |
if(item == NULL) return ; |
if(item == NULL) return ; |
| 247 |
((WikiData*)(item))->modText(&plainTextStr); |
((WikiData*)(item))->modText(&plainTextStr); |
| 248 |
((WikiData*)(item))->save(); |
((WikiData*)(item))->save(); |
| 249 |
//frame->showSearchResult(wiki); |
//frame->showSearchResult(wiki); |
| 250 |
|
#endif |
| 251 |
} |
} |