summaryrefslogtreecommitdiff
path: root/automation/source/server/recorder.cxx
blob: c4c1ba36ac0778e9cf07e7bdfc505d79a24f2dba (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
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
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
/*************************************************************************
 *
 *  $RCSfile: recorder.cxx,v $
 *
 *  $Revision: 1.1 $
 *
 *  last change: $Author: mh $ $Date: 2002-11-18 15:28:17 $
 *
 *  The Contents of this file are made available subject to the terms of
 *  either of the following licenses
 *
 *         - GNU Lesser General Public License Version 2.1
 *         - Sun Industry Standards Source License Version 1.1
 *
 *  Sun Microsystems Inc., October, 2002
 *
 *  GNU Lesser General Public License Version 2.1
 *  =============================================
 *  Copyright 2002 by Sun Microsystems, Inc.
 *  901 San Antonio Road, Palo Alto, CA 94303, USA
 *
 *  This library is free software; you can redistribute it and/or
 *  modify it under the terms of the GNU Lesser General Public
 *  License version 2.1, as published by the Free Software Foundation.
 *
 *  This library is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *  Lesser General Public License for more details.
 *
 *  You should have received a copy of the GNU Lesser General Public
 *  License along with this library; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 *  MA  02111-1307  USA
 *
 *
 *  Sun Industry Standards Source License Version 1.1
 *  =================================================
 *  The contents of this file are subject to the Sun Industry Standards
 *  Source License Version 1.1 (the "License"); You may not use this file
 *  except in compliance with the License. You may obtain a copy of the
 *  License at http://www.openoffice.org/license.html.
 *
 *  Software provided under this License is provided on an "AS IS" basis,
 *  WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING,
 *  WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
 *  MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
 *  See the License for the specific provisions governing your rights and
 *  obligations concerning the Software.
 *
 *  The Initial Developer of the Original Code is: Sun Microsystems, Inc.
 *
 *  Copyright: 2002 by Sun Microsystems, Inc.
 *
 *  All Rights Reserved.
 *
 *  Contributor(s): _______________________________________
 *
 *
 ************************************************************************/

#ifndef _SV_WINDOW_HXX
#include <vcl/window.hxx>
#endif
#ifndef _VCL_VCLEVENT_HXX
#include <vcl/vclevent.hxx>
#endif
#ifndef _SV_BUTTON_HXX
#include <vcl/button.hxx>
#endif
#ifndef _SV_EDIT_HXX
#include <vcl/edit.hxx>
#endif
#ifndef _SV_SPINFLD_HXX
#include <vcl/spinfld.hxx>
#endif
#ifndef _SV_MSGBOX_HXX
#include <vcl/msgbox.hxx>
#endif
#ifndef _SV_TOOLBOX_HXX
#include <vcl/toolbox.hxx>
#endif
#ifndef _SV_LSTBOX_HXX
#include <vcl/lstbox.hxx>
#endif
#ifndef _SV_SOUND_HXX
#include <vcl/sound.hxx>
#endif
#ifndef _SV_COMBOBOX_HXX
#include <vcl/combobox.hxx>
#endif
#ifndef _SV_FLOATWIN_HXX
#include <vcl/floatwin.hxx>
#endif
#include "statemnt.hxx"
#include "retstrm.hxx"
#include "rcontrol.hxx"

class MacroRecorder
{
private:
    Window* GetParentWithID( Window* pThis );

    Link aEventListenerHdl;
    DECL_LINK( EventListener, VclSimpleEvent* );

    Window* pLastWin;
    Window* pEditModify;
    String aEditModifyString;

    ToolBox *pActionParent;      // toolbox from which a tearoff or OpenMenu might happen

    // record keys
    String aKeyString;
    ULONG aKeyUniqueID;     // has to be remembert seperately since Window might be gone when needed
    Window* pKeyWin;
    BOOL bKeyFollowFocus;

    AutoTimer aHookRefresh;
    void AddEventHooks();
    void RemoveEventHooks();
    DECL_LINK( HookRefreskHdl, void* );

public:

    MacroRecorder();
    ~MacroRecorder();
};


MacroRecorder::MacroRecorder()
: pLastWin( NULL )
, pEditModify( NULL )
, pActionParent( NULL )
, aKeyUniqueID( 0 )
, pKeyWin( NULL )
, bKeyFollowFocus( FALSE )
{
    aHookRefresh.SetTimeout( 500 );
    aHookRefresh.SetTimeoutHdl( LINK( this, MacroRecorder, HookRefreskHdl) );
    aHookRefresh.Start();
    aEventListenerHdl = LINK( this, MacroRecorder, EventListener );
    AddEventHooks();
}

MacroRecorder::~MacroRecorder()
{
    aHookRefresh.Stop();
    RemoveEventHooks();
}

void MacroRecorder::AddEventHooks()
{
    Window *pTopLevel = Application::GetFirstTopLevelWindow();
    while ( pTopLevel )
    {
        Window *pParent = pTopLevel;
        while ( pParent->GetParent() )
            pParent = pParent->GetParent();

        pParent->RemoveChildEventListener( aEventListenerHdl );     // might be instrumented already
        pParent->AddChildEventListener( aEventListenerHdl );

        pTopLevel = Application::GetNextTopLevelWindow( pTopLevel );
    }
}

void MacroRecorder::RemoveEventHooks()
{
    Window *pTopLevel = Application::GetFirstTopLevelWindow();
    while ( pTopLevel )
    {
        pTopLevel->RemoveChildEventListener( aEventListenerHdl );
        pTopLevel = Application::GetNextTopLevelWindow( pTopLevel );
    }
}

IMPL_LINK( MacroRecorder, HookRefreskHdl, void*, EMPTYARG )
{
    AddEventHooks();
    return 0;
}


Window* MacroRecorder::GetParentWithID( Window* pThis )
{
    Window *pOverlap = pThis->GetWindow( WINDOW_OVERLAP );
    while ( pOverlap != pThis && pThis->GetUniqueOrHelpId() == 0 && pThis->GET_REAL_PARENT() )
        pThis = pThis->GET_REAL_PARENT();
    return pThis;
}

IMPL_LINK( MacroRecorder, EventListener, VclSimpleEvent*, pEvent )
{
    BOOL bSendData = FALSE;

    if ( pEvent->ISA( VclWindowEvent ) )
    {
        VclWindowEvent* pWinEvent = ( VclWindowEvent* ) pEvent;
        Window* pWin = pWinEvent->GetWindow();
        ULONG nEventID = pWinEvent->GetId();
#ifdef DEBUG
        if ( nEventID >= 1001 && nEventID != VCLEVENT_WINDOW_KEYUP )
            nEventID = pWinEvent->GetId();  // Just something to set a breakpoint
        else
            return 0;
#endif

// check for different action after collecting keys
        // send if there_is_something_to_send
        // and eather event_is_not_of_interest
        //     or ( new_window and new_window_is_interesting )    ( ignore interesting events to uninteresting window )

            if (  aKeyString.Len()
                && (  ( nEventID != VCLEVENT_WINDOW_KEYINPUT && nEventID != VCLEVENT_WINDOW_MOUSEMOVE )
                    || ( pKeyWin != pWin
                        && ( pWin->GetType() == WINDOW_CONTROL || pWin->GetType() == WINDOW_WINDOW )
                        )
                   )
               )
            {
                // we cannot access pKeyWin since it might have dissapeared
                if ( bKeyFollowFocus )
                    StatementList::pRet->GenReturn( RET_MacroRecorder, aKeyUniqueID, (USHORT)M_TypeKeys, aKeyString, bKeyFollowFocus );
                else
                    StatementList::pRet->GenReturn( RET_MacroRecorder, aKeyUniqueID, (USHORT)M_TypeKeys, aKeyString );
                bSendData = TRUE;
                // cleanup
                aKeyString.Erase();
                pKeyWin = NULL;
                bKeyFollowFocus = FALSE;
            }

        switch ( pWin->GetType() )
        {
            case WINDOW_TABPAGE:
                switch( nEventID )
                {
                    case VCLEVENT_WINDOW_ACTIVATE:
                        StatementList::pRet->GenReturn( RET_MacroRecorder, 0, (USHORT)(M_SetPage|M_RET_NUM_CONTROL), pWin->GetUniqueOrHelpId() );
                        bSendData = TRUE;
                        break;
                }
                break;
            case WINDOW_RADIOBUTTON:
            case WINDOW_IMAGERADIOBUTTON:
                switch( nEventID )
                {
                    case VCLEVENT_BUTTON_CLICK:  // VCLEVENT_RADIOBUTTON_TOGGLE
                        {
                            if ( ((RadioButton*)pWin)->IsChecked() )
                            {
                                StatementList::pRet->GenReturn( RET_MacroRecorder, pWin->GetUniqueOrHelpId(), (USHORT)M_Check );
                                bSendData = TRUE;
                            }
                        }
                        break;
                }
                break;
            case WINDOW_CHECKBOX:
            case WINDOW_TRISTATEBOX:
                switch( nEventID )
                {
                    case VCLEVENT_BUTTON_CLICK: //VCLEVENT_CHECKBOX_TOGGLE:
                        {
                            USHORT nMethod;
                            switch ( ((TriStateBox*)pWin)->GetState() )
                            {
                                case STATE_CHECK: nMethod = M_Check; break;
                                case STATE_NOCHECK: nMethod = M_UnCheck; break;
                                case STATE_DONTKNOW: nMethod = M_TriState; break;
                            }
                            StatementList::pRet->GenReturn( RET_MacroRecorder, pWin->GetUniqueOrHelpId(), nMethod );
                            bSendData = TRUE;
                        }
                        break;
                }
                break;
            case WINDOW_EDIT:
            case WINDOW_MULTILINEEDIT:
                switch( nEventID )
                {
                    case VCLEVENT_EDIT_MODIFY:
                        pEditModify = pWin;
                        aEditModifyString = ((Edit*)pWin)->GetText();
                        break;
                }
                break;
            case WINDOW_MULTILISTBOX:
                switch( nEventID )
                {
                    case VCLEVENT_LISTBOX_SELECT:
                        Sound::Beep();
                }
            case WINDOW_LISTBOX:
                switch( nEventID )
                {
//                    case VCLEVENT_LISTBOX_DOUBLECLICK:
                    case VCLEVENT_LISTBOX_SELECT:
                        StatementList::pRet->GenReturn( RET_MacroRecorder, pWin->GetUniqueOrHelpId(), (USHORT)M_Select, ULONG( ((ListBox*)pWin)->GetSelectEntryPos() +1 ) );
                        bSendData = TRUE;
                        break;
                }
                break;
            case WINDOW_COMBOBOX:
            case WINDOW_PATTERNBOX:
            case WINDOW_NUMERICBOX:
            case WINDOW_METRICBOX:
            case WINDOW_CURRENCYBOX:
            case WINDOW_DATEBOX:
            case WINDOW_TIMEBOX:
                switch( nEventID )
                {
                    case VCLEVENT_EDIT_MODIFY:
                        pEditModify = pWin;
                        aEditModifyString = ((Edit*)pWin)->GetText();
                        break;
                    case VCLEVENT_COMBOBOX_SELECT:
                        {
                            pEditModify = NULL;
                            aEditModifyString.Erase();

                            USHORT nPos = ((ComboBox*)pWin)->GetEntryPos(((ComboBox*)pWin)->GetText());
                            if ( nPos == COMBOBOX_ENTRY_NOTFOUND )
                                Sound::Beep();
                            else
                            {
                                StatementList::pRet->GenReturn( RET_MacroRecorder, pWin->GetUniqueOrHelpId(), (USHORT)M_Select, (ULONG) nPos+1 );
                                bSendData = TRUE;
                            }
                        }
                }
                break;
            case WINDOW_PUSHBUTTON:
            case WINDOW_OKBUTTON:
            case WINDOW_CANCELBUTTON:
            case WINDOW_IMAGEBUTTON:
            case WINDOW_MOREBUTTON:
            case WINDOW_HELPBUTTON:
                switch( nEventID )
                {
                    case VCLEVENT_BUTTON_CLICK:
                        Window* pParent = pWin->GetParent();
                        if ( pParent->IsDialog() && pWin->GetUniqueOrHelpId() == 0 )
                        {
                            switch ( pParent->GetType() )
                            {
                                case WINDOW_MESSBOX:
                                case WINDOW_INFOBOX:
                                case WINDOW_WARNINGBOX:
                                case WINDOW_ERRORBOX:
                                case WINDOW_QUERYBOX:
                                case WINDOW_BUTTONDIALOG:
                                    {
                                        USHORT nMethod;
                                        ButtonDialog* pBD = (ButtonDialog*)pParent;

                                        // we have to find the current Button ID ourselves since it is not generated at this point :-(
                                        USHORT nCurrentButtonId = 99999;    // Some wild value to wak up people
                                        int i;
                                        for ( i = 0; i < pBD->GetButtonCount() ; i++ )
                                        {
                                            if ( pBD->GetPushButton( pBD->GetButtonId(i) ) == pWin )
                                            {
                                                nCurrentButtonId = pBD->GetButtonId(i);
                                                break;
                                            }
                                        }

                                        switch ( nCurrentButtonId )
                                        {
                                            case BUTTONID_OK: nMethod = M_OK; break;
                                            case BUTTONID_CANCEL: nMethod = M_Cancel; break;
                                            case BUTTONID_YES: nMethod = M_Yes; break;
                                            case BUTTONID_NO: nMethod = M_No; break;
                                            case BUTTONID_RETRY: nMethod = M_Repeat; break;
                                            case BUTTONID_HELP: nMethod = M_Help; break;
                                            default: nMethod = M_Click;
                                        }
                                        if ( nMethod != M_Click )
                                            StatementList::pRet->GenReturn( RET_MacroRecorder, (USHORT)0, nMethod );
                                        else
                                            StatementList::pRet->GenReturn( RET_MacroRecorder, (USHORT)0, nMethod, (ULONG)nCurrentButtonId );
                                        bSendData = TRUE;
                                    }
                                    break;
                                default:
                                    {
                                        USHORT nMethod;
                                        switch ( pWin->GetType() )
                                        {
                                            case WINDOW_OKBUTTON: nMethod = M_OK; break;
                                            case WINDOW_CANCELBUTTON: nMethod = M_Cancel; break;
                                            case WINDOW_HELPBUTTON: nMethod = M_Help; break;
                                            default: Sound::Beep();
                                        }
                                        StatementList::pRet->GenReturn( RET_MacroRecorder, pParent->GetUniqueOrHelpId(), nMethod );
                                        bSendData = TRUE;
                                    }
                                    break;
                            }
                        }
                        if ( !bSendData && pWin->GetUniqueOrHelpId() )
                        {
                            StatementList::pRet->GenReturn( RET_MacroRecorder, pWin->GetUniqueOrHelpId(), (USHORT)M_Click );
                            bSendData = TRUE;
                        }
                }
                break;
/*          case C_MoreButton:
                switch( nEventID )
                {
                    case M_IsOpen :
                        pRet->GenReturn ( RET_Value, nUId, ((MoreButton*)pControl)->GetState());
                        break;
                    case M_Click :
                        ((MoreButton*)pControl)->Click();
                        break;
                    case M_Open :
                        ((MoreButton*)pControl)->SetState(TRUE);
                        break;
                    case M_Close :
                        ((MoreButton*)pControl)->SetState(FALSE);
                        break;
                    default:
                        ReportError( nUId, GEN_RES_STR2c2( S_UNKNOWN_METHOD, MethodString(nMethodId), "MoreButton" ) );
                        break;
                }
                break;*/
            case WINDOW_SPINFIELD:
            case WINDOW_PATTERNFIELD:
            case WINDOW_NUMERICFIELD:
            case WINDOW_METRICFIELD:
            case WINDOW_CURRENCYFIELD:
            case WINDOW_DATEFIELD:
            case WINDOW_TIMEFIELD:
                switch( nEventID )
                {
                    case VCLEVENT_SPINFIELD_UP:
                    case VCLEVENT_SPINFIELD_DOWN:
                    case VCLEVENT_SPINFIELD_FIRST:
                    case VCLEVENT_SPINFIELD_LAST:
                        {
                            pEditModify = NULL;
                            aEditModifyString.Erase();

                            USHORT nMethod;
                            switch ( nEventID )
                            {
                                case VCLEVENT_SPINFIELD_UP: nMethod = M_More; break;
                                case VCLEVENT_SPINFIELD_DOWN: nMethod = M_Less; break;
                                case VCLEVENT_SPINFIELD_FIRST: nMethod = M_ToMin; break;
                                case VCLEVENT_SPINFIELD_LAST: nMethod = M_ToMax; break;
                            }
                            StatementList::pRet->GenReturn( RET_MacroRecorder, pWin->GetUniqueOrHelpId(), nMethod );
                            bSendData = TRUE;
                        }
                        break;
                    case VCLEVENT_EDIT_MODIFY:
                        pEditModify = pWin;
                        aEditModifyString = ((SpinField*)pWin)->GetText();
                        break;
                }
                break;

            case WINDOW_MENUBUTTON:
                    switch( nEventID )
                    {
                    case VCLEVENT_BUTTON_CLICK:
                        StatementList::pRet->GenReturn( RET_MacroRecorder, pWin->GetUniqueOrHelpId(), (USHORT)M_Click );
                        bSendData = TRUE;
                        break;
/*      Keyevent or Timeout
                    case M_Open :
                        {
                            MouseEvent aMEvnt;
                            Point aPt( pControl->GetSizePixel().Width() / 2, pControl->GetSizePixel().Height() / 2 );
                            aMEvnt = MouseEvent( aPt,1,MOUSE_SIMPLECLICK,MOUSE_LEFT );
                            ImplMouseButtonDown( pControl, aMEvnt );

                            ULONG nStart = Time::GetSystemTicks();
                            ULONG nDelay = pControl->GetSettings().GetMouseSettings().GetActionDelay();
                            while ( ( Time::GetSystemTicks() - nStart ) < nDelay + 100 )
                                SafeReschedule();

                            ImplMouseButtonUp  ( pControl, aMEvnt );
                        }
                        break;*/
                    }
                break;
            case WINDOW_TOOLBOX:
                {
                    ToolBox *pTB = ((ToolBox*)pWin);
                    switch( nEventID )
                    {
                        case VCLEVENT_TOOLBOX_SELECT:
                            {   // a Button has been clicked
                                // so this cannot be a tearoff or OpenMenu anymore
                                pActionParent = NULL;
                                // compare to 1 for floating ToolBoxes
                                if ( ( pWin->GetUniqueOrHelpId() == 0 || pWin->GetUniqueOrHelpId() == 1 ) )
                                    // generate direct Button access
                                    StatementList::pRet->GenReturn( RET_MacroRecorder, pTB->GetHelpId( pTB->GetCurItemId() ), (USHORT)(M_Click) );
                                else
                                    // access via Toolbox
                                    StatementList::pRet->GenReturn( RET_MacroRecorder, pTB->GetUniqueOrHelpId(), (USHORT)(M_Click|M_RET_NUM_CONTROL), pTB->GetHelpId( pTB->GetCurItemId() ) );
                                bSendData = TRUE;
                            }
                            break;
                        case VCLEVENT_TOOLBOX_CLICK:
                            pActionParent = pTB;
                            break;
                        case VCLEVENT_WINDOW_SHOW:
                            if ( pActionParent )
                            {   // a new toolbox opens up, might be a tearoff
                                if ( pActionParent != pWin )
                                {   // it IS a tearoff not an undock
                                    // compare to 1 for floating ToolBoxes
                                    if ( ( pActionParent->GetUniqueOrHelpId() == 0 || pActionParent->GetUniqueOrHelpId() == 1 ) )
                                        // generate direct Button access
                                        StatementList::pRet->GenReturn( RET_MacroRecorder, pActionParent->GetHelpId( pActionParent->GetCurItemId() ), (USHORT)(M_TearOff) );
                                    else
                                        // access via Toolbox
                                        StatementList::pRet->GenReturn( RET_MacroRecorder, pActionParent->GetUniqueOrHelpId(), (USHORT)(M_TearOff|M_RET_NUM_CONTROL), pActionParent->GetHelpId( pActionParent->GetCurItemId() ) );
                                    bSendData = TRUE;
                                }
                                pActionParent = NULL;
                            }
                            break;
                        case VCLEVENT_TOOLBOX_DEACTIVATE:
                            pActionParent = NULL;
                            break;
                    }
                }
                break;
/*                  ToolBox *pTB = ((ToolBox*)pControl);
                    if ( pTB->GetUniqueOrHelpId() != nUId ) // Also Button auf der ToolBox gefunden
                    {
                        if ( nParams == PARAM_NONE )
                        {           // Wir fälschen einen Parameter
                            nParams = PARAM_USHORT_1;
                            nNr1 = nUId;
                        }
                        else
                            ReportError( nUId, GEN_RES_STR1( S_INTERNAL_ERROR, MethodString( nMethodId ) ) );
                    }

#define FIND_HELP\
{\
    if( nParams == PARAM_USHORT_1 )\
        nLNr1 = nNr1;\
    for ( nNr1 = 0; nNr1 < pTB->GetItemCount() && nLNr1 != pTB->GetHelpId(pTB->GetItemId(nNr1)) ; nNr1++ ) {}\
    bBool1 = nLNr1 == pTB->GetHelpId(pTB->GetItemId(nNr1));\
    if ( !bBool1 )\
        ReportError( nUId, GEN_RES_STR1( S_HELPID_ON_TOOLBOX_NOT_FOUND, MethodString( nMethodId ) ) );\
    else\
    {\
        if ( !pTB->IsItemEnabled( pTB->GetItemId(nNr1) ) && nMethodId != _M_IsEnabled )\
        {\
            ReportError( nUId, GEN_RES_STR1( S_BUTTON_DISABLED_ON_TOOLBOX, MethodString( nMethodId ) ) );\
            bBool1 = FALSE;\
        }\
        else if ( !pTB->IsItemVisible( pTB->GetItemId(nNr1) ) )\
        {\
            ReportError( nUId, GEN_RES_STR1( S_BUTTON_HIDDEN_ON_TOOLBOX, MethodString( nMethodId ) ) );\
            bBool1 = FALSE;\
        }\
        else\
        {\
            if ( pTB->GetItemRect(pTB->GetItemId(nNr1)).IsEmpty() )\
            {\
                USHORT nLine = pTB->GetCurLine();\
                do\
                {\
                    pTB->ShowLine( FALSE );\
                    for ( int i = 1 ; i < 30 ; i++ )\
                        SafeReschedule();\
                }\
                while ( pTB->GetCurLine() != nLine && pTB->GetItemRect(pTB->GetItemId(nNr1)).IsEmpty() );\
                pTB->Invalidate( pTB->GetScrollRect() );\
            }\
            if ( pTB->GetItemRect(pTB->GetItemId(nNr1)).IsEmpty() )\
            {\
                ReportError( nUId, GEN_RES_STR1( S_CANNOT_MAKE_BUTTON_VISIBLE_IN_TOOLBOX, MethodString( nMethodId ) ) );\
                bBool1 = FALSE;\
            }\
        }\
    }\
}\

                    switch( nEventID )
                    {
                        case M_SetNextToolBox :
                            if ( (nParams & PARAM_STR_1) )
                                pTB->SetNextToolBox( aString1 );
                            else
                                pTB->SetNextToolBox( pTB->GetNextToolBox() );
                            pTB->NextToolBox();
                            break;
                        case M_GetNextToolBox :
                            pRet->GenReturn ( RET_Value, nUId, (String)pTB->GetNextToolBox());
                            break;
                        default:
                            ReportError( nUId, GEN_RES_STR2c2( S_UNKNOWN_METHOD, MethodString(nMethodId), "ToolBox" ) );
                            break;
                    }
                }
                break;
*/
            case WINDOW_CONTROL:
            case WINDOW_WINDOW:
                switch( nEventID )
                {
                    case VCLEVENT_WINDOW_COMMAND:
                        break;
                    case VCLEVENT_WINDOW_KEYINPUT:
                        {
                            const KeyEvent *pKeyEvent = ((KeyEvent*)pWinEvent->GetData());
                            const KeyCode aKeyCode = pKeyEvent->GetKeyCode();
                            if ( pKeyEvent )
                            {
                                if ( ( !aKeyCode.IsMod1() && !aKeyCode.IsMod2() ) &&
                                      (( aKeyCode.GetGroup() == KEYGROUP_NUM)   ||
                                       ( aKeyCode.GetGroup() == KEYGROUP_ALPHA) ||
                                       ( aKeyCode.GetCode() == KEY_SPACE) ||
                                       ( aKeyCode.GetCode() == KEY_ADD) ||
                                       ( aKeyCode.GetCode() == KEY_SUBTRACT) ||
                                       ( aKeyCode.GetCode() == KEY_MULTIPLY) ||
                                       ( aKeyCode.GetCode() == KEY_DIVIDE) ||
                                       ( aKeyCode.GetCode() == KEY_POINT) ||
                                       ( aKeyCode.GetCode() == KEY_COMMA) ||
                                       ( aKeyCode.GetCode() == KEY_EQUAL) ||
                                       ( aKeyCode.GetCode() == 0) ) )
                                {
                                    DBG_ASSERT( pKeyEvent->GetCharCode(), "no charcode found" )
                                    aKeyString += pKeyEvent->GetCharCode();
                                }
                                else
                                {   // not a regular key, transfer KeyCode
                                    aKeyString += 1;   // mask it
                                    // extra for '>' which is coded as <SHIFT LESS>
                                    if ( pKeyEvent->GetCharCode() == '>' )
                                        aKeyString += ( KEY_GREATER | aKeyCode.GetAllModifier() & ~KEY_SHIFT );
                                    else
                                        aKeyString += ( aKeyCode.GetCode() | aKeyCode.GetAllModifier() );
                                }
                                pKeyWin = pWin;
                                Window *pIdWin = pWin;
                                while ( pIdWin->GetParent() && !pIdWin->GetUniqueOrHelpId() )
                                {
                                    pIdWin = pIdWin->GetParent();
                                    bKeyFollowFocus = TRUE;
                                }
                                aKeyUniqueID = pIdWin->GetUniqueOrHelpId();
                            }
                        }
                        break;

                    case VCLEVENT_WINDOW_MOUSEMOVE:
                    case VCLEVENT_WINDOW_MOUSEBUTTONDOWN:
                    case VCLEVENT_WINDOW_MOUSEBUTTONUP:
                        {
                        }
                        break;


                }
                break;
              case WINDOW_DOCKINGWINDOW:
//                switch( nEventID )
                {
//                  case 1 .. 0xffff:
    DBG_TRACE3( "TT_VCLMessage %u %u  %X",nEventID, pWin->GetType(), pWin );
                        BOOL bx = ((DockingWindow*)pWin)->IsFloatingMode();
//                      break;
/*                  case M_Dock :
                        if ( ((DockingWindow*)pControl)->IsFloatingMode() )
                            ((DockingWindow*)pControl)->SetFloatingMode(FALSE);
                        else
                            ReportError( nUId, GEN_RES_STR1( S_ALLOWED_ONLY_IN_FLOATING_MODE, MethodString( nMethodId ) ) );
                        break;
                    case M_Undock :
                        if ( !((DockingWindow*)pControl)->IsFloatingMode() )
                            ((DockingWindow*)pControl)->SetFloatingMode(TRUE);
                        else
                            ReportError( nUId, GEN_RES_STR1( S_ALLOWED_ONLY_IN_FLOATING_MODE, MethodString( nMethodId ) ) );
                        break;
                    case M_IsDocked :
                        pRet->GenReturn ( RET_Value, nUId, (BOOL) !((DockingWindow*)pControl)->IsFloatingMode());
                        break;
                    case M_Close:
                            //nWindowWaitUId = nUId;
                        DBG_ASSERT( nUId == pControl->GetUniqueOrHelpId(), "nUID != UniqueOrHelpId");
                        SET_WINP_CLOSING(pControl);
                        ((DockingWindow*)pControl)->Close();
                        break;
                    case M_Size:
                    case M_Move:
                    case M_IsMax :
                    case M_Minimize :
                    case M_Maximize :
                        if ( ((DockingWindow*)pControl)->IsFloatingMode() )
                        {
                            pControl = ((DockingWindow*)pControl)->GetFloatingWindow();
                            goto FloatWin;
                        }
                        else
                            ReportError( nUId, GEN_RES_STR1( S_ALLOWED_ONLY_IN_DOCKING_MODE, MethodString( nMethodId ) ) );
                        break;
                    case M_Help:        // Alles was unten weiterbehandelt werden soll
                        goto MoreDialog;

                    default:
                        ReportError( nUId, GEN_RES_STR2c2( S_UNKNOWN_METHOD, MethodString(nMethodId), "DockingWindow" ) );
                        break;*/
                }
                break;






            case WINDOW_FLOATINGWINDOW:
                {
    DBG_TRACE3( "TT_VCLMessage %u %u  %X",nEventID, pWin->GetType(), pWin );
                    FloatingWindow *pFW = ((FloatingWindow*)pWin);
                    switch( nEventID )
                    {
/*
// M_OpenMenu an einem ToolboxButton
                        case VCLEVENT_WINDOW_SHOW:
                            if ( pActionParent )
                            {   // a new FloatingWindow opens up, so we assume an OpenMenu
                                // compare to 1 for floating ToolBoxes
                                if ( ( pActionParent->GetUniqueOrHelpId() == 0 || pActionParent->GetUniqueOrHelpId() == 1 ) )
                                    // generate direct Button access
                                    StatementList::pRet->GenReturn( RET_MacroRecorder, pActionParent->GetHelpId( pActionParent->GetCurItemId() ), (USHORT)(M_OpenMenu) );
                                else
                                    // access via Toolbox
                                    StatementList::pRet->GenReturn( RET_MacroRecorder, pActionParent->GetUniqueOrHelpId(), (USHORT)(M_OpenMenu|M_RET_NUM_CONTROL), pActionParent->GetHelpId( pActionParent->GetCurItemId() ) );
                                bSendData = TRUE;
                            }
                            break;
  */
                    }
                }
                break;
/*
                    case M_AnimateMouse :
                        AnimateMouse( pControl, MitteOben);
                        break;
                    case M_IsMax :
                        pRet->GenReturn ( RET_Value, nUId, (BOOL)!((FloatingWindow*)pControl)->IsRollUp());
                        break;
                    case M_Minimize :
                        ((FloatingWindow*)pControl)->RollUp();
                        break;
                    case M_Maximize :
                        ((FloatingWindow*)pControl)->RollDown();
                        break;
                    case M_Size:
                    {
                        if ( pControl->GetStyle() & WB_SIZEABLE )
                        {
                            pControl->SetSizePixel(Size(nNr1,nNr2));
                            pControl->Resize();
                        }
                        else
                            ReportError( nUId, GEN_RES_STR1( S_SIZE_NOT_CHANGEABLE, MethodString( nMethodId ) ) );
                        break;
                    }
                    case M_Close:
                        DBG_ASSERT( nUId == pControl->GetUniqueOrHelpId(), "nUID != UniqueOrHelpId");
                        SET_WINP_CLOSING(pControl);
                        ((FloatingWindow*)pControl)->Close();
                        break;
                    case M_Help:        // Alles was unten weiterbehandelt werden soll
                    case M_Move:
                        goto MoreDialog;
                    default:
                        ReportError( nUId, GEN_RES_STR2c2( S_UNKNOWN_METHOD, MethodString(nMethodId), "FloatingWin" ) );
                        break;
                }
                break;*/








/*
            case C_ModelessDlg:
            case C_Dlg:
            case C_TabDlg:
                MoreDialog:
                switch( nEventID )
                {

                    // (Rect GetRect)

                    case M_AnimateMouse :
                        AnimateMouse( pControl, MitteOben);
                        break;
                    case M_Close:
                        DBG_ASSERT( nUId == pControl->GetUniqueOrHelpId(), "nUID != UniqueOrHelpId");
                        SET_WINP_CLOSING(pControl);
                        ((SystemWindow*)pControl)->Close();
                        break;
                    case M_Move:
                    {
                        pControl->SetPosPixel(Point(nNr1,nNr2));
                        break;
                    }
                    default:
                        ReportError( nUId, GEN_RES_STR2c2( S_UNKNOWN_METHOD, MethodString(nMethodId), "Dialog" ) );
                        break;
                }
                break;*/













/*
            case C_WorkWin:
                switch( nEventID )
                {
                    case M_Close:
                        DBG_ASSERT( nUId == pControl->GetUniqueOrHelpId(), "nUID != UniqueOrHelpId");
                        SET_WINP_CLOSING(pControl);
                        ((WorkWindow*)pControl)->Close();
                        break;
                    case M_Size:
                    case M_Move:
                        goto FloatWin;
                        break;
                    case M_Help:        // Alles was unten weiterbehandelt werden soll
                        goto MoreDialog;
                    default:
                        ReportError( nUId, GEN_RES_STR2c2( S_UNKNOWN_METHOD, MethodString(nMethodId), "WorkWindow" ) );
                        break;
                }
                break;
  */


/*          case C_TabPage:
                switch( nEventID )
                {
                }
                break;*/













/*
            case C_MessBox:
            case C_InfoBox:
            case C_WarningBox:
            case C_ErrorBox:
            case C_QueryBox:
                {
                    BOOL bDone = TRUE;
                    MessBox* pMB = (MessBox*)pControl;
                    switch( nEventID )
                    {
#if SUPD > 631
                        case M_GetCheckBoxText:
                            pRet->GenReturn ( RET_Value, nUId, pMB->GetCheckBoxText() );
                            break;
                        case M_IsChecked :
                            pRet->GenReturn ( RET_Value, nUId, BOOL( pMB->GetCheckBoxState() == STATE_CHECK) );
                            break;
                        case M_GetState :
                            pRet->GenReturn ( RET_Value, nUId, ULONG( pMB->GetCheckBoxState() ));
                            break;
                        case M_Check :
                            pMB->SetCheckBoxState( STATE_CHECK );
                            break;
                        case M_UnCheck :
                            pMB->SetCheckBoxState( STATE_NOCHECK );
                            break;
#endif
                        case M_GetText :
                            pRet->GenReturn ( RET_Value, nUId, pMB->GetMessText());
                            break;

                        default:
                            bDone = FALSE;
                            break;
                    }
                    if ( bDone )
                        break;  // break the case here else continue at C_ButtonDialog
                }
            case C_ButtonDialog:
                {
                    ButtonDialog* pBD = (ButtonDialog*)pControl;
#ifdef DEBUG
                    m_pDbgWin->AddText( "Working MessBox: " );
                    if (pControl->IsVisible())
                        m_pDbgWin->AddText("*(Visible)\n");
                    else
                        m_pDbgWin->AddText("*(nicht Visible)\n");
#endif
                    switch( nEventID )
                    {
                        case M_GetText :
                            pRet->GenReturn ( RET_Value, nUId, pControl->GetText());
                            break;
                        case M_Click:
                            if ( nParams & PARAM_USHORT_1 )
                            {
                                if ( pBD->GetPushButton( nNr1 ) )
                                {
                                    if ( nNr1 != BUTTONID_HELP )
                                    {
                                        SET_WINP_CLOSING(pControl);
                                    }
                                    pBD->GetPushButton( nNr1 )->Click();
                                }
                                else
                                    ReportError( nUId, GEN_RES_STR2( S_NO_DEFAULT_BUTTON, UniString::CreateFromInt32( nNr1 ), MethodString( nMethodId ) ) );
                            }
                            else
                                ReportError( nUId, GEN_RES_STR1( S_BUTTONID_REQUIRED, MethodString( nMethodId ) ) );
                            break;
                        case M_GetButtonCount :
                            pRet->GenReturn ( RET_Value, nUId, ULONG(pBD->GetButtonCount()));
                            break;
                        case M_GetButtonId :
                            if ( ValueOK(nUId, MethodString( nMethodId ),nNr1,pBD->GetButtonCount()) )
                                pRet->GenReturn ( RET_Value, nUId, ULONG(pBD->GetButtonId(nNr1-1)));
                            break;
                        default:
                            ReportError( nUId, GEN_RES_STR2c2( S_UNKNOWN_METHOD, MethodString(nMethodId), "MessageBox" ) );
                            break;
                    }
                    break;


                 */


























        }


        switch( nEventID )
        {
            case VCLEVENT_CONTROL_LOSEFOCUS:
                if ( pEditModify == pWin )
                {
                    StatementList::pRet->GenReturn( RET_MacroRecorder, pWin->GetUniqueOrHelpId(), M_SetText, aEditModifyString );
                    bSendData = TRUE;
                    pEditModify = NULL;
                    aEditModifyString.Erase();  //could be somewhat lengthy
                }
                break;
        }

        pLastWin = pWin;

    }  // if
    else if ( pEvent->ISA( VclMenuEvent ) )
    {
        VclMenuEvent* pMenuEvent = ( VclMenuEvent* ) pEvent;
    }


    if ( bSendData )
        new StatementFlow( NULL, F_EndCommandBlock );   // Kommando zum Senden erzeugen und in que eintragen

    return 0;
}


void StatementCommand::HandleMacroRecorder()
{
    static MacroRecorder *pMacroRecorder = NULL;

    if ( ! (nParams & PARAM_BOOL_1) )
        bBool1 = TRUE;

    if ( bBool1 )
    {
        if ( !pMacroRecorder )
            pMacroRecorder = new MacroRecorder;
    }
    else
    {
        delete pMacroRecorder;
        pMacroRecorder = NULL;
    }
}