field.pp 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239
  1. (******************************************************************************
  2. *
  3. * Copyright (c) 1994-2000 Palm, Inc. or its subsidiaries.
  4. * All rights reserved.
  5. *
  6. * File: Field.h
  7. *
  8. * Release: Palm OS SDK 4.0 (63220)
  9. *
  10. * Description:
  11. * This file defines field structures and routines.
  12. *
  13. * History:
  14. * August 29, 1994 Created by Art Lamb
  15. *
  16. *****************************************************************************)
  17. unit field;
  18. interface
  19. uses palmos, coretraps, rect, font, window, control;
  20. const
  21. maxFieldTextLen = $7fff;
  22. // default maximun number of line the a dynamicly sizing field will expand to.
  23. // Can be changed with FldSetMaxVisibleLines
  24. maxFieldLines = 11;
  25. // kind alignment values
  26. type
  27. justifications = Enum;
  28. const
  29. leftAlign = 0;
  30. centerAlign = Succ(leftAlign);
  31. rightAlign = Succ(centerAlign);
  32. type
  33. JustificationType = justifications;
  34. const
  35. undoBufferSize = 100;
  36. type
  37. UndoMode = enum;
  38. const
  39. undoNone = 0;
  40. undoTyping = Succ(undoNone);
  41. undoBackspace = Succ(undoTyping);
  42. undoDelete = Succ(undoBackspace);
  43. undoPaste = Succ(undoDelete);
  44. undoCut = Succ(undoPaste);
  45. undoInput = Succ(undoCut);
  46. type
  47. FieldUndoType = record
  48. {$ifdef ALLOW_ACCESS_TO_INTERNALS_OF_FIELDS} // These fields will not be available in the next OS release!
  49. mode: UndoMode;
  50. reserved: UInt8;
  51. start: UInt16;
  52. end_: UInt16;
  53. bufferLen: UInt16;
  54. buffer: PChar;
  55. {$endif}
  56. end;
  57. FieldUndoTag = FieldUndoType;
  58. FieldAttrType = record
  59. Bits: UInt16;
  60. {
  61. UInt16 usable :1; // Set if part of ui
  62. UInt16 visible :1; // Set if drawn, used internally
  63. UInt16 editable :1; // Set if editable
  64. UInt16 singleLine :1; // Set if only a single line is displayed
  65. UInt16 hasFocus :1; // Set if the field has the focus
  66. UInt16 dynamicSize :1; // Set if height expands as text is entered
  67. UInt16 insPtVisible :1; // Set if the ins pt is scolled into view
  68. UInt16 dirty :1; // Set if user modified
  69. UInt16 underlined :2; // text underlined mode
  70. UInt16 justification :2; // text alignment
  71. UInt16 autoShift :1; // Set if auto case shift
  72. UInt16 hasScrollBar :1; // Set if the field has a scroll bar
  73. UInt16 numeric :1; // Set if numeric, digits and secimal separator only
  74. UInt16 reserved :1; // Reserved for future use
  75. }
  76. end;
  77. FieldAttrTag = FieldAttrType;
  78. FieldAttrPtr = ^FieldAttrType;
  79. LineInfoType = record
  80. {$ifdef ALLOW_ACCESS_TO_INTERNALS_OF_FIELDS} // These fields will not be available in the next OS release!
  81. start: UInt16; // position in text string of first char.
  82. length: UInt16; // number of character in the line
  83. {$endif}
  84. end;
  85. LineInfoTag = LineInfoType;
  86. LineInfoPtr = ^LineInfoType;
  87. FieldType = record
  88. {$ifdef ALLOW_ACCESS_TO_INTERNALS_OF_FIELDS} // These fields will not be available in the next OS release!
  89. id: UInt16;
  90. rect: RectangleType;
  91. attr: FieldAttrType;
  92. text: PChar; // pointer to the start of text string
  93. textHandle: MemHandle; // block the contains the text string
  94. lines: LineInfoPtr;
  95. textLen: UInt16;
  96. textBlockSize: UInt16;
  97. maxChars: UInt16;
  98. selFirstPos: UInt16;
  99. selLastPos: UInt16;
  100. insPtXPos: UInt16;
  101. insPtYPos: UInt16;
  102. fontID: FontID;
  103. maxVisibleLines: UInt8; // added in 4.0 to support FldSetMaxVisibleLines
  104. {$endif}
  105. end;
  106. FieldPtr = ^FieldType; // deprecated, use FieldType *
  107. //---------------------------------------------------------------------
  108. // Field Functions
  109. //---------------------------------------------------------------------
  110. procedure FldCopy(const fldP: FieldPtr); syscall sysTrapFldCopy;
  111. procedure FldCut(fldP: FieldPtr); syscall sysTrapFldCut;
  112. procedure FldDrawField(fldP: FieldPtr); syscall sysTrapFldDrawField;
  113. procedure FldEraseField(fldP: FieldPtr); syscall sysTrapFldEraseField;
  114. procedure FldFreeMemory(fldP: FieldPtr); syscall sysTrapFldFreeMemory;
  115. procedure FldGetBounds(const fldP: FieldPtr; rect: RectanglePtr); syscall sysTrapFldGetBounds;
  116. function FldGetFont(const fldP: FieldPtr): FontID; syscall sysTrapFldGetFont;
  117. procedure FldGetSelection(const fldP: FieldPtr; var startPosition, endPosition: UInt16); syscall sysTrapFldGetSelection;
  118. function FldGetTextHandle(const fldP: FieldPtr): MemHandle; syscall sysTrapFldGetTextHandle;
  119. function FldGetTextPtr(const fldP: FieldPtr): PChar; syscall sysTrapFldGetTextPtr;
  120. function FldHandleEvent(fldP: FieldPtr; eventP: EventPtr): Boolean; syscall sysTrapFldHandleEvent;
  121. procedure FldPaste(fldP: FieldPtr); syscall sysTrapFldPaste;
  122. procedure FldRecalculateField(fldP: FieldPtr; redraw: Boolean); syscall sysTrapFldRecalculateField;
  123. procedure FldSetBounds(fldP: FieldPtr; const rP: RectanglePtr); syscall sysTrapFldSetBounds;
  124. procedure FldSetFont(fldP: FieldPtr; fontID: FontID); syscall sysTrapFldSetFont;
  125. procedure FldSetText(fldP: FieldPtr; textHandle: MemHandle; offset, size: UInt16); syscall sysTrapFldSetText;
  126. procedure FldSetTextHandle(fldP: FieldPtr; textHandle: MemHandle); syscall sysTrapFldSetTextHandle;
  127. procedure FldSetTextPtr(fldP: FieldPtr; textP: PChar); syscall sysTrapFldSetTextPtr;
  128. procedure FldSetUsable(fldP: FieldPtr; usable: Boolean); syscall sysTrapFldSetUsable;
  129. procedure FldSetSelection(fldP: FieldPtr; startPosition, endPosition: UInt16); syscall sysTrapFldSetSelection;
  130. procedure FldGrabFocus(fldP: FieldPtr); syscall sysTrapFldGrabFocus;
  131. procedure FldReleaseFocus(fldP: FieldPtr); syscall sysTrapFldReleaseFocus;
  132. function FldGetInsPtPosition(const fldP: FieldPtr): UInt16; syscall sysTrapFldGetInsPtPosition;
  133. procedure FldSetInsPtPosition(fldP: FieldPtr; pos: UInt16); syscall sysTrapFldSetInsPtPosition;
  134. procedure FldSetInsertionPoint(fldP: FieldPtr; pos: UInt16); syscall sysTrapFldSetInsertionPoint;
  135. function FldGetScrollPosition(const fldP: FieldPtr): UInt16; syscall sysTrapFldGetScrollPosition;
  136. procedure FldSetScrollPosition(fldP: FieldPtr; pos: UInt16); syscall sysTrapFldSetScrollPosition;
  137. procedure FldGetScrollValues(const fldP: FieldPtr; var scrollPosP, textHeightP, fieldHeightP: UInt16); syscall sysTrapFldGetScrollValues;
  138. function FldGetTextLength(const fldP: FieldPtr): UInt16; syscall sysTrapFldGetTextLength;
  139. procedure FldScrollField(fldP: FieldPtr; linesToScroll: UInt16; direction: WinDirectionType); syscall sysTrapFldScrollField;
  140. function FldScrollable(const fldP: FieldPtr; direction: WinDirectionType): Boolean; syscall sysTrapFldScrollable;
  141. function FldGetVisibleLines(const fldP: FieldPtr): UInt16; syscall sysTrapFldGetVisibleLines;
  142. function FldGetTextHeight(const fldP: FieldPtr): UInt16; syscall sysTrapFldGetTextHeight;
  143. function FldCalcFieldHeight(const chars: PChar; maxWidth: UInt16): UInt16; syscall sysTrapFldCalcFieldHeight;
  144. function FldWordWrap(const chars: PChar; maxWidth: Int16): UInt16; syscall sysTrapFldWordWrap;
  145. procedure FldCompactText(fldP: FieldPtr); syscall sysTrapFldCompactText;
  146. function FldDirty(const fldP: FieldPtr): Boolean; syscall sysTrapFldDirty;
  147. procedure FldSetDirty(fldP: FieldPtr; dirty: Boolean); syscall sysTrapFldSetDirty;
  148. function FldGetMaxChars(const fldP: FieldPtr): UInt16; syscall sysTrapFldGetMaxChars;
  149. procedure FldSetMaxChars(fldP: FieldPtr; maxChars: UInt16); syscall sysTrapFldSetMaxChars;
  150. function FldInsert(fldP: FieldPtr; const insertChars: PChar; insertLen: UInt16): Boolean; syscall sysTrapFldInsert;
  151. procedure FldDelete(fldP: FieldPtr; start, end_: UInt16); syscall sysTrapFldDelete;
  152. procedure FldUndo(fldP: FieldPtr); syscall sysTrapFldUndo;
  153. function FldGetTextAllocatedSize(const fldP: FieldPtr): UInt16; syscall sysTrapFldGetTextAllocatedSize;
  154. procedure FldSetTextAllocatedSize(fldP: FieldPtr; allocatedSize: UInt16); syscall sysTrapFldSetTextAllocatedSize;
  155. procedure FldGetAttributes(const fldP: FieldPtr; attrP: FieldAttrPtr); syscall sysTrapFldGetAttributes;
  156. procedure FldSetAttributes(fldP: FieldPtr; const attrP: FieldAttrPtr); syscall sysTrapFldSetAttributes;
  157. procedure FldSendChangeNotification(const fldP: FieldPtr); syscall sysTrapFldSendChangeNotification;
  158. procedure FldSendHeightChangeNotification(const fldP: FieldPtr; pos: UInt16; numLines: Int16); syscall sysTrapFldSendHeightChangeNotification;
  159. function FldMakeFullyVisible(fldP: FieldPtr): Boolean; syscall sysTrapFldMakeFullyVisible;
  160. function FldGetNumberOfBlankLines(const fldP: FieldPtr): UInt16; syscall sysTrapFldGetNumberOfBlankLines;
  161. function FldNewField(formPP: PointerPtr; id: UInt16; x, y, width, height: Coord;
  162. font: FontID; maxChars: UInt32; editable, underlined, singleLine, dynamicSize: Boolean;
  163. justification: JustificationType; autoShift, hasScrollBar, numeric: Boolean): FieldPtr; syscall sysTrapFldNewField;
  164. // added in 4.0
  165. procedure FldSetMaxVisibleLines(fldP: FieldPtr; maxLines: UInt8); syscall sysTrapFldSetMaxVisibleLines;
  166. implementation
  167. end.