Ardour  9.0-pre0-582-g084a23a80d
textiter.h
Go to the documentation of this file.
1 // -*- c++ -*-
2 // Generated by gmmproc 2.45.3 -- DO NOT MODIFY!
3 #ifndef _GTKMM_TEXTITER_H
4 #define _GTKMM_TEXTITER_H
5 
6 
7 #include <glibmm/ustring.h>
8 #include <sigc++/sigc++.h>
9 
10 /* $Id: textiter.hg,v 1.8 2006/05/11 11:40:24 murrayc Exp $ */
11 
12 /* Copyright(C) 1998-2002 The gtkmm Development Team
13  *
14  * This library is free software, ) you can redistribute it and/or
15  * modify it under the terms of the GNU Lesser General Public
16  * License as published by the Free Software Foundation, ) either
17  * version 2.1 of the License, or(at your option) any later version.
18  *
19  * This library is distributed in the hope that it will be useful,
20  * but WITHOUT ANY WARRANTY, ) without even the implied warranty of
21  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
22  * Lesser General Public License for more details.
23  *
24  * You should have received a copy of the GNU Lesser General Public
25  * License along with this library, ) if not, write to the Free
26  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
27  */
28 
29 #include <glibmm/exceptionhandler.h>
30 #include <glibmm/slisthandle.h>
31 #include <gdkmm/pixbuf.h>
32 #include <gtkmm/texttag.h>
33 #include <gtkmm/textchildanchor.h>
34 #include <gtkmm/textattributes.h>
35 
36 
37 namespace Gtk
38 {
39 
40 
56 {
58  TEXT_SEARCH_TEXT_ONLY = 1 << 1
59 };
60 
63  { return static_cast<TextSearchFlags>(static_cast<unsigned>(lhs) | static_cast<unsigned>(rhs)); }
64 
67  { return static_cast<TextSearchFlags>(static_cast<unsigned>(lhs) & static_cast<unsigned>(rhs)); }
68 
71  { return static_cast<TextSearchFlags>(static_cast<unsigned>(lhs) ^ static_cast<unsigned>(rhs)); }
72 
75  { return static_cast<TextSearchFlags>(~static_cast<unsigned>(flags)); }
76 
79  { return (lhs = static_cast<TextSearchFlags>(static_cast<unsigned>(lhs) | static_cast<unsigned>(rhs))); }
80 
83  { return (lhs = static_cast<TextSearchFlags>(static_cast<unsigned>(lhs) & static_cast<unsigned>(rhs))); }
84 
87  { return (lhs = static_cast<TextSearchFlags>(static_cast<unsigned>(lhs) ^ static_cast<unsigned>(rhs))); }
88 
89 } // namespace Gtk
90 
91 
92 #ifndef DOXYGEN_SHOULD_SKIP_THIS
93 namespace Glib
94 {
95 
96 template <>
97 class Value<Gtk::TextSearchFlags> : public Glib::Value_Flags<Gtk::TextSearchFlags>
98 {
99 public:
100  static GType value_type() G_GNUC_CONST;
101 };
102 
103 } // namespace Glib
104 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
105 
106 
107 namespace Gtk
108 {
109 
110 
111 class TextBuffer;
112 class TextMark;
113 
114 //TODO: Maybe we should have separate iterators for words, lines, and sentences.
129 class TextIter
130 {
131  public:
132 #ifndef DOXYGEN_SHOULD_SKIP_THIS
133  typedef TextIter CppObjectType;
134  typedef GtkTextIter BaseObjectType;
135 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
136 
139  static GType get_type() G_GNUC_CONST;
140 
142 
143  explicit TextIter(const GtkTextIter* gobject); // always takes a copy
144 
146  GtkTextIter* gobj() { return &gobject_; }
147 
149  const GtkTextIter* gobj() const { return &gobject_; }
150 
151 protected:
153 
154 private:
155 
156 
157 public:
158  typedef std::bidirectional_iterator_tag iterator_category;
159  typedef gunichar value_type;
160  typedef int difference_type;
162  typedef void pointer;
163 
165  inline TextIter& operator++();
166  inline const TextIter operator++(int);
167 
169  inline TextIter& operator--();
170  inline const TextIter operator--(int);
171 
173  inline value_type operator*() const;
174 
176  inline operator bool() const;
177 
178 #ifndef DOXYGEN_SHOULD_SKIP_THIS
179 
180 protected:
181  template <class Predicate>
182  struct PredicateAdapter
183  {
184  Predicate predicate_;
185  inline PredicateAdapter(const Predicate& predicate);
186  static gboolean gtk_callback(gunichar uc, void* user_data);
187  };
188 
189 
200  bool forward_find_char_impl(GtkTextCharPredicate predicate, void* user_data, const GtkTextIter* limit);
201 
202 
210  bool backward_find_char_impl(GtkTextCharPredicate predicate, void* user_data, const GtkTextIter* limit);
211 
212 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
213 
214 public:
215 
220  Glib::RefPtr<TextBuffer> get_buffer() const;
221 
222 
231  int get_offset() const;
232 
239  int get_line() const;
240 
247  int get_line_offset() const;
248 
257  int get_line_index() const;
258 
259 
268 
277 
278 
289  gunichar get_char() const;
290 
303  Glib::ustring get_slice(const TextIter& end) const;
304 
314  Glib::ustring get_text(const TextIter& end) const;
315 
323  Glib::ustring get_visible_slice(const TextIter& end) const;
324 
332  Glib::ustring get_visible_text(const TextIter& end) const;
333 
334 
341  Glib::RefPtr<Gdk::Pixbuf> get_pixbuf() const;
342 
351  Glib::SListHandle< Glib::RefPtr<TextMark> > get_marks();
352 
361  Glib::SListHandle< Glib::RefPtr<const TextMark> > get_marks() const;
362 
363 
370  Glib::RefPtr<TextChildAnchor> get_child_anchor();
371 
378  Glib::RefPtr<const TextChildAnchor> get_child_anchor() const;
379 
380 
391  Glib::SListHandle< Glib::RefPtr<TextTag> > get_toggled_tags(bool toggled_on = true);
392 
403  Glib::SListHandle< Glib::RefPtr<const TextTag> > get_toggled_tags(bool toggled_on = true) const;
404 
405 
416  bool begins_tag(const Glib::RefPtr<const TextTag>& tag) const;
417  bool begins_tag() const;
418 
429  bool ends_tag(const Glib::RefPtr<const TextTag>& tag) const;
430  bool ends_tag() const;
431 
439  bool toggles_tag(const Glib::RefPtr<const TextTag>& tag) const;
440  bool toggles_tag() const;
441 
442 
448  bool has_tag(const Glib::RefPtr<const TextTag>& tag) const;
449  bool has_tag() const;
450 
451 
457  Glib::SListHandle< Glib::RefPtr<TextTag> > get_tags();
458 
464  Glib::SListHandle< Glib::RefPtr<const TextTag> > get_tags() const;
465 
466 
483  bool editable(bool default_setting = true) const;
484 
495  bool can_insert(bool default_editability = true) const;
496 
497 
505  bool starts_word() const;
506 
514  bool ends_word() const;
515 
523  bool inside_word() const;
524 
532  bool starts_sentence() const;
533 
541  bool ends_sentence() const;
542 
551  bool inside_sentence() const;
552 
561  bool starts_line() const;
562 
574  bool ends_line() const;
575 
581  bool is_cursor_position() const;
582 
583 
589  int get_chars_in_line() const;
590 
596  int get_bytes_in_line() const;
597 
598  bool get_attributes(TextAttributes& values) const;
599 
607  Pango::Language get_language() const;
608 
616  bool is_end() const;
617 
623  bool is_start() const;
624 
625 
636  bool forward_char();
637 
646 
657  bool forward_chars(int count);
658 
669  bool backward_chars(int count);
670 
678  bool forward_line();
679 
691 
703  bool forward_lines(int count);
704 
716  bool backward_lines(int count);
717 
727 
737 
743  bool forward_word_ends(int count);
744 
750  bool backward_word_starts(int count);
751 
752 
761 
773 
785  bool forward_visible_line(int count);
786 
798  bool backward_visible_lines(int count);
799 
800  //TODO: Now that there are so many *_visible_ versions of the methods, maybe we should
801  //just add a visible=false parameter and therefore halve the number of methods. murrayc
802 
803 
813 
823 
829  bool forward_visible_word_ends(int count);
830 
837 
838 
848 
858 
866  bool forward_sentence_ends(int count);
867 
875  bool backward_sentence_starts(int count);
876 
877 
892 
898 
905  bool forward_cursor_positions(int count);
906 
913  bool backward_cursor_positions(int count);
914 
915 
922 
929 
937 
945 
946 
952  void set_offset(int char_offset);
953 
960  void set_line(int line_number);
961 
971  void set_line_offset(int char_on_line);
972 
980  void set_line_index(int byte_on_line);
981 
987 
1000 
1001 
1008  void set_visible_line_offset(int char_on_line);
1009 
1016  void set_visible_line_index(int byte_on_line);
1017 
1018 
1030  bool forward_to_tag_toggle(const Glib::RefPtr<TextTag>& tag);
1031 
1043  bool backward_to_tag_toggle(const Glib::RefPtr<TextTag>& tag);
1044 
1045  template <class Predicate> bool forward_find_char(const Predicate& predicate, const TextIter& limit);
1046  template <class Predicate> bool forward_find_char(const Predicate& predicate);
1047  template <class Predicate> bool backward_find_char(const Predicate& predicate, const TextIter& limit);
1048  template <class Predicate> bool backward_find_char(const Predicate& predicate);
1049 
1050 
1073  bool forward_search(const Glib::ustring& str, TextSearchFlags flags, TextIter& match_start, TextIter& match_end, const TextIter& limit) const;
1074 
1083  bool forward_search(const Glib::ustring& str, TextSearchFlags flags, TextIter& match_start, TextIter& match_end) const;
1084 
1085 
1095  bool backward_search(const Glib::ustring& str, TextSearchFlags flags, TextIter& match_start, TextIter& match_end, const TextIter& limit) const;
1096 
1104  bool backward_search(const Glib::ustring& str, TextSearchFlags flags, TextIter& match_start, TextIter& match_end) const;
1105 
1106 
1115  int compare(const TextIter& rhs) const;
1116 
1124  bool in_range(const TextIter& start, const TextIter& end) const;
1125 
1135  void order(TextIter& second);
1136 
1137 
1138 };
1139 
1140 
1141 #ifndef DOXYGEN_SHOULD_SKIP_THIS
1142 
1143 template <class Predicate> inline
1144 TextIter::PredicateAdapter<Predicate>::PredicateAdapter(const Predicate& predicate)
1145 :
1146  predicate_ (predicate)
1147 {}
1148 
1149 // static
1150 template <class Predicate>
1151 gboolean TextIter::PredicateAdapter<Predicate>::gtk_callback(gunichar uc, void* user_data)
1152 {
1153  try
1154  {
1155  // This will either use Predicate::operator(), or call a function pointer.
1156  // The explicit conditional expression avoids relying on an implicit
1157  // conversion of the return type to int, which might be not available.
1158  return (static_cast<TextIter::PredicateAdapter<Predicate>*>(user_data)->predicate_(uc)) ? 1 : 0;
1159  }
1160  catch(...)
1161  {
1162  Glib::exception_handlers_invoke();
1163  return 0;
1164  }
1165 }
1166 
1167 inline
1168 TextIter& TextIter::operator++()
1169 {
1170  forward_char();
1171  return *this;
1172 }
1173 
1174 inline
1175 const TextIter TextIter::operator++(int)
1176 {
1177  const TextIter temp (*this);
1178  forward_char();
1179  return temp;
1180 }
1181 
1182 inline
1183 TextIter& TextIter::operator--()
1184 {
1185  backward_char();
1186  return *this;
1187 }
1188 
1189 inline
1190 const TextIter TextIter::operator--(int)
1191 {
1192  const TextIter temp (*this);
1193  backward_char();
1194  return temp;
1195 }
1196 
1197 inline
1199 {
1200  return get_char();
1201 }
1202 
1203 inline
1204 TextIter::operator bool() const
1205 {
1206  return !is_end();
1207 }
1208 
1209 template <class Predicate>
1210 bool TextIter::forward_find_char(const Predicate& predicate, const TextIter& limit)
1211 {
1212  typedef TextIter::PredicateAdapter<Predicate> PredAdapter;
1213  PredAdapter adapter (predicate);
1214  return this->forward_find_char_impl(&PredAdapter::gtk_callback, &adapter, limit.gobj());
1215 }
1216 
1217 template <class Predicate>
1218 bool TextIter::forward_find_char(const Predicate& predicate)
1219 {
1220  typedef TextIter::PredicateAdapter<Predicate> PredAdapter;
1221  PredAdapter adapter (predicate);
1222  return this->forward_find_char_impl(&PredAdapter::gtk_callback, &adapter, 0);
1223 }
1224 
1225 template <class Predicate>
1226 bool TextIter::backward_find_char(const Predicate& predicate, const TextIter& limit)
1227 {
1228  typedef TextIter::PredicateAdapter<Predicate> PredAdapter;
1229  PredAdapter adapter (predicate);
1230  return this->backward_find_char_impl(&PredAdapter::gtk_callback, &adapter, limit.gobj());
1231 }
1232 
1233 template <class Predicate>
1234 bool TextIter::backward_find_char(const Predicate& predicate)
1235 {
1236  typedef TextIter::PredicateAdapter<Predicate> PredAdapter;
1237  PredAdapter adapter (predicate);
1238  return this->backward_find_char_impl(&PredAdapter::gtk_callback, &adapter, 0);
1239 }
1240 
1241 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
1242 
1243 } // namespace Gtk
1244 
1245 
1246 namespace Gtk
1247 {
1248 
1254 bool operator==(const TextIter& lhs, const TextIter& rhs);
1255 
1261 bool operator!=(const TextIter& lhs, const TextIter& rhs);
1262 
1268 bool operator<(const TextIter& lhs, const TextIter& rhs);
1269 
1275 bool operator>(const TextIter& lhs, const TextIter& rhs);
1276 
1282 bool operator<=(const TextIter& lhs, const TextIter& rhs);
1283 
1289 bool operator>=(const TextIter& lhs, const TextIter& rhs);
1290 
1291 
1292 } // namespace Gtk
1293 
1294 
1295 namespace Glib
1296 {
1297 
1303 
1308 const Gtk::TextIter& wrap(const GtkTextIter* object);
1309 
1310 #ifndef DOXYGEN_SHOULD_SKIP_THIS
1311 template <>
1312 class Value<Gtk::TextIter> : public Glib::Value_Boxed<Gtk::TextIter>
1313 {};
1314 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
1315 
1316 } // namespace Glib
1317 
1318 
1319 #endif /* _GTKMM_TEXTITER_H */
1320 
Glib::ustring get_visible_text(const TextIter &end) const
void set_offset(int char_offset)
bool is_cursor_position() const
bool forward_word_end()
bool can_insert(bool default_editability=true) const
bool backward_cursor_positions(int count)
bool operator!=(const TextIter &lhs, const TextIter &rhs)
bool toggles_tag(const Glib::RefPtr< const TextTag > &tag) const
bool ends_tag() const
TextIter & operator++()
bool forward_find_char(const Predicate &predicate, const TextIter &limit)
bool backward_word_starts(int count)
bool operator<(const TextIter &lhs, const TextIter &rhs)
int difference_type
Definition: textiter.h:160
bool starts_word() const
bool forward_find_char(const Predicate &predicate)
int get_offset() const
bool starts_sentence() const
int get_visible_line_offset() const
int get_visible_line_index() const
bool forward_sentence_end()
bool backward_visible_line()
Glib::ustring get_slice(const TextIter &end) const
bool forward_to_line_end()
bool ends_word() const
bool ends_tag(const Glib::RefPtr< const TextTag > &tag) const
bool operator>=(const TextIter &lhs, const TextIter &rhs)
std::bidirectional_iterator_tag iterator_category
Definition: textiter.h:158
Glib::RefPtr< Gdk::Pixbuf > get_pixbuf() const
bool forward_search(const Glib::ustring &str, TextSearchFlags flags, TextIter &match_start, TextIter &match_end, const TextIter &limit) const
int get_line() const
bool inside_word() const
bool begins_tag(const Glib::RefPtr< const TextTag > &tag) const
bool backward_visible_cursor_position()
bool backward_chars(int count)
void set_visible_line_index(int byte_on_line)
void pointer
Definition: textiter.h:162
bool backward_visible_word_starts(int count)
bool backward_visible_lines(int count)
bool backward_visible_cursor_positions(int count)
bool forward_char()
Glib::ustring get_visible_slice(const TextIter &end) const
bool backward_search(const Glib::ustring &str, TextSearchFlags flags, TextIter &match_start, TextIter &match_end, const TextIter &limit) const
bool is_end() const
void order(TextIter &second)
bool forward_visible_line()
GtkTextIter gobject_
Definition: textiter.h:152
Gtk::TextIter & wrap(GtkTextIter *object)
bool forward_visible_line(int count)
bool begins_tag() const
Pango::Language get_language() const
bool toggles_tag() const
const Gtk::TextIter & wrap(const GtkTextIter *object)
void set_line_offset(int char_on_line)
Glib::SListHandle< Glib::RefPtr< const TextTag > > get_tags() const
bool forward_visible_cursor_position()
bool backward_line()
bool forward_sentence_ends(int count)
bool inside_sentence() const
bool has_tag(const Glib::RefPtr< const TextTag > &tag) const
void forward_to_end()
Glib::RefPtr< const TextChildAnchor > get_child_anchor() const
bool operator<=(const TextIter &lhs, const TextIter &rhs)
bool forward_visible_cursor_positions(int count)
bool ends_sentence() const
void set_visible_line_offset(int char_on_line)
int get_chars_in_line() const
bool backward_sentence_start()
bool has_tag() const
bool backward_sentence_starts(int count)
bool operator==(const TextIter &lhs, const TextIter &rhs)
int get_line_index() const
bool forward_to_tag_toggle(const Glib::RefPtr< TextTag > &tag)
bool backward_lines(int count)
bool forward_cursor_positions(int count)
Glib::SListHandle< Glib::RefPtr< const TextTag > > get_toggled_tags(bool toggled_on=true) const
bool backward_word_start()
Glib::RefPtr< TextBuffer > get_buffer() const
value_type operator*() const
bool backward_visible_word_start()
bool backward_find_char(const Predicate &predicate)
value_type reference
Definition: textiter.h:161
bool forward_search(const Glib::ustring &str, TextSearchFlags flags, TextIter &match_start, TextIter &match_end) const
bool get_attributes(TextAttributes &values) const
Glib::SListHandle< Glib::RefPtr< TextMark > > get_marks()
bool forward_word_ends(int count)
bool ends_line() const
bool forward_chars(int count)
static GType get_type() G_GNUC_CONST
Glib::RefPtr< TextChildAnchor > get_child_anchor()
void set_line(int line_number)
bool forward_cursor_position()
const GtkTextIter * gobj() const
Provides access to the underlying C instance.
Definition: textiter.h:149
bool forward_visible_word_end()
bool backward_cursor_position()
bool in_range(const TextIter &start, const TextIter &end) const
bool forward_line()
bool editable(bool default_setting=true) const
gunichar get_char() const
Glib::SListHandle< Glib::RefPtr< const TextMark > > get_marks() const
bool backward_find_char(const Predicate &predicate, const TextIter &limit)
bool backward_to_tag_toggle(const Glib::RefPtr< TextTag > &tag)
TextIter & operator--()
int get_line_offset() const
bool starts_line() const
bool operator>(const TextIter &lhs, const TextIter &rhs)
bool forward_visible_word_ends(int count)
bool forward_lines(int count)
bool is_start() const
int get_bytes_in_line() const
gunichar value_type
Definition: textiter.h:159
const TextIter operator++(int)
Glib::SListHandle< Glib::RefPtr< TextTag > > get_tags()
Glib::ustring get_text(const TextIter &end) const
const TextIter operator--(int)
bool backward_search(const Glib::ustring &str, TextSearchFlags flags, TextIter &match_start, TextIter &match_end) const
int compare(const TextIter &rhs) const
bool backward_char()
Glib::SListHandle< Glib::RefPtr< TextTag > > get_toggled_tags(bool toggled_on=true)
void set_line_index(int byte_on_line)
CellRendererState & operator|=(CellRendererState &lhs, CellRendererState rhs)
Definition: cellrenderer.h:86
CellRendererState operator&(CellRendererState lhs, CellRendererState rhs)
Definition: cellrenderer.h:74
TextSearchFlags
Definition: textiter.h:56
CellRendererState operator^(CellRendererState lhs, CellRendererState rhs)
Definition: cellrenderer.h:78
CellRendererState operator~(CellRendererState flags)
Definition: cellrenderer.h:82
CellRendererState & operator&=(CellRendererState &lhs, CellRendererState rhs)
Definition: cellrenderer.h:90
CellRendererState operator|(CellRendererState lhs, CellRendererState rhs)
Definition: cellrenderer.h:70
CellRendererState & operator^=(CellRendererState &lhs, CellRendererState rhs)
Definition: cellrenderer.h:94
@ TEXT_SEARCH_VISIBLE_ONLY
Definition: textiter.h:57
@ TEXT_SEARCH_TEXT_ONLY
Definition: textiter.h:58
gboolean(* GtkTextCharPredicate)(gunichar ch, gpointer user_data)
Definition: gtktextiter.h:262
typedefG_BEGIN_DECLS struct _GtkTextIter GtkTextIter
Definition: gtktexttag.h:67
PBD::PropertyDescriptor< timepos_t > start
Definition: ardour_ui.h:188
Definition: lobject.h:100