• Main Page
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

pltkwd.h

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

Generated on Wed Oct 12 2011 20:42:23 for PLplot by  doxygen 1.7.1