Reference Manual

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

# text.h

Go to the documentation of this file.

    00001 /*  Inti: Integrated Foundation Classes
    00002  *  Copyright (C) 2002-2003 The Inti 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 INTI_ATK_TEXT_H
    00025 #define INTI_ATK_TEXT_H
    00026
    00027 #ifndef INTI_G_TYPE_H
    00028 #include <inti/glib/type.h>
    00029 #endif
    00030
    00031 #ifndef INTI_ATK_UTIL_H
    00032 #include <inti/atk/util.h>
    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 Inti {
    00044
    00045 namespace G {
    00046 class Unichar;
    00047 }
    00048
    00049 namespace Atk {
    00050
    00051 class TextIface;
    00052
    00060
    00061 enum TextAttribute
    00062 {
    00063         TEXT_ATTR_INVALID = ATK_TEXT_ATTR_INVALID,
    00065
    00066         TEXT_ATTR_LEFT_MARGIN= ATK_TEXT_ATTR_LEFT_MARGIN,
    00068
    00069         TEXT_ATTR_RIGHT_MARGIN = ATK_TEXT_ATTR_RIGHT_MARGIN,
    00071
    00072         TEXT_ATTR_INDENT = ATK_TEXT_ATTR_INDENT,
    00074
    00075         TEXT_ATTR_INVISIBLE = ATK_TEXT_ATTR_INVISIBLE,
    00077
    00078         TEXT_ATTR_EDITABLE = ATK_TEXT_ATTR_EDITABLE,
    00080
    00081         TEXT_ATTR_PIXELS_ABOVE_LINES = ATK_TEXT_ATTR_PIXELS_ABOVE_LINES,
    00083
    00084         TEXT_ATTR_PIXELS_BELOW_LINES = ATK_TEXT_ATTR_PIXELS_BELOW_LINES,
    00086
    00087         TEXT_ATTR_PIXELS_INSIDE_WRAP = ATK_TEXT_ATTR_PIXELS_INSIDE_WRAP,
    00090
    00091         TEXT_ATTR_BG_FULL_HEIGHT = ATK_TEXT_ATTR_BG_FULL_HEIGHT,
    00095
    00096         TEXT_ATTR_RISE = ATK_TEXT_ATTR_RISE,
    00098
    00099         TEXT_ATTR_UNDERLINE = ATK_TEXT_ATTR_UNDERLINE,
    00101
    00102         TEXT_ATTR_STRIKETHROUGH = ATK_TEXT_ATTR_STRIKETHROUGH,
    00104
    00105         TEXT_ATTR_SIZE = ATK_TEXT_ATTR_SIZE,
    00107
    00108         TEXT_ATTR_SCALE = ATK_TEXT_ATTR_SCALE,
    00110
    00111         TEXT_ATTR_WEIGHT = ATK_TEXT_ATTR_WEIGHT,
    00113
    00114         TEXT_ATTR_LANGUAGE = ATK_TEXT_ATTR_LANGUAGE,
    00116
    00117         TEXT_ATTR_FAMILY_NAME = ATK_TEXT_ATTR_FAMILY_NAME,
    00119
    00120         TEXT_ATTR_BG_COLOR = ATK_TEXT_ATTR_BG_COLOR,
    00122
    00123         TEXT_ATTR_FG_COLOR = ATK_TEXT_ATTR_FG_COLOR,
    00125
    00126         TEXT_ATTR_BG_STIPPLE = ATK_TEXT_ATTR_BG_STIPPLE,
    00128
    00129         TEXT_ATTR_FG_STIPPLE = ATK_TEXT_ATTR_FG_STIPPLE,
    00131
    00132         TEXT_ATTR_WRAP_MODE = ATK_TEXT_ATTR_WRAP_MODE,
    00134
    00135         TEXT_ATTR_DIRECTION = ATK_TEXT_ATTR_DIRECTION,
    00137
    00138         TEXT_ATTR_JUSTIFICATION = ATK_TEXT_ATTR_JUSTIFICATION,
    00140
    00141         TEXT_ATTR_STRETCH = ATK_TEXT_ATTR_STRETCH,
    00145
    00146         TEXT_ATTR_VARIANT = ATK_TEXT_ATTR_VARIANT,
    00148
    00149         TEXT_ATTR_STYLE = ATK_TEXT_ATTR_STYLE,
    00151
    00152         TEXT_ATTR_LAST_DEFINED  = ATK_TEXT_ATTR_LAST_DEFINED
    00154 };
    00155
    00159
    00160 enum TextBoundary
    00161 {
    00162         TEXT_BOUNDARY_CHAR = ATK_TEXT_BOUNDARY_CHAR,
    00163         TEXT_BOUNDARY_WORD_START = ATK_TEXT_BOUNDARY_WORD_START,
    00164         TEXT_BOUNDARY_WORD_END = ATK_TEXT_BOUNDARY_WORD_END,
    00165         TEXT_BOUNDARY_SENTENCE_START = ATK_TEXT_BOUNDARY_SENTENCE_START,
    00166         TEXT_BOUNDARY_SENTENCE_END = ATK_TEXT_BOUNDARY_SENTENCE_END,
    00167         TEXT_BOUNDARY_LINE_START = ATK_TEXT_BOUNDARY_LINE_START,
    00168         TEXT_BOUNDARY_LINE_END = ATK_TEXT_BOUNDARY_LINE_END
    00169 };
    00170
    00173
    00174 TextAttribute text_attribute_register(const String& name);
    00178
    00179 String text_attribute_get_name(TextAttribute attr);
    00183
    00184 TextAttribute text_attribute_for_name(const String& name);
    00189
    00190 String text_attribute_get_value(TextAttribute attr, int index);
    00195
    00197
    00202
    00203 class Attribute
    00204 {
    00205         AtkAttribute attrib_;
    00206
    00207 public:
    00210
    00211         Attribute();
    00213
    00214         Attribute(TextAttribute attr, int index);
    00222
    00223         Attribute(TextAttribute attr, const String& value);
    00232
    00233         Attribute(const String& name, const String& value);
    00241
    00242         Attribute(const AtkAttribute& attrib);
    00245
    00246         Attribute(const Attribute& src);
    00249
    00250         ~Attribute();
    00252
    00253         Attribute& operator=(const Attribute& src);
    00256
    00260
    00261         AtkAttribute* atk_attribute() const { return const_cast<AtkAttribute*>(&attrib_); }
    00263
    00264         TextAttribute attr() const;
    00267
    00268         String name() const;
    00270
    00271         String value() const;
    00273
    00277
    00278         void set(const String& name, const String& value);
    00286
    00288 };
    00289
    00307
    00308 class Text  : public virtual G::TypeInterface
    00309 {
    00310         friend class TextIface;
    00311
    00312 protected:
    00315
    00316         virtual ~Text () = 0;
    00318
    00320 //  Override these do_ methods when you want to change the default behaviour of the AtkText.
    00321
    00322         virtual char* do_get_text(int start_offset, int end_offset);
    00323
    00324         virtual char* do_get_text_after_offset(int offset, AtkTextBoundary boundary_type, int *start_offset, int *end_offset);
    00325
    00326         virtual char* do_get_text_at_offset(int offset, AtkTextBoundary boundary_type, int *start_offset, int *end_offset);
    00327
    00328         virtual gunichar do_get_character_at_offset(int offset);
    00329
    00330         virtual char* do_get_text_before_offset(int offset, AtkTextBoundary boundary_type, int *start_offset, int *end_offset);
    00331
    00332         virtual int do_get_caret_offset();
    00333
    00334         virtual AtkAttributeSet* do_get_run_attributes(int offset, int *start_offset, int *end_offset);
    00335
    00336         virtual AtkAttributeSet* do_get_default_attributes();
    00337
    00338         virtual void do_get_character_extents(int offset, int *x, int *y, int *width, int *height, AtkCoordType coords);
    00339
    00340         virtual int do_get_character_count();
    00341
    00342         virtual int do_get_offset_at_point(int  x, int y, AtkCoordType coords);
    00343
    00344         virtual int do_get_n_selections();
    00345
    00346         virtual char* do_get_selection(int selection_num, int *start_offset, int *end_offset);
    00347
    00348         virtual bool do_add_selection(int start_offset, int end_offset);
    00349
    00350         virtual bool do_remove_selection(int selection_num);
    00351
    00352         virtual bool do_set_selection(int selection_num, int start_offset, int end_offset);
    00353
    00354         virtual bool do_set_caret_offset(int offset);
    00355
    00358
    00359         virtual void on_text_changed(int position, int length);
    00363
    00364         virtual void on_text_caret_moved(int location);
    00367
    00368         virtual void on_text_selection_changed();
    00370
    00371         virtual void on_text_attributes_changed();
    00373
    00375 //  Signals
    00376
    00377         typedef G::Signal2<void, int, int> TextChangedSignalType;
    00378         typedef G::SignalProxy<TypeInstance, TextChangedSignalType> TextChangedSignalProxy;
    00379         static const TextChangedSignalType text_changed_signal;
    00380
    00381         typedef G::Signal1<void, int> TextCaretMovedSignalType;
    00382         typedef G::SignalProxy<TypeInstance, TextCaretMovedSignalType> TextCaretMovedSignalProxy;
    00383         static const TextCaretMovedSignalType text_caret_moved_signal;
    00384
    00385         typedef G::Signal0<void> TextSelectionChangedSignalType;
    00386         typedef G::SignalProxy<TypeInstance, TextSelectionChangedSignalType> TextSelectionChangedSignalProxy;
    00387         static const TextSelectionChangedSignalType text_selection_changed_signal;
    00388
    00389         typedef G::Signal0<void> TextAttributesChangedSignalType;
    00390         typedef G::SignalProxy<TypeInstance, TextAttributesChangedSignalType> TextAttributesChangedSignalProxy;
    00391         static const TextAttributesChangedSignalType text_attributes_changed_signal;
    00392
    00393 public:
    00396
    00397         AtkText* atk_text() const { return (AtkText*)instance; }
    00399
    00400         AtkTextIface* atk_text_iface() const;
    00402
    00403         operator AtkText* () const;
    00405
    00406         String get_text(int start_offset, int end_offset) const;
    00411
    00412         G::Unichar get_character_at_offset(int offset) const;
    00416
    00417         String get_text_after_offset(int offset, TextBoundary boundary_type, int *start_offset, int *end_offset) const;
    00452
    00453         String get_text_at_offset(int offset, TextBoundary boundary_type, int *start_offset, int *end_offset) const;
    00488
    00489         String get_text_before_offset(int offset, TextBoundary boundary_type, int *start_offset, int *end_offset) const;
    00526
    00527         int get_caret_offset() const;
    00529
    00530         void get_character_extents(int offset, int *x, int *y, int *width, int *height, CoordType coords) const;
    00538
    00539         std::vector<Attribute> get_run_attributes(int offset, int *start_offset, int *end_offset) const;
    00551
    00552         std::vector<Attribute> get_default_attributes() const;
    00558
    00559         int get_character_count() const;
    00562
    00563         int get_offset_at_point(int x, int y, CoordType coords) const;
    00572
    00573         int get_n_selections() const;
    00576
    00577         String get_selection(int selection_num, int *start_offset, int *end_offset) const;
    00588
    00592
    00593         bool add_selection(int start_offset, int end_offset);
    00598
    00599         bool remove_selection(int selection_num);
    00608
    00609         bool set_selection(int selection_num, int start_offset, int end_offset);
    00620
    00621         bool set_caret_offset(int offset);
    00625
    00629
    00630         const TextChangedSignalProxy sig_text_changed()
    00631         {
    00632                 return TextChangedSignalProxy(this, &text_changed_signal);
    00633         }
    00635
    00636
    00637         const TextCaretMovedSignalProxy sig_text_caret_moved()
    00638         {
    00639                 return TextCaretMovedSignalProxy(this, &text_caret_moved_signal);
    00640         }
    00642
    00643         const TextSelectionChangedSignalProxy sig_text_selection_changed()
    00644         {
    00645                 return TextSelectionChangedSignalProxy(this, &text_selection_changed_signal);
    00646         }
    00648
    00649         const TextAttributesChangedSignalProxy sig_text_attributes_changed()
    00650         {
    00651                 return TextAttributesChangedSignalProxy(this, &text_attributes_changed_signal);
    00652         }
    00654
    00656 };
    00657
    00658 } // namespace Atk
    00659
    00660 } // namespace Inti
    00661
    00662 #endif // INTI_ATK_TEXT_H
    00663

Main Page - Footer