home *** CD-ROM | disk | FTP | other *** search
/ GEMini Atari / GEMini_Atari_CD-ROM_Walnut_Creek_December_1993.iso / files / program / gempp15b / vdi.h < prev    next >
Encoding:
C/C++ Source or Header  |  1993-10-23  |  11.7 KB  |  319 lines

  1. /////////////////////////////////////////////////////////////////////////////
  2. //
  3. //  VDI
  4. //
  5. //  A VDI is an encapsulation of a VDI [Virtual] Workstation.
  6. //
  7. //  This file is Copyright 1992,1993 by Warwick W. Allison.
  8. //  This file is part of the gem++ library.
  9. //  You are free to copy and modify these sources, provided you acknowledge
  10. //  the origin by retaining this notice, and adhere to the conditions
  11. //  described in the file COPYING.LIB.
  12. //
  13. /////////////////////////////////////////////////////////////////////////////
  14.  
  15. #ifndef VDI_h
  16.  
  17. #define VDI_h
  18.  
  19. #include <bool.h>
  20. #include <stddef.h>
  21. #include <gemfast.h>
  22.  
  23.  
  24. class VDI
  25. {
  26. public:
  27.     VDI();                        // Standard screen VDI.
  28.     VDI(VDI&);                    // Duplicate VDI.
  29.     VDI(const char* metafile);    // Standard metafile (only if GDOS present).
  30.  
  31.     // This is the best I can do at the moment...
  32.     VDI(short* raster);            // Standard size 0=allocate
  33.  
  34.     // ... because these 3 don't work yet.
  35.     VDI(int w, int h);            // (w x h) pixels, standard depth.
  36.     VDI(int w, int h, int depth);    // (w x h) pixels, depth bitplanes.
  37.     VDI(short* raster, int w, int h, int depth);    // Fully user defined.
  38.  
  39.     ~VDI();
  40.  
  41.     int  operator!() { return Handle<0; }    // !v == creation failed
  42.  
  43.     // Global
  44.     void clrwk();
  45.     void updwk();
  46.  
  47.     // Constants
  48.     int MaxX() const                { return WorkOut[0]; }
  49.     int MaxY() const                { return WorkOut[1]; }
  50.     int Width() const                { return WorkOut[0]+1; }
  51.     int Height() const                { return WorkOut[1]+1; }
  52.     bool PreciseScaling() const        { return WorkOut[2]; }
  53.     int PixelWidth() /* microns */ const            { return WorkOut[3]; }
  54.     int PixelHeight() /* microns */ const            { return WorkOut[4]; }
  55.     int NumberOfCharacterHeights()    { return WorkOut[5]; }
  56.     int NumberOfLineTypes()            { return WorkOut[6]; }
  57.     /* don't believe */ int NumberOfLineWidths()        { return WorkOut[7]; }
  58.     int NumberOfMarkerTypes()        { return WorkOut[8]; }
  59.     int NumberOfMarkerSizes()        { return WorkOut[9]; }
  60.     int NumberOfTextFaces()            { return WorkOut[10]; }
  61.     int NumberOfPatterns()            { return WorkOut[11]; }
  62.     int NumberOfHatchStyles()        { return WorkOut[12]; }
  63.     int NumberOfPredefinedColours()    { return WorkOut[13]; }
  64.     int NumberOfAvailableColours()    { return WorkOut[39]; }
  65.     int NumberOfGDPs()                { return WorkOut[14]; }
  66.     int GDP(int i /* 0..9 */)        { return WorkOut[15+i]; }
  67.     int GDPAttribute(int i /* 0..9 */)        { return WorkOut[25+i]; }
  68.     bool Colour()                    { return WorkOut[35]; }
  69.     bool RotateTextWorks()            { return WorkOut[36]; }
  70.     bool FillAreaWorks()            { return WorkOut[37]; }
  71.     bool CellArrayWorks()            { return WorkOut[38]; }
  72.     int NumberOfLocators()            { return WorkOut[40]; }
  73.     int NumberOfValidators()        { return WorkOut[41]; }
  74.     int NumberOfChoosers()            { return WorkOut[42]; }
  75.     int NumberOfStringDevices()        { return WorkOut[43]; }
  76.     int WorkstationType()            { return WorkOut[44]; }
  77.     bool CanOutput()                { return (WorkOut[44]&1)==0; }
  78.     bool CanInput()                    { return (WorkOut[44]&3)>0; }
  79.     bool IsMetafile()                { return WorkOut[44]==4; }
  80.  
  81.     int ScreenType()                { return ExtWorkOut[0]; }
  82.     int NumberOfBackgroundColours()    { return ExtWorkOut[1]; }
  83.     bool TextEffectsSupported()        { return ExtWorkOut[2]; }
  84.     bool ScalableRasters()            { return ExtWorkOut[3]; }
  85.     int NumberOfPlanes()            { return ExtWorkOut[4]; }
  86.     bool TrueColor()                { return ExtWorkOut[5]; }
  87.     int Speed()                        { return ExtWorkOut[6]; }
  88.     bool ContourFillSupported()        { return ExtWorkOut[7]; }
  89.     int CharacterRotationType()        { return ExtWorkOut[8]; }
  90.     int NumberOfWritingModes()        { return ExtWorkOut[9]; }
  91.     int InputModesAvailable()        { return ExtWorkOut[10]; }
  92.     bool TextAlignmentSupported()    { return ExtWorkOut[11]; }
  93.     bool InkingSupported()            { return ExtWorkOut[12]; }
  94.     int RubberbandingSupported()    { return ExtWorkOut[13]; }
  95.     int MaximumVertices()            { return ExtWorkOut[14]; }
  96.     int MaximumIntin()                { return ExtWorkOut[15]; }
  97.     int NumberOfMouseButtons()        { return ExtWorkOut[16]; }
  98.     bool StyledWideLinesSupported()    { return ExtWorkOut[17]; }
  99.     bool WideLinesWriteModesSupported()    { return ExtWorkOut[18]; }
  100.  
  101.     int Charwidth();
  102.     int Charheight();
  103.     int Charcellwidth();
  104.     int Charcellheight();
  105.  
  106.     // Attributes
  107.     int  swr_mode (int mode);
  108.     void s_color (int index, int rgb[]);
  109.     int     sl_type (int style);
  110.     void sl_udsty (int pat);
  111.     int     sl_width (int width);
  112.     int     sl_color (int index);
  113.     void sl_ends (int begstyle, int endstyle);
  114.     int     sm_type (int symbol);
  115.     void sm_height (int height);
  116.     int     sm_color (int index);
  117.     int  st_height (int height, int *charw, int *charh, int *cellw, int *cellh);
  118.     int     st_point (int point, int *charw, int *charh, int *cellw, int *cellh);
  119.     int     st_rotation (int ang);
  120.     int     st_font (int font);
  121.     int     st_color (int index);
  122.     int     st_effects (int effects);
  123.     void st_alignment (int hin, int vin, int *hout, int *vout); 
  124.     int     sf_interior (int style);
  125.     int     sf_fill (int style);
  126.     int     sf_style (int style);
  127.     int     sf_color (int index);
  128.     int     sf_perimeter (int vis);
  129.     void sf_udpat (int pat[], int planes);
  130.  
  131.     int     st_load_fonts (int select);
  132.     void st_unload_fonts (int select);
  133.     void s_clip (int clip_flag, int pxyarray[]);
  134.  
  135.     // Outputs
  136.     void bar (int pxyarray[]);
  137.     void arc (int x, int y, int radius, int begang, int endang); 
  138.     void pieslice (int x, int y, int radius, int begang, int endang);
  139.     void circle (int x, int y, int radius);
  140.     void ellarc (int x, int y, int xrad, int yrad, int begang, int endang);
  141.     void ellpie (int x, int y, int xrad, int yrad, int begang, int endang);
  142.     void ellipse (int x, int y, int xrad, int yrad);
  143.     void rbox (int pxyarray[]);
  144.     void rfbox (int pxyarray[]);
  145.     void justified (int x, int y, char *str, int len, int word_space, int char_space);
  146.     void pline (int count, int pxyarray[]);
  147.     void pmarker (int count, int pxyarray[]);
  148.     int     gtext (int x, int y, char *str);
  149.     void fillarea (int count, int pxyarray[]);
  150.     void cellarray (int pxyarray[], int row_length, int elements, int nrows, int write_mode, int colarray[]);
  151.     void contourfill (int x, int y, int index);
  152.     void r_recfl (int pxyarray[]);
  153.  
  154.     void ro_cpyfm (int mode, int pxyarray[], const MFDB& src, const MFDB& dst);
  155.     void rt_cpyfm (int mode, int pxyarray[], const MFDB& src, const MFDB& dst, int color[]);  
  156.     void r_trnfm (const MFDB& src, const MFDB& dst);
  157.     void get_pixel (int x, int y, int *pel, int *indx); 
  158.  
  159.  
  160.     // Inputs
  161.     int     sin_mode  (int dev, int mode);
  162.     void rq_locator (int x, int y, int *xout, int *yout, int *term);  
  163.     int     sm_locator (int x, int y, int *xout, int *yout, int *term);
  164.  
  165.     void rq_valuator (int in, int *out, int *term);
  166.     void sm_valuator (int in, int *out, int *term, int *status);
  167.     void rq_choice (int cin, int *cout);
  168.     int     sm_choice (int *choice);
  169.     void rq_string (int len, int echo, int echoxy[], char *str);
  170.     int     sm_string (int len, int echo, int echoxy[], char *str);
  171.     void sc_form (int form[]);
  172.     void ex_timv (void *time_addr, void **otime_addr, int *time_conv); 
  173.     void show_c (int reset);
  174.     void hide_c ();
  175.     void q_mouse (int *pstatus, int *x, int *y);
  176.     void ex_butv (void *new_p, void **old);
  177.     void ex_motv (void *new_p, void **old);
  178.     void ex_curv (void *new_p, void **old);
  179.     void q_key_s (int *state);
  180.  
  181.     // Inquiries
  182.     void q_extnd (int flag, int work_out[]);
  183.     int     q_color (int index, int flag, int rgb[]);
  184.     void ql_attribute (int atrib[]);
  185.     void qm_attributes (int atrib[]);
  186.     void qf_attributes (int atrib[]);
  187.     void qt_attributes (int atrib[]);
  188.     void qt_extent (char *str, int extent[]);
  189.     int     qt_width (int chr, int *cw, int *ldelta, int *rdelta);
  190.     int     qt_name (int element, char *name);
  191.     void q_cellarray (int pxyarray[], int row_len, int nrows, int *el_used, int *rows_used, int *status, int color[]);  
  192.     void qin_mode (int dev, int *mode);
  193.     void qt_fontinfo (int *minade, int *maxade, int distances[], int *maxwidth, int effects[]);  
  194.     void qt_font_info (int *minade, int *maxade, int distances[], int *maxwidth, int effects[]);  
  195.  
  196.     // ASCII terminal
  197.     void q_chcells (int *n_rows, int *n_cols);
  198.     void exit_cur ();
  199.     void enter_cur ();
  200.     void curup ();
  201.     void curdown ();
  202.     void curright ();
  203.     void curleft ();
  204.     void curhome ();
  205.     void eeos ();
  206.     void eeol ();
  207.     void s_curaddress (int row, int col);
  208.     void curtext (char *s);
  209.     void rvon ();
  210.     void rvoff ();
  211.     void q_curaddress (int *cur_row, int *cur_col);
  212.     int  q_tabstatus ();
  213.     void hardcopy ();
  214.     void dspcur  (int x, int y);
  215.     void rmcur ();
  216.     void form_adv ();
  217.     void output_window (int *pxyarray);
  218.     void clear_disp_list ();
  219.     void bit_image (const char *filename, int aspect, int x_scale, int y_scale, int h_align, int v_align, int *pxyarray);
  220.     void q_scan (int *g_slice, int *g_page, int *a_slice, int *a_page, int *div_fac);
  221.     void alpha_text (const char *string);
  222.     int  s_palette (int palette);
  223.     void sound (int frequency, int duration);
  224.     int  s_mute (int action);
  225.     void t_resolution (int xres, int yres, int *xset, int *yset);
  226.     void t_axis (int xres, int yres, int *xset, int *yset);
  227.     void t_origin (int xorigin, int yorigin);
  228.     void q_dimensions (int *xdimension, int *ydimension);
  229.     void t_alignment (int dx, int dy);
  230.     void sp_film (int index, int lightness);
  231.     int  qp_filmname (int index, char *name);
  232.     void sc_expose (int state);
  233.     void meta_extents (int min_x, int min_y, int max_x, int max_y);
  234.     void write_meta (int num_intin, int *a_intin, int num_ptsin, int *a_ptsin);
  235.     void m_pagesize (int pgwidth, int pgheight);
  236.     void m_coords (int llx, int lly, int urx, int ury);
  237.     void m_filename (const char *filename);
  238.     void escape2000 (int times);
  239.     unsigned long q_vgdos ();
  240.     void getbitmap_info (int ch, long *advancex, long *advancey, long *xoffset, long *yoffset, int *width, int *height, short **bitmap);
  241.     void qt_f_extent (const char *str, int extent[]);
  242.     void ftext (int x, int y, const char *str);
  243.     //void killoutline (void *component); OBSOLETE
  244.     void getoutline (int ch, int *xyarray, char *bezarray, int maxverts, int *numverts);
  245.     void st_scratch (int mode);
  246.     void st_error (int mode, int *errorvar);
  247.     int  st_arbpt (int point, int *wchar, int *hchar, int *wcell, int *hcell);
  248.     void qt_advance (int ch, int *xadv, int *yadv, int *xrem, int *yrem); 
  249.     void qt_devinfo (int device, int *isdev, char *drivername);
  250.     int  savecache (char *filename);
  251.     int  loadcache (char *filename, int mode);
  252.     int  flushcache ();
  253.     int  st_setsize (int point, int *wchar, int *hchar, int *wcell, int *hcell);
  254.     int  st_skew (int skew);
  255. //    void qt_get_tables (void **gascii, void **style); OBSOLETE
  256.     void qt_get_table (short **map);
  257.     void qt_cachesize (int which_cache, size_t *size);
  258.     int  bez (int count, int *xyarr, char *bezarr, int extent[4], int *npts, int *nmvs);
  259.     int  bez_fill (int count, int *xyarr, char *bezarr, int extent[4], int *npts, int *nmvs);
  260.     int  bez_qual (int percent, int *actual);
  261.     int  bez_on ();
  262.     void bez_off ();
  263.  
  264.     void shtext (int wsid, int x, int y, const char *text, int color, int xshadow, int yshadow);
  265.     void set_app_buff (void **buf_p, int size);
  266.  
  267. // Shorthands...
  268.     // As standard calls, but do not return cell dimensions / other values
  269.     int  st_height(int height);
  270.     int     st_point(int point);
  271.     void st_alignment(int hin, int vin);
  272.  
  273.     // Clip to full area of device
  274.     void clip();
  275.     // Clip to area
  276.     void clip(int x1, int y1, int x2, int y2);
  277.     // No clipping
  278.     void clip_off();
  279.  
  280.  
  281.     // Non Pxyarray versions... (slower, easier)
  282.     void bar(int x1, int y1, int x2, int y2);
  283.     void rbox(int x1, int y1, int x2, int y2);
  284.     void rfbox(int x1, int y1, int x2, int y2);
  285.     void line(int x1, int y1, int x2, int y2);
  286.     void marker(int x, int y);
  287.     void r_recfl(int x1, int y1, int x2, int y2);
  288.  
  289.     // Combine SRC and DST using any logical operators.
  290.     // eg. SRC|DST gives "or" mode.
  291.     const int SRC=3;
  292.     const int DST=5;
  293.  
  294.     // Unary version - destination is this VDI
  295.     void ro_cpyfm(int mode, int pxyarray[], VDI& from);
  296.     void rt_cpyfm(int mode, int pxyarray[], VDI& from, int color[]);  
  297.     void r_trnfm(VDI& from);
  298.  
  299.     // Nullary version - source and destination is this VDI
  300.     void ro_cpyfm(int mode, int pxyarray[]);
  301.     void rt_cpyfm(int mode, int pxyarray[], int color[]);  
  302.     void r_trnfm();
  303.  
  304.     const MFDB& MF() { return mfdb; }
  305.  
  306. private:
  307.     int Handle;
  308.     int* WorkIn;
  309.     int* WorkOut;
  310.     int* ExtWorkOut;
  311.  
  312.     void BeCurrent();
  313.     bool LocalRaster;
  314.  
  315.     MFDB mfdb;
  316. };
  317.  
  318. #endif
  319.