home *** CD-ROM | disk | FTP | other *** search
/ Media Share 9 / MEDIASHARE_09.ISO / cprog / guilib20.zip / GUI.H < prev    next >
C/C++ Source or Header  |  1992-12-18  |  10KB  |  535 lines

  1. #include <dos.h>
  2. #include <string.h>
  3. #include <graphics.h>
  4.  
  5. #define TRUE 1
  6. #define FALSE 0
  7. #define IN 0
  8. #define OUT 1
  9. #define THICK 0
  10. #define THIN 1
  11. #define TEXT 0
  12. #define IMAGE 1
  13.  
  14. #define ALTA 30
  15. #define ALTB 48
  16. #define ALTC 46
  17. #define ALTD 32
  18. #define ALTE 18
  19. #define ALTF 33
  20. #define ALTG 34
  21. #define ALTH 35
  22. #define ALTI 23
  23. #define ALTJ 36
  24. #define ALTK 37
  25. #define ALTL 38
  26. #define ALTM 50
  27. #define ALTN 49
  28. #define ALTO 24
  29. #define ALTP 25
  30. #define ALTQ 16
  31. #define ALTR 19
  32. #define ALTS 31
  33. #define ALTT 20
  34. #define ALTU 22
  35. #define ALTV 47
  36. #define ALTW 17
  37. #define ALTX 45
  38. #define ALTY 21
  39. #define ALTZ 44
  40.  
  41. #define ALT1 120
  42. #define ALT2 121
  43. #define ALT3 122
  44. #define ALT4 123
  45. #define ALT5 124
  46. #define ALT6 125
  47. #define ALT7 126
  48. #define ALT8 127
  49. #define ALT9 128
  50. #define ALT0 129
  51.  
  52. #define ALTMINUS  130
  53. #define ALTPLUS   131
  54.  
  55. //LIB
  56. void dlay(int ticks);
  57. long getticks();
  58. int altkey();
  59. int ctrlkey();
  60. int lshiftkey();
  61. int rshiftkey();
  62. void flushkeys();
  63. unsigned char getvidmode();
  64.  
  65. //MOUSECLASS
  66. class Mcursor {
  67.       int shown;
  68.       int current;
  69.       int xpos;
  70.       int ypos;
  71.       void mouse_interrupt();
  72.       int m1;
  73.       int m2;
  74.       int m3;
  75.       int m4;
  76.       int button;
  77.       int count;
  78.       long tickcount;
  79.       int disabled;
  80.     public:
  81.       int  init();
  82.       void changeto(int);
  83.       void get_status();
  84.       void show();
  85.       void hide();
  86.       void set_hor_bounds(int,int);
  87.       void set_ver_bounds(int,int);
  88.       void Mcursor::conditional_off(int x1,int y1,int x2,int y2);
  89.       void Mcursor::position(int,int);
  90.       int  LBP();
  91.       int  RBP();
  92.       int  getcurrent();
  93.       int  mousex();
  94.       int  mousey();
  95.       int  mx();
  96.       int  my();
  97.       void unarm();
  98.       void arm();
  99.       int  LBDCLK();
  100.       };
  101.  
  102. #define UPARROW 1
  103. #define DOT 2
  104. #define PENCIL 3
  105. #define CROSSHAIR 4
  106. #define ARROW 5
  107. #define FINGER 6
  108. #define POINT 7
  109. #define CLOCK 8
  110. #define DISK 9
  111. #define IBAR 10
  112. #define PAINTCAN 11
  113. #define HAND 12
  114. #define ERASOR 13
  115. #define GUNSIGHT 14
  116. #define SCISSORS 15
  117. #define JAWS 16
  118.  
  119. //INPUT
  120. void beep();
  121. char *strdel(char *,int);
  122. char *strins(char *,int,char);
  123.  
  124. class Gstring {
  125.     protected:
  126.         int x;
  127.         int y;
  128.         int xpos;
  129.         int length;
  130.         int ucase;
  131.         char laststring[81];
  132.         int shown;
  133.         int escape;
  134.         int retrn;
  135.         int tab;
  136.         int uparrow;
  137.         int dnarrow;
  138.         int infgd;
  139.         int inbgd;
  140.         int firstchar;
  141.         int curpos;
  142.         int curson;
  143.         void showcurs();
  144.         void hidecurs();
  145.     public:
  146.         Gstring();
  147.         ~Gstring();
  148.         void init(int,int,int,int);
  149.         void show();
  150.         void input();
  151.         void get_input();
  152.         void get_form_input();
  153.         void get_form_mouse_input();
  154.         char *getstring();
  155.         void reset();
  156.         void preset(char *);
  157.         int isshown();
  158.         void check_for_blink();
  159.         int returnhit();
  160.         int escapehit();
  161.         int uparrowhit();
  162.         int dnarrowhit();
  163.         int tabhit();
  164.         void setincolors(int,int);
  165.         int hit();
  166.         };
  167.  
  168. //GROBJECT
  169. class Point
  170. {
  171.     protected:
  172.         int x,y,color;
  173.         viewporttype vref;
  174.     public:
  175.         Point();
  176.         void move(int ptx,int pty);
  177.         virtual void draw();
  178.         void create(int ptx,int pty,int c);
  179.         void restoreviewport();
  180.         void Setcolor(int c);
  181.         virtual void setloc(int ptx,int pty);
  182.         virtual void erase();
  183.         int Getcolor();
  184.         int Getx();
  185.         int Gety();
  186.         };
  187.  
  188. //************************************************************************
  189.  
  190. class Colorbutton:public Point
  191. {
  192.     protected:
  193.         int color;
  194.         int width;
  195.         int height;
  196.     public:
  197.         void init(int,int,int,int,int);
  198.         void show(int);
  199.         int  clicked();
  200.         int     hit();
  201.         int getcolor();
  202.         };
  203.  
  204. //************************************************************************
  205.  
  206. class Closebutton:public Colorbutton
  207. {
  208.     public:
  209.         void  show();
  210.         };
  211.  
  212. //************************************************************************
  213.  
  214. class Icon:public Point
  215. {
  216.     protected:
  217.         int state;
  218.     public:
  219.         void far *picture;
  220.         Icon();
  221.         ~Icon();
  222.         void init(int,int,char*);
  223.         void show();
  224.         void choose();
  225.         int hit();
  226.         int clicked();
  227.         int ispressed();
  228.         };
  229.  
  230. //************************************************************************
  231.  
  232. class Gcheckbox:public Point
  233. {
  234.     protected:
  235.         int checked;
  236.         char *desc;
  237.         int length;
  238.     public:
  239.         Gcheckbox();
  240.         ~Gcheckbox();
  241.         void init(int,int,char *);
  242.         void show();
  243.         void check();
  244.         void uncheck();
  245.         int is_checked();
  246.         int hit();
  247.         };
  248.  
  249. //************************************************************************
  250.  
  251. class Gradio:public Gcheckbox
  252. {
  253.     public:
  254.         void show();
  255.         void check();
  256.         void uncheck();
  257.         };
  258.  
  259. //************************************************************************
  260.  
  261. class Acticon:public Icon
  262. {
  263.     protected:
  264.         void *picture[32];
  265.         int state;
  266.         int numpix;
  267.     public:
  268.         Acticon();
  269.         ~Acticon();
  270.         void init(int,int,char*);
  271.         void show(int);
  272.         void choose();
  273.         int ispressed();
  274.         void animate(int);
  275.         void backforth(int);
  276.         };
  277.  
  278. //************************************************************************
  279.  
  280. class Button:public Point
  281. {
  282.     protected:
  283.         int state,sizex,sizey;
  284.         char btntxt[40];
  285.         int  file_text;
  286.         void far *picture;
  287.         void getpic(char*);
  288.     public:
  289.         Button();
  290.         ~Button();
  291.         virtual void show();
  292.         virtual void press();
  293.         void init(int ptx,int pty,char* text,int);
  294.         int hit();
  295.         int pressed();
  296.         };
  297.  
  298. //************************************************************************
  299.  
  300. class Bitmap:public Point
  301. {
  302.     protected:
  303.         int sizex,sizey;
  304.         int size;
  305.         void far *picture;
  306.         int shown;
  307.         int clickcount;
  308.         long last_tick;
  309.     public:
  310.         Bitmap();
  311.         ~Bitmap();
  312.         void init(int,int);
  313.         void load(char *);
  314.         void save(char *);
  315.         void show_XOR();
  316.         void show_COPY();
  317.         void show_AND();
  318.         void show_OR();
  319.         void show_NOT();
  320.         int is_shown();
  321.         void hide();
  322.         void moveto(int,int);
  323.         int capture(int,int,int,int);
  324.         int hit();
  325.         int clicked();
  326.         int LBDCLK();
  327.         int LBSCLK();
  328.         int xsize();
  329.         int ysize();
  330.         int bitmapx();
  331.         int bitmapy();
  332.         void changexy(int,int);
  333.         };
  334.  
  335. //************************************************************************
  336.  
  337. class Panel:public Point
  338. {
  339.     protected:
  340.         int w;
  341.         int h;
  342.         int in_or_out;
  343.         int thick_or_thin;
  344.     public:
  345.         Panel();
  346.         ~Panel();
  347.         virtual void show();
  348.         void init(int,int,int,int,int,int);
  349.         };
  350.  
  351. //************************************************************************
  352.  
  353. class Bevel:public Point
  354. {
  355.     private:
  356.         int w;
  357.         int h;
  358.         int thick_or_thin;
  359.         Panel outerbevel;
  360.         Panel innerbevel;
  361.     public:
  362.         void init(int,int,int,int,int);
  363.         virtual void show();
  364.         };
  365.  
  366. //************************************************************************
  367.  
  368. class OKbox:public Point
  369. {
  370.     protected:
  371.         Button OKbutton;
  372.         Button ESCbutton;
  373.         Panel panel;
  374.         char text[90];
  375.         void *screen;
  376.         int OKorNOT;
  377.     public:
  378.         OKbox();
  379.         ~OKbox();
  380.         void init(int,int,char*);
  381.         int show();
  382.         };
  383.  
  384. //************************************************************************
  385.  
  386. class Gwindow:public Point
  387. {
  388.     protected:
  389.         Closebutton closebox;
  390.         int            w,h;
  391.         int            fgd,bgd;
  392.         int            tfgd,tbgd;
  393.         int            active;
  394.         char        title[48];
  395.         void        *beneath;
  396.     public:
  397.         Gwindow();
  398.         ~Gwindow();
  399.         void init(int,int,int,int,int,int,int,int,char *);
  400.         void show();
  401.         void redraw();
  402.         void hide();
  403.         int     closeboxhit();
  404.         int  sizecornerhit();
  405.         int  titlebarhit();
  406.         void resize();
  407.         void move();
  408.         int write_to_disk();
  409.         int read_from_disk();
  410.         int totalGwindows();
  411.         };
  412.  
  413. //GMENU
  414. typedef char gitemarray[80][10];
  415.  
  416.  
  417. class Gmenu {
  418.     protected:
  419.         int on;
  420.         int x,y,w,h;
  421.         int num;
  422.         gitemarray gitems;
  423.         int menuchoice;
  424.         int oldbarx,oldbary;
  425.         void *ptr;
  426.         void *menubar;
  427.     public:
  428.         Gmenu();
  429.         ~Gmenu();
  430.         void init(int xloc,int yloc,int numentries,gitemarray gitem);
  431.         int show();
  432.         void hide();
  433.         int isshown();
  434.         };
  435.  
  436. //**************************************************************************
  437.  
  438. class Gmenubutton {
  439.     protected:
  440.         int on;
  441.         int x,y;
  442.         int offfgd,offbgd;
  443.         int onfgd,onbgd;
  444.         char id[20];
  445.     public:
  446.         Gmenubutton();
  447.         ~Gmenubutton();
  448.         void init(int xloc,int yloc,int ffgd,int fbgd,
  449.         int nfgd,int nbgd,char txt[20]);
  450.         void show();
  451.         void press();
  452.         int hit();
  453.         };
  454.  
  455. //GPRINT
  456. void gprintf(int xloc,int yloc,char *fmt,...);
  457. void gprintc(int xloc, int yloc, char *fmt,...);
  458. void gprintxy(int xloc,int yloc,char *fmt,...);
  459.  
  460. //SOUNDQ
  461. #define TimerTick 0x8
  462. #define noisemax 8192
  463. #define ON 1
  464. #define OFF 0
  465.  
  466. #define C 523
  467. #define CS 554
  468. #define D 587
  469. #define DS 622
  470. #define E 659
  471. #define F 698
  472. #define FS 740
  473. #define G 784
  474. #define GS 831
  475. #define A 880
  476. #define AS 932
  477. #define B 988
  478. #define C1 1046
  479.  
  480. #define SN 32
  481. #define EN 63
  482. #define QN 125
  483. #define HN 250
  484. #define WN 500
  485.  
  486. #define ENT 20
  487. #define QNT 41
  488. #define HNT 83
  489.  
  490. #define BN 30000,5
  491. #define SR 30000,32
  492. #define ER 30000,63
  493. #define QR 30000,125
  494. #define HR 30000,250
  495. #define WR 30000,500
  496. #define NM 30000,1
  497.  
  498. class SoundQ{
  499.     protected:
  500.         float speed_factor;
  501.     public:
  502.         SoundQ();
  503.         ~SoundQ();
  504.         void play(int,int);
  505.         void adjust_speed(float);
  506.         };
  507.  
  508. typedef struct
  509. {
  510.   int duration;
  511.   int freq;
  512. } noise;
  513.  
  514. void empty_sound_queue();
  515. void init_sound(void);
  516. void restore_sound(void);
  517. int submit_sound(int freq,int delay);
  518. void interrupt soundsystem(...);
  519.  
  520. //SCREEN
  521. extern "C" void     _Cdecl vga256_driver();
  522.  
  523. class Screen {
  524.     protected:
  525.         static int huge alwayszero();
  526.     public:
  527.         Screen();
  528.         ~Screen();
  529.         int VGA_480_16();
  530.         int VGA_350_16();
  531.         int VGA_200_16();
  532.         int VGA_200_256();
  533.         void fill(int);
  534.         };
  535.