gtktext.inc 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277
  1. // included by gtk2.pas
  2. {$IFDEF read_forward_definitions}
  3. {$ENDIF read_forward_definitions}
  4. //------------------------------------------------------------------------------
  5. {$IFDEF read_interface_types}
  6. // internal type
  7. PGtkTextFont = pointer;
  8. { Position in list. }
  9. { Offset into that property. }
  10. { Current index. }
  11. PGtkPropertyMark = ^TGtkPropertyMark;
  12. TGtkPropertyMark = record
  13. _property : PGList;
  14. offset : guint;
  15. index : guint;
  16. end;
  17. { GAPPED TEXT SEGMENT }
  18. { The text, a single segment of text a'la emacs, with a gap
  19. where insertion occurs. }
  20. { The allocated length of the text segment. }
  21. { The gap position, index into address where a char
  22. should be inserted. }
  23. { The gap size, s.t. (text + gap_position + gap_size) is
  24. the first valid character following the gap. }
  25. { The last character position, index into address where a
  26. character should be appeneded. Thus, text_end - gap_size
  27. is the length of the actual data. }
  28. { LINE START CACHE }
  29. { A cache of line-start information. Data is a LineParam . }
  30. { Index to the start of the first visible line. }
  31. { The number of pixels cut off of the top line. }
  32. { First visible horizontal pixel. }
  33. { First visible vertical pixel. }
  34. { FLAGS }
  35. { True iff this buffer is wrapping lines, otherwise it is using a
  36. horizontal scrollbar. }
  37. { If a fontset is supplied for the widget, use_wchar become true,
  38. and we use GdkWchar as the encoding of text. }
  39. { Frozen, don't do updates. @@@ fixme }
  40. { TEXT PROPERTIES }
  41. { A doubly-linked-list containing TextProperty objects. }
  42. { The theEnd of this list. }
  43. { The first node before or on the point along with its offset to
  44. the point and the buffer's current point. This is the only
  45. PropertyMark whose index is guaranteed to remain correct
  46. following a buffer insertion or deletion. }
  47. { SCRATCH AREA }
  48. { SCROLLING }
  49. { CURSOR }
  50. { Position of cursor. }
  51. { Baseline of line cursor is drawn on. }
  52. { Where it is in the buffer. }
  53. { Character to redraw. }
  54. { Distance from baseline of the font. }
  55. { Where it would be if it could be. }
  56. { How many people have undrawn. }
  57. { Current Line }
  58. { Tab Stops }
  59. { Text font for current style }
  60. { Timer used for auto-scrolling off ends }
  61. { currently pressed mouse button }
  62. { gc for drawing background pixmap }
  63. PGtkText = ^TGtkText;
  64. TGtkText = record
  65. old_editable : TGtkOldEditable;
  66. text_area : PGdkWindow;
  67. hadj : PGtkAdjustment;
  68. vadj : PGtkAdjustment;
  69. gc : PGdkGC;
  70. line_wrap_bitmap : PGdkPixmap;
  71. line_arrow_bitmap : PGdkPixmap;
  72. text : record
  73. case longint of
  74. 0 : ( wc : PGdkWChar );
  75. 1 : ( ch : Pguchar );
  76. end;
  77. text_len : guint;
  78. gap_position : guint;
  79. gap_size : guint;
  80. text_end : guint;
  81. line_start_cache : PGList;
  82. first_line_start_index : guint;
  83. first_cut_pixels : guint;
  84. first_onscreen_hor_pixel : guint;
  85. first_onscreen_ver_pixel : guint;
  86. flag0 : word;
  87. freeze_count : guint;
  88. text_properties : PGList;
  89. text_properties_end : PGList;
  90. point : TGtkPropertyMark;
  91. scratch_buffer : record
  92. case longint of
  93. 0 : ( wc : PGdkWChar );
  94. 1 : ( ch : Pguchar );
  95. end;
  96. scratch_buffer_len : guint;
  97. last_ver_value : gint;
  98. cursor_pos_x : gint;
  99. cursor_pos_y : gint;
  100. cursor_mark : TGtkPropertyMark;
  101. cursor_char : TGdkWChar;
  102. cursor_char_offset : gchar;
  103. cursor_virtual_x : gint;
  104. cursor_drawn_level : gint;
  105. current_line : PGList;
  106. tab_stops : PGList;
  107. default_tab_width : gint;
  108. current_font : PGtkTextFont;
  109. timer : gint;
  110. button : guint;
  111. bg_gc : PGdkGC;
  112. end;
  113. PGtkTextClass = ^TGtkTextClass;
  114. TGtkTextClass = record
  115. parent_class : TGtkOldEditableClass;
  116. set_scroll_adjustments : procedure (text:PGtkText; hadjustment:PGtkAdjustment; vadjustment:PGtkAdjustment); cdecl;
  117. end;
  118. {$ENDIF read_interface_types}
  119. //------------------------------------------------------------------------------
  120. {$IFDEF read_interface_rest}
  121. const
  122. bm_TGtkText_line_wrap = $1;
  123. bp_TGtkText_line_wrap = 0;
  124. bm_TGtkText_word_wrap = $2;
  125. bp_TGtkText_word_wrap = 1;
  126. bm_TGtkText_use_wchar = $4;
  127. bp_TGtkText_use_wchar = 2;
  128. function GTK_TYPE_TEXT : GType;
  129. function GTK_TEXT(obj: pointer) : PGtkText;
  130. function GTK_TEXT_CLASS(klass: pointer) : PGtkTextClass;
  131. function GTK_IS_TEXT(obj: pointer) : boolean;
  132. function GTK_IS_TEXT_CLASS(klass: pointer) : boolean;
  133. function GTK_TEXT_GET_CLASS(obj: pointer) : PGtkTextClass;
  134. function line_wrap(a : PGtkText) : guint;
  135. procedure set_line_wrap(a : PGtkText; __line_wrap : guint);
  136. function word_wrap(a : PGtkText) : guint;
  137. procedure set_word_wrap(a : PGtkText; __word_wrap : guint);
  138. function use_wchar(a : PGtkText) : gboolean;
  139. procedure set_use_wchar(a : PGtkText; __use_wchar : gboolean);
  140. function gtk_text_get_type:TGtkType; cdecl; external gtklib;
  141. function gtk_text_new(hadj:PGtkAdjustment; vadj:PGtkAdjustment):PGtkWidget; cdecl; external gtklib;
  142. procedure gtk_text_set_editable(text:PGtkText; editable:gboolean); cdecl; external gtklib;
  143. procedure gtk_text_set_word_wrap(text:PGtkText; word_wrap:gboolean); cdecl; external gtklib;
  144. procedure gtk_text_set_line_wrap(text:PGtkText; line_wrap:gboolean); cdecl; external gtklib;
  145. procedure gtk_text_set_adjustments(text:PGtkText; hadj:PGtkAdjustment; vadj:PGtkAdjustment); cdecl; external gtklib;
  146. procedure gtk_text_set_point(text:PGtkText; index:guint); cdecl; external gtklib;
  147. function gtk_text_get_point(text:PGtkText):guint; cdecl; external gtklib;
  148. function gtk_text_get_length(text:PGtkText):guint; cdecl; external gtklib;
  149. procedure gtk_text_freeze(text:PGtkText); cdecl; external gtklib;
  150. procedure gtk_text_thaw(text:PGtkText); cdecl; external gtklib;
  151. procedure gtk_text_insert(text:PGtkText; font:PGdkFont; fore:PGdkColor; back:PGdkColor; chars:Pchar;
  152. length:gint); cdecl; external gtklib;
  153. function gtk_text_backward_delete(text:PGtkText; nchars:guint):gboolean; cdecl; external gtklib;
  154. function gtk_text_forward_delete(text:PGtkText; nchars:guint):gboolean; cdecl; external gtklib;
  155. function GTK_TEXT_INDEX_WCHAR(t: PGtkText; index: guint): guint32;
  156. function GTK_TEXT_INDEX_UCHAR(t: PGtkText; index: guint): GUChar;
  157. {$ENDIF read_interface_rest}
  158. //------------------------------------------------------------------------------
  159. {$IFDEF read_implementation}
  160. function GTK_TYPE_TEXT : GType;
  161. begin
  162. GTK_TYPE_TEXT:=gtk_text_get_type;
  163. end;
  164. function GTK_TEXT(obj: pointer) : PGtkText;
  165. begin
  166. GTK_TEXT:=PGtkText(GTK_CHECK_CAST(obj,GTK_TYPE_TEXT));
  167. end;
  168. function GTK_TEXT_CLASS(klass: pointer) : PGtkTextClass;
  169. begin
  170. GTK_TEXT_CLASS:=PGtkTextClass(GTK_CHECK_CLASS_CAST(klass,GTK_TYPE_TEXT));
  171. end;
  172. function GTK_IS_TEXT(obj: pointer) : boolean;
  173. begin
  174. GTK_IS_TEXT:=GTK_CHECK_TYPE(obj,GTK_TYPE_TEXT);
  175. end;
  176. function GTK_IS_TEXT_CLASS(klass: pointer) : boolean;
  177. begin
  178. GTK_IS_TEXT_CLASS:=GTK_CHECK_CLASS_TYPE(klass,GTK_TYPE_TEXT);
  179. end;
  180. function GTK_TEXT_GET_CLASS(obj: pointer) : PGtkTextClass;
  181. begin
  182. GTK_TEXT_GET_CLASS:=PGtkTextClass(GTK_CHECK_GET_CLASS(obj,GTK_TYPE_TEXT));
  183. end;
  184. function line_wrap(a : PGtkText) : guint;
  185. begin
  186. line_wrap:=(a^.flag0 and bm_TGtkText_line_wrap) shr bp_TGtkText_line_wrap;
  187. end;
  188. procedure set_line_wrap(a : PGtkText; __line_wrap : guint);
  189. begin
  190. a^.flag0:=a^.flag0 or ((__line_wrap shl bp_TGtkText_line_wrap)
  191. and bm_TGtkText_line_wrap);
  192. end;
  193. function word_wrap(a : PGtkText) : guint;
  194. begin
  195. word_wrap:=(a^.flag0 and bm_TGtkText_word_wrap) shr bp_TGtkText_word_wrap;
  196. end;
  197. procedure set_word_wrap(a : PGtkText; __word_wrap : guint);
  198. begin
  199. a^.flag0:=a^.flag0 or ((__word_wrap shl bp_TGtkText_word_wrap)
  200. and bm_TGtkText_word_wrap);
  201. end;
  202. function use_wchar(a : PGtkText) : gboolean;
  203. begin
  204. use_wchar:=((a^.flag0 and bm_TGtkText_use_wchar) shr bp_TGtkText_use_wchar)>0;
  205. end;
  206. procedure set_use_wchar(a : PGtkText; __use_wchar : gboolean);
  207. begin
  208. if __use_wchar then
  209. a^.flag0:=a^.flag0 or bm_TGtkText_use_wchar
  210. else
  211. a^.flag0:=a^.flag0 and not bm_TGtkText_use_wchar;
  212. end;
  213. function GTK_TEXT_INDEX_WCHAR(t: PGtkText; index: guint): guint32;
  214. begin
  215. {$IFNDEF KYLIX}
  216. if Use_WChar(t) then begin
  217. if index < t^.gap_position then begin
  218. Result:=t^.text.wc[index];
  219. end else begin
  220. Result:=t^.text.wc[index+t^.gap_size];
  221. end;
  222. end else begin
  223. writeln('GTK_TEXT_INDEX_WCHAR ERROR: t does not use wide char');
  224. Result:=0;
  225. end;
  226. {$ENDIF}
  227. end;
  228. function GTK_TEXT_INDEX_UCHAR(t: PGtkText; index: guint): GUChar;
  229. begin
  230. {$IFNDEF KYLIX}
  231. if Use_WChar(t) then begin
  232. writeln('GTK_TEXT_INDEX_WCHAR ERROR: t does not use unsigned char');
  233. Result:=0;
  234. end else begin
  235. if index < t^.gap_position then begin
  236. Result:=t^.text.ch[index];
  237. end else begin
  238. Result:=t^.text.ch[index+t^.gap_size];
  239. end;
  240. end;
  241. {$ENDIF}
  242. end;
  243. {$ENDIF read_implementation}
  244. // included by gtk2.pas