-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathxeroxpatrone.cpp
More file actions
138 lines (115 loc) · 4.39 KB
/
xeroxpatrone.cpp
File metadata and controls
138 lines (115 loc) · 4.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
/**
*
* Xeroxpatrone
*
* http://code.google.com/p/xeroxpatrone
*
* Copyright (C) 2010 Dominik Meyer
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
#include "xeroxpatrone.h"
#include "logger.h"
#include "mainpanel.h"
#include "helpwindow.h"
bool XeroxpatroneApp::OnInit() {
#if defined(OS_WINDOWS) && defined(DEBUG)
//_CrtSetBreakAlloc(1395);
#endif
wxImage::AddHandler(new wxPNGHandler);
XeroxpatroneMainWindow *mainFrame = new XeroxpatroneMainWindow(_T("Xeroxpatrone"), wxPoint(300, 100),
wxSize(400, 600));
mainFrame->Show(true);
SetTopWindow(mainFrame);
return true;
}
int XeroxpatroneApp::OnExit() {
return 0;
}
XeroxpatroneMainWindow::XeroxpatroneMainWindow(const wxString& title, const wxPoint& pos, const wxSize& size)
: wxFrame(NULL, -1, title, pos, size),
logger(NULL), mainPanel(NULL) {
logger = new Logger(this);
logger->SetupLogging();
wxMenu *mainMenuFile = new wxMenu;
mainMenuFile->Append(ID_MAIN_Rescan, _T("&Scan for devices again ..."));
mainMenuFile->AppendSeparator();
mainMenuFile->Append(ID_MAIN_Quit, _T("&Quit..."));
wxMenu *mainMenuQuestionmark = new wxMenu;
//#ifdef DEBUG
mainMenuQuestionmark->Append(ID_MAIN_ShowLog, _T("&Show Log Window"));
mainMenuQuestionmark->Append(ID_MAIN_HideLog, _T("&Hide Log Window"));
mainMenuQuestionmark->AppendSeparator();
//#endif
mainMenuQuestionmark->Append(ID_MAIN_ShowHelp, _T("&Help"));
mainMenuQuestionmark->AppendSeparator();
mainMenuQuestionmark->Append(ID_MAIN_About, _T("&About..."));
wxMenuBar *mainMenu = new wxMenuBar;
mainMenu->Append(mainMenuFile, _T("&File"));
mainMenu->Append(mainMenuQuestionmark, _T("&?"));
SetMenuBar(mainMenu);
wxBoxSizer* xTopSizer = new wxBoxSizer(wxVERTICAL);
mainPanel = new MainPanel(this);
xTopSizer->Add(mainPanel, 1, wxEXPAND, 0);
SetAutoLayout(true);
SetSizer(xTopSizer);
Layout();
wxLogMessage(_T("Xeroxpatrone initalized ..."));
}
XeroxpatroneMainWindow::~XeroxpatroneMainWindow() {
SAFE_DELETE(logger);
}
void XeroxpatroneMainWindow::OnQuit(wxCommandEvent& WXUNUSED(event)) {
Close(true);
}
void XeroxpatroneMainWindow::OnClose(wxCloseEvent& event) {
OnCloseWindow(event);
}
void XeroxpatroneMainWindow::OnRescan(wxCommandEvent& WXUNUSED(event)) {
if(mainPanel) {
mainPanel->Destroy();
}
wxBoxSizer* xTopSizer = new wxBoxSizer(wxVERTICAL);
mainPanel = new MainPanel(this);
xTopSizer->Add(mainPanel, 1, wxEXPAND, 0);
SetAutoLayout(true);
SetSizer(xTopSizer);
Layout();;
}
void XeroxpatroneMainWindow::OnAbout(wxCommandEvent& WXUNUSED(event)) {
wxMessageBox(_T("Xeroxpatrone.\n\nUses the wxWindows Toolkit."),
_T("About"), wxOK | wxICON_INFORMATION, this);
}
void XeroxpatroneMainWindow::OnShowLogWindow(wxCommandEvent& WXUNUSED(event)) {
logger->ShowLogWindow();
}
void XeroxpatroneMainWindow::OnHideLogWindow(wxCommandEvent& WXUNUSED(event)) {
logger->HideLogWindow();
}
void XeroxpatroneMainWindow::OnHelp(wxCommandEvent& WXUNUSED(event)) {
HelpWindow* pHelpWindow = new HelpWindow(this, _T("Help"), wxDefaultPosition, wxDefaultSize);
pHelpWindow->Show(true);
}
BEGIN_EVENT_TABLE(XeroxpatroneMainWindow, wxFrame)
EVT_MENU(ID_MAIN_Quit, XeroxpatroneMainWindow::OnQuit)
EVT_MENU(ID_MAIN_Rescan, XeroxpatroneMainWindow::OnRescan)
EVT_CLOSE(XeroxpatroneMainWindow::OnClose)
EVT_MENU(ID_MAIN_ShowLog, XeroxpatroneMainWindow::OnShowLogWindow)
EVT_MENU(ID_MAIN_HideLog, XeroxpatroneMainWindow::OnHideLogWindow)
EVT_MENU(ID_MAIN_About, XeroxpatroneMainWindow::OnAbout)
EVT_MENU(ID_MAIN_ShowHelp, XeroxpatroneMainWindow::OnHelp)
END_EVENT_TABLE()
IMPLEMENT_APP(XeroxpatroneApp);