Reference Manual

Main Page | Namespace List | Class Hierarchy | Alphabetical List | Compound List | File List | Namespace Members | Compound Members | File Members

# textbuffer.h

Go to the documentation of this file.

    00001 /*  Inti: Integrated Foundation Classes
    00002  *  Copyright (C) 2002-2003 The Inti Development Team.
    00003  *  Copyright (C) 2000 Red Hat, Inc.
    00004  *
    00005  *  This program is free software; you can redistribute it and/or modify
    00006  *  it under the terms of the GNU General Public License as published by
    00007  *  the Free Software Foundation; either version 2 of the License, or
    00008  *  (at your option) any later version.
    00009  *
    00010  *  This program is distributed in the hope that it will be useful,
    00011  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
    00012  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    00013  *  GNU Library General Public License for more details.
    00014  *
    00015  *  You should have received a copy of the GNU Library General Public License
    00016  *  along with this program; if not, write to the Free Software
    00017  *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
    00018  */
    00019
    00026
    00027 #ifndef INTI_GTK_TEXT_BUFFER_H
    00028 #define INTI_GTK_TEXT_BUFFER_H
    00029
    00030 #ifndef INTI_G_OBJECT_H
    00031 #include <inti/glib/object.h>
    00032 #endif
    00033
    00034 #ifndef INTI_GTK_TEXT_ITER_H
    00035 #include <inti/gtk/textiter.h>
    00036 #endif
    00037
    00038 #ifndef INTI_GTK_TEXT_TAG_H
    00039 #include <inti/gtk/texttag.h>
    00040 #endif
    00041
    00042 #ifndef GTK_TEXT_BUFFER_H
    00043 #include <gtk/gtktextbuffer.h>
    00044 #endif
    00045
    00046 #ifndef _CPP_VECTOR
    00047 #include <vector>
    00048 #endif
    00049
    00050 namespace Inti {
    00051
    00052 namespace Gdk {
    00053 class Pixbuf;
    00054 }
    00055
    00056 namespace Gtk {
    00057
    00058 class Clipboard;
    00059 class TextBufferClass;
    00060 class TextChildAnchorClass;
    00061 class TextMarkClass;
    00062 class Widget;
    00063
    00084
    00085 class TextMark : public G::Object
    00086 {
    00087         friend class G::Object;
    00088         friend class TextMarkClass;
    00089
    00090         TextMark(const TextMark&);
    00091         TextMark& operator=(const TextMark&);
    00092
    00093 protected:
    00096
    00097         explicit TextMark(GtkTextMark *mark, bool reference = false);
    00104
    00106
    00107 public:
    00110
    00111         virtual ~TextMark();
    00113
    00117
    00118         GtkTextMark* gtk_text_mark() const { return (GtkTextMark*)instance; }
    00120
    00121         GtkTextMarkClass* gtk_text_mark_class() const;
    00123
    00124         operator GtkTextMark* () const;
    00126
    00127         bool get_visible() const;
    00129
    00130         String get_name() const;
    00132
    00133         bool get_deleted() const;
    00136
    00137         TextBuffer* get_buffer() const;
    00139
    00140         bool get_left_gravity() const;
    00142
    00146
    00147         void set_visible(bool setting);
    00155
    00157 };
    00158
    00165
    00166 class TextChildAnchor : public G::Object
    00167 {
    00168         friend class G::Object;
    00169         friend class TextChildAnchorClass;
    00170
    00171         TextChildAnchor(const TextChildAnchor&);
    00172         TextChildAnchor& operator=(const TextChildAnchor&);
    00173
    00174 protected:
    00177
    00178         explicit TextChildAnchor(GtkTextChildAnchor *anchor, bool reference = true);
    00185
    00187
    00188 public:
    00191
    00192         TextChildAnchor();
    00197
    00198         virtual ~TextChildAnchor();
    00200
    00204
    00205         GtkTextChildAnchor* gtk_text_child_anchor() const { return (GtkTextChildAnchor*)instance; }
    00207
    00208         GtkTextChildAnchorClass* gtk_text_child_anchor_class() const;
    00210
    00211         operator GtkTextChildAnchor* () const;
    00213
    00214         bool get_widgets(std::vector<Widget*>& widgets) const;
    00218
    00219         bool get_deleted() const;
    00226
    00228 };
    00229
    00261
    00262 class TextBuffer : public G::Object
    00263 {
    00264         friend class G::Object;
    00265         friend class TextBufferClass;
    00266
    00267         TextBuffer(const TextBuffer&);
    00268         TextBuffer& operator=(const TextBuffer&);
    00269
    00270 protected:
    00273
    00274         explicit TextBuffer(GtkTextBuffer *buffer, bool reference = true);
    00281
    00285
    00286         virtual void on_insert_text(TextIter& pos, const String& text);
    00288
    00289         virtual void on_insert_pixbuf(TextIter& pos, Gdk::Pixbuf& pixbuf);
    00291
    00292         virtual void on_insert_child_anchor(TextIter& pos, TextChildAnchor& anchor);
    00294
    00295         virtual void on_delete_range(TextIter& start, TextIter& end);
    00298
    00299         virtual void on_changed();
    00301
    00302         virtual void on_modified_changed();
    00304
    00305         virtual void on_mark_set(const TextIter& location, TextMark& mark);
    00307
    00308         virtual void on_mark_deleted(TextMark& mark);
    00310
    00311         virtual void on_apply_tag(TextTag& tag, const TextIter& start_char, const TextIter& end_char);
    00314
    00315         virtual void on_remove_tag(TextTag& tag, const TextIter& start_char, const TextIter& end_char);
    00318
    00319         virtual void on_begin_user_action();
    00322
    00323         virtual void on_end_user_action();
    00325
    00327 //  Properties
    00328
    00329         typedef G::Property<TextTagTable*, G::Object*> TagTablePropertyType;
    00330         typedef G::PropertyProxy<G::Object, TagTablePropertyType> TagTablePropertyProxy;
    00331         static const TagTablePropertyType tag_table_property;
    00332
    00333 //  Signals
    00334
    00335         typedef G::Signal3<void, GtkTextIter*, const char*, int> InsertTextSignalType;
    00336         typedef G::SignalProxy<TypeInstance, InsertTextSignalType> InsertTextSignalProxy;
    00337         static const InsertTextSignalType insert_text_signal;
    00338
    00339         typedef G::Signal2<void, GtkTextIter*, GdkPixbuf*> InsertPixbufSignalType;
    00340         typedef G::SignalProxy<TypeInstance, InsertPixbufSignalType> InsertPixbufSignalProxy;
    00341         static const InsertPixbufSignalType insert_pixbuf_signal;
    00342
    00343         typedef G::Signal2<void, GtkTextIter*, GtkTextChildAnchor*> InsertChildAnchorSignalType;
    00344         typedef G::SignalProxy<TypeInstance, InsertChildAnchorSignalType> InsertChildAnchorSignalProxy;
    00345         static const InsertChildAnchorSignalType insert_child_anchor_signal;
    00346
    00347         typedef G::Signal2<void, GtkTextIter*, GtkTextIter*> DeleteRangeSignalType;
    00348         typedef G::SignalProxy<TypeInstance, DeleteRangeSignalType> DeleteRangeSignalProxy;
    00349         static const DeleteRangeSignalType delete_range_signal;
    00350
    00351         typedef G::Signal0<void> ChangedSignalType;
    00352         typedef G::SignalProxy<TypeInstance, ChangedSignalType> ChangedSignalProxy;
    00353         static const ChangedSignalType changed_signal;
    00354
    00355         typedef G::Signal0<void> ModifiedChangedSignalType;
    00356         typedef G::SignalProxy<TypeInstance, ModifiedChangedSignalType> ModifiedChangedSignalProxy;
    00357         static const ModifiedChangedSignalType modified_changed_signal;
    00358
    00359         typedef G::Signal2<void, const GtkTextIter*, GtkTextMark*> MarkSetSignalType;
    00360         typedef G::SignalProxy<TypeInstance, MarkSetSignalType> MarkSetSignalProxy;
    00361         static const MarkSetSignalType mark_set_signal;
    00362
    00363         typedef G::Signal1<void, GtkTextMark*> MarkDeletedSignalType;
    00364         typedef G::SignalProxy<TypeInstance, MarkDeletedSignalType> MarkDeletedSignalProxy;
    00365         static const MarkDeletedSignalType mark_deleted_signal;
    00366
    00367         typedef G::Signal3<void, GtkTextTag*, const GtkTextIter*, const GtkTextIter*> ApplyTagSignalType;
    00368         typedef G::SignalProxy<TypeInstance, ApplyTagSignalType> ApplyTagSignalProxy;
    00369         static const ApplyTagSignalType apply_tag_signal;
    00370
    00371         typedef G::Signal3<void, GtkTextTag*, const GtkTextIter*, const GtkTextIter*> RemoveTagSignalType;
    00372         typedef G::SignalProxy<TypeInstance, RemoveTagSignalType> RemoveTagSignalProxy;
    00373         static const RemoveTagSignalType remove_tag_signal;
    00374
    00375         typedef G::Signal0<void> BeginUserActionSignalType;
    00376         typedef G::SignalProxy<TypeInstance, BeginUserActionSignalType> BeginUserActionSignalProxy;
    00377         static const BeginUserActionSignalType begin_user_action_signal;
    00378
    00379         typedef G::Signal0<void> EndUserActionSignalType;
    00380         typedef G::SignalProxy<TypeInstance, EndUserActionSignalType> EndUserActionSignalProxy;
    00381         static const EndUserActionSignalType end_user_action_signal;
    00382
    00383 public:
    00386
    00387         explicit TextBuffer(TextTagTable *table = 0);
    00390
    00391         virtual ~TextBuffer();
    00393
    00397
    00398         GtkTextBuffer* gtk_text_buffer() const { return (GtkTextBuffer*)instance; }
    00400
    00401         GtkTextBufferClass* gtk_text_buffer_class() const;
    00403
    00404         operator GtkTextBuffer* () const;
    00406
    00407         int get_line_count() const;
    00412
    00413         int get_char_count() const;
    00420
    00421         TextTagTable* get_tag_table() const;
    00424
    00425         String get_text(const TextIter& start, const TextIter& end, bool include_hidden_chars = false) const;
    00436
    00437         String get_slice(const TextIter& start, const TextIter& end, bool include_hidden_chars = false) const;
    00450
    00451         TextMark* get_mark(const String& name) const;
    00455
    00456         TextMark* get_insert() const;
    00462
    00463         TextMark* get_selection_bound() const;
    00473
    00474         TextIter get_iter_at_line_offset(int line_number, int char_offset) const;
    00482
    00483         TextIter get_iter_at_line_index(int line_number, int byte_index) const;
    00492
    00493         TextIter get_iter_at_offset(int char_offset) const;
    00502
    00503         TextIter get_iter_at_line(int line_number) const;
    00507
    00508         TextIter get_start_iter() const;
    00513
    00514         TextIter get_end_iter() const;
    00521
    00522         void get_bounds(TextIter& start, TextIter& end) const;
    00527
    00528         TextIter get_iter_at_mark(TextMark& mark) const;
    00532
    00533         TextIter get_iter_at_child_anchor(TextChildAnchor& anchor) const;
    00537
    00538         bool get_modified() const;
    00544
    00545         bool get_selection_bounds(TextIter *start = 0, TextIter *end = 0) const;
    00555
    00559
    00560         void begin_user_action();
    00574
    00575         void end_user_action();
    00577
    00578         void set_text(const String& text);
    00581
    00582         void set_text(const char *text, int length = -1);
    00586
    00587         void insert(TextIter& iter, const String& text);
    00596
    00597         void insert(TextIter& iter, const char *text, int length = -1);
    00608
    00609         void insert_at_cursor(const String& text);
    00612
    00613         void insert_at_cursor(const char *text, int length = -1);
    00617
    00618         bool insert_interactive(TextIter& iter, const String& text, bool default_editable);
    00630
    00631         bool insert_interactive(TextIter& iter, const char *text, int length, bool default_editable);
    00644
    00645         bool insert_interactive_at_cursor(const String& text, bool default_editable);
    00654
    00655         bool insert_interactive_at_cursor(const char *text, int length, bool default_editable);
    00665
    00666         void insert_range(TextIter& iter, const TextIter& start, const TextIter& end);
    00677
    00678         bool insert_range_interactive(TextIter& iter, const TextIter& start, const TextIter& end, bool default_editable);
    00689
    00690         void insert_with_tag(TextIter& iter, const String& text, TextTag&tag);
    00698
    00699         void insert_with_tag(TextIter& iter, const char *text, int length, TextTag& tag);
    00708
    00709         void insert_with_tags(TextIter& iter, const String& text, TextTag *first_tag, ...);
    00718
    00719         void insert_with_tags(TextIter& iter, const char *text, int length, TextTag *first_tag, ...);
    00729
    00730         void insert_with_tag_by_name(TextIter& iter, const String& text, const char *tag_name);
    00735
    00736         void insert_with_tag_by_name(TextIter& iter, const char *text, int length, const char *tag_name);
    00742
    00743         void insert_with_tags_by_name(TextIter& iter, const String& text, const char *first_tag_name, ...);
    00749
    00750         void insert_with_tags_by_name(TextIter& iter, const char *text, int length, const char *first_tag_name, ...);
    00757
    00758         void delete_range(TextIter& start, TextIter& end);
    00768
    00769         bool delete_range_interactive(TextIter& start, TextIter& end, bool default_editable);
    00779
    00780         void insert_pixbuf(TextIter& iter, Gdk::Pixbuf& pixbuf);
    00790
    00791         void insert_child_anchor(TextIter& iter, TextChildAnchor& anchor);
    00803
    00804         TextChildAnchor* create_child_anchor(TextIter& iter);
    00812
    00813         TextMark* create_mark(const String& mark_name, const TextIter& where, bool left_gravity);
    00830
    00831         void move_mark(TextMark& mark, const TextIter& where);
    00837
    00838         void move_mark_by_name(const String& name, const TextIter& where);
    00843
    00844         void delete_mark(TextMark& mark);
    00854
    00855         void delete_mark_by_name(const String& name);
    00858
    00859         void place_cursor(const TextIter& where);
    00867
    00868         void apply_tag(TextTag& tag, const TextIter& start, const TextIter& end);
    00876
    00877         void apply_tag_by_name(const String& name, const TextIter& start, const TextIter& end);
    00883
    00884         void remove_tag(TextTag& tag, const TextIter& start, const TextIter& end);
    00892
    00893         void remove_tag_by_name(const String& name, const TextIter& start, const TextIter& end);
    00899
    00900         void remove_all_tags(const TextIter& start, const TextIter& end);
    00908
    00909         TextTag* create_tag(const String& tag_name, const char *first_property_name, ...);
    00922
    00923         void set_modified(bool setting);
    00930
    00931         void add_selection_clipboard(Clipboard& clipboard);
    00938
    00939         void remove_selection_clipboard(Clipboard& clipboard);
    00942
    00943         void cut_clipboard(Clipboard& clipboard, bool default_editable);
    00947
    00948         void copy_clipboard(Clipboard& clipboard);
    00951
    00952         void paste_clipboard(Clipboard& clipboard, TextIter *override_location, bool default_editable);
    00960
    00961         bool delete_selection(bool interactive, bool default_editable);
    00970
    00974
    00975         const TagTablePropertyProxy prop_tag_table()
    00976         {
    00977                 return TagTablePropertyProxy(this, &tag_table_property);
    00978         }
    00980
    00984
    00985         const InsertTextSignalProxy sig_insert_text()
    00986         {
    00987                 return InsertTextSignalProxy(this, &insert_text_signal);
    00988         }
    00990
    00991         const InsertPixbufSignalProxy sig_insert_pixbuf()
    00992         {
    00993                 return InsertPixbufSignalProxy(this, &insert_pixbuf_signal);
    00994         }
    00996
    00997         const InsertChildAnchorSignalProxy sig_insert_child_anchor()
    00998         {
    00999                 return InsertChildAnchorSignalProxy(this, &insert_child_anchor_signal);
    01000         }
    01002
    01003         const DeleteRangeSignalProxy sig_delete_range()
    01004         {
    01005                 return DeleteRangeSignalProxy(this, &delete_range_signal);
    01006         }
    01009
    01010         const ChangedSignalProxy sig_changed()
    01011         {
    01012                 return ChangedSignalProxy(this, &changed_signal);
    01013         }
    01016
    01017         const ModifiedChangedSignalProxy sig_modified_changed()
    01018         {
    01019                 return ModifiedChangedSignalProxy(this, &modified_changed_signal);
    01020         }
    01023
    01024         const MarkSetSignalProxy sig_mark_set()
    01025         {
    01026                 return MarkSetSignalProxy(this, &mark_set_signal);
    01027         }
    01029
    01030         const MarkDeletedSignalProxy sig_mark_deleted()
    01031         {
    01032                 return MarkDeletedSignalProxy(this, &mark_deleted_signal);
    01033         }
    01035
    01036         const ApplyTagSignalProxy sig_apply_tag()
    01037         {
    01038                 return ApplyTagSignalProxy(this, &apply_tag_signal);
    01039         }
    01042
    01043         const RemoveTagSignalProxy sig_remove_tag()
    01044         {
    01045                 return RemoveTagSignalProxy(this, &remove_tag_signal);
    01046         }
    01049
    01050         const BeginUserActionSignalProxy sig_begin_user_action()
    01051         {
    01052                 return BeginUserActionSignalProxy(this, &begin_user_action_signal);
    01053         }
    01056
    01057         const EndUserActionSignalProxy sig_end_user_action()
    01058         {
    01059                 return EndUserActionSignalProxy(this, &end_user_action_signal);
    01060         }
    01063
    01065 };
    01066
    01067 } // namespace Gtk
    01068
    01069 } // namespace Inti
    01070
    01071 #endif // INTI_GTK_TEXT_BUFFER_H
    01072

Main Page - Footer