gtktextlayout.inc 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314
  1. // included by gtk2.pas
  2. {$IFDEF read_forward_definitions}
  3. {$ENDIF read_forward_definitions}
  4. //------------------------------------------------------------------------------
  5. {$IFDEF read_interface_types}
  6. PGtkTextLineDisplay = ^TGtkTextLineDisplay;
  7. { This is a "semi-private" header; it is intended for
  8. use by the text widget, and the text canvas item,
  9. but that's all. We may have to install it so the
  10. canvas item can use it, but users are not supposed
  11. to use it.
  12. }
  13. { forward declarations that have to be here to avoid including
  14. gtktextbtree.h
  15. }
  16. { width of the display area on-screen,
  17. i.e. pixels we should wrap to fit inside. }
  18. { width/height of the total logical area being layed out }
  19. { Pixel offsets from the left and from the top to be used when we
  20. draw; these allow us to create left/top margins. We don't need
  21. anything special for bottom/right margins, because those don't
  22. affect drawing.
  23. }
  24. { gint left_edge; }
  25. { gint top_edge; }
  26. { Default style used if no tags override it }
  27. { Pango contexts used for creating layouts }
  28. { A cache of one style; this is used to ensure
  29. we don't constantly regenerate the style
  30. over long runs with the same style. }
  31. { A cache of one line display. Getting the same line
  32. many times in a row is the most common case.
  33. }
  34. { Whether we are allowed to wrap right now }
  35. { Whether to show the insertion cursor }
  36. { For what GtkTextDirection to draw cursor GTK_TEXT_DIR_NONE -
  37. means draw both cursors.
  38. }
  39. { The preedit string and attributes, if any }
  40. PGtkTextLayout = ^TGtkTextLayout;
  41. TGtkTextLayout = record
  42. parent_instance : TGObject;
  43. screen_width : gint;
  44. width : gint;
  45. height : gint;
  46. buffer : PGtkTextBuffer;
  47. default_style : PGtkTextAttributes;
  48. ltr_context : PPangoContext;
  49. rtl_context : PPangoContext;
  50. one_style_cache : PGtkTextAttributes;
  51. one_display_cache : PGtkTextLineDisplay;
  52. wrap_loop_count : gint;
  53. flag0 : word;
  54. preedit_string : Pgchar;
  55. preedit_attrs : PPangoAttrList;
  56. preedit_len : gint;
  57. preedit_cursor : gint;
  58. end;
  59. { Some portion of the layout was invalidated
  60. }
  61. { A range of the layout changed appearance and possibly height
  62. }
  63. { may be NULL }
  64. { Padding for future expansion }
  65. PGtkTextLayoutClass = ^TGtkTextLayoutClass;
  66. TGtkTextLayoutClass = record
  67. parent_class : TGObjectClass;
  68. invalidated : procedure (layout:PGtkTextLayout); cdecl;
  69. changed : procedure (layout:PGtkTextLayout; y:gint; old_height:gint; new_height:gint); cdecl;
  70. wrap : function (layout:PGtkTextLayout; line:PGtkTextLine; line_data:PGtkTextLineData):PGtkTextLineData; cdecl;
  71. get_log_attrs : procedure (layout:PGtkTextLayout; line:PGtkTextLine; var attrs:PPangoLogAttr; n_attrs:Pgint); cdecl;
  72. invalidate : procedure (layout:PGtkTextLayout; start:PGtkTextIter; theEnd:PGtkTextIter); cdecl;
  73. free_line_data : procedure (layout:PGtkTextLayout; line:PGtkTextLine; line_data:PGtkTextLineData); cdecl;
  74. allocate_child : procedure (layout:PGtkTextLayout; child:PGtkWidget; x:gint; y:gint); cdecl;
  75. _gtk_reserved1 : procedure ; cdecl;
  76. _gtk_reserved2 : procedure ; cdecl;
  77. _gtk_reserved3 : procedure ; cdecl;
  78. _gtk_reserved4 : procedure ; cdecl;
  79. end;
  80. PGtkTextAttrAppearance = ^TGtkTextAttrAppearance;
  81. TGtkTextAttrAppearance = record
  82. attr : TPangoAttribute;
  83. appearance : TGtkTextAppearance;
  84. end;
  85. PGtkTextCursorDisplay = ^TGtkTextCursorDisplay;
  86. TGtkTextCursorDisplay = record
  87. x : gint;
  88. y : gint;
  89. height : gint;
  90. flag0 : word;
  91. end;
  92. { Width of layout }
  93. { width - margins, if no width set on layout, if width set on layout, -1 }
  94. { Amount layout is shifted from left edge - this is the left margin
  95. plus any other factors, such as alignment or indentation.
  96. }
  97. { Byte index of insert cursor within para or -1 }
  98. TGtkTextLineDisplay = record
  99. layout : PPangoLayout;
  100. cursors : PGSList;
  101. shaped_objects : PGSList;
  102. direction : TGtkTextDirection;
  103. width : gint;
  104. total_width : gint;
  105. height : gint;
  106. x_offset : gint;
  107. left_margin : gint;
  108. right_margin : gint;
  109. top_margin : gint;
  110. bottom_margin : gint;
  111. insert_index : gint;
  112. size_only : gboolean;
  113. line : PGtkTextLine;
  114. end;
  115. {$ENDIF read_interface_types}
  116. //------------------------------------------------------------------------------
  117. {$IFDEF read_interface_rest}
  118. {$IFNDEF KYLIX}
  119. var
  120. gtk_text_attr_appearance_type : TPangoAttrType;cvar; external;
  121. {$ENDIF}
  122. function GTK_TYPE_TEXT_LAYOUT : GType;
  123. function GTK_TEXT_LAYOUT(obj: pointer) : PGtkTextLayout;
  124. function GTK_TEXT_LAYOUT_CLASS(klass: pointer) : PGtkTextLayoutClass;
  125. function GTK_IS_TEXT_LAYOUT(obj: pointer) : boolean;
  126. function GTK_IS_TEXT_LAYOUT_CLASS(klass: pointer) : boolean;
  127. function GTK_TEXT_LAYOUT_GET_CLASS(obj: pointer) : PGtkTextLayoutClass;
  128. const
  129. bm_TGtkTextLayout_cursor_visible = $1;
  130. bp_TGtkTextLayout_cursor_visible = 0;
  131. bm_TGtkTextLayout_cursor_direction = $6;
  132. bp_TGtkTextLayout_cursor_direction = 1;
  133. function cursor_visible(var a : TGtkTextLayout) : guint; overload;
  134. procedure set_cursor_visible(var a : TGtkTextLayout; __cursor_visible : guint); overload;
  135. function cursor_direction(var a : TGtkTextLayout) : gint;
  136. procedure set_cursor_direction(var a : TGtkTextLayout; __cursor_direction : gint);
  137. const
  138. bm_TGtkTextCursorDisplay_is_strong = $1;
  139. bp_TGtkTextCursorDisplay_is_strong = 0;
  140. bm_TGtkTextCursorDisplay_is_weak = $2;
  141. bp_TGtkTextCursorDisplay_is_weak = 1;
  142. function is_strong(var a : TGtkTextCursorDisplay) : guint;
  143. procedure set_is_strong(var a : TGtkTextCursorDisplay; __is_strong : guint);
  144. function is_weak(var a : TGtkTextCursorDisplay) : guint;
  145. procedure set_is_weak(var a : TGtkTextCursorDisplay; __is_weak : guint);
  146. function gtk_text_layout_get_type:GType; cdecl; external gtklib;
  147. function gtk_text_layout_new:PGtkTextLayout; cdecl; external gtklib;
  148. procedure gtk_text_layout_set_buffer(layout:PGtkTextLayout; buffer:PGtkTextBuffer); cdecl; external gtklib;
  149. function gtk_text_layout_get_buffer(layout:PGtkTextLayout):PGtkTextBuffer; cdecl; external gtklib;
  150. procedure gtk_text_layout_set_default_style(layout:PGtkTextLayout; values:PGtkTextAttributes); cdecl; external gtklib;
  151. procedure gtk_text_layout_set_contexts(layout:PGtkTextLayout; ltr_context:PPangoContext; rtl_context:PPangoContext); cdecl; external gtklib;
  152. procedure gtk_text_layout_set_cursor_direction(layout:PGtkTextLayout; direction:TGtkTextDirection); cdecl; external gtklib;
  153. procedure gtk_text_layout_default_style_changed(layout:PGtkTextLayout); cdecl; external gtklib;
  154. procedure gtk_text_layout_set_screen_width(layout:PGtkTextLayout; width:gint); cdecl; external gtklib;
  155. procedure gtk_text_layout_set_preedit_string(layout:PGtkTextLayout; preedit_string:Pgchar; preedit_attrs:PPangoAttrList; cursor_pos:gint); cdecl; external gtklib;
  156. procedure gtk_text_layout_set_cursor_visible(layout:PGtkTextLayout; cursor_visible:gboolean); cdecl; external gtklib;
  157. function gtk_text_layout_get_cursor_visible(layout:PGtkTextLayout):gboolean; cdecl; external gtklib;
  158. { Getting the size or the lines potentially results in a call to
  159. recompute, which is pretty massively expensive. Thus it should
  160. basically only be done in an idle handler.
  161. Long-term, we would really like to be able to do these without
  162. a full recompute so they may get cheaper over time.
  163. }
  164. procedure gtk_text_layout_get_size(layout:PGtkTextLayout; width:Pgint; height:Pgint); cdecl; external gtklib;
  165. { [top_y, bottom_y) }
  166. function gtk_text_layout_get_lines(layout:PGtkTextLayout; top_y:gint; bottom_y:gint; first_line_y:Pgint):PGSList; cdecl; external gtklib;
  167. procedure gtk_text_layout_wrap_loop_start(layout:PGtkTextLayout); cdecl; external gtklib;
  168. procedure gtk_text_layout_wrap_loop_end(layout:PGtkTextLayout); cdecl; external gtklib;
  169. function gtk_text_layout_get_line_display(layout:PGtkTextLayout; line:PGtkTextLine; size_only:gboolean):PGtkTextLineDisplay; cdecl; external gtklib;
  170. procedure gtk_text_layout_free_line_display(layout:PGtkTextLayout; display:PGtkTextLineDisplay); cdecl; external gtklib;
  171. procedure gtk_text_layout_get_line_at_y(layout:PGtkTextLayout; target_iter:PGtkTextIter; y:gint; line_top:Pgint); cdecl; external gtklib;
  172. procedure gtk_text_layout_get_iter_at_pixel(layout:PGtkTextLayout; iter:PGtkTextIter; x:gint; y:gint); cdecl; external gtklib;
  173. procedure gtk_text_layout_invalidate(layout:PGtkTextLayout; start:PGtkTextIter; theEnd:PGtkTextIter); cdecl; external gtklib;
  174. procedure gtk_text_layout_free_line_data(layout:PGtkTextLayout; line:PGtkTextLine; line_data:PGtkTextLineData); cdecl; external gtklib;
  175. function gtk_text_layout_is_valid(layout:PGtkTextLayout):gboolean; cdecl; external gtklib;
  176. procedure gtk_text_layout_validate_yrange(layout:PGtkTextLayout; anchor_line:PGtkTextIter; y0:gint; y1:gint); cdecl; external gtklib;
  177. procedure gtk_text_layout_validate(layout:PGtkTextLayout; max_pixels:gint); cdecl; external gtklib;
  178. { This function should return the passed-in line data,
  179. OR remove the existing line data from the line, and
  180. return a NEW line data after adding it to the line.
  181. That is, invariant after calling the callback is that
  182. there should be exactly one line data for this view
  183. stored on the btree line.
  184. }
  185. function gtk_text_layout_wrap(layout:PGtkTextLayout; line:PGtkTextLine; line_data:PGtkTextLineData):PGtkTextLineData; cdecl; external gtklib;
  186. { may be NULL }
  187. procedure gtk_text_layout_changed(layout:PGtkTextLayout; y:gint; old_height:gint; new_height:gint); cdecl; external gtklib;
  188. procedure gtk_text_layout_get_iter_location(layout:PGtkTextLayout; iter:PGtkTextIter; rect:PGdkRectangle); cdecl; external gtklib;
  189. procedure gtk_text_layout_get_line_yrange(layout:PGtkTextLayout; iter:PGtkTextIter; y:Pgint; height:Pgint); cdecl; external gtklib;
  190. procedure _gtk_text_layout_get_line_xrange(layout:PGtkTextLayout; iter:PGtkTextIter; x:Pgint; width:Pgint); cdecl; external gtklib;
  191. procedure gtk_text_layout_get_cursor_locations(layout:PGtkTextLayout; iter:PGtkTextIter; strong_pos:PGdkRectangle; weak_pos:PGdkRectangle); cdecl; external gtklib;
  192. function gtk_text_layout_clamp_iter_to_vrange(layout:PGtkTextLayout; iter:PGtkTextIter; top:gint; bottom:gint):gboolean; cdecl; external gtklib;
  193. function gtk_text_layout_move_iter_to_line_end(layout:PGtkTextLayout; iter:PGtkTextIter; direction:gint):gboolean; cdecl; external gtklib;
  194. function gtk_text_layout_move_iter_to_previous_line(layout:PGtkTextLayout; iter:PGtkTextIter):gboolean; cdecl; external gtklib;
  195. function gtk_text_layout_move_iter_to_next_line(layout:PGtkTextLayout; iter:PGtkTextIter):gboolean; cdecl; external gtklib;
  196. procedure gtk_text_layout_move_iter_to_x(layout:PGtkTextLayout; iter:PGtkTextIter; x:gint); cdecl; external gtklib;
  197. function gtk_text_layout_move_iter_visually(layout:PGtkTextLayout; iter:PGtkTextIter; count:gint):gboolean; cdecl; external gtklib;
  198. function gtk_text_layout_iter_starts_line(layout:PGtkTextLayout; iter:PGtkTextIter):gboolean; cdecl; external gtklib;
  199. procedure gtk_text_layout_get_iter_at_line(layout:PGtkTextLayout; iter:PGtkTextIter; line:PGtkTextLine; byte_offset:gint); cdecl; external gtklib;
  200. { Don't use these. Use gtk_text_view_add_child_at_anchor().
  201. These functions are defined in gtktextchild.c, but here
  202. since they are semi-public and require GtkTextLayout to
  203. be declared.
  204. }
  205. procedure gtk_text_child_anchor_register_child(anchor:PGtkTextChildAnchor; child:PGtkWidget; layout:PGtkTextLayout); cdecl; external gtklib;
  206. procedure gtk_text_child_anchor_unregister_child(anchor:PGtkTextChildAnchor; child:PGtkWidget); cdecl; external gtklib;
  207. procedure gtk_text_child_anchor_queue_resize(anchor:PGtkTextChildAnchor; layout:PGtkTextLayout); cdecl; external gtklib;
  208. procedure gtk_text_anchored_child_set_layout(child:PGtkWidget; layout:PGtkTextLayout); cdecl; external gtklib;
  209. procedure gtk_text_layout_spew(layout:PGtkTextLayout); cdecl; external gtklib;
  210. {$ENDIF read_interface_rest}
  211. //------------------------------------------------------------------------------
  212. {$IFDEF read_implementation}
  213. function GTK_TYPE_TEXT_LAYOUT : GType;
  214. begin
  215. GTK_TYPE_TEXT_LAYOUT:=gtk_text_layout_get_type;
  216. end;
  217. function GTK_TEXT_LAYOUT(obj: pointer) : PGtkTextLayout;
  218. begin
  219. GTK_TEXT_LAYOUT:=PGtkTextLayout(G_TYPE_CHECK_INSTANCE_CAST(obj,GTK_TYPE_TEXT_LAYOUT));
  220. end;
  221. function GTK_TEXT_LAYOUT_CLASS(klass: pointer) : PGtkTextLayoutClass;
  222. begin
  223. GTK_TEXT_LAYOUT_CLASS:=PGtkTextLayoutClass(G_TYPE_CHECK_CLASS_CAST(klass,GTK_TYPE_TEXT_LAYOUT));
  224. end;
  225. function GTK_IS_TEXT_LAYOUT(obj: pointer) : boolean;
  226. begin
  227. GTK_IS_TEXT_LAYOUT:=G_TYPE_CHECK_INSTANCE_TYPE(obj,GTK_TYPE_TEXT_LAYOUT);
  228. end;
  229. function GTK_IS_TEXT_LAYOUT_CLASS(klass: pointer) : boolean;
  230. begin
  231. GTK_IS_TEXT_LAYOUT_CLASS:=G_TYPE_CHECK_CLASS_TYPE(klass,GTK_TYPE_TEXT_LAYOUT);
  232. end;
  233. function GTK_TEXT_LAYOUT_GET_CLASS(obj: pointer) : PGtkTextLayoutClass;
  234. begin
  235. GTK_TEXT_LAYOUT_GET_CLASS:=PGtkTextLayoutClass(G_TYPE_INSTANCE_GET_CLASS(obj,GTK_TYPE_TEXT_LAYOUT));
  236. end;
  237. function cursor_visible(var a : TGtkTextLayout) : guint;
  238. begin
  239. cursor_visible:=(a.flag0 and bm_TGtkTextLayout_cursor_visible) shr bp_TGtkTextLayout_cursor_visible;
  240. end;
  241. procedure set_cursor_visible(var a : TGtkTextLayout; __cursor_visible : guint);
  242. begin
  243. a.flag0:=a.flag0 or ((__cursor_visible shl bp_TGtkTextLayout_cursor_visible) and bm_TGtkTextLayout_cursor_visible);
  244. end;
  245. function cursor_direction(var a : TGtkTextLayout) : gint;
  246. begin
  247. cursor_direction:=(a.flag0 and bm_TGtkTextLayout_cursor_direction) shr bp_TGtkTextLayout_cursor_direction;
  248. end;
  249. procedure set_cursor_direction(var a : TGtkTextLayout; __cursor_direction : gint);
  250. begin
  251. a.flag0:=a.flag0 or ((__cursor_direction shl bp_TGtkTextLayout_cursor_direction) and bm_TGtkTextLayout_cursor_direction);
  252. end;
  253. function is_strong(var a : TGtkTextCursorDisplay) : guint;
  254. begin
  255. is_strong:=(a.flag0 and bm_TGtkTextCursorDisplay_is_strong) shr bp_TGtkTextCursorDisplay_is_strong;
  256. end;
  257. procedure set_is_strong(var a : TGtkTextCursorDisplay; __is_strong : guint);
  258. begin
  259. a.flag0:=a.flag0 or ((__is_strong shl bp_TGtkTextCursorDisplay_is_strong) and bm_TGtkTextCursorDisplay_is_strong);
  260. end;
  261. function is_weak(var a : TGtkTextCursorDisplay) : guint;
  262. begin
  263. is_weak:=(a.flag0 and bm_TGtkTextCursorDisplay_is_weak) shr bp_TGtkTextCursorDisplay_is_weak;
  264. end;
  265. procedure set_is_weak(var a : TGtkTextCursorDisplay; __is_weak : guint);
  266. begin
  267. a.flag0:=a.flag0 or ((__is_weak shl bp_TGtkTextCursorDisplay_is_weak) and bm_TGtkTextCursorDisplay_is_weak);
  268. end;
  269. {$ENDIF read_implementation}
  270. // included by gtk2.pas