OpenASIP
2.0
src
procgen
ProDe
PrintCmd.cc
Go to the documentation of this file.
1
/*
2
Copyright (c) 2002-2009 Tampere University.
3
4
This file is part of TTA-Based Codesign Environment (TCE).
5
6
Permission is hereby granted, free of charge, to any person obtaining a
7
copy of this software and associated documentation files (the "Software"),
8
to deal in the Software without restriction, including without limitation
9
the rights to use, copy, modify, merge, publish, distribute, sublicense,
10
and/or sell copies of the Software, and to permit persons to whom the
11
Software is furnished to do so, subject to the following conditions:
12
13
The above copyright notice and this permission notice shall be included in
14
all copies or substantial portions of the Software.
15
16
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22
DEALINGS IN THE SOFTWARE.
23
*/
24
/**
25
* @file PrintCmd.cc
26
*
27
* Definition of PrintCmd class.
28
*
29
* @author Veli-Pekka J��skel�inen 2004 (vjaaskel-no.spam-cs.tut.fi)
30
*/
31
32
#include <wx/docview.h>
33
#include <string>
34
35
#include "tce_config.h"
36
#include "
PrintCmd.hh
"
37
#include "
ProDeConstants.hh
"
38
#include "
ProDe.hh
"
39
#include "
ErrorDialog.hh
"
40
41
using
std::string;
42
43
44
/**
45
* The Constructor.
46
*/
47
PrintCmd::PrintCmd
():
48
EditorCommand
(
ProDeConstants
::CMD_NAME_PRINT) {
49
50
}
51
52
53
/**
54
* The Destructor.
55
*/
56
PrintCmd::~PrintCmd
() {
57
}
58
59
60
/**
61
* Executes the command.
62
*
63
* If the wxWidgets printing framework was not compiled in the wxWidgets
64
* library, printing is not possible. An error message will be displayed
65
* instead of printing.
66
*
67
* @return Always false. The command is not undoable.
68
*/
69
bool
70
PrintCmd::Do
() {
71
72
#if WX_PRINTING_DISABLED
73
74
// wxWidgets was compiled without printing framework, display an
75
// error message.
76
77
wxString message =
78
wxString(_T(
"Printing framework is disabled in the wxWidgets\n"
));
79
80
message.Append(_T(
"library. Print previewing is not possible."
));
81
82
ErrorDialog
error(
parentWindow
(), message);
83
error.ShowModal();
84
return
false
;
85
86
#else
87
88
// wxWidgets was compiled with the printing framework, create printout
89
// of the active view and print it.
90
91
// find the active view
92
wxView*
view
= wxGetApp().docManager()->GetCurrentView();
93
if
(
view
== NULL) {
94
return
false
;
95
}
96
97
// create a printout of the active view
98
wxPrintout* printout =
view
->OnCreatePrintout();
99
100
if
(printout != NULL) {
101
wxPrinter printer;
102
printer.Print(
view
->GetFrame(), printout,
true
);
103
104
delete
printout;
105
}
106
107
return
false
;
108
109
#endif // WX_PRINTING_DISABLED
110
111
}
112
113
114
/**
115
* Return id of this command.
116
*
117
* @return ID for this command to be used in menus and toolbars.
118
*/
119
int
120
PrintCmd::id
()
const
{
121
return
ProDeConstants::COMMAND_PRINT
;
122
}
123
124
125
/**
126
* Creates and returns a new instance of this command.
127
*
128
* @return Newly created instance of this command.
129
*/
130
PrintCmd
*
131
PrintCmd::create
()
const
{
132
return
new
PrintCmd
();
133
}
134
135
136
/**
137
* Returns path to the command's icon file.
138
*
139
* @return Full path to the command's icon file.
140
*/
141
string
142
PrintCmd::icon
()
const
{
143
return
ProDeConstants::CMD_ICON_PRINT
;
144
}
145
146
147
/**
148
* Returns true when command is executable, false when not.
149
*
150
* This command is executable when a document is open.
151
*
152
* @return True, if the command is executable.
153
*/
154
bool
155
PrintCmd::isEnabled
() {
156
wxDocManager* manager = wxGetApp().docManager();
157
if
(manager->GetCurrentView() != NULL) {
158
return
true
;
159
}
160
return
false
;
161
}
PrintCmd::isEnabled
virtual bool isEnabled()
Definition:
PrintCmd.cc:155
PrintCmd::create
virtual PrintCmd * create() const
Definition:
PrintCmd.cc:131
PrintCmd.hh
ProDe.hh
ProDeConstants::COMMAND_PRINT
@ COMMAND_PRINT
Definition:
ProDeConstants.hh:412
ProDeConstants::CMD_ICON_PRINT
static const std::string CMD_ICON_PRINT
Icon location for the "Print" command.
Definition:
ProDeConstants.hh:300
PrintCmd::PrintCmd
PrintCmd()
Definition:
PrintCmd.cc:47
PrintCmd
Definition:
PrintCmd.hh:41
ErrorDialog
Definition:
ErrorDialog.hh:42
PrintCmd::id
virtual int id() const
Definition:
PrintCmd.cc:120
ErrorDialog.hh
EditorCommand::view
wxView * view() const
Definition:
EditorCommand.cc:76
ProDeConstants.hh
EditorCommand
Definition:
EditorCommand.hh:46
PrintCmd::Do
virtual bool Do()
Definition:
PrintCmd.cc:70
ProDeConstants
Definition:
ProDeConstants.hh:43
GUICommand::parentWindow
wxWindow * parentWindow() const
Definition:
GUICommand.cc:75
PrintCmd::~PrintCmd
virtual ~PrintCmd()
Definition:
PrintCmd.cc:56
PrintCmd::icon
virtual std::string icon() const
Definition:
PrintCmd.cc:142
Generated by
1.8.17