summaryrefslogtreecommitdiff
path: root/fpcsrc/packages/palmunits/src/field.pp
blob: 7258c421783b93fb9ab3f739e7ce7bc68cdd7e00 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
(******************************************************************************
 *
 * Copyright (c) 1994-2000 Palm, Inc. or its subsidiaries.
 * All rights reserved.
 *
 * File: Field.h
 *
 * Release: Palm OS SDK 4.0 (63220)
 *
 * Description:
 *   This file defines field structures and routines.
 *
 * History:
 *    August 29, 1994   Created by Art Lamb
 *
 *****************************************************************************)
unit field;

interface

uses palmos, coretraps, rect, font, window, control;

const
  maxFieldTextLen = $7fff;

// default maximun number of line the a dynamicly sizing field will expand to.
// Can be changed with FldSetMaxVisibleLines

  maxFieldLines = 11;

// kind alignment values
type
  justifications = Enum;

const
  leftAlign = 0;
  centerAlign = Succ(leftAlign);
  rightAlign = Succ(centerAlign);

type
  JustificationType = justifications;

const
  undoBufferSize = 100;

type
  UndoMode = enum;

const
  undoNone = 0;
  undoTyping = Succ(undoNone);
  undoBackspace = Succ(undoTyping);
  undoDelete = Succ(undoBackspace);
  undoPaste = Succ(undoDelete);
  undoCut = Succ(undoPaste);
  undoInput = Succ(undoCut);

type
  FieldUndoType = record
  {$ifdef ALLOW_ACCESS_TO_INTERNALS_OF_FIELDS} // These fields will not be available in the next OS release!
    mode: UndoMode;
    reserved: UInt8;
    start: UInt16;
    end_: UInt16;
    bufferLen: UInt16;
    buffer: PChar;
  {$endif}
  end;
  FieldUndoTag = FieldUndoType;

  FieldAttrType = record
    Bits: UInt16;
{
 UInt16 usable   :1; // Set if part of ui
 UInt16 visible   :1; // Set if drawn, used internally
 UInt16 editable  :1; // Set if editable
 UInt16 singleLine  :1; // Set if only a single line is displayed
 UInt16 hasFocus      :1;   // Set if the field has the focus
 UInt16 dynamicSize :1;   // Set if height expands as text is entered
 UInt16 insPtVisible :1; // Set if the ins pt is scolled into view
 UInt16 dirty   :1; // Set if user modified
 UInt16 underlined  :2; // text underlined mode
 UInt16 justification :2; // text alignment
 UInt16 autoShift  :1; // Set if auto case shift
 UInt16 hasScrollBar :1; // Set if the field has a scroll bar
 UInt16 numeric   :1; // Set if numeric, digits and secimal separator only
 UInt16 reserved  :1;   // Reserved for future use
}
  end;
  FieldAttrTag = FieldAttrType;
  FieldAttrPtr = ^FieldAttrType;

  LineInfoType = record
  {$ifdef ALLOW_ACCESS_TO_INTERNALS_OF_FIELDS} // These fields will not be available in the next OS release!
    start: UInt16;  // position in text string of first char.
    length: UInt16; // number of character in the line
  {$endif}
  end;
  LineInfoTag = LineInfoType;
  LineInfoPtr = ^LineInfoType;

  FieldType = record
  {$ifdef ALLOW_ACCESS_TO_INTERNALS_OF_FIELDS} // These fields will not be available in the next OS release!
    id: UInt16;
    rect: RectangleType;
    attr: FieldAttrType;
    text: PChar; // pointer to the start of text string
    textHandle: MemHandle; // block the contains the text string
    lines: LineInfoPtr;
    textLen: UInt16;
    textBlockSize: UInt16;
    maxChars: UInt16;
    selFirstPos: UInt16;
    selLastPos: UInt16;
    insPtXPos: UInt16;
    insPtYPos: UInt16;
    fontID: FontID;
    maxVisibleLines: UInt8; // added in 4.0 to support FldSetMaxVisibleLines
  {$endif}
  end;

  FieldPtr = ^FieldType; // deprecated, use FieldType *

//---------------------------------------------------------------------
// Field Functions
//---------------------------------------------------------------------

procedure FldCopy(const fldP: FieldPtr); syscall sysTrapFldCopy;

procedure FldCut(fldP: FieldPtr); syscall sysTrapFldCut;

procedure FldDrawField(fldP: FieldPtr); syscall sysTrapFldDrawField;

procedure FldEraseField(fldP: FieldPtr); syscall sysTrapFldEraseField;

procedure FldFreeMemory(fldP: FieldPtr); syscall sysTrapFldFreeMemory;

procedure FldGetBounds(const fldP: FieldPtr; rect: RectanglePtr); syscall sysTrapFldGetBounds;

function FldGetFont(const fldP: FieldPtr): FontID; syscall sysTrapFldGetFont;

procedure FldGetSelection(const fldP: FieldPtr; var startPosition, endPosition: UInt16); syscall sysTrapFldGetSelection;

function FldGetTextHandle(const fldP: FieldPtr): MemHandle; syscall sysTrapFldGetTextHandle;

function FldGetTextPtr(const fldP: FieldPtr): PChar; syscall sysTrapFldGetTextPtr;

function FldHandleEvent(fldP: FieldPtr; eventP: EventPtr): Boolean; syscall sysTrapFldHandleEvent;

procedure FldPaste(fldP: FieldPtr); syscall sysTrapFldPaste;

