PLplot
5.10.0
|
00001 // 00002 // Holds system header includes, prototypes of xwin driver 00003 // utility functions, and definition of the state structure. 00004 // 00005 00006 #ifndef __PLTKWD_H__ 00007 #define __PLTKWD_H__ 00008 00009 #include "plplot.h" 00010 #include "plstrm.h" 00011 00012 // System headers 00013 00014 #ifndef MAC_TCL 00015 #ifndef __MWERKS__ 00016 #include <sys/types.h> 00017 #endif 00018 #endif 00019 00020 #include <tk.h> 00021 #ifdef MAC_TCL 00022 #else 00023 // These are pulled in by 'tkMacPort.h' 00024 #include <X11/Xlib.h> 00025 #include <X11/Xutil.h> 00026 #include <X11/cursorfont.h> 00027 #include <X11/keysym.h> 00028 #endif 00029 // Specify max number of displays in use 00030 00031 #define PLTKDISPLAYS 100 00032 00033 // Set constants for dealing with colormap. In brief: 00034 // 00035 // ccmap When set, turns on custom color map 00036 // 00037 // See Init_CustomCmap() and Init_DefaultCmap() for more info. 00038 // Set ccmap at your own risk -- still under development. 00039 // 00040 00041 static int plplot_tkwin_ccmap = 0; 00042 00043 // One of these holds the display info, shared by all streams on a given 00044 // display 00045 00046 typedef struct 00047 { 00048 int nstreams; // Number of streams using display 00049 int ixwd; // Specifies tkwDisplay number 00050 char *displayName; // Name of X display 00051 int screen; // X screen 00052 Display *display; // X display 00053 Visual *visual; // X Visual 00054 GC gcXor; // Graphics context for XOR draws 00055 Colormap map; // Colormap 00056 unsigned depth; // display depth 00057 int color; // Set to 1 if a color output device 00058 int ncol0; // Number of cmap 0 colors allocated 00059 int ncol1; // Number of cmap 1 colors allocated 00060 XColor cmap0[16]; // Color entries for cmap 0 00061 XColor cmap1[256]; // Color entries for cmap 1 00062 XColor fgcolor; // Foreground color (if grayscale) 00063 Tk_Cursor xhair_cursor; // Crosshair cursor 00064 } TkwDisplay; 00065 00066 // One of these holds the X driver state information 00067 00068 typedef struct 00069 { 00070 TkwDisplay *tkwd; // Pointer to display info 00071 00072 Window window; // X window id 00073 Pixmap pixmap; // Off-screen pixmap 00074 GC gc; // Graphics context 00075 XColor curcolor; // Current pen color 00076 00077 long event_mask; // Event mask 00078 int flags; // 1 = delete, 2 = exit event loop 00079 long init_width; // Initial window width 00080 long init_height; // Initial window height 00081 00082 unsigned width, height, border; // Current window dimensions 00083 00084 double xscale_init; // initial pixels/lx (virt. coords) 00085 double yscale_init; // initial pixels/ly (virt. coords) 00086 double xscale; // as above, but current value 00087 double yscale; // (after possible resizing) 00088 00089 short xlen, ylen; // Lengths of device coord space 00090 00091 int write_to_window; // Set if plotting direct to window 00092 int write_to_pixmap; // Set if plotting to pixmap 00093 00094 int instr; // Instruction timer 00095 int max_instr; // Limit before X server is queried 00096 00097 PLGraphicsIn gin; // Graphics input structure 00098 00099 int locate_mode; // Set while in locate mode 00100 int drawing_xhairs; // Set during xhair draws 00101 XPoint xhair_x[2], xhair_y[2]; // Crosshair lines 00102 00103 void ( *MasterEH )( PLStream *, XEvent * ); // Master X event handler 00104 } TkwDev; 00105 00106 //-------------------------------------------------------------------------- 00107 // Function Prototypes 00108 //-------------------------------------------------------------------------- 00109 00110 #ifdef __cplusplus 00111 extern "C" { 00112 #endif 00113 00114 // Performs basic driver initialization. 00115 00116 void 00117 plD_open_tkwin( PLStream *pls ); 00118 00119 // Copies the supplied PLColor to an XColor 00120 00121 void 00122 PLColor_to_TkColor( PLColor *plcolor, XColor *xcolor ); 00123 00124 // Copies the supplied XColor to a PLColor 00125 00126 void 00127 PLColor_from_TkColor( PLColor *plcolor, XColor *xcolor ); 00128 00129 // Same but also tells me if the color changed 00130 int 00131 PLColor_from_TkColor_Changed( PLColor *plcolor, XColor *xcolor ); 00132 00133 void Tkw_StoreColor( PLStream* pls, TkwDisplay* tkwd, XColor* col ); 00134 00135 // Set background & foreground colors. 00136 00137 void 00138 pltkwin_setBGFG( PLStream *pls ); 00139 00140 #ifdef __cplusplus 00141 } 00142 #endif 00143 00144 #endif // __PLTKWD_H__