home *** CD-ROM | disk | FTP | other *** search
/ Hall of Fame / HallofFameCDROM.cdr / prog2 / boss_ng.lzh / BOSSGEN.TXT < prev    next >
Encoding:
Text File  |  1988-02-15  |  22.3 KB  |  566 lines

  1. !short:General Notes
  2.         ^bGeneral Notes^b
  3.  
  4.         ^bGenindex^b, ^bHelp^b, and ^bPopup^b are support programs and functions for 
  5.         the BOSSDEMO program.  They can, however, serve as valuable aids 
  6.         to you in the creation of help screens and popup menus. The code 
  7.         is provided to demonstrate how the functions in The Window BOSS 
  8.         can be used to create online help screens and popup windows.
  9.  
  10.         Both the C and assembly functions make very heavy use of 
  11.         pointers.  The code contains numerous checks to ensure that 
  12.         memory outside of that in use by the program is not corrupted.  
  13.         If you attempt to do something that would cause memory to be 
  14.         corrupted an error message will appear and your program will 
  15.         exit.  This message will usually say that a bad handle was passed 
  16.         to some function.  You can, if you wish, remove this check by 
  17.         modifying the "wns_err" function in the wn_sup.c file.
  18.  
  19.         Generally speaking, the members of the window control block 
  20.         (refer to windows.h) should not be modified unless you are 
  21.         familiar with how they are used by the various functions.  
  22.  
  23.         Although the routines appear to support the multi page 
  24.         capabilities of the IBM Color Card, actual support of this 
  25.         feature has not been implemented.  Invoking the functions with 
  26.         references to video pages other than 0 might produce interesting 
  27.         but undesired results.  
  28.  
  29.         If you are upgrading from a previous version of The Window BOSS 
  30.         be sure to re-compile and re-link your application.  This will 
  31.         eliminate the possibility of any "unusual" errors due to changes 
  32.         that may have been made to either the functions or the window 
  33.         control block structure.
  34.  
  35.         Several global symbols are used by the various functions:
  36.  
  37.                                  int ^bwn_dmaflg^b;
  38.                                  int ^bwn_sbit^b;
  39.  
  40.              ^bwn_dmaflg^b when TRUE enables direct writes into video ram. 
  41.              This is the default setting and should work in all cases.  
  42.              Setting wn_dmaflg to FALSE will disable these direct writes. 
  43.              When ^bwn_dmaflg^b is FALSE the BIOS video routines are used. 
  44.              This results in slower screen updates.  However, this method 
  45.              does have the advantage of being considered "well behaved" 
  46.              by IBM's Topview, Microsoft's Windows, and DESQ.  
  47.              
  48.              ^bwn_sbit^b controls the window refresh rate on systems with 
  49.              color cards.  When set to SLOW (defined in windows.h) window 
  50.              displays will appear to be painted on the screen rather than 
  51.              flash displayed. This is the default value.  Setting ^bwn_sbit^b 
  52.              to FAST enables flash displays. Artistic use of ^bwn_sbit can 
  53.              give your application that extra visual touch. Experiment!
  54.  
  55.              The best way to manipulate the method by which windows are 
  56.              updated is via the ^bwn_dmode()^b function.  Calling 
  57.              ^bwn_dmode(PAINT)^b causes the image to be painted while 
  58.              ^bwn_dmode(FLASH)^b causes the image to be flash updated. This 
  59.              is the preferred method.  Please keep in mind that windows 
  60.              are always flash updated on monochrome systems. 
  61.  
  62.         From a performance standpoint, the fastest (flicker & snow free) 
  63.         screen updates will occur with ^bwn_dmaflg=TRUE^b and ^bwn_sbit=FAST.^b  
  64.         The key words here are flicker and snow free.  Scrolling speed 
  65.         can be increased with, a proportional increase in flicker 
  66.         (perhaps), by using ^bwn_scroll()^b function to set the scrolling 
  67.         method for the window to BIOS.  This technique will provide the 
  68.         fastest screen updates and scrolling on color systems.
  69.  
  70.         Several of the compilers support a compile time command line 
  71.         parameter that results in structures being byte aligned instead 
  72.         of word aligned.  In all cases, the default (i.e. no command line 
  73.         parameter) option was used to compile the modules in the various 
  74.         libraries.
  75.  
  76.         ^uBorland Turbo C^u users who prefer "The Integrated Environment" 
  77.         over the "Command-Line Version" MUST define the symbol 
  78.         "BORLAND=1". (Select Options, Compiler, Defines and enter 
  79.         "^bBORLAND=1^b"in the dialogue box without quotes and in upper case.
  80.         
  81.         ^uMicrosoft Version 5.0^u libraries were generated using the the 
  82.         "^b/Zl^b" command line parameter. 
  83.  
  84.         ^uMicrosoft QuickC^u users who prefer the programming environment 
  85.         must select EXE as output and use the DOS shell (from the FILES 
  86.         MENU) to test run their application.  Program lists must always 
  87.         be created and include ^bMSQCPE.LIB^b.  We have found the programming 
  88.         environment to be very useful for editing and syntax checking but 
  89.         somewhat limited in other areas (i.e. medium model support only).  
  90.         Additionally, ^bMSCV4=1^b must be defined in the run options dialog 
  91.         box.
  92.  
  93.         Programs such as Wordstar and Lotus change the video mode when 
  94.         they run.  If your system is equipped with a color monitor and 
  95.         your windows are appearing in black and white issue a call to 
  96.         ^bv_smode^b to set the video mode to 3.  Alternatively, you can use 
  97.         the "^uMODE CO80^u" command at DOS level before you run your 
  98.         application.  
  99.  
  100.         PLEASE - Pass along your comments.  The Window BOSS is your tool.  
  101.         If, heaven forbid, you find any logic errors let us know.  We are 
  102.         committed to making The Window BOSS the best price performer 
  103.         available.  Call, write, or if you prefer, you can reach Phil 
  104.         Mongelluzzo via CompuServe [71565,1001].  Fido fans can leave mail 
  105.         on our support BBS at (203)-271-1579. There is no reason to sit, 
  106.         steam, or complain to those who can not provide any real form of 
  107.         support.  Lastly, if you use The Window BOSS, register your copy.  
  108.         The Shareware System will only work if you support it!
  109. !short:Link Assistance
  110.         ^bLinking^b
  111.  
  112.              Simply specify the ?WIN.LIB file that corresponds to the 
  113.              compiler/memory model you are using.  Don't forget to 
  114.              include your compilers runtime library as well.  The 
  115.              following examples should demonstrate the ease of linking.  
  116.  
  117.                   ^uLattice^u
  118.                   link c+hello,hello,,swin+lcm+lc
  119.  
  120.                   ^uComputer Innovations^u
  121.                   link hello,hello,,swin+c86s2s
  122.  
  123.                   ^uDatalight^u
  124.                   link c+hello,hello,hello,swin+nl
  125.  
  126.                   ^uMicrosoft (3 & 4)^u
  127.                   link hello,hello,,swin+slibc
  128.  
  129.                   ^uMicrosoft (5.0)^u
  130.                   link hello,hello,,swin
  131.  
  132.                   ^uMicrosoft QuickC^u
  133.                   link hello,hello,,swin
  134.  
  135.                   ^uBorland^u             
  136.                   tlink /c c0s hello,hello,hello,swin emu maths cs
  137. !short:Tiled Windows
  138.         ^bTiled Windows^b
  139.  
  140.         The Window BOSS fully supports the concept of tiled or 
  141.         overlapping windows.  That is to say that you can have several 
  142.         windows on the screen at the same time and freely access any one 
  143.         of them without having to be concerned with the order in which 
  144.         they were opened or whether or not any other windows overlap the 
  145.         one you wish to access.  The Window BOSS employs the "most 
  146.         recently used is active" concept.  This concept is based on the 
  147.         following:
  148.  
  149.              . The last window referenced is the current active 
  150.                window.  
  151.  
  152.              . The current active window is always the top window 
  153.                tile.
  154.  
  155.         For example, let us assume that you have opened three overlapping 
  156.         windows in the following order; w1, w2, w3. w3 is considered to 
  157.         be the top window tile because it was the last window referenced. 
  158.         If you now reference, or explicitly activate, w2 The Window BOSS 
  159.         will automatically adjust the screen image to insure that w2 is 
  160.         now the top window tile with w3 and w1 being partially hidden by 
  161.         w2.
  162.  
  163.                   ^bBefore^b                   ^bAfter^b
  164.  
  165.                   +----------+             +----------+
  166.                   |  ^bW1^b      |             |^bW1^b       |
  167.                   |  +----------+          |  +----------+
  168.                   |  | ^bW2^b       |          |  | ^uW2^u       |
  169.                   |  |  +------------+     |  |          |----+
  170.                   |  |  | ^uW3^u         |     |  |          | ^bW3^b |
  171.                   |  |  |            |     |  |          |    |
  172.                   |  |  +------------+     |  |          |----+
  173.                   |  |          |          |  |          |
  174.                   |  +----------+          |  +----------+
  175.                   |          |             |          |
  176.                   +----------+             +----------+
  177.  
  178.         It is extremely important to keep in mind that The Window BOSS 
  179.         will automatically activate (bring to the top) the window being 
  180.         referenced.  Keep your screen layouts attractive and uncluttered. 
  181.         This  will  minimize window thrashing which is both annoying  and 
  182.         time consuming.
  183. !short:Function Assistance
  184.         ^bFunction Assistance and notes^b
  185.  
  186.         The Window BOSS's functions fall into two major groups, those 
  187.         that manipulate windows and those that deal with the video or 
  188.         keyboard interface at a relatively low level.  All window 
  189.         manipulation functions being with the prefix "wn_" as in 
  190.         "wn_open", while all video and keyboard based functions begin 
  191.         with "v_" or "_" as in "^bv_getch^b" and "^b_putch^b".  This convention 
  192.         makes it easy to remember where to look when you want to do 
  193.         something.  Additionally, there are several global functions 
  194.         which which begin with "wns_".  These functions, although visible 
  195.         to the outside world, are used internally by The Window BOSS. 
  196.  
  197.         The Window BOSS has been tested on the IBMPC/XT/AT and 3270 PC 
  198.         equipped with monochrome, CGA, and EGA video boards. All 
  199.         functions with the exception of v_sctype(), which does not do 
  200.         well on the 3270 PC, work as specified.
  201.  
  202.         Several functions require an attribute byte.  The attribute byte 
  203.         contains background specific data in the upper 4 bits and 
  204.         foreground specific data in the lower 4 bits.  Color and bit 
  205.         definitions can be found in windows.h. You can use a statement of 
  206.         the form: ^uatrib = ((BLUE << 4) | WHITE);^u to set the attribute to 
  207.         the correct form.  The preceding example would result in a BLUE 
  208.         background with WHITE characters.  The macro v_setatr in 
  209.         windows.h can also be used.
  210.  
  211. !short:Sample Program
  212.         ^bSample program (hello.c)^b
  213.  
  214.                 ^u#include "windows.h"^u
  215.                 main()
  216.                 {
  217.                 ^uWINDOWPTR^u w1;                   /* window handle */
  218.                 int batrib;                     /* border atrib */
  219.                 int watrib;                     /* window atrib */
  220.  
  221.                 /*
  222.                  * Set attributes:
  223.                  *
  224.                  *      border - blue/white box
  225.                  *      window - white background/black letters
  226.                  *
  227.                 */
  228.  
  229.                   batrib = ^uv_setatr^u(BLUE,WHITE,0,0);
  230.                   watrib = ^uv_setatr^u(WHITE,BLACK,0,0);
  231.  
  232.                 /*
  233.                  * Open window at 0,0 - 15 cells wide and 3 cells high
  234.                 */
  235.  
  236.                   w1 = ^uwn_open^u(0,0,0,15,3,watrib,batrib);
  237.                   if(!w1) exit();
  238.  
  239.                 /*
  240.                  * Print the famous string and wait for key to be struck.
  241.                  * Close window on key strike.. exit.
  242.                 */
  243.  
  244.                   ^uwn_printf^u(w1,"Hello World...");
  245.                   ^uv_getch^u();
  246.                   ^uwn_close^u(w1);
  247.                 }
  248.  
  249.                 /* End */
  250. !short:Listing of WINDOWS.H
  251.     ^uListing of WINDOWS.H^u
  252.     
  253. /* #define ^bBORLAND^b 1 */
  254. /* #define ^bMSCV3^b */
  255. /* #define ^bMSCV4^b */
  256. /* #define ^bLC2^b   */
  257. /* #define ^bLC3^b   */
  258. /* #define ^bDLC^b   */
  259. /* #define ^bC86^b   */
  260.  
  261. /*
  262. ** ^uMicrosoft 3.00^u
  263. */
  264.  
  265. #ifdef MSCV3
  266. #define MSC     1
  267. #define MSC4    0
  268. #define DLC     0
  269. #define CI86    0
  270. #define LC2     0
  271. #define LC3     0
  272. #if M_I86SM                             /* small code, small data */
  273. #define SPTR    1
  274. #define LPTR    0
  275. #endif
  276. #if M_I86LM                             /* large code, large data */
  277. #define SPTR    0
  278. #define LPTR    1
  279. #endif
  280. #if M_I86CM                             /* small code, large data */
  281. #define SPTR    0
  282. #define LPTR    1
  283. #endif
  284. #if M_I86MM                             /* large code, small data */
  285. #define SPTR    1
  286. #define LPTR    0
  287. #endif
  288. #define LATTICE 1
  289. #endif
  290.  
  291. /*
  292. ** ^uMicrosoft 4.0, 5.0, QuickC^u
  293. */
  294.  
  295. #ifdef ^bMSCV4^b
  296. #define MSC     1
  297. #define MSC4    1
  298. #define DLC     0
  299. #define CI86    0
  300. #define LC2     0
  301. #define LC3     0
  302. #if ^bM_I86SM^b                             /* small code, small data */
  303. #define SPTR    1
  304. #define LPTR    0
  305. #endif
  306. #if ^bM_I86LM^b                             /* large code, large data */
  307. #define SPTR    0
  308. #define LPTR    1
  309. #endif
  310. #if ^bM_I86CM^b                             /* small code, large data */
  311. #define SPTR    0
  312. #define LPTR    1
  313. #endif
  314. #if ^bM_I86MM^b                             /* large code, small data */
  315. #define SPTR    1
  316. #define LPTR    0
  317. #endif
  318. #define LATTICE 1
  319. #endif
  320.  
  321. /*
  322. ** ^uBORLAND^u
  323. */
  324.  
  325. #ifdef ^bBORLAND^b
  326. #define MSC     1
  327. #define MSC4    1
  328. #define DLC     0
  329. #define CI86    0
  330. #define LC2     0
  331. #define LC3     0
  332. #if^b __SMALL__^b                           /* small code, small data */
  333. #define SPTR    1
  334. #define LPTR    0
  335. #endif
  336. #if ^b__LARGE__^b                           /* large code, large data */
  337. #define SPTR    0
  338. #define LPTR    1
  339. #endif
  340. #if ^b__COMPACT__^b                         /* small code, large data */
  341. #define SPTR    0
  342. #define LPTR    1
  343. #endif
  344. #if ^b__MEDIUM__^b                          /* large code, small data */
  345. #define SPTR    1
  346. #define LPTR    0
  347. #endif
  348. #define ^bLATTICE 1^b
  349. #endif
  350.  
  351. /*
  352. ** ^uComputer Innovations^u
  353. */
  354.  
  355. #ifdef ^bC86^b
  356. #define BORLAND 0
  357. #define MSCV3   0
  358. #define MSCV4   0
  359. #define MSC     0
  360. #define MSC3    0
  361. #define MSC4    0
  362. #define DLC     0
  363. #define CI86    1
  364. #define LC2     0
  365. #define LC3     0
  366. #ifdef^b_C86_BIG^b
  367. #define LPTR    1
  368. #define SPTR    0
  369. #else
  370. #define LPTR    0
  371. #define SPTR    1
  372. #endif
  373. #define LATTICE 0
  374. #endif
  375. #define TRUE    1                       /* truth */
  376. #define FALSE   0                       /* lies */
  377. #define The_BOSS TRUE                   /* convienent equate */
  378.  
  379. #if ^bCI86^b                                /* NB: ****** */
  380. struct WORDREGS {                       /* register layout is */
  381.         unsigned int ax;                /* different from the rest !! */
  382.         unsigned int bx;
  383.         unsigned int cx;
  384.         unsigned int dx;
  385.         unsigned int si;
  386.         unsigned int di;
  387.         unsigned int ds;                /* <= NB */
  388.         unsigned int es;                /* <= NB */
  389.         unsigned int flags;
  390.         };
  391. struct BYTEREGS {
  392.         unsigned char al, ah;
  393.         unsigned char bl, bh;
  394.         unsigned char cl, ch;
  395.         unsigned char dl, dh;
  396.         };
  397. union REGS {
  398.         struct WORDREGS x;
  399.         struct BYTEREGS h;
  400.         };
  401. struct SREGS {
  402.         unsigned int cs;
  403.         unsigned int ss;
  404.         unsigned int ds;
  405.         unsigned int es;
  406.         };
  407. #endif
  408.  
  409.  
  410. #if ^bMSCV3^b | ^bMSCV4^b | ^bBORLAND^b             /* Microsoft C or BORLAND */
  411. #define LINT_ARGS                       /* enforce type checking */
  412. #if ^bBORLAND^b
  413. #include "alloc.h"                      /* Borland */
  414. #else
  415. #include "malloc.h"                     /* for malloc... MSC */
  416. #endif
  417. #else                                   /* if not Microsoft C */
  418. char *malloc(), *calloc();              /* keep everybody happy */
  419. #endif
  420.  
  421. #include "stdio.h"                      /* standard header */
  422. #include "dos.h"                        /* Lattice stuff */
  423. #include "ctype.h"                      /* character conversion stuff */
  424. #if ^bMSC4^b
  425. #include "stdarg.h"                     /* variable arg list marcos */
  426. #endif
  427.  
  428. #define SAVE    TRUE                    /* similar truth */
  429. #define RESTORE FALSE                   /* fibs */
  430. #define PAINT   TRUE                    /* screen update modes */
  431. #define FLASH   FALSE                   /* ditto */
  432. #define REPLACE 1                       /* for flicker free */
  433. #define ERASE   0                       /* scroll w_sapd & w_sapu */
  434. #define FAST    0x01                    /* fast retrace */
  435. #define SLOW    0x08                    /* slow retrace */
  436.  
  437. #define NULPTR  (char *) 0              /* null pointer */
  438. #define BEL     0x07                    /* beep */
  439. #define BS      0x08                    /* backspace */
  440. #define NUL     '\0'                    /* NUL char */
  441. #define ESC     0x1b                    /* Escape */
  442. #define CR      0x0d                    /* carriage return */
  443. #define LF      0x0a                    /* linefeed */
  444. #define DEL     0x7f                    /* delete */
  445. #define NAK     0x15                    /* ^U */
  446. #define ETX     0x03                    /* ^C */
  447. #define CAN     0x18                    /* ^X */
  448. #define Del     0x53                    /* Del key scan code */
  449. #define ECHO    0x8000                  /* echo disable bit */
  450.  
  451. #define BIOS    0x01                    /* BIOS Scrolling */
  452. #define DMAS    0x02                    /* The BOSS's DMA Scrolling */
  453.  
  454. /*
  455. ** ^uExternals^u
  456. */
  457.  
  458. extern int wn_dmaflg;                   /* dma flag */
  459. extern char wn_sbit;                    /* retrace test bit 8 slow, 1 fast */
  460. extern int wn_blank;                    /* vidon & vidoff control flag */
  461. extern int wns_bchars[];                /* box chars */
  462. extern unsigned int wns_mtflg;          /* monitor type flag */
  463. extern int wns_cflag;                   /* close in progress flag */
  464.  
  465. extern struct SREGS wns_srp;            /* for segread */
  466.  
  467. extern unsigned wni_seg[];              /* for wns_push/pop */
  468. extern unsigned wni_off[];              /* ditto */
  469. extern unsigned wni_ptr[];              /* ditto */
  470.  
  471. #define BCUL  wns_bchars[0]             /* some shorthand for later */
  472. #define BCUR  wns_bchars[1]
  473. #define BCTB  wns_bchars[2]
  474. #define BCSD  wns_bchars[3]
  475. #define BCLL  wns_bchars[4]
  476. #define BCLR  wns_bchars[5]
  477.  
  478. /*
  479. ** ^uMisc Stuff^u
  480. */
  481.  
  482. #if ^bLC2^b | ^bLC3^b | ^bDLC^b | ^bCI86^b       
  483. extern unsigned wns_mtype();            /* make everyone happy */
  484. #endif
  485.  
  486. #define WMR   wn->bsize                 /* shorthand */
  487.  
  488. typedef struct ^bwcb^b                      /* Window control block */
  489. {
  490. int ulx,                                /* upper left corner x coordinate */
  491.     uly,                                /* upper left corner y coordinate */
  492.     xsize,                              /* width of window - INSIDE dimension */
  493.     ysize,                              /* height of window -INSIDE dimension */
  494.     ccx,                                /* virtual cursor offset in window */
  495.     ccy,
  496.     style,                              /* attribute to be used in window */
  497.     bstyle,                             /* border attribute */
  498.     bsize;                              /* total border size 0 or 2 only */
  499. char *scrnsave;                         /* pointer to screen save buffer */
  500. int page,                               /* current video page being used */
  501.     oldx,                               /* cursor position when window was */
  502.     oldy,                               /* opened (used for screen restore) */
  503.     wrpflg,                             /* wrap flag */
  504.     synflg;                             /* cursor sync flag */
  505. char *handle;                           /* my own id */
  506.     char *prevptr;                      /* linked list - previous */
  507.     char *nextptr;                      /* linked list - next */
  508.     unsigned tmpseg;                    /* for activate */
  509.     unsigned tmpoff;                    /* ditto */
  510.     int  smeth;                         /* scroll method to use */
  511. } ^bWINDOW,^b ^b*WINDOWPTR;^b
  512.  
  513. extern WINDOWPTR ^bwns_last;^b              /* last window opened */
  514.  
  515. #if ^bMSCV3^b | ^bMSCV4^b | ^bBORLAND^b             /* allow for LINT_ARGS */
  516. #ifndef GENFNS
  517. #include "windows.fns"                  /* enforce type checking */
  518. #endif
  519. #else                                   /* and almost lint args */
  520. struct wcb *wn_open();
  521. struct wcb *wn_move();
  522. struct wcb *wn_save();
  523. char *wn_gets();
  524. #endif
  525.  
  526. #define BLACK   0x00                    /* foreground */
  527. #define RED     0x04                    /* background */
  528. #define GREEN   0x02                    /* colors */
  529. #define YELLOW  0x06                    /* bg << 4 | fg */
  530. #define BLUE    0x01
  531. #define MAGENTA 0x05
  532. #define CYAN    0x03
  533. #define WHITE   0x07
  534. #define BLINK   0x80
  535. #define BOLD    0x08
  536. #define NDISPB  0x00                    /* non display black */
  537. #define NDISPW  0x77                    /* non display white */
  538. #define RVIDEO  0x70                    /* reverse video */
  539. #define UNLINE  0x01                    /* under line (BLUE) */
  540.  
  541. #define NVIDEO  0x07                    /* normal video */
  542. #define NORMAL  0x03                    /* cyan is normal for me */
  543.  
  544. /*
  545. ** ^uDisplay Mode Atributes^u
  546. */
  547.  
  548. #define B4025  0                        /* black & white 40 x 25 */
  549. #define C4025  1                        /* color 40 x 25 */
  550. #define B8025  2                        /* black & white 80 x 25 */
  551. #define C8025  3                        /* color 80 x 25 */
  552. #define C320   4                        /* color graphics 320 x 200 */
  553. #define B320   5                        /* black & white graphics */
  554. #define HIRES  6                        /* B&W hi res 640 * 200 */
  555. #define MONO   7                        /* monocrome 80 x 25 */
  556.  
  557. /*
  558. ** Macro to set attribute byte
  559. */
  560.  
  561. #define ^bv_setatr^b(bg,fg,blink,bold) ((blink|(bg<<4))|(fg|bold))
  562.  
  563. /* End */
  564.  
  565.  
  566.