/
Edit.prg
1097 lines (680 loc) · 21.8 KB
/
Edit.prg
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
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/// <include file="Gui.xml" path="doc/Edit/*" />
CLASS Edit INHERIT TextControl
PROTECT lNoNotify AS LOGIC
PROTECT lForceModFlag2True AS LOGIC
//PP-030828 Strong typing
/// <exclude />
ASSIGN __ForceModFlag2True(lNewValue AS LOGIC) STRICT
//PP-030828 Strong typing
RETURN (lForceModFlag2True := lNewValue)
/// <exclude />
ACCESS __NoNotify AS LOGIC STRICT
//PP-030828 Strong typing
RETURN lNoNotify
/// <include file="Gui.xml" path="doc/Edit.CanUndo/*" />
METHOD CanUndo()
IF SELF:ValidateControl()
RETURN LOGIC(_CAST, SendMessage(SELF:Handle(), EM_CANUNDO, 0, 0 ))
ENDIF
RETURN FALSE
/// <include file="Gui.xml" path="doc/Edit.Caption/*" />
ACCESS Caption
RETURN cCaption
/// <include file="Gui.xml" path="doc/Edit.Caption/*" />
ASSIGN Caption(cNewCaption)
IF !IsString(cNewCaption)
WCError{#Caption,#Edit,__WCSTypeError,cNewCaption,1}:Throw()
ENDIF
RETURN cCaption := cNewCaption
/// <include file="Gui.xml" path="doc/Edit.Clear/*" />
METHOD Clear()
IF SELF:ValidateControl()
SendMessage (SELF:Handle(), WM_CLEAR, 0, 0 )
ENDIF
RETURN SELF
/// <include file="Gui.xml" path="doc/Edit.Copy/*" />
METHOD Copy()
LOCAL hHandle AS PTR
IF SELF:ValidateControl()
hHandle := SELF:Handle()
SendMessage(hHandle, EM_GETSEL, 0, 0)
SendMessage(hHandle, WM_COPY, 0, 0)
ENDIF
RETURN SELF
/// <include file="Gui.xml" path="doc/Edit.Cut/*" />
METHOD Cut()
IF SELF:ValidateControl()
SendMessage(SELF:Handle(), WM_CUT, 0, 0)
ENDIF
RETURN SELF
/// <include file="Gui.xml" path="doc/Edit.Font/*" />
METHOD Font(oNewFont, lRescal)
LOCAL uRet AS USUAL
LOCAL oMargins AS Pair
IF SELF:ValidateControl()
oMargins := SELF:Margins
uRet := SUPER:Font(oNewFont, lRescal)
SELF:Margins := oMargins
ENDIF
RETURN uRet
/// <include file="Gui.xml" path="doc/Edit.ctor/*" />
CONSTRUCTOR(oOwner, xID, oPoint, oDimension, kStyle)
LOCAL dwStyle AS DWORD
IF !(xID IS ResourceID)
dwStyle:= _OR(WS_CHILD, WS_CLIPSIBLINGS)
IF !IsNil(kStyle)
dwStyle := _OR(DWORD(kStyle), dwStyle)
ENDIF
SUPER(oOwner, xID, oPoint, oDimension, "Edit", dwStyle, TRUE)
ELSE
SUPER(oOwner, xID, oPoint, oDimension, , kStyle, TRUE)
ENDIF
RETURN
/// <include file="Gui.xml" path="doc/Edit.IsPassword/*" />
METHOD IsPassword()
LOCAL Style AS LONG
// DHer: 18/12/2008
Style := GetWindowLong(SELF:Handle(),GWL_STYLE)
RETURN _AND(Style,ES_PASSWORD)!=0
/// <include file="Gui.xml" path="doc/Edit.Margins/*" />
ACCESS Margins
LOCAL dwRet AS DWORD
IF SELF:ValidateControl()
dwRet := DWORD(SendMessage(SELF:Handle(), EM_GETMARGINS, 0, 0))
ENDIF
RETURN Dimension{LoWord(dwRet), HiWord(dwRet)}
/// <include file="Gui.xml" path="doc/Edit.Margins/*" />
ASSIGN Margins(oNewMargins)
LOCAL wLeft, wRight AS WORD
IF SELF:ValidateControl()
wLeft := oNewMargins:Width
wRight := oNewMargins:Height
SendMessage(SELF:Handle(), EM_SETMARGINS, _OR(EC_LEFTMARGIN, EC_RIGHTMARGIN), MAKELPARAM(wLeft, wRight))
ENDIF
RETURN
/// <include file="Gui.xml" path="doc/Edit.Modified/*" />
ACCESS Modified
IF SELF:ValidateControl()
IF lForceModFlag2True
RETURN TRUE
ELSE
RETURN (SendMessage(SELF:Handle(), EM_GETMODIFY, 0, 0 ) != 0)
ENDIF
ENDIF
RETURN FALSE
/// <include file="Gui.xml" path="doc/Edit.Modified/*" />
ASSIGN Modified(lModified)
IF !IsLogic(lModified)
WCError{#Modified,#Edit,__WCSTypeError,lModified,1}:Throw()
ENDIF
IF SELF:ValidateControl()
SendMessage(SELF:Handle(), EM_SETMODIFY, DWORD(_CAST, lModified), 0)
ENDIF
RETURN
/// <include file="Gui.xml" path="doc/Edit.Paste/*" />
METHOD Paste(cNewString)
LOCAL hHandle AS PTR
IF SELF:ValidateControl()
IF IsNil(cNewString)
hHandle := SELF:Handle()
SendMessage(hHandle, WM_CLEAR, 0, 0)
SendMessage(hHandle, WM_PASTE, 0, 0)
ELSE
IF !IsString(cNewString)
WCError{#Paste,#Edit,__WCSTypeError,cNewString,1}:Throw()
ENDIF
SendMessage(SELF:Handle(), EM_REPLACESEL, 0, LONGINT(_CAST, String2Psz(cNewString)))
ENDIF
ENDIF
RETURN SELF
/// <include file="Gui.xml" path="doc/Edit.ReadOnly/*" />
ACCESS ReadOnly
IF SELF:ValidateControl()
RETURN (_AND(GetWindowLong(SELF:Handle(), GWL_STYLE), ES_READONLY) > 0)
ENDIF
RETURN (_AND(dwStyle, DWORD(_CAST, ES_READONLY)) > 0)
/// <include file="Gui.xml" path="doc/Edit.ReadOnly/*" />
ASSIGN ReadOnly(lNewValue)
IF SELF:ValidateControl()
SendMessage(SELF:Handle(), EM_SETREADONLY, DWORD(_CAST, lNewValue), 0L)
ELSE
IF (lNewValue)
dwStyle := _OR(dwStyle, DWORD(_CAST, ES_READONLY))
ELSE
dwStyle := _AND(dwStyle, DWORD(_CAST, _NOT(ES_READONLY)))
ENDIF
ENDIF
RETURN
/// <include file="Gui.xml" path="doc/Edit.SelectedText/*" />
ACCESS SelectedText
//PP-040508 Update S.Ebert
LOCAL dwLast AS DWORD
LOCAL dwFirst AS DWORD
LOCAL cReturn AS STRING
IF SELF:ValidateControl()
SendMessage(hWnd, EM_GETSEL, DWORD(_CAST,@dwFirst), LONGINT(_CAST,@dwLast))
IF dwLast > dwFirst
cReturn := SubStr3(SELF:__GetText(), dwFirst+1, dwLast - dwFirst)
ENDIF
ENDIF
RETURN cReturn
/// <include file="Gui.xml" path="doc/Edit.SelectedText/*" />
ASSIGN SelectedText(cNewString)
IF !IsString(cNewString)
WCError{#SelectedText,#Edit,__WCSTypeError,cNewString,1}:Throw()
ENDIF
IF SELF:ValidateControl()
SendMessage( SELF:Handle(), EM_REPLACESEL, 0, LONGINT(_CAST, String2Psz(cNewString)))
ENDIF
RETURN
/// <include file="Gui.xml" path="doc/Edit.Selection/*" />
ACCESS Selection
LOCAL dwStart AS DWORD
LOCAL dwFinish AS DWORD
IF SELF:ValidateControl()
SendMessage(SELF:Handle(), EM_GETSEL, DWORD(_CAST, @dwStart), LONGINT(_CAST, @dwFinish))
RETURN Selection{dwStart, dwFinish}
ENDIF
RETURN Selection{0,0}
/// <include file="Gui.xml" path="doc/Edit.Selection/*" />
ASSIGN Selection(oSelection)
LOCAL oSel AS Selection
IF !(oSelection IS Selection)
WCError{#Selection,#Edit,__WCSTypeError,oSelection,1}:Throw()
ENDIF
oSel := oSelection
IF SELF:ValidateControl()
//PP-040418 Issue 12761
PostMessage(SELF:Handle(), EM_SETSEL, DWORD(oSel:Start), oSel:Finish)
ENDIF
RETURN
/// <include file="Gui.xml" path="doc/Edit.SelectAll/*" />
METHOD SelectAll()
// Selects the whole text in an edit control
IF SELF:ValidateControl()
SendMessage( SELF:Handle(), EM_SETSEL, 0, -1 )
ENDIF
RETURN NIL
/// <include file="Gui.xml" path="doc/Edit.SelectNone/*" />
METHOD SelectNone()
// Deselects the text in an edit control
IF SELF:ValidateControl()
SendMessage( SELF:Handle(), EM_SETSEL, 0, 0 )
ENDIF
RETURN NIL
/// <include file="Gui.xml" path="doc/Edit.SetSelectionFocus/*" />
METHOD SetSelectionFocus()
// DHer: 18/12/2008
SELF:Owner:SetFocus()
SELF:SetFocus()
SELF:Selection := Selection{0,SLen(SELF:Textvalue)+1}
RETURN NIL
/// <include file="Gui.xml" path="doc/Edit.TextLimit/*" />
ACCESS TextLimit
IF SELF:ValidateControl()
RETURN SendMessage(SELF:Handle(), EM_GETLIMITTEXT, 0, 0)
ENDIF
RETURN 0
/// <include file="Gui.xml" path="doc/Edit.TextLimit/*" />
ASSIGN TextLimit(nChars)
LOCAL dwTextLen AS DWORD
LOCAL ptrBuffer AS PTR
LOCAL wChars AS DWORD
LOCAL hHandle AS PTR
IF !IsNumeric(nChars)
WCError{#TextLimit,#Edit,__WCSTypeError,nChars,1}:Throw()
ENDIF
IF SELF:ValidateControl()
hHandle := SELF:Handle()
wChars := nChars
dwTextLen := DWORD(SendMessage(hHandle, WM_GETTEXTLENGTH, 0, 0))
IF (dwTextLen > wChars)
ptrBuffer := MemAlloc(wChars+1)
SendMessage(hHandle, WM_GETTEXT, wChars+1, LONGINT(_CAST, ptrBuffer))
SendMessage(hHandle, WM_SETTEXT, 0, LONGINT(_CAST, ptrBuffer))
MemFree(ptrBuffer)
ENDIF
SendMessage(hHandle, EM_LIMITTEXT, wChars, 0)
ENDIF
RETURN
/// <include file="Gui.xml" path="doc/Edit.TextValue/*" />
ACCESS TextValue
RETURN SELF:__GetText()
/// <include file="Gui.xml" path="doc/Edit.TextValue/*" />
ASSIGN TextValue(cNewText)
LOCAL cTextValue AS STRING
LOCAL cOldValue AS STRING
IF !IsString(cNewText)
WCError{#TextValue,#Edit,__WCSTypeError,cNewText,1}:Throw()
ENDIF
cOldValue := AsString(uValue)
cTextValue := SELF:__SetText(cNewText)
IF SELF:FieldSpec IS FieldSpec var oFS
uValue := oFS:Val(cTextValue)
ELSE
uValue := cTextValue
ENDIF
SELF:ValueChanged := !(cOldValue == AsString(uValue))
RETURN
/// <include file="Gui.xml" path="doc/Edit.Undo/*" />
METHOD Undo()
IF SELF:ValidateControl()
RETURN (SendMessage(SELF:Handle(), EM_UNDO, 0, 0) != 0)
ENDIF
RETURN FALSE
END CLASS
/// <include file="Gui.xml" path="doc/SingleLineEdit/*" />
CLASS SingleLineEdit INHERIT Edit
PROTECT oEditString AS __FormattedString
PROTECT wOverWrite AS LONGINT //RvdH 070205 changed from WORD to LONG
PROTECT wScrMode AS LONGINT //RvdH 070205 changed from WORD to LONG
PROTECT wFocusSel AS LONGINT //RvdH 070205 changed from WORD to LONG
PROTECT lAllowSelection AS LOGIC
PROTECT lAutoFocusChange AS LOGIC
//PP-030828 Strong typing
/// <exclude />
ASSIGN __AllowSelection(lNewValue AS LOGIC) STRICT
//PP-030828 Strong typing
RETURN (lAllowSelection := lNewValue)
/// <exclude />
ACCESS __CurPos AS LONGINT STRICT
//PP-030828 Strong typing
LOCAL liStart AS LONGINT
SendMessage(SELF:Handle(), EM_GETSEL, DWORD(_CAST, @liStart), 0)
liStart++
RETURN liStart
/// <exclude />
ASSIGN __CurPos(iNewPos AS LONGINT) STRICT
//PP-030828 Strong typing
IF (iNewPos > 0)
SendMessage(SELF:Handle(), EM_SETSEL, DWORD(iNewPos-1), iNewPos-1)
ELSE
SendMessage(SELF:Handle(), EM_SETSEL, 0, 0)
ENDIF
RETURN
/// <exclude />
ACCESS __EditString AS __FormattedString STRICT
//PP-030828 Strong typing
RETURN oEditString
/// <exclude />
ACCESS __FSLength AS DWORD STRICT
//PP-030828 Strong typing
IF (oFieldSpec != NULL_OBJECT)
RETURN ofieldSpec:Length
ENDIF
RETURN 0xFFFF
/// <exclude />
METHOD __Update() AS Control STRICT
//PP-030828 Strong typing
// Added version of __Update() for TextControl
LOCAL cText,cNumText AS STRING
LOCAL cNewText AS STRING
LOCAL uOldValue AS USUAL
IF (NULL_STRING == SELF:Picture)
RETURN SUPER:__Update()
ELSEIF SELF:Modified
cText := SELF:TextValue
uOldValue := AsString(uValue)
IF (oFieldSpec != NULL_OBJECT)
IF (oFieldSpec:ValType == "N")
IF (oEditString != NULL_OBJECT)
cNumText := SubStr(cText, oEditString:NextEditPos(0))
ELSE
cNumText := cText
ENDIF
IF (oEditString != NULL_OBJECT) .AND. (At2(",", oEditString:Picture) != 0)
cNumText := StrTran(cNumText, Chr(SetThousandSep()), "")
ENDIF
cNumText := StrTran(cNumText, " ", "")
uValue := Val(cNumText)
ELSEIF (IVarGet(oFieldSpec, #Nullable) == TRUE)
uValue := Unformat(cText, SELF:Picture, oEditString:Type+"0")
ELSE
uValue := Unformat(cText, SELF:Picture, oEditString:Type)
ENDIF
ELSE
uValue := Unformat(cText, SELF:Picture, oEditString:Type)
ENDIF
cNewText := Transform(uValue, SELF:Picture)
IF !(cNewText == cText)
SELF:TextValue := cNewText
ENDIF
SELF:Modified := FALSE
SELF:ValueChanged := !(uOldValue == AsString(uValue))
ENDIF
RETURN SELF
/// <exclude />
ASSIGN __Value(uNewValue AS USUAL) STRICT
//PP-030828 Strong typing
IF (oEditString != NULL_OBJECT .AND. (oFieldSpec == NULL_OBJECT))
oEditString:UsualValue := uNewValue
SELF:uValue := uNewValue
oHLStatus := NULL_OBJECT
SELF:Modified := FALSE
SELF:lChanged := TRUE
ELSE
SUPER:__Value := uNewValue
ENDIF
RETURN
/// <include file="Gui.xml" path="doc/SingleLineEdit.AutoFocusChange/*" />
ACCESS AutoFocusChange
RETURN lAutoFocusChange
/// <include file="Gui.xml" path="doc/SingleLineEdit.AutoFocusChange/*" />
ASSIGN AutoFocusChange(lNewVal)
RETURN (lAutoFocusChange := lNewVal)
/// <include file="Gui.xml" path="doc/SingleLineEdit.CreateFormattedString/*" />
METHOD CreateFormattedString(cPicture, cType, cDefTempl)
//PP-031115 New method, replaces __FormattedString assignment with method call, allowing overriding
//PP-040101 Fixed method name spelling
oEditString := __FormattedString{SELF, cPicture, cType, wOverWrite, cDefTempl, wScrMode}
RETURN SELF
/// <include file="Gui.xml" path="doc/SingleLineEdit.Dispatch/*" />
METHOD Dispatch(oEvent)
LOCAL oEvt := oEvent AS @@Event
LOCAL uMsg AS DWORD
LOCAL wParam AS DWORD
LOCAL lShiftOn AS LOGIC
LOCAL lCtrlOn AS LOGIC
LOCAL lExtSel AS LOGIC
uMsg := oEvt:uMsg
wParam := oEvt:wParam
IF ((oEditString != NULL_OBJECT) .AND. (_AND(GetWindowLong(hwnd, GWL_STYLE), ES_READONLY) == 0))
IF (((uMsg == WM_KEYDOWN) .OR. (uMsg == WM_KEYUP) .OR. (uMsg == WM_CHAR)))
#ifndef __VULCAN__
lShiftOn := LOGIC(_CAST, _AND(GetKeyState(VK_SHIFT), SHORTINT(_CAST, 0x8000)))
lCtrlOn := LOGIC(_CAST, _AND(GetKeyState(VK_CONTROL), SHORTINT(_CAST, 0x8000)))
#else
lShiftOn := GetKeyState(VK_SHIFT) < 0
lCtrlOn := GetKeyState(VK_CONTROL) < 0
#endif
lExtSel := lShiftOn .AND. ((uMsg == WM_KEYDOWN) .OR. (uMsg == WM_KEYUP)) .AND.;
((wParam == VK_LEFT) .OR. (wParam == VK_RIGHT) .OR. (wParam == VK_END) .OR. (wParam == VK_HOME))
IF !((lAllowSelection .AND. lExtSel) .OR. (lCtrlOn .AND. (uMsg != WM_CHAR)))
//PP-040429 The following IF clause was within the ProcessKeyEvent IF clause
// It was moved here in response to emailed bug report from Willie Moore, 2004-04-28
//PP-030505 Bug:100
IF uMsg == WM_CHAR
IF SELF:Selection:Start = 0 .AND. SELF:oEditString <> NULL_OBJECT
SELF:oEditString:TestFirstChar(Chr( wParam))
ENDIF
ENDIF
//IF oEditString:ProcessKeyEvent(__ObjectCastClassPtr(oEvt, __pCKeyEvent))
IF oEditString:ProcessKeyEvent(KeyEvent{oEvt})
// 2.5b fix to invoke event handler
SUPER:Dispatch(oEvt)
RETURN 1L
ENDIF
ENDIF
//elseif (uMsg == EM_SETSEL) .and. (oEvt:lParam < 0)
// self:__CurPos := oEditString:NextEditPos(1)
// return 1L
ELSEIF (uMsg == WM_PASTE)
SELF:oEditString:Paste()
RETURN 1L
ELSEIF (uMsg == WM_CUT)
SELF:oEditString:Cut()
RETURN 1L
ELSEIF (uMsg == WM_SYSKEYDOWN)
//SELF:KeyDown(__ObjectCastClassPtr(oEvt, __pCKeyEvent))
SELF:KeyDown(KeyEvent{oEvt})
RETURN SELF:EventReturnValue
ELSEIF (uMsg == WM_SYSKEYUP)
//SELF:KeyUp(__ObjectCastClassPtr(oEvt, __pCKeyEvent))
SELF:KeyUp(KeyEvent{oEvt})
RETURN SELF:EventReturnValue
ENDIF
ENDIF
RETURN SUPER:Dispatch(oEvt)
/// <include file="Gui.xml" path="doc/SingleLineEdit.FieldSpec/*" />
ASSIGN FieldSpec(oNewFS)
LOCAL sPic AS STRING
LOCAL pos AS USUAL
LOCAL vt AS STRING
LOCAL sDefTempl AS STRING
SUPER:FieldSpec := oNewFS
vt := oFieldSpec:ValType
DO CASE
CASE (vt == "C")
sDefTempl := Replicate("X", Min(oFieldSpec:Length, MAX_FMTSTRING_LEN))
CASE (vt == "L")
sDefTempl := "L"
CASE oFieldSpec:ValType == "N"
sDefTempl := Replicate("#", Min(oFieldSpec:Length, MAX_FMTSTRING_LEN))
IF (oFieldSpec:Decimals > 0)
pos := oFieldSpec:Length - oFieldSpec:Decimals
sDefTempl := Left(sDefTempl, Pos - 1) + "." + Replicate("#", oFieldSpec:Decimals)
ENDIF
ENDCASE
IF (NULL_STRING != SELF:Picture)
sPic := SELF:Picture
ELSEIF (NULL_STRING != oFieldSpec:Picture)
sPic := oFieldSpec:Picture
ELSEIF (vt == "D")
sPic := "@D"
ELSEIF !__DBCSEnabled()
sPic := sDefTempl
ENDIF
IF (NULL_STRING != sPic)
//PP-031115 Replace __FormattedString assignment with method call, allowing overriding
// oEditString := __FormattedString{SELF, sPic, vT, wOverWrite, sDefTempl, wScrMode}
//PP-040101 Fixed method name spelling
SELF:CreateFormattedString(sPic, vT, sDefTempl)
ENDIF
DO CASE
//RvdH 050602 Added default value for STRINGS (issue 13031)
CASE (vt == "C")
SELF:__Value := ""
CASE (vt == "L")
SELF:__Value := FALSE
CASE (vt == "N")
IF (oFieldSpec:Decimals > 0)
SELF:__Value := 0.0
ELSE
SELF:__Value := 0
ENDIF
ENDCASE
SELF:modified := FALSE
RETURN
/// <include file="Gui.xml" path="doc/SingleLineEdit.FocusChange/*" />
METHOD FocusChange(oFocusChangeEvent)
LOCAL iPos AS INT
//PP-030505 Bug:93 SendMessage changed to PostMessage
IF oFocusChangeEvent:GotFocus
IF (oEditString != NULL_OBJECT)
oEditString:lendkey := FALSE
ENDIF
IF (wFocusSel == FSEL_HOME)
IF (oEditString != NULL_OBJECT)
iPos := 1
IF !oEditString:IsEditPos(iPos)
iPos := oEditString:NextEditPos(iPos)
ENDIF
iPos--
ENDIF
PostMessage(SELF:Handle(), EM_SETSEL, DWORD(_CAST, iPos), iPos)
ELSEIF (wFocusSel == FSEL_END)
IF (oEditString != NULL_OBJECT)
iPos := oEditString:PrevEditPos(INT(_CAST, SLen(SELF:CurrentText)))
ELSE
iPos := INT(_CAST, SLen(SELF:CurrentText))
ENDIF
PostMessage(SELF:Handle(), EM_SETSEL, DWORD(_CAST, iPos), iPos)
ELSEIF (wFocusSel == FSEL_TRIM)
iPos := INT(_CAST, SLen(RTrim(SELF:CurrentText)))
PostMessage(SELF:Handle(), EM_SETSEL, 0, iPos)
ELSEIF (wFocusSel == FSEL_TRIMEND)
iPos := INT(_CAST, SLen(RTrim(SELF:CurrentText)))
PostMessage(SELF:Handle(), EM_SETSEL, DWORD(iPos), iPos)
ENDIF
ENDIF
RETURN SUPER:FocusChange(oFocusChangeEvent)
/// <include file="Gui.xml" path="doc/SingleLineEdit.FocusSelect/*" />
ACCESS FocusSelect
RETURN wFocusSel
/// <include file="Gui.xml" path="doc/SingleLineEdit.FocusSelect/*" />
ASSIGN FocusSelect(wNewValue)
IF !IsLong(wNewValue)
WCError{#FocusSelect,#SingleLineEdit,__WCSTypeError,wNewValue,1}:Throw()
ENDIF
IF (wNewValue < 0) .OR. (wNewValue > 4)
wNewValue := FSEL_TRIM
ENDIF
RETURN (wFocusSel := wNewValue)
/// <include file="Gui.xml" path="doc/SingleLineEdit.ctor/*" />
CONSTRUCTOR(oOwner, xID, oPoint, oDimension, kStyle)
SUPER(oOwner, xID, oPoint, oDimension, kStyle)
wOverWrite := OVERWRITE_NEVER
wScrMode := SCRMODE_FULL
wFocusSel := FSEL_TRIM
lAllowSelection := TRUE
RETURN
/// <include file="Gui.xml" path="doc/SingleLineEdit.OverWrite/*" />
ACCESS OverWrite
RETURN wOverWrite
/// <include file="Gui.xml" path="doc/SingleLineEdit.OverWrite/*" />
ASSIGN OverWrite(wNewValue)
IF !IsLong(wNewValue)
WCError{#OverWrite,#SingleLineEdit,__WCSTypeError,wNewValue,1}:Throw()
ENDIF
IF (wNewValue < 0) .OR. (wNewValue > 2)
wNewValue := OVERWRITE_NEVER
ENDIF
wOverWrite := wNewValue
IF (oEditString != NULL_OBJECT)
oEditString:wOverwrite := wOverWrite
ENDIF
RETURN
/// <include file="Gui.xml" path="doc/SingleLineEdit.Picture/*" />
ACCESS Picture
IF oEditString == NULL_OBJECT
RETURN NULL_STRING
ENDIF
RETURN oEditString:Picture
/// <include file="Gui.xml" path="doc/SingleLineEdit.Picture/*" />
ASSIGN Picture(cNewPicture)
LOCAL uOldVal AS USUAL
IF !IsString(cNewPicture)
WCError{#Picture,#SingleLineEdit,__WCSTypeError,cNewPicture,1}:Throw()
ENDIF
IF (oEditString == NULL_OBJECT)
lNoNotify := TRUE
//PP-031115 Replace __FormattedString assignment with method call, allowing overriding
// oEditString := __FormattedString{SELF, cNewPicture, "C", wOverWrite,,wScrMode}
//PP-040101 Fixed method name spelling
SELF:CreateFormattedString(cNewPicture, "C", NIL)
lNoNotify := FALSE
ELSE
IF (cNewPicture == NULL_STRING)
oEditString := NULL_OBJECT
RETURN NULL_STRING
ELSE
uOldVal := uValue // new for 2.0b, should allow picture change on the fly
oEditString:Picture := cNewPicture
oEditString:UsualValue := uOldVal // new for 2.0b
ENDIF
ENDIF
RETURN oEditString:Picture
/// <include file="Gui.xml" path="doc/SingleLineEdit.ScrollMode/*" />
ACCESS ScrollMode
RETURN wScrMode
/// <include file="Gui.xml" path="doc/SingleLineEdit.ScrollMode/*" />
ASSIGN ScrollMode(wNewValue)
IF !IsLong(wNewValue)
WCError{#ScrMode,#SingleLineEdit,__WCSTypeError,wNewValue,1}:Throw()
ENDIF
IF (wNewValue < 0) .OR. (wNewValue > 2)
wNewValue := SCRMODE_FULL
ENDIF
wScrMode := wNewValue
IF (oEditString != NULL_OBJECT)
oEditString:wScrMode := wScrMode
ENDIF
RETURN
/// <include file="Gui.xml" path="doc/SingleLineEdit.TextValue/*" />
ACCESS TextValue
LOCAL cText AS STRING
LOCAL cOrigText AS STRING
LOCAL cFormat AS STRING
LOCAL nPosDay AS DWORD
LOCAL nPosMonth AS DWORD
LOCAL nDay AS INT
LOCAL nMonth AS INT
// DHer: 18/12/2008
// Error in VO : Date "25/2 /2005" gets translated to in "25/04/2005" !!! (in DD/MM/YYYY format)
cOrigText := SUPER:TextValue
cText := cOrigText
IF SELF:oFieldSpec<>NULL_OBJECT
IF SELF:oFieldSpec:ValType="D" // When Date
IF GetFocus()<>SELF:Handle() // When Losing Focus
IF At2(" ",cText) <> 0 // When space in cText
cFormat := Upper(GetDateFormat())
nPosDay := At("DD",cFormat)
nPosMonth := At("MM",cFormat)
IF nPosDay<>0
nDay := Val(SubStr(cText,nPosDay,2))
IF nDay<>0
cText := Stuff(cText, nPosDay, 2, StrZero(nDay,2,0))
ENDIF