Module text_win.pkg
1//************************************************************************
2//
3// Confidential Trade Secret.
4// Copyright 1987-1992 Data Access Corporation, Miami FL, USA
5// All Rights reserved
6// DataFlex is a registered trademark of Data Access Corporation.
7//
8//
9// $Source: k:\RCS\.\pkg\text_win.pkg,v $
10// $Revision: 1 $
11// $State: Exp $
12// $Author: james $
13// $Date: Apr 01 16:09:34 1997 $
14// $Locker: $
15//
16// $Log: text_win.pkg,v $
17//Revision 2.1 1993/08/25 17:49:49 james
18//Adding new main branch
19//
20//Revision 1.2 1993/04/28 00:20:34 james
21//Initializing 3.04 source code.
22//
23//Revision 1.1 1992/09/08 14:43:09 james
24//Initial revision
25//
26//Revision 1.14 92/06/10 02:27:53 lee
27//child wrapping now saves if autosave in origin OR in current object
28//
29//Revision 1.13 92/06/03 15:17:46 steve-l
30//altered Child_Wrapping for proper argument dereferencing
31//
32//Revision 1.12 92/06/03 15:10:46 steve-l
33//altered child_Wrapping for new argument
34//
35//Revision 1.11 92/06/01 17:57:26 steve-l
36//guarded REQUEST_SAVE behavior with server=0 | not(read-only(server))
37//
38//Revision 1.10 92/05/29 19:14:53 steve-l
39//REFRESH message altered to send entry_clear_all or entry_clear plus entry_display.
40//Old code retained commented-out in case of later re-optimization.
41//
42//Revision 1.9 92/05/29 14:05:54 lee
43//removed end_construct_* messages from mixins; now, classes that use the mixin
44//send the message that used to be sent by the end_construct_* message (for
45//efficiency).
46//
47//Revision 1.8 92/05/14 17:11:41 SWM
48//Updated Copyright slug.
49//
50//Revision 1.7 92/03/29 18:45:20 lee
51//added MSG_END_CONSTRUCT_OBJECT, moved ENDMAC macro stuff into END_CONSTRUCT-
52//OBJECT procedures (in .pkgs). moved Flag_ITems to list.pkg after generalizing
53//it based on PROTOTYPE_OBJECT instead of Whether or not it is a table-oriented
54//object. Moved define_access_keys mechanism completely into actionbr.pkg.
55//fixed two typos: import_class_protocol used !# instead of !3, and register-
56//procedure used !1 instead of !2.
57//
58//Revision 1.6 92/03/09 19:05:02 james
59//Added #CHKSUB directive to insure source
60//only compiled with correct revision of
61//compiler.
62//
63//Revision 1.5 92/03/05 15:44:40 steve-l
64//Request_Superfind changed to set ERR false before calling server and to
65//check err (with found) afterward, in case of non-file-boundary errors.
66//Cut_Marked_Area and Paste messages altered to set Changed_State to true.
67//
68//Revision 1.4 92/01/13 14:49:12 steve-l
69//Added MSG_REFRESH
70//
71//Revision 1.3 92/01/12 15:27:38 steve-l
72//*** empty log message ***
73//
74//Revision 1.2 91/11/08 09:19:47 steve-l
75//it
76//
77//************************************************************************/
78
79//************************************************************************
80// File Name: Text_Win.Pkg
81// Creation Date: January 1, 1991
82// Modified Date: January 13, 1992
83// Author(s): Steven A. Lowe
84//
85// This module contains the Text_Window class definition.
86//
87// This package implements an editing object for variable-length text fields
88// and sequential files.
89//************************************************************************/
90
91//************************************************************************
92// Version: 1.0
93// 12-92-1992 : Created
94//
95// Author: John J. Tuohy
96//
97// 1. Adds Stop_UI_State Support
98// 2. Adds Should_Save Property // (LS) moved into server.pkg
99// 3. Modifies Changed_State to check Should_save (fixes RT bug) (LS - undid this mod)
100//
101// 10-07-1993 Add include file with new exit_function procedure. RT bug
102// 03-21-1994 (LS) v1.1 Added Non_Dependent_Item_Mixin (for manual
103// bcst/delg).
104// 04-08-1994 (LS) v1.1 Added DEO delegation.
105//************************************************************************/
106
107//************************************************************************/
108// 12/22/94 JJT Merge Changes
109// Merged the 0 class into entry_form.
110// Added DEO delegate logic to request_???? messages.
111// Changed Request_save to set chagned_state to false
112// after a server-less save performs a write
113// 05/22/95 JJT Added object_validation to focus support in request_clear
114// and request_clear_all (also see deodlgmx.pkg)
115// 08/29/95 JJT Fixed entry_update to respect parameters properly.
116// 09/04/95 JJT - Code Clean up (removed dead commented code)
117//************************************************************************/
118
119
120#CHKSUB 1 1 // Verify the UI subsystem.
121
122use NESTING.pkg //include DEO nesting standard support module
123use NAVIGATE.pkg //include DEO navigation standard support module
124use VERIFY.pkg //include Verification support module
125use SERVER.pkg //include Server support module
126use ACTIONBR.pkg //include action-bar support module
127use FINDEDIT.pkg //include Finding/Editing support module
128use refmodes.pkg //refresh mode constants
129Use Dep_Item.pkg // Auto-Dependent_Item Support v1.1
130Use DEODlgMx.pkg // v1.1 DEO delegation support
131
132//
133//Class: Text_Window
134//
135//SuperClass: EDIT
136//
137//Description: This class implements a text-editing object suitable for
138// use with Entry_Form and Table objects, which may be bound to a
139// sequential ASCII file or a database memo-field
140//
141// Usage: object tw is a Text_Window FOR file.fieldname
142// set location to ...
143// set right_margin to ...
144// set size to ...
145// end_object
146//
147
148class Text_Window_mixin is a mixin
149 //
150 //Operation: CONSTRUCT_OBJECT
151 //
152 //Assumption(s): none
153 //
154 //Goal(s): define an instance with appropriate keys and properties
155 //
156 //Algorithm: relies on support module constructors
157 //
158 //Usage: used internally
159 //
160 procedure Construct_Object
161 forward send construct_object
162 on_key kPrompt SEND Prompt PRIVATE
163 on_key kZoom SEND Zoom PRIVATE
164 { Visibility=Private }
165 Property integer Private.Data_File
166 { Visibility=Private }
167 Property integer Private.Data_Field
168 send define_nesting //invoke DEO nesting standard support constructor
169 send define_navigation //invoke DEO navigation standard support constructor
170 send define_verify //invoke verify support constructor
171 send define_server //invoke server support constructor
172 send define_action_bar //invoke action-bar support constructor
173 send define_find_edit //invoke Finding/Editing support constructor
174 // for text editors, begin/end of data do what they always did. Jump to top/botton of edit
175 on_key kBegin_of_Data SEND Beginning_of_Data PRIVATE
176 on_key kEnd_of_Data SEND End_of_Data PRIVATE
177 Send Define_DEO_Delegate // v1.1
178 end_procedure
179
180 IMPORT_CLASS_PROTOCOL Nesting_Mixin //these statements
181 IMPORT_CLASS_PROTOCOL Navigate_Mixin //import the methods
182 IMPORT_CLASS_PROTOCOL Verify_Mixin //from the mixins
183 IMPORT_CLASS_PROTOCOL Server_Mixin //into the current class
184 IMPORT_CLASS_PROTOCOL Action_Bar_Mixin //instead of using
185 IMPORT_CLASS_PROTOCOL Find_Edit_Mixin //bulky include-files
186
187 IMPORT_CLASS_PROTOCOL Non_Dependent_Item_Mixin // v1.1
188 IMPORT_CLASS_PROTOCOL DEO_Delegate_Mixin // ver 1.1
189
190 procedure Zoom
191 end_procedure
192
193 procedure Prompt
194 end_procedure
195
196 //
197 // created for server and EntItem support
198 //
199 // returns non-zero if data invalid, 0 if no error (valid)
200 // no action by default; intended for augmentation/override
201 //
202 // NOTE: if this object's validation fails, this object should
203 // take the focus.
204 //
205 Function Validate_Items Boolean bNotFindReq Returns Integer
206 end_function
207
208 //
209 // created for Server support
210 //
211 { Visibility=Private }
212 procedure Display
213 send entry_display 0 0
214 end_procedure
215
216 //
217 // created for Server support
218 //
219 { Visibility=Private }
220 procedure Clear
221 send entry_clear 1
222 end_procedure
223
224 //
225 // created for Server support
226 //
227 { Visibility=Private }
228 procedure Clear_All
229 send entry_clear_all 1
230 end_procedure
231
232 //
233 // created for Server support
234 //
235 { Visibility=Private }
236 procedure Clear_Set
237 send entry_clear 1
238 end_procedure
239
240 //
241 // created for FindEdit support
242 //
243 procedure Request_Clear
244 Integer obj# foc retval
245 If (Should_delegate_Clear(self)) ;
246 Delegate Send Request_Clear
247 Else Begin
248 get Server to obj#
249 //
250 // modification for Verify support
251 //
252 if (Should_Save(self) AND ;
253 (Verify_Data_Loss(self) <> 0)) ;
254 procedure_return
255
256 Get Focus of desktop to Foc
257 get Object_Item_Validation of Foc to retval
258 set Object_Item_Validation of Foc to false
259 //
260 // modification for Server support
261 //
262 if obj# ne 0 send clear to obj#
263 else send entry_clear 0
264 if (Auto_Top_Panel_State(self)) send beginning_of_panel
265 set Object_Item_Validation of Foc to retval
266 End
267 end_procedure
268
269 //
270 // created for FindEdit support
271 //
272 procedure Request_Clear_All
273 Integer obj# foc retval
274 If (Should_delegate_Clear(self)) ;
275 Delegate Send Request_Clear_all
276 Else Begin
277 get Server to obj#
278 //
279 // modification for Verify support
280 //
281 if (Should_Save(self) AND ;
282 (Verify_Data_Loss(self) <> 0)) ;
283 procedure_return
284
285 Get Focus of desktop to Foc
286 get Object_Item_Validation of Foc to retval
287 set Object_Item_Validation of Foc to false
288 //
289 // modification for Server support
290 //
291 if obj# ne 0 send clear_all to obj#
292 else send entry_clear_all 0
293 if (Auto_Top_Panel_State(self)) send beginning_of_panel
294 set Object_Item_Validation of Foc to retval
295 End
296 end_procedure
297
298 //
299 // created for FindEdit support
300 //
301 procedure Request_Delete
302 Integer obj#
303 If (Should_delegate_Delete(self)) ;
304 Delegate Send Request_Delete
305 Else Begin
306 indicate err false
307 get Server to obj#
308 if (obj# <> 0 AND can_delete(obj#) <> 0) begin
309 //
310 // modification for Verify support
311 //
312 if (Verify_Delete(self) <> 0) procedure_return
313 //
314 // modification for Server support
315 //
316 set changed_State to false
317 if (Deferred_State(self)) ;
318 send Request_Assign to obj# 0 //0 means main_file of Server
319 send Request_Delete to obj#
320 // ignore auto_clear_deo_state in deletes. Always clear deleted record
321 If (not(err)) send Request_Clear
322 //[not err] if (Auto_Clear_DEO_State(self)) send Request_Clear
323 end
324 end
325 end_procedure
326
327 //
328 // created for FindEdit support
329 //
330 procedure Request_Save
331 Integer obj# chgdFlag retval
332 If (Should_delegate_Save(self)) ;
333 Delegate Send Request_Save
334 Else Begin
335 get Server to obj#
336 if (obj# = 0 OR not(Read_Only_State(obj#))) begin
337 indicate err false
338 if (Should_Save(self)) begin
339 if obj# ne 0 get Request_Validate of obj# to retval
340 else get Validate_Items FALSE to retval
341 if retval ne 0 procedure_Return
342 //
343 // modification for Verify support
344 //
345 if (Verify_Save(self) <> 0) procedure_return
346 //
347 // modification for Server support
348 //
349 if obj# ne 0 begin
350 if (Deferred_State(self)) ;
351 send Request_Assign to obj# 0 //0 means main_file of server
352 send Request_Save to obj#
353 end
354 else Begin
355 send write
356 // (JJT) added to make non-server text file unchanged after
357 // save.
358 Set Changed_state to False
359 end
360 end
361 [not err] if (Auto_Clear_DEO_State(self)) send Request_Clear
362 end
363 end
364 end_procedure
365
366 // this allows us to save a record without it clearing regardless of
367 // the Auto_Clear_DEO_State value
368 //
369 Procedure Request_Save_No_Clear
370 integer oldclr
371 If (Should_delegate_Save(self)) ;
372 Delegate Send Request_Save_no_Clear
373 Else Begin
374 Get Auto_Clear_DEO_State to OldClr // whatever it was
375 Set Auto_Clear_DEO_State to False // it is now NO!
376 send request_save // do your magic
377 Set Auto_Clear_DEO_State to OldClr // back to whatever it was
378 End
379 End_procedure
380
381 //
382 // FindEdit support behavior
383 //
384 procedure Request_Find integer mode integer entUpdtFlag
385 Integer dataFile srvr# dfrdState
386 If (Should_delegate_Find(self)) ;
387 Delegate Send Request_Find mode entUpdtFlag
388 Else Begin
389 get Data_File to dataFile
390 get Server to srvr#
391 get Deferred_State to dfrdState
392
393 //
394 // server augmentation
395 //
396 if (srvr# <> 0 AND dataFile > 0) begin
397 send Item_Find to srvr# mode dataFile ;
398 (Data_Field(self,CURRENT)) entUpdtFlag TRUE dfrdState
399 [found] if dfrdState send entry_display 0 0
400 end
401 End
402 end_procedure
403
404 //
405 // created for FindEdit support
406 //
407 procedure Request_Superfind integer mode
408 Integer obj#
409 If (Should_delegate_Find(self)) ;
410 Delegate Send Request_SuperFind mode
411 Else Begin
412 //
413 // modification for Server support
414 //
415 get Server to obj#
416 if obj# ne 0 begin
417 indicate err false
418 send Request_SuperFind to obj# mode (data_file(self,CURRENT)) ;
419 (data_field(self,CURRENT))
420 [not found not err] begin
421 if mode lt 2 error DFERR_FIND_PRIOR_BEG_OF_FILE
422 else error DFERR_FIND_PAST_END_OF_FILE
423 end
424 end
425 end
426 end_procedure
427
428 //
429 // created for navigation support
430 //
431 { MethodType=Event Visibility=Private Obsolete=True }
432 procedure Child_Wrapping integer direction integer xorigID
433 Integer origID
434
435 if NUM_ARGUMENTS gt 1 move xorigID to origID
436 else get focus of desktop to origID
437 if origID eq 0 move self to origID
438
439 send activate
440 if direction EQ 1 begin
441 if (Auto_Save_State(origID)) send request_Save to origID
442 else if (auto_save_state(self)) send request_save
443 end
444 procedure_return 1
445 end_procedure
446
447 //
448 // created for Navigation support
449 //
450 { Visibility=Private Obsolete=True }
451 procedure Top_of_Panel
452 if (focus(desktop) <> self) send activate
453 forward send beginning_of_panel
454 end_procedure
455
456 //
457 // created for Navigation support
458 //
459 { Visibility=Private Obsolete=True }
460 procedure Bottom_of_Panel
461 Integer lastChild
462 //
463 // modification for Composition support
464 //
465 if (Has_Components_State(self)) begin
466 get Find_Last_DEO to lastChild
467 if lastChild ne 0 begin
468 send Bottom_Of_Panel to lastChild
469 procedure_return
470 end
471 end
472 send activate
473 forward send End_of_Panel
474 end_procedure
475
476 //
477 // created for EntItem simulation
478 //
479 { MethodType=Property }
480 function Data_File integer item# returns integer
481 integer retval
482 get Private.Data_File to retval
483 function_Return retval
484 end_function
485
486 //
487 // created for EntItem simulation
488 //
489 { MethodType=Property }
490 procedure set Data_File integer item# integer newval
491 set Private.Data_File to newval
492 end_procedure
493
494 //
495 // created for EntItem simulation
496 //
497 { MethodType=Property }
498 function Data_Field integer item# returns integer
499 Integer retval
500 get Private.Data_Field to retval
501 function_Return retval
502 end_function
503
504 //
505 // created for EntItem simulation
506 //
507 { MethodType=Property }
508 function Item_Count returns integer
509 function_return 1 //pretend to be a single item
510 end_function
511
512 //
513 // created for EntItem simulation
514 //
515 { MethodType=Property }
516 procedure set Data_Field integer item# integer newval
517 set Private.Data_Field to newval
518 end_procedure
519
520 //
521 // created for EntItem simulation: ecflag <> 0 means use Cleared-array
522 //
523 { Visibility=Private }
524 procedure Entry_Clear integer ecflag
525 integer dfile
526 indicate FOUND as ecflag eq 0
527 [NOT FOUND] begin
528 get data_file item 0 to dfile
529 if dfile eq 0 indicate found TRUE
530 else is_file_included dfile 0
531 end
532 [FOUND] send Delete_Data
533 end_procedure
534
535 //
536 // created for EntItem simulation:
537 // must clear if ecaDoneFlag = 0 OR if Data_File in DONE-array
538 //
539 { Visibility=Private }
540 procedure Entry_Clear_All integer ecaDoneFlag
541 Integer dfile
542 indicate FOUND as ecaDoneFlag eq 0
543 [NOT FOUND] begin
544 get data_file item 0 to dfile
545 if dfile eq 0 indicate found TRUE
546 else is_file_included dfile 0
547 end
548 [FOUND] send Delete_Data
549 end_procedure
550
551 { Visibility=Private }
552 procedure Read_File //msg for action_bar
553 send entry_display 0 0
554 end_procedure
555
556 //
557 // created for EntItem simulation and Server support:
558 // if file# = 0, display only if Data_File is in Done-array
559 // else display only if file# = Data_File
560 //
561 { Visibility=Private }
562 procedure Entry_Display integer file# integer flag
563 Integer oldval dFile
564 get data_file to dFile
565 if dfile eq 0 indicate found TRUE
566 else if file# eq 0 is_file_included dFile 1
567 else indicate found as (file# = dFile OR flag = TRUE)
568 [FOUND] begin
569 get dynamic_update_state to oldVal
570 set dynamic_update_state to false
571 send Delete_Data //init buffer
572 send read //read buffer from file
573 send beginning_of_data
574 set changed_state to FALSE //read leaves it TRUE, so must reset!
575 set dynamic_update_state to oldVal
576 end
577 end_procedure
578
579 //
580 // created for EntItem simulation and Server support
581 // if file# = 0, display only if Data_File is in Done-array
582 // else display only if file# = Data_File
583 //
584 { Visibility=Private }
585 procedure Entry_Update integer file# integer flag
586 integer dFile
587 get Data_File to dFile
588 if (dfile=0 AND flag<>1) ; // if Ascii file, update if
589 indicate found TRUE // not a find.
590 else if (file# = 0 AND flag = 3) ; // A DSO Save
591 is_file_included dFile 1
592 else indicate FOUND as (file# = dFile OR file# = 0)
593 [FOUND] if (flag=1 OR changed_State(self)) ne 0 send write
594 end_procedure
595
596 //
597 //Operation: MODE_INSERT
598 //
599 //Assumption(s): none
600 //
601 //Goal(s): set INSERT_MODE to True
602 //
603 //Algorithm: sets INSERT_MODE to True
604 //
605 //Usage:
606 //
607 { Visibility=Private Obsolete=True }
608 procedure Mode_Insert
609 set insert_mode to true
610 end_procedure
611 //
612 //Operation: MODE_OVERWRITE
613 //
614 //Assumption(s): none
615 //
616 //Goal(s): set INSERT_MODE to False
617 //
618 //Algorithm: sets INSERT_MODE to False
619 //
620 //Usage:
621 //
622 { Visibility=Private Obsolete=True }
623 procedure Mode_Overwrite
624 set insert_mode to false
625 end_procedure
626 //
627 //Operation: MARK_BLOCK
628 //
629 //Assumption(s): none
630 //
631 //Goal(s): begin mark of text block in buffer
632 //
633 //Algorithm: sets COLUMN_MODE to False and sends MARK_ON
634 //
635 //Usage:
636 //
637 { Visibility=Private Obsolete=True }
638 procedure Mark_Block
639 set column_mode to false
640 send Mark_On
641 end_procedure
642 //
643 //Operation: MARK_COLUMN
644 //
645 //Assumption(s): none
646 //
647 //Goal(s): mark columnar area of text in buffer
648 //
649 //Algorithm: sets COLUMN_MODE to True and sends MARK_ON
650 //
651 //Usage:
652 //
653 { Visibility=Private Obsolete=True }
654 procedure Mark_Column
655 set column_mode to true
656 send Mark_On
657 end_procedure
658 //
659 //Operation: CUT_MARKED_AREA
660 //
661 //Assumption(s): none
662 //
663 //Goal(s): cut marked text to ClipBoard object
664 //
665 //Algorithm: sends CUT
666 //
667 //Usage:
668 //
669 { Visibility=Private Obsolete=True }
670 procedure Cut_Marked_Area
671 send cut true ClipBoard true
672 set changed_state to true
673 end_procedure
674 //
675 //Operation: COPY_MARKED_AREA
676 //
677 //Assumption(s): none
678 //
679 //Goal(s): copy marked text to ClipBoard
680 //
681 //Algorithm: sends CUT
682 //
683 //Usage:
684 //
685 { Visibility=Private Obsolete=True }
686 procedure Copy_Marked_Area
687 send cut true ClipBoard false
688 end_procedure
689 //
690 //Operation: PASTE_BLOCK
691 //
692 //Assumption(s): none
693 //
694 //Goal(s): insert text from ClipBoard into buffer at current position
695 //
696 //Algorithm: sends PASTE to ClipBoard object
697 //
698 //Usage:
699 //
700 { Visibility=Private Obsolete=True }
701 procedure Paste_Block
702 send paste to clipBoard false self false
703 set changed_state to true
704 end_procedure
705
706 //
707 //Operation: UPDATE_DEPENDENT_ITEMS
708 //
709 //Assumption(s): none
710 //
711 //Goal(s): do nothing (cancels message sent by Server-mixin)
712 //
713 //Algorithm: none
714 //
715 //Usage:
716 //
717 { Visibility=Private }
718 procedure Update_Dependent_Items
719 end_procedure
720
721 { MethodType=Event }
722 procedure Refresh integer notifyMode
723// integer datafile oldVal
724
725// get data_file item current to datafile
726// is_file_included datafile 0 //look in cleared
727// [found] send delete_data //clear if present
728// is_file_included datafile 1 //look in done
729// [FOUND] begin //read data
730// get dynamic_update_state to oldVal
731// set dynamic_update_state to false
732// send Delete_Data //init buffer
733// send read //read buffer from file
734// send beginning_of_data
735// set changed_state to FALSE //read leaves it TRUE, so must reset!
736// set dynamic_update_state to oldVal
737// end
738
739 //
740 // above commented out and below added for backward compatibility
741 //
742
743 if notifyMode eq MODE_CLEAR_ALL send entry_clear_all 1
744 else begin
745 send entry_clear 1
746 send entry_display 0 0
747 end
748
749 end_procedure
750
751 procedure End_Construct_Object
752 send Mark_Components // nesting
753 send Define_Access_Keys 0 // action_bar_keys
754 forward send End_Construct_Object
755 end_procedure
756end_class
757
758
759