Develop and Download Open Source Software

Browse CVS Repository

Diff of /malonnote/mnController.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.8 by maloninc, Tue Aug 2 07:21:38 2005 UTC revision 1.16 by maloninc, Tue Sep 13 11:17:03 2005 UTC
# Line 15  BEGIN_EVENT_TABLE(mnController, wxEvtHan Line 15  BEGIN_EVENT_TABLE(mnController, wxEvtHan
15          EVT_TREE_END_LABEL_EDIT(ID_SearchTree, mnController::handleEndLabelEdit)          EVT_TREE_END_LABEL_EDIT(ID_SearchTree, mnController::handleEndLabelEdit)
16          EVT_MENU(ID_MenuFileNew, mnController::handleNewButton)          EVT_MENU(ID_MenuFileNew, mnController::handleNewButton)
17          EVT_MENU(ID_MenuFileRemove, mnController::handleRemoveButton)          EVT_MENU(ID_MenuFileRemove, mnController::handleRemoveButton)
18            EVT_MENU(ID_MenuFileHighlight, mnController::handleHighlightButton)
19          EVT_MENU(ID_MenuFileEdit, mnController::handleEditButton)          EVT_MENU(ID_MenuFileEdit, mnController::handleEditButton)
20          EVT_MENU(ID_MenuFileExit, mnController::handleExit)          EVT_MENU(ID_MenuFileExit, mnController::handleExit)
21          EVT_MENU(ID_MenuFileConfig, mnController::handleConfig)          EVT_MENU(ID_MenuFileConfig, mnController::handleConfig)
22            EVT_MENU(ID_MenuFileGroup, mnController::handleGroup)
23          EVT_MENU(wxID_ABOUT, mnController::handleAbout)          EVT_MENU(wxID_ABOUT, mnController::handleAbout)
24          EVT_CLOSE(mnController::handleClose)          EVT_CLOSE(mnController::handleClose)
25          EVT_COMMAND(ID_HtmlTextCtrl, mnEVT_LINK_CLICK, mnController::handleLinkClick)          EVT_COMMAND(ID_HtmlTextCtrl, mnEVT_LINK_CLICK, mnController::handleLinkClick)
# Line 30  mnController::mnController(mnFrame* infr Line 32  mnController::mnController(mnFrame* infr
32          wxDirDialog* dlg;          wxDirDialog* dlg;
33    
34          frame = inframe;          frame = inframe;
         isEditing = FALSE;  
35    
36          /* create wiki model */          /* create wiki model */
37          wxConfig* config = new wxConfig(wxT(CONF_APP_NAME));          wxConfig* config = new wxConfig(wxT(CONF_APP_NAME));
# Line 64  void mnController::handleConfig(wxComman Line 65  void mnController::handleConfig(wxComman
65          if(config->Read(wxT(CONF_WIKI_DIR), dirName)) {          if(config->Read(wxT(CONF_WIKI_DIR), dirName)) {
66                  if(wxMessageBox(*dirName, wxT("Change data directory?"), wxYES_NO|wxICON_QUESTION) == wxNO){                  if(wxMessageBox(*dirName, wxT("Change data directory?"), wxYES_NO|wxICON_QUESTION) == wxNO){
67                          delete config;                          delete config;
                         isEditing = FALSE;  
68                          return;                          return;
69                  }                  }
70          }                }      
# Line 79  void mnController::handleConfig(wxComman Line 79  void mnController::handleConfig(wxComman
79          delete config;          delete config;
80    
81          frame->showSearchResult(wiki);          frame->showSearchResult(wiki);
         isEditing = FALSE;  
82  }  }
83    
84  void mnController::handleSearch(wxCommandEvent& event)  void mnController::handleSearch(wxCommandEvent& event)
# Line 98  void mnController::handleSearch(wxComman Line 97  void mnController::handleSearch(wxComman
97    
98          wiki->addSearchStr(str);          wiki->addSearchStr(str);
99          frame->showSearchResult(wiki);          frame->showSearchResult(wiki);
         isEditing = FALSE;  
