home *** CD-ROM | disk | FTP | other *** search
- {$V-}
-
- (*
-
- WFIELD1
- -------
- This program is an example of a Memo window embedded within a data entry
- screen. Points worth noting:
-
- 1) MemoCommands.AddCommand is used to make <CtrlEnter> an exit command
- (ccUser0) for the memo window. The post-edit routine for the entry
- screen then remaps ccUser0 to ccNextField. (Memo.Process doesn't
- consider ccNextField to be an exit command.)
-
- 2) By turning off the efAllowEscape option before calling AddWindowField,
- we tell OPENTRY to treat the ccQuit command (<Esc>) as equivalent
- to ccNextField when it is issued within the DirList.
-
- 3) If UseAdjustableWindows is defined, the child window does not have to
- be positioned correctly at the time it is instantiated; it just needs
- to be the right width and height. OPENTRY will move it into position
- if necessary. If UseAdjustableWIndows is not defined, it *must* be
- positioned correctly, because OPENTRY has no way to move it.
-
- 4) The wNoCoversBuffer option is used for the Memo field to limit memory
- usage.
-
- *)
-
- program WFIELD1;
-
- {$I OPDEFINE.INC}
-
- uses
- Dos,
- OpInline,
- OpString,
- OpRoot,
- OpCrt,
- {$IFDEF UseMouse}
- OpMouse,
- {$ENDIF}
- OpAbsFld,
- OpCmd,
- OpField,
- OpFrame,
- OpWindow,
- OpSelect,
- OpEntry,
- OpMemo;
-
- {$IFDEF UseMouse}
- const
- MouseChar : Char = #04;
- {$ENDIF}
-
- {Color set used by entry screen}
- const
- EsColors : ColorSet = (
- TextColor : $1E; TextMono : $0F;
- CtrlColor : $1E; CtrlMono : $0F;
- FrameColor : $13; FrameMono : $0F;
- HeaderColor : $3F; HeaderMono : $70;
- ShadowColor : $08; ShadowMono : $08;
- HighlightColor : $4F; HighlightMono : $70;
- PromptColor : $1F; PromptMono : $07;
- SelPromptColor : $1F; SelPromptMono : $07;
- ProPromptColor : $17; ProPromptMono : $07;
- FieldColor : $1E; FieldMono : $0F;
- SelFieldColor : $31; SelFieldMono : $70;
- ProFieldColor : $17; ProFieldMono : $07;
- ScrollBarColor : $13; ScrollBarMono : $07;
- SliderColor : $13; SliderMono : $0F;
- HotSpotColor : $30; HotSpotMono : $70;
- BlockColor : $3E; BlockMono : $0F;
- MarkerColor : $3F; MarkerMono : $70;
- DelimColor : $1E; DelimMono : $0F;
- SelDelimColor : $31; SelDelimMono : $0F;
- ProDelimColor : $1E; ProDelimMono : $0F;
- SelItemColor : $3E; SelItemMono : $70;
- ProItemColor : $17; ProItemMono : $07;
- HighItemColor : $1F; HighItemMono : $0F;
- AltItemColor : $1F; AltItemMono : $0F;
- AltSelItemColor : $3F; AltSelItemMono : $70;
- FlexAHelpColor : $1F; FlexAHelpMono : $0F;
- FlexBHelpColor : $1F; FlexBHelpMono : $0F;
- FlexCHelpColor : $1B; FlexCHelpMono : $70;
- UnselXrefColor : $1E; UnselXrefMono : $09;
- SelXrefColor : $3F; SelXrefMono : $70;
- MouseColor : $4F; MouseMono : $70
- );
-
- {Entry field constants}
- const
- idName = 0;
- idAddress = 1;
- idCity = 2;
- idPhone = 3;
- idMemo = 4;
-
- type
- UserRecord =
- record
- Name : string[25];
- Address : string[25];
- City : string[25];
- Phone : string[14];
- MemoField : array[1..4096] of Char;
- end;
- var
- ES : EntryScreen;
- M : Memo;
- UR : UserRecord;
- Status : Word;
-
- {$F+}
- procedure PostEdit(ESP : EntryScreenPtr);
- {-Called just after a field has been edited}
- begin
- with ESP^ do
- if GetCurrentID = idMemo then
- if GetLastCommand = ccUser0 then
- SetLastCommand(ccNextField);
- end;
- {$F-}
-
- function InitEntryScreen : Word;
- {-Initialize entry screen generated by MAKESCRN}
- const
- Frame1 = '┌└┐┘──││';
- WinOptions = wBordered+wClear+wUserContents;
- begin
- with ES do begin
- if not InitCustom(7, 5, 72, 20, EsColors, WinOptions) then begin
- InitEntryScreen := InitStatus;
- Exit;
- end;
-
- wFrame.SetFrameType(Frame1);
- SetWrapMode(WrapAtEdges);
-
- SetPostEditProc(PostEdit);
-
- wFrame.AddSpanHeader('├', '─', '┤', 5, frTT);
- wFrame.AddCustomHeader(' Notes ', frTL, 5, 5,
- EsColors.PromptColor, EsColors.PromptMono);
-
- {idName:}
- AddStringField(
- 'Name', 1, 7,
- CharStr('x', 25), 1, 13, 25,
- 1, UR.Name);
-
- {idAddress:}
- AddStringField(
- 'Address', 2, 4,
- CharStr('x', 25), 2, 13, 25,
- 2, UR.Address);
-
- {idAddress:}
- AddStringField(
- 'City', 3, 7,
- CharStr('x', 25), 3, 13, 25,
- 2, UR.City);
-
- {idPhone:}
- AddStringField(
- 'Phone', 4, 6,
- '(999) 999-9999', 4, 13, 14,
- 3, UR.Phone);
-
- {idMemo:}
- esFieldOptionsOff(efAllowEscape);
- AddWindowField(
- '', 6, 2,
- 6, 2,
- 4, M);
-
- InitEntryScreen := GetLastError;
- end;
- end;
-
- begin
- {initialize user record}
- FillChar(UR, SizeOf(UR), 0);
- FillChar(UR.MemoField, SizeOf(UR.MemoField), ^Z);
-
- {make <CtrlEnter> an exit command}
- MemoCommands.AddCommand(ccUser0, 1, Ord(^J), 0);
-
- {initialize memo field editor}
- if not M.InitCustom(
- {$IFDEF UseAdjustableWindows}
- 1, 1, 64, 11, {let OPENTRY move it into position}
- {$ELSE}
- 8, 10, 71, 20,
- {$ENDIF}
- EsColors, DefWindowOptions or wNoCoversBuffer, 4096, @UR.MemoField) then
- Status := InitStatus
- else
- Status := 0;
- if Status <> 0 then begin
- WriteLn('Error initializing memo field: ', Status);
- Halt(1);
- end;
-
- {initialize entry screen}
- Status := InitEntryScreen;
- if Status <> 0 then begin
- WriteLn('Error initializing entry screen: ', Status);
- Halt(1);
- end;
-
- {clear the screen}
- TextChar := #178;
- TextAttr := 7;
- ClrScr;
-
- {$IFDEF UseMouse}
- if MouseInstalled then
- with EsColors do begin
- {activate mouse cursor}
- SoftMouseCursor($0000, (ColorMono(MouseColor, MouseMono) shl 8)+
- Byte(MouseChar));
- ShowMouse;
- {enable mouse support}
- EntryCommands.cpOptionsOn(cpEnableMouse);
- MemoCommands.cpOptionsOn(cpEnableMouse);
- end;
- {$ENDIF}
-
- ES.Process;
-
- ES.Erase;
-
- {$IFDEF UseMouse}
- HideMouse;
- {$ENDIF}
-
- {show exit command}
- ClrScr;
- WriteLn('Exit command = ', ES.GetLastCommand);
-
- {dispose of the parent *and* its children}
- ES.Done;
- end.