home *** CD-ROM | disk | FTP | other *** search
/ Windoware / WINDOWARE_1_6.iso / source / winobj / winobj.hpp < prev    next >
C/C++ Source or Header  |  1991-01-13  |  6KB  |  135 lines

  1. // Copyright 1991 (c),   Lake View Software
  2. //                       4321 Harborough Rd.
  3. //                       Columbus, OH 43220
  4. // Window Object Library
  5. // WinObj.hpp
  6.  
  7. #if !defined _WINDOW_OBJECTS
  8. #define _WINDOW_OBJECTS true
  9.  
  10. #include <stdio.h>
  11. #include "win.h"
  12.  
  13. typedef int (*valid_func)(void *);
  14.  
  15. extern int w_count;
  16. extern char *Box_char[];
  17. extern int Max_x,Max_y;
  18. extern int get_count;
  19.  
  20. // Get Object
  21. class GetObj {
  22.     public:
  23.         GetObj *Prev_get;
  24.         GetObj *Next_get;
  25.         int y,x;
  26.         int len,dec;
  27.         int type;
  28.         long int *i_obj;
  29.         double *d_obj;
  30.         char *s_obj;
  31.         char style;
  32.         char *picture;
  33.         valid_func valid;
  34. };
  35.  
  36.  
  37. // Window Object
  38. class WinObj  {
  39.     protected:
  40.         int wsc,wsr,wec,wer;
  41.         int width,height;       // Actual screen space available
  42.         int get_attr;
  43.         int win_attr;           // Default attribute for window
  44.         int bor_attr;
  45.         int bor_type;
  46.         char fill_char;         // window fill character
  47.         int title_pos;          // Title positoin
  48.         char *title_str;            // Pointer to title string
  49.         char *wdata_buf;            // Data buffer
  50.         char *wattr_buf;            // attribute buffer
  51.         static WinObj *w_active;
  52.         WinObj *next_win;
  53.         WinObj *prev_win;
  54.         GetObj *Current_get;
  55.         GetObj *Last_get;
  56.         char opened;            // Opened flag
  57.         char hidden;            // Hidden flag
  58.         char needs_display;      // Refresh flag
  59.         char has_border;         //  border flag
  60.         char has_shadow;        // shadow flag
  61.         char scroll_h,scroll_v;            // scroll arrows flag
  62.         unsigned vh,vw;              // Virtual height and width
  63.         unsigned buf_size;           // Window data and attr buf size
  64.         unsigned sx,sy;              // Start x and y for virtual display
  65.         unsigned cur_pos;        // Cursor x and y
  66.         void reset_window();    // reset all flags
  67.         void show_cursor();     // Show cursor in window
  68.         void display();         // Display window contents on top
  69.         int get_realy(int y);   // return screen y for window y
  70.         int get_realx(int x);   // return screen x for window x
  71.         int buf_offset(int y,int x);   // returns buffer offset for window x,y
  72.         void draw_box (int sr,int sc,int er,int ec,int color,int type);
  73.         void draw_border();     // draw the window border
  74.         void show_title();      // display title
  75.         int get_titlestart(int &len);    // get start x of title and length
  76.         int input(GetObj *Obj);        // Get a read from the screen
  77.         int create_get(int y,int x);    // create a new get object
  78.         void show_get (GetObj *Obj);    // Display get on screen with get attr
  79.         void update(int start_pos,int len);         // Update a portion of window
  80.   public:
  81.         ~WinObj() { close();};
  82.         void assign(int v_h=0,int v_w=0);  // remote init
  83.         WinObj(int v_h=0,int v_w=0);
  84.         int set_virtual (int y,int x);          // set virtual size
  85.         int open (int sr,int sc,int er,int ec,
  86.                  int btype=W_DOUBLE,int wattr=_BLACK|LGREY,int battr=_BLACK|LGREY);
  87.         void set_active();      // makes window current window
  88.         void update();                              // Update but don't refresh
  89.         void close();
  90.         int set_attr(int color);        // Returns pervios attribute
  91.         void set_attr(int color,int y,int x,int cnt=1);    // change attr
  92.         void set_fill(char fill);       // set window fill character.
  93.         void change_border(int type,int color=-1);
  94.         void title(char *str,int position=W_CENTER);
  95.         void shadow(int on_off=W_ON);
  96.         void gotoxy(int y=0,int x=0);    // Move cursor in window
  97.         int  pan (int delta_y, int delta_x);  // change pan location
  98.         int set_pan (int y,int x);          // set pan location
  99.         void bprintf(char *,...);        // Print f in window
  100.         void bprintf(int y,int x,char *,...);  // xy bprintf
  101.         void printf(char *,...);        // Print f in window
  102.         void printf(int y,int x,char *,...);  // xy printf
  103.         int center(int y,char *);           // center in virtual window
  104.         void clr_win();             // Clear window
  105.         void clr_eol();                // Clear to end of current line
  106.         void del_line(int line_no);            // Delete current, line pull up
  107.         void ins_line(int line_no);            // Ins new line, push down
  108.         int get(int y, int x, char *str, char *picture=NULL);
  109.         int get(int y, int x, long int &geti,int len=5);
  110.         int get(int y, int x, double &getd, int len=10, int dec=2);
  111.         int get(int y, int x, char *str, char style);
  112.         int valid (int (*func)(void *));                   // Valid function
  113.         int get_key(int echo=W_NOECHO);              // Get single key from keyboard  do not echo
  114.         int read();                 // Read all defined gets
  115.         void clear_gets();            // Clear all defined gets
  116.         void hide();                    // Hide window
  117.         void unhide();                 // Show window
  118.         int move(int y,int x);          // Move the window
  119.         int size(int new_height,int new_width);    // Resize the window
  120.         /* Infromation functions */
  121.         int do_youown(int y,int x,char &ch,char &attr);        // Do you own screen position
  122.         WinObj *who_owns(int y,int x,char &ch,char &attr);
  123.         unsigned max_x(),max_y();       // return maximum virtual x/y coordinates
  124.         int get_scr (int &sr,int &sc,int &er,int &ec);  // get coordinates
  125.         int get_pan(int &y, int &x);         // return current pan coordinates
  126.         int wherexy(int &y, int &x);         // return current cursor pos
  127.         int is_open();                       // open status
  128.         int ret_char(int y,int x);  // get window char
  129.         int ret_attr(int y,int x);  // get window attr
  130.         int text_save(FILE *fp);            // save window text
  131.         int text_retrieve(FILE *fp);        // retrieve text
  132. };
  133.  
  134. #endif
  135.