GFC Logo GFC Title Logo
Reference Manual
Main Page  |  Namespace List  |  Alphabetical List  |  Class List  |  File List

text.hh

Go to the documentation of this file.
00001 /* GFC-UI: GTK+ Foundation Classes (User Interface Library) 00002 * Copyright (C) 2002-2004 The GFC Development Team. 00003 * 00004 * This program is free software; you can redistribute it and/or modify 00005 * it under the terms of the GNU General Public License as published by 00006 * the Free Software Foundation; either version 2 of the License, or 00007 * (at your option) any later version. 00008 * 00009 * This program is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 * GNU Library General Public License for more details. 00013 * 00014 * You should have received a copy of the GNU Library General Public License 00015 * along with this program; if not, write to the Free Software 00016 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00017 */ 00018 00023 00024 #ifndef GFC_ATK_TEXT_HH 00025 #define GFC_ATK_TEXT_HH 00026 00027 #ifndef GFC_G_TYPE_HH 00028 #include <gfc/glib/type.hh> 00029 #endif 00030 00031 #ifndef GFC_ATK_UTIL_HH 00032 #include <gfc/atk/util.hh> 00033 #endif 00034 00035 #ifndef __ATK_TEXT_H__ 00036 #include <atk/atktext.h> 00037 #endif 00038 00039 #ifndef _CPP_VECTOR 00040 #include <vector> 00041 #endif 00042 00043 namespace GFC { 00044 00045 namespace G { 00046 class Unichar; 00047 } 00048 00049 namespace Atk { 00050 00058 00059 enum TextAttribute 00060 { 00061 TEXT_ATTR_INVALID = ATK_TEXT_ATTR_INVALID, 00063 00064 TEXT_ATTR_LEFT_MARGIN= ATK_TEXT_ATTR_LEFT_MARGIN, 00066 00067 TEXT_ATTR_RIGHT_MARGIN = ATK_TEXT_ATTR_RIGHT_MARGIN, 00069 00070 TEXT_ATTR_INDENT = ATK_TEXT_ATTR_INDENT, 00072 00073 TEXT_ATTR_INVISIBLE = ATK_TEXT_ATTR_INVISIBLE, 00075 00076 TEXT_ATTR_EDITABLE = ATK_TEXT_ATTR_EDITABLE, 00078 00079 TEXT_ATTR_PIXELS_ABOVE_LINES = ATK_TEXT_ATTR_PIXELS_ABOVE_LINES, 00081 00082 TEXT_ATTR_PIXELS_BELOW_LINES = ATK_TEXT_ATTR_PIXELS_BELOW_LINES, 00084 00085 TEXT_ATTR_PIXELS_INSIDE_WRAP = ATK_TEXT_ATTR_PIXELS_INSIDE_WRAP, 00088 00089 TEXT_ATTR_BG_FULL_HEIGHT = ATK_TEXT_ATTR_BG_FULL_HEIGHT, 00093 00094 TEXT_ATTR_RISE = ATK_TEXT_ATTR_RISE, 00096 00097 TEXT_ATTR_UNDERLINE = ATK_TEXT_ATTR_UNDERLINE, 00099 00100 TEXT_ATTR_STRIKETHROUGH = ATK_TEXT_ATTR_STRIKETHROUGH, 00102 00103 TEXT_ATTR_SIZE = ATK_TEXT_ATTR_SIZE, 00105 00106 TEXT_ATTR_SCALE = ATK_TEXT_ATTR_SCALE, 00108 00109 TEXT_ATTR_WEIGHT = ATK_TEXT_ATTR_WEIGHT, 00111 00112 TEXT_ATTR_LANGUAGE = ATK_TEXT_ATTR_LANGUAGE, 00114 00115 TEXT_ATTR_FAMILY_NAME = ATK_TEXT_ATTR_FAMILY_NAME, 00117 00118 TEXT_ATTR_BG_COLOR = ATK_TEXT_ATTR_BG_COLOR, 00120 00121 TEXT_ATTR_FG_COLOR = ATK_TEXT_ATTR_FG_COLOR, 00123 00124 TEXT_ATTR_BG_STIPPLE = ATK_TEXT_ATTR_BG_STIPPLE, 00126 00127 TEXT_ATTR_FG_STIPPLE = ATK_TEXT_ATTR_FG_STIPPLE, 00129 00130 TEXT_ATTR_WRAP_MODE = ATK_TEXT_ATTR_WRAP_MODE, 00132 00133 TEXT_ATTR_DIRECTION = ATK_TEXT_ATTR_DIRECTION, 00135 00136 TEXT_ATTR_JUSTIFICATION = ATK_TEXT_ATTR_JUSTIFICATION, 00138 00139 TEXT_ATTR_STRETCH = ATK_TEXT_ATTR_STRETCH, 00143 00144 TEXT_ATTR_VARIANT = ATK_TEXT_ATTR_VARIANT, 00146 00147 TEXT_ATTR_STYLE = ATK_TEXT_ATTR_STYLE, 00149 00150 TEXT_ATTR_LAST_DEFINED = ATK_TEXT_ATTR_LAST_DEFINED 00152 }; 00153 00157 00158 enum TextBoundary 00159 { 00160 TEXT_BOUNDARY_CHAR = ATK_TEXT_BOUNDARY_CHAR, 00161 TEXT_BOUNDARY_WORD_START = ATK_TEXT_BOUNDARY_WORD_START, 00162 TEXT_BOUNDARY_WORD_END = ATK_TEXT_BOUNDARY_WORD_END, 00163 TEXT_BOUNDARY_SENTENCE_START = ATK_TEXT_BOUNDARY_SENTENCE_START, 00164 TEXT_BOUNDARY_SENTENCE_END = ATK_TEXT_BOUNDARY_SENTENCE_END, 00165 TEXT_BOUNDARY_LINE_START = ATK_TEXT_BOUNDARY_LINE_START, 00166 TEXT_BOUNDARY_LINE_END = ATK_TEXT_BOUNDARY_LINE_END 00167 }; 00168 00171 00172 enum TextClipType 00173 { 00174 TEXT_CLIP_NONE = ATK_TEXT_CLIP_NONE, 00175 TEXT_CLIP_MIN = ATK_TEXT_CLIP_MIN, 00176 TEXT_CLIP_MAX = ATK_TEXT_CLIP_MAX, 00177 ATK_TEXT_CLIP_BOTH = TEXT_CLIP_MAX 00178 }; 00179 00182 00183 TextAttribute text_attribute_register(const String& name); 00187 00188 String text_attribute_get_name(TextAttribute attr); 00192 00193 TextAttribute text_attribute_for_name(const String& name); 00198 00199 String text_attribute_get_value(TextAttribute attr, int index); 00204 00206 00211 00212 class Attribute 00213 { 00214 AtkAttribute attrib_; 00215 00216 public: 00219 00220 Attribute(); 00222 00223 Attribute(TextAttribute attr, int index); 00231 00232 Attribute(TextAttribute attr, const String& value); 00241 00242 Attribute(const String& name, const String& value); 00250 00251 Attribute(const AtkAttribute& attrib); 00254 00255 Attribute(const Attribute& src); 00258 00259 ~Attribute(); 00261 00262 Attribute& operator=(const Attribute& src); 00265 00269 00270 AtkAttribute* atk_attribute() const; 00272 00273 TextAttribute attr() const; 00276 00277 String name() const; 00279 00280 String value() const; 00282 00286 00287 void set(const String& name, const String& value); 00295 00297 }; 00298 00304 00305 class TextRectangle 00306 { 00307 AtkTextRectangle rectangle_; 00308 00309 public: 00312 00313 TextRectangle(); 00315 00316 TextRectangle(int x, int y, int width, int height); 00322 00323 TextRectangle(const AtkTextRectangle& rectangle); 00326 00330 00331 AtkTextRectangle* atk_text_rectangle() const; 00333 00334 operator AtkTextRectangle* () const; 00336 00337 int x() const; 00339 00340 int y() const; 00342 00343 int width() const; 00345 00346 int height() const; 00348 00352 00353 void set(int x, int y, int width, int height); 00359 00361 }; 00362 00367 00368 class TextRange 00369 { 00370 AtkTextRange range_; 00371 00372 public: 00375 00376 TextRange(const AtkTextRange& range); 00378 00379 ~TextRange(); 00381 00385 00386 AtkTextRange* atk_text_rectangle() const; 00388 00389 TextRectangle bounds() const; 00392 00393 int start_offset() const; 00396 00397 int end_offset() const; 00400 00401 const char* content() const; 00404 00406 }; 00407 00425 00426 class Text : public virtual G::TypeInterface 00427 { 00428 protected: 00431 00432 Text(); 00434 00435 virtual ~Text () = 0; 00437 00441 00442 typedef G::Signal<void, int, int> TextChangedSignalType; 00443 typedef G::SignalProxy<TypeInstance, TextChangedSignalType> TextChangedSignalProxy; 00444 static const TextChangedSignalType text_changed_signal; 00451 00452 typedef G::Signal<void, int> TextCaretMovedSignalType; 00453 typedef G::SignalProxy<TypeInstance, TextCaretMovedSignalType> TextCaretMovedSignalProxy; 00454 static const TextCaretMovedSignalType text_caret_moved_signal; 00460 00461 typedef G::Signal<void> TextSelectionChangedSignalType; 00462 typedef G::SignalProxy<TypeInstance, TextSelectionChangedSignalType> TextSelectionChangedSignalProxy; 00463 static const TextSelectionChangedSignalType text_selection_changed_signal; 00468 00469 typedef G::Signal<void> TextAttributesChangedSignalType; 00470 typedef G::SignalProxy<TypeInstance, TextAttributesChangedSignalType> TextAttributesChangedSignalProxy; 00471 static const TextAttributesChangedSignalType text_attributes_changed_signal; 00476 00478 00479 public: 00482 00483 AtkText* atk_text() const; 00485 00486 operator AtkText* () const; 00488 00489 String get_text(int start_offset, int end_offset) const; 00494 00495 G::Unichar get_character_at_offset(int offset) const; 00499 00500 String get_text_after_offset(int offset, TextBoundary boundary_type, int *start_offset, int *end_offset) const; 00535 00536 String get_text_at_offset(int offset, TextBoundary boundary_type, int *start_offset, int *end_offset) const; 00571 00572 String get_text_before_offset(int offset, TextBoundary boundary_type, int *start_offset, int *end_offset) const; 00609 00610 int get_caret_offset() const; 00612 00613 void get_character_extents(int offset, int *x, int *y, int *width, int *height, CoordType coords) const; 00621 00622 std::vector<Attribute> get_run_attributes(int offset, int *start_offset, int *end_offset) const; 00634 00635 std::vector<Attribute> get_default_attributes() const; 00641 00642 int get_character_count() const; 00645 00646 int get_offset_at_point(int x, int y, CoordType coords) const; 00655 00656 int get_n_selections() const; 00659 00660 String get_selection(int selection_num, int *start_offset, int *end_offset) const; 00671 00672 TextRectangle get_range_extents(int start_offset, int end_offset, CoordType coord_type); 00678 00679 void get_range_extents(int start_offset, int end_offset, CoordType coord_type, TextRectangle& rect); 00685 00686 std::vector<TextRange> get_bounded_ranges(const TextRectangle& rect, CoordType coord_type, 00687 TextClipType x_clip_type, TextClipType y_clip_type); 00694 00698 00699 bool add_selection(int start_offset, int end_offset); 00704 00705 bool remove_selection(int selection_num); 00714 00715 bool set_selection(int selection_num, int start_offset, int end_offset); 00726 00727 bool set_caret_offset(int offset); 00731 00735 00736 const TextChangedSignalProxy sig_text_changed(); 00738 00739 const TextCaretMovedSignalProxy sig_text_caret_moved(); 00741 00742 const TextSelectionChangedSignalProxy sig_text_selection_changed(); 00744 00745 const TextAttributesChangedSignalProxy sig_text_attributes_changed(); 00747 00749 }; 00750 00751 } // namespace Atk 00752 00753 } // namespace GFC 00754 00755 #include <gfc/atk/inline/text.inl> 00756 00757 #endif // GFC_ATK_TEXT_HH 00758

Generated on Tue Aug 24 00:34:32 2004 for GFC-UI by doxygen 1.3.8