field.pp 8.9 KB

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