2006-01-27 18:57:53 +01:00
|
|
|
// src/graphicalterminalio.hh - Copyright 2005, 2006, University
|
2006-01-27 16:04:06 +01:00
|
|
|
// of Padova, dept. of Pure and Applied
|
|
|
|
// Mathematics
|
|
|
|
//
|
|
|
|
// This file is part of SGPEMv2.
|
|
|
|
//
|
|
|
|
// This 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.
|
|
|
|
//
|
|
|
|
// SGPEMv2 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 SGPEMv2; if not, write to the Free Software
|
|
|
|
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
|
2006-01-27 18:57:53 +01:00
|
|
|
#ifndef GRAPHICALTERMINALIO_HH
|
|
|
|
#define GRAPHICALTERMINALIO_HH 1
|
2006-01-27 16:04:06 +01:00
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
#include "gettext.h"
|
|
|
|
|
|
|
|
#include <gtkmm/box.h>
|
2006-02-01 23:56:29 +01:00
|
|
|
#include <gtkmm/entry.h>
|
2006-01-27 16:04:06 +01:00
|
|
|
#include <gtkmm/textview.h>
|
2006-02-10 21:44:48 +01:00
|
|
|
#include <gtkmm/window.h>
|
2006-01-27 16:04:06 +01:00
|
|
|
#include <glibmm/ustring.h>
|
|
|
|
|
2006-02-22 23:45:06 +01:00
|
|
|
#include "text_simulation.hh"
|
|
|
|
|
2006-02-09 20:43:24 +01:00
|
|
|
#include "io_manager.hh"
|
2006-01-27 16:04:06 +01:00
|
|
|
|
2006-02-09 20:33:35 +01:00
|
|
|
namespace sgpem {
|
2006-01-27 16:04:06 +01:00
|
|
|
|
2006-02-09 20:33:35 +01:00
|
|
|
// ---------------------------------------------
|
|
|
|
|
|
|
|
class GraphicalTerminalIO;
|
|
|
|
|
|
|
|
// ---------------------------------------------
|
|
|
|
|
2006-02-24 14:19:27 +01:00
|
|
|
/** \brief Class GraphicalTerminalIO implements the methods requested
|
|
|
|
by IOManager using graphichal widgets.
|
|
|
|
Consists in a window displaying some textual output and providing a control for text input.
|
|
|
|
It is associated with a TextSimulaton, which provide the interpretation and elaboration of the user
|
|
|
|
commands.
|
|
|
|
*/
|
2006-02-10 21:44:48 +01:00
|
|
|
class GraphicalTerminalIO : public IOManager, public Gtk::Window
|
2006-02-09 20:33:35 +01:00
|
|
|
{
|
2006-02-15 23:58:18 +01:00
|
|
|
|
2006-02-09 20:33:35 +01:00
|
|
|
public:
|
2006-02-24 14:19:27 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
Creates a GraphichalTerminalIO supported by the specified TextSimulation.
|
|
|
|
\param sim the TextSimulation that will support this IOManager.
|
|
|
|
*/
|
|
|
|
GraphicalTerminalIO(TextSimulation* sim);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Destructor.
|
|
|
|
*/
|
2006-02-22 23:45:06 +01:00
|
|
|
virtual ~GraphicalTerminalIO();
|
2006-02-09 20:33:35 +01:00
|
|
|
|
2006-02-24 14:19:27 +01:00
|
|
|
/**
|
|
|
|
Prints on the window the provided buffer.
|
|
|
|
\param buffer the buffer to print.
|
|
|
|
*/
|
|
|
|
virtual uint write_buffer(const Glib::ustring& buffer);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Reads the user input.
|
|
|
|
\return the user input.
|
|
|
|
*/
|
|
|
|
virtual Glib::ustring read_command();
|
|
|
|
|
|
|
|
/**
|
|
|
|
Returns whether the IOManager can read user input while performing a write operation.
|
|
|
|
\return whether the IOManager can read user input while performing a write operation.
|
|
|
|
*/
|
2006-02-17 23:19:25 +01:00
|
|
|
virtual bool is_full_duplex();
|
2006-02-24 14:19:27 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
Specifies the operations to perform at user input.
|
|
|
|
*/
|
2006-02-22 23:45:06 +01:00
|
|
|
void onSend();
|
2006-02-17 23:19:25 +01:00
|
|
|
|
2006-02-09 20:33:35 +01:00
|
|
|
private:
|
2006-02-23 13:50:19 +01:00
|
|
|
bool _on_input_commit(GdkEventKey* event);
|
|
|
|
|
2006-02-23 13:12:43 +01:00
|
|
|
TextSimulation* _sim;
|
|
|
|
Gtk::TextView _text_output;
|
|
|
|
mutable Gtk::Entry _text_input;
|
|
|
|
Gtk::Button* _send;
|
2006-02-09 20:33:35 +01:00
|
|
|
};
|
2006-01-27 16:04:06 +01:00
|
|
|
|
2006-02-09 20:33:35 +01:00
|
|
|
}
|
2006-01-27 16:04:06 +01:00
|
|
|
|
|
|
|
#endif
|
2006-02-19 23:36:24 +01:00
|
|
|
|