-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathControl.prg
More file actions
1328 lines (979 loc) · 35.5 KB
/
Control.prg
File metadata and controls
1328 lines (979 loc) · 35.5 KB
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 "FiveWin.Ch"
#define LTGRAY_BRUSH 1
#define GRAY_BRUSH 2
#define WM_ERASEBKGND 20
#define WM_LBUTTONDBLCLK 515 // 0x203
#define WM_CTLCOLOR 25 // 0x19 // Don't remove Color Control
#define WM_MENUSELECT 287
#ifndef __CLIPPER__
#ifndef __C3__
#define WM_HELP 0x0053
#else
#define WM_HELP 83
#endif
#else
#define WM_HELP 83
#endif
#define GW_HWNDNEXT 2
#define GW_CHILD 5
#define GWW_INSTANCE -6
#define SC_CLOSE 61536 // 0xF060
#define SC_NEXT 61504
#define SC_KEYMENU 61696 // 0xF100
#define WM_SYSCOMMAND 274 // 0x0112
#define DM_GETDEFID WM_USER
#define DC_HASDEFID 21323 // 0x534B
// Controls mouse-resizing types in design mode
#define RES_NW 1
#define RES_N 2
#define RES_NE 3
#define RES_E 4
#define RES_SE 5
#define RES_S 6
#define RES_SW 7
#define RES_W 8
#define DLGC_DEFPUSHBUTTON 16 //0x0010
#define GWL_STYLE (-16)
#define COLOR_WINDOW 5
#ifdef __XPP__
#define Super ::TWindow
#endif
static nMRow, nMCol
static nXGrid := 8, nYGrid := 8
static lDragging := .f.
//----------------------------------------------------------------------------//
CLASS TControl FROM TWindow
DATA bSetGet, bChange, bDragBegin
DATA lCaptured, lDrag, lMouseDown, lUpdate AS LOGICAL
DATA l3DLook AS LOGICAL INIT .f. // HIDDEN
DATA nLastRow, nLastCol AS NUMERIC
DATA nMResize AS NUMERIC // Controls resize with mouse in design mode
// automatic initialized to zero
DATA nDlgCode // Default GetDlgCode() returned value
// by default nil. (Default behavior).
DATA oJump // After VALID set focus to this control
// if defined
DATA l97Look AS LOGICAL
#ifdef __XPP__
CLASS VAR nInitID SHARED
CLASS VAR nPoint SHARED
CLASS VAR aDots SHARED
#else
CLASSDATA nInitID INIT 100
CLASSDATA nPoint
CLASSDATA aDots
#endif
DATA nClientBevel AS NUMERIC
CLASSDATA aProperties ;
INIT { "cTitle", "cVarName", "l3D", "nClrText",;
"nClrPane", "nAlign", "nTop", "nLeft",;
"nWidth", "nHeight", "oFont", "Cargo" }
#ifdef __XPP__
DATA nTop, nLeft
#endif
METHOD nTop() SETGET
METHOD nLeft() SETGET
/*
METHOD _cVarName( cNewVarName ) INLINE If( ! ::lDrag .and. ! ::oWnd:lDesign,;
OSend( ::oWnd, "_" + cNewVarName, Self ),),;
Super:cVarName := cNewVarName */
METHOD AdjBottom() INLINE WndAdjBottom( ::hWnd ),;
If( ::lDrag .and. GetFocus() == ::hWnd,;
::ShowDots(),)
METHOD AdjClient()
METHOD AdjLeft()
METHOD AdjRight()
METHOD AdjTop() INLINE WndAdjTop( ::hWnd ),;
If( ::lDrag .and. GetFocus() == ::hWnd,;
::ShowDots(),)
METHOD Change() VIRTUAL
METHOD ChangeFocus() INLINE PostMessage( ::hWnd, FM_CHANGEFOCUS )
METHOD Click() INLINE ::oWnd:AEvalWhen()
METHOD CoorsUpdate() VIRTUAL
METHOD cToChar( cCtrlClass )
METHOD Init() VIRTUAL // XBPP avoid calling TWindow New !!!
METHOD Initiate( hDlg )
METHOD Default()
METHOD EraseBkGnd( hDC )
METHOD FWLostFocus( hCtlFocus )
#ifdef __CLIPPER__
METHOD HideDots() INLINE ;
If( ! Empty( ::aDots ),;
( ASend( ::aDots, "Hide" ), SysRefresh() ),)
#else
#ifndef __C3__
METHOD HideDots() INLINE ;
If( ! Empty( ::aDots ),;
( ASend( ::aDots, "Hide()" ), SysRefresh() ),)
#else
METHOD HideDots() INLINE ;
If( ! Empty( ::aDots ),;
( ASend( ::aDots, "Hide" ), SysRefresh() ),)
#endif
#endif
METHOD GetDlgCode( nLastKey )
METHOD GetNewId()
METHOD GotFocus( hCtlLost )
MESSAGE HelpTopic METHOD __HelpTopic()
METHOD Inspect( cDataName )
METHOD _l3D( lOnOff ) INLINE If( ::l3DLook := lOnOff, ::Set3DLook(),)
METHOD l3D() INLINE ::l3DLook
METHOD LostFocus( hWndGetFocus ) INLINE ::SetMsg(), Super:LostFocus( hWndGetFocus )
METHOD Move( nTop, nLeft, nWidth, nHeight, lRepaint )
METHOD MResize( nType, nRow, nCol ) // Controls resize in design mode
METHOD End()
METHOD nAlign() SETGET
METHOD _nWidth( nNewWidth ) INLINE If( ! Empty( ::hWnd ), WndWidth( ::hWnd, nNewWidth ),),;
If( ::lDrag, ::ShowDots(),)
METHOD _nHeight( nNewHeight ) INLINE If( ! Empty( ::hWnd ), WndHeight( ::hWnd, nNewHeight ),),;
If( ::lDrag, ::ShowDots(),)
METHOD Notify( nIdCtrl, nPtrNMHDR ) VIRTUAL // common controls notifications
#ifdef __CLIPPER__
METHOD HandleEvent( nMsg, nWParam, nLParam ) EXTERN ;
CtlHandleEvent( nMsg, nWParam, nLParam )
#else
METHOD HandleEvent( nMsg, nWParam, nLParam )
#endif
METHOD KeyChar( nKey, nFlags )
METHOD KeyDown( nKey, nFlags )
METHOD KeyUp( nKey, nFlags ) VIRTUAL
MESSAGE SetFocus METHOD _SetFocus()
METHOD CheckDots()
METHOD Colors( hDC )
METHOD DragBegin( nRow, nCol, nKeyFlags )
// METHOD DrawItem( nPStruct ) VIRTUAL
METHOD FillMeasure() VIRTUAL
METHOD KillFocus( hCtlFocus )
METHOD Set3DLook() INLINE Ctl3DLook( ::hWnd )
METHOD VarPut( uVal ) INLINE If( ValType( ::bSetGet ) == "B",;
Eval( ::bSetGet, uVal ),)
METHOD VarGet() INLINE If( ValType( ::bSetGet ) == "B", Eval( ::bSetGet ),)
METHOD LButtonDown( nRow, nCol, nKeyFlags )
METHOD LButtonUp( nRow, nCol, nKeyFlags )
METHOD MouseMove( nRow, nCol, nKeyFlags )
METHOD ForWhen()
METHOD Display() VIRTUAL
METHOD Paint() VIRTUAL
METHOD Redefine( nId, oWnd ) CONSTRUCTOR
METHOD SysCommand( nType, nLoWord, nHiWord )
METHOD ShowDots()
ENDCLASS
//----------------------------------------------------------------------------//
METHOD AdjClient() CLASS TControl
local hTop, hBottom, hLeft, hRight
if ::oWnd:oTop != nil
hTop = ::oWnd:oTop:hWnd
endif
if ::oWnd:oBar != nil
hTop = ::oWnd:oBar:hWnd
endif
if ::oWnd:oBottom != nil
hBottom = ::oWnd:oBottom:hWnd
endif
if ::oWnd:oMsgBar != nil
hBottom = ::oWnd:oMsgBar:hWnd
endif
if ::oWnd:oLeft != nil
hLeft = ::oWnd:oLeft:hWnd
endif
if ::oWnd:oRight != nil
hRight = ::oWnd:oRight:hWnd
endif
WndAdjClient( ::hWnd, hTop, hBottom, hLeft, hRight,, ::nClientBevel )
if ::lDrag .and. GetFocus() == ::hWnd
::ShowDots()
endif
return nil
//----------------------------------------------------------------------------//
METHOD AdjLeft() CLASS TControl
local hTop, hBottom
if ::oWnd:oTop != nil
hTop = ::oWnd:oTop:hWnd
endif
if ::oWnd:oBar != nil
hTop = ::oWnd:oBar:hWnd
endif
if ::oWnd:oBottom != nil
hBottom = ::oWnd:oBottom:hWnd
endif
if ::oWnd:oMsgBar != nil
hBottom = ::oWnd:oMsgBar:hWnd
endif
WndAdjLeft( ::hWnd, hTop, hBottom )
if ::lDrag .and. GetFocus() == ::hWnd
::ShowDots()
endif
return nil
//----------------------------------------------------------------------------//
METHOD AdjRight() CLASS TControl
local hTop, hBottom
if ::oWnd:oTop != nil
hTop = ::oWnd:oTop:hWnd
endif
if ::oWnd:oBar != nil
hTop = ::oWnd:oBar:hWnd
endif
if ::oWnd:oBottom != nil
hBottom = ::oWnd:oBottom:hWnd
endif
if ::oWnd:oMsgBar != nil
hBottom = ::oWnd:oMsgBar:hWnd
endif
WndAdjRight( ::hWnd, hTop, hBottom )
if ::lDrag .and. GetFocus() == ::hWnd
::ShowDots()
endif
return nil
//----------------------------------------------------------------------------//
METHOD cToChar( cCtrlClass ) CLASS TControl
local n := GetDlgBaseUnits()
DEFAULT cCtrlClass := ::ClassName(),;
::cCaption := "",;
::nId := ::GetNewId(),;
::nStyle := nOR( WS_CHILD, WS_VISIBLE, WS_TABSTOP )
return cCtrl2Chr( Int( 2 * 8 * ::nTop / nHiWord( n ) ),;
Int( 2 * 4 * ::nLeft / nLoWord( n ) ),;
Int( 2 * 8 * ::nBottom / nHiWord( n ) ),;
Int( 2 * 4 * ::nRight / nLoWord( n ) ),;
::nId, ::nStyle, cCtrlClass, ::cCaption )
//----------------------------------------------------------------------------//
METHOD Initiate( hDlg ) CLASS TControl
DEFAULT ::lActive := .t., ::lDrag := .f., ::lCaptured := .f.,;
::lFocused := .f., ::lCancel := .f.
if( ( ::hWnd := GetDlgItem( hDlg, ::nId ) ) != 0 )
If( ::lActive, ::Enable(), ::Disable() )
::Link()
if ::oFont != nil
::SetFont( ::oFont )
else
::GetFont()
endif
else
#define NOVALID_CONTROLID 1
Eval( ErrorBlock(), _FWGenError( NOVALID_CONTROLID, "No: " + ;
Str( ::nId, 6 ) ) )
endif
return nil
//----------------------------------------------------------------------------//
METHOD _SetFocus() CLASS TControl
local hCtrlNext
if ::lWhen()
SetFocus( ::hWnd )
else
hCtrlNext = GetWindow( ::hWnd, GW_HWNDNEXT )
if GetParent( hCtrlNext ) != ::oWnd:hWnd
hCtrlNext = GetWindow( ::oWnd:hWnd, GW_CHILD )
endif
SetFocus( hCtrlNext )
endif
return nil
//----------------------------------------------------------------------------//
METHOD Colors( hDC ) CLASS TControl
DEFAULT ::nClrText := GetTextColor( hDC ),;
::nClrPane := GetBkColor( hDC ),;
::oBrush := TBrush():New( , ::nClrPane )
SetTextColor( hDC, ::nClrText )
SetBkColor( hDC, ::nClrPane )
return ::oBrush:hBrush
//----------------------------------------------------------------------------//
METHOD Default() CLASS TControl
::lDrag = .f.
::lCaptured = .f.
return nil
//----------------------------------------------------------------------------//
METHOD LButtonDown( nRow, nCol, nKeyFlags ) CLASS TControl
::oWnd:nLastKey = 1002 // fixes CANCEL clause.
::lMouseDown = .t.
::nLastRow = nRow
::nLastCol = nCol
if ::lDrag
::HideDots()
CursorCatch()
if ! ::lCaptured
::nPoint = nMakeLong( nRow -= ( nRow % nYGrid ), nCol -= ( nCol % nXGrid ) )
nMRow = nRow
nMCol = nCol
CtrlDrawFocus( ::hWnd )
::Capture()
::lCaptured = .t.
endif
return 0
else
return Super:LButtonDown( nRow, nCol, nKeyFlags )
endif
return nil
//----------------------------------------------------------------------------//
METHOD LButtonUp( nRow, nCol, nKeyFlags ) CLASS TControl
local aPoint := { nRow, nCol }
::lMouseDown = .f.
if lDragging
lDragging = .f.
ReleaseCapture()
aPoint = ClientToScreen( ::hWnd, aPoint )
if aPoint[ 1 ] > 32768
aPoint[ 1 ] -= 65535
endif
if aPoint[ 2 ] > 32768
aPoint[ 2 ] -= 65535
endif
SendMessage( WindowFromPoint( aPoint[ 2 ], aPoint[ 1 ] ),;
FM_DROPOVER, nKeyFlags, nMakeLong( nRow, nCol ) )
return nil
endif
if ::lDrag
if ::lCaptured
ReleaseCapture()
::lCaptured = .f.
CtrlDrawFocus( ::hWnd, ;
( nRow := nLoWord( ::nPoint ) ) - nMRow,;
( nCol := nHiWord( ::nPoint ) ) - nMCol, ;
nRow,;
nCol,;
::nMResize )
aPoint[ 1 ] = nRow
aPoint[ 2 ] = nCol
if Empty( ::nMResize )
::Move( ::nTop + nRow - nMRow, ::nLeft + nCol - nMCol,,, .t. )
else
// The click is relative to the control
// and we need it relative to the control container
aPoint = ClientToScreen( ::hWnd, aPoint )
aPoint = ScreenToClient( ::oWnd:hWnd, aPoint )
nRow := aPoint[ 1 ] - aPoint[ 1 ] % nYGrid
nCol := aPoint[ 2 ] - aPoint[ 2 ] % nXGrid
do case
case ::nMResize == RES_NW
::Move( nRow, nCol,;
::nWidth + ( ::nLeft - nCol ),;
::nHeight + ( ::nTop - nRow ), .t. )
case ::nMResize == RES_N
::Move( nRow, ::nLeft, ::nWidth, ::nHeight + ( ::nTop - nRow ), .t. )
case ::nMResize == RES_NE
::Move( nRow, ::nLeft, nCol - ::nLeft,;
::nHeight + ( ::nTop - nRow ), .t. )
case ::nMResize == RES_E
::SetSize( nCol - ::nLeft, ::nHeight, .t. )
case ::nMResize == RES_W
::Move( ::nTop, nCol,;
::nWidth + ( ::nLeft - nCol ),;
::nHeight, .t. )
case ::nMResize == RES_SE
::SetSize( nCol - ::nLeft, nRow - ::nTop, .t. )
case ::nMResize == RES_S
::SetSize( ::nWidth, nRow - ::nTop, .t. )
case ::nMResize == RES_SW
::Move( ::nTop, nCol,;
::nWidth + ( ::nLeft - nCol ), nRow - ::nTop, .t. )
endcase
::nPoint = nil
endif
if ::nAlign() != 0
::oWnd:ReSize()
endif
if ::aDots != nil
::ShowDots()
endif
::nMResize = 0
endif
if GetFocus() != ::hWnd
SetFocus( ::hWnd )
endif
return 0
endif
return Super:LButtonUp( nRow, nCol, nKeyFlags )
//----------------------------------------------------------------------------//
METHOD MouseMove( nRow, nCol, nKeyFlags ) CLASS TControl
local nOldRow, nOldCol
DEFAULT ::lMouseDown := .f.
if nRow > 32768
nRow -= 65535
endif
if nCol > 32768
nCol -= 65535
endif
if ::lDrag
if ::lCaptured
if Empty( ::nMResize )
CursorCatch()
endif
nOldRow := nLoWord( ::nPoint )
nOldCol := nHiWord( ::nPoint )
if Abs( nOldRow - nRow ) >= nXGrid .or. ;
Abs( nOldCol - nCol ) >= nYGrid
CtrlDrawFocus( ::hWnd, ;
nOldRow - nMRow,;
nOldCol - nMCol,;
nOldRow,;
nOldCol,;
::nMResize )
::nPoint = nMakeLong( nRow -= nRow % nYGrid,;
nCol -= nCol % nXGrid )
CtrlDrawFocus( ::hWnd, ;
nRow - nMRow,;
nCol - nMCol,;
nRow,;
nCol, ;
::nMResize )
endif
else
if ::oCursor != nil
SetCursor( ::oCursor:hCursor )
endif
endif
return 0
else
if ::lMouseDown .and. ;
( Abs( nRow - ::nLastRow ) > 5 .or. Abs( nCol - ::nLastCol ) > 5 ) ;
.and. ! Empty( ::oDragCursor )
SetCursor( ::oDragCursor:hCursor )
if ! lDragging
::DragBegin( nRow, nCol, nKeyFlags )
endif
else
return Super:MouseMove( nRow, nCol, nKeyFlags )
endif
endif
return 0
//----------------------------------------------------------------------------//
METHOD Move( nTop, nLeft, nWidth, nHeight, lRepaint ) CLASS TControl
Super:Move( nTop, nLeft, nWidth, nHeight, lRepaint )
DEFAULT ::lDrag := .f., ::lFocused := .f.
if ::lDrag .and. ::aDots != nil .and. ::lFocused
::ShowDots()
endif
return nil
//----------------------------------------------------------------------------//
METHOD End() CLASS TControl
local nAt := If( ::oWnd != nil .and. ! Empty( ::oWnd:aControls ),;
AScan( ::oWnd:aControls, { | oCtrl | oCtrl:hWnd == Self:hWnd } ),;
0 )
if nAt != 0
ADel( ::oWnd:aControls, nAt )
ASize( ::oWnd:aControls, Len( ::oWnd:aControls ) - 1 )
endif
if !Empty( ::oBrush )
::oBrush:End()
end if
if ::oWnd != nil .and. ::oWnd:oCtlFocus == Self
::oWnd:oCtlFocus = nil
endif
return Super:End()
//----------------------------------------------------------------------------//
METHOD KeyChar( nKey, nFlags ) CLASS TControl
local nDefValue, nDefButton, hDef, nAt
do case
case nKey == VK_TAB .and. GetKeyState( VK_SHIFT )
::oWnd:GoPrevCtrl( ::hWnd )
return 0 // We don't want API default behavior
case nKey == VK_TAB
::oWnd:GoNextCtrl( ::hWnd )
return 0 // We don't want API default behavior
case nKey == VK_ESCAPE
::oWnd:KeyChar( nKey, nFlags )
return 0
case nKey == VK_RETURN
SysRefresh() // A.L. 23/04/03 it valids the VALID of a control
// before firing the ACTION of a default pushbutton
// if ::hWnd != GetFocus() // A.L. 23/04/03 The VALID was .t.
if ( nDefButton := nLoWord( SendMessage( ::oWnd:hWnd,;
DM_GETDEFID ) ) ) != 0 .and. ;
( hDef := GetDlgItem( ::oWnd:hWnd, nDefButton ) ) != 0 ;
.and. nDefButton != ::nId .and. ;
lAnd( GetWindowLong( hDef, GWL_STYLE ), BS_DEFPUSHBUTTON )
SendMessage( hDef, WM_KEYDOWN, VK_RETURN )
return 0
else
// TBtnBmp control used as a default button (ID --> 1 IDOK)
if ( nAt := AScan( ::oWnd:aControls, { | o | o:nId == 1 } ) ) != 0
if Upper( ::oWnd:aControls[ nAt ]:ClassName() ) == "TBTNBMP"
Eval( ::oWnd:aControls[ nAt ]:bAction )
endif
return 0
endif
endif
// endif
endcase
return Super:KeyChar( nKey, nFlags )
//----------------------------------------------------------------------------//
METHOD nTop( nNewTop ) CLASS TControl
if PCount() > 0
if ! Empty( ::hWnd )
WndTop( ::hWnd, nNewTop )
endif
Super:nTop = nNewTop
else
if ! Empty( ::hWnd )
return WndTop( ::hWnd )
else
return Super:nTop
endif
endif
return nil
//----------------------------------------------------------------------------//
METHOD nLeft( nNewLeft ) CLASS TControl
if PCount() > 0
if ! Empty( ::hWnd )
WndLeft( ::hWnd, nNewLeft )
endif
Super:nLeft = nNewLeft
else
if ! Empty( ::hWnd )
return WndLeft( ::hWnd )
else
return Super:nLeft
endif
endif
return nil
//----------------------------------------------------------------------------//
METHOD ForWhen() CLASS TControl
::oWnd:AEvalWhen()
::lCaptured = .f.
// keyboard navigation
if ::oJump != nil
SetFocus( ::oJump:hWnd )
::oJump = nil
elseif ::oWnd:nLastKey == VK_UP .or. ( ::oWnd:nLastKey == VK_TAB .and. ;
GetKeyState( VK_SHIFT ) )
::oWnd:GoPrevCtrl( ::hWnd )
elseif ::oWnd:nLastKey == VK_DOWN .or. ::oWnd:nLastKey == VK_RETURN .or. ;
::oWnd:nLastKey == VK_TAB
::oWnd:GoNextCtrl( ::hWnd )
else
if Empty( GetFocus() )
SetFocus( ::hWnd )
endif
endif
::oWnd:nLastKey = 0
return nil
//----------------------------------------------------------------------------//
METHOD KeyDown( nKey, nFlags ) CLASS TControl
if ::lDrag
do case
case nKey == VK_DELETE
if ApoloMsgNoYes( "Delete this control ?" )
::End()
if Len( ::oWnd:aControls ) == 0
#ifdef __CLIPPER__
ASend( ::aDots, "Hide" )
#else
#ifndef __C3__
ASend( ::aDots, "Hide()" )
#else
ASend( ::aDots, "Hide" )
#endif
#endif
endif
endif
endcase
else
return Super:KeyDown( nKey, nFlags )
endif
return nil
//----------------------------------------------------------------------------//
METHOD KillFocus( hCtlFocus ) CLASS TControl
local oWnd
if ! Empty( hCtlFocus ) .and. ::bValid != nil .and. WndParents( hCtlFocus, ::hWnd ) .and. ;
( oWnd := oWndFromhWnd( hCtlFocus ) ) != nil .and. ;
Upper( oWnd:Classname() ) $ "TBUTTON;TBTNBMP" .and. ;
( oWnd:lCancel != nil .and. oWnd:lCancel .and. ;
( ::oWnd:nLastKey != VK_TAB .and. ::oWnd:nLastKey != VK_RETURN .and. ;
::oWnd:nLastKey != VK_DOWN .and. ::oWnd:nLastKey != VK_UP ) )
::oWnd:lValidating = .t.
::oWnd:nLastKey := 0
::ForWhen()
::oWnd:lValidating = .f.
::LostFocus( hCtlFocus )
return nil
else
if Upper( GetClassName( hCtlFocus ) ) == "TBTNBMP"
::oWnd:nLastKey := 0 // it fixes TBtnBmp CANCEL clause
endif
endif
// in FiveWin++ lValidating comes as nil sometimes
if ! Empty( hCtlFocus ) .and. ( ::oWnd:lValidating == nil .or. ! ::oWnd:lValidating ) ;
.and. IsWindowVisible( ::oWnd:hWnd ) .and. WndParents( hCtlFocus, ::hWnd )
PostMessage( ::hWnd, FM_LOSTFOCUS, hCtlFocus )
endif
return ::LostFocus( hCtlFocus )
//----------------------------------------------------------------------------//
METHOD EraseBkGnd( hDC ) CLASS TControl
if ! Empty( ::bEraseBkGnd )
return Eval( ::bEraseBkGnd, hDC )
endif
if ::oBrush != nil
FillRect( hDC, GetClientRect( ::hWnd ), ::oBrush:hBrush )
return 1
endif
return nil
//----------------------------------------------------------------------------//
METHOD FWLostFocus( hCtlFocus ) CLASS TControl
local oWnd
if ::oWnd:lValidating == nil .or. ! ::oWnd:lValidating // FW++ lValidating nil sometimes
::oWnd:lValidating = .t.
if GetParent( hCtlFocus ) != ::oWnd:hWnd
if ( oWnd := oWndFromHWnd( GetParent( hCtlFocus ) ) ) != nil
if oWnd:lValidating == nil .or. ! oWnd:lValidating
oWnd:lValidating = .t.
else
::oWnd:lValidating = .f.
return nil
endif
endif
endif
if ! ::lValid()
SetFocus( ::hWnd )
else
if ! Upper( ::ClassName() ) $ "TFOLDER,TPAGES"
::ForWhen()
endif
endif
::oWnd:lValidating = .f.
if oWnd != nil
oWnd:lValidating = .f.
endif
endif
return nil
//----------------------------------------------------------------------------//
METHOD GetDlgCode( nLastKey ) CLASS TControl
if .not. ::oWnd:lValidating
if nLastKey == VK_RETURN .or. nLastKey == VK_TAB .or. ;
nLastkey == VK_DOWN .or. nLastkey == VK_UP
::oWnd:nLastKey = nLastKey
// don't do a else here with :nLastKey = 0
// or WHEN does not work properly, as we pass here twice before
// evaluating the WHEN
endif
endif
if ::oWnd:oWnd == nil // There is no folders !!!
return ::nDlgCode // standard GetDlgCode behavior (nil)
else
if ( Upper( ::oWnd:oWnd:ClassName() ) != "TFOLDER" .and. ;
Upper( ::oWnd:oWnd:ClassName() ) != "TPAGES" )
return ::nDlgCode // standard GetDlgCode behavior (nil)
endif
endif
return DLGC_WANTALLKEYS // It is the only way to have 100% control using Folders
//----------------------------------------------------------------------------//
METHOD GetNewId() CLASS TControl
DEFAULT ::nInitId := 100
if ::nInitId < 30000
::nInitId++
else
::nInitId = 100
endif
return ::nInitId
//----------------------------------------------------------------------------//
METHOD GotFocus( hCtlLost ) CLASS TControl
::lFocused = .t.
::oWnd:nResult = Self // old code pending to be oCtlFocus
::oWnd:oCtlFocus = Self
::oWnd:hCtlFocus = ::hWnd
::SetMsg( ::cMsg )
if ::lDrag
::ShowDots()
endif
if ::bGotFocus != nil
return Eval( ::bGotFocus, Self, hCtlLost )
endif
return nil
//----------------------------------------------------------------------------//
METHOD SysCommand( nType, nLoWord, nHiWord ) CLASS TControl
local oFolder, nItem, nButton
local hCtrl
do case
case nType == SC_KEYMENU // Alt+... control accelerator pressed
if ! Empty( oFolder := ::oWnd:oWnd ) .and. ;
( Upper( oFolder:ClassName() ) == "TFOLDER" )
if ( nItem := oFolder:GetHotPos( nLoWord ) ) > 0
oFolder:SetOption( nItem )
return 0
else
if ( hCtrl := ::oWnd:GetHotPos( nLoWord, ::hWnd ) ) != 0
nButton := AScan( ::oWnd:aControls, { | o | o:hWnd == hCtrl } )
if nButton != 0
SetFocus( hCtrl )
SysRefresh() // process the VALID if defined
if GetFocus() != ::hWnd // the VALID returned .t. if defined
PostMessage( hCtrl, FM_CLICK )
endif
return 0
endif
elseif ( hCtrl := ::oWnd:oWnd:oWnd:GetHotPos( nLoWord, ::hWnd ) ) != 0
nButton := AScan( ::oWnd:oWnd:oWnd:aControls, { | o | o:hWnd == hCtrl } )
if nButton != 0
SetFocus( hCtrl )
SysRefresh() // process the VALID if defined
if GetFocus() != ::hWnd // the VALID returned .t. if defined
PostMessage( hCtrl, FM_CLICK )
endif
return 0
endif
else
return nil
endif
endif
endif
endcase
return nil
//----------------------------------------------------------------------------//
METHOD __HelpTopic() CLASS TControl
if Empty( ::nHelpId )
if ::oWnd != nil
::oWnd:HelpTopic()
else
HelpIndex()
endif
else
HelpPopup( ::nHelpId )
endif
return nil
//----------------------------------------------------------------------------//
METHOD Inspect( cDataName ) CLASS TControl
do case
case cDataName == "nAlign"
return { "None", "Top", "Left", "Bottom", "Right", "Client" }
otherwise
return Super:Inspect( cDataName )
endcase
return nil