100  }  }
101    
102    void mnController::handleGroup(wxCommandEvent& event)
103    {
104            wiki->group();
105            frame->showSearchResult(wiki, false);
106    }
107    
108    
109  void mnController::handleNewButton(wxCommandEvent& event)  void mnController::handleNewButton(wxCommandEvent& event)
110  {  {
111          int             ans;          int             ans;
# Line 133  void mnController::handleRemoveButton(wx Line 138  void mnController::handleRemoveButton(wx
138          wxTreeItemData* item = frame->getSelectedItem();          wxTreeItemData* item = frame->getSelectedItem();
139    
140          if(item){          if(item){
141                  ((WikiData*)(item))->removeDataFile();                  if(wxMessageBox(wxT("Do you realy remove this memo?\n") + frame->getSelectedLabel(), wxT("Realy?"), wxYES_NO|wxICON_QUESTION) == wxYES){
142                            ((WikiData*)(item))->removeDataFile();
143                    }
144          }          }
145          else {          else {
146                  wiki->removeSearchStr(frame->getSelectedLabel());                  wiki->removeSearchStr(frame->getSelectedLabel());
147          }          }
148          frame->showSearchResult(wiki);          frame->showSearchResult(wiki);
         isEditing = FALSE;  
149  }  }
150    
151    void mnController::handleHighlightButton(wxCommandEvent& event)
152    {
153            frame->highlightSelectedItem();
154    }
155    
156    
157  void mnController::handleTreeItemSelect(wxTreeEvent& event)  void mnController::handleTreeItemSelect(wxTreeEvent& event)
158  {  {
159          frame->showSelectedItemText(event);          frame->showSelectedItemText(event);
         isEditing = FALSE;  
160  }  }
161    
162    
163  void mnController::handleTreeItemSelecting(wxTreeEvent& event)  void mnController::handleTreeItemSelecting(wxTreeEvent& event)
164  {  {
         if(frame->isNewItem(event.GetOldItem())) {  
                 frame->showSearchResult(wiki);  
                 event.Veto();  
         }  
165  }  }
166    
167  void mnController::handleBeginLabelEdit(wxTreeEvent& event)  void mnController::handleBeginLabelEdit(wxTreeEvent& event)
# Line 167  void mnController::handleEndLabelEdit(wx Line 174  void mnController::handleEndLabelEdit(wx
174          wxString newSubject   = event.GetLabel();          wxString newSubject   = event.GetLabel();
175          wxTreeItemData* item  = frame->getSelectedItem();          wxTreeItemData* item  = frame->getSelectedItem();
176    
177          if(item == NULL) return ;          if(item == NULL) {
178                    return ;
179            }
180                    
181          if(newSubject.Len() == 0) {          if(newSubject.Len() == 0) {
182                  event.Veto();                  event.Veto();
# Line 176  void mnController::handleEndLabelEdit(wx Line 185  void mnController::handleEndLabelEdit(wx
185          }          }
186    
187          ((WikiData*)(item))->modSubject(&newSubject);          ((WikiData*)(item))->modSubject(&newSubject);
         if(frame->isNewItem(event.GetItem())){  
                 return;  
         }  
188    
189          event.Veto();          event.Veto();
190          frame->showSearchResult(wiki);          frame->showSearchResult(wiki);
# Line 233  void mnController::handleEditButton(wxCo Line 239  void mnController::handleEditButton(wxCo
239    
240  void mnController::handleLinkClick(wxCommandEvent &event)  void mnController::handleLinkClick(wxCommandEvent &event)
241  {  {
242            const wxString* wikiDataDir;
243          wxString href = event.GetString();          wxString href = event.GetString();
244          wxString tag;          wxString tag;
245          wxString url;          wxString val;
246            wxString doc;
247          wxStringTokenizer tkz(href, wxT(":"));          wxStringTokenizer tkz(href, wxT(":"));
248    
249          tag = tkz.GetNextToken();                tag = tkz.GetNextToken();      
250          url = tkz.GetNextToken();          val = tkz.GetNextToken();
251            if(tag.CmpNoCase(wxT("mnlink")) == 0) {
252          if(tag.Cmp(wxT("mnlink")) == 0) {                  event.SetString(val);
                 event.SetString(url);  
253                  handleSearch(event);                  handleSearch(event);
254          }          }
255            else if(tag.CmpNoCase(wxT("mndoc")) == 0) {
256                    wikiDataDir = wiki->getWikiDataDir();
257                    doc = *wikiDataDir + wxT("/docs/") + val;
258                    openDoc(doc);
259            }
260          else {          else {
261                  openUrl(href);                  openUrl(href);
262          }          }
# Line 252  void mnController::handleLinkClick(wxCom Line 264  void mnController::handleLinkClick(wxCom
264    
265  void mnController::openUrl(wxString& url)  void mnController::openUrl(wxString& url)
266  {  {
         wxChar* argv[5];  
267          wxString cmd;          wxString cmd;
268    
269  #ifdef __WXMSW__  #ifdef __WXMSW__
         argv[0] = wxT("explorer");  
         argv[1] = (wxChar*)url.c_str();  
         argv[2] = NULL;  
270          cmd.sprintf(wxT("explorer %s"), url.c_str());          cmd.sprintf(wxT("explorer %s"), url.c_str());
271  #endif  #endif
272    
# Line 271  void mnController::openUrl(wxString& url Line 279  void mnController::openUrl(wxString& url
279  #endif  #endif
280    
281  #ifdef __WXGTK__  #ifdef __WXGTK__
282          wxLogMessage(wxT("Ooops!, I don't know how to launch %s"), url.c_str());          cmd.sprintf(wxT("gnome-open %s"), url.c_str());
         return;  
283  #endif  #endif
284    
285          //wxExecute(argv);          //wxExecute(argv);
286          wxExecute(cmd);          wxExecute(cmd);
287  }  }
288    
289    void mnController::openDoc(wxString& doc)
290    {
291            wxString cmd;
292    
293    #ifdef __WXMSW__
294            cmd.sprintf(wxT("cmd /c \"start %s\""), doc.c_str());
295    #endif
296    
297    #ifdef __WXMAC__
298            cmd.sprintf(wxT("open %s"), doc.c_str());
299    #endif
300    
301    #ifdef __WXCOCOA__
302            cmd.sprintf(wxT("open %s"), doc.c_str());
303    #endif
304    
305    #ifdef __WXGTK__
306            cmd.sprintf(wxT("gnome-open %s"), doc.c_str());
307    #endif
308    
309            wxExecute(cmd);
310    }

Legend:
Removed from v.1.8  
changed lines
  Added in v.1.16

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