PLplot  5.10.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
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__