FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
gnuplot-old/src/win/wgraph.c at gnuplot-4-4-alpha · gnuplot/gnuplot-old · GitHub
gnuplot
gnuplot-old
Repository navigation
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
gnuplot-old
/
src
/
win
/
wgraph.c
Copy path
More file actions
More file actions
Latest commit
History
History
History
2949 lines (2652 loc) · 82.3 KB
Breadcrumbs
gnuplot-old
/
src
/
win
/
wgraph.c
Copy path
File metadata and controls
2949 lines (2652 loc) · 82.3 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
#ifndef
lint
static
char
*
RCSid
() {
return
RCSid
(
"$Id: wgraph.c,v 1.67 2009/03/23 23:12:50 sfeam Exp $"
); }
#endif
/* GNUPLOT - win/wgraph.c */
/*[
* Copyright 1992, 1993, 1998, 2004 Maurice Castro, Russell Lang
*
* Permission to use, copy, and distribute this software and its
* documentation for any purpose with or without fee is hereby granted,
* provided that the above copyright notice appear in all copies and
* that both that copyright notice and this permission notice appear
* in supporting documentation.
*
* Permission to modify the software is granted, but not the right to
* distribute the complete modified source code. Modifications are to
* be distributed as patches to the released version. Permission to
* distribute binaries produced by compiling modified sources is granted,
* provided you
* 1. distribute the corresponding source modifications from the
* released version in the form of a patch file along with the binaries,
* 2. add special version identification to distinguish your version
* in addition to the base release version number,
* 3. provide your name and address as the primary contact for the
* support of your modified version, and
* 4. retain our contact information in regard to use of the base
* software.
* Permission to distribute the released version of the source code along
* with corresponding source modifications in the form of a patch file is
* granted with same provisions 2 through 4 for binary distributions.
*
* This software is provided "as is" without express or implied warranty
* to the extent permitted by applicable law.
]*/
/*
* AUTHORS
*
* Maurice Castro
* Russell Lang
*/
#define
STRICT
#include
<windows.h>
#include
<windowsx.h>
#if
WINVER
>=
0x030a
# include
<commdlg.h>
#endif
#ifndef
__MSC__
# include
<mem.h>
#endif
#include
<stdio.h>
#include
<string.h>
#include
"wgnuplib.h"
#include
"wresourc.h"
#include
"wcommon.h"
#include
"term_api.h"
/* for enum JUSTIFY */
#ifdef
USE_MOUSE
# include
"gpexecute.h"
# include
"mouse.h"
#endif
# include
"color.h"
# include
"getcolor.h"
#ifdef
USE_MOUSE
/* Petr Mikulik, February 2001
* Declarations similar to src/os2/gclient.c -- see section
* "PM: Now variables for mouse" there in.
*/
/* If wgnuplot crashes during redrawing and mouse on, then this could help: */
/* static char lock_mouse = 1; */
/* Status of the ruler */
static
struct
Ruler
{
TBOOLEAN
on
;
/* ruler active ? */
int
x
,
y
;
/* ruler position */
}
ruler
=
{FALSE,
0
,
0
,};
/* Status of the line from ruler to cursor */
static
struct
RulerLineTo
{
TBOOLEAN
on
;
/* ruler line active ? */
int
x
,
y
;
/* ruler line end position (previous cursor position) */
}
ruler_lineto
=
{FALSE,
0
,
0
,};
/* Status of zoom box */
static
struct
Zoombox
{
TBOOLEAN
on
;
/* set to TRUE during zooming */
POINT
from
,
to
;
/* corners of the zoom box */
LPCSTR
text1
,
text2
;
/* texts in the corners (i.e. positions) */
}
zoombox
=
{ FALSE, {
0
,
0
}, {
0
,
0
},
NULL
,
NULL
};
/* Pointer definitions */
HCURSOR
hptrDefault
,
hptrCrossHair
,
hptrScaling
,
hptrRotating
,
hptrZooming
,
hptrCurrent
;
/* Mouse support routines */
static
void
Wnd_exec_event
(
LPGW
lpgw
,
LPARAM
lparam
,
char
type
,
int
par1
);
static
void
Wnd_refresh_zoombox
(
LPGW
lpgw
,
LPARAM
lParam
);
static
void
Wnd_refresh_ruler_lineto
(
LPGW
lpgw
,
LPARAM
lParam
);
static
void
GetMousePosViewport
(
LPGW
lpgw
,
int
*
mx
,
int
*
my
);
static
void
Draw_XOR_Text
(
LPGW
lpgw
,
const
char
*
text
,
size_t
length
,
int
x
,
int
y
);
static
void
DisplayStatusLine
(
LPGW
lpgw
);
static
void
UpdateStatusLine
(
LPGW
lpgw
,
const
char
text
[]);
static
void
DrawRuler
(
LPGW
lpgw
);
static
void
DrawRulerLineTo
(
LPGW
lpgw
);
static
void
DrawZoomBox
(
LPGW
lpgw
);
static
void
LoadCursors
(
LPGW
lpgw
);
static
void
DestroyCursors
(
LPGW
lpgw
);
#endif
/* USE_MOUSE */
/* ================================== */
#define
MAXSTR
255
#define
WGDEFCOLOR
15
COLORREF
wginitcolor
[
WGDEFCOLOR
]
=
{
RGB
(
255
,
0
,
0
),
/* red */
RGB
(
0
,
255
,
0
),
/* green */
RGB
(
0
,
0
,
255
),
/* blue */
RGB
(
255
,
0
,
255
),
/* magenta */
RGB
(
0
,
0
,
128
),
/* dark blue */
RGB
(
128
,
0
,
0
),
/* dark red */
RGB
(
0
,
128
,
128
),
/* dark cyan */
RGB
(
0
,
0
,
0
),
/* black */
RGB
(
128
,
128
,
128
),
/* grey */
RGB
(
0
,
128
,
64
),
/* very dark cyan */
RGB
(
128
,
128
,
0
),
/* dark yellow */
RGB
(
128
,
0
,
128
),
/* dark magenta */
RGB
(
192
,
192
,
192
),
/* light grey */
RGB
(
0
,
255
,
255
),
/* cyan */
RGB
(
255
,
255
,
0
),
/* yellow */
};
#define
WGDEFSTYLE
5
int
wginitstyle
[
WGDEFSTYLE
]
=
{
PS_SOLID
,
PS_DASH
,
PS_DOT
,
PS_DASHDOT
,
PS_DASHDOTDOT
};
/* Maximum number of GWOPBLK arrays to be remembered. */
/* HBB 20010218: moved here from wgnuplib.h: other parts of the program don't
* need to know about it */
#define
GWOPMAX
4096
/* bitmaps for filled boxes (ULIG) */
/* zeros represent the foreground color and ones represent the background color */
/* FIXME HBB 20010916: *never* extern in a C source! */
/* extern int filldensity; */
/* extern int fillpattern; */
static
unsigned
char
halftone_bitmaps
[][
16
]
=
{
{
0xFF
,
0xFF
,
0xFF
,
0xFF
,
0xFF
,
0xFF
,
0xFF
,
0xFF
,
0xFF
,
0xFF
,
0xFF
,
0xFF
,
0xFF
,
0xFF
,
0xFF
,
0xFF
},
/* no fill */
{
0xEE
,
0xEE
,
0xBB
,
0xBB
,
0xEE
,
0xEE
,
0xBB
,
0xBB
,
0xEE
,
0xEE
,
0xBB
,
0xBB
,
0xEE
,
0xEE
,
0xBB
,
0xBB
},
/* 25% pattern */
{
0xAA
,
0xAA
,
0x55
,
0x55
,
0xAA
,
0xAA
,
0x55
,
0x55
,
0xAA
,
0xAA
,
0x55
,
0x55
,
0xAA
,
0xAA
,
0x55
,
0x55
},
/* 50% pattern */
{
0x88
,
0x88
,
0x22
,
0x22
,
0x88
,
0x88
,
0x22
,
0x22
,
0x88
,
0x88
,
0x22
,
0x22
,
0x88
,
0x88
,
0x22
,
0x22
},
/* 75% pattern */
{
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
}
/* solid pattern */
};
#define
halftone_num
(sizeof(halftone_bitmaps) / sizeof (*halftone_bitmaps))
static
HBRUSH
halftone_brush
[
halftone_num
];
static
BITMAP
halftone_bitdata
[
halftone_num
];
static
HBITMAP
halftone_bitmap
[
halftone_num
];
static
unsigned
char
pattern_bitmaps
[][
16
]
=
{
{
0xFF
,
0xFF
,
0xFF
,
0xFF
,
0xFF
,
0xFF
,
0xFF
,
0xFF
,
0xFF
,
0xFF
,
0xFF
,
0xFF
,
0xFF
,
0xFF
,
0xFF
,
0xFF
},
/* no fill */
{
0xFE
,
0xFE
,
0x7D
,
0x7D
,
0xBB
,
0xBB
,
0xD7
,
0xD7
,
0xEF
,
0xEF
,
0xD7
,
0xD7
,
0xBB
,
0xBB
,
0x7D
,
0x7D
},
/* cross-hatch (1) */
{
0x77
,
0x77
,
0xBB
,
0xBB
,
0xDD
,
0xDD
,
0xBB
,
0xBB
,
0x77
,
0x77
,
0xBB
,
0xBB
,
0xDD
,
0xDD
,
0xBB
,
0xBB
},
/* double cross-hatch (2) */
{
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
},
/* solid fill (3) */
{
0xFE
,
0xFE
,
0xFD
,
0xFD
,
0xFB
,
0xFB
,
0xF7
,
0xF7
,
0xEF
,
0xEF
,
0xDF
,
0xDF
,
0xBF
,
0xBF
,
0x7F
,
0x7F
},
/* diagonals (4) */
{
0x7F
,
0x7F
,
0xBF
,
0xBF
,
0xDF
,
0xDF
,
0xEF
,
0xEF
,
0xF7
,
0xF7
,
0xFB
,
0xFB
,
0xFD
,
0xFD
,
0xFE
,
0xFE
},
/* diagonals (5) */
{
0xEE
,
0xEE
,
0xEE
,
0xEE
,
0xDD
,
0xDD
,
0xDD
,
0xDD
,
0xBB
,
0xBB
,
0xBB
,
0xBB
,
0x77
,
0x77
,
0x77
,
0x77
},
/* steep diagonals (6) */
{
0x77
,
0x77
,
0x77
,
0x77
,
0xBB
,
0xBB
,
0xBB
,
0xBB
,
0xDD
,
0xDD
,
0xDD
,
0xDD
,
0xEE
,
0xEE
,
0xEE
,
0xEE
}
/* steep diagonals (7) */
#if
(
0
)
,{
0xFC
,
0xFC
,
0xF3
,
0xF3
,
0xCF
,
0xCF
,
0x3F
,
0x3F
,
0xFC
,
0xFC
,
0xF3
,
0xF3
,
0xCF
,
0xCF
,
0x3F
,
0x3F
},
/* shallow diagonals (old 5) */
{
0x3F
,
0x3F
,
0xCF
,
0xCF
,
0xF3
,
0xF3
,
0xFC
,
0xFC
,
0x3F
,
0x3F
,
0xCF
,
0xCF
,
0xF3
,
0xF3
,
0xFC
,
0xFC
}
/* shallow diagonals (old 6) */
#endif
};
#define
pattern_num
(sizeof(pattern_bitmaps)/(sizeof(*pattern_bitmaps)))
static
HBRUSH
pattern_brush
[
pattern_num
];
static
BITMAP
pattern_bitdata
[
pattern_num
];
static
HBITMAP
pattern_bitmap
[
pattern_num
];
static
TBOOLEAN
brushes_initialized
=
FALSE;
/* ================================== */
/* prototypes for module-local functions */
LRESULT
CALLBACK
WINEXPORT
WndGraphProc
(
HWND
hwnd
,
UINT
message
,
WPARAM
wParam
,
LPARAM
lParam
);
BOOL
CALLBACK
WINEXPORT
LineStyleDlgProc
(
HWND
hdlg
,
UINT
wmsg
,
WPARAM
wparam
,
LPARAM
lparam
);
static
void
DestroyBlocks
(
LPGW
lpgw
);
static
BOOL
AddBlock
(
LPGW
lpgw
);
static
void
StorePen
(
LPGW
lpgw
,
int
i
,
COLORREF
ref
,
int
colorstyle
,
int
monostyle
);
static
void
MakePens
(
LPGW
lpgw
,
HDC
hdc
);
static
void
DestroyPens
(
LPGW
lpgw
);
static
void
Wnd_GetTextSize
(
HDC
hdc
,
LPCSTR
str
,
size_t
len
,
int
*
cx
,
int
*
cy
);
static
void
MakeFonts
(
LPGW
lpgw
,
LPRECT
lprect
,
HDC
hdc
);
static
void
DestroyFonts
(
LPGW
lpgw
);
static
void
SetFont
(
LPGW
lpgw
,
HDC
hdc
);
static
void
SelFont
(
LPGW
lpgw
);
static
void
dot
(
HDC
hdc
,
int
xdash
,
int
ydash
);
static
void
drawgraph
(
LPGW
lpgw
,
HDC
hdc
,
LPRECT
rect
);
static
void
CopyClip
(
LPGW
lpgw
);
static
void
CopyPrint
(
LPGW
lpgw
);
static
void
WriteGraphIni
(
LPGW
lpgw
);
static
void
ReadGraphIni
(
LPGW
lpgw
);
static
COLORREF
GetColor
(
HWND
hwnd
,
COLORREF
ref
);
static
void
UpdateColorSample
(
HWND
hdlg
);
static
BOOL
LineStyle
(
LPGW
lpgw
);
/* ================================== */
/* Helper functions for GraphOp(): */
/* destroy memory blocks holding graph operations */
static
void
DestroyBlocks
(
LPGW
lpgw
)
{
struct
GWOPBLK
*
this
,
*
next
;
struct
GWOP
FAR
*
gwop
;
unsigned
int
i
;
this
=
lpgw
->
gwopblk_head
;
while
(
this
!=
NULL
) {
next
=
this
->
next
;
if
(!
this
->
gwop
) {
this
->
gwop
=
(
struct
GWOP
FAR
*
)
GlobalLock
(
this
->
hblk
);
}
if
(
this
->
gwop
) {
/* free all text strings within this block */
gwop
=
this
->
gwop
;
for
(
i
=
0
;
i
<
GWOPMAX
;
i
++
) {
if
(
gwop
->
htext
)
LocalFree
(
gwop
->
htext
);
gwop
++
;
}
}
GlobalUnlock
(
this
->
hblk
);
GlobalFree
(
this
->
hblk
);
LocalFreePtr
(
this
);
this
=
next
;
}
lpgw
->
gwopblk_head
=
NULL
;
lpgw
->
gwopblk_tail
=
NULL
;
lpgw
->
nGWOP
=
0
;
}
/* add a new memory block for graph operations */
/* returns TRUE if block allocated */
static
BOOL
AddBlock
(
LPGW
lpgw
)
{
HGLOBAL
hblk
;
struct
GWOPBLK
*
next
,
*
this
;
/* create new block */
next
=
(
struct
GWOPBLK
*
)
LocalAllocPtr
(
LHND
,
sizeof
(
struct
GWOPBLK
) );
if
(
next
==
NULL
)
return
FALSE;
hblk
=
GlobalAlloc
(
GHND
,
GWOPMAX
*
sizeof
(
struct
GWOP
));
if
(
hblk
==
NULL
)
return
FALSE;
next
->
hblk
=
hblk
;
next
->
gwop
=
(
struct
GWOP
FAR
*
)
NULL
;
next
->
next
=
(
struct
GWOPBLK
*
)
NULL
;
next
->
used
=
0
;
/* attach it to list */
this
=
lpgw
->
gwopblk_tail
;
if
(
this
==
NULL
) {
lpgw
->
gwopblk_head
=
next
;
}
else
{
this
->
next
=
next
;
this
->
gwop
=
(
struct
GWOP
FAR
*
)
NULL
;
GlobalUnlock
(
this
->
hblk
);
}
lpgw
->
gwopblk_tail
=
next
;
next
->
gwop
=
(
struct
GWOP
FAR
*
)
GlobalLock
(
next
->
hblk
);
if
(
next
->
gwop
==
(
struct
GWOP
FAR
*
)
NULL
)
return
FALSE;
return
TRUE;
}
void
WDPROC
GraphOp
(
LPGW
lpgw
,
WORD
op
,
WORD
x
,
WORD
y
,
LPCSTR
str
)
{
if
(
str
)
GraphOpSize
(
lpgw
,
op
,
x
,
y
,
str
,
_fstrlen
(
str
)
+
1
);
else
GraphOpSize
(
lpgw
,
op
,
x
,
y
,
NULL
,
0
);
}
void
WDPROC
GraphOpSize
(
LPGW
lpgw
,
WORD
op
,
WORD
x
,
WORD
y
,
LPCSTR
str
,
DWORD
size
)
{
struct
GWOPBLK
*
this
;
struct
GWOP
FAR
*
gwop
;
char
*
npstr
;
this
=
lpgw
->
gwopblk_tail
;
if
( (
this
==
NULL
)
||
(
this
->
used
>=
GWOPMAX
) ) {
/* not enough space so get new block */
if
(!
AddBlock
(
lpgw
))
return
;
this
=
lpgw
->
gwopblk_tail
;
}
gwop
=
&
this
->
gwop
[
this
->
used
];
gwop
->
op
=
op
;
gwop
->
x
=
x
;
gwop
->
y
=
y
;
gwop
->
htext
=
0
;
if
(
str
) {
gwop
->
htext
=
LocalAlloc
(
LHND
,
size
);
npstr
=
LocalLock
(
gwop
->
htext
);
if
(
gwop
->
htext
&&
(
npstr
!=
(
char
*
)
NULL
))
memcpy
(
npstr
,
str
,
size
);
LocalUnlock
(
gwop
->
htext
);
}
this
->
used
++
;
lpgw
->
nGWOP
++
;
return
;
}
/* ================================== */
/* Prepare Graph window for being displayed by windows, read wgnuplot.ini, update
* the window's menus and show it */
void
WDPROC
GraphInit
(
LPGW
lpgw
)
{
HMENU
sysmenu
;
WNDCLASS
wndclass
;
char
buf
[
MAX_PATH
];
HDC
hdc
;
TEXTMETRIC
metric
;
if
(!
lpgw
->
hPrevInstance
) {
wndclass
.
style
=
CS_HREDRAW
|
CS_VREDRAW
;
wndclass
.
lpfnWndProc
=
WndGraphProc
;
wndclass
.
cbClsExtra
=
0
;
wndclass
.
cbWndExtra
=
2
*
sizeof
(
void
FAR
*
);
wndclass
.
hInstance
=
lpgw
->
hInstance
;
wndclass
.
hIcon
=
LoadIcon
(
NULL
,
IDI_APPLICATION
);
wndclass
.
hCursor
=
LoadCursor
(
NULL
,
IDC_ARROW
);
wndclass
.
hbrBackground
=
(
HBRUSH
)
GetStockObject
(
WHITE_BRUSH
);
wndclass
.
lpszMenuName
=
NULL
;
wndclass
.
lpszClassName
=
szGraphClass
;
RegisterClass
(
&
wndclass
);
}
ReadGraphIni
(
lpgw
);
lpgw
->
hWndGraph
=
CreateWindow
(
szGraphClass
,
lpgw
->
Title
,
WS_OVERLAPPEDWINDOW
,
lpgw
->
Origin
.
x
,
lpgw
->
Origin
.
y
,
lpgw
->
Size
.
x
,
lpgw
->
Size
.
y
,
NULL
,
NULL
,
lpgw
->
hInstance
,
lpgw
);
/* determine height of status line */
hdc
=
GetDC
(
lpgw
->
hWndGraph
);
GetTextMetrics
(
hdc
,
&
metric
);
lpgw
->
statuslineheight
=
metric
.
tmHeight
*
1.2
;
ReleaseDC
(
lpgw
->
hWndGraph
,
hdc
);
lpgw
->
hPopMenu
=
CreatePopupMenu
();
AppendMenu
(
lpgw
->
hPopMenu
,
MF_STRING
| (
lpgw
->
graphtotop
?
MF_CHECKED
:
MF_UNCHECKED
),
M_GRAPH_TO_TOP
,
"Bring to &Top"
);
AppendMenu
(
lpgw
->
hPopMenu
,
MF_STRING
| (
lpgw
->
color
?
MF_CHECKED
:
MF_UNCHECKED
),
M_COLOR
,
"C&olor"
);
AppendMenu
(
lpgw
->
hPopMenu
,
MF_STRING
,
M_COPY_CLIP
,
"&Copy to Clipboard"
);
#if
WINVER
>=
0x030a
AppendMenu
(
lpgw
->
hPopMenu
,
MF_STRING
,
M_BACKGROUND
,
"&Background..."
);
AppendMenu
(
lpgw
->
hPopMenu
,
MF_STRING
,
M_CHOOSE_FONT
,
"Choose &Font..."
);
AppendMenu
(
lpgw
->
hPopMenu
,
MF_STRING
,
M_LINESTYLE
,
"&Line Styles..."
);
#endif
AppendMenu
(
lpgw
->
hPopMenu
,
MF_STRING
,
M_PRINT
,
"&Print..."
);
if
(
lpgw
->
IniFile
!=
(
LPSTR
)
NULL
) {
wsprintf
(
buf
,
"&Update %s"
,
lpgw
->
IniFile
);
AppendMenu
(
lpgw
->
hPopMenu
,
MF_STRING
,
M_WRITEINI
, (
LPSTR
)
buf
);
}
/* modify the system menu to have the new items we want */
sysmenu
=
GetSystemMenu
(
lpgw
->
hWndGraph
,
0
);
AppendMenu
(
sysmenu
,
MF_SEPARATOR
,
0
,
NULL
);
AppendMenu
(
sysmenu
,
MF_POPUP
, (
UINT
)
lpgw
->
hPopMenu
,
"&Options"
);
AppendMenu
(
sysmenu
,
MF_STRING
,
M_ABOUT
,
"&About"
);
if
(!
IsWindowVisible
(
lpgw
->
lptw
->
hWndParent
)) {
AppendMenu
(
sysmenu
,
MF_SEPARATOR
,
0
,
NULL
);
AppendMenu
(
sysmenu
,
MF_STRING
,
M_COMMANDLINE
,
"C&ommand Line"
);
}
ShowWindow
(
lpgw
->
hWndGraph
,
SW_SHOWNORMAL
);
}
/* close a graph window */
void
WDPROC
GraphClose
(
LPGW
lpgw
)
{
/* Pass it through mouse handling to check for "bind Close" */
Wnd_exec_event
(
lpgw
, (
LPARAM
)
0
,
GE_reset
,
0
);
/* close window */
if
(
lpgw
->
hWndGraph
)
DestroyWindow
(
lpgw
->
hWndGraph
);
#ifndef
WGP_CONSOLE
TextMessage
();
#endif
lpgw
->
hWndGraph
=
NULL
;
lpgw
->
locked
=
TRUE;
DestroyBlocks
(
lpgw
);
lpgw
->
locked
=
FALSE;
}
void
WDPROC
GraphStart
(
LPGW
lpgw
,
double
pointsize
)
{
lpgw
->
locked
=
TRUE;
DestroyBlocks
(
lpgw
);
lpgw
->
org_pointsize
=
pointsize
;
if
( !
lpgw
->
hWndGraph
||
!
IsWindow
(
lpgw
->
hWndGraph
) )
GraphInit
(
lpgw
);
if
(
IsIconic
(
lpgw
->
hWndGraph
))
ShowWindow
(
lpgw
->
hWndGraph
,
SW_SHOWNORMAL
);
if
(
lpgw
->
graphtotop
) {
/* HBB NEW 20040221: avoid grabbing the keyboard focus
* unless mouse mode is on */
#ifdef
USE_MOUSE
if
(
mouse_setting
.
on
) {
BringWindowToTop
(
lpgw
->
hWndGraph
);
return
;
}
#endif
/* USE_MOUSE */
SetWindowPos
(
lpgw
->
hWndGraph
,
HWND_TOP
,
0
,
0
,
0
,
0
,
SWP_NOACTIVATE
|
SWP_NOMOVE
|
SWP_NOSIZE
);
}
}
void
WDPROC
GraphEnd
(
LPGW
lpgw
)
{
RECT
rect
;
GetClientRect
(
lpgw
->
hWndGraph
,
&
rect
);
InvalidateRect
(
lpgw
->
hWndGraph
, (
LPRECT
)
&
rect
,
1
);
lpgw
->
locked
=
FALSE;
UpdateWindow
(
lpgw
->
hWndGraph
);
#ifdef
USE_MOUSE
gp_exec_event
(
GE_plotdone
,
0
,
0
,
0
,
0
,
0
);
/* notify main program */
#endif
}
/* shige */
void
WDPROC
GraphChangeTitle
(
LPGW
lpgw
)
{
SetWindowText
(
lpgw
->
hWndGraph
,
lpgw
->
Title
);
}
void
WDPROC
GraphResume
(
LPGW
lpgw
)
{
lpgw
->
locked
=
TRUE;
}
void
WDPROC
GraphPrint
(
LPGW
lpgw
)
{
if
(
lpgw
->
hWndGraph
&&
IsWindow
(
lpgw
->
hWndGraph
))
SendMessage
(
lpgw
->
hWndGraph
,
WM_COMMAND
,
M_PRINT
,
0L
);
}
void
WDPROC
GraphRedraw
(
LPGW
lpgw
)
{
if
(
lpgw
->
hWndGraph
&&
IsWindow
(
lpgw
->
hWndGraph
))
SendMessage
(
lpgw
->
hWndGraph
,
WM_COMMAND
,
M_REBUILDTOOLS
,
0L
);
}
/* ================================== */
/* Helper functions for bookkeeping of pens, brushes and fonts */
/* Set up LOGPEN structures based on information coming from wgnuplot.ini, via
* ReadGraphIni() */
static
void
StorePen
(
LPGW
lpgw
,
int
i
,
COLORREF
ref
,
int
colorstyle
,
int
monostyle
)
{
LOGPEN
FAR
*
plp
;
plp
=
&
lpgw
->
colorpen
[
i
];
plp
->
lopnColor
=
ref
;
if
(
colorstyle
<
0
) {
plp
->
lopnWidth
.
x
=
-
colorstyle
;
plp
->
lopnStyle
=
0
;
}
else
{
plp
->
lopnWidth
.
x
=
1
;
plp
->
lopnStyle
=
colorstyle
%
5
;
}
plp
->
lopnWidth
.
y
=
0
;
plp
=
&
lpgw
->
monopen
[
i
];
plp
->
lopnColor
=
RGB
(
0
,
0
,
0
);
if
(
monostyle
<
0
) {
plp
->
lopnWidth
.
x
=
-
monostyle
;
plp
->
lopnStyle
=
0
;
}
else
{
plp
->
lopnWidth
.
x
=
1
;
plp
->
lopnStyle
=
monostyle
%
5
;
}
plp
->
lopnWidth
.
y
=
0
;
}
/* Prepare pens and brushes (--> colors) for use by the driver. Pens are (now) created
* on-the-fly (--> DeleteObject(SelectObject(...)) idiom), but the brushes are still
* all created statically, and kept until the window is closed */
static
void
MakePens
(
LPGW
lpgw
,
HDC
hdc
)
{
int
i
;
if
((
GetDeviceCaps
(
hdc
,
NUMCOLORS
)
==
2
)
||
!
lpgw
->
color
) {
lpgw
->
hapen
=
CreatePenIndirect
((
LOGPEN
FAR
*
)
&
lpgw
->
monopen
[
1
]);
/* axis */
lpgw
->
hbrush
=
CreateSolidBrush
(
RGB
(
255
,
255
,
255
));
for
(
i
=
0
;
i
<
WGNUMPENS
+
2
;
i
++
)
lpgw
->
colorbrush
[
i
]
=
CreateSolidBrush
(
RGB
(
0
,
0
,
0
));
}
else
{
lpgw
->
hapen
=
CreatePenIndirect
((
LOGPEN
FAR
*
)
&
lpgw
->
colorpen
[
1
]);
/* axis */
lpgw
->
hbrush
=
CreateSolidBrush
(
lpgw
->
background
);
for
(
i
=
0
;
i
<
WGNUMPENS
+
2
;
i
++
)
lpgw
->
colorbrush
[
i
]
=
CreateSolidBrush
(
lpgw
->
colorpen
[
i
].
lopnColor
);
}
/* build pattern brushes for filled boxes (ULIG) */
if
( !
brushes_initialized
) {
int
i
;
for
(
i
=
0
;
i
<
halftone_num
;
i
++
) {
halftone_bitdata
[
i
].
bmType
=
0
;
halftone_bitdata
[
i
].
bmWidth
=
16
;
halftone_bitdata
[
i
].
bmHeight
=
8
;
halftone_bitdata
[
i
].
bmWidthBytes
=
2
;
halftone_bitdata
[
i
].
bmPlanes
=
1
;
halftone_bitdata
[
i
].
bmBitsPixel
=
1
;
halftone_bitdata
[
i
].
bmBits
=
halftone_bitmaps
[
i
];
halftone_bitmap
[
i
]
=
CreateBitmapIndirect
(
&
halftone_bitdata
[
i
]);
halftone_brush
[
i
]
=
CreatePatternBrush
(
halftone_bitmap
[
i
]);
}
for
(
i
=
0
;
i
<
pattern_num
;
i
++
) {
pattern_bitdata
[
i
].
bmType
=
0
;
pattern_bitdata
[
i
].
bmWidth
=
16
;
pattern_bitdata
[
i
].
bmHeight
=
8
;
pattern_bitdata
[
i
].
bmWidthBytes
=
2
;
pattern_bitdata
[
i
].
bmPlanes
=
1
;
pattern_bitdata
[
i
].
bmBitsPixel
=
1
;
pattern_bitdata
[
i
].
bmBits
=
pattern_bitmaps
[
i
];
pattern_bitmap
[
i
]
=
CreateBitmapIndirect
(
&
pattern_bitdata
[
i
]);
pattern_brush
[
i
]
=
CreatePatternBrush
(
pattern_bitmap
[
i
]);
}
brushes_initialized
=
TRUE;
}
}
/* Undo effect of MakePens(). To be called just before the window is closed. */
static
void
DestroyPens
(
LPGW
lpgw
)
{
int
i
;
DeleteObject
(
lpgw
->
hbrush
);
DeleteObject
(
lpgw
->
hapen
);
for
(
i
=
0
;
i
<
WGNUMPENS
+
2
;
i
++
)
DeleteObject
(
lpgw
->
colorbrush
[
i
]);
/* delete brushes used for boxfilling (ULIG) */
if
(
brushes_initialized
) {
int
i
;
for
(
i
=
0
;
i
<
halftone_num
;
i
++
) {
DeleteObject
(
halftone_bitmap
[
i
]);
DeleteObject
(
halftone_brush
[
i
]);
}
for
(
i
=
0
;
i
<
pattern_num
;
i
++
) {
DeleteObject
(
pattern_bitmap
[
i
]);
DeleteObject
(
pattern_brush
[
i
]);
}
brushes_initialized
=
FALSE;
}
}
/* ================================== */
/* HBB 20010218: new function. An isolated snippet from MakeFont(), now also
* used in Wnd_put_tmptext() to size the temporary bitmap. */
static
void
Wnd_GetTextSize
(
HDC
hdc
,
LPCSTR
str
,
size_t
len
,
int
*
cx
,
int
*
cy
)
{
#ifdef
WIN32
SIZE
size
;
GetTextExtentPoint
(
hdc
,
str
,
len
,
&
size
);
*
cx
=
size
.
cx
;
*
cy
=
size
.
cy
;
#else
/* Hmm... if not for compatibility to Win 3.0 and earlier, we could
* use GetTextExtentPoint on Win16, too :-( */
DWORD
extent
;
extent
=
GetTextExtent
(
hdc
,
str
,
len
);
*
cx
=
LOWORD
(
extent
);
*
cy
=
HIWORD
(
extent
);
#endif
}
void
GetPlotRect
(
LPGW
lpgw
,
LPRECT
rect
)
{
GetClientRect
(
lpgw
->
hWndGraph
,
rect
);
rect
->
bottom
-=
lpgw
->
statuslineheight
;
/* leave some room for the status line */
if
(
rect
->
bottom
<
rect
->
top
)
rect
->
bottom
=
rect
->
top
;
}
static
void
MakeFonts
(
LPGW
lpgw
,
LPRECT
lprect
,
HDC
hdc
)
{
HFONT
hfontold
;
TEXTMETRIC
tm
;
int
result
;
char
FAR
*
p
;
int
cx
,
cy
;
lpgw
->
rotate
=
FALSE;
_fmemset
(
&
(
lpgw
->
lf
),
0
,
sizeof
(
LOGFONT
));
_fstrncpy
(
lpgw
->
lf
.
lfFaceName
,
lpgw
->
fontname
,
LF_FACESIZE
);
lpgw
->
lf
.
lfHeight
=
-
MulDiv
(
lpgw
->
fontsize
,
GetDeviceCaps
(
hdc
,
LOGPIXELSY
),
72
);
lpgw
->
lf
.
lfCharSet
=
DEFAULT_CHARSET
;
if
( (
p
=
_fstrstr
(
lpgw
->
fontname
,
" Italic"
))
!=
(
LPSTR
)
NULL
) {
lpgw
->
lf
.
lfFaceName
[ (
unsigned
int
)(
p
-
lpgw
->
fontname
) ]
=
'\0'
;
lpgw
->
lf
.
lfItalic
=
TRUE;
}
if
( (
p
=
_fstrstr
(
lpgw
->
fontname
,
" Bold"
))
!=
(
LPSTR
)
NULL
) {
lpgw
->
lf
.
lfFaceName
[ (
unsigned
int
)(
p
-
lpgw
->
fontname
) ]
=
'\0'
;
lpgw
->
lf
.
lfWeight
=
FW_BOLD
;
}
if
(
lpgw
->
hfonth
==
0
) {
lpgw
->
hfonth
=
CreateFontIndirect
((
LOGFONT
FAR
*
)
&
(
lpgw
->
lf
));
}
/* we do need a 90 degree font */
if
(
lpgw
->
hfontv
)
DeleteObject
(
lpgw
->
hfontv
);
lpgw
->
lf
.
lfEscapement
=
900
;
lpgw
->
lf
.
lfOrientation
=
900
;
lpgw
->
hfontv
=
CreateFontIndirect
((
LOGFONT
FAR
*
)
&
(
lpgw
->
lf
));
/* save text size */
hfontold
=
SelectObject
(
hdc
,
lpgw
->
hfonth
);
Wnd_GetTextSize
(
hdc
,
"0123456789"
,
10
,
&
cx
,
&
cy
);
lpgw
->
vchar
=
MulDiv
(
cy
,
lpgw
->
ymax
,
lprect
->
bottom
-
lprect
->
top
);
lpgw
->
hchar
=
MulDiv
(
cx
/
10
,
lpgw
->
xmax
,
lprect
->
right
-
lprect
->
left
);
/* CMW: Base tick size on character size */
lpgw
->
htic
=
lpgw
->
hchar
/
2
;
cy
=
MulDiv
(
cx
/
20
,
GetDeviceCaps
(
hdc
,
LOGPIXELSY
),
GetDeviceCaps
(
hdc
,
LOGPIXELSX
));
lpgw
->
vtic
=
MulDiv
(
cy
,
lpgw
->
ymax
,
lprect
->
bottom
-
lprect
->
top
);
/* find out if we can rotate text 90deg */
SelectObject
(
hdc
,
lpgw
->
hfontv
);
result
=
GetDeviceCaps
(
hdc
,
TEXTCAPS
);
if
((
result
&
TC_CR_90
)
||
(
result
&
TC_CR_ANY
))
lpgw
->
rotate
=
TRUE;
GetTextMetrics
(
hdc
,(
TEXTMETRIC
FAR
*
)
&
tm
);
if
(
tm
.
tmPitchAndFamily
&
TMPF_VECTOR
)
lpgw
->
rotate
=
TRUE;
/* vector fonts can all be rotated */
#if
WINVER
>=
0x030a
if
(
tm
.
tmPitchAndFamily
&
TMPF_TRUETYPE
)
lpgw
->
rotate
=
TRUE;
/* truetype fonts can all be rotated */
#endif
SelectObject
(
hdc
,
hfontold
);
return
;
}
static
void
DestroyFonts
(
LPGW
lpgw
)
{
if
(
lpgw
->
hfonth
) {
DeleteObject
(
lpgw
->
hfonth
);
lpgw
->
hfonth
=
0
;
}
if
(
lpgw
->
hfontv
) {
DeleteObject
(
lpgw
->
hfontv
);
lpgw
->
hfontv
=
0
;
}
return
;
}
static
void
SetFont
(
LPGW
lpgw
,
HDC
hdc
)
{
if
(
lpgw
->
rotate
&&
lpgw
->
angle
) {
if
(
lpgw
->
hfontv
)
DeleteObject
(
lpgw
->
hfontv
);
lpgw
->
lf
.
lfEscapement
=
lpgw
->
lf
.
lfOrientation
=
lpgw
->
angle
*
10
;
lpgw
->
hfontv
=
CreateFontIndirect
((
LOGFONT
FAR
*
)
&
(
lpgw
->
lf
));
if
(
lpgw
->
hfontv
)
SelectObject
(
hdc
,
lpgw
->
hfontv
);
}
else
{
if
(
lpgw
->
hfonth
)
SelectObject
(
hdc
,
lpgw
->
hfonth
);
}
return
;
}
static
void
SelFont
(
LPGW
lpgw
)
{
#if
WINVER
>=
0x030a
LOGFONT
lf
;
CHOOSEFONT
cf
;
HDC
hdc
;
char
lpszStyle
[
LF_FACESIZE
];
char
FAR
*
p
;
/* Set all structure fields to zero. */
_fmemset
(
&
cf
,
0
,
sizeof
(
CHOOSEFONT
));
_fmemset
(
&
lf
,
0
,
sizeof
(
LOGFONT
));
cf
.
lStructSize
=
sizeof
(
CHOOSEFONT
);
cf
.
hwndOwner
=
lpgw
->
hWndGraph
;
_fstrncpy
(
lf
.
lfFaceName
,
lpgw
->
fontname
,
LF_FACESIZE
);
if
((
p
=
_fstrstr
(
lpgw
->
fontname
,
" Bold"
))
!=
(
LPSTR
)
NULL
) {
_fstrncpy
(
lpszStyle
,
p
+
1
,
LF_FACESIZE
);
lf
.
lfFaceName
[ (
unsigned
int
)(
p
-
lpgw
->
fontname
) ]
=
'\0'
;
}
else
if
((
p
=
_fstrstr
(
lpgw
->
fontname
,
" Italic"
))
!=
(
LPSTR
)
NULL
) {
_fstrncpy
(
lpszStyle
,
p
+
1
,
LF_FACESIZE
);
lf
.
lfFaceName
[ (
unsigned
int
)(
p
-
lpgw
->
fontname
) ]
=
'\0'
;
}
else
{
_fstrcpy
(
lpszStyle
,
"Regular"
);
}
cf
.
lpszStyle
=
lpszStyle
;
hdc
=
GetDC
(
lpgw
->
hWndGraph
);
lf
.
lfHeight
=
-
MulDiv
(
lpgw
->
fontsize
,
GetDeviceCaps
(
hdc
,
LOGPIXELSY
),
72
);
ReleaseDC
(
lpgw
->
hWndGraph
,
hdc
);
cf
.
lpLogFont
=
&
lf
;
cf
.
nFontType
=
SCREEN_FONTTYPE
;
cf
.
Flags
=
CF_SCREENFONTS
|
CF_INITTOLOGFONTSTRUCT
|
CF_USESTYLE
;
if
(
ChooseFont
(
&
cf
)) {
_fstrcpy
(
lpgw
->
fontname
,
lf
.
lfFaceName
);
lpgw
->
fontsize
=
cf
.
iPointSize
/
10
;
if
(
cf
.
nFontType
&
BOLD_FONTTYPE
)
lstrcat
(
lpgw
->
fontname
,
" Bold"
);
if
(
cf
.
nFontType
&
ITALIC_FONTTYPE
)
lstrcat
(
lpgw
->
fontname
,
" Italic"
);
/* set current font as default font */
strcpy
(
lpgw
->
deffontname
,
lpgw
->
fontname
);
lpgw
->
deffontsize
=
lpgw
->
fontsize
;
SendMessage
(
lpgw
->
hWndGraph
,
WM_COMMAND
,
M_REBUILDTOOLS
,
0L
);
}
#endif
}
#ifdef
USE_MOUSE
/* ================================== */
static
void
LoadCursors
(
LPGW
lpgw
)
{
/* 3 of them are standard cursor shapes: */
hptrDefault
=
LoadCursor
(
NULL
,
IDC_ARROW
);
hptrZooming
=
LoadCursor
(
NULL
,
IDC_SIZEALL
);
hptrCrossHair
=
LoadCursor
(
NULL
,
IDC_CROSS
);
/* the other 2 are kept in the resource file: */
hptrScaling
=
LoadCursor
(
lpgw
->
hInstance
,
MAKEINTRESOURCE
(
IDC_SCALING
));
hptrRotating
=
LoadCursor
(
lpgw
->
hInstance
,
MAKEINTRESOURCE
(
IDC_ROTATING
));
hptrCurrent
=
hptrCrossHair
;
}
static
void
DestroyCursors
(
LPGW
lpgw
)
{
/* No-op. Cursors from LoadCursor() don't need destroying */
return
;
}
#endif
/* USE_MOUSE */
/* ================================== */
static
void
dot
(
HDC
hdc
,
int
xdash
,
int
ydash
)
{
MoveTo
(
hdc
,
xdash
,
ydash
);
LineTo
(
hdc
,
xdash
,
ydash
+
1
);
}
/* This one is really the heart of this module: it executes the stored set of
* commands, whenever it changed or a redraw is necessary */
static
void
drawgraph
(
LPGW
lpgw
,
HDC
hdc
,
LPRECT
rect
)
{
int
xdash
,
ydash
;
/* the transformed coordinates */
int
rr
,
rl
,
rt
,
rb
;
struct
GWOP
FAR
*
curptr
;
struct
GWOPBLK
*
blkptr
;
int
htic
,
vtic
;
int
hshift
,
vshift
;
unsigned
int
lastop
=
-1
;
/* used for plotting last point on a line */
int
pen
;
int
polymax
=
200
;
int
polyi
=
0
;
POINT
*
ppt
;
unsigned
int
ngwop
=
0
;
BOOL
isColor
;
double
line_width
=
1.0
;
unsigned
int
fillstyle
=
0.0
;
int
idx
;
if
(
lpgw
->
locked
)
return
;
/* HBB 20010218: the GDI status query functions don't work on Metafile
* handles, so can't know whether the screen is actually showing
* color or not, if drawgraph() is being called from CopyClip().
* Solve by defaulting isColor to 1 if hdc is a metafile. */
isColor
=
(((
GetDeviceCaps
(
hdc
,
PLANES
)
*
GetDeviceCaps
(
hdc
,
BITSPIXEL
))
>
2
)
||
(
GetDeviceCaps
(
hdc
,
TECHNOLOGY
)
==
DT_METAFILE
));
if
(
lpgw
->
background
!=
RGB
(
255
,
255
,
255
)
&&
lpgw
->
color
&&
isColor
) {
SetBkColor
(
hdc
,
lpgw
->
background
);
FillRect
(
hdc
,
rect
,
lpgw
->
hbrush
);
}
ppt
=
(
POINT
*
)
LocalAllocPtr
(
LHND
, (
polymax
+
1
)
*
sizeof
(
POINT
));
rr
=
rect
->
right
;
rl
=
rect
->
left
;
rt
=
rect
->
top
;
rb
=
rect
->
bottom
;
htic
=
lpgw
->
org_pointsize
*
MulDiv
(
lpgw
->
htic
,
rr
-
rl
,
lpgw
->
xmax
)
+
1
;
vtic
=
lpgw
->
org_pointsize
*
MulDiv
(
lpgw
->
vtic
,
rb
-
rt
,
lpgw
->
ymax
)
+
1
;
lpgw
->
angle
=
0
;
SetFont
(
lpgw
,
hdc
);
SetTextAlign
(
hdc
,
TA_LEFT
|
TA_BASELINE
);
/* calculate text shifting for horizontal text */
hshift
=
0
;
vshift
=
MulDiv
(
lpgw
->
vchar
,
rb
-
rt
,
lpgw
->
ymax
)/
2
;
pen
=
2
;
SelectObject
(
hdc
,
lpgw
->
hapen
);
SelectObject
(
hdc
,
lpgw
->
colorbrush
[
pen
]);
/* do the drawing */
blkptr
=
lpgw
->
gwopblk_head
;
curptr
=
NULL
;
if
(
blkptr
) {
if
(!
blkptr
->
gwop
)
blkptr
->
gwop
=
(
struct
GWOP
FAR
*
)
GlobalLock
(
blkptr
->
hblk
);
if
(!
blkptr
->
gwop
)
return
;
curptr
=
(
struct
GWOP
FAR
*
)
blkptr
->
gwop
;
}
while
(
ngwop
<
lpgw
->
nGWOP
) {
/* transform the coordinates */
xdash
=
MulDiv
(
curptr
->
x
,
rr
-
rl
-
1
,
lpgw
->
xmax
)
+
rl
;
ydash
=
MulDiv
(
curptr
->
y
,
rt
-
rb
+
1
,
lpgw
->
ymax
)
+
rb
-
1
;
if
((
lastop
==
W_vect
)
&&
(
curptr
->
op
!=
W_vect
)) {
if
(
polyi
>=
2
) {
Polyline
(
hdc
,
ppt
,
polyi
);
/* Bastian's proposed new fix */
MoveTo
(
hdc
,
ppt
[
0
].
x
,
ppt
[
0
].
y
);
}
else
if
(
polyi
==
1
)
/* Bastian's earlier fix */
LineTo
(
hdc
,
ppt
[
0
].
x
,
ppt
[
0
].
y
);
polyi
=
0
;
}
switch
(
curptr
->
op
) {
case
0
:
/* have run past last in this block */
break
;
case
W_move
:
ppt
[
0
].
x
=
xdash
;
ppt
[
0
].
y
=
ydash
;
polyi
=
1
;
break
;
case
W_vect
:
ppt
[
polyi
].
x
=
xdash
;
ppt
[
polyi
].
y
=
ydash
;
polyi
++
;
if
(
polyi
>=
polymax
) {
Polyline
(
hdc
,
ppt
,
polyi
);
ppt
[
0
].
x
=
xdash
;
ppt
[
0
].
y
=
ydash
;
polyi
=
1
;
}
break
;
case
W_line_type
:
{
LOGBRUSH
lb
;
LOGPEN
cur_penstruct
;
short
cur_pen
=
((
curptr
->
x
<
(
WORD
)(
-2
))
? (
curptr
->
x
%
WGNUMPENS
)
+
2
:
curptr
->
x
+
2
);
/* set color only when second parameter to W_line_type equals 1 */
if
(
curptr
->
y
!=
1
)
pen
=
cur_pen
;
cur_penstruct
=
(
lpgw
->
color
&&
isColor
) ?
lpgw
->
colorpen
[
pen
] :
lpgw
->
monopen
[
pen
];
cur_penstruct
.
lopnColor
=
((
lpgw
->
color
&&
isColor
) ?
lpgw
->
colorpen
[
cur_pen
] :
lpgw
->
monopen
[
cur_pen
]).
lopnColor
;
if
(
line_width
!=
1
)
cur_penstruct
.
lopnWidth
.
x
*=
line_width
;
/* use ExtCreatePen instead of CreatePen/CreatePenIndirect
* to support dashed lines if line_width > 1 */
lb
.
lbStyle
=
BS_SOLID
;
lb
.
lbColor
=
cur_penstruct
.
lopnColor
;
#if
0
/* shige work-around for Windows clipboard bug */
lpgw
->
hapen
=
ExtCreatePen
(
(
line_width
==
1
?
PS_COSMETIC
:
PS_GEOMETRIC
) |
cur_penstruct
.
lopnStyle
|
PS_ENDCAP_FLAT
|
PS_JOIN_BEVEL
,
cur_penstruct
.
lopnWidth
.
x
,
&
lb
,
0
,
0
);
#else
if
(
line_width
==
1
)
lpgw
->
hapen
=
CreatePenIndirect
((
LOGPEN
FAR
*
)
&
cur_penstruct
);
else
lpgw
->
hapen
=
ExtCreatePen
(
PS_GEOMETRIC
|
cur_penstruct
.
lopnStyle
|
PS_ENDCAP_FLAT
|
PS_JOIN_BEVEL
,
cur_penstruct
.
lopnWidth
.
x
,
&
lb
,
0
,
0
);
#endif
DeleteObject
(
SelectObject
(
hdc
,
lpgw
->
hapen
));
SelectObject
(
hdc
,
lpgw
->
colorbrush
[
cur_pen
]);
/* PM 7.7.2002: support color text */
SetTextColor
(
hdc
,
cur_penstruct
.
lopnColor
);
}
break
;
case
W_put_text
:
{
char
*
str
;
str
=
LocalLock
(
curptr
->
htext
);
if
(
str
) {
/* shift correctly for rotated text */
xdash
+=
hshift
;
ydash
+=
vshift
;
SetBkMode
(
hdc
,
TRANSPARENT
);
TextOut
(
hdc
,
xdash
,
ydash
,
str
,
lstrlen
(
str
));
SetBkMode
(
hdc
,
OPAQUE
);
}
LocalUnlock
(
curptr
->
htext
);
}
break
;
case
W_fillstyle
:
/* HBB 20010916: new entry, needed to squeeze the many
* parameters of a filled box call through the bottlneck
* of the fixed number of parameters in GraphOp() and
* struct GWOP, respectively. */
fillstyle
=
curptr
->
x
;
break
;
case
W_boxfill
:
/* ULIG */
assert
(
polyi
==
1
);
/* NOTE: the x and y passed with this call are the width and
* height of the box, actually. The left corner was stored into
* ppt[0] by a preceding W_move, and the style was memorized
View remainder of file in raw view
Back
|
FazBrowse Home
|
New Git URL