| 1 |
/* |
| 2 |
Copyright (C) 2002 Kai Sterker <[email protected]> |
| 3 |
Part of the Adonthell Project <http://adonthell.nongnu.org> |
| 4 |
|
| 5 |
Dlgedit is free software; you can redistribute it and/or modify |
| 6 |
it under the terms of the GNU General Public License as published by |
| 7 |
the Free Software Foundation; either version 2 of the License, or |
| 8 |
(at your option) any later version. |
| 9 |
|
| 10 |
Dlgedit is distributed in the hope that it will be useful, |
| 11 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 |
GNU General Public License for more details. |
| 14 |
|
| 15 |
You should have received a copy of the GNU General Public License |
| 16 |
along with Dlgedit. If not, see <http://www.gnu.org/licenses/>. |
| 17 |
*/ |
| 18 |
|
| 19 |
/** |
| 20 |
* @file gui_edit.h |
| 21 |
* |
| 22 |
* @author Kai Sterker |
| 23 |
* @brief Wrapper around the GtkText widget. |
| 24 |
*/ |
| 25 |
|
| 26 |
#include <string> |
| 27 |
#include <gtk/gtk.h> |
| 28 |
#include <gdk/gdk.h> |
| 29 |
|
| 30 |
/** |
| 31 |
* Provides a simple C++ interface to GtkText. The widget is initialised |
| 32 |
* to use a font with fixed width, so it should only be used to edit code. |
| 33 |
*/ |
| 34 |
class GuiEdit |
| 35 |
{ |
| 36 |
public: |
| 37 |
/** |
| 38 |
* Create a new GtkText widget. |
| 39 |
* @param container Container to put the editor widget into. |
| 40 |
*/ |
| 41 |
GuiEdit (GtkWidget *container); |
| 42 |
~GuiEdit (); |
| 43 |
|
| 44 |
/** |
| 45 |
* Get a pointer to the GtkText widget. |
| 46 |
* @return a pointer to the editor widget. |
| 47 |
*/ |
| 48 |
GtkWidget *widget () { return view; } |
| 49 |
|
| 50 |
/** |
| 51 |
* Set the text of the widget |
| 52 |
* @param text to display in the entry |
| 53 |
*/ |
| 54 |
void setText (const std::string &text); |
| 55 |
|
| 56 |
/** |
| 57 |
* Retrieve the text of the widget |
| 58 |
* @return text contained in the widget. |
| 59 |
*/ |
| 60 |
std::string getText (); |
| 61 |
|
| 62 |
private: |
| 63 |
GtkTextBuffer *entry; // The actual text buffer |
| 64 |
GtkWidget *view; // The widget to display the buffer |
| 65 |
}; |