procedure FldRecalculateField(fldP: FieldPtr; redraw: Boolean); syscall sysTrapFldRecalculateField;

procedure FldSetBounds(fldP: FieldPtr; const rP: RectanglePtr); syscall sysTrapFldSetBounds;

procedure FldSetFont(fldP: FieldPtr; fontID: FontID); syscall sysTrapFldSetFont;

procedure FldSetText(fldP: FieldPtr; textHandle: MemHandle; offset, size: UInt16); syscall sysTrapFldSetText;

procedure FldSetTextHandle(fldP: FieldPtr; textHandle: MemHandle); syscall sysTrapFldSetTextHandle;

procedure FldSetTextPtr(fldP: FieldPtr; textP: PChar); syscall sysTrapFldSetTextPtr;

procedure FldSetUsable(fldP: FieldPtr; usable: Boolean); syscall sysTrapFldSetUsable;

procedure FldSetSelection(fldP: FieldPtr; startPosition, endPosition: UInt16); syscall sysTrapFldSetSelection;

procedure FldGrabFocus(fldP: FieldPtr); syscall sysTrapFldGrabFocus;

procedure FldReleaseFocus(fldP: FieldPtr); syscall sysTrapFldReleaseFocus;

function FldGetInsPtPosition(const fldP: FieldPtr): UInt16; syscall sysTrapFldGetInsPtPosition;

procedure FldSetInsPtPosition(fldP: FieldPtr; pos: UInt16); syscall sysTrapFldSetInsPtPosition;

procedure FldSetInsertionPoint(fldP: FieldPtr; pos: UInt16); syscall sysTrapFldSetInsertionPoint;

function FldGetScrollPosition(const fldP: FieldPtr): UInt16; syscall sysTrapFldGetScrollPosition;

procedure FldSetScrollPosition(fldP: FieldPtr; pos: UInt16); syscall sysTrapFldSetScrollPosition;

procedure FldGetScrollValues(const fldP: FieldPtr; var scrollPosP, textHeightP, fieldHeightP: UInt16); syscall sysTrapFldGetScrollValues;

function FldGetTextLength(const fldP: FieldPtr): UInt16; syscall sysTrapFldGetTextLength;

procedure FldScrollField(fldP: FieldPtr; linesToScroll: UInt16; direction: WinDirectionType); syscall sysTrapFldScrollField;

function FldScrollable(const fldP: FieldPtr; direction: WinDirectionType): Boolean; syscall sysTrapFldScrollable;

function FldGetVisibleLines(const fldP: FieldPtr): UInt16; syscall sysTrapFldGetVisibleLines;

function FldGetTextHeight(const fldP: FieldPtr): UInt16; syscall sysTrapFldGetTextHeight;

function FldCalcFieldHeight(const chars: PChar; maxWidth: UInt16): UInt16; syscall sysTrapFldCalcFieldHeight;

function FldWordWrap(const chars: PChar; maxWidth: Int16): UInt16; syscall sysTrapFldWordWrap;

procedure FldCompactText(fldP: FieldPtr); syscall sysTrapFldCompactText;

function FldDirty(const fldP: FieldPtr): Boolean; syscall sysTrapFldDirty;

procedure FldSetDirty(fldP: FieldPtr; dirty: Boolean); syscall sysTrapFldSetDirty;

function FldGetMaxChars(const fldP: FieldPtr): UInt16; syscall sysTrapFldGetMaxChars;

procedure FldSetMaxChars(fldP: FieldPtr; maxChars: UInt16); syscall sysTrapFldSetMaxChars;

function FldInsert(fldP: FieldPtr; const insertChars: PChar; insertLen: UInt16): Boolean; syscall sysTrapFldInsert;

procedure FldDelete(fldP: FieldPtr; start, end_: UInt16); syscall sysTrapFldDelete;

procedure FldUndo(fldP: FieldPtr); syscall sysTrapFldUndo;

function FldGetTextAllocatedSize(const fldP: FieldPtr): UInt16; syscall sysTrapFldGetTextAllocatedSize;

procedure FldSetTextAllocatedSize(fldP: FieldPtr; allocatedSize: UInt16); syscall sysTrapFldSetTextAllocatedSize;

procedure FldGetAttributes(const fldP: FieldPtr; attrP: FieldAttrPtr); syscall sysTrapFldGetAttributes;

procedure FldSetAttributes(fldP: FieldPtr; const attrP: FieldAttrPtr); syscall sysTrapFldSetAttributes;

procedure FldSendChangeNotification(const fldP: FieldPtr); syscall sysTrapFldSendChangeNotification;

procedure FldSendHeightChangeNotification(const fldP: FieldPtr; pos: UInt16; numLines: Int16); syscall sysTrapFldSendHeightChangeNotification;

function FldMakeFullyVisible(fldP: FieldPtr): Boolean; syscall sysTrapFldMakeFullyVisible;

function FldGetNumberOfBlankLines(const fldP: FieldPtr): UInt16; syscall sysTrapFldGetNumberOfBlankLines;

function  FldNewField(formPP: PointerPtr; id: UInt16; x, y, width, height: Coord;
                      font: FontID; maxChars: UInt32; editable, underlined, singleLine, dynamicSize: Boolean;
                      justification: JustificationType; autoShift, hasScrollBar, numeric: Boolean): FieldPtr; syscall sysTrapFldNewField;

// added in 4.0
procedure FldSetMaxVisibleLines(fldP: FieldPtr; maxLines: UInt8); syscall sysTrapFldSetMaxVisibleLines;

implementation

end.