OpenASIP  2.0
ConsoleWindow.hh
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 ConsoleWindow.hh
26  *
27  * Declaration of ConsoleWindow class.
28  *
29  * @author Veli-Pekka Jääskeläinen 2005 (vjaaskel-no.spam-cs.tut.fi)
30  * @note rating: red
31  */
32 
33 #ifndef CONSOLE_WINDOW_HH
34 #define CONSOLE_WINDOW_HH
35 
36 #include <wx/wx.h>
37 #include <string>
38 #include "SimulatorEvent.hh"
39 #include "ProximSimulatorWindow.hh"
40 
41 class ProximLineReader;
42 class ProximMainFrame;
43 
44 /**
45  * Simulator console window class.
46  *
47  * ConsoleWindow is a console with a multiline textual output window,
48  * and a singleline textual input widget. Commands are requested from
49  * the console window using SimulatorEvents.
50  */
52 public:
53  ConsoleWindow(ProximMainFrame* parent, wxWindowID id);
54  virtual ~ConsoleWindow();
55  virtual void reset();
56  void write(std::string text);
57  void clear();
58 
59 private:
60  virtual void onSimulatorBusy(SimulatorEvent& event);
61  virtual void onSimulatorDone(SimulatorEvent& event);
62 
63  void createContents();
64  void onSimulatorOutput(const SimulatorEvent& event);
65  void onError(const SimulatorEvent& event);
66  void textEntered(wxCommandEvent& event);
67  void onInputKey(wxKeyEvent& event);
68  /// Output text control.
69  wxTextCtrl* outTextCtrl_;
70  /// Input text control.
71  wxTextCtrl* inTextCtrl_;
72  /// Linereader to send the user input to.
74  /// Stores the command history iterator, used for command history browsing.
76 
77  /// IDs for the window widgets.
78  enum {
79  ID_INPUT = 20000,
81  };
82 
83  /**
84  * Text input widget for the console.
85  *
86  * This derived wxTextCtrl passes all key events through the parent
87  * console's key event handler. Event passing makes it possible to hook
88  * special keys such as browsing command history with up/down arrow keys.
89  */
90  class ConsoleWindowInputCtrl : public wxTextCtrl {
91  public:
94  private:
95  void onKeyDown(wxKeyEvent& event);
96  /// Parent console of the widget.
98 
99  DECLARE_EVENT_TABLE()
100  };
101 
102  DECLARE_EVENT_TABLE()
103 
104 };
105 
106 #endif
ProximMainFrame
Definition: ProximMainFrame.hh:58
ConsoleWindow::~ConsoleWindow
virtual ~ConsoleWindow()
Definition: ConsoleWindow.cc:117
ConsoleWindow::reset
virtual void reset()
Definition: ConsoleWindow.cc:124
ConsoleWindow::onSimulatorBusy
virtual void onSimulatorBusy(SimulatorEvent &event)
Definition: ConsoleWindow.cc:281
ProximSimulatorWindow.hh
ConsoleWindow::lineReader_
ProximLineReader * lineReader_
Linereader to send the user input to.
Definition: ConsoleWindow.hh:73
ConsoleWindow::clear
void clear()
Definition: ConsoleWindow.cc:269
SimulatorEvent.hh
ConsoleWindow::ID_OUTPUT
@ ID_OUTPUT
Definition: ConsoleWindow.hh:80
ConsoleWindow::ConsoleWindowInputCtrl::console_
ConsoleWindow * console_
Parent console of the widget.
Definition: ConsoleWindow.hh:97
ConsoleWindow::onSimulatorDone
virtual void onSimulatorDone(SimulatorEvent &event)
Definition: ConsoleWindow.cc:293
ConsoleWindow::ID_INPUT
@ ID_INPUT
Definition: ConsoleWindow.hh:79
ProximSimulatorWindow
Definition: ProximSimulatorWindow.hh:47
ConsoleWindow::ConsoleWindowInputCtrl::~ConsoleWindowInputCtrl
virtual ~ConsoleWindowInputCtrl()
Definition: ConsoleWindow.hh:93
ConsoleWindow::ConsoleWindowInputCtrl::ConsoleWindowInputCtrl
ConsoleWindowInputCtrl(ConsoleWindow *console)
Definition: ConsoleWindow.cc:66
ConsoleWindow::onInputKey
void onInputKey(wxKeyEvent &event)
Definition: ConsoleWindow.cc:226
ProximLineReader
Definition: ProximLineReader.hh:60
ConsoleWindow::onSimulatorOutput
void onSimulatorOutput(const SimulatorEvent &event)
Definition: ConsoleWindow.cc:195
ConsoleWindow::historyIterator_
int historyIterator_
Stores the command history iterator, used for command history browsing.
Definition: ConsoleWindow.hh:75
ConsoleWindow::inTextCtrl_
wxTextCtrl * inTextCtrl_
Input text control.
Definition: ConsoleWindow.hh:71
ConsoleWindow::ConsoleWindowInputCtrl
Definition: ConsoleWindow.hh:90
ConsoleWindow::outTextCtrl_
wxTextCtrl * outTextCtrl_
Output text control.
Definition: ConsoleWindow.hh:69
ConsoleWindow::textEntered
void textEntered(wxCommandEvent &event)
Definition: ConsoleWindow.cc:135
ConsoleWindow::onError
void onError(const SimulatorEvent &event)
Definition: ConsoleWindow.cc:211
ConsoleWindow::ConsoleWindowInputCtrl::onKeyDown
void onKeyDown(wxKeyEvent &event)
Definition: ConsoleWindow.cc:83
SimulatorEvent
Definition: SimulatorEvent.hh:42
ConsoleWindow::write
void write(std::string text)
Definition: ConsoleWindow.cc:150
ConsoleWindow::ConsoleWindow
ConsoleWindow(ProximMainFrame *parent, wxWindowID id)
Definition: ConsoleWindow.cc:101
ConsoleWindow::createContents
void createContents()
Definition: ConsoleWindow.cc:164
ConsoleWindow
Definition: ConsoleWindow.hh:51