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