home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c100 / 1.ddi / SNAV0111.ZIP / SNAV1.HPP < prev    next >
Encoding:
C/C++ Source or Header  |  1990-04-16  |  4.6 KB  |  128 lines

  1. //          ┌───────┐
  2. //    ─────────>│ AVNER │
  3. //    ─────────>│  BEN  │──────> Software Engineering Method
  4. //          └───────┘
  5. //    10 Dov-Hoz st. Tel-Aviv 63416 Israel tel. 972-3-221535
  6.  
  7. // The Screen NAVigator, ver 1.10 April 1990
  8. // Copyright (c) 1989 by Avner Ben
  9. // Snav is not, and never was, free software.
  10. // for conditions for use refer to file "copyrigh.txt"
  11.  
  12. // The Screen Navigator is an object-oriented device-independent
  13. // character-graphics driver package, written in the C++ language,
  14. // distributed in the form of C++ source code.
  15. // For further information refer to the documentation files.
  16.  
  17. // The user may not omit this text, from the beginning of the file, to
  18. // the line of asterisks below.
  19.  
  20. /***************************************************************************/
  21.  
  22. // package nucleus part 2 - headers
  23. // This file defines the "computer-alphabet" object, and offers an
  24. // extended-ASCII implementation, as on the IBM-PC.
  25. // for data-structure logic, refer to file "article".
  26.  
  27. // History:
  28. // 28.7.89  avner ben coded.
  29. /////// snav v1.0
  30. // 25.10.89 avner ben classified.
  31. /////// snav v1.1
  32. // 5.3.90  avner ben - C++ v2.0 upgrade.
  33.  
  34. // Site history (of this copy):
  35. // __.__.__ ____________ : __________________.
  36.  
  37. #ifndef SNAV1_H
  38. #define SNAV1_H
  39.  
  40. #ifndef SNAV0_H
  41. #include "snav0.hpp"
  42. #endif
  43.  
  44. class computer_alphabet
  45. {
  46.     private :
  47.         char    *name;
  48.         int    numchars;    // including zero
  49.         int    *grafc;     // array of [numchars][2]
  50.         int    index[16][16];    // access by weight:intersection
  51.  
  52.     public :
  53.         computer_alphabet(char *name, int bufsize, int *data);
  54.         // bufsize: number of characters supported, including bin zero
  55.         // data: ptr to zero-terminated integer array, arranged in
  56.         // successions of four integers corresponding to:
  57.         //    unsigned character (possibly ascii) num,
  58.         //    character's intersection(),
  59.         //    character's weight_d.y(),
  60.         //    character's weight_d.x();
  61.         ~computer_alphabet(void);
  62.         // free internal character storage
  63.         void poke_c(char c, const intersection &avdir, const weight_d &wgt);
  64.         // modify default character attributes, updating index
  65.  
  66.         // access method services:
  67.         intersection cdir(char inc)
  68.         // retrieve direction set defined for character (temporary result)
  69.         // cdir('|')==>[Up,Down]
  70.             { return intersection(*(grafc+(unsigned char)inc*2)); }
  71.         weight_d cweight(char inc)
  72.         // retrieve width of char in dimension (temporary result)
  73.         // cweight('│')==>0:1
  74.             { return weight_d(*(grafc+(unsigned char)inc*2+1)); }
  75.         char get_c(const intersection &avdir, weight_d wgt);
  76.         // retrieve character by attributes, or a close match
  77.         // get_c(RTDIR+LTDIR+UPDIR,1:1)==>'┴'
  78.         char translate(char c, weight_d wgt);
  79.         // translate character to target width, as close as possible
  80.         // translate('┴',2:1)==>'╧'
  81.  
  82.         // character connectivity
  83.         boolean ccont(char cfrom, char cto, const direction &dirfrom);
  84.         // test if two characters connect in a direction.
  85.         // ccont('├','-',RTDIR)==>TRUE
  86.         // ccont('├','-',LTDIR)==>FALSE
  87.         char carrw(char *env, direction dir, weight_d wgt, int len,
  88.          int pos, boolean directed=FALSE);
  89.         //  draw one character within an arc.
  90.         //  env:    "environment" sorrownding current page position,
  91.         //        ordered: current char, then neighbours, arranged
  92.         //        in (direction++ order)
  93.         //  dir:    direction of arc being charted.
  94.         //  wgt:    arc width.
  95.         //  len:    total arc length planned.
  96.         //  pos:    current position from arc start (starting at 1).
  97.         //  directed:    if true, last char (pos==len) is an arrowhead.
  98.         char *cearrw(char *env, direction dir, weight_d wgt, int len,
  99.          int pos, boolean directed);
  100.         // version of carrw that trims exess from the environment
  101.         // to make some procedures use this instead, #define ENV_MODIFY
  102.         char ctrim(char c, const direction &extradir);
  103.         // trim char in protruding direction, if present
  104.         // ctrim('├',RTDIR)==>'│'
  105.         char celong(char c, const direction &elongdir);
  106.         // elongate char in this direction, if not already present
  107.         // celong('│',RTDIR)==>'├'
  108.  
  109.         //miscelanous:
  110.         int list(FILE *outf);
  111.         // print the index (originally intended for debugging)
  112.         void inverse(const axis &dim);
  113.         // invert the semigraphic alphabet on axis (e.g. latin=>semitic)
  114. };
  115.  
  116. #ifndef SNAV_C
  117. extern computer_alphabet *alph;
  118. // system defined default alphabet (ascii_pc).
  119. // all your inquiries to the current alphabet object must
  120. // be of the type: alph->function(args);
  121. // if you overload your own alphabet, make sure to preserve this address!
  122. extern int ascii_pc_data[];
  123. // in-memory file to pass to the constructor of an ascii_pc type alphabet.
  124. // Used by system to initialize the default alphabet.
  125. #endif
  126.  
  127. #endif
  128.