FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
gnuplot/src/os2/gclient.c at master · gnuplot/gnuplot · GitHub
gnuplot
gnuplot
Repository navigation
Code
Pull requests
2
(2)
Actions
Security and quality
Insights
Expand file tree
Breadcrumbs
gnuplot
/
src
/
os2
/
gclient.c
Copy path
More file actions
More file actions
Latest commit
History
History
History
4675 lines (4092 loc) · 122 KB
Breadcrumbs
gnuplot
/
src
/
os2
/
gclient.c
Copy path
File metadata and controls
4675 lines (4092 loc) · 122 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
/****************************************************************************
PROGRAM: Gnupmdrv
MODULE: gclient.c
This file contains the client window procedures for Gnupmdrv
****************************************************************************/
/* PM driver for GNUPLOT */
/*[
* Copyright 1992, 1993, 1998, 2004, 2019-2021 Roger Fearick
*
* 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.
]*/
/*
* AUTHOR
*
* Gnuplot driver for OS/2: Roger Fearick
*
*
* CONTRIBUTIONS:
*
* Petr Mikulik (see PM labels)
* - menu item to keep aspect ratio on/off (October 1997)
* - mouse support (1998, 1999); changes made after gnuplot 3.7.0.5:
* - use gnuplot's pid in the name of shared memory (11. 5. 1999)
* - mouse in maps; distance in polar coords (14. 5. 1999)
* - event semaphore for sending data via shared memory;
* zooming completely revised;
* remap keys in 'case WM_CHAR';
* Ctrl-C for breaking long drawings;
* new menu items under 'Mouse' and 'Utilities' (August 1999)
* - rewrite of mouse support for the new scheme common with X11
* (October 1999 - January 2000)
* - pm3d stuff (since January 1999)
*
* Franz Bakan
* - communication gnupmdrv -> gnuplot via shared memory (April 1999)
* - date and time on x axis (August 1999)
*
* Bastian Maerkisch
* RGB colors, pattern fill, images, fixes (2004, 2005)
* dashed lines, bold/italic text, fill style for boxes and polygons, fixes (2019)
* line-to-ruler, zoom-coordinates, cleanup, fixes (2021)
*
*/
#define
INCL_PM
#define
INCL_WIN
#define
INCL_SPL
#define
INCL_SPLDOSPRINT
#define
INCL_WINSTDFONT
#define
INCL_DOSMEMMGR
#define
INCL_DOSPROCESS
#define
INCL_DOSERRORS
#define
INCL_DOSFILEMGR
#define
INCL_DOSNMPIPES
#define
INCL_DOSSESMGR
#define
INCL_DOSSEMAPHORES
#define
INCL_DOSMISC
#ifdef
HAVE_EXCEPTQ
# define
INCL_DOSEXCEPTIONS
# define
INCL_DOSMODULEMGR
#endif
#define
INCL_DOSQUEUES
#define
INCL_WINSWITCHLIST
#define
INCL_GPIPRIMITIVES
#define
INCL_GPILCIDS
#include
<os2.h>
/* Warning: the OS/2 headers already define LT_DEFAULT
which conflicts with our definition. */
#undef
LT_DEFAULT
#include
<string.h>
#include
<stdio.h>
#include
<io.h>
#include
<fcntl.h>
#include
<math.h>
#include
<float.h>
#include
<stdlib.h>
#include
<unistd.h>
#include
<process.h>
#include
<signal.h>
#include
<time.h>
#include
"config.h"
#include
"version.c"
/* directly include version information */
#include
"term_api.h"
#include
"gnupmdrv.h"
#include
"pm_msgs.h"
#include
"mousecmn.h"
/* Finally, include the common mousing declarations and routines: */
#include
"gpexecute.h"
/*==== m i s c e l l a n e o u s =============================================*/
/* Bug report #570 (Feb. 2008)
The standard font selection dialog is somehow broken after saving options.
(Feb. 2021) For newer OS/2 versions, this seems no longer be the case, but
you can still use the font palette dialog instead.
*/
#define
STANDARD_FONT_DIALOG
1
/*==== d e b u g g i n g =====================================================*/
#ifdef
HAVE_EXCEPTQ
# include
<exceptq.h>
/* missing definition */
BOOL
LoadExceptq
(
EXCEPTIONREGISTRATIONRECORD
*
pExRegRec
,
const
char
*
pOpts
,
const
char
*
pInfo
);
#endif
#ifdef
HAVE_PMPRINTF
# include
<pmprintf.h>
#endif
#define
DEBUG_IMAGE
(
a
)
// PmPrintf a
#define
DEBUG_COLOR
(
a
)
// PmPrintf a
#define
DEBUG_FONT
(
a
)
// PmPrintf a
#define
DEBUG_LINES
(
a
)
// PmPrintf a
#define
DEBUG_LAYER
(
a
)
// PmPrintf a
#define
TEXT_DEBUG
(
x
)
// PmPrintf x
/*==== l o c a l d a t a ==================================================*/
static
long
lLineTypes
[
7
]
=
{
LINETYPE_SOLID
,
LINETYPE_SHORTDASH
,
LINETYPE_DOT
,
LINETYPE_DASHDOT
,
LINETYPE_LONGDASH
,
LINETYPE_DOUBLEDOT
,
LINETYPE_DASHDOUBLEDOT
};
static
long
lCols
[
16
]
=
{
CLR_BLACK
,
CLR_DARKGRAY
,
CLR_RED
,
CLR_GREEN
,
CLR_BLUE
,
CLR_PINK
,
CLR_CYAN
,
CLR_BROWN
,
CLR_YELLOW
,
CLR_DARKBLUE
,
CLR_DARKRED
,
CLR_DARKGREEN
,
CLR_DARKCYAN
,
CLR_DARKPINK
,
CLR_PALEGRAY
,
CLR_WHITE
};
static
BOOL
bCols_init
=
FALSE;
/* Note that there are 16 colours used for drawing. The two more
entries in this array were added by Ilya to avoid drawing white
line on white background. */
#define
nColors
16
static
LONG
alColourTable
[
nColors
+
2
];
static
BOOL
bPMPaletteMode
=
TRUE;
/* do we use PM palette manager? */
/* RGB equivalents of all normal CLR_xxx colour constants
Note: First entry corresponds to CLR_WHITE, which is negative (-2)!
*/
static
LONG
rgb_colors
[
18
];
/* macro to facilitate translation */
#define
RGB_TRANS
(
v
) rgb_colors[(v)-CLR_WHITE]
/* A value of 0 indicates direct rgb colors without palette */
#define
RGB_PALETTE_SIZE
0
/* size of the 'virtual' palette used for
translation of index to RGB value */
/* GNUBUF is the size of the buffer for the data stream from gnuplot.
Requests larger than this are split. By default, we use 128kB. */
#define
GNUBUF
131072
/* buffer for gnuplot commands */
#define
PIPEBUF
4096
/* size of pipe buffers */
#define
PAUSE_DLG
1
/* pause handled in dialog box */
#define
PAUSE_BTN
2
/* pause handled by menu item */
#define
PAUSE_GNU
3
/* pause handled by Gnuplot */
#define
DEFLW
20
static
HDC
hdcScreen
;
static
HPS
hpsScreen
;
/* screen pres. space */
static
int
iSeg
=
1
;
static
HSWITCH
hSwitch
=
0
;
/* switching between windows */
static
SWCNTRL
swGnu
;
static
BOOL
bColours
=
TRUE;
static
BOOL
bShellPos
=
FALSE;
static
BOOL
bPopFront
=
TRUE;
static
BOOL
bKeepRatio
=
TRUE;
static
double
multLineHor
=
1.
;
/* Horizontal and vertical spacing shifts */
static
double
multLineVert
=
0.
;
/* for multiline prints. */
static
int
codepage
=
0
;
static
int
ulMouseSprintfFormatItem
=
IDM_MOUSE_FORMAT_XcY
;
static
const
char
*
SetDataStyles
[]
=
{
"boxes"
,
"dots"
,
"fsteps"
,
"histeps"
,
"impulses"
,
"lines"
,
"linespoints"
,
"points"
,
"steps"
};
static
ULONG
ulShellPos
[
4
];
static
PAUSEDATA
pausedata
=
{
sizeof
(
PAUSEDATA
),
NULL
,
NULL
};
static
char
szInitialFontNameSize
[
FONTBUF
]
=
INITIAL_FONT
;
static
int
iInitialFontSize
;
static
char
*
szInitialFontName
;
static
char
szFontNameSize
[
FONTBUF
];
/* default name and size, format: "10.Helvetica" */
static
char
szCurrentFontNameSize
[
FONTBUF
];
/* currently selected font */
static
unsigned
fontscale
=
100
;
/* scaling factor for font size in percent */
static
PRQINFO3
infPrinter
=
{
""
};
static
QPRINT
qPrintData
=
{
sizeof
(
QPRINT
),
0.0
,
0.0
,
1.0
,
1.0
,
0
,
""
,
""
,
&
infPrinter
,
0
,
NULL
};
//static HEV semStartSeq; /* semaphore to start things in right sequence */
static
HEV
semPause
;
static
HMTX
semHpsAccess
;
static
ULONG
ulPauseReply
=
1
;
static
ULONG
ulPauseMode
=
PAUSE_DLG
;
static
ULONG
ulPauseItem
=
IDM_PAUSEDLG
;
static
HWND
hSysMenu
;
/* stuff for screen-draw thread control */
static
TID
tidDraw
,
tidSpawn
;
static
BOOL
breakDrawing
=
FALSE;
/* //PM flag for stopping (long) drawings */
/* font data */
static
int
lSupOffset
=
0
;
static
int
lSubOffset
=
0
;
static
int
lBaseSupOffset
=
0
;
static
int
lBaseSubOffset
=
0
;
static
int
lCharWidth
=
217
;
static
int
lCharHeight
=
465
;
/* useMouse is set when user switches mousing on, e.g. the mouse is allowed */
static
BOOL
useMouse
=
TRUE;
/* gnuplot's PM terminal sends GR_MOUSECAPABLE message from its init routine, which
sets the variable below. Then we are sure that we talk to a mouse-capable
terminal and can read the mouse data from the pipe.
Non-mouseable versions of PM terminal or non-gnuplot programs using
gnupmdrv will let this variable unset, thus no mousing occurs.
*/
static
BOOL
mouseTerminal
=
FALSE;
/* Lock (hide) mouse when building the plot (redrawing screen).
Otherwise gnupmdrv would crash when trying to display mouse position
in a window not yet plotted.
*/
static
BOOL
lock_mouse
=
TRUE;
/* Status of zoom box */
static
struct
Zoombox
{
BOOL
on
;
/* set during zooming */
POINTL
from
,
to
;
/* corners of the zoom box */
char
*
text1
,
*
text2
;
/* texts in the corners (i.e. positions) */
}
zoombox
=
{ FALSE, {
0
,
0
}, {
0
,
0
},
NULL
,
NULL
};
/* Structure for the ruler: on/off, position,... */
static
struct
{
BOOL
on
;
int
x
,
y
;
/* ruler position */
}
ruler
=
{
0
,
0
,
0
};
/* Status of the line from ruler to cursor */
static
struct
{
BOOL
on
;
/* ruler line active ? */
int
x
,
y
;
/* ruler line end position (previous cursor position) */
}
ruler_lineto
=
{ FALSE,
0
,
0
};
// Pointer definition
HWND
hptrDefault
,
hptrCrossHair
,
hptrScaling
,
hptrRotating
,
hptrZooming
,
hptrCurrent
;
// After passing gpPMmenu in PM_pipe and SET_GRAPHICS, it seems not to be possible
// to update the menu. Thus this flag is set on and menu is updated
// afterwards.
struct
t_gpPMmenu
gpPMmenu
;
BOOL
gpPMmenu_update_req
=
FALSE;
// colours of mouse-relating drawings (CLR_DEFAULT is not allowed!)
#define
COLOR_MOUSE
CLR_BLACK // mouse position
#define
COLOR_ANNOTATE
CLR_BLACK // annotating strings (MB3)
#define
COLOR_RULER
CLR_DARKPINK // colour of the ruler
#define
COLOR_ERROR
CLR_RED // colour of error messages
static
enum
JUSTIFY
jmode
;
static
SIZEF
sizBaseSubSup
;
static
SIZEF
sizCurSubSup
;
static
SIZEF
sizCurFont
;
static
long
lVOffset
=
0
;
static
SIZEF
sizBaseFont
;
static
struct
_ft
{
char
*
name
;
int
codepage
;
BOOL
bold
;
BOOL
italic
;
LONG
lcid
;
}
tabFont
[
256
]
=
{
{
NULL
,
0
, FALSE, FALSE,
0L
},
{
NULL
}
};
typedef
struct
_plotlist
{
int
no
;
// plot number
unsigned
plot
;
// segment number of plot
unsigned
plot1
;
// segment number of plot
unsigned
key
;
// segment number of key
unsigned
key1
;
// segment number of key
struct
_plotlist
*
next
;
}
plotlist
;
static
plotlist
*
plots
=
NULL
;
typedef
struct
image_list_entry
{
PBITMAPINFO2
pbmi
;
PBYTE
image
;
struct
image_list_entry
*
next
;
}
image_list_entry
;
static
image_list_entry
*
image_list
=
NULL
;
/*==== f u n c t i o n s =====================================================*/
int
DoPrint
(
HWND
);
HBITMAP
CopyToBitmap
(
HPS
);
HMF
CopyToMetaFile
(
HPS
);
MRESULT
WmClientCmdProc
(
HWND
,
ULONG
,
MPARAM
,
MPARAM
);
void
ChangeCheck
(
HWND
,
USHORT
,
USHORT
);
BOOL
QueryIni
(
HAB
);
static
void
SaveIni
(
HWND
);
static
void
ThreadDraw
(
void
*
);
static
void
DoPaint
(
HWND
,
HPS
);
static
void
SelectFont
(
HPS
,
char
*
);
static
void
SwapFont
(
HPS
,
char
*
);
static
void
CopyToClipBrd
(
HWND
);
static
void
ReadGnu
(
void
*
);
static
void
SetFillStyle
(
HPS
hps
,
int
style
);
static
HPS
InitScreenPS
(
void
);
static
APIRET
BufRead
(
HFILE
,
void
*
,
int
,
PULONG
);
static
BOOL
GetNewFont
(
HWND
,
HPS
);
void
SigHandler
(
int
);
static
void
FontExpand
(
char
*
);
#ifdef
PM_KEEP_OLD_ENHANCED_TEXT
static
char
*
ParseText
(
HPS
,
char
*
,
BOOL
,
char
*
,
int
,
int
,
BOOL
,
BOOL
);
static
void
CharStringAt
(
HPS
,
int
,
int
,
int
,
char
*
);
static
int
QueryTextBox
(
HPS
,
int
,
char
*
);
#endif
static
void
LMove
(
HPS
hps
,
POINTL
*
p
);
static
void
LLine
(
HPS
hps
,
POINTL
*
p
);
static
int
LType
(
int
iType
);
/* Functions related to mouse processing */
static
void
TextToClipboard
(
PCSZ
);
static
void
GetMousePosViewport
(
HWND
hWnd
,
int
*
mx
,
int
*
my
);
static
void
MousePosToViewport
(
int
*
x
,
int
*
y
,
SHORT
mx
,
SHORT
my
);
static
void
gpPMmenu_update
(
void
);
static
void
ResetStatusLineText
(
void
);
static
void
DisplayStatusLine
();
static
void
UpdateStatusLine
(
char
*
text
);
static
void
DrawMouseText
(
HPS
hps
,
PPOINTL
pt
,
char
*
text
,
LONG
len
);
static
void
DrawZoomBox
(
void
);
static
void
DrawRuler
(
void
);
static
void
DrawRulerLineTo
(
void
);
static
BOOL
modify_segment
(
HPS
hps
,
unsigned
seg
,
unsigned
op
);
#define
IGNORE_MOUSE
(!mouseTerminal || !useMouse || lock_mouse)
/* don't react to mouse in the event handler, and avoid some crashes */
/* Drag'n'Drop support from PMEmacs */
struct
drop
{
unsigned long
cookie
;
unsigned
len
;
char
str
[
CCHMAXPATH
];
};
/*==== c o d e ===============================================================*/
/* Our own versions of strlcpy and strlcat, required only for EMX. */
#ifndef
__KLIBC__
#undef
strlcpy
static
size_t
strlcpy
(
char
*
dst
,
const
char
*
src
,
size_t
size
)
{
size_t
len
=
strlen
(
src
);
if
(
size
>
0
) {
strncpy
(
dst
,
src
,
size
);
if
(
len
>=
size
)
dst
[
size
-
1
]
=
NUL
;
}
return
len
;
}
#undef
strlcat
size_t
strlcat
(
char
*
dst
,
const
char
*
src
,
size_t
size
)
{
size_t
len
=
strlen
(
dst
);
return
strlcpy
(
dst
+
len
,
src
,
size
-
len
)
+
len
;
}
#endif
/* An object is being dragged over the client window. Check whether
it can be dropped or not. */
void
report_error
(
HWND
hWnd
,
char
*
s
)
{
HPS
hps
;
POINTL
pt
;
RECTL
rc
;
hps
=
WinGetPS
(
hWnd
);
GpiSetMix
(
hps
,
FM_OVERPAINT
);
/* clear the rectangle below the text */
/* GpiSetColor(hps, RGB_TRANS(CLR_CYAN)); */
GpiSetColor
(
hps
,
RGB_TRANS
(
CLR_BACKGROUND
));
pt
.
x
=
0
;
pt
.
y
=
0
;
GpiMove
(
hps
,
&
pt
);
/* clear the whole line */
GpiQueryPageViewport
(
hpsScreen
,
&
rc
);
pt
.
x
=
rc
.
xRight
;
pt
.
y
=
16
;
GpiBox
(
hps
,
DRO_FILL
,
&
pt
,
0
,
0
);
/* now write the mouse position on the screen */
GpiSetColor
(
hps
,
RGB_TRANS
(
COLOR_ERROR
));
/* set text color */
GpiSetCharMode
(
hps
,
CM_MODE1
);
pt
.
x
=
2
;
pt
.
y
=
2
;
GpiCharStringAt
(
hps
,
&
pt
,(
long
)
strlen
(
s
),
s
);
WinReleasePS
(
hps
);
}
MRESULT
drag_over
(
HWND
hWnd
,
PDRAGINFO
pDraginfo
)
{
PDRAGITEM
pditem
;
USHORT
indicator
,
operation
;
/* Redefine this macro for debugging. */
#define
DRAG_FAIL
(
x
) report_error(hWnd,x)
indicator
=
DOR_NODROPOP
;
operation
=
DO_COPY
;
if
(!
DrgAccessDraginfo
(
pDraginfo
))
DRAG_FAIL
(
"DrgAccessDraginfo failed"
);
else
if
(!(
pDraginfo
->
usOperation
==
DO_DEFAULT
||
pDraginfo
->
usOperation
==
DO_COPY
))
DRAG_FAIL
(
"Invalid operation"
);
else
if
(
DrgQueryDragitemCount
(
pDraginfo
)
<
1
)
DRAG_FAIL
(
"Invalid count"
);
else
{
pditem
=
DrgQueryDragitemPtr
(
pDraginfo
,
0
);
if
(!(
pditem
->
fsSupportedOps
&
DO_COPYABLE
))
DRAG_FAIL
(
"Not copyable"
);
else
if
(!
DrgVerifyRMF
(
pditem
,
"DRM_OS2FILE"
,
NULL
))
DRAG_FAIL
(
"DrgVerifyRMF failed"
);
else
{
/* The object can be dropped (copied). */
indicator
=
DOR_DROP
;
operation
=
DO_COPY
;
}
}
DrgFreeDraginfo
(
pDraginfo
);
return
(
MRFROM2SHORT
(
indicator
,
operation
));
}
/* An object is dropped on the client window. */
MRESULT
drag_drop
(
HWND
hwnd
,
PDRAGINFO
pDraginfo
)
{
PDRAGITEM
pditem
;
POINTL
ptl
;
char
name
[
CCHMAXPATH
];
char
path
[
CCHMAXPATH
];
char
*
p
;
int
count
,
idx
,
len
;
DrgAccessDraginfo
(
pDraginfo
);
ptl
.
x
=
pDraginfo
->
xDrop
;
ptl
.
y
=
pDraginfo
->
yDrop
;
WinMapWindowPoints
(
HWND_DESKTOP
,
hwnd
,
&
ptl
,
1
);
count
=
DrgQueryDragitemCount
(
pDraginfo
);
for
(
idx
=
0
;
idx
<
count
;
++
idx
) {
pditem
=
DrgQueryDragitemPtr
(
pDraginfo
,
idx
);
DrgQueryStrName
(
pditem
->
hstrContainerName
,
sizeof
(
path
),
path
);
DrgQueryStrName
(
pditem
->
hstrSourceName
,
sizeof
(
name
),
name
);
DrgSendTransferMsg
(
pditem
->
hwndItem
,
DM_ENDCONVERSATION
,
MPFROMLONG
(
pditem
->
ulItemID
),
MPFROMSHORT
(
DMFL_TARGETSUCCESSFUL
));
len
=
strlen
(
path
);
if
(
len
>=
1
&&
strchr
(
"\\/:"
,
path
[
len
-
1
])
==
NULL
)
path
[
len
++
]
=
'/'
;
if
(
len
+
strlen
(
name
)
+
1
<=
sizeof
(
path
)) {
strcpy
(
path
+
len
,
name
);
for
(
p
=
path
;
*
p
!=
0
;
++
p
)
if
(
*
p
==
'\\'
)
*
p
=
'/'
;
if
(
input_from_PM_Terminal
) {
sprintf
(
input_from_PM_Terminal
,
"set loadpath \"%.*s\"; load \"%s\""
,
len
,
path
,
path
);
gp_execute
(
0
);
}
}
else
report_error
(
hwnd
,
"Dropped path name too long"
);
}
/* for (idx) */
DrgDeleteDraginfoStrHandles
(
pDraginfo
);
DrgFreeDraginfo
(
pDraginfo
);
return
(
0
);
}
#if
0
/* A color has been dropped on a frame (or the background color has
been changed with WinSetPresParam). */
static
void
drop_color
(
HWND
hwnd
)
{
RGB
rgb
;
char
buf
[
3
];
if
(
WinQueryPresParam
(
hwnd
,
PP_BACKGROUNDCOLOR
,
0
,
NULL
,
sizeof
(
rgb
),
&
rgb
,
QPF_NOINHERIT
|
QPF_PURERGBCOLOR
)
==
sizeof
(
rgb
)
) {
buf
[
0
]
=
rgb
.
bRed
;
buf
[
1
]
=
rgb
.
bGreen
;
buf
[
2
]
=
rgb
.
bBlue
;
#if
CAN_DROP_COLOR
send_drop_color
(
buf
,
3
);
#endif
}
}
#endif
/*
** Window proc for main window
** -- passes most stuff to active child window via WmClientCmdProc
** -- passes DDE messages to DDEProc
*/
MRESULT
EXPENTRY
DisplayClientWndProc
(
HWND
hWnd
,
ULONG
message
,
MPARAM
mp1
,
MPARAM
mp2
)
{
static
RECTL
rectlPaint
=
{
0
,
0
,
0
,
0
};
static
int
iPaintCount
=
0
;
static
int
firstcall
=
1
;
static
int
prev_mx
=
0
,
prev_my
=
0
;
/* previous mouse position */
int
mx
,
my
;
/* current mouse position */
#if
1
GetMousePosViewport
(
hWnd
,
&
mx
,
&
my
);
#else
/* The following cannot be used because `message' is not OK for
* WM_CHAR */
/* macro which gets mouse coords in pixels */
mx
=
MOUSEMSG
(
&
message
)
->
x
;
my
=
MOUSEMSG
(
&
message
)
->
y
;
/* viewport units --- this trashes mx,my! */
MousePosToViewport
(
&
mx
,
&
my
,
mx
,
my
);
#endif
/* Graphics part, SET_GRAPHICS, required to update menu */
if
(
gpPMmenu_update_req
)
gpPMmenu_update
();
/* Update the status line */
DisplayStatusLine
();
/* mouse events first */
switch
(
message
) {
case
WM_MOUSEMOVE
:
if
(
IGNORE_MOUSE
) {
WinSetPointer
(
HWND_DESKTOP
,
hptrDefault
);
/* set default pointer */
return
0L
;
}
/* check for valid mouse parameters */
if
((
mx
<=
0
)
&&
(
my
<=
0
))
return
0L
;
/* was the mouse moved? */
if
((
prev_mx
!=
mx
)
||
(
prev_my
!=
my
)) {
WinSetPointer
(
HWND_DESKTOP
,
hptrCurrent
);
if
(
zoombox
.
on
) {
DrawZoomBox
();
/* erase zoom box */
zoombox
.
to
.
x
=
mx
;
zoombox
.
to
.
y
=
my
;
DrawZoomBox
();
/* draw new zoom box */
}
if
(
ruler
.
on
&&
ruler_lineto
.
on
) {
DrawRulerLineTo
();
/* erase current line */
ruler_lineto
.
x
=
mx
;
ruler_lineto
.
y
=
my
;
DrawRulerLineTo
();
/* draw new line */
}
/* track(show) mouse position -- send the event to gnuplot */
gp_exec_event
(
GE_motion
,
mx
,
my
,
0
,
0
,
0
);
}
prev_mx
=
mx
;
prev_my
=
my
;
return
0L
;
/* end of WM_MOUSEMOVE */
case
WM_BUTTON1DOWN
:
{
BOOL
fSuccess
;
POINTL
pt
;
SIZEL
size
=
{
100L
,
100L
};
/* size of pick aperture */
LONG
alSegTag
[
2
];
WinSetFocus
(
HWND_DESKTOP
,
hWnd
);
WinSetWindowPos
(
hwndFrame
,
HWND_TOP
,
0
,
0
,
0
,
0
,
SWP_ACTIVATE
|
SWP_ZORDER
);
// check if we are clicking on a key entry
pt
.
x
=
mx
;
pt
.
y
=
my
;
fSuccess
=
GpiSetPickAperturePosition
(
hpsScreen
,
&
pt
);
/* set aperture size (use default) */
//fSuccess = GpiSetPickApertureSize(hpsScreen, PICKAP_DEFAULT, &size);
fSuccess
=
GpiSetPickApertureSize
(
hpsScreen
,
PICKAP_REC
,
&
size
);
if
(
GpiCorrelateChain
(
hpsScreen
,
PICKSEL_VISIBLE
,
&
pt
,
1
,
1
,
alSegTag
)
>
0
) {
DEBUG_LAYER
((
"Click correlation: tag=%li"
,
alSegTag
[
0
]));
plotlist
*
plot
=
plots
;
while
(
plot
!=
NULL
) {
if
(
plot
->
key
==
alSegTag
[
0
]
||
plot
->
key1
==
alSegTag
[
0
]) {
modify_segment
(
hpsScreen
,
plot
->
plot
,
MODPLOTS_INVERT_VISIBILITIES
);
modify_segment
(
hpsScreen
,
plot
->
plot1
,
MODPLOTS_INVERT_VISIBILITIES
);
break
;
}
plot
=
plot
->
next
;
}
// enforce a redraw
WinInvalidateRect
(
hWnd
,
NULL
, TRUE);
}
else
{
if
(!
IGNORE_MOUSE
)
gp_exec_event
(
GE_buttonpress
,
mx
,
my
,
1
,
0
,
0
);
}
return
0L
;
}
case
WM_BUTTON2DOWN
:
WinSetFocus
(
HWND_DESKTOP
,
hWnd
);
WinSetWindowPos
(
hwndFrame
,
HWND_TOP
,
0
,
0
,
0
,
0
,
SWP_ACTIVATE
|
SWP_ZORDER
);
if
(!
IGNORE_MOUSE
)
gp_exec_event
(
GE_buttonpress
,
mx
,
my
,
3
,
0
,
0
);
return
0L
;
case
WM_BUTTON3DOWN
:
WinSetFocus
(
HWND_DESKTOP
,
hWnd
);
WinSetWindowPos
(
hwndFrame
,
HWND_TOP
,
0
,
0
,
0
,
0
,
SWP_ACTIVATE
|
SWP_ZORDER
);
if
(!
IGNORE_MOUSE
)
gp_exec_event
(
GE_buttonpress
,
mx
,
my
,
2
,
0
,
0
);
return
0L
;
case
WM_BUTTON1DBLCLK
:
if
(!
IGNORE_MOUSE
)
gp_exec_event
(
GE_buttonrelease
,
mx
,
my
,
1
,
0
,
0
);
return
0L
;
case
WM_BUTTON2DBLCLK
:
if
(!
IGNORE_MOUSE
)
/* Note: 9999 should be replaced by time! */
gp_exec_event
(
GE_buttonrelease
,
mx
,
my
,
3
,
9999
,
0
);
return
0L
;
case
WM_BUTTON3DBLCLK
:
if
(!
IGNORE_MOUSE
)
gp_exec_event
(
GE_buttonrelease
,
mx
,
my
,
2
,
9999
,
0
);
return
0L
;
case
WM_BUTTON1UP
:
if
(!
IGNORE_MOUSE
)
gp_exec_event
(
GE_buttonrelease
,
mx
,
my
,
1
,
9999
,
0
);
return
0L
;
case
WM_BUTTON2UP
:
if
(!
IGNORE_MOUSE
)
gp_exec_event
(
GE_buttonrelease
,
mx
,
my
,
3
,
9999
,
0
);
return
0L
;
case
WM_BUTTON3UP
:
if
(!
IGNORE_MOUSE
)
gp_exec_event
(
GE_buttonrelease
,
mx
,
my
,
2
,
9999
,
0
);
return
0L
;
}
/* switch over mouse events */
switch
(
message
) {
case
WM_CREATE
:
{
SIZEL
sizlPage
;
LONG
NumColors
;
LONG
PalSupport
;
/* set initial values */
ChangeCheck
(
hWnd
,
IDM_LINES_THICK
,
bWideLines
?
IDM_LINES_THICK
:
0
);
ChangeCheck
(
hWnd
,
IDM_COLOURS
,
bColours
?
IDM_COLOURS
:
0
);
ChangeCheck
(
hWnd
,
IDM_FRONT
,
bPopFront
?
IDM_FRONT
:
0
);
ChangeCheck
(
hWnd
,
IDM_KEEPRATIO
,
bKeepRatio
?
IDM_KEEPRATIO
:
0
);
ChangeCheck
(
hWnd
,
IDM_USEMOUSE
,
useMouse
?
IDM_USEMOUSE
:
0
);
#if
0
ChangeCheck
(
hWnd
,
IDM_MOUSE_POLAR_DISTANCE
,
mousePolarDistance
?
IDM_MOUSE_POLAR_DISTANCE
:
0
);
#endif
switch
(
ulPauseMode
) {
case
PAUSE_DLG
:
ChangeCheck
(
hWnd
,
ulPauseItem
,
IDM_PAUSEDLG
);
ulPauseItem
=
IDM_PAUSEDLG
;
break
;
case
PAUSE_BTN
:
ChangeCheck
(
hWnd
,
ulPauseItem
,
IDM_PAUSEBTN
);
ulPauseItem
=
IDM_PAUSEBTN
;
break
;
case
PAUSE_GNU
:
ChangeCheck
(
hWnd
,
ulPauseItem
,
IDM_PAUSEGNU
);
ulPauseItem
=
IDM_PAUSEGNU
;
break
;
}
/* disable close from system menu (close only from gnuplot) */
hApp
=
WinQueryWindow
(
hWnd
,
QW_PARENT
);
/* temporary assignment.. */
hSysMenu
=
WinWindowFromID
(
hApp
,
FID_SYSMENU
);
/* setup semaphores */
/* DosCreateEventSem(NULL, &semStartSeq, 0L, 0L); */
DosCreateEventSem
(
NULL
,
&
semPause
,
0L
,
0L
);
DosCreateMutexSem
(
NULL
,
&
semHpsAccess
,
0L
,
1L
);
/* create a dc and hps to draw on the screen */
hdcScreen
=
WinOpenWindowDC
(
hWnd
);
/* How many colors can be displayed ? */
DevQueryCaps
(
hdcScreen
,
CAPS_COLORS
,
1
,
&
NumColors
);
/* Is Palette Manager supported at all? */
DevQueryCaps
(
hdcScreen
,
CAPS_ADDITIONAL_GRAPHICS
,
1
,
&
PalSupport
);
/* Determine if PM Palette Manager should be used */
bPMPaletteMode
=
(
PalSupport
&
CAPS_PALETTE_MANAGER
)
&&
(
NumColors
<=
256
);
DEBUG_COLOR
((
"WM_CREATE: colors = %i, pm = %i, rgb = %i"
,
NumColors
,
PalSupport
&
CAPS_PALETTE_MANAGER
, !
bPMPaletteMode
));
sizlPage
.
cx
=
0
;
sizlPage
.
cy
=
0
;
sizlPage
.
cx
=
GNUXPAGE
;
sizlPage
.
cy
=
GNUYPAGE
;
hpsScreen
=
GpiCreatePS
(
hab
,
hdcScreen
,
&
sizlPage
,
PU_HIMETRIC
|
GPIT_NORMAL
|
GPIA_ASSOC
);
/* spawn server for GNUPLOT ... */
tidSpawn
=
_beginthread
(
ReadGnu
,
NULL
,
32768
,
NULL
);
/* initialize pointers */
hptrDefault
=
WinQuerySysPointer
(
HWND_DESKTOP
,
SPTR_ARROW
, FALSE);
hptrCrossHair
=
WinLoadPointer
(
HWND_DESKTOP
,(
ULONG
)
0
,
IDP_CROSSHAIR
);
hptrScaling
=
WinLoadPointer
(
HWND_DESKTOP
,(
ULONG
)
0
,
IDP_SCALING
);
hptrRotating
=
WinLoadPointer
(
HWND_DESKTOP
,(
ULONG
)
0
,
IDP_ROTATING
);
hptrZooming
=
WinQuerySysPointer
(
HWND_DESKTOP
,
SPTR_MOVE
, FALSE);
hptrCurrent
=
hptrCrossHair
;
break
;
}
case
WM_GPSTART
:
/* Show the Mouse menu if connected to mouseable PM terminal */
if
(
1
||
mouseTerminal
)
/* PM: workaround for a bug---SEE "BUGS 2" IN README!!! */
/* if (mouseTerminal) */
WinEnableMenuItem
(
WinWindowFromID
(
WinQueryWindow
(
hApp
,
QW_PARENT
),
FID_MENU
),
IDM_MOUSE
, TRUE);
if
(!
input_from_PM_Terminal
) {
/* no feedback */
#define
NOFEEDBACK
(
X
) \
WinEnableMenuItem(WinWindowFromID( \
WinQueryWindow(hApp, QW_PARENT), \
FID_MENU), \
X, FALSE)
NOFEEDBACK
(
IDM_SET_GRID
);
NOFEEDBACK
(
IDM_SET_LINLOGY
);
NOFEEDBACK
(
IDM_SET_AUTOSCALE
);
NOFEEDBACK
(
IDM_DO_REPLOT
);
NOFEEDBACK
(
IDM_DO_RELOAD
);
NOFEEDBACK
(
IDM_DO_SENDCOMMAND
);
NOFEEDBACK
(
IDM_SET
);
#undef
NOFEEDBACK
}
/* get details of command-line window */
hSwitch
=
WinQuerySwitchHandle
(
0
,
ppidGnu
);
WinQuerySwitchEntry
(
hSwitch
,
&
swGnu
);
if
(
firstcall
) {
/* set size of this window */
WinSetWindowPos
(
WinQueryWindow
(
hWnd
,
QW_PARENT
),
bPopFront
?
HWND_TOP
:
swGnu
.
hwnd
,
ulShellPos
[
0
],
ulShellPos
[
1
],
ulShellPos
[
2
],
ulShellPos
[
3
],
bShellPos
? (
bPopFront
?
SWP_SIZE
|
SWP_MOVE
|
SWP_SHOW
|
SWP_ACTIVATE
:
SWP_SIZE
|
SWP_MOVE
|
SWP_SHOW
|
SWP_ZORDER
)
: (
bPopFront
?
SWP_SHOW
|
SWP_ACTIVATE
:
SWP_SHOW
|
SWP_ZORDER
));
signal
(
SIGTERM
,
SigHandler
);
firstcall
=
0
;
}
if
(!
bPopFront
)
WinSwitchToProgram
(
hSwitch
);
DosReleaseMutexSem
(
semHpsAccess
);
return
0
;
case
WM_COMMAND
:
return
WmClientCmdProc
(
hWnd
,
message
,
mp1
,
mp2
);
case
WM_CHAR
:
{
/* Note: doc for WM_CHAR is available in PMMSG.INF */
USHORT
usFlag
=
SHORT1FROMMP
(
mp1
);
/* keyboard control codes */
SHORT
key
=
SHORT2FROMMP
(
mp2
);
/* virtual key code */
static
int
last_modifier_mask
=
-99
;
int
modifier_mask
=
((
usFlag
&
KC_SHIFT
) ?
Mod_Shift
:
0
)
| ((
usFlag
&
KC_CTRL
) ?
Mod_Ctrl
:
0
)
| ((
usFlag
&
KC_ALT
) ?
Mod_Alt
:
0
);
if
(
modifier_mask
!=
last_modifier_mask
) {
gp_exec_event
(
GE_modifier
,
mx
,
my
,
modifier_mask
,
0
,
0
);
last_modifier_mask
=
modifier_mask
;
}
#if
0
if
(!(
usFlag
&
KC_SCANCODE
))
return
0L
;
// only modifier mask has changed */
#endif
if
(
usFlag
&
KC_KEYUP
)
return
0L
;
/* ignore key release events */
switch
(
key
) {
case
VK_SPACE
: {
#ifndef
DISABLE_SPACE_RAISES_CONSOLE
/* raise gnuplot's window */
HWND
hw
=
WinQueryWindow
(
swGnu
.
hwnd
,
QW_BOTTOM
);
WinSetFocus
(
HWND_DESKTOP
,
hw
);
WinSendMsg
(
hw
,
message
,
MPFROM2SHORT
((
USHORT
)(
KC_SCANCODE
),
1
),
0
/* MPFROMSHORT(key) */
);
WinSwitchToProgram
(
hSwitch
);
#else
key
=
' '
;
#endif
/* DISABLE_SPACE_RAISES_CONSOLE */
break
;
}
/* remap virtual keys to gnuplot's codes: */
case
VK_BACKSPACE
:
key
=
GP_BackSpace
;
break
;
case
VK_TAB
:
key
=
GP_Tab
;
break
;
case
VK_NEWLINE
:
key
=
GP_Return
;
break
;
case
VK_PAUSE
:
key
=
GP_Pause
;
break
;
case
VK_SCRLLOCK
:
key
=
GP_Scroll_Lock
;
break
;
case
VK_SYSRQ
:
key
=
GP_Sys_Req
;
break
;
case
VK_ESC
:
key
=
GP_Escape
;
break
;
case
VK_DELETE
:
key
=
GP_Delete
;
break
;
case
VK_INSERT
:
key
=
GP_KP_Insert
;
break
;
case
VK_HOME
:
key
=
GP_Home
;
break
;
case
VK_LEFT
:
key
=
GP_Left
;
break
;
case
VK_UP
:
key
=
GP_Up
;
break
;
case
VK_RIGHT
:
key
=
GP_Right
;
break
;
case
VK_DOWN
:
key
=
GP_Down
;
break
;
case
VK_END
:
key
=
GP_End
;
break
;
case
VK_PAGEUP
:
key
=
GP_PageUp
;
break
;
case
VK_PAGEDOWN
:
key
=
GP_PageDown
;
break
;
case
VK_F1
:
key
=
GP_F1
;
break
;
case
VK_F2
:
key
=
GP_F2
;
break
;
case
VK_F3
:
key
=
GP_F3
;
break
;
case
VK_F4
:
key
=
GP_F4
;
break
;
case
VK_F5
:
key
=
GP_F5
;
break
;
case
VK_F6
:
key
=
GP_F6
;
break
;
case
VK_F7
:
key
=
GP_F7
;
break
;
case
VK_F8
:
key
=
GP_F8
;
break
;
case
VK_F9
:
key
=
GP_F9
;
break
;
case
VK_F10
:
key
=
GP_F10
;
break
;
case
VK_F11
:
key
=
GP_F11
;
break
;
case
VK_F12
:
key
=
GP_F12
;
break
;
case
VK_SHIFT
:
case
VK_CTRL
:
case
VK_ALT
:
gp_exec_event
(
GE_modifier
,
mx
,
my
,
modifier_mask
,
0
,
0
);
return
0L
;
default
:
key
=
SHORT1FROMMP
(
mp2
);
/* character key code */
}
/* switch(key) */
if
(
key
)
gp_exec_event
(
GE_keypress
,
mx
,
my
,
key
,
0
,
0
);
return
0L
;
}
/*case(WM_CHAR) */
case
WM_DESTROY
:
if
(
WinSendMsg
(
hWnd
,
WM_USER_PRINT_QBUSY
,
0L
,
0L
)
!=
0L
) {
WinMessageBox
(
HWND_DESKTOP
,
View remainder of file in raw view
Back
|
FazBrowse Home
|
New Git URL