TextSink.xml revision 994689c1
1994689c1Smrg<sect1 id="TextSink_Object"> 2994689c1Smrg<title>TextSink Object</title> 3994689c1Smrg<para> 4994689c1Smrg<!-- .LP --> 5994689c1Smrg<!-- .XS --> 6994689c1Smrg<!-- TextSink Object --> 7994689c1Smrg<!-- .XE --> 8994689c1Smrg<!-- .IN "TextSink object" "" "@DEF@" --> 9994689c1Smrg</para> 10994689c1Smrg<para> 11994689c1Smrg<!-- .LP --> 12994689c1Smrg<literallayout class="monospaced"> 13994689c1Smrg<!-- .TA 2.0i --> 14994689c1Smrg<!-- .ta 2.0i --> 15994689c1SmrgApplication Header file <X11/Xaw/TextSink.h> 16994689c1Smrg<!-- .IN "TextSink.h" "" --> 17994689c1SmrgClass Header file <X11/Xaw/TextSinkP.h> 18994689c1Smrg<!-- .IN "TextSinkP.h" "" --> 19994689c1SmrgClass textSinkObjectClass 20994689c1Smrg<!-- .IN "textSinkObjectClass" "" --> 21994689c1SmrgClass Name TextSink 22994689c1Smrg<!-- .IN "TextSink object" "class name" --> 23994689c1SmrgSuperclass Object 24994689c1Smrg</literallayout> 25994689c1Smrg</para> 26994689c1Smrg<para> 27994689c1Smrg<!-- .LP --> 28994689c1SmrgThe TextSink object is the root object for all text sinks. Any new text 29994689c1Smrgsink objects should be subclasses of the TextSink Object. The TextSink 30994689c1SmrgClass contains all methods that the Text widget expects a text sink to 31994689c1Smrgexport. 32994689c1Smrg</para> 33994689c1Smrg<para> 34994689c1Smrg<!-- .LP --> 35994689c1SmrgSince all text sinks will have some resources in common, the TextSink 36994689c1Smrgdefines a few new resources. 37994689c1Smrg</para> 38994689c1Smrg<sect2 id="textsink_resources"> 39994689c1Smrg<title>Resources</title> 40994689c1Smrg<para> 41994689c1Smrg<!-- .LP --> 42994689c1SmrgWhen creating an TextSink object instance, the following resources are 43994689c1Smrgretrieved from the argument list or from the resource database: 44994689c1Smrg</para> 45994689c1Smrg<para> 46994689c1Smrg<!-- .LP --> 47994689c1Smrg<!-- .IN "AsciiSink object" "resources" --> 48994689c1Smrg<informaltable> 49994689c1Smrg <tgroup cols='5' align='center'> 50994689c1Smrg <colspec colname='c1'/> 51994689c1Smrg <colspec colname='c2'/> 52994689c1Smrg <colspec colname='c3'/> 53994689c1Smrg <colspec colname='c4'/> 54994689c1Smrg <colspec colname='c5'/> 55994689c1Smrg <thead> 56994689c1Smrg <row> 57994689c1Smrg <entry>Name</entry> 58994689c1Smrg <entry>Class</entry> 59994689c1Smrg <entry>Type</entry> 60994689c1Smrg <entry>Notes</entry> 61994689c1Smrg <entry>Default Value</entry> 62994689c1Smrg </row> 63994689c1Smrg </thead> 64994689c1Smrg <tbody> 65994689c1Smrg <row> 66994689c1Smrg <entry>background</entry> 67994689c1Smrg <entry>Background</entry> 68994689c1Smrg <entry>Pixel</entry> 69994689c1Smrg <entry></entry> 70994689c1Smrg <entry>XtDefaultBackground</entry> 71994689c1Smrg </row> 72994689c1Smrg <row> 73994689c1Smrg <entry>destroyCallback</entry> 74994689c1Smrg <entry>Callback</entry> 75994689c1Smrg <entry>XtCallbackList</entry> 76994689c1Smrg <entry></entry> 77994689c1Smrg <entry>NULL</entry> 78994689c1Smrg </row> 79994689c1Smrg <row> 80994689c1Smrg <entry>foreground</entry> 81994689c1Smrg <entry>Foreground</entry> 82994689c1Smrg <entry>Pixel</entry> 83994689c1Smrg <entry></entry> 84994689c1Smrg <entry>XtDefaultForeground</entry> 85994689c1Smrg </row> 86994689c1Smrg <row> 87994689c1Smrg <entry>_</entry> 88994689c1Smrg </row> 89994689c1Smrg </tbody> 90994689c1Smrg </tgroup> 91994689c1Smrg</informaltable> 92994689c1Smrg<!-- .Bg Bold --> 93994689c1Smrg<!-- .Dc --> 94994689c1Smrg<!-- .Sg Bold --> 95994689c1Smrg</para> 96994689c1Smrg</sect2> 97994689c1Smrg<sect2 id="Subclassing_the_TextSink"> 98994689c1Smrg<title>Subclassing the TextSink</title> 99994689c1Smrg<!-- .IN "TextSink object" "subclassing" "@DEF@" --> 100994689c1Smrg<para> 101994689c1Smrg<!-- .LP --> 102994689c1SmrgThe only purpose of the TextSink Object is to be subclassed. It 103994689c1Smrgcontains the minimum set of class methods that all text sinks must have. 104994689c1SmrgWhile all may be inherited, the direct descendant of TextSink <function>must 105994689c1Smrgspecify</function> some of them as TextSink does contain enough information to 106994689c1Smrgbe a valid text sink by itself. Do not try to use 107994689c1Smrgthe TextSink as a valid sink for the Text widget; it is not intended 108994689c1Smrgto be used as a sink by itself. 109994689c1Smrg<informaltable> 110994689c1Smrg <tgroup cols='4' align='center'> 111994689c1Smrg <colspec colname='c1'/> 112994689c1Smrg <colspec colname='c2'/> 113994689c1Smrg <colspec colname='c3'/> 114994689c1Smrg <colspec colname='c4'/> 115994689c1Smrg <thead> 116994689c1Smrg <row> 117994689c1Smrg <entry>Function</entry> 118994689c1Smrg <entry>Inherit with</entry> 119994689c1Smrg <entry>Public Interface</entry> 120994689c1Smrg <entry>must specify</entry> 121994689c1Smrg </row> 122994689c1Smrg </thead> 123994689c1Smrg <tbody> 124994689c1Smrg <row> 125994689c1Smrg <entry>DisplayText</entry> 126994689c1Smrg <entry>XtInheritDisplayText</entry> 127994689c1Smrg <entry>XawTextSinkDisplayText</entry> 128994689c1Smrg <entry>yes</entry> 129994689c1Smrg </row> 130994689c1Smrg <row> 131994689c1Smrg <entry>InsertCursor</entry> 132994689c1Smrg <entry>XtInheritInsertCursor</entry> 133994689c1Smrg <entry>XawTextSinkInsertCursor</entry> 134994689c1Smrg <entry>yes</entry> 135994689c1Smrg </row> 136994689c1Smrg <row> 137994689c1Smrg <entry>ClearToBackground</entry> 138994689c1Smrg <entry>XtInheritClearToBackground</entry> 139994689c1Smrg <entry>XawTextSinkClearToBackground</entry> 140994689c1Smrg <entry>no</entry> 141994689c1Smrg </row> 142994689c1Smrg <row> 143994689c1Smrg <entry>FindPosition</entry> 144994689c1Smrg <entry>XtInheritFindPosition</entry> 145994689c1Smrg <entry>XawTextSinkFindPosition</entry> 146994689c1Smrg <entry>yes</entry> 147994689c1Smrg </row> 148994689c1Smrg <row> 149994689c1Smrg <entry>FindDistance</entry> 150994689c1Smrg <entry>XtInheritFindDistance</entry> 151994689c1Smrg <entry>XawTextSinkFindDistance</entry> 152994689c1Smrg <entry>yes</entry> 153994689c1Smrg </row> 154994689c1Smrg <row> 155994689c1Smrg <entry>Resolve</entry> 156994689c1Smrg <entry>XtInheritResolve</entry> 157994689c1Smrg <entry>XawTextSinkResolve</entry> 158994689c1Smrg <entry>yes</entry> 159994689c1Smrg </row> 160994689c1Smrg <row> 161994689c1Smrg <entry>MaxLines</entry> 162994689c1Smrg <entry>XtInheritMaxLines</entry> 163994689c1Smrg <entry>XawTextSinkMaxLines</entry> 164994689c1Smrg <entry>no</entry> 165994689c1Smrg </row> 166994689c1Smrg <row> 167994689c1Smrg <entry>MaxHeight</entry> 168994689c1Smrg <entry>XtInheritMaxHeight</entry> 169994689c1Smrg <entry>XawTextSinkMaxHeight</entry> 170994689c1Smrg <entry>no</entry> 171994689c1Smrg </row> 172994689c1Smrg <row> 173994689c1Smrg <entry>SetTabs</entry> 174994689c1Smrg <entry>XtInheritSetTabs</entry> 175994689c1Smrg <entry>XawTextSinkSetTabs</entry> 176994689c1Smrg <entry>no</entry> 177994689c1Smrg </row> 178994689c1Smrg <row> 179994689c1Smrg <entry>GetCursorBounds</entry> 180994689c1Smrg <entry>XtInheritGetCursorBounds</entry> 181994689c1Smrg <entry>XawTextSinkGetCursorBounds</entry> 182994689c1Smrg <entry>yes</entry> 183994689c1Smrg </row> 184994689c1Smrg </tbody> 185994689c1Smrg </tgroup> 186994689c1Smrg</informaltable> 187994689c1Smrg</para> 188994689c1Smrg<sect3 id="Displaying_Text"> 189994689c1Smrg<title>Displaying Text</title> 190994689c1Smrg<para> 191994689c1Smrg<!-- .LP --> 192994689c1SmrgTo display a section of the text buffer contained in the text source 193994689c1Smrguse the function <function>DisplayText</function>: 194994689c1Smrg<!-- .IN "TextSink object" "DisplayText" "@DEF@" --> 195994689c1Smrg<funcsynopsis> 196994689c1Smrg<funcprototype> 197994689c1Smrg <funcdef>void<function> DisplayText</function></funcdef> 198994689c1Smrg <paramdef>Widget<parameter> w</parameter></paramdef> 199994689c1Smrg <paramdef>Positionx,<parameter> y</parameter></paramdef> 200994689c1Smrg <paramdef>XawTextPositionpos1,<parameter> pos2</parameter></paramdef> 201994689c1Smrg <paramdef>Boolean<parameter> highlight</parameter></paramdef> 202994689c1Smrg</funcprototype> 203994689c1Smrg</funcsynopsis> 204994689c1Smrg<!-- .FN --> 205994689c1Smrg<variablelist> 206994689c1Smrg <varlistentry> 207994689c1Smrg <term> 208994689c1Smrg <emphasis remap='I'>w</emphasis> 209994689c1Smrg </term> 210994689c1Smrg <listitem> 211994689c1Smrg <para> 212994689c1SmrgSpecifies the TextSink object. 213994689c1Smrg </para> 214994689c1Smrg </listitem> 215994689c1Smrg </varlistentry> 216994689c1Smrg <varlistentry> 217994689c1Smrg <term> 218994689c1Smrg <emphasis remap='I'>x</emphasis> 219994689c1Smrg </term> 220994689c1Smrg <listitem> 221994689c1Smrg <para> 222994689c1SmrgSpecifies the x location to start drawing the text. 223994689c1Smrg </para> 224994689c1Smrg </listitem> 225994689c1Smrg </varlistentry> 226994689c1Smrg <varlistentry> 227994689c1Smrg <term> 228994689c1Smrg <emphasis remap='I'>y</emphasis> 229994689c1Smrg </term> 230994689c1Smrg <listitem> 231994689c1Smrg <para> 232994689c1SmrgSpecifies the y location to start drawing text. 233994689c1Smrg </para> 234994689c1Smrg </listitem> 235994689c1Smrg </varlistentry> 236994689c1Smrg <varlistentry> 237994689c1Smrg <term> 238994689c1Smrg <emphasis remap='I'>pos1</emphasis> 239994689c1Smrg </term> 240994689c1Smrg <listitem> 241994689c1Smrg <para> 242994689c1SmrgSpecifies the location within the text source of the first character 243994689c1Smrgto be printed. 244994689c1Smrg </para> 245994689c1Smrg </listitem> 246994689c1Smrg </varlistentry> 247994689c1Smrg <varlistentry> 248994689c1Smrg <term> 249994689c1Smrg <emphasis remap='I'>pos2</emphasis> 250994689c1Smrg </term> 251994689c1Smrg <listitem> 252994689c1Smrg <para> 253994689c1SmrgSpecifies the location within the text source of the last character 254994689c1Smrgto be printed. 255994689c1Smrg </para> 256994689c1Smrg </listitem> 257994689c1Smrg </varlistentry> 258994689c1Smrg <varlistentry> 259994689c1Smrg <term> 260994689c1Smrg <emphasis remap='I'>highlight</emphasis> 261994689c1Smrg </term> 262994689c1Smrg <listitem> 263994689c1Smrg <para> 264994689c1SmrgSpecifies whether or not to paint the text region highlighted. 265994689c1Smrg </para> 266994689c1Smrg </listitem> 267994689c1Smrg </varlistentry> 268994689c1Smrg</variablelist> 269994689c1Smrg</para> 270994689c1Smrg<para> 271994689c1Smrg<!-- .LP --> 272994689c1SmrgThe Text widget will only pass one line at a time to the text sink, so 273994689c1Smrgthis function does not need to know how to line feed the text. It is 274994689c1Smrgacceptable for this function to just ignore Carriage Returns. <emphasis remap='I'>x</emphasis> 275994689c1Smrgand <emphasis remap='I'>y</emphasis> denote the upper left hand corner of the first character to 276994689c1Smrgbe displayed. 277994689c1Smrg</para> 278994689c1Smrg</sect3> 279994689c1Smrg<sect3 id="Displaying_the_Insert_Point"> 280994689c1Smrg<title>Displaying the Insert Point</title> 281994689c1Smrg<para> 282994689c1Smrg<!-- .LP --> 283994689c1SmrgThe function that controls the display of the text cursor is 284994689c1Smrg<function>InsertCursor</function>. This function will be called whenever the text 285994689c1Smrgwidget desires to change the state of, or move the insert point. 286994689c1Smrg<funcsynopsis> 287994689c1Smrg<funcprototype> 288994689c1Smrg <funcdef>void<function> InsertCursor</function></funcdef> 289994689c1Smrg <paramdef>Widget<parameter> w</parameter></paramdef> 290994689c1Smrg <paramdef>Positionx,<parameter> y</parameter></paramdef> 291994689c1Smrg <paramdef>XawTextInsertState<parameter> state</parameter></paramdef> 292994689c1Smrg</funcprototype> 293994689c1Smrg</funcsynopsis> 294994689c1Smrg<!-- .FN --> 295994689c1Smrg<variablelist> 296994689c1Smrg <varlistentry> 297994689c1Smrg <term> 298994689c1Smrg <emphasis remap='I'>w</emphasis> 299994689c1Smrg </term> 300994689c1Smrg <listitem> 301994689c1Smrg <para> 302994689c1SmrgSpecifies the TextSink object. 303994689c1Smrg </para> 304994689c1Smrg </listitem> 305994689c1Smrg </varlistentry> 306994689c1Smrg <varlistentry> 307994689c1Smrg <term> 308994689c1Smrg <emphasis remap='I'>x</emphasis> 309994689c1Smrg </term> 310994689c1Smrg <listitem> 311994689c1Smrg <para> 312994689c1SmrgSpecifies the x location of the cursor in Pixels. 313994689c1Smrg </para> 314994689c1Smrg </listitem> 315994689c1Smrg </varlistentry> 316994689c1Smrg <varlistentry> 317994689c1Smrg <term> 318994689c1Smrg <emphasis remap='I'>y</emphasis> 319994689c1Smrg </term> 320994689c1Smrg <listitem> 321994689c1Smrg <para> 322994689c1SmrgSpecifies the y location of the cursor in Pixels. 323994689c1Smrg </para> 324994689c1Smrg </listitem> 325994689c1Smrg </varlistentry> 326994689c1Smrg <varlistentry> 327994689c1Smrg <term> 328994689c1Smrg <emphasis remap='I'>state</emphasis> 329994689c1Smrg </term> 330994689c1Smrg <listitem> 331994689c1Smrg <para> 332994689c1SmrgSpecifies the state of the cursor, may be one of <function>XawisOn</function> or 333994689c1Smrg<function>XawisOff</function>. 334994689c1Smrg </para> 335994689c1Smrg </listitem> 336994689c1Smrg </varlistentry> 337994689c1Smrg</variablelist> 338994689c1Smrg</para> 339994689c1Smrg<para> 340994689c1Smrg<!-- .LP --> 341994689c1Smrg<emphasis remap='I'>X</emphasis> and <emphasis remap='I'>y</emphasis> denote the upper left hand corner of the insert point. 342994689c1Smrg</para> 343994689c1Smrg</sect3> 344994689c1Smrg<sect3 id="Clearing_Portions_of_the_Text_window"> 345994689c1Smrg<title>Clearing Portions of the Text window</title> 346994689c1Smrg<para> 347994689c1Smrg<!-- .LP --> 348994689c1SmrgTo clear a portion of the Text window to its background color, the Text 349994689c1Smrgwidget will call <function>ClearToBackground</function>. The TextSink object already 350994689c1Smrgdefines this function as calling <function>XClearArea</function> on the region passed. 351994689c1SmrgThis behavior will be used if you specify 352994689c1Smrg<function>XtInheritClearToBackground</function> for this method. 353994689c1Smrg<!-- .IN "XtInheritClearToBackground" "" --> 354994689c1Smrg<!-- .IN "TextSink object" "ClearToBackground" "@DEF@" --> 355994689c1Smrg<funcsynopsis> 356994689c1Smrg<funcprototype> 357994689c1Smrg <funcdef>void<function> ClearToBackground</function></funcdef> 358994689c1Smrg <paramdef>Widget<parameter> w</parameter></paramdef> 359994689c1Smrg <paramdef>Positionx,<parameter> y</parameter></paramdef> 360994689c1Smrg <paramdef>Dimensionwidth,<parameter> height</parameter></paramdef> 361994689c1Smrg</funcprototype> 362994689c1Smrg</funcsynopsis> 363994689c1Smrg<!-- .FN --> 364994689c1Smrg<variablelist> 365994689c1Smrg <varlistentry> 366994689c1Smrg <term> 367994689c1Smrg <emphasis remap='I'>w</emphasis> 368994689c1Smrg </term> 369994689c1Smrg <listitem> 370994689c1Smrg <para> 371994689c1SmrgSpecifies the TextSink object. 372994689c1Smrg </para> 373994689c1Smrg </listitem> 374994689c1Smrg </varlistentry> 375994689c1Smrg <varlistentry> 376994689c1Smrg <term> 377994689c1Smrg <emphasis remap='I'>x</emphasis> 378994689c1Smrg </term> 379994689c1Smrg <listitem> 380994689c1Smrg <para> 381994689c1SmrgSpecifies the x location, in pixels, of the Region to clear. 382994689c1Smrg </para> 383994689c1Smrg </listitem> 384994689c1Smrg </varlistentry> 385994689c1Smrg <varlistentry> 386994689c1Smrg <term> 387994689c1Smrg <emphasis remap='I'>y</emphasis> 388994689c1Smrg </term> 389994689c1Smrg <listitem> 390994689c1Smrg <para> 391994689c1SmrgSpecifies the y location, in pixels, of the Region to clear. 392994689c1Smrg </para> 393994689c1Smrg </listitem> 394994689c1Smrg </varlistentry> 395994689c1Smrg <varlistentry> 396994689c1Smrg <term> 397994689c1Smrg <emphasis remap='I'>width</emphasis> 398994689c1Smrg </term> 399994689c1Smrg <listitem> 400994689c1Smrg <para> 401994689c1SmrgSpecifies the width, in pixels, of the Region to clear. 402994689c1Smrg </para> 403994689c1Smrg </listitem> 404994689c1Smrg </varlistentry> 405994689c1Smrg <varlistentry> 406994689c1Smrg <term> 407994689c1Smrg <emphasis remap='I'>height</emphasis> 408994689c1Smrg </term> 409994689c1Smrg <listitem> 410994689c1Smrg <para> 411994689c1SmrgSpecifies the height, in pixels, of the Region to clear. 412994689c1Smrg </para> 413994689c1Smrg </listitem> 414994689c1Smrg </varlistentry> 415994689c1Smrg</variablelist> 416994689c1Smrg</para> 417994689c1Smrg<para> 418994689c1Smrg<!-- .LP --> 419994689c1Smrg<emphasis remap='I'>X</emphasis> and <emphasis remap='I'>y</emphasis> denote the upper left hand corner of region to clear. 420994689c1Smrg</para> 421994689c1Smrg</sect3> 422994689c1Smrg<sect3 id="Finding_a_Text_Position_Given_Pixel_Values"> 423994689c1Smrg<title>Finding a Text Position Given Pixel Values</title> 424994689c1Smrg<para> 425994689c1Smrg<!-- .LP --> 426994689c1SmrgTo find the text character position that will be rendered at a given x 427994689c1Smrglocation the Text widget uses the function <function>FindPosition</function>: 428994689c1Smrg<!-- .IN "TextSink object" "FindPosition" "@DEF@" --> 429994689c1Smrg<funcsynopsis> 430994689c1Smrg<funcprototype> 431994689c1Smrg <funcdef>void<function> FindPosition</function></funcdef> 432994689c1Smrg <paramdef>Widget<parameter> w</parameter></paramdef> 433994689c1Smrg <paramdef>XawTextPosition<parameter> fromPos</parameter></paramdef> 434994689c1Smrg <paramdef>intfromX,<parameter> width</parameter></paramdef> 435994689c1Smrg <paramdef>Boolean<parameter> stopAtWordBreak</parameter></paramdef> 436994689c1Smrg <paramdef>XawTextPosition<parameter> *pos_return</parameter></paramdef> 437994689c1Smrg <paramdef>int*width_return,<parameter> *height_return</parameter></paramdef> 438994689c1Smrg</funcprototype> 439994689c1Smrg</funcsynopsis> 440994689c1Smrg<!-- .FN --> 441994689c1Smrg<variablelist> 442994689c1Smrg <varlistentry> 443994689c1Smrg <term> 444994689c1Smrg <emphasis remap='I'>w</emphasis> 445994689c1Smrg </term> 446994689c1Smrg <listitem> 447994689c1Smrg <para> 448994689c1SmrgSpecifies the TextSink object. 449994689c1Smrg </para> 450994689c1Smrg </listitem> 451994689c1Smrg </varlistentry> 452994689c1Smrg <varlistentry> 453994689c1Smrg <term> 454994689c1Smrg <emphasis remap='I'>fromPos</emphasis> 455994689c1Smrg </term> 456994689c1Smrg <listitem> 457994689c1Smrg <para> 458994689c1SmrgSpecifies a reference position, usually the first character in this line. 459994689c1SmrgThis character is always to the left of the desired character location. 460994689c1Smrg </para> 461994689c1Smrg </listitem> 462994689c1Smrg </varlistentry> 463994689c1Smrg <varlistentry> 464994689c1Smrg <term> 465994689c1Smrg <emphasis remap='I'>fromX</emphasis> 466994689c1Smrg </term> 467994689c1Smrg <listitem> 468994689c1Smrg <para> 469994689c1SmrgSpecifies the distance that the left edge of <emphasis remap='I'>fromPos</emphasis> is from the 470994689c1Smrgleft edge of the window. This is the reference x location for the 471994689c1Smrgreference position. 472994689c1Smrg </para> 473994689c1Smrg </listitem> 474994689c1Smrg </varlistentry> 475994689c1Smrg <varlistentry> 476994689c1Smrg <term> 477994689c1Smrg <emphasis remap='I'>width</emphasis> 478994689c1Smrg </term> 479994689c1Smrg <listitem> 480994689c1Smrg <para> 481994689c1SmrgSpecifies the distance, in pixels, from the reference position to the 482994689c1Smrgdesired character position. 483994689c1Smrg </para> 484994689c1Smrg </listitem> 485994689c1Smrg </varlistentry> 486994689c1Smrg <varlistentry> 487994689c1Smrg <term> 488994689c1Smrg <emphasis remap='I'>stopAtWordBreak</emphasis> 489994689c1Smrg </term> 490994689c1Smrg <listitem> 491994689c1Smrg <para> 492994689c1SmrgSpecifies whether or not the position that is returned should be forced 493994689c1Smrgto be on a word boundary. 494994689c1Smrg </para> 495994689c1Smrg </listitem> 496994689c1Smrg </varlistentry> 497994689c1Smrg <varlistentry> 498994689c1Smrg <term> 499994689c1Smrg <emphasis remap='I'>pos_return</emphasis> 500994689c1Smrg </term> 501994689c1Smrg <listitem> 502994689c1Smrg <para> 503994689c1SmrgReturns the character position that corresponds to the location that has 504994689c1Smrgbeen specified, or the work break immediately to the left of the 505994689c1Smrgposition if <emphasis remap='I'>stopAtWordBreak</emphasis> is <function>True</function>. 506994689c1Smrg </para> 507994689c1Smrg </listitem> 508994689c1Smrg </varlistentry> 509994689c1Smrg <varlistentry> 510994689c1Smrg <term> 511994689c1Smrg <emphasis remap='I'>width_return</emphasis> 512994689c1Smrg </term> 513994689c1Smrg <listitem> 514994689c1Smrg <para> 515994689c1SmrgReturns the actual distance between <emphasis remap='I'>fromPos</emphasis> and <emphasis remap='I'>pos_return</emphasis>. 516994689c1Smrg </para> 517994689c1Smrg </listitem> 518994689c1Smrg </varlistentry> 519994689c1Smrg <varlistentry> 520994689c1Smrg <term> 521994689c1Smrg <emphasis remap='I'>height_return</emphasis> 522994689c1Smrg </term> 523994689c1Smrg <listitem> 524994689c1Smrg <para> 525994689c1SmrgReturns the maximum height of the text between <emphasis remap='I'>fromPos</emphasis> and 526994689c1Smrg<emphasis remap='I'>pos_return</emphasis>. 527994689c1Smrg </para> 528994689c1Smrg </listitem> 529994689c1Smrg </varlistentry> 530994689c1Smrg</variablelist> 531994689c1Smrg</para> 532994689c1Smrg<para> 533994689c1Smrg<!-- .LP --> 534994689c1SmrgThis function need make no attempt to deal with line feeds. The text 535994689c1Smrgwidget will only call it one line at a time. 536994689c1Smrg</para> 537994689c1Smrg<para> 538994689c1Smrg<!-- .LP --> 539994689c1Smrg<!-- .sp --> 540994689c1SmrgAnother means of finding a text position is provided by the <function>Resolve</function> 541994689c1Smrgfunction: 542994689c1Smrg<!-- .IN "TextSink object" "Resolve" "@DEF@" --> 543994689c1Smrg<funcsynopsis> 544994689c1Smrg<funcprototype> 545994689c1Smrg <funcdef>void<function> Resolve</function></funcdef> 546994689c1Smrg <paramdef>Widget<parameter> w</parameter></paramdef> 547994689c1Smrg <paramdef>XawTextPosition<parameter> fromPos</parameter></paramdef> 548994689c1Smrg <paramdef>intfromX,<parameter> width</parameter></paramdef> 549994689c1Smrg <paramdef>XawTextPosition<parameter> *pos_return</parameter></paramdef> 550994689c1Smrg</funcprototype> 551994689c1Smrg</funcsynopsis> 552994689c1Smrg<!-- .FN --> 553994689c1Smrg<variablelist> 554994689c1Smrg <varlistentry> 555994689c1Smrg <term> 556994689c1Smrg <emphasis remap='I'>w</emphasis> 557994689c1Smrg </term> 558994689c1Smrg <listitem> 559994689c1Smrg <para> 560994689c1SmrgSpecifies the TextSink object. 561994689c1Smrg </para> 562994689c1Smrg </listitem> 563994689c1Smrg </varlistentry> 564994689c1Smrg <varlistentry> 565994689c1Smrg <term> 566994689c1Smrg <emphasis remap='I'>fromPos</emphasis> 567994689c1Smrg </term> 568994689c1Smrg <listitem> 569994689c1Smrg <para> 570994689c1SmrgSpecifies a reference position, usually the first character in this line. 571994689c1SmrgThis character is always to the left of the desired character location. 572994689c1Smrg </para> 573994689c1Smrg </listitem> 574994689c1Smrg </varlistentry> 575994689c1Smrg <varlistentry> 576994689c1Smrg <term> 577994689c1Smrg <emphasis remap='I'>fromX</emphasis> 578994689c1Smrg </term> 579994689c1Smrg <listitem> 580994689c1Smrg <para> 581994689c1SmrgSpecifies the distance that the left edge of <emphasis remap='I'>fromPos</emphasis> is from the 582994689c1Smrgleft edge of the window. This is the reference x location for the 583994689c1Smrgreference position. 584994689c1Smrg </para> 585994689c1Smrg </listitem> 586994689c1Smrg </varlistentry> 587994689c1Smrg <varlistentry> 588994689c1Smrg <term> 589994689c1Smrg <emphasis remap='I'>width</emphasis> 590994689c1Smrg </term> 591994689c1Smrg <listitem> 592994689c1Smrg <para> 593994689c1SmrgSpecifies the distance, in pixels, from the reference position to the 594994689c1Smrgdesired character position. 595994689c1Smrg </para> 596994689c1Smrg </listitem> 597994689c1Smrg </varlistentry> 598994689c1Smrg <varlistentry> 599994689c1Smrg <term> 600994689c1Smrg <emphasis remap='I'>pos_return</emphasis> 601994689c1Smrg </term> 602994689c1Smrg <listitem> 603994689c1Smrg <para> 604994689c1SmrgReturns the character position that corresponds to the 605994689c1Smrglocation that has been specified, or the word break immediately to the left 606994689c1Smrgif <emphasis remap='I'>stopAtWordBreak</emphasis> is <function>True</function>. 607994689c1Smrg </para> 608994689c1Smrg </listitem> 609994689c1Smrg </varlistentry> 610994689c1Smrg</variablelist> 611994689c1Smrg</para> 612994689c1Smrg<para> 613994689c1Smrg<!-- .LP --> 614994689c1SmrgThis function need make no attempt to deal with line feeds. The text 615994689c1Smrgwidget will only call it one line at a time. This is a more convenient 616994689c1Smrginterface to the <function>FindPosition</function> function, and provides a subset of its 617994689c1Smrgfunctionality. 618994689c1Smrg<!-- .IN "FindPosition" "" --> 619994689c1Smrg</para> 620994689c1Smrg</sect3> 621994689c1Smrg<sect3 id="Finding_the_Distance_Between_two_Text_Positions"> 622994689c1Smrg<title>Finding the Distance Between two Text Positions</title> 623994689c1Smrg<para> 624994689c1Smrg<!-- .LP --> 625994689c1SmrgTo find the distance in pixels between two text positions on the same 626994689c1Smrgline use the function <function>FindDistance</function>. 627994689c1Smrg<!-- .IN "TextSink object" "FindDistance" "@DEF@" --> 628994689c1Smrg<funcsynopsis> 629994689c1Smrg<funcprototype> 630994689c1Smrg <funcdef>void<function> FindDistance</function></funcdef> 631994689c1Smrg <paramdef>Widget<parameter> w</parameter></paramdef> 632994689c1Smrg <paramdef>XawTextPositionfromPos,<parameter> toPos</parameter></paramdef> 633994689c1Smrg <paramdef>int<parameter> fromX</parameter></paramdef> 634994689c1Smrg <paramdef>XawTextPosition<parameter> *pos_return</parameter></paramdef> 635994689c1Smrg <paramdef>int*width_return,<parameter> *height_return</parameter></paramdef> 636994689c1Smrg</funcprototype> 637994689c1Smrg</funcsynopsis> 638994689c1Smrg<!-- .FN --> 639994689c1Smrg<variablelist> 640994689c1Smrg <varlistentry> 641994689c1Smrg <term> 642994689c1Smrg <emphasis remap='I'>w</emphasis> 643994689c1Smrg </term> 644994689c1Smrg <listitem> 645994689c1Smrg <para> 646994689c1SmrgSpecifies the TextSink object. 647994689c1Smrg </para> 648994689c1Smrg </listitem> 649994689c1Smrg </varlistentry> 650994689c1Smrg <varlistentry> 651994689c1Smrg <term> 652994689c1Smrg <emphasis remap='I'>fromPos</emphasis> 653994689c1Smrg </term> 654994689c1Smrg <listitem> 655994689c1Smrg <para> 656994689c1SmrgSpecifies the text buffer position, in characters, of the first position. 657994689c1Smrg </para> 658994689c1Smrg </listitem> 659994689c1Smrg </varlistentry> 660994689c1Smrg <varlistentry> 661994689c1Smrg <term> 662994689c1Smrg <emphasis remap='I'>fromX</emphasis> 663994689c1Smrg </term> 664994689c1Smrg <listitem> 665994689c1Smrg <para> 666994689c1SmrgSpecifies the distance that the left edge of <emphasis remap='I'>fromPos</emphasis> is from the 667994689c1Smrgleft edge of the window. This is the reference x location for the 668994689c1Smrgreference position. 669994689c1Smrg </para> 670994689c1Smrg </listitem> 671994689c1Smrg </varlistentry> 672994689c1Smrg <varlistentry> 673994689c1Smrg <term> 674994689c1Smrg <emphasis remap='I'>toPos</emphasis> 675994689c1Smrg </term> 676994689c1Smrg <listitem> 677994689c1Smrg <para> 678994689c1SmrgSpecifies the text buffer position, in characters, of the second position. 679994689c1Smrg </para> 680994689c1Smrg </listitem> 681994689c1Smrg </varlistentry> 682994689c1Smrg <varlistentry> 683994689c1Smrg <term> 684994689c1Smrg <emphasis remap='I'>resWidth</emphasis> 685994689c1Smrg </term> 686994689c1Smrg <listitem> 687994689c1Smrg <para> 688994689c1SmrgReturn the actual distance between <emphasis remap='I'>fromPos</emphasis> 689994689c1Smrgand <emphasis remap='I'>pos_return</emphasis>. 690994689c1Smrg </para> 691994689c1Smrg </listitem> 692994689c1Smrg </varlistentry> 693994689c1Smrg <varlistentry> 694994689c1Smrg <term> 695994689c1Smrg <emphasis remap='I'>resPos</emphasis> 696994689c1Smrg </term> 697994689c1Smrg <listitem> 698994689c1Smrg <para> 699994689c1SmrgReturns the character position that corresponds to the actual character 700994689c1Smrgposition used for <emphasis remap='I'>toPos</emphasis> in the calculations. This may be 701994689c1Smrgdifferent than <emphasis remap='I'>toPos</emphasis>, for example if <emphasis remap='I'>fromPos</emphasis> and <emphasis remap='I'>toPos</emphasis> 702994689c1Smrgare on different lines in the file. 703994689c1Smrg </para> 704994689c1Smrg </listitem> 705994689c1Smrg </varlistentry> 706994689c1Smrg <varlistentry> 707994689c1Smrg <term> 708994689c1Smrg <emphasis remap='I'>height_return</emphasis> 709994689c1Smrg </term> 710994689c1Smrg <listitem> 711994689c1Smrg <para> 712994689c1SmrgReturns the maximum height of the text between <emphasis remap='I'>fromPos</emphasis> and 713994689c1Smrg<emphasis remap='I'>pos_return</emphasis>. 714994689c1Smrg </para> 715994689c1Smrg </listitem> 716994689c1Smrg </varlistentry> 717994689c1Smrg</variablelist> 718994689c1Smrg</para> 719994689c1Smrg<para> 720994689c1Smrg<!-- .LP --> 721994689c1SmrgThis function need make no attempt to deal with line feeds. The Text 722994689c1Smrgwidget will only call it one line at a time. 723994689c1Smrg</para> 724994689c1Smrg</sect3> 725994689c1Smrg<sect3 id="Finding_the_Size_of_the_Drawing_area"> 726994689c1Smrg<title>Finding the Size of the Drawing area</title> 727994689c1Smrg<para> 728994689c1Smrg<!-- .LP --> 729994689c1SmrgTo find the maximum number of lines that will fit into the current Text 730994689c1Smrgwidget, use the function <function>MaxLines</function>. The TextSink already defines 731994689c1Smrgthis function to compute the maximum number of lines by using the height 732994689c1Smrgof <function>font</function>. 733994689c1Smrg<!-- .IN "TextSink object" "MaxLines" "@DEF@" --> 734994689c1Smrg<funcsynopsis> 735994689c1Smrg<funcprototype> 736994689c1Smrg <funcdef>int<function> MaxLines</function></funcdef> 737994689c1Smrg <paramdef>Widget<parameter> w</parameter></paramdef> 738994689c1Smrg <paramdef>Dimension<parameter> height</parameter></paramdef> 739994689c1Smrg</funcprototype> 740994689c1Smrg</funcsynopsis> 741994689c1Smrg<!-- .FN --> 742994689c1Smrg<variablelist> 743994689c1Smrg <varlistentry> 744994689c1Smrg <term> 745994689c1Smrg <emphasis remap='I'>w</emphasis> 746994689c1Smrg </term> 747994689c1Smrg <listitem> 748994689c1Smrg <para> 749994689c1SmrgSpecifies the TextSink object. 750994689c1Smrg </para> 751994689c1Smrg </listitem> 752994689c1Smrg </varlistentry> 753994689c1Smrg <varlistentry> 754994689c1Smrg <term> 755994689c1Smrg <emphasis remap='I'>height</emphasis> 756994689c1Smrg </term> 757994689c1Smrg <listitem> 758994689c1Smrg <para> 759994689c1SmrgSpecifies the height of the current drawing area. 760994689c1Smrg </para> 761994689c1Smrg </listitem> 762994689c1Smrg </varlistentry> 763994689c1Smrg</variablelist> 764994689c1Smrg</para> 765994689c1Smrg<para> 766994689c1Smrg<!-- .LP --> 767994689c1SmrgReturns the maximum number of lines that will fit in <emphasis remap='I'>height</emphasis>. 768994689c1Smrg</para> 769994689c1Smrg<para> 770994689c1Smrg<!-- .LP --> 771994689c1Smrg<!-- .sp --> 772994689c1SmrgTo find the height required for a given number of text lines, use 773994689c1Smrgthe function <function>MaxHeight</function>. The TextSink already defines this 774994689c1Smrgfunction to compute the maximum height of the window by using the 775994689c1Smrgheight of <function>font</function>. 776994689c1Smrg<!-- .IN "TextSink object" "MaxHeight" "@DEF@" --> 777994689c1Smrg<funcsynopsis> 778994689c1Smrg<funcprototype> 779994689c1Smrg <funcdef>int<function> MaxHeight</function></funcdef> 780994689c1Smrg <paramdef>Widget<parameter> w</parameter></paramdef> 781994689c1Smrg <paramdef>int<parameter> lines</parameter></paramdef> 782994689c1Smrg</funcprototype> 783994689c1Smrg</funcsynopsis> 784994689c1Smrg<!-- .FN --> 785994689c1Smrg<variablelist> 786994689c1Smrg <varlistentry> 787994689c1Smrg <term> 788994689c1Smrg <emphasis remap='I'>w</emphasis> 789994689c1Smrg </term> 790994689c1Smrg <listitem> 791994689c1Smrg <para> 792994689c1SmrgSpecifies the TextSink object. 793994689c1Smrg </para> 794994689c1Smrg </listitem> 795994689c1Smrg </varlistentry> 796994689c1Smrg <varlistentry> 797994689c1Smrg <term> 798994689c1Smrg <emphasis remap='I'>height</emphasis> 799994689c1Smrg </term> 800994689c1Smrg <listitem> 801994689c1Smrg <para> 802994689c1SmrgSpecifies the height of the current drawing area. 803994689c1Smrg </para> 804994689c1Smrg </listitem> 805994689c1Smrg </varlistentry> 806994689c1Smrg</variablelist> 807994689c1Smrg</para> 808994689c1Smrg<para> 809994689c1Smrg<!-- .LP --> 810994689c1SmrgReturns the height that will be taken up by the number of lines passed. 811994689c1Smrg</para> 812994689c1Smrg</sect3> 813994689c1Smrg<sect3 id="Setting_the_Tab_Stops"> 814994689c1Smrg<title>Setting the Tab Stops</title> 815994689c1Smrg<para> 816994689c1Smrg<!-- .LP --> 817994689c1SmrgTo set the tab stops for a text sink use the <function>SetTabs</function> function. 818994689c1SmrgThe TextSink already defines this function to set the tab x location in 819994689c1Smrgpixels to be the number of characters times the figure width of 820994689c1Smrg<function>font</function>. 821994689c1Smrg<!-- .IN "TextSink object" "SetTabs" "@DEF@" --> 822994689c1Smrg<funcsynopsis> 823994689c1Smrg<funcprototype> 824994689c1Smrg <funcdef>void<function> SetTabs</function></funcdef> 825994689c1Smrg <paramdef>Widget<parameter> w</parameter></paramdef> 826994689c1Smrg <paramdef>inttab_count,<parameter> *tabs</parameter></paramdef> 827994689c1Smrg</funcprototype> 828994689c1Smrg</funcsynopsis> 829994689c1Smrg<!-- .FN --> 830994689c1Smrg<variablelist> 831994689c1Smrg <varlistentry> 832994689c1Smrg <term> 833994689c1Smrg <emphasis remap='I'>w</emphasis> 834994689c1Smrg </term> 835994689c1Smrg <listitem> 836994689c1Smrg <para> 837994689c1SmrgSpecifies the TextSink object. 838994689c1Smrg </para> 839994689c1Smrg </listitem> 840994689c1Smrg </varlistentry> 841994689c1Smrg <varlistentry> 842994689c1Smrg <term> 843994689c1Smrg <emphasis remap='I'>tab_count</emphasis> 844994689c1Smrg </term> 845994689c1Smrg <listitem> 846994689c1Smrg <para> 847994689c1SmrgSpecifies the number of tabs passed in <emphasis remap='I'>tabs</emphasis>. 848994689c1Smrg </para> 849994689c1Smrg </listitem> 850994689c1Smrg </varlistentry> 851994689c1Smrg <varlistentry> 852994689c1Smrg <term> 853994689c1Smrg <emphasis remap='I'>tabs</emphasis> 854994689c1Smrg </term> 855994689c1Smrg <listitem> 856994689c1Smrg <para> 857994689c1SmrgSpecifies the position, in characters, of the tab stops. 858994689c1Smrg </para> 859994689c1Smrg </listitem> 860994689c1Smrg </varlistentry> 861994689c1Smrg</variablelist> 862994689c1Smrg</para> 863994689c1Smrg<para> 864994689c1Smrg<!-- .LP --> 865994689c1SmrgThis function is responsible for the converting character positions passed 866994689c1Smrgto it into whatever internal positions the TextSink uses for tab placement. 867994689c1Smrg</para> 868994689c1Smrg</sect3> 869994689c1Smrg<sect3 id="Getting_the_Insert_Point_s_Size_and_Location"> 870994689c1Smrg<title>Getting the Insert Point's Size and Location</title> 871994689c1Smrg<para> 872994689c1Smrg<!-- .LP --> 873994689c1SmrgTo get the size and location of the insert point use the 874994689c1Smrg<function>GetCursorBounds</function> function. 875994689c1Smrg<!-- .IN "TextSink object" "GetCursorBounds" "@DEF@" --> 876994689c1Smrg<funcsynopsis> 877994689c1Smrg<funcprototype> 878994689c1Smrg <funcdef>void<function> GetCursorBounds</function></funcdef> 879994689c1Smrg <paramdef>Widget<parameter> w</parameter></paramdef> 880994689c1Smrg <paramdef>XRectangle<parameter> *rect_return</parameter></paramdef> 881994689c1Smrg</funcprototype> 882994689c1Smrg</funcsynopsis> 883994689c1Smrg<!-- .FN --> 884994689c1Smrg<variablelist> 885994689c1Smrg <varlistentry> 886994689c1Smrg <term> 887994689c1Smrg <emphasis remap='I'>w</emphasis> 888994689c1Smrg </term> 889994689c1Smrg <listitem> 890994689c1Smrg <para> 891994689c1SmrgSpecifies the TextSinkObject. 892994689c1Smrg </para> 893994689c1Smrg </listitem> 894994689c1Smrg </varlistentry> 895994689c1Smrg <varlistentry> 896994689c1Smrg <term> 897994689c1Smrg <emphasis remap='I'>rect_return</emphasis> 898994689c1Smrg </term> 899994689c1Smrg <listitem> 900994689c1Smrg <para> 901994689c1SmrgReturns the location and size of the insert point. 902994689c1Smrg </para> 903994689c1Smrg </listitem> 904994689c1Smrg </varlistentry> 905994689c1Smrg</variablelist> 906994689c1Smrg</para> 907994689c1Smrg<para> 908994689c1Smrg<!-- .LP --> 909994689c1Smrg<emphasis remap='I'>Rect</emphasis> will be filled with the current size and location of the 910994689c1Smrginsert point. 911994689c1Smrg 912994689c1Smrg</para> 913994689c1Smrg</sect3> 914994689c1Smrg</sect2> 915994689c1Smrg</sect1> 916