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
|
/* -*- mode: C++; tab-width: 4 -*- */
/* ===================================================================== *\
Copyright (c) 1999-2001 Palm, Inc. or its subsidiaries.
All rights reserved.
This file is part of the Palm OS Emulator.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
\* ===================================================================== */
#ifndef EmDlg_h
#define EmDlg_h
#include "EmFileImport.h" // EmFileImportMethod
#include "EmFileRef.h" // EmFileRefList
#include "EmTransport.h" // EmTransport
#include "EmTransportSerial.h" // EmTransportSerial::BaudList
#include "EmTypes.h" // EmResetType
#include "EmStructs.h" // DatabaseInfoList
#include "Logging.h" // FOR_EACH_LOG_PREF, FOR_EACH_REPORT_PREF
/*
EmDlg fulfills two purposes:
* Provides a "repository" for all dialogs the emulator shows.
Each dialog is invoked by calling an EmDlg entry point. This
entry point takes an optional set of parameters, shows and
handles all interaction with the dialog, and returns the
EmDlgItemID of the dialog item used to close the dialog (e.g.,
OK, Cancel, etc.).
* Provides a cross-platform interface for manipulating dialogs
and their items.
For the most part, clients of EmDlg use it to open and handle dialogs,
and EmDlg itself uses the cross-platform part in order to update
text, item states, etc., of the dialog.
To add a new dialog:
* Define a new EmDlgID. New ids should be added to the end of
the current list of IDs. They should not be renumbered.
Dialogs on some platforms (in particular, the Mac) are dependant
on the numbers assigned to the EmDlgIDs, so don't renumber them
without also renumbering all Mac dialogs and dialog items.
* Define new EmDlgItemIDs for all the items in the dialog. All
dialog items need to have unique IDs assigned to them -- even
across all dialogs -- so use the DLG_BASE macro to establish a
little number space for them based on the EmDlgID of the dialog
they're in.
* Define a new entry point. This entry point should have a name
along the lines of Do<Something> (e.g., DoHordeNew,
DoDatabaseExport). This entry point can take any number of
parameters you like.
* Implement this entry point by calling EmDlg::RunDialog, passing
to it the EmDlgID of the dialog box to show, a pointer to a
callback procedure, and a pointer to any custom data to pass to
the callback procedure (usually a pointer to a parameter block
containing the parameters passed to the entry point).
* Implement the callback procedure. The callback procedure is
responsible for initializing the dialog and its elements,
for handling clicks on the dialog items, and for finalizing and
closing the dialog. A template for a callback procedure is kept
at the bottom of EmDlg.cpp.
* The callback procedure is passed a reference to an
EmDlgContext. This structure contains information about the
dialog and why the callback procedure is being called. The
first thing the callback should do is examine the fCommandID
field. This field is of type EmDlgCmdID, and can be one of the
following values:
* kDlgCmdInit Passed to the callback procedure once to
initialize the dialog and its elements.
* kDlgCmdIdle Passed to the callback procedure several
times a second to allow the dialog to idle.
Sent to the callback only if it indicates
that it wants idle time (by setting the
fNeedsIdle field when initialized).
* kDlgCmdItemSelected Passed to the callback procedure any time
a dialog item is selected.
* kDlgCmdDestroy Passed to the callback procedure once when
the dialog is being destroyed. The dialog
may choose to perform any last minute
cleanup here.
* If the command is kDlgCmdItemSelected, then the callback
procedure should examine the fItemID field. This indicates what
dialog item was selected.
* The callback procedure returns an EmDlgFnResult. This can be
one of the following values:
* kDlgResultContinue Keep the dialog open--we're not done yet.
* kDlgResultClose Close the dialog. Either the user pressed
a button to close the dialog, or the dialog
has some sort of auto-close feature, or an
error occurred.
* Define your platform-specific dialogs. In general, create your
dialogs as you would naturally on that platform (e.g., use
Constructor on the Mac, VC++'s dialog editor on Windows, or
fluid if using FLTK on Unix). However, to hook those dialogs up
to the cross-platform mechanism, the following additional steps
need to be taken:
Macintosh
---------
* The dialog's 'ppob' resource ID should be kDialogIDBase
(2000) plus the EmDlgID of the dialog.
* The dialog items should have IDs (and, if applicable,
message values) of kDialogItemIDBase (5000) plus their
EmDlgItemID.
Unix (FLTK)
-----------
* Name the function that creates the dialog along the lines
of "PrvMake<DialogName>". In PrvMakeDialog() in
EmDlgFltk.cpp, add a case statement to call this function.
* When creating widgets in fluid, include a line like the
following in the "code" sections:
::PrvSetWidgetID (o, kDlgItemOK);
Windows
-------
* Create the dialog and items using any resource symbols you
care to define. Note that the values for your resource
symbols must be unique from those for all other dialog
items. The Emulator will enforce this with checks in
PrvFromDlgItemID and PrvToDlgItemID (two internal routines
used when creating and manipulating dialogs -- these checks
are made only in debug builds).
* In EmDlgWin.cpp, map the symbols you've defined to the
cross-platform symbols by adding the appropriate entries to
kDlgIDMap and kDlgItemIDMap.
*/
class EmROMTransfer;
enum EmDlgCmdID
{
kDlgCmdNone = 0,
kDlgCmdInit = 1,
kDlgCmdIdle = 2,
kDlgCmdItemSelected = 3,
kDlgCmdDestroy = 4,
kDlgCmdPanelEnter = 5,
kDlgCmdPanelExit = 6
};
enum EmDlgFnResult
{
kDlgResultNone = 0,
kDlgResultContinue = 1,
kDlgResultClose = 2
};
enum EmDlgID
{
kDlgNone = 0,
kDlgAboutBox = 1,
kDlgSessionNew = 2,
kDlgSessionSave = 3,
kDlgHordeNew = 4,
kDlgDatabaseImport = 5,
kDlgDatabaseExport = 6,
kDlgROMTransferQuery = 7,
kDlgROMTransferProgress = 8,
kDlgGremlinControl = 9,
kDlgEditPreferences = 10,
kDlgEditLogging = 11,
kDlgEditDebugging = 12,
kDlgEditSkins = 13,
kDlgCommonDialog = 14,
kDlgSaveBound = 15,
kDlgEditHostFS = 16,
kDlgEditBreakpoints = 17,
kDlgEditCodeBreakpoint = 18,
kDlgEditTracingOptions = 19,
kDlgEditPreferencesFullyBound = 20,
kDlgReset = 21,
kDlgSessionInfo = 22,
kDlgGetSocketAddress = 23,
kDlgEditErrorHandling = 24,
kDlgMinimizeProgress = 25
};
enum EmDlgPanelID
{
kDlgPanelNone = 0,
kDlgPanelAbtMain = 1,
kDlgPanelAbtWindows = 2,
kDlgPanelAbtMac = 3,
kDlgPanelAbtUAE = 4,
kDlgPanelAbtQNX = 5
};
#define DLG_BASE(dlgID) ((dlgID) * 100)
enum EmDlgItemID
{
kDlgItemNone = 0,
kDlgItemOK = 0x01,
kDlgItemCancel = 0x02,
kDlgItemYes = 0x03,
kDlgItemNo = 0x04,
kDlgItemContinue = 0x05,
kDlgItemDebug = 0x06,
kDlgItemReset = 0x07,
kDlgItemNextGremlin = 0x08,
kDlgItemAbtAppName = DLG_BASE(kDlgAboutBox) + 0,
kDlgItemAbtURLPalmWeb = DLG_BASE(kDlgAboutBox) + 1,
kDlgItemAbtURLPalmMail = DLG_BASE(kDlgAboutBox) + 2,
kDlgItemAbtURLWindowsWeb = DLG_BASE(kDlgAboutBox) + 3,
kDlgItemAbtURLWindowsMail = DLG_BASE(kDlgAboutBox) + 4,
kDlgItemAbtURLMacWeb = DLG_BASE(kDlgAboutBox) + 5,
kDlgItemAbtURLMacMail = DLG_BASE(kDlgAboutBox) + 6,
kDlgItemAbtURLUAEWeb = DLG_BASE(kDlgAboutBox) + 7,
kDlgItemAbtURLUAEMail = DLG_BASE(kDlgAboutBox) + 8,
kDlgItemAbtURLQNXWeb = DLG_BASE(kDlgAboutBox) + 9,
kDlgItemAbtURLQNXMail = DLG_BASE(kDlgAboutBox) + 10,
kDlgItemNewDevice = DLG_BASE(kDlgSessionNew) + 0,
kDlgItemNewSkin = DLG_BASE(kDlgSessionNew) + 1,
kDlgItemNewMemorySize = DLG_BASE(kDlgSessionNew) + 2,
kDlgItemNewROM = DLG_BASE(kDlgSessionNew) + 3,
kDlgItemNewROMBrowse = DLG_BASE(kDlgSessionNew) + 4,
kDlgItemHrdAppList = DLG_BASE(kDlgHordeNew) + 0,
kDlgItemHrdStart = DLG_BASE(kDlgHordeNew) + 1,
kDlgItemHrdStop = DLG_BASE(kDlgHordeNew) + 2,
kDlgItemHrdCheckSwitch = DLG_BASE(kDlgHordeNew) + 3,
kDlgItemHrdCheckSave = DLG_BASE(kDlgHordeNew) + 4,
kDlgItemHrdCheckStop = DLG_BASE(kDlgHordeNew) + 5,
kDlgItemHrdDepthSwitch = DLG_BASE(kDlgHordeNew) + 6,
kDlgItemHrdDepthSave = DLG_BASE(kDlgHordeNew) + 7,
kDlgItemHrdDepthStop = DLG_BASE(kDlgHordeNew) + 8,
kDlgItemHrdLogging = DLG_BASE(kDlgHordeNew) + 9,
kDlgItemHrdFirstLaunchedApp = DLG_BASE(kDlgHordeNew) + 10,
kDlgItemHrdSelectAll = DLG_BASE(kDlgHordeNew) + 11,
kDlgItemHrdSelectNone = DLG_BASE(kDlgHordeNew) + 12,
kDlgItemImpNumFiles = DLG_BASE(kDlgDatabaseImport) + 0,
kDlgItemImpProgress = DLG_BASE(kDlgDatabaseImport) + 1,
kDlgItemExpDbList = DLG_BASE(kDlgDatabaseExport) + 0,
kDlgItemDlqInstructions = DLG_BASE(kDlgROMTransferQuery) + 0,
kDlgItemDlqPortList = DLG_BASE(kDlgROMTransferQuery) + 1,
kDlgItemDlqBaudList = DLG_BASE(kDlgROMTransferQuery) + 2,
kDlgItemDlpMessage = DLG_BASE(kDlgROMTransferProgress) + 0,
kDlgItemDlpProgress = DLG_BASE(kDlgROMTransferProgress) + 1,
kDlgItemGrmNumber = DLG_BASE(kDlgGremlinControl) + 0,
kDlgItemGrmEventNumber = DLG_BASE(kDlgGremlinControl) + 1,
kDlgItemGrmElapsedTime = DLG_BASE(kDlgGremlinControl) + 2,
kDlgItemGrmStop = DLG_BASE(kDlgGremlinControl) + 3,
kDlgItemGrmResume = DLG_BASE(kDlgGremlinControl) + 4,
kDlgItemGrmStep = DLG_BASE(kDlgGremlinControl) + 5,
kDlgItemPrfRedirectSerial = DLG_BASE(kDlgEditPreferences) + 0,
kDlgItemPrfRedirectIR = DLG_BASE(kDlgEditPreferences) + 1,
kDlgItemPrfRedirectMystery = DLG_BASE(kDlgEditPreferences) + 2,
kDlgItemPrfRedirectNetLib = DLG_BASE(kDlgEditPreferences) + 9,
kDlgItemPrfEnableSound = DLG_BASE(kDlgEditPreferences) + 10,
kDlgItemPrfSaveAlways = DLG_BASE(kDlgEditPreferences) + 11,
kDlgItemPrfSaveAsk = DLG_BASE(kDlgEditPreferences) + 12,
kDlgItemPrfSaveNever = DLG_BASE(kDlgEditPreferences) + 13,
kDlgItemPrfUserName = DLG_BASE(kDlgEditPreferences) + 14,
kDlgItemLogNormal = DLG_BASE(kDlgEditLogging) + 0,
kDlgItemLogGremlins = DLG_BASE(kDlgEditLogging) + 1,
kDlgItemLogCheckBase = DLG_BASE(kDlgEditLogging) + 10,
#undef DEFINE_BUTTON_ID
#define DEFINE_BUTTON_ID(name) kDlgItemLog##name,
FOR_EACH_LOG_PREF(DEFINE_BUTTON_ID)
kDlgItemDbgDialogBeep = DLG_BASE(kDlgEditDebugging) + 0,
kDlgItemDbgCheckBase = DLG_BASE(kDlgEditDebugging) + 10,
#undef DEFINE_BUTTON_ID
#define DEFINE_BUTTON_ID(name) kDlgItemDbg##name,
FOR_EACH_REPORT_PREF(DEFINE_BUTTON_ID)
kDlgItemSknSkinList = DLG_BASE(kDlgEditSkins) + 0,
kDlgItemSknDoubleScale = DLG_BASE(kDlgEditSkins) + 1,
kDlgItemSknWhiteBackground = DLG_BASE(kDlgEditSkins) + 2,
kDlgItemSknDim = DLG_BASE(kDlgEditSkins) + 3,
kDlgItemSknRed = DLG_BASE(kDlgEditSkins) + 4,
kDlgItemSknGreen = DLG_BASE(kDlgEditSkins) + 5,
kDlgItemSknStayOnTop = DLG_BASE(kDlgEditSkins) + 6,
kDlgItemCmnText = DLG_BASE(kDlgCommonDialog) + 0,
kDlgItemCmnIconStop = DLG_BASE(kDlgCommonDialog) + 1,
kDlgItemCmnIconCaution = DLG_BASE(kDlgCommonDialog) + 2,
kDlgItemCmnIconNote = DLG_BASE(kDlgCommonDialog) + 3,
kDlgItemCmnButton1 = DLG_BASE(kDlgCommonDialog) + 4,
kDlgItemCmnButton2 = DLG_BASE(kDlgCommonDialog) + 5,
kDlgItemCmnButton3 = DLG_BASE(kDlgCommonDialog) + 6,
kDlgItemCmnButtonCopy = DLG_BASE(kDlgCommonDialog) + 7,
kDlgItemBndSaveROM = DLG_BASE(kDlgSaveBound) + 0,
kDlgItemBndSaveRAM = DLG_BASE(kDlgSaveBound) + 1,
kDlgItemHfsList = DLG_BASE(kDlgEditHostFS) + 0,
kDlgItemHfsPath = DLG_BASE(kDlgEditHostFS) + 1,
kDlgItemHfsMounted = DLG_BASE(kDlgEditHostFS) + 2,
kDlgItemHfsBrowse = DLG_BASE(kDlgEditHostFS) + 3,
kDlgItemBrkList = DLG_BASE(kDlgEditBreakpoints) + 0,
kDlgItemBrkButtonEdit = DLG_BASE(kDlgEditBreakpoints) + 1,
kDlgItemBrkButtonClear = DLG_BASE(kDlgEditBreakpoints) + 2,
kDlgItemBrkCheckEnabled = DLG_BASE(kDlgEditBreakpoints) + 3,
kDlgItemBrkStartAddress = DLG_BASE(kDlgEditBreakpoints) + 4,
kDlgItemBrkNumberOfBytes = DLG_BASE(kDlgEditBreakpoints) + 5,
kDlgItemBrkAddress = DLG_BASE(kDlgEditCodeBreakpoint) + 0,
kDlgItemBrkCondition = DLG_BASE(kDlgEditCodeBreakpoint) + 1,
kDlgItemTrcOutput = DLG_BASE(kDlgEditTracingOptions) + 0,
kDlgItemTrcTargetText = DLG_BASE(kDlgEditTracingOptions) + 1,
kDlgItemTrcTargetValue = DLG_BASE(kDlgEditTracingOptions) + 2,
kDlgItemTrcInfo = DLG_BASE(kDlgEditTracingOptions) + 3,
kDlgItemTrcAutoConnect = DLG_BASE(kDlgEditTracingOptions) + 4,
kDlgItemRstSoft = DLG_BASE(kDlgReset) + 0,
kDlgItemRstHard = DLG_BASE(kDlgReset) + 1,
kDlgItemRstDebug = DLG_BASE(kDlgReset) + 2,
kDlgItemRstNoExt = DLG_BASE(kDlgReset) + 3,
kDlgItemInfDeviceFld = DLG_BASE(kDlgSessionInfo) + 0,
kDlgItemInfRAMFld = DLG_BASE(kDlgSessionInfo) + 1,
kDlgItemInfROMFld = DLG_BASE(kDlgSessionInfo) + 2,
kDlgItemInfSessionFld = DLG_BASE(kDlgSessionInfo) + 3,
kDlgItemSocketAddress = DLG_BASE(kDlgGetSocketAddress) + 0,
kDlgItemErrWarningOff = DLG_BASE(kDlgEditErrorHandling) + 0,
kDlgItemErrErrorOff = DLG_BASE(kDlgEditErrorHandling) + 1,
kDlgItemErrWarningOn = DLG_BASE(kDlgEditErrorHandling) + 2,
kDlgItemErrErrorOn = DLG_BASE(kDlgEditErrorHandling) + 3,
kDlgItemMinPassNumber = DLG_BASE(kDlgMinimizeProgress) + 0,
kDlgItemMinEventNumber = DLG_BASE(kDlgMinimizeProgress) + 1,
kDlgItemMinElapsed = DLG_BASE(kDlgMinimizeProgress) + 2,
kDlgItemMinRange = DLG_BASE(kDlgMinimizeProgress) + 3,
kDlgItemMinDiscarded = DLG_BASE(kDlgMinimizeProgress) + 4,
kDlgItemMinProgress = DLG_BASE(kDlgMinimizeProgress) + 5,
kDlgItemLast
};
enum EmCommonDialogFlags
{
// Each button is stored in an 8-bit field. A button ID is
// stored in the lower 4-bits, and the upper 4-bits are use
// to hold flags indicating if the button is the default button,
// if the button is enabled, or if the button is even visible.
// There are three of these fields, filling 24 of the 32 bits of
// the flags parameter.
/*
The various buttons have different positions depending on the platform
being run on:
Mac/Unix:
+----------------------------------+
| ** |
| ** Blah blah blah |
| ** |
| |
| |
| Button3 Button2 Button1 |
+----------------------------------+
Windows:
+----------------------------------+
| ** Button1 |
| ** Blah blah blah Button2 |
| ** Button3 |
| |
| |
| |
+----------------------------------+
*/
kButtonMask = 0x0F,
kButtonDefault = 0x10,
kButtonEscape = 0x20,
kButtonVisible = 0x40,
kButtonEnabled = 0x80,
kButtonFieldShift = 8,
kButtonFieldMask = 0x000000FF,
// The following naming convention is used for the following values:
//
// An all-upper name
// the button is the default button (and visible and enabled)
//
// A first-upper name
// the button is visible and enabled.
//
// An all-lower name
// the button is visible but disabled.
#define SET_BUTTON(p, x) (((long)(x) & kButtonFieldMask) << (kButtonFieldShift * (p)))
#define GET_BUTTON(p, x) (((x) >> (kButtonFieldShift * (p))) & kButtonFieldMask)
#define SET_BUTTON_DEFAULT(p, x) SET_BUTTON(p, (x) | kButtonVisible | kButtonEnabled | kButtonDefault)
#define SET_BUTTON_ESCAPE(p, x) SET_BUTTON(p, (x) | kButtonVisible | kButtonEnabled | kButtonEscape)
#define SET_BUTTON_STANDARD(p, x) SET_BUTTON(p, (x) | kButtonVisible | kButtonEnabled)
#define SET_BUTTON_DISABLED(p, x) SET_BUTTON(p, (x) | kButtonVisible)
kDlgFlags_None = 0,
kDlgFlags_OK = SET_BUTTON_DEFAULT (0, kDlgItemOK),
kDlgFlags_CANCEL = SET_BUTTON_DEFAULT (0, kDlgItemCancel),
kDlgFlags_OK_Cancel = SET_BUTTON_DEFAULT (0, kDlgItemOK)
| SET_BUTTON_ESCAPE (1, kDlgItemCancel),
kDlgFlags_Ok_CANCEL = SET_BUTTON_STANDARD (0, kDlgItemOK)
| SET_BUTTON_DEFAULT (1, kDlgItemCancel),
kDlgFlags_YES_No = SET_BUTTON_DEFAULT (0, kDlgItemYes)
| SET_BUTTON_ESCAPE (1, kDlgItemNo),
kDlgFlags_Yes_NO = SET_BUTTON_STANDARD (0, kDlgItemYes)
| SET_BUTTON_DEFAULT (1, kDlgItemNo),
kDlgFlags_Continue_DEBUG_Reset = SET_BUTTON_STANDARD (0, kDlgItemContinue)
| SET_BUTTON_DEFAULT (1, kDlgItemDebug)
| SET_BUTTON_STANDARD (2, kDlgItemReset),
kDlgFlags_continue_DEBUG_Reset = SET_BUTTON_DISABLED (0, kDlgItemContinue)
| SET_BUTTON_DEFAULT (1, kDlgItemDebug)
| SET_BUTTON_STANDARD (2, kDlgItemReset),
kDlgFlags_continue_debug_RESET = SET_BUTTON_DISABLED (0, kDlgItemContinue)
| SET_BUTTON_DISABLED (1, kDlgItemDebug)
| SET_BUTTON_DEFAULT (2, kDlgItemReset)
};
typedef vector<EmDlgItemID> EmDlgItemIDList;
typedef long EmDlgItemIndex;
typedef vector<EmDlgItemIndex> EmDlgItemIndexList;
typedef long EmDlgListIndex; // Zero-based
typedef vector<EmDlgListIndex> EmDlgListIndexList;
const EmDlgListIndex kDlgItemListNone = -1;
struct EmDlgContext;
typedef EmDlgItemID (*EmDlgThreadFn)(const void*);
typedef EmDlgFnResult (*EmDlgFn)(EmDlgContext&);
typedef void* EmDlgRef;
enum EmROMFileStatus
{
kROMFileOK,
kROMFileDubious,
kROMFileUnknown
};
struct EmDlgContext
{
EmDlgContext (void);
EmDlgContext (const EmDlgContext&);
EmDlgFnResult Init ();
EmDlgFnResult Event (EmDlgItemID);
EmDlgFnResult Idle ();
void Destroy ();
EmDlgFnResult PanelEnter ();
EmDlgFnResult PanelExit ();
EmDlgFn fFn;
EmDlgFnResult fFnResult;
EmDlgRef fDlg;
EmDlgID fDlgID;
EmDlgPanelID fPanelID;
EmDlgItemID fItemID;
EmDlgCmdID fCommandID;
bool fNeedsIdle;
void* fUserData;
EmDlgItemID fDefaultItem;
EmDlgItemID fCancelItem;
};
struct DoGetFileParameters
{
DoGetFileParameters (EmFileRef& result,
const string& prompt,
const EmDirRef& defaultPath,
const EmFileTypeList& filterList) :
fResult (result),
fPrompt (prompt),
fDefaultPath (defaultPath),
fFilterList (filterList)
{
}
EmFileRef& fResult;
const string& fPrompt;
const EmDirRef& fDefaultPath;
const EmFileTypeList& fFilterList;
};
struct DoGetFileListParameters
{
DoGetFileListParameters (EmFileRefList& results,
const string& prompt,
const EmDirRef& defaultPath,
const EmFileTypeList& filterList) :
fResults (results),
fPrompt (prompt),
fDefaultPath (defaultPath),
fFilterList (filterList)
{
}
EmFileRefList& fResults;
const string& fPrompt;
const EmDirRef& fDefaultPath;
const EmFileTypeList& fFilterList;
};
struct DoPutFileParameters
{
DoPutFileParameters (EmFileRef& result,
const string& prompt,
const EmDirRef& defaultPath,
const EmFileTypeList& filterList,
const string& defaultName) :
fResult (result),
fPrompt (prompt),
fDefaultPath (defaultPath),
fFilterList (filterList),
fDefaultName (defaultName)
{
}
EmFileRef& fResult;
const string& fPrompt;
const EmDirRef& fDefaultPath;
const EmFileTypeList& fFilterList;
const string& fDefaultName;
};
struct DoGetDirectoryParameters
{
DoGetDirectoryParameters (EmDirRef& result,
const string& prompt,
const EmDirRef& defaultPath) :
fResult (result),
fPrompt (prompt),
fDefaultPath (defaultPath)
{
}
EmDirRef& fResult;
const string& fPrompt;
const EmDirRef& fDefaultPath;
};
struct DoSessionSaveParameters
{
DoSessionSaveParameters (const string& appName,
const string& docName,
Bool quitting) :
fAppName (appName),
fDocName (docName),
fQuitting (quitting)
{
}
const string& fAppName;
const string& fDocName;
Bool fQuitting;
};
struct RunDialogParameters
{
RunDialogParameters (EmDlgFn fn, void* userData, EmDlgID dlgID) :
fFn (fn),
fUserData (userData),
fDlgID (dlgID)
{
}
EmDlgFn fFn;
void* fUserData;
EmDlgID fDlgID;
};
// !!! Needs to be moved elsewhere
typedef DatabaseInfoList EmDatabaseList;
struct EditCodeBreakpointData;
struct EmErrorHandlingMenuBundle;
class EmDlg
{
public:
static EmDlgItemID DoGetFile (EmFileRef& result,
const string& prompt,
const EmDirRef& defaultPath,
const EmFileTypeList& filterList);
static EmDlgItemID DoGetFileList (EmFileRefList& results,
const string& prompt,
const EmDirRef& defaultPath,
const EmFileTypeList& filterList);
static EmDlgItemID DoPutFile (EmFileRef& result,
const string& prompt,
const EmDirRef& defaultPath,
const EmFileTypeList& filterList,
const string& defaultName);
static EmDlgItemID DoGetDirectory (EmDirRef& result,
const string& prompt,
const EmDirRef& defaultPath);
static EmDlgItemID DoAboutBox (void);
static EmDlgItemID DoSessionNew (Configuration&);
static EmDlgItemID DoSessionSave (const string& docName,
Bool quitting);
static EmDlgItemID DoHordeNew (void);
static EmDlgItemID DoDatabaseImport (const EmFileRefList&,
EmFileImportMethod method);
static EmDlgItemID DoDatabaseExport (void);
static EmDlgItemID DoReset (EmResetType&);
static EmDlgItemID DoROMTransferQuery (EmTransport::Config*&);
static EmDlgItemID DoROMTransferProgress (EmROMTransfer&);
static EmDlgItemID DoEditPreferences (void);
static EmDlgItemID DoEditLoggingOptions (LoggingType);
static EmDlgItemID DoEditDebuggingOptions (void);
static EmDlgItemID DoEditErrorHandling (void);
static EmDlgItemID DoEditSkins (void);
static EmDlgItemID DoEditHostFSOptions (void);
static EmDlgItemID DoEditBreakpoints (void);
static EmDlgItemID DoEditCodeBreakpoint (EditCodeBreakpointData&);
#if HAS_TRACER
static EmDlgItemID DoEditTracingOptions (void);
#endif
static EmDlgItemID DoCommonDialog (StrCode msg,
EmCommonDialogFlags);
static EmDlgItemID DoCommonDialog (const char* msg,
EmCommonDialogFlags);
static EmDlgItemID DoCommonDialog (const string& msg,
EmCommonDialogFlags);
static EmDlgItemID DoSaveBound (void);
static EmDlgItemID DoSessionInfo (void);
static EmDlgItemID DoGetSocketAddress (string&);
static void GremlinControlOpen (void);
static void GremlinControlClose (void);
static void MinimizeProgressOpen (void);
static void MinimizeProgressClose (void);
static EmDlgItemID RunDialog (EmDlgFn, void*, EmDlgID);
static EmDlgItemID RunDialog (EmDlgThreadFn, const void* parameters);
static EmDlgRef DialogOpen (EmDlgFn, void*, EmDlgID);
static void DialogClose (EmDlgRef);
private:
static EmDlgItemID HostRunGetFile (const void* parameters);
static EmDlgItemID HostRunGetFileList (const void* parameters);
static EmDlgItemID HostRunPutFile (const void* parameters);
static EmDlgItemID HostRunGetDirectory (const void* parameters);
static EmDlgItemID HostRunAboutBox (const void* parameters);
static EmDlgItemID HostRunSessionSave (const void* parameters);
static EmDlgItemID HostRunDialog (const void* parameters);
static EmDlgRef HostDialogOpen (EmDlgFn, void*, EmDlgID);
static void HostDialogClose (EmDlgRef);
public: // public right now for PrvIdleCallback, PrvCreateDialog
static void HostDialogInit (EmDlgContext&);
static void HostStartIdling (EmDlgContext&);
static void HostStopIdling (EmDlgContext&);
#if PLATFORM_WINDOWS
static BOOL CALLBACK PrvHostModalProc (HWND hWnd,
UINT msg,
WPARAM wParam,
LPARAM lParam);
static BOOL CALLBACK PrvHostModelessProc (HWND hWnd,
UINT msg,
WPARAM wParam,
LPARAM lParam);
#endif
private:
friend struct EmDlgContext; // To call HostStartIdling
private:
static EmDlgFnResult PrvSessionNew (EmDlgContext&);
static EmDlgFnResult PrvHordeNew (EmDlgContext&);
static EmDlgFnResult PrvDatabaseImport (EmDlgContext&);
static EmDlgFnResult PrvDatabaseExport (EmDlgContext&);
static EmDlgFnResult PrvReset (EmDlgContext&);
static EmDlgFnResult PrvROMTransferQuery (EmDlgContext&);
static EmDlgFnResult PrvROMTransferProgress (EmDlgContext&);
static EmDlgFnResult PrvEditPreferences (EmDlgContext&);
static EmDlgFnResult PrvEditLoggingOptions (EmDlgContext&);
static EmDlgFnResult PrvEditDebuggingOptions (EmDlgContext&);
static EmDlgFnResult PrvErrorHandling (EmDlgContext&);
static EmDlgFnResult PrvEditSkins (EmDlgContext&);
static EmDlgFnResult PrvEditHostFSOptions (EmDlgContext&);
static EmDlgFnResult PrvEditBreakpoints (EmDlgContext&);
static EmDlgFnResult PrvEditCodeBreakpoint (EmDlgContext&);
#if HAS_TRACER
static EmDlgFnResult PrvEditTracingOptions (EmDlgContext&);
#endif
static EmDlgFnResult PrvCommonDialog (EmDlgContext&);
static EmDlgFnResult PrvSaveBound (EmDlgContext&);
static EmDlgFnResult PrvSessionInfo (EmDlgContext&);
static EmDlgFnResult PrvGetSocketAddress (EmDlgContext&);
static EmDlgFnResult PrvGremlinControl (EmDlgContext&);
static EmDlgFnResult PrvMinimizeProgress (EmDlgContext&);
// DoSessionNew
static void PrvBuildROMMenu (const EmDlgContext&);
static void PrvBuildDeviceMenu (const EmDlgContext&);
static void PrvBuildSkinMenu (const EmDlgContext&);
static void PrvBuildMemorySizeMenu (const EmDlgContext&);
static void PrvNewSessionSetOKButton (const EmDlgContext&);
static void PrvFilterDeviceList (const EmFileRef& romFile,
EmDeviceList& devices,
EmDeviceList::iterator& devices_end,
unsigned int& version);
static void PrvFilterMemorySizes (MemoryTextList& sizes,
const Configuration& cfg);
static EmROMFileStatus PrvCanUseROMFile (EmFileRef& testRef);
// DoHordeNew
static UInt32 PrvSelectedAppNameToIndex (EmDatabaseList list, const string& appName);
static DatabaseInfo PrvSelectedIndexToApp (EmDatabaseList list, uint32 index);
static void PrvSelectedList (EmDatabaseList selectedApps,
StringList &selectedAppStrings);
// DoDatabaseExport
static Bool PrvExportFile (const DatabaseInfo& db);
// DoROMTransferQuery
static void PrvGetDlqPortItemList (EmTransportDescriptorList& menuItems);
static void PrvConvertBaudListToStrings (const EmTransportSerial::BaudList& baudList,
StringList& baudStrList);
// DoEditPreferences
static void PrvEditPrefToDialog (EmDlgContext& context);
static void PrvEditPrefFromDialog (EmDlgContext& context);
static void PrvBuildDescriptorLists (EmDlgContext& context);
static void PrvGetEditPreferences (EmDlgContext& context);
static void PrvPutEditPreferences (EmDlgContext& context);
static Bool PrvEditPreferencesValidate (EmDlgContext& context);
static void PrvGetPrefSocketAddress (EmDlgContext& context);
// DoEditLoggingOptions
static void PrvFetchLoggingPrefs (EmDlgContext& context);
static void PrvInstallLoggingPrefs (EmDlgContext& context);
static void PrvLoggingPrefsToButtons (EmDlgContext& context);
static void PrvLoggingPrefsFromButtons (EmDlgContext& context);
// DoEditDebuggingOptions
static void PrvFetchDebuggingPrefs (EmDlgContext& context);
static void PrvInstallDebuggingPrefs (EmDlgContext& context);
static void PrvDebuggingPrefsToButtons (EmDlgContext& context);
static void PrvDebuggingPrefsFromButtons (EmDlgContext& context);
// DoEditErrorHandling
static string PrvMenuItemText (EmErrorHandlingOption item);
static void PrvBuildMenu (EmErrorHandlingMenuBundle& menu,
StringList& items);
static long PrvFindIndex (EmErrorHandlingMenuBundle& menu,
EmErrorHandlingOption toFind);
static void PrvErrorHandlingToDialog (EmDlgContext& context,
EmErrorHandlingMenuBundle& menu);
static void PrvErrorHandlingFromDialog (EmDlgContext& context,
EmErrorHandlingMenuBundle& menu);
static EmDlgItemID PrvAskChangeLogging (void);
static void PrvCheckSetting (EmDlgContext& context,
EmErrorHandlingMenuBundle& menu);
static Bool PrvCheckSettings (EmDlgContext& context);
static void PrvEnableLoggingOption (EmErrorHandlingMenuBundle& menu);
static void PrvEnableLoggingOptions (void);
// DoEditHostFSOptions
static void PrvEditHostFSOptionsOK (EmDlgContext& context);
// DoEditBreakpoints
static void PrvEnableCodeBreakpointControls (EmDlgContext& context, bool enable);
static void PrvEnableDataBreakpointControls (EmDlgContext& context, bool enable);
static void PrvRefreshCodeBreakpointList (EmDlgContext& context);
static void PrvGetCodeBreakpoints (EmDlgContext& context);
static void PrvSetCodeBreakpoints (EmDlgContext& context);
// DoEditTracingOptions
#if HAS_TRACER
static void PrvPopTracerSettings (EmDlgContext& context);
static void PrvPushTracerSettings (EmDlgContext& context);
#endif
// GremlinControl
static void PrvGrmUpdateGremlinNumber (EmDlgContext& context);
static void PrvGrmUpdateEventNumber (EmDlgContext& context);
static void PrvGrmUpdateElapsedTime (EmDlgContext& context);
static void PrvGrmUpdateAll (EmDlgContext& context);
// Minimization Progress
static void PrvMinUpdatePassNumber (EmDlgContext& context);
static void PrvMinUpdateEventNumber (EmDlgContext& context);
static void PrvMinUpdateElapsed (EmDlgContext& context);
static void PrvMinUpdateRange (EmDlgContext& context);
static void PrvMinUpdateDiscarded (EmDlgContext& context);
static void PrvMinUpdateProgress (EmDlgContext& context);
static void PrvMinUpdateAll (EmDlgContext& context);
public: // Most of these are really "Host" functions
static void SetDlgBounds (EmDlgRef, const EmRect&);
static EmRect GetDlgBounds (EmDlgRef);
static void MoveDlgTo (EmDlgRef, EmCoord x, EmCoord y);
static void MoveDlgTo (EmDlgRef, const EmPoint&);
static void CenterDlg (EmDlgRef);
static void EnsureDlgOnscreen (EmDlgRef);
static void SetDlgDefaultButton (EmDlgContext&, EmDlgItemID);
static void SetDlgCancelButton (EmDlgContext&, EmDlgItemID);
static void SetItemMin (EmDlgRef, EmDlgItemID, long max);
static void SetItemValue (EmDlgRef, EmDlgItemID, long value);
static void SetItemMax (EmDlgRef, EmDlgItemID, long max);
static void SetItemBounds (EmDlgRef, EmDlgItemID, const EmRect&);
static void SetItemText (EmDlgRef, EmDlgItemID, StrCode);
static void SetItemText (EmDlgRef, EmDlgItemID, const char*);
static void SetItemText (EmDlgRef, EmDlgItemID, string);
static long GetItemMin (EmDlgRef, EmDlgItemID);
static long GetItemValue (EmDlgRef, EmDlgItemID);
static long GetItemMax (EmDlgRef, EmDlgItemID);
static EmRect GetItemBounds (EmDlgRef, EmDlgItemID);
static string GetItemText (EmDlgRef, EmDlgItemID);
static void EnableItem (EmDlgRef, EmDlgItemID);
static void DisableItem (EmDlgRef, EmDlgItemID);
static void EnableDisableItem (EmDlgRef, EmDlgItemID, Bool);
static void ShowItem (EmDlgRef, EmDlgItemID);
static void HideItem (EmDlgRef, EmDlgItemID);
static void ShowHideItem (EmDlgRef, EmDlgItemID, Bool);
static void ClearMenu (EmDlgRef, EmDlgItemID);
static void AppendToMenu (EmDlgRef, EmDlgItemID, const string&);
static void AppendToMenu (EmDlgRef, EmDlgItemID, const StringList&);
static void EnableMenuItem (EmDlgRef, EmDlgItemID, long);
static void DisableMenuItem (EmDlgRef, EmDlgItemID, long);
static void ClearList (EmDlgRef, EmDlgItemID);
static void AppendToList (EmDlgRef, EmDlgItemID, const string&);
static void AppendToList (EmDlgRef, EmDlgItemID, const StringList&);
static void SelectListItem (EmDlgRef, EmDlgItemID, EmDlgListIndex);
static void SelectListItems (EmDlgRef, EmDlgItemID, const EmDlgListIndexList&);
static void UnselectListItem (EmDlgRef, EmDlgItemID, EmDlgListIndex);
static void UnselectListItems (EmDlgRef, EmDlgItemID, const EmDlgListIndexList&);
static EmDlgListIndex GetSelectedItem (EmDlgRef, EmDlgItemID);
static void GetSelectedItems (EmDlgRef, EmDlgItemID, EmDlgListIndexList&);
static int GetTextHeight (EmDlgRef, EmDlgItemID, const string&);
static Bool StringToLong (const char*, long*);
};
#endif /* EmDlg_h */
|