home *** CD-ROM | disk | FTP | other *** search
/ Gold Fish 3 / goldfish_volume_3.bin / files / fish / disks / d1031.lha / Programs / Textfield / Doc / textfield_gc.doc < prev    next >
Encoding:
Text File  |  1994-11-12  |  37.2 KB  |  944 lines

  1. TABLE OF CONTENTS
  2.  
  3. textfield.gadget/textfield.gadget
  4. textfield.gadget/TEXTFIELD_GetClass
  5. textfield.gadget/textfield.gadget           textfield.gadget/textfield.gadget
  6.  
  7.     NAME
  8.     textfield.gadget -- multi-line text entry BOOPSI object (V2)
  9.  
  10.     LEGAL
  11.     textfield.gadget is © 1994 Mark Thomas
  12.     All rights reserved.
  13.  
  14.     FUNCTION
  15.     The textfield class allows you create an area on your screen for text
  16.     entry.  The class supports a number of features including unlimited
  17.     or limited size text entry, specifying the font and style to use,
  18.     specifying the colors for different parts (text, background, and
  19.     lines), two types of borders (with option to invert the borders for a
  20.     total of 4 types of borders) or no border, text left/center/right
  21.     justification, vertical centering, IntuiText labels, attached Images,
  22.     line spacing, limited character acceptance, insertion or block cursor,
  23.     cursor blinking speed or no blinking, read-only mode, modified buffer
  24.     flag, lined paper, cut/copy/paste/erase while editing or program-
  25.     matically, undo buffer, and settable word delimiter characters for
  26.     word wrapping.
  27.  
  28.  
  29.     SIZE ISSUE
  30.  
  31.     The textfield class gadget should be used for relatively small areas
  32.     where you want to allow text entry.  Typically a size below 320 x 200
  33.     is a fairly reasonable limit, but larger sizes will work.  In other
  34.     words it is not intended to be a whole editor like Ed.  Please note
  35.     that the vertical size has more affect on speed than the horizontal
  36.     size.  Many people have ignored the size issue in previous versions,
  37.     and it doesn't seem to have caused problem.  I keep this here until
  38.     the day I can really optimize the gadget.
  39.  
  40.  
  41.     PROGRAMMING LANGUAGE
  42.  
  43.     This gadget is written for a C language interface and is that way
  44.     simply because the Amiga development is geared more towards the C
  45.     language than any other.  This does not mean that the gadget cannot be
  46.     used with another language.  In particular, support for Oberon is
  47.     given in the form of two mod files.  One file, TextField.mod provides
  48.     the actual interface to the gadget class.  It can be compiled and
  49.     linked into an Oberon project.  The other, TestClass.mod is a sample
  50.     program, similar to the C version, that tests the class and shows how
  51.     to use the class.  Thanks goes to Stefan for taking the effort to
  52.     convert the files.
  53.  
  54.     If you use C, the important thing to know is that you need to include
  55.     the header file <gadgets/textfield.h>.  And depending on what you do
  56.     you may need to include some other files: <intuition/gadgetclass.h>,
  57.     <intuition/classes.h>, <intuition/classusr.h>, <intuition/icclass.h>,
  58.     <intuition/imageclass.h>, <utility/tagitem.h>.
  59.  
  60.  
  61.     HOW TO OPEN THE TEXTFIELD GADGET LIBRARY (for non-SAS/C 6.50+ users)
  62.  
  63.     To use the class you must open the "textfield.gadget" library like so:
  64.     OpenLibrary("gadgets/textfield.gadget", 0).  If that was successful,
  65.     then you need to get the class pointer with the TEXTFIELD_GetClass()
  66.     function.  You do not have to check to make sure that the pointer
  67.     returned by TEXTFIELD_GetClass() is valid (see TEXTFIELD_GetClass
  68.     description).  You do not have to return the pointer with any
  69.     function, just do not use the pointer after you close the
  70.     "textfield.gadget" library.
  71.  
  72.     Here's a quick guide:
  73.  
  74.     struct Library *TextFieldBase;
  75.     Class *TextFieldClass;
  76.  
  77.     TextFieldBase = OpenLibrary("gadgets/textfield.gadget", 0)
  78.     if (TextFieldBase) {
  79.         TextFieldClass = TEXTFIELD_GetClass();
  80.  
  81.         /* use the class */
  82.  
  83.         TextFieldClass = NULL;
  84.         CloseLibrary(TextFieldBase);
  85.     }
  86.  
  87.  
  88.     HOW TO OPEN THE TEXTFIELD GADGET LIBRARY (for SAS/C 6.50+ users)
  89.  
  90.     If you use SAS/C 6.50 or greater, then you can use the TextFieldAuto.c
  91.     source file provided in the source draw to have the library open
  92.     automatically at startup, and close automatically at termination so
  93.     that you will not have to take care of these yourself.  I highly
  94.     recommend using this feature.  The file makes two variables available
  95.     to the client:
  96.  
  97.     extern struct Library *TextFieldBase;
  98.     extern Class *TextFieldClass;
  99.  
  100.     Starting in main() these varaibles will automatically be defined to
  101.     have the library base and the class pointer.  If the library fails to
  102.     open, SAS/C's auto-open feature will close down the program with a
  103.     standard Amiga requester telling the user what happened.
  104.  
  105.  
  106.     NO PUBLIC CLASS NAME
  107.  
  108.     Future versions of the textfield.gadget intend to offer a public class
  109.     name that you can use, but that will have to wait until (or if)
  110.     Commodore or CATS return from the dead since I have to register the
  111.     class name.  At which time that a public class name is offered, both
  112.     the old TEXTFIELD_GetClass() and the class name can be used with the
  113.     NewObject() function so that old and new programs will work.
  114.  
  115.  
  116.     WORKS ON OS 2.04 AND UP
  117.  
  118.     The class will work on OS 2.04 and up, but for OS 2.04 through 2.1
  119.     there is no standard place to put .gadget libraries, so on these
  120.     systems the gadget should be installed in a drawer named "Gadgets" in
  121.     the same directory of the program that uses it.  See the example
  122.     program on how to open the class.  For OS 3.0 and up, just install
  123.     the textfield.gadget file in "SYS:Classes/Gadgets" like normal.
  124.  
  125.  
  126.     COMPARISON TO STRING GADGET
  127.  
  128.     Unlike the Amiga's string gadget, you get a gadget up message from
  129.     this gadget when you hit the right mouse button, or either Amiga keys
  130.     and the right alt keys pressed together.
  131.  
  132.  
  133.     GADGET GRAPHIC ELEMENTS SUPPORTED
  134.  
  135.     This gadget does support the GA_Image tag for rendering a linked list
  136.     of images attached to the gadget.  Borders structures are not
  137.     supported.  (Complain if you want it.)
  138.  
  139.     As of version 2.0 the gadget also supports GA_IntuiText also.  This
  140.     means this gadget will render a linked list of IntuiText structures.
  141.     Note that GA_Text and GA_LabelImage are not supported.  (Like above,
  142.     complain if you want it.)
  143.  
  144.     This may or may not help you, but the render order for the elements of
  145.     this gadget is as follows:
  146.  
  147.         Border           (if enabled)
  148.         Lines of text
  149.         Image            (from GA_Image)
  150.         IntuiText        (from GA_IntuiText)
  151.  
  152.     So, images do overwrite borders and the lines of text.  Also note that
  153.     the gadget will render at least one line of text, and at least one
  154.     character per line, so restrict the width and height if this is a
  155.     problem.
  156.  
  157.  
  158.     IMPORTANT NOTES ON ACCESSING THE BUFFER
  159.  
  160.     You must follow these rules or bad things can happen.
  161.  
  162.     The buffer pointer returned by TEXTFIELD_Text with the get method is
  163.     read only.  You must not modify the buffer at any time.
  164.  
  165.     The buffer pointer returned by TEXTFIELD_Text with the get method is
  166.     valid between any of the following:
  167.  
  168.         OffGadget()
  169.          valid
  170.         OnGadget()
  171.  
  172.         GA_Disabled, TRUE
  173.          valid
  174.         Disabled, FALSE
  175.  
  176.         TEXTFIELD_ReadOnly, TRUE
  177.          valid
  178.         TEXTFIELD_ReadOnly, FALSE
  179.  
  180.     Anytime you are outside all of the above situations, the pointer is
  181.     invalid and is guaranteed to change.  In fact you will get a NULL
  182.     pointer if you are outside all of the above situations.
  183.  
  184.     The size of the buffer you have can be obtained by issuing a get
  185.     method of TEXTFIELD_Size on the gadget inside the above situations.
  186.     And if you get a size of 0, then you must not reference the pointer
  187.     that is returned because it is NULL.  Be very careful to never
  188.     reference past the size given.  The buffer is not NULL terminated.
  189.     In C, that's buffer[0] through buffer[size - 1].
  190.  
  191.  
  192.     CHARACTERS ALLOWED IN THE BUFFER
  193.  
  194.     The text you get from TEXTFIELD_Text only contains values from 0x0a,
  195.     0x20 - 0x7f, and 0xa0 - 0xff.  In other words you get the printable
  196.     characters, plus '\n'.  No tabs are supported for now.
  197.  
  198.     When characters are sent to the gadget, either by the application or
  199.     by the user, only the characters listed above are allowed in.  You can
  200.     also make further restrictions with TEXTFIELD_AcceptChars and
  201.     TEXTFIELD_RejectChars.  There is one other character that is allowed
  202.     in, 0x0d, but it is converted to 0x0a for you.  When you read the
  203.     buffer, it will return only 0x0a characters.
  204.  
  205.  
  206.     CHANGING ATTRIBUTES
  207.  
  208.     When setting attributes, the gadget will always render the changes,
  209.     except if the gadget's geometry is changed, in which case it will
  210.     return a non-zero value to let you know changes need to be rendered by
  211.     refreshing the gadget.
  212.  
  213.     A geometry change means that the gadget moves in the window.
  214.     Specifically the following attributes cause the geometry to change:
  215.  
  216.     GA_Top, GA_Left, GA_Width, GA_Height, GA_RelWidth, GA_RelHeight,
  217.     GA_RelBottom, GA_RelRight.
  218.  
  219.     Here's how to handle this inside an application.
  220.  
  221.     if (SetGadgetAttrs(gadget, window, requester, ...)) {
  222.         /* gadget needs rendering */
  223.         RefreshGList(gadget, window, requester, 1);
  224.     }
  225.  
  226.  
  227.     MOVING OR SIZING THE GADGET
  228.  
  229.     If you want to move the gadget or change its size you should take note
  230.     of the section above on changing attributes.  In addition, the source
  231.     file TestClass.c in the TestClass example shows how to move the gadget
  232.     or change its size.  You should clear out the old position, then set
  233.     the new position and size, and finally refresh the gadget.
  234.  
  235.  
  236.     APPLICABILITY IN THE TAGS SECTION
  237.  
  238.     In the TAGS section there is a statement with each attribute called
  239.     applicability.  It consists of a letters inside parentheses, like
  240.     (ISGNU).  These are standard BOOPSI letters that tell you which
  241.     standard methods the attribute can be used.  Here's what the letters
  242.     refer to (see the BOOPSI reference in the RKRM: Libraries for further
  243.     information):
  244.  
  245.         I - OM_NEW     (initializable)
  246.         S - OM_SET     (settable)
  247.         G - OM_GET     (gettable)
  248.         N - OM_NOTIFY  (is passed in gadget's notify message)
  249.         U - OM_UPDATE  (updatable)
  250.  
  251.  
  252.     SETTING ATTRIBUTES
  253.  
  254.     Some of the attributes cause others to not work properly.  Do not get
  255.     discouraged.  This only applies when sending then in one OM_SET
  256.     method.  It is unavoidable in the current release, so if you are
  257.     seeing things not work right, or in particular if a later tag works
  258.     but a former one does not, then split the attributes among two calls.
  259.     The gadget is set up so that later tags have precedence over former
  260.     tags.  This particularly applies to attributes that change the cursor
  261.     position and scrolling (changing top and such).
  262.  
  263.  
  264.     UNDO
  265.  
  266.     The undo function is implemented as an alternate paste buffer.  In
  267.     certain situations list below text will be copied into an undo buffer.
  268.     When the undo command is issued, the text in that buffer is pasted to
  269.     the current cursor position.  It does not really undo anything, it
  270.     just saves otherwise lost text.  When the undo is actually performed,
  271.     the undo buffer becomes cleared so that you cannot undo the same text
  272.     multiple times.
  273.  
  274.     List of places where text is saved in the undo buffer:
  275.  
  276.     - If you hit BACKSPACE or DELETE while some text is marked, the marked
  277.       text is placed in the undo buffer before the text is deleted.
  278.  
  279.     - If you hit SHIFT BACKSPACE or DELETE, the text that is deleted is
  280.       placed in the undo buffer.
  281.  
  282.     - If you hit ALT BACKSPACE or DELETE, the word that is deleted is
  283.       placed in the undo buffer.
  284.  
  285.     - If you hit CTRL X, the line that is deleted is placed in the undo
  286.       buffer.
  287.  
  288.     - If you type a character while some text is marked, the marked text
  289.       is placed in the undo buffer before the text is delete.
  290.  
  291.     - When you perform a normal paste while text is marked, the marked
  292.       text is placed in the undo buffer before it is deleted and the paste
  293.       occurs.
  294.  
  295.     - If you perform an erase (RAMIGA E or programmatically), the whole
  296.       buffer is placed in the undo buffer before it is deleted.
  297.  
  298.  
  299.     DOCS FOR USERS
  300.  
  301.     You can mark text for cutting, copying, and erasing by simply clicking
  302.     and dragging.  Hitting alphanumeric keys replaces the text that is
  303.     highlighted.  Hitting cursor keys moves you to the front or end of the
  304.     highlighted text.
  305.  
  306.     While you drag to scroll, the farther away from the gadget your mouse
  307.     pointer is, the faster the gadget will scroll.
  308.  
  309.     For key sequences, the Amiga Style Guide was followed.  Anywhere the
  310.     undo buffer is mentioned, the statement is only valid if the UndoStream
  311.     is supplied (see tag section below).
  312.  
  313.     Key Sequence              Function
  314.     ----------------------------------------------------------------------
  315.            TAB                Activate next gadget (if GA_TabCycle)
  316.  
  317.      SHIFT TAB                Activate previous gadget (if GA_TabCycle)
  318.  
  319.      SHIFT CURSOR UP          Move to the top line in the current page, or
  320.                               scroll up one page if cursor is on top line
  321.  
  322.      SHIFT CURSOR DOWN        Move to the bottom line in the current page,
  323.                               or scroll down one page if cursor is on top
  324.                               line
  325.  
  326.       CTRL or
  327.      SHIFT CURSOR RIGHT       Move to the right end of the current line
  328.  
  329.       CTRL or
  330.      SHIFT CURSOR LEFT        Move to the left end of the current line
  331.  
  332.      SHIFT BACKSPACE          Delete all text to the left of cursor on the
  333.                               current line
  334.  
  335.      SHIFT DELETE             Delete all text to the right of the cursor
  336.                               on the current line (in block cursor mode
  337.                               this also includes the highlighted
  338.                               character)
  339.  
  340.       CTRL CURSOR UP          Move to the top line of the text
  341.  
  342.       CTRL CURSOR DOWN        Move to the bottom line of the text
  343.  
  344.        ALT CURSOR RIGHT       Move to the next word (using the delimiter
  345.                               characters provided by the programmer)
  346.  
  347.        ALT CURSOR LEFT        Move to the previous word (using the
  348.                               delimiter characters provided by the
  349.                               programmer)
  350.  
  351.        ALT CURSOR UP          Move to first character in gadget
  352.  
  353.        ALT CURSOR DOWN        Move to last character in gadget
  354.  
  355.        ALT BACKSPACE          Deletes the word to the left of the cursor
  356.                               starting at the current cursor position
  357.  
  358.        ALT DEL                Deletes the word to the right of the cursor
  359.                                   starting at the current cursor position
  360.  
  361.       CTRL X                  Deletes the whole line that the cursor is on
  362.  
  363.     RAMIGA [                  Switch to left justification
  364.                               (if TEXTFIELD_UserAlign is set)
  365.  
  366.     RAMIGA \ or
  367.     RAMIGA =                  Switch to center justification
  368.                               (if TEXTFIELD_UserAlign is set)
  369.  
  370.     RAMIGA ]                  Switch to right justification
  371.                               (if TEXTFIELD_UserAlign is set)
  372.  
  373.     RAMIGA E                  Erase all text in gadget (saved in undo
  374.                               buffer) (no read-only)
  375.  
  376.     RAMIGA V                  Paste text from clipboard to current cursor
  377.                               position (no read-only)
  378.  
  379.     RAMIGA A                  Mark all text
  380.  
  381.     RAMIGA U                  Undeletes (pastes) the last block of text
  382.                               marked, or recover from RAMIGA E
  383.                               (no read-only)
  384.  
  385.     When text is highlighted the following keys have functions:
  386.  
  387.            BACKSPACE          Erase marked text (saved in undo buffer)
  388.  
  389.            DEL                Erase marked text (saved in undo buffer)
  390.  
  391.     RAMIGA X                  Cut marked text to clipboard (no read-only)
  392.  
  393.     RAMIGA C                  Copy marked text to clipboard
  394.  
  395.     RAMIGA V                  Replace marked text with text from
  396.                               clipboard (save marked text in undo
  397.                               buffer) (no read-only)
  398.  
  399.            (any text key)     Replace marked text with that character
  400.     ----------------------------------------------------------------------
  401.  
  402.     TAGS
  403.     GA_Left (WORD) -- Specifies the left edge of the gadget.
  404.  
  405.     GA_Top (WORD) -- Specified the top edge of the gadget.
  406.  
  407.     GA_Width (WORD) -- Specifies the width of the gadget.  If a border is
  408.         chosen, it will be rednered within this value.
  409.  
  410.     GA_Height (WORD) -- Specifies the height of the gadget.  If a border
  411.         is chosen, it will be rendered within this value.
  412.  
  413.     GA_RelRight (WORD) -- Specifies the gadget as being relative to the
  414.         right border of whatever the gadget is attached to.  See the
  415.         BOOPSI Class Reference.
  416.  
  417.     GA_RelBottom (WORD) -- Specifies the gadget as being relative to the
  418.         bottom border of whatever the gadget is attached to.  See the
  419.         BOOPSI Class Reference.
  420.  
  421.     GA_RelWidth (WORD) -- Specifies the gadget as being relative to the
  422.         width of whatever it is attached to.  See the BOOPSI Class
  423.         Reference.
  424.  
  425.     GA_RelHeight (WORD) -- Specifies the gadget as being relative to the
  426.         height of whatever it is attached to.  See the BOOPSI Class
  427.         Reference.
  428.  
  429.     GA_Image (struct Image *) -- Pass a pointer to a linked list of images
  430.         and this class will render them relative to the gadget's upper
  431.         left corner.  See rendering order above.
  432.  
  433.     GA_IntuiText (struct IntuiText *) -- Pass a pointer to a linked list
  434.         of IntuiText structures and this class will render them relative
  435.         to the gadget's upper left corner.  See rendering order above.
  436.         (V2)
  437.  
  438.     GA_Disabled (BOOL) -- TRUE disables the gadget, not allowing input,
  439.         and FALSE enables the gadget for input.  When the gadget is
  440.         disables, it usually is ghosted, see TEXTFIELD_NoGhost for
  441.         other conditions.
  442.  
  443.     GA_TabCycle (BOOL) -- Turns on tab cycling.  See the BOOPSI Class
  444.         Reference.
  445.  
  446.     TEXTFIELD_Text (char *) -- This set/replaces text.  NULL means no
  447.         change.  To set the buffer empty pass "" (pointer to empty
  448.         string, not a NULL pointer).  When you use it to get text see
  449.         special conditions under IMPORTANT above.  The cursor position
  450.         is reset to the beginning (0).  The pointer passed must be a
  451.         pointer to a NULL terminated string of characters.  If you
  452.         have read only mode turned on with TEXTFIELD_ReadOnly, this
  453.         attribute still works.
  454.  
  455.         Default for this tag is NULL.  Applicability is (ISG U).
  456.  
  457.     TEXTFIELD_InsertText (char *) -- This inserts text at current cursor
  458.         position and move the cursor to the end of the inserted text.
  459.         You must pass a NULL terminated pointer to characters.  If you
  460.         have read only mode turned on with TEXTFIELD_ReadOnly, this
  461.         attribute still works.
  462.  
  463.         Applicability is ( S  U).
  464.  
  465.     TEXTFIELD_DeleteText (ULONG) -- This deletes the number of characters
  466.         you pass in the data field, starting at the current cursor
  467.         position.  This attribute works even if read only mode is
  468.         turned on with TEXTFIELD_ReadOnly.
  469.  
  470.         Applicability is ( S  U). (V2)
  471.  
  472.     TEXTFIELD_TextFont (struct TextFont *) -- Sets the font for the gadget
  473.         to use.  Pass the object a pointer to a TextFont structure.
  474.         This supersedes TEXTFIELD_TextAttr below.  Please do not close
  475.         this font while the gadget is using it. :)  The default font
  476.         is your screen's current font.
  477.  
  478.         Default for this tag is NULL. Applicability is (IS  U).
  479.  
  480.     TEXTFIELD_TextAttr (struct TextAttr *) -- Sets the font the gadget is
  481.         to use.  Pass the gadget a pointer to a TextAttr structure.
  482.         This is superseded by TEXTFIELD_TextFont.  The default font is
  483.         the screen's current font.
  484.  
  485.         Default for this tag is NULL.  Applicability is (IS  U).
  486.  
  487.     TEXTFIELD_FontStyle (ULONG) -- The style will get set to what you pass
  488.         here.  The font style automatically gets reset when
  489.         TEXTFIELD_TextFont or TEXTFIELD_TextAttr is set.
  490.  
  491.         Default for this tag is FSF_PLAIN.  Applicability is (IS  U).
  492.  
  493.     TEXTFIELD_Delimiters (char *) -- You get the default if you pass NULL.
  494.         Words break after these and "\n".  You will probably want at
  495.         least " ", the space.  This string is not copied, so do not
  496.         get rid of it while the gadget is in use.
  497.  
  498.         Default for this tag is ",)!@^&*_=+\\|<>?/ ".  Applicability
  499.         is (IS  U).
  500.  
  501.     TEXTFIELD_AcceptChars (char *) -- Tells the textfield gadget which
  502.         characters to accept.  All others are rejected, and non-
  503.         printable characters are automaically rejected.  Some of these
  504.         characters may not be accepted if they also appear in the
  505.         reject string.  This string is not copied, so do not get rid
  506.         of it while the gadget is in use.  A NULL means to accept all
  507.         characters.
  508.  
  509.         Default for this tag is NULL.  Applicability is (IS  U). (V2)
  510.  
  511.     TEXTFIELD_RejectChars (char *) -- Tells the textfield gadget which
  512.         characters to reject.  Non-printable characters are
  513.         automaically rejected.  Characters specified with this are
  514.         always rejected.  This string is not copied, so do not get rid
  515.         of it while the gadget is in use.  A NULL means to reject no
  516.         characters.
  517.  
  518.         Default for this tag is NULL.  Applicability is (IS  U). (V2)
  519.  
  520.     TEXTFIELD_BlinkRate (ULONG) -- This sets the number of microseconds
  521.         between a cursor on-off, or off-on transition.  A value of 0
  522.         means do not blink.  Realistically, this should be set to
  523.         100000 or higher since BOOPSI objects don't get idle messages
  524.         any faster than about once every 10th of a second, but any
  525.         value between 0 and 100000 will just make the cursor blink as
  526.         fast as it can.  If you give the user an option of blink
  527.         speed, suggest values: 0 for no blink, 750000 for a slow
  528.         blink, 500000 for a medium blink, and 250000 for a fast blink.
  529.  
  530.         Default for this tag is 0.  Applicability is (IS  U).
  531.  
  532.     TEXTFIELD_BlockCursor (BOOL) -- Turn on/off block cursor mode.  You
  533.         should not use a block cursor if your font is italic because
  534.         it looks weird.
  535.  
  536.         Default for this tag is FALSE.  Applicability is (IS  U).
  537.  
  538.     TEXTFIELD_CursorPos (ULONG/ULONG *) -- Get/Set the cursor position.
  539.         The cursor position returned is always an exact offset into
  540.         the buffer you get to read via TEXTFIELD_Text.  0 takes you
  541.         to the first character in the gadget, and 0xFFFFFFFF takes
  542.         you past the last character in the gadget.  In general, any
  543.         value you pass that is larger than what's returned by
  544.         TEXTFIELD_Size will end up just past the last character in
  545.         the gadget.  Setting this attribute will scroll the text to
  546.         the position you set the cursor to.  If there is any text
  547.         highlighted, highlighting is turned off.  When you get the
  548.         current cursor position, you must pass a pointer to a ULONG.
  549.         The ULONG will then have the cursor position in it.
  550.  
  551.         Applicability is (ISG U).
  552.  
  553.     TEXTFIELD_Size (ULONG *) -- Returns the number of characters in the
  554.         gadget's buffer, including \n characters.  This gives you the
  555.         size when you want to use TEXTFIELD_Text to read the text in
  556.         the gadget.  You must pass a pointer to a ULONG and then the
  557.         ULONG will contain the value.
  558.  
  559.         Applicability is (  G  ).
  560.  
  561.     TEXTFIELD_MaxSize (ULONG) -- Limit the size of text entered into the
  562.         gadget.  0 means unlimited, otherwise limits the buffer size
  563.         to what you pass.  This includes \n characters.
  564.  
  565.         Default for this tag is UNLIMITED.  Applicability is (I    ).
  566.  
  567.     TEXTFIELD_MaxSizeBeep (BOOL) -- This attribute lets you set whether
  568.         the system DisplayBeep() function is called if the user
  569.         attempts to enter text into the gadget and the gadget is full
  570.         (i.e. the gadget's buffer size is equal to the limit set by
  571.         TEXTFIELD_MaxSize).  If TRUE the system beep is called.  If
  572.         FALSE, the system beep is not called.
  573.  
  574.         Default for this tag is TRUE.  Applicability is (IS  U). (V2)
  575.  
  576.     TEXTFIELD_Visible (ULONG *) -- Get the current number of visible
  577.         lines.  It always returns how many _could_ be displayed if
  578.         there were enough characters to fill the display.  Use for
  579.         notifying a BOOPSI prop gadget.  You actually pass a pointer
  580.         to a ULONG and then the ULONG will contain the value.  See
  581.         example program.
  582.  
  583.         Applicability is (  GN ).
  584.  
  585.     TEXTFIELD_Lines (ULONG *) -- Get the total number of lines in the
  586.         buffer of the gadget.  Use this to also notify a BOOPSI prop
  587.         gadget.  You pass a pointer to a ULONG and then the ULONG will
  588.         contain the value.  See example program.
  589.  
  590.         Applicability is (  GN ).
  591.  
  592.     TEXTFIELD_Top (ULONG/ULONG *) -- Get or set ordinal value of the top
  593.         line.  0 is the top most line.  This is useful for ICA_MAP and
  594.         ICA_TARGET when using the BOOPSI prop gadget and notifications.
  595.         When you get the value you pass a pointer to a ULONG and then
  596.         the ULONG will contain the value.  See sample program for
  597.         example.
  598.  
  599.         Default for this tag is 0.  Applicability is ( SGNU).
  600.  
  601.     TEXTFIELD_Partial (BOOL) -- When this flag is set to TRUE, partial
  602.         lines will be shown at the bottom of the gadget.  When this
  603.         flag is set to false, then only whole lines will be shown in
  604.         the gadget.  Note that having both TEXTFIELD_VCenter, and
  605.         TEXTFIELD_Partial on is not allowed and doesn't make sense.
  606.         If both TEXTFIELD_VCenter and TEXTFIELD_Partial are turned on
  607.         at the same time, only TEXTFIELD_VCenter will get turned on.
  608.  
  609.         Default for this tag is FALSE.  Applicability is (IS  U).
  610.  
  611.     TEXTFIELD_NoGhost (BOOL) -- If TRUE, never ghost when gadget is
  612.         disabled.  If FALSE, then ghost when gadget is disabled.  You
  613.         can use this to make a read only multiline string gadget.  It
  614.         has a special purpose, though.
  615.  
  616.         Normally you will want a gadget to be enabled when allowing
  617.         text to be entered.  However, when you need to read the text
  618.         from the gadget, you have to disable it.  But disabling a
  619.         gadget ghosts it.  So, with this option, you can pass
  620.         GA_Disabled, TRUE, TEXTFIELD_NoGhost, TRUE at the same time
  621.         and it will disable without ever showing the ghosted pattern.
  622.         And likewise, passing the attributes GA_Disabled, FALSE,
  623.         TEXTFIELD_NoGhost, FALSE will seamlessly reenable the gadget.
  624.         While the gadget is disabled, read the text and then be on
  625.         your way.  Also note that most S and U attributes are settable
  626.         while the gadget is disabled, notably TEXTFIELD_Top.  This
  627.         allows you to make a scrollable read-only multiline non-
  628.         ghosted text, image capable, and border capable gadget.
  629.         Sounds useful to me!
  630.  
  631.         The read only mode is probably better.  See below.
  632.  
  633.         Default for this tag is FALSE.  Applicability is (IS  U).
  634.  
  635.     TEXTFIELD_ReadOnly (BOOL) -- If TRUE, then the gadget does not allow
  636.         text to be entered or deleted by the user.  However, the user
  637.         can still highlight so that text can be copied to the
  638.         clipboard.  If FALSE, then the gadget acts normally.  If you
  639.         want a read only mode without clipboard support, then use the
  640.         GA_Disabled and TEXTFIELD_NoGhost mode mentioned in the
  641.         TEXTFIELD_NoGhost description.
  642.  
  643.         All but two of the normal keyboard editing commands are
  644.         ignored while in read-only mode.  RAMIGA-a highlights all
  645.         text, and RAMIGA-c copies highlighted text to the clipboard.
  646.         Other RAMIGA keys will get passed is TEXTFIELD_PassCommand is
  647.         turned on.
  648.  
  649.         So that the gadget acts more like it's not active while in
  650.         this mode, certain keys events get passed on to the window:
  651.         F1-F10, Help, Cursor keys.
  652.  
  653.         Note that non-RAWKEY events, like mouse moves, buttons, and
  654.         timer events are not passed on so that normal highlighting and
  655.         scrolling can occur.
  656.  
  657.         There is no visual change in the gadget when it is read-only
  658.         other than it does not have a cursor.  You should set the
  659.         border to an inverted bevel or inverted double-bevel.  By the
  660.         style guide, inverted borders represent read-only gadgets.
  661.  
  662.         Default for this tag is FALSE.  Applicability is (IS  U).
  663.         (V2)
  664.  
  665.     TEXTFIELD_Modified (BOOL) -- This attribute is a flag that you can
  666.         set and read to find out if a gadget's buffer has been
  667.         modified in some way.  For instance, if you wanted to load
  668.         some text into the gadget, then when the program quits
  669.         determine if the text was modified then you would load and
  670.         set the flag like this: TEXTFIELD_Text, text,
  671.         TEXTFIELD_Modified, FALSE.  Note that the order matters, such
  672.         that if they were reversed the text change would promptly
  673.         set the modified flag to TRUE.  You can read or set this flag
  674.         at any time.
  675.  
  676.         Default for this tag is FALSE.  Applicability is (IS  U).
  677.         (V2)
  678.  
  679.     TEXTFIELD_PassCommand (BOOL) -- This attribute is a flag to allow the
  680.         gadget to pass unused right Amiga key sequences (command key
  681.         sequences) on to the client application.  If the flag is set
  682.         to TRUE then the key sequences are passed to the client.
  683.         There is a side effect that causes the gadget to become
  684.         inactive (as if the user had clicked outside the gadget).
  685.         The default behavior (set to FALSE) is to ignore these key
  686.         sequences so that the gadget remains active.
  687.  
  688.         Default for this tag is FALSE.  Applicability is (IS  U).
  689.         (V2)
  690.  
  691.     TEXTFIELD_Border (ULONG) -- Sets the border type.  See defines below.
  692.         The gadget offers a standard bevel, and standard double bevel.
  693.         If you need another type, your could always create an image,
  694.         link it to the gadget with GA_Image, and set its top and left
  695.         edges above and to the left of this gadget (negative in the
  696.         image structure), and make the width and height larger than
  697.         this gadget.
  698.  
  699.         Default for this tag is TEXTFIELD_BORDER_NONE.  Applicability
  700.         is (IS  U).
  701.  
  702.     TEXTFIELD_Inverted (BOOL) -- If this flags is TRUE, the border is
  703.         drawn inverted, if there is a border.  If FALSE, the border is
  704.         drawn non-inverted.  This option is here in case you want to
  705.         give the textfield gadget a read-only look when used in
  706.         conjunction with TEXTFIELD_NoGhost and GA_Disabled.
  707.  
  708.         Default for this tag is FALSE.  Applicability is (IS  U).
  709.  
  710.     TEXTFIELD_Up (ULONG) -- Moves the text up by one line.  You can pass
  711.         anything, but it will only move the text up by a line, if it's
  712.         not at the top already.  Useful BOOPSI notifications.
  713.  
  714.         Applicability is ( S  U).
  715.  
  716.     TEXTFIELD_Down (ULONG) -- Moves the text down by one line.  You can
  717.         pass anything, but it will only move the text down by a line,
  718.         if it's not at the bottom already.  Useful for BOOPSI
  719.         notifications.
  720.  
  721.         Applicability is ( S  U).
  722.  
  723.     TEXTFIELD_Alignment (ULONG/ULONG *) -- Set/Get the line justification.
  724.         This gadget offers left, center, and right justification.
  725.         When you are getting the flags, you need to pass a pointer to
  726.         a ULONG and then the ULONG will contain the flags.  See
  727.         defines below.
  728.  
  729.         Default for this tag is TEXTFIELD_ALIGN_LEFT.  Applicability
  730.         is (ISG U).
  731.  
  732.     TEXTFIELD_VCenter (BOOL) -- Turn on/off vertical centering.  When on,
  733.         the lines in the display are centered vertically.  If the
  734.         total number of lines is less than the visible number of lines
  735.         then the smaller number of lines are centered.  This allows
  736.         you to center single lines of text within the gadget very
  737.         easily.  For normal text entry operation, it is best to leave
  738.         this off.  Also, check TEXTFIELD_Partial for possible
  739.         conflicts when used with TEXTFIELD_VCenter.
  740.  
  741.         Default for this tag is FALSE.  Applicability is (IS  U).
  742.  
  743.     TEXTFIELD_UserAlign (BOOL) -- If this is set at creation, then the
  744.         user will have control over the left/center/right
  745.         justification of text through RIGHT-AMIGA [, =, ] keyboard
  746.         shortcuts.  If you want to save what the user has set the
  747.         justification to, then do a GetAttr() on TEXTFIELD_Alignment.
  748.  
  749.         Default for this tag is FALSE.  Applicability is (I    ).
  750.  
  751.     TEXTFIELD_RuledPaper (BOOL) -- Lets you set whether the paper
  752.         (background) has ruled horizontal lines under each line of
  753.         text or not.
  754.  
  755.         Default for this tag is FALSE.  Applicability is (IS  U).
  756.  
  757.     TEXTFIELD_PaperPen (ULONG) -- This lets you specify the pen used for
  758.         drawing the paper (background) of the gadget.  A value of -1
  759.         means use default, which is BACKGROUNDPEN.
  760.  
  761.         Default for this tag is -1.  Applicability is (IS  U).
  762.  
  763.     TEXTFIELD_InkPen (ULONG) -- This lets you specify the pen used for
  764.         drawing the text.  A value of -1 means use the default, which
  765.         is TEXTPEN.  If this pen, and the TEXTFIELD_LinePen are
  766.         different, then rendering speed is slowed down a bit.  It is
  767.         recommended that the line pen be left to -1.
  768.  
  769.         Default for this tag is -1.  Applicability is (IS  U).
  770.  
  771.     TEXTFIELD_LinePen (ULONG) -- This lets you specify the pen used for
  772.         drawing the ruled lines, if TEXTFIELD_RuledPaper is TRUE.  See
  773.         TEXTFIELD_InkPen for possible speed problems when specifying
  774.         this pen.  A value of -1 means to use the same pen as
  775.         TEXTFIELD_InkPen.
  776.  
  777.         Default for this tag is -1.  Applicability is (IS  U).
  778.  
  779.     TEXTFIELD_Spacing (UBYTE) -- Lets you set an extra amount of spacing
  780.         between lines of text, for maybe doing 1-1/2 or double
  781.         spacing.  It's a pixel value between 0 and 255.  The space is
  782.         added to the top of each line.  In other words, the baseline
  783.         is moved down by the amount you specify.
  784.  
  785.         Default for this tag is 0.  Applicability is (IS  U).
  786.  
  787.     TEXTFIELD_ClipStream (struct ClipboardHandle *) -- This tag allows
  788.         clipboard support in the gadget.  Pass the pointer returned
  789.         from the iffparse.library OpenClipboard() function.  If a NULL
  790.         is passed, the clipboard support is not allowed.  Please
  791.         supply this tag value.  Don't leave users without clipboard
  792.         support.  It is recommended that the unit opened by
  793.         OpenClipboard() be 0 or PRIMARY_UNIT, since that is the
  794.         standard unit, but you can pick whatever unit you or your user
  795.         wants.  This stream can be safely given to multiple objects.
  796.  
  797.         Default for this tag is NULL.  Applicability is (I    ).
  798.  
  799.     TEXTFIELD_ClipStream2 (struct ClipboardHandle *) -- ClipStream2 is
  800.         used for the undo features of the textfield class.  It is
  801.         obtained from the iffparse.library OpenClipboard() function.
  802.         You should probably use a clipboard unit other than 0 to avoid
  803.         conflicts with normal clips.  This stream can be safely passed
  804.         to multiple objects.  (See TEXTFIELD_UndoStream)
  805.  
  806.         Default for this tag is NULL.  Applicability (I    ).
  807.  
  808.     TEXTFIELD_UndoStream -- This is a synonym for
  809.         TEXTFIELD_ClipStream2.  See it above.
  810.  
  811.     TEXTFIELD_LineLength (ULONG *) -- Get the contents of the ULONG to a
  812.         line number and that ULONG will be replaced with the length of
  813.         that line in characters.  If you are worried about the line
  814.         lengths changing while you are reading them, then try removing
  815.         the gadget from the window first.  Please realize that if the
  816.         gadget has a relative width or height then the lengths can
  817.         change anytime the user resized the window.
  818.  
  819.         Applicability is (  G  ). (V2)
  820.  
  821.     TEXTFIELD_SelectSize (ULONG/ULONG *) -- Set the number of characters
  822.         to highlight starting from the current cursor position.  If
  823.         the value is 0, highlighting will be turned off.  If the
  824.         number is non-zero, that number of characters will be
  825.         highlighted.  You can also get the number of highlighted
  826.         characters with this attribute by passing a ULONG *.  If you
  827.         get a 0 value, then highlighting is turned off.  This can is
  828.         useful for the copy, cut, and paste commands.
  829.  
  830.         Applicability is ( SG U). (V2)
  831.  
  832.     TEXTFIELD_Copy -- When this attribute is specified, the gadget copies
  833.         any highlighted text to the clipboard.  Highlighting is turned
  834.         off after issuing this.  You can put Copy in a menu with this.
  835.         This does not take a parameter.
  836.  
  837.         Applicability is ( S  U). (V2)
  838.  
  839.     TEXTFIELD_CopyAll -- When this attribute is specified, the gadget
  840.         copies all of the gadget's text to the clipboard.  It does not
  841.         affect the state of the highlight and the text does not need
  842.         to be highlighted.  You can put Copy All in a menu with this.
  843.         This does not take a parameter.
  844.  
  845.         Applicability is ( S  U). (V2)
  846.  
  847.     TEXTFIELD_Cut -- When this attribute is specified, the gadget will
  848.         cut any highlighted text to the clipboard.  Cut text goes to
  849.         the clipboard.  You can put Cut in a menu with this.  This
  850.         does not take a parameter.
  851.  
  852.         Applicability is ( S  U). (V2)
  853.  
  854.     TEXTFIELD_Paste -- When this attribute is specified, the gadget will
  855.         delete any highlighted text to the undo buffer, then it will
  856.         paste the text from the clipboard to the gadget.  You can put
  857.         Paste in a menu with this.  This does not take a parameter.
  858.  
  859.         Applicability is ( S  U). (V2)
  860.  
  861.     TEXTFIELD_Erase -- When this attribute is specified, the gadget will
  862.         delete any highlighted text, otherwise do nothing.  If text
  863.         is deleted, it's placed in the undo buffer.  You can put Erase
  864.         in a menu with this.  This does not take a parameter.
  865.  
  866.         Applicability is ( S  U). (V2)
  867.  
  868.     TEXTFIELD_Undo -- When this attribute is specified, the gadget will
  869.         delete any highlighted text, then insert the text from the
  870.         undo buffer.  You can put Undo in a menu with this.  This does
  871.         not take a parameter.
  872.  
  873.         Applicability is ( S  U). (V2)
  874.  
  875.     BORDER REFERENCE
  876.     You can use the width and heights given when calculating window sizes
  877.     and limits.  To make the window's height minimal with respect to your
  878.     font, use (window border top) + (window border bottom) + (num_lines *
  879.     (font height)) + (gadget border height).  Also, if you use
  880.     TEXTFIELD_Spacing, you'll have to add that in too.
  881.  
  882.     TEXTFIELD_BORDER_NONE            Border takes up:  0 width,  0 height
  883.     TEXTFIELD_BORDER_BEVEL           Border takes up:  8 width,  4 height
  884.     TEXTFIELD_BORDER_DOUBLEBEVEL     Border takes up: 12 width,  6 height
  885.  
  886.     ALIGMENT REFERENCE
  887.     TEXTFIELD_ALIGN_LEFT             Cause text to be flush left
  888.     TEXTFIELD_ALIGN_CENTER           Cause text to be centered
  889.     TEXTFIELD_ALIGN_RIGHT            Cause text to be flush right
  890.  
  891.     BUGS
  892.     What bugs?  Please let me know if you find any.
  893.     See the History file for a list of fixed bugs.
  894.  
  895.     DEBUGGING
  896.  
  897.     A version of the textfield.gadget library is provided with routines
  898.     that print debug information to the serial port using the current
  899.     settings for the serial device.  It could be helpful.  Just rename
  900.     the debug gadget (textfield.debug.gadget) to textfield.gadget and
  901.     place it in the normal gadgets place listed above.
  902.  
  903.     CONTACT
  904.     To contact me for reporting bugs or giving suggestions:
  905.  
  906.     Mark Thomas
  907.     1515 Royal Crest Dr. #3259
  908.     Austin, TX  78741
  909.  
  910.     or
  911.  
  912.     mthomas@cs.utexas.edu
  913.  
  914.     or
  915.  
  916.     URL: http://www.cs.utexas.edu/~mthomas
  917. textfield.gadget/TEXTFIELD_GetClass       textfield.gadget/TEXTFIELD_GetClass
  918.  
  919.     NAME
  920.     TEXTFIELD_GetClass -- Gets the pointer to the textfield class. (V1.0)
  921.  
  922.     SYNOPSIS
  923.     textfield_class = TEXTFIELD_GetClass();
  924.     D0
  925.  
  926.     Class *TEXTFIELD_GetClass(void);
  927.  
  928.     FUNCTION
  929.     Obtains the pointer to the textfield.gadget class for use with
  930.     NewObject().  This function always returns a valid pointer so
  931.     you do not need to check it.  The reason is that if the library
  932.     opens fine, then the pointer returned is already setup.  (Of course
  933.     this implies that if opening the library fails, you shouldn't be
  934.     calling this.)
  935.  
  936.     INPUTS
  937.     None.
  938.  
  939.     RESULT
  940.     textfield_class - the pointer to the textfield.gadget class.
  941.  
  942.     BUGS
  943.     None.
  944.