OpenASIP  2.0
Public Member Functions | List of all members
PrintCmd Class Reference

#include <PrintCmd.hh>

Inheritance diagram for PrintCmd:
Inheritance graph
Collaboration diagram for PrintCmd:
Collaboration graph

Public Member Functions

 PrintCmd ()
 
virtual ~PrintCmd ()
 
virtual bool Do ()
 
virtual int id () const
 
virtual PrintCmdcreate () const
 
virtual std::string icon () const
 
virtual bool isEnabled ()
 
- Public Member Functions inherited from EditorCommand
 EditorCommand (std::string name, wxWindow *parent=NULL)
 
virtual ~EditorCommand ()
 
void setView (wxView *view)
 
wxView * view () const
 
- Public Member Functions inherited from GUICommand
 GUICommand (std::string name, wxWindow *parent)
 
virtual ~GUICommand ()
 
virtual bool isChecked () const
 
virtual std::string shortName () const
 
void setParentWindow (wxWindow *view)
 
wxWindow * parentWindow () const
 
std::string name () const
 

Detailed Description

EditorCommand for printing documents.

Definition at line 41 of file PrintCmd.hh.

Constructor & Destructor Documentation

◆ PrintCmd()

PrintCmd::PrintCmd ( )

The Constructor.

Definition at line 47 of file PrintCmd.cc.

47  :
49 
50 }

Referenced by create().

◆ ~PrintCmd()

PrintCmd::~PrintCmd ( )
virtual

The Destructor.

Definition at line 56 of file PrintCmd.cc.

56  {
57 }

Member Function Documentation

◆ create()

PrintCmd * PrintCmd::create ( ) const
virtual

Creates and returns a new instance of this command.

Returns
Newly created instance of this command.

Implements GUICommand.

Definition at line 131 of file PrintCmd.cc.

131  {
132  return new PrintCmd();
133 }

References PrintCmd().

Here is the call graph for this function:

◆ Do()

bool PrintCmd::Do ( )
virtual

Executes the command.

If the wxWidgets printing framework was not compiled in the wxWidgets library, printing is not possible. An error message will be displayed instead of printing.

Returns
Always false. The command is not undoable.

Implements GUICommand.

Definition at line 70 of file PrintCmd.cc.

70  {
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 }

References GUICommand::parentWindow(), and EditorCommand::view().

Here is the call graph for this function:

◆ icon()

string PrintCmd::icon ( ) const
virtual

Returns path to the command's icon file.

Returns
Full path to the command's icon file.

Reimplemented from EditorCommand.

Definition at line 142 of file PrintCmd.cc.

142  {
144 }

References ProDeConstants::CMD_ICON_PRINT.

◆ id()

int PrintCmd::id ( ) const
virtual

Return id of this command.

Returns
ID for this command to be used in menus and toolbars.

Implements GUICommand.

Definition at line 120 of file PrintCmd.cc.

120  {
122 }

References ProDeConstants::COMMAND_PRINT.

◆ isEnabled()

bool PrintCmd::isEnabled ( )
virtual

Returns true when command is executable, false when not.

This command is executable when a document is open.

Returns
True, if the command is executable.

Reimplemented from EditorCommand.

Definition at line 155 of file PrintCmd.cc.

155  {
156  wxDocManager* manager = wxGetApp().docManager();
157  if (manager->GetCurrentView() != NULL) {
158  return true;
159  }
160  return false;
161 }

The documentation for this class was generated from the following files:
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
ProDeConstants::CMD_NAME_PRINT
static const std::string CMD_NAME_PRINT
Command name for the "Print" command.
Definition: ProDeConstants.hh:84
EditorCommand::EditorCommand
EditorCommand(std::string name, wxWindow *parent=NULL)
Definition: EditorCommand.cc:42
ErrorDialog
Definition: ErrorDialog.hh:42
EditorCommand::view
wxView * view() const
Definition: EditorCommand.cc:76
GUICommand::parentWindow
wxWindow * parentWindow() const
Definition: GUICommand.cc:75