diff options
| author | Greg Ercolano <erco@seriss.com> | 2010-12-09 20:26:00 +0000 |
|---|---|---|
| committer | Greg Ercolano <erco@seriss.com> | 2010-12-09 20:26:00 +0000 |
| commit | 5ca2671de8b1460f25d2c725d457c0fec5cb153e (patch) | |
| tree | cb5f16c8b9a6eb91c603915d3bac91ab6b1c8b64 | |
| parent | 60764e05ca6b5a83eaa88260046ebedcc62f7277 (diff) | |
Added texteditor-simple example program.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@7991 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
| -rw-r--r-- | examples/Makefile | 1 | ||||
| -rw-r--r-- | examples/texteditor-simple.cxx | 62 |
2 files changed, 63 insertions, 0 deletions
diff --git a/examples/Makefile b/examples/Makefile index 383377b28..013770c45 100644 --- a/examples/Makefile +++ b/examples/Makefile @@ -9,6 +9,7 @@ ALL = howto-add_fd-and-popen$(EXEEXT) \ table-sort$(EXEEXT) \ table-with-keyboard-nav$(EXEEXT) \ tabs-simple$(EXEEXT) \ + texteditor-simple$(EXEEXT) \ tree-simple$(EXEEXT) \ wizard-simple$(EXEEXT) diff --git a/examples/texteditor-simple.cxx b/examples/texteditor-simple.cxx new file mode 100644 index 000000000..3556cba24 --- /dev/null +++ b/examples/texteditor-simple.cxx @@ -0,0 +1,62 @@ +// +// "$Id$" +// +// A simple example of Fl_Text_Editor +// +// Fl_Text_Editor is unlike other FLTK widgets in that +// to work correctly, it must be assigned to an instance of an +// Fl_Text_Buffer. The below shows using buffer() to connect +// the two classes together. +// +// Note that the example can also be used to demonstrate +// Fl_Text_Display; just replace all instances of +// Fl_Text_Editor with Fl_Text_Display and rebuild. +// +// Copyright 2010 Greg Ercolano. +// Copyright 1998-2010 by Bill Spitzak and others. +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Library General Public +// License as published by the Free Software Foundation; either +// version 2 of the License, or (at your option) any later version. +// +// This library 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 +// Library General Public License for more details. +// +// You should have received a copy of the GNU Library General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +// USA. +// +// Please report all bugs and problems on the following page: +// +// http://www.fltk.org/str.php +// + +#include <FL/Fl.H> +#include <FL/Fl_Double_Window.H> +#include <FL/Fl_Text_Editor.H> + +int main() { + Fl_Double_Window *win = new Fl_Double_Window(640, 480, "Simple Fl_Text_Editor"); + Fl_Text_Buffer *buff = new Fl_Text_Buffer(); + Fl_Text_Editor *edit = new Fl_Text_Editor(20, 20, 640-40, 480-40); + edit->buffer(buff); // attach the text buffer to our editor widget + win->resizable(*edit); + win->show(); + buff->text("line 0\nline 1\nline 2\n" + "line 3\nline 4\nline 5\n" + "line 6\nline 7\nline 8\n" + "line 9\nline 10\nline 11\n" + "line 12\nline 13\nline 14\n" + "line 15\nline 16\nline 17\n" + "line 18\nline 19\nline 20\n" + "line 21\nline 22\nline 23\n"); + return(Fl::run()); +} + +// +// End of "$Id$". +// |
