PLplot  5.15.0
pltkwd.h
Go to the documentation of this file.
1 //
2 // Holds system header includes, prototypes of xwin driver
3 // utility functions, and definition of the state structure.
4 //
5 
6 #ifndef __PLTKWD_H__
7 #define __PLTKWD_H__
8 
9 #include "plplot.h"
10 #include "plstrm.h"
11 
12 // System headers
13 
14 #ifndef MAC_TCL
15 #ifndef __MWERKS__
16 #include <sys/types.h>
17 #endif
18 #endif
19 
20 #include <tk.h>
21 #ifdef MAC_TCL
22 #else
23 // These are pulled in by 'tkMacPort.h'
24 #include <X11/Xlib.h>
25 #include <X11/Xutil.h>
26 #include <X11/cursorfont.h>
27 #include <X11/keysym.h>
28 #endif
29 // Specify max number of displays in use
30 
31 #define PLTKDISPLAYS 100
32 
33 // Set constants for dealing with colormap. In brief:
34 //
35 // ccmap When set, turns on custom color map
36 //
37 // See Init_CustomCmap() and Init_DefaultCmap() for more info.
38 // Set ccmap at your own risk -- still under development.
39 //
40 
41 static int plplot_tkwin_ccmap = 0;
42 
43 // One of these holds the display info, shared by all streams on a given
44 // display
45 
46 typedef struct
47 {
48  int nstreams; // Number of streams using display
49  int ixwd; // Specifies tkwDisplay number
50  char *displayName; // Name of X display
51  int screen; // X screen
52  Display *display; // X display
53  Visual *visual; // X Visual
54  GC gcXor; // Graphics context for XOR draws
55  Colormap map; // Colormap
56  unsigned depth; // display depth
57  int color; // Set to 1 if a color output device
58  int ncol0; // Number of cmap 0 colors allocated
59  int ncol1; // Number of cmap 1 colors allocated
60  XColor cmap0[16]; // Color entries for cmap 0
61  XColor cmap1[256]; // Color entries for cmap 1
62  XColor fgcolor; // Foreground color (if grayscale)
63  Tk_Cursor xhair_cursor; // Crosshair cursor
64 } TkwDisplay;
65 
66 // One of these holds the X driver state information
67 
68 typedef struct
69 {
70  TkwDisplay *tkwd; // Pointer to display info
71 
72  Window window; // X window id
73  Pixmap pixmap; // Off-screen pixmap
74  GC gc; // Graphics context
75  XColor curcolor; // Current pen color
76 
77  long event_mask; // Event mask
78  int flags; // 1 = delete, 2 = exit event loop
79  long init_width; // Initial window width
80  long init_height; // Initial window height
81 
82  unsigned width, height, border; // Current window dimensions
83 
84  double xscale_init; // initial pixels/lx (virt. coords)
85  double yscale_init; // initial pixels/ly (virt. coords)
86  double xscale; // as above, but current value
87  double yscale; // (after possible resizing)
88 
89  short xlen, ylen; // Lengths of device coord space
90 
91  int write_to_window; // Set if plotting direct to window
92  int write_to_pixmap; // Set if plotting to pixmap
93 
94  int instr; // Instruction timer
95  int max_instr; // Limit before X server is queried
96 
97  PLGraphicsIn gin; // Graphics input structure
98 
99  int locate_mode; // Set while in locate mode
100  int drawing_xhairs; // Set during xhair draws
101  XPoint xhair_x[2], xhair_y[2]; // Crosshair lines
102 
103  void ( *MasterEH )( PLStream *, XEvent * ); // Master X event handler
104 } TkwDev;
105 
106 //--------------------------------------------------------------------------
107 // Function Prototypes
108 //--------------------------------------------------------------------------
109 
110 #ifdef __cplusplus
111 extern "C" {
112 #endif
113 
114 // Performs basic driver initialization.
115 
116 void
118 
119 // Copies the supplied PLColor to an XColor
120 
121 void
122 PLColor_to_TkColor( PLColor *plcolor, XColor *xcolor );
123 
124 // Copies the supplied XColor to a PLColor
125 
126 void
127 PLColor_from_TkColor( PLColor *plcolor, XColor *xcolor );
128 
129 // Same but also tells me if the color changed
130 int
131 PLColor_from_TkColor_Changed( PLColor *plcolor, XColor *xcolor );
132 
133 void Tkw_StoreColor( PLStream* pls, TkwDisplay* tkwd, XColor* col );
134 
135 // Set background & foreground colors.
136 
137 void
138 pltkwin_setBGFG( PLStream *pls );
139 
140 #ifdef __cplusplus
141 }
142 #endif
143 
144 #endif // __PLTKWD_H__
char * displayName
Definition: pltkwd.h:50
void PLColor_to_TkColor(PLColor *plcolor, XColor *xcolor)
static int plplot_tkwin_ccmap
Definition: pltkwd.h:41
short ylen
Definition: pltkwd.h:89
long event_mask
Definition: pltkwd.h:77
Display * display
Definition: pltkwd.h:52
Tk_Cursor xhair_cursor
Definition: pltkwd.h:63
Visual * visual
Definition: pltkwd.h:53
int height
Definition: plplotter.c:121
int drawing_xhairs
Definition: pltkwd.h:100
int ncol0
Definition: pltkwd.h:58
long init_width
Definition: pltkwd.h:79
#define Tk_Cursor
Definition: plframe.c:80
XColor curcolor
Definition: pltkwd.h:75
double xscale
Definition: pltkwd.h:86
int flags
Definition: pltkwd.h:78
int ncol1
Definition: pltkwd.h:59
XPoint xhair_x[2]
Definition: plplotter.c:181
unsigned depth
Definition: pltkwd.h:56
Pixmap pixmap
Definition: pltkwd.h:73
int color
Definition: pltkwd.h:57
int locate_mode
Definition: pltkwd.h:99
XPoint xhair_y[2]
Definition: plplotter.c:182
void plD_open_tkwin(PLStream *pls)
int nstreams
Definition: pltkwd.h:48
long init_height
Definition: pltkwd.h:80
GC gcXor
Definition: pltkwd.h:54
double xscale_init
Definition: pltkwd.h:84
double yscale
Definition: pltkwd.h:87
int PLColor_from_TkColor_Changed(PLColor *plcolor, XColor *xcolor)
int ixwd
Definition: pltkwd.h:49
double yscale_init
Definition: pltkwd.h:85
int instr
Definition: pltkwd.h:94
GC gc
Definition: pltkwd.h:74
int screen
Definition: pltkwd.h:51
static PLStream * pls[PL_NSTREAMS]
Definition: plcore.h:88
unsigned width
Definition: pltkwd.h:82
XColor fgcolor
Definition: pltkwd.h:62
PLGraphicsIn gin
Definition: pltkwd.h:97
Colormap map
Definition: pltkwd.h:55
int write_to_window
Definition: pltkwd.h:91
TkwDisplay * tkwd
Definition: pltkwd.h:70
void PLColor_from_TkColor(PLColor *plcolor, XColor *xcolor)
Tk_3DBorder border
Definition: plplotter.c:115
int max_instr
Definition: pltkwd.h:95
void pltkwin_setBGFG(PLStream *pls)
Definition: pltkwd.h:68
int write_to_pixmap
Definition: pltkwd.h:92
Window window
Definition: pltkwd.h:72
void Tkw_StoreColor(PLStream *pls, TkwDisplay *tkwd, XColor *col)