Develop and Download Open Source Software

Browse CVS Repository

Contents of /malonnote/main.cpp

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


Revision 1.10 - (show annotations) (download) (as text)
Tue Oct 24 08:52:04 2006 UTC (17 years, 4 months ago) by maloninc
Branch: MAIN
CVS Tags: HEAD
Changes since 1.9: +15 -0 lines
File MIME type: text/x-c++src
add FastSearch menu item and save it

1 // -*- C++ -*- generated by wxGlade 0.3.5.1 on Wed Jun 29 12:57:38 2005
2
3 #include <wx/wx.h>
4 #include <wx/image.h>
5 #include <wx/snglinst.h>
6 #include <wx/xrc/xmlres.h>
7 #include "mnDef.h"
8 #include "mnFrame.h"
9 #include "mnFrameController.h"
10
11 extern void InitXmlResource(); // defined in mnResource.cpp generated by wxrc
12
13 class mnApp: public wxApp {
14 public:
15 bool OnInit();
16 int OnExit();
17
18 private:
19 mnFrame* mainFrame;
20 wxSingleInstanceChecker* m_checker;
21 };
22
23 IMPLEMENT_APP(mnApp)
24
25 //static wxLocale locale(wxLANGUAGE_DEFAULT);
26
27 bool mnApp::OnInit()
28 {
29 wxString* dirName = new wxString();
30 wxString* fastSearchOpt = new wxString();
31 wxString gotDirName;
32 wxDirDialog* dlg;
33 wxString confKey;
34
35 const wxString appName = wxString::Format(wxT(MN_APP_NAME) wxT("-%s"), wxGetUserId().c_str());
36
37 m_checker = new wxSingleInstanceChecker(appName);
38 if ( m_checker->IsAnotherRunning() ){
39 wxMessageBox(wxT("Another program instance is already running, aborting."));
40 delete m_checker;
41 exit(0);
42 }
43
44 wxInitAllImageHandlers();
45 wxXmlResource::Get()->InitAllHandlers();
46 InitXmlResource();
47
48 mainFrame = new mnFrame(0);
49
50 /* set controller object as event handler */
51 mnFrameController* controller = new mnFrameController(mainFrame);
52 mainFrame->PushEventHandler(controller);
53
54 SetTopWindow(mainFrame);
55 mainFrame->Show();
56
57 /* add note panel */
58 wxConfig* config = new wxConfig(wxT(CONF_APP_NAME));
59 if(config->Read(wxT(CONF_WIKI_DIR), dirName) == FALSE) {
60 delete dirName;
61 dlg = new wxDirDialog(mainFrame);
62 if(dlg->ShowModal() == wxID_OK) {
63 gotDirName = dlg->GetPath();
64 config->Write(wxT(CONF_WIKI_DIR), gotDirName.c_str());
65 mainFrame->addNotePanel(&gotDirName);
66 }
67 else {
68 mainFrame->Close();
69 }
70 }
71 else {
72 mainFrame->addNotePanel(dirName);
73
74 for(int i = 1; ;i++) {
75 confKey.sprintf(wxT(CONF_WIKI_DIR) "%d", i);
76 if(config->Read(confKey.c_str(), dirName) == FALSE) break;
77 mainFrame->addNotePanel(dirName);
78 }
79 mainFrame->getNotebook()->SetSelection(0);
80 }
81
82 /* check Fast Search option */
83 wxMenuItem* mItem = mainFrame->GetMenuBar()->FindItem(XRCID("FastSearch"));
84 if(config->Read(wxT(CONF_FAST_SEARCH_OPT), fastSearchOpt) == FALSE) {
85 mItem->Check(true);
86 }
87 else{
88 if( fastSearchOpt->Contains(wxT(MN_ENABLE_FAST_SEARCH)) ) {
89 mItem->Check(true);
90 }
91 else {
92 mItem->Check(false);
93 }
94 }
95
96 delete config;
97
98 mainFrame->setFocusToSearchTextCtrl();
99 return true;
100 }
101
102 int mnApp::OnExit()
103 {
104 delete m_checker;
105 }

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