-
Notifications
You must be signed in to change notification settings - Fork 0
/
wdialog.cpp
executable file
·2038 lines (1861 loc) · 65.8 KB
/
wdialog.cpp
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
/*
** Astrolog (Version 6.40) File: wdialog.cpp
**
** IMPORTANT NOTICE: Astrolog and all chart display routines and anything
** not enumerated below used in this program are Copyright (C) 1991-2018 by
** Walter D. Pullen ([email protected], http://www.astrolog.org/astrolog.htm).
** Permission is granted to freely use, modify, and distribute these
** routines provided these credits and notices remain unmodified with any
** altered or distributed versions of the program.
**
** The main ephemeris databases and calculation routines are from the
** library SWISS EPHEMERIS and are programmed and copyright 1997-2008 by
** Astrodienst AG. The use of that source code is subject to the license for
** Swiss Ephemeris Free Edition, available at http://www.astro.com/swisseph.
** This copyright notice must not be changed or removed by any user of this
** program.
**
** Additional ephemeris databases and formulas are from the calculation
** routines in the program PLACALC and are programmed and Copyright (C)
** 1989,1991,1993 by Astrodienst AG and Alois Treindl ([email protected]). The
** use of that source code is subject to regulations made by Astrodienst
** Zurich, and the code is not in the public domain. This copyright notice
** must not be changed or removed by any user of this program.
**
** The original planetary calculation routines used in this program have
** been copyrighted and the initial core of this program was mostly a
** conversion to C of the routines created by James Neely as listed in
** 'Manual of Computer Programming for Astrologers', by Michael Erlewine,
** available from Matrix Software.
**
** The PostScript code within the core graphics routines are programmed
** and Copyright (C) 1992-1993 by Brian D. Willoughby ([email protected]).
**
** More formally: 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. This program is
** distributed in the hope that it will be useful and inspiring, but
** WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
** General Public License for more details, a copy of which is in the
** LICENSE.HTM file included with Astrolog, and at http://www.gnu.org
**
** Initial programming 8/28-30/1991.
** X Window graphics initially programmed 10/23-29/1991.
** PostScript graphics initially programmed 11/29-30/1992.
** Last code change made 7/22/2018.
*/
#include "astrolog.h"
#ifdef WIN
/*
******************************************************************************
** Dialog Utility Functions.
******************************************************************************
*/
/* Set the contents of the given edit control in a dialog to a string. */
void SetEditSz(HWND hdlg, int id, CONST char *sz)
{
while (*sz == ' ') /* Strip off any extra leading spaces. */
sz++;
SetEdit(id, sz);
}
/* Set the contents of the given edit control in a dialog to a floating */
/* point value, with at most 'n' significant fractional digits. */
void SetEditR(HWND hdlg, int id, real r, int n)
{
char sz[cchSzDef], szT[8], *pch;
sprintf(szT, "%%.%df", NAbs(n));
sprintf(sz, szT, r);
for (pch = sz; *pch; pch++)
;
while (pch > sz && *(--pch) == '0') /* Drop off any trailing 0 digits. */
;
/* Positive n means ensure at least one fractional digit. */
pch[n > 0 ? 1 + (*pch == '.') : (*pch != '.')] = chNull;
SetEdit(id, sz);
}
/* Set the contents of four combo controls and their dropdowns in a dialog */
/* indicating month, day, year, and time fields to the given values. */
void SetEditMDYT(HWND hdlg, int idMon, int idDay, int idYea, int idTim,
int mon, int day, int yea, real tim)
{
char sz[cchSzDef];
int i;
ClearCombo(idMon);
ClearCombo(idDay);
ClearCombo(idYea);
ClearCombo(idTim);
if (!FValidMon(mon))
mon = 1;
sprintf(sz, "%.3s", szMonth[mon]);
SetEdit(idMon, sz);
for (i = 1; i <= cSign; i++)
SetCombo(idMon, szMonth[i]);
if (!FValidDay(day, mon, yea))
day = 1;
SetEditN(idDay, day);
for (i = 0; i <= 25; i += 5) {
sprintf(sz, "%d", Max(i, 1)); SetCombo(idDay, sz);
}
SetEditN(idYea, yea);
for (i = 2010; i < 2020; i++) {
sprintf(sz, "%d", i); SetCombo(idYea, sz);
}
sprintf(sz, "%s", SzTim(tim));
SetEditSz(hdlg, idTim, sz);
SetCombo(idTim, "Midnight");
SetCombo(idTim, (char *)(us.fEuroTime ? "6:00" : "6:00am"));
SetCombo(idTim, "Noon");
SetCombo(idTim, (char *)(us.fEuroTime ? "18:00" : "6:00pm"));
}
/* Set the contents of four combo controls in a dialog indicating daylight, */
/* time zone, longitude, and latitude fields to the given values. */
void SetEditSZOA(HWND hdlg, int idDst, int idZon, int idLon, int idLat,
real dst, real zon, real lon, real lat)
{
char sz[cchSzDef];
int i;
flag fT;
ClearCombo(idDst);
ClearCombo(idZon);
ClearCombo(idLon);
ClearCombo(idLat);
if (dst == 0.0 || dst == 1.0 || dst == dstAuto)
sprintf(sz, "%s",
dst == 0.0 ? "No" : (dst == 1.0 ? "Yes" : "Autodetect"));
else
sprintf(sz, "%.2f", dst);
SetEdit(idDst, sz);
SetCombo(idDst, "No"); SetCombo(idDst, "Yes");
sprintf(sz, "%s", SzZone(zon));
SetEdit(idZon, (char *)(sz[0] == '+' ? &sz[1] : sz));
/* For the time zone dropdown, fill it out with all abbreviations of */
/* three letters that don't reference daylight or war time. */
for (i = 0; i < cZone; i++) {
if (szZon[i][1] && szZon[i][1] != 'D' && szZon[i][1] != 'W' &&
szZon[i][2] && szZon[i][2] != 'D')
SetCombo(idZon, szZon[i]);
}
fT = us.fAnsiChar; us.fAnsiChar = fFalse;
sprintf(sz, "%s", SzLocation(lon, lat));
us.fAnsiChar = fT;
i = 7 + is.fSeconds*3;
sz[i] = chNull;
SetEditSz(hdlg, idLon, &sz[0]);
SetCombo(idLon, "122W20"); SetCombo(idLon, "0E00");
SetEditSz(hdlg, idLat, &sz[i+1]);
SetCombo(idLat, "47N36"); SetCombo(idLat, "0S00");
}
/* Set the contents of a combo control in a dialog indicating a color */
/* field to the given value, and fill its dropdown with the color list. */
void SetEditColor(HWND hdlg, int id, KI ki, flag fExtra)
{
int i, iMax = cColor + fExtra*2;
SetEdit(id, szColor[ki]);
for (i = 0; i < iMax; i++)
SetCombo(id, szColor[i]);
}
/* Return the contents of a dialog edit control as a floating point value. */
real GetEditR(HWND hdlg, int id)
{
char sz[cchSzMax];
GetEdit(id, sz);
return atof(sz);
}
/* Bring up an error box indicating an illegal value for a dialog field. */
void ErrorEnsure(int n, CONST char *sz)
{
char szT[cchSzDef];
sprintf(szT, "The value %d is not a valid %s setting.", n, sz);
PrintWarning(szT);
}
/* Take many of the user visible settings, and write them out to a new */
/* command switch file, which may be read in to restore those settings. */
/* Most often this would be used to create a new astrolog.as default */
/* settings file. This is called from File \ Save Settings menu command. */
flag FOutputSettings()
{
char sz[cchSzDef];
FILE *file;
int i;
flag f1, f2;
if (us.fNoWrite)
return fFalse;
file = fopen(is.szFileOut, "w"); /* Create and open the file for output. */
if (file == NULL) {
sprintf(sz, "Settings file %s can not be created.", is.szFileOut);
PrintError(sz);
return fFalse;
}
sprintf(sz, "@0309 ; %s (%s) default settings file %s\n\n",
szAppName, szVersionCore, DEFAULT_INFOFILE); PrintFSz();
sprintf(sz, "-z %s ", SzZone(us.zonDef)); PrintFSz();
PrintF("; Default time zone [hours W or E of UTC ]\n");
if (us.dstDef != dstAuto)
sprintf(sz, "-z0 %d ", (int)us.dstDef);
else
sprintf(sz, "-z0 Autodetect ");
PrintFSz();
PrintF("; Default Daylight time [0 standard, 1 daylight]\n");
f1 = us.fAnsiChar; us.fAnsiChar = 3;
f2 = is.fSeconds; is.fSeconds = fTrue;
sprintf(sz, "-zl %s ", SzLocation(us.lonDef, us.latDef)); PrintFSz();
us.fAnsiChar = f1; is.fSeconds = f2;
PrintF("; Default location [longitude and latitude]\n");
sprintf(sz, "-zv %s ", SzElevation(us.elvDef)); PrintFSz();
PrintF("; Default elevation [in feet or meters ]\n");
sprintf(sz, "-zj \"%s\" \"%s\" ; Default name and location\n\n",
us.namDef, us.locDef); PrintFSz();
PrintF("-n "
"; Comment out this line to not start with chart for \"now\".\n");
sprintf(sz, "-Yz %ld ", us.lTimeAddition); PrintFSz();
PrintF(
"; Time minute addition to be used when \"now\" charts are off.\n\n");
sprintf(sz, "%cs ", ChDashF(us.fSidereal)); PrintFSz();
PrintF(
"; Zodiac selection [\"_s\" is tropical, \"=s\" is sidereal]\n");
sprintf(sz, ":s %.0f ", us.rZodiacOffset); PrintFSz();
PrintF(
"; Zodiac offset value [Change \"0\" to desired ayanamsa ]\n");
sprintf(sz, "-A %d ", us.nAsp); PrintFSz();
PrintF(
"; Number of aspects [Change \"5\" to desired number ]\n");
i = us.nHouseSystem; sprintf(sz, "-c %.4s ", i == hsEqualMC ?
rgSystem[1].sz : (i == hsSinewaveDelta ? rgSystem[3].sz : szSystem[i]));
PrintFSz();
PrintF(
"; House system [Change \"Plac\" to desired system ]\n");
sprintf(sz, "%cc3 ", ChDashF(us.fHouse3D)); PrintFSz();
PrintF(
"; 3D house boundaries [\"=c3\" is 3D houses, \"_c3\" is 2D ]\n");
sprintf(sz, "%ck ", ChDashF(us.fAnsiColor)); PrintFSz();
PrintF(
"; Ansi color text [\"=k\" is color, \"_k\" is monochrome ]\n");
sprintf(sz, ":d %d ", us.nDivision); PrintFSz();
PrintF(
"; Searching divisions [Change \"48\" to desired divisions ]\n");
sprintf(sz, "%cb0 ", ChDashF(us.fSeconds)); PrintFSz();
PrintF(
"; Print zodiac seconds [\"_b0\" to minute, \"=b0\" to second ]\n");
sprintf(sz, "%cb ", ChDashF(us.fEphemFiles)); PrintFSz();
PrintF(
"; Use ephemeris files [\"=b\" uses them, \"_b\" doesn't ]\n");
sprintf(sz, ":w %d ", us.nWheelRows); PrintFSz();
PrintF(
"; Wheel chart text rows [Change \"0\" to desired wheel rows ]\n");
sprintf(sz, ":I %d ", us.nScreenWidth); PrintFSz();
PrintF(
"; Text screen columns [Change \"80\" to desired columns ]\n");
sprintf(sz, "-YQ %d ", us.nScrollRow); PrintFSz();
PrintF(
"; Text screen scroll limit [Change \"24\" or set to \"0\" for none]\n");
sprintf(sz, "%cYd ", ChDashF(us.fEuroDate)); PrintFSz();
PrintF(
"; European date format [\"_Yd\" is MDY, \"=Yd\" is DMY ]\n");
sprintf(sz, "%cYt ", ChDashF(us.fEuroTime)); PrintFSz();
PrintF(
"; European time format [\"_Yt\" is AM/PM, \"=Yt\" is 24 hour ]\n");
sprintf(sz, "%cYv ", ChDashF(us.fEuroDist)); PrintFSz();
PrintF(
"; European length units [\"_Yv\" is imperial, \"=Yv\" is metric]\n");
sprintf(sz, "%cYr ", ChDashF(us.fRound)); PrintFSz();
PrintF(
"; Show rounded positions [\"=Yr\" rounds, \"_Yr\" doesn't ]\n");
sprintf(sz, "%cYC ", ChDashF(us.fSmartCusp)); PrintFSz();
PrintF(
"; Smart cusp displays [\"=YC\" is smart, \"_YC\" is normal ]\n");
sprintf(sz, "%cYO ", ChDashF(us.fSmartSave)); PrintFSz();
PrintF(
"; Smart copy and printing [\"=YO\" does it smart, \"_YO\" doesn't]\n");
sprintf(sz, "%cY8 ", ChDashF(us.fClip80)); PrintFSz();
PrintF(
"; Clip text to end of line [\"=Y8\" clips, \"_Y8\" doesn't clip ]\n");
PrintF("\n\n; DEFAULT RESTRICTIONS:\n\n-YR 0 10 ");
for (i = 0; i <= 10; i++) PrintF(SzNumF(ignore[i]));
PrintF(" ; Planets\n-YR 11 21 ");
for (i = 11; i <= 21; i++) PrintF(SzNumF(ignore[i]));
PrintF(" ; Minor planets\n-YR 22 33 ");
for (i = 22; i <= 33; i++) PrintF(SzNumF(ignore[i]));
PrintF(" ; House cusps\n-YR 34 42 ");
for (i = 34; i <= 42; i++) PrintF(SzNumF(ignore[i]));
PrintF(" ; Uranians\n\n");
PrintF("; DEFAULT TRANSIT RESTRICTIONS:\n\n-YRT 0 10 ");
for (i = 0; i <= 10; i++) PrintF(SzNumF(ignore2[i]));
PrintF(" ; Planets\n-YRT 11 21 ");
for (i = 11; i <= 21; i++) PrintF(SzNumF(ignore2[i]));
PrintF(" ; Minor planets\n-YRT 22 33 ");
for (i = 22; i <= 33; i++) PrintF(SzNumF(ignore2[i]));
PrintF(" ; House cusps\n-YRT 34 42 ");
for (i = 34; i <= 42; i++) PrintF(SzNumF(ignore2[i]));
PrintF(" ; Uranians\n\n");
sprintf(sz, "-YR0 %s%s ; Restrict sign, direction changes\n\n",
SzNumF(us.fIgnoreSign), SzNumF(us.fIgnoreDir)); PrintFSz();
PrintF("-YR7 ");
for (i = 0; i < 5; i++) PrintF(SzNumF(ignore7[i]));
PrintF(" ; Restrict rulerships: std, esoteric, hierarch, exalt, ray\n\n\n");
PrintF("; DEFAULT ASPECT ORBS:\n\n-YAo 1 5 ");
for (i = 1; i <= 5; i++) { sprintf(sz, " %.0f", rAspOrb[i]); PrintFSz(); }
PrintF(" ; Major aspects\n-YAo 6 11 ");
for (i = 6; i <= 11; i++) { sprintf(sz, " %.0f", rAspOrb[i]); PrintFSz(); }
PrintF(" ; Minor aspects\n-YAo 12 18 ");
for (i = 12; i <= 18; i++) { sprintf(sz, " %.0f", rAspOrb[i]); PrintFSz(); }
PrintF(" ; Obscure aspects\n\n");
PrintF("; DEFAULT MAX PLANET ASPECT ORBS:\n\n-YAm 0 10 ");
for (i = 0; i <= 10; i++) { sprintf(sz, "%4.0f", rObjOrb[i]); PrintFSz(); }
PrintF(" ; Planets\n-YAm 11 21 ");
for (i = 11; i <= 21; i++) { sprintf(sz, "%4.0f", rObjOrb[i]); PrintFSz(); }
PrintF(" ; Minor planets\n-YAm 22 33 ");
for (i = 22; i <= 33; i++) { sprintf(sz, "%4.0f", rObjOrb[i]); PrintFSz(); }
PrintF(" ; Cusp objects\n-YAm 34 42 ");
for (i = 34; i <= 42; i++) { sprintf(sz, "%4.0f", rObjOrb[i]); PrintFSz(); }
PrintF(" ; Uranians\n-YAm 43 43 ");
sprintf(sz, "%4.0f", rObjOrb[43]); PrintFSz();
PrintF(" ; Fixed stars\n");
PrintF("\n; DEFAULT PLANET ASPECT ORB ADDITIONS:\n\n-YAd 0 10 ");
for (i = 0; i <= 10; i++) { sprintf(sz, " %.0f", rObjAdd[i]); PrintFSz(); }
PrintF(" ; Planets\n-YAd 11 21 ");
for (i = 11; i <= 21; i++) { sprintf(sz, " %.0f", rObjAdd[i]); PrintFSz(); }
PrintF(" ; Minor planets\n-YAd 22 33 ");
for (i = 22; i <= 33; i++) { sprintf(sz, " %.0f", rObjAdd[i]); PrintFSz(); }
PrintF(" ; Cusp objects\n-YAd 34 42 ");
for (i = 34; i <= 42; i++) { sprintf(sz, " %.0f", rObjAdd[i]); PrintFSz(); }
PrintF(" ; Uranians\n-YAd 43 43 ");
sprintf(sz, " %.0f", rObjAdd[43]); PrintFSz();
PrintF(" ; Fixed stars\n\n\n");
PrintF("; DEFAULT INFLUENCES:\n\n-Yj 0 10 ");
for (i = 0; i <= 10; i++) { sprintf(sz, " %.0f", rObjInf[i]); PrintFSz(); }
PrintF(" ; Planets\n-Yj 11 21 ");
for (i = 11; i <= 21; i++) { sprintf(sz, " %.0f", rObjInf[i]); PrintFSz(); }
PrintF(" ; Minor planets\n-Yj 22 33 ");
for (i = 22; i <= 33; i++) { sprintf(sz, " %.0f", rObjInf[i]); PrintFSz(); }
PrintF(" ; Cusp objects\n-Yj 34 42 ");
for (i = 34; i <= 42; i++) { sprintf(sz, " %.0f", rObjInf[i]); PrintFSz(); }
PrintF(" ; Uranians\n-Yj 43 43 ");
sprintf(sz, "%.0f", rObjInf[43]); PrintFSz();
PrintF(" ; Fixed stars\n\n");
PrintF("-YjC 1 12 ");
for (i = 1; i <= cSign; i++)
{ sprintf(sz, " %.0f", rHouseInf[i]); PrintFSz(); }
PrintF(" ; Houses\n\n-YjA 1 5 ");
for (i = 1; i <= 5; i++) { sprintf(sz, "%4.1f", rAspInf[i]); PrintFSz(); }
PrintF(" ; Major aspects\n-YjA 6 11 ");
for (i = 6; i <= 11; i++) { sprintf(sz, "%4.1f", rAspInf[i]); PrintFSz(); }
PrintF(" ; Minor aspects\n-YjA 12 18 ");
for (i = 12; i <= 18; i++) { sprintf(sz, "%4.1f", rAspInf[i]); PrintFSz(); }
PrintF(" ; Obscure aspects\n\n");
PrintF("; DEFAULT TRANSIT INFLUENCES:\n\n-YjT 0 10 ");
for (i = 0; i <= 10; i++)
{ sprintf(sz, " %.0f", rTransitInf[i]); PrintFSz(); }
PrintF(" ; Planets\n-YjT 11 21 ");
for (i = 11; i <= 21; i++)
{ sprintf(sz, " %.0f", rTransitInf[i]); PrintFSz(); }
PrintF(" ; Minor planets\n-YjT 34 42 ");
for (i = 34; i <= 42; i++)
{ sprintf(sz, " %.0f", rTransitInf[i]); PrintFSz(); }
PrintF(" ; Uranians\n-YjT 43 43 ");
sprintf(sz, "%.0f", rTransitInf[43]); PrintFSz();
PrintF(" ; Fixed stars\n\n");
sprintf(sz, "-Yj0 %.0f %.0f %.0f %.0f ",
rObjInf[oNorm1 + 1], rObjInf[oNorm1 + 2], rHouseInf[cSign + 1],
rHouseInf[cSign + 2]); PrintFSz();
PrintF(" ; In ruling sign, exalted sign, ruling house, exalted house\n");
sprintf(sz, "-Yj7 %.0f %.0f %.0f %.0f %.0f %.0f ", rObjInf[oNorm1 + 3],
rObjInf[oNorm1 + 4], rObjInf[oNorm1 + 5], rHouseInf[cSign + 3],
rHouseInf[cSign + 4], rHouseInf[cSign + 5]); PrintFSz();
PrintF(" ; Esoteric, Hierarchical, Ray ruling - sign, house\n\n\n");
PrintF("; DEFAULT RAYS:\n\n-Y7C 1 12 ");
for (i = 1; i <= cSign; i++)
{ sprintf(sz, " %d", rgSignRay[i]); PrintFSz(); }
PrintF(" ; Signs\n-Y7O 0 10 ");
for (i = 0; i <= 10; i++)
{ sprintf(sz, " %d", rgObjRay[i]); PrintFSz(); }
PrintF(" ; Planets\n-Y7O 34 42 ");
for (i = 34; i <= 42; i++)
{ sprintf(sz, " %d", rgObjRay[i]); PrintFSz(); }
PrintF(" ; Uranians\n\n\n");
PrintF("; DEFAULT COLORS:\n\n-YkO 0 10 ");
for (i = 0; i <= 10; i++)
{ sprintf(sz, " %.3s", szColor[kObjU[i]]); PrintFSz(); }
PrintF(" ; Planet colors\n-YkO 11 21 ");
for (i = 11; i <= 21; i++)
{ sprintf(sz, " %.3s", szColor[kObjU[i]]); PrintFSz(); }
PrintF(" ; Minor colors\n-YkO 22 33 ");
for (i = 22; i <= 33; i++)
{ sprintf(sz, " %.3s", szColor[kObjU[i]]); PrintFSz(); }
PrintF(" ; Cusp colors\n-YkO 34 42 ");
for (i = 34; i <= 42; i++)
{ sprintf(sz, " %.3s", szColor[kObjU[i]]); PrintFSz(); }
PrintF(" ; Uranian colors\n\n-YkA 1 5 ");
for (i = 1; i <= 5; i++)
{ sprintf(sz, " %.3s", szColor[kAspA[i]]); PrintFSz(); }
PrintF(" ; Major aspect colors\n-YkA 6 11 ");
for (i = 6; i <= 11; i++)
{ sprintf(sz, " %.3s", szColor[kAspA[i]]); PrintFSz(); }
PrintF(" ; Minor aspect colors\n-YkA 12 18 ");
for (i = 12; i <= 18; i++)
{ sprintf(sz, " %.3s", szColor[kAspA[i]]); PrintFSz(); }
PrintF(" ; Obscure aspect colors\n\n-YkC ");
for (i = eFir; i <= eWat; i++)
{ sprintf(sz, " %.3s", szColor[kElemA[i]]); PrintFSz(); }
PrintF(" ; Element colors\n-Yk7 1 7 ");
for (i = 1; i <= cRay; i++)
{ sprintf(sz, " %.3s", szColor[kRayA[i]]); PrintFSz(); }
PrintF(" ; Ray colors\n-Yk0 1 7 ");
for (i = 1; i <= 7; i++)
{ sprintf(sz, " %.3s", szColor[kRainbowA[i]]); PrintFSz(); }
PrintF(" ; Rainbow colors\n-Yk 0 8 ");
for (i = 0; i <= 8; i++)
{ sprintf(sz, " %.3s", szColor[kMainA[i]]); PrintFSz(); }
PrintF(" ; Main colors\n\n\n");
PrintF("; GRAPHICS DEFAULTS:\n\n");
sprintf(sz, "%cXm ", ChDashF(gs.fColor)); PrintFSz();
PrintF("; Color charts [\"=Xm\" is color, \"_Xm\" is monochrome]\n");
sprintf(sz, "%cXr ", ChDashF(gs.fInverse)); PrintFSz();
PrintF("; Reverse background [\"_Xr\" is black, \"=Xr\" is white ]\n");
i = gs.xWin; if (fSidebar) i -= SIDESIZE;
sprintf(sz, ":Xw %d %d ", i, gs.yWin); PrintFSz();
PrintF("; Default X and Y resolution (not including sidebar)\n");
sprintf(sz, ":Xs %d ", gs.nScale); PrintFSz();
PrintF("; Character scale [100-400]\n");
sprintf(sz, ":XS %d ", gs.nScaleText); PrintFSz();
PrintF("; Graphics text scale [100-400]\n");
sprintf(sz, "%cXQ ", ChDashF(gs.fKeepSquare)); PrintFSz();
PrintF(
"; Square charts [\"=XQ\" forces square, \"_XQ\" allows rectangle]\n");
sprintf(sz, "%cXu ", ChDashF(gs.fBorder)); PrintFSz();
PrintF(
"; Chart border [\"=Xu\" shows border, \"_Xu\" doesn't show ]\n");
sprintf(sz, ":Xb%c ", ChUncap(gs.chBmpMode)); PrintFSz();
PrintF("; Bitmap file type\n");
sprintf(sz, ":YXG %d ", gs.nGlyphs); PrintFSz();
PrintF("; Glyph selections [Capricorn, Uranus, Pluto, Lilith]\n");
sprintf(sz, ":YXg %d ", gs.nGridCell); PrintFSz();
PrintF("; Aspect grid cells [\"0\" for autodetect ]\n");
sprintf(sz, ":YXS %.1f ", gs.rspace); PrintFSz();
PrintF("; Orbit radius in AU [\"0.0\" for autodetect]\n");
sprintf(sz, ":YXj %d ", gs.cspace, gs.zspace); PrintFSz();
PrintF("; Orbit trail count\n");
sprintf(sz, ":YX7 %d ", gs.nRayWidth); PrintFSz();
PrintF("; Esoteric ray column influence width\n");
sprintf(sz, ":YXf %d ", gs.fFont); PrintFSz();
PrintF("; Use actual fonts\n");
sprintf(sz, ":YXp %d ", gs.nOrient); PrintFSz();
PrintF(
"; PostScript paper orientation [\"-1\" portrait, \"1\" landscape]\n");
sprintf(sz, ":YXp0 %s ", SzLength(gs.xInch)); PrintFSz();
sprintf(sz, "%s ", SzLength(gs.yInch)); PrintFSz();
PrintF("; PostScript paper X and Y sizes\n\n");
sprintf(sz, "%cX ", ChDashF(us.fGraphics)); PrintFSz();
PrintF("; Graphics chart display [\"_X\" is text, \"=X\" is graphics]\n");
sprintf(sz, "\n; %s\n", DEFAULT_INFOFILE); PrintFSz();
fclose(file);
return fTrue;
}
/*
******************************************************************************
** Windows Dialogs.
******************************************************************************
*/
/* Bring up the Windows standard file open dialog, and process the */
/* command file specified if any. This is called from the File \ Open Chart */
/* and File \ Open Chart #2 menu commands. */
flag API DlgOpenChart()
{
char sz[cchSzDef];
CI ciT;
/* Setup dialog title and settings and get the name of a file from it. */
if (us.fNoRead) {
PrintWarning("File input is not allowed now.");
return fFalse;
}
sprintf(sz, "Open Chart #%d", wi.nDlgChart);
if (wi.nDlgChart < 2)
sz[10] = chNull;
ofn.lpstrTitle = sz;
ofn.lpstrFilter = "Astrolog Files (*.as)\0*.as\0All Files (*.*)\0*.*\0";
sprintf(szFileName, "*.as");
if (!GetOpenFileName((LPOPENFILENAME)&ofn))
return fFalse;
/* Process the given file based on what open command is being run. */
ciT = ciCore;
FInputData(ofn.lpstrFileTitle);
if (wi.nDlgChart > 1) {
if (wi.nDlgChart == 2)
ciTwin = ciCore;
else if (wi.nDlgChart == 3)
ciThre = ciCore;
else
ciFour = ciCore;
ciCore = ciT;
}
wi.fCast = fTrue;
return fTrue;
}
/* Bring up the Windows standard file save dialog, get the name of a file */
/* from the user, and save to it either right away or set variables to */
/* ensure it will be done later. This is called from all six File Save menu */
/* commands: Save Info, Positions, Text, Bitmap, Picture, and PostScript. */
flag API DlgSaveChart()
{
char *pch;
/* Setup dialog title and settings and get the name of a file from it. */
if (us.fNoWrite) {
PrintWarning("File output is not allowed now.");
return fFalse;
}
ofn.lpstrFilter = "Astrolog Files (*.as)\0*.as\0All Files (*.*)\0*.*\0";
ofn.lpstrDefExt = "as";
sprintf(szFileName, "*.as");
switch (wi.wCmd) {
case cmdSaveChart:
ofn.lpstrTitle = "Save Chart Info";
break;
case cmdSavePositions:
ofn.lpstrTitle = "Save Chart Positions";
break;
case cmdSaveText:
if (!us.fTextHTML) {
ofn.lpstrTitle = "Save Chart Text";
ofn.lpstrFilter = "Text Files (*.txt)\0*.txt\0All Files (*.*)\0*.*\0";
ofn.lpstrDefExt = "txt";
sprintf(szFileName, "*.txt");
} else {
ofn.lpstrTitle = "Save Chart HTML Text";
ofn.lpstrFilter = "HTML Files (*.htm)\0*.txt\0All Files (*.*)\0*.*\0";
ofn.lpstrDefExt = "htm";
sprintf(szFileName, "*.htm");
}
break;
case cmdSaveBitmap:
ofn.lpstrTitle = "Save Chart Bitmap";
ofn.lpstrFilter =
"Windows Bitmaps (*.bmp)\0*.bmp\0All Files (*.*)\0*.*\0";
ofn.lpstrDefExt = "bmp";
sprintf(szFileName, "*.bmp");
break;
case cmdSavePicture:
ofn.lpstrTitle = "Save Chart Picture";
ofn.lpstrFilter =
"Windows Metafiles (*.wmf)\0*.wmf\0All Files (*.*)\0*.*\0";
ofn.lpstrDefExt = "wmf";
sprintf(szFileName, "*.wmf");
break;
case cmdSavePS:
ofn.lpstrTitle = "Save Chart PostScript";
ofn.lpstrFilter =
"PostScript Text (*.eps)\0*.eps\0All Files (*.*)\0*.*\0";
ofn.lpstrDefExt = "eps";
sprintf(szFileName, "*.eps");
break;
case cmdSaveWire:
ofn.lpstrTitle = "Save Chart Wireframe";
ofn.lpstrFilter =
"Daedalus Wireframes (*.dw)\0*.dw\0All Files (*.*)\0*.*\0";
ofn.lpstrDefExt = "dw";
sprintf(szFileName, "*.dw");
break;
case cmdSaveSettings:
ofn.lpstrTitle = "Save Settings";
sprintf(szFileName, "%s", DEFAULT_INFOFILE);
break;
}
if (wi.wCmd != cmdSaveWallTile && wi.wCmd != cmdSaveWallCenter &&
wi.wCmd != cmdSaveWallStretch && wi.wCmd != cmdSaveWallFit &&
wi.wCmd != cmdSaveWallFill) {
if (!GetSaveFileName((LPOPENFILENAME)&ofn))
return fFalse;
} else {
ofn.lpstrFile = (char *)PAllocate(cchSzMax, NULL);
GetWindowsDirectory(ofn.lpstrFile, cchSzMax);
pch = ofn.lpstrFile + CchSz(ofn.lpstrFile);
sprintf(pch, "%c%s%s", '\\', szAppName, ".bmp");
}
/* Saving chart info, position, or setting command files can be done */
/* here. Saving actual chart output isn't done until the next redraw. */
is.szFileOut = gi.szFileOut = ofn.lpstrFile;
switch (wi.wCmd) {
case cmdSaveChart:
us.fWritePos = fFalse;
return FOutputData();
case cmdSavePositions:
us.fWritePos = fTrue;
return FOutputData();
case cmdSaveText:
is.szFileScreen = ofn.lpstrFile;
us.fGraphics = fFalse;
wi.fRedraw = fTrue;
break;
case cmdSaveBitmap:
case cmdSaveWallTile:
case cmdSaveWallCenter:
case cmdSaveWallStretch:
case cmdSaveWallFit:
case cmdSaveWallFill:
gs.fBitmap = fTrue;
gs.fMeta = gs.fPS = gs.fWire = fFalse;
us.fGraphics = wi.fRedraw = fTrue;
break;
case cmdSavePicture:
gs.fMeta = fTrue;
gs.fBitmap = gs.fPS = gs.fWire = fFalse;
us.fGraphics = wi.fRedraw = fTrue;
break;
case cmdSavePS:
gs.fPS = fTrue;
gs.fBitmap = gs.fMeta = gs.fWire = fFalse;
us.fGraphics = wi.fRedraw = fTrue;
break;
case cmdSaveWire:
gs.fWire = fTrue;
gs.fBitmap = gs.fMeta = gs.fPS = fFalse;
us.fGraphics = wi.fRedraw = fTrue;
break;
case cmdSaveSettings:
return FOutputSettings();
}
return fTrue;
}
/* Bring up the Windows standard print dialog, receive any printing */
/* settings from the user, and proceed to print the current graphics or */
/* text chart as displayed in the window. Called from File Print command. */
flag API DlgPrint()
{
DLGPROC lpAbortDlg;
ABORTPROC lpAbortProc;
HDC hdc;
LPDEVMODE lpDevMode = NULL;
LPDEVNAMES lpDevNames;
LPSTR lpszDriverName;
LPSTR lpszDeviceName;
LPSTR lpszPortName;
DOCINFO doci;
int xPrint, yPrint;
int xClient, yClient;
flag fInverse;
/* Bring up the Windows print dialog. */
wi.fNoUpdate = fFalse;
if (!PrintDlg((LPPRINTDLG)&prd))
return fTrue;
/* Get the printer DC. */
if (prd.hDC)
hdc = prd.hDC;
else {
/* If the dialog didn't just return the DC, try to make one manually. */
if (!prd.hDevNames)
return fFalse;
lpDevNames = (LPDEVNAMES)GlobalLock(prd.hDevNames);
lpszDriverName = (LPSTR)lpDevNames + lpDevNames->wDriverOffset;
lpszDeviceName = (LPSTR)lpDevNames + lpDevNames->wDeviceOffset;
lpszPortName = (LPSTR)lpDevNames + lpDevNames->wOutputOffset;
GlobalUnlock(prd.hDevNames);
if (prd.hDevMode)
lpDevMode = (LPDEVMODE)GlobalLock(prd.hDevMode);
hdc = CreateDC(lpszDriverName, lpszDeviceName, lpszPortName,
/*(LPSTR)*/lpDevMode);
if (prd.hDevMode && lpDevMode)
GlobalUnlock(prd.hDevMode);
}
if (prd.hDevNames) {
GlobalFree(prd.hDevNames);
prd.hDevNames = (HGLOBAL)NULL;
}
if (prd.hDevMode) {
GlobalFree(prd.hDevMode);
prd.hDevMode = (HGLOBAL)NULL;
}
/* Setup the abort dialog and start the print job. */
lpAbortDlg = (DLGPROC)MakeProcInstance((FARPROC)DlgAbort, wi.hinst);
lpAbortProc = (ABORTPROC)MakeProcInstance((FARPROC)DlgAbortProc, wi.hinst);
SetAbortProc(hdc, lpAbortProc);
doci.cbSize = sizeof(DOCINFO);
doci.lpszDocName = szAppName;
doci.lpszOutput = NULL;
if (StartDoc(hdc, &doci) < 0) {
FreeProcInstance(lpAbortDlg);
FreeProcInstance(lpAbortProc);
DeleteDC(hdc);
return fFalse;
}
wi.fAbort = FALSE;
wi.hwndAbort = CreateDialog(wi.hinst, MAKEINTRESOURCE(dlgAbort), wi.hwnd,
lpAbortDlg);
if (!wi.hwndAbort)
return fFalse;
ShowWindow(wi.hwndAbort, SW_NORMAL);
EnableWindow(wi.hwnd, fFalse);
StartPage(hdc);
/* Scale the chart to the page. */
if (us.fGraphics) {
gs.xWin *= METAMUL; gs.yWin *= METAMUL; gs.nScale *= METAMUL;
fInverse = gs.fInverse;
if (us.fSmartSave)
gs.fInverse = fTrue;
}
SetMapMode(hdc, MM_ANISOTROPIC); /* So SetViewportExt can be called */
xPrint = GetDeviceCaps(hdc, HORZRES);
yPrint = GetDeviceCaps(hdc, VERTRES);
SetViewportOrg(hdc, 0, 0);
SetViewportExt(hdc, xPrint, yPrint);
xClient = wi.xClient; yClient = wi.yClient;
wi.xClient = gs.xWin;
wi.yClient = NMultDiv(wi.xClient, yPrint, xPrint);
if (gs.yWin > wi.yClient) {
wi.yClient = gs.yWin;
wi.xClient = NMultDiv(wi.yClient, xPrint, yPrint);
}
wi.hdcPrint = hdc;
FRedraw(); /* Actually go "draw" the chart to the printer. */
/* Restore globals that were temporarily changed to print above. */
wi.hdcPrint = hdcNil;
wi.xClient = xClient; wi.yClient = yClient;
if (us.fGraphics) {
gs.xWin /= METAMUL; gs.yWin /= METAMUL; gs.nScale /= METAMUL;
gs.fInverse = fInverse;
}
/* Finalize and cleanup everything. */
if (!wi.fAbort) {
EndPage(hdc);
EndDoc(hdc);
}
EnableWindow(wi.hwnd, fTrue);
DestroyWindow(wi.hwndAbort);
FreeProcInstance(lpAbortDlg);
FreeProcInstance(lpAbortProc);
DeleteDC(hdc);
return fTrue;
}
/* Message loop function for the printing abort dialog. Loops until */
/* printing is completed or the user hits cancel, returning which result. */
flag API DlgAbortProc(HDC hdc, int nCode)
{
MSG msg;
if (wi.hwndAbort == (HWND)NULL)
return fTrue;
while (!wi.fAbort && PeekMessage(&msg, (HWND)NULL, 0, 0, PM_REMOVE))
if (!IsDialogMessage(wi.hwndAbort, &msg)) {
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return !wi.fAbort;
}
/* Processing function for the printing abort modeless dialog, as brought */
/* up temporarily when printing via the File \ Print menu command. */
BOOL API DlgAbort(HWND hdlg, uint message, WPARAM wParam, LPARAM lParam)
{
switch (message) {
case WM_INITDIALOG:
SetFocus(GetDlgItem(hdlg, IDCANCEL));
return fFalse;
case WM_COMMAND:
if (wParam == IDOK || wParam == IDCANCEL) {
wi.fAbort = fTrue;
EndDialog(hdlg, fTrue);
return fTrue;
}
break;
}
return fFalse;
}
/* Processing function for the command switch entry dialog, as brought up */
/* with the Edit \ Enter Command Line menu command. */
flag API DlgCommand(HWND hdlg, uint message, WORD wParam, LONG lParam)
{
char sz[cchSzMax];
switch (message) {
case WM_INITDIALOG:
SetFocus(GetDlgItem(hdlg, deCo));
return fFalse;
case WM_COMMAND:
if (wParam == IDOK) {
GetEdit(deCo, sz);
FProcessCommandLine(sz);
wi.fCast = wi.fMenuAll = fTrue;
}
if (wParam == IDOK || wParam == IDCANCEL) {
EndDialog(hdlg, fTrue);
return fTrue;
}
break;
}
return fFalse;
}
/* Processing function for the color customization dialog, as brought up */
/* with the View \ Set Colors menu command. */
flag API DlgColor(HWND hdlg, uint message, WORD wParam, LONG lParam)
{
char sz[cchSzMax];
int i, j, k, l;
switch (message) {
case WM_INITDIALOG:
for (i = 0; i < cColor; i++) {
j = ikPalette[i];
SetEditColor(hdlg, dck00 + i, j <= 0 ? kMainA[-j] : kRainbowA[j],
fFalse);
}
for (i = 0; i < cElem; i++)
SetEditColor(hdlg, dce0 + i, kElemA[i], fFalse);
for (i = 1; i <= cRay; i++)
SetEditColor(hdlg, dcr1 - 1 + i, kRayA[i], fFalse);
return fTrue;
case WM_COMMAND:
if (wParam == IDOK) {
for (k = 0; k <= 1; k++) {
for (i = 0; i < cColor; i++) {
GetEdit(dck00 + i, sz);
l = NParseSz(sz, pmColor);
if (k) {
j = ikPalette[i];
if (j <= 0)
kMainA[-j] = l;
else
kRainbowA[j] = l;
} else
EnsureN(l, FValidColor(l), "palette color");
}
for (i = 0; i < cElem; i++) {
GetEdit(dce0 + i, sz);
l = NParseSz(sz, pmColor);
if (k)
kElemA[i] = l;
else
EnsureN(l, FValidColor(l), "element color");
}
for (i = 1; i <= cRay; i++) {
GetEdit(dcr1 - 1 + i, sz);
l = NParseSz(sz, pmColor);
if (k)
kRayA[i] = l;
else
EnsureN(l, FValidColor(l), "aspect color");
}
}
wi.fRedraw = fTrue;
}
if (wParam == IDOK || wParam == IDCANCEL) {
EndDialog(hdlg, fTrue);
return fTrue;
}
break;
}
return fFalse;
}
/* Processing function for the chart info entry dialog, as brought up by */
/* both the Info \ Set Chart Info and Info \ Set Chart #2 menu commands. */
flag API DlgInfo(HWND hdlg, uint message, WORD wParam, LONG lParam)
{
CI ci;
char sz[cchSzMax];
switch (message) {
case WM_INITDIALOG:
if (wi.nDlgChart < 2)
ci = ciMain;
else {
sprintf(sz, "Enter Chart #%d Info", wi.nDlgChart);
SetWindowText(hdlg, sz);
if (wi.nDlgChart == 2)
ci = ciTwin;
else if (wi.nDlgChart == 3)
ci = ciThre;
else
ci = ciFour;
}
SetEditSz(hdlg, deInNam, ci.nam);
SetEditSz(hdlg, deInLoc, ci.loc);
LInit:
SetEditMDYT(hdlg, dcInMon, dcInDay, dcInYea, dcInTim,
ci.mon, ci.day, ci.yea, ci.tim);
SetEditSZOA(hdlg, dcInDst, dcInZon, dcInLon, dcInLat,
ci.dst, ci.zon, ci.lon, ci.lat);
SetFocus(GetDlgItem(hdlg, dcInMon));
return fFalse;
case WM_COMMAND:
if (wParam == dbInNow || wParam == dbInSet) {
#ifdef TIME
if (wParam == dbInNow) {
GetTimeNow(&ci.mon, &ci.day, &ci.yea, &ci.tim, us.dstDef, us.zonDef);
ci.dst = us.dstDef; ci.zon = us.zonDef;
ci.lon = us.lonDef; ci.lat = us.latDef;
} else
#endif
ci = ciSave;
goto LInit;
}
if (wParam == IDOK) {
GetEdit(dcInMon, sz); ci.mon = NParseSz(sz, pmMon);
GetEdit(dcInDay, sz); ci.day = NParseSz(sz, pmDay);
GetEdit(dcInYea, sz); ci.yea = NParseSz(sz, pmYea);
GetEdit(dcInTim, sz); ci.tim = RParseSz(sz, pmTim);
GetEdit(dcInDst, sz); ci.dst = RParseSz(sz, pmDst);
GetEdit(dcInZon, sz); ci.zon = RParseSz(sz, pmZon);
GetEdit(dcInLon, sz); ci.lon = RParseSz(sz, pmLon);
GetEdit(dcInLat, sz); ci.lat = RParseSz(sz, pmLat);
EnsureN(ci.mon, FValidMon(ci.mon), "month");
EnsureN(ci.yea, FValidYea(ci.yea), "year");
EnsureN(ci.day, FValidDay(ci.day, ci.mon, ci.yea), "day");
EnsureR(ci.tim, FValidTim(ci.tim), "time");
EnsureR(ci.dst, FValidZon(ci.dst), "daylight");
EnsureR(ci.zon, FValidZon(ci.zon), "zone");
EnsureR(ci.lon, FValidLon(ci.lon), "longitude");