TIP: Click on subject to list as thread! ANSI
echo: c_plusplus
to: STEWART EVANS
from: ANTON S. MAXIMENKO
date: 1997-07-03 03:11:00
subject: c++ help

    Best wishes,  Stewart !
 SE> I've just started C++ at uni this year and was wondering if anyone could
 SE> point me in the right direction to creating a good user interface, all I
 SE> know concerning this stuff is basic cout or printf stuff, other than 
hat
 SE> I dont really have a clue.
    It's better to use video medory direct output. I use it with classes.
    This is example how to create with classes Interface. (Simplified 
rsion)
    Write - function to output with colors to point you need
    BackGround - function to feel desctop
    Class Window - class window
          You can hide window, recall from memory...
    There are a lot of comments, but they are on russian languge. Example 
uses russian words too. But don't bother. This is only example
=== start cut Inter.H ===
   #include 
   #include 
   #include 
   typedef unsigned char disp [25][80][2]; // 3D memory array
   extern disp far* video; // Pointer
   void write (int x, int y, int color, int bkcolor, char * str);
   void back_ground(void);
     class Window
        {
        unsigned int x1, y1, x2, y2, color, b_color;
        char * string;                       // Window name
        int lenth, height;                   // Size
        disp BG_Mem /*FG_Mem*/;
        public:
        Window(unsigned int x, unsigned int y,
                     unsigned int xx, unsigned int yy,
                     unsigned int co, unsigned int bko)
              {
              x1=x;
              y1=y;
              if(yy>=24)
                { y2 = 23; } else y2 = yy;
              if(xx>=78)
                { x2 = 77; } else x2=xx;
              lenth = x2-x1;
              height = y2-y1;
              color = co;
              b_color = bko;
              };  //
        void Draw(void); // Draw window
        void Bk_Remember(void); // Remember window area
        void Mem_Restore(void); // Restore window area
        };
 === final cut Inter.H ===
=== start cut Inter.Cpp ===
#include "inter.h"
disp far* video;
   void write (int x, int y, int color, int bkcolor, char * str)
     {
     int i=0;
     while (str[i] != 0)
       {
       (*video)[y][x+i][0] = str[i];
       (*video)[y][x+i][1] = color+16*bkcolor;
       i++;
       }
     };
/* -------------- */
void back_ground(void)
  {
  for (int i=0; i<=24; i++)
  for (int j=0; j<=79; j++)
    {
     (*video)[i][j][0] = '°';
     (*video)[i][j][1] = 0+7*16;
    }
  for(i=0;i<=79;i++)
    {
    (*video)[24][i][0] = ' ';
    (*video)[24][i][1] = 0+7*16;
    };
  };
            void Window::Draw (void)
          {
    // Drawind window
          for (int i=y1; i<=y2; i++)
          for (int j=x1; j<=x2; j++)
            {
              (*video)[i][j][0] = ' ';
              (*video)[i][j][1] = color+16*b_color;
            };
          for (i=x1; i<=x2; i++)
             {
               (*video)[y1][i][0] = 'Í';
               (*video)[y2][i][0] = 'Í';
             };
          for (i=y1; i<=y2; i++)
             {
               (*video)[i][x1][0] = 'º';
               (*video)[i][x2][0] = 'º';
             };
             (*video)[y2][x1][0] = 'È';
             (*video)[y1][x1][0] = 'É';
             (*video)[y1][x2][0] = '»';
             (*video)[y2][x2][0] = '¼';
          for(i=x1+2; i<=x2+2; i++)
             {
             (*video)[y2+1][i][1] = 6; // Shadow
             }
          for(i=y1+1; i<=y2; i++)
             {
             (*video)[i][x2+1][1] = 6;
             (*video)[i][x2+2][1] = 6;
             };
          };
/* ======================================= */
 void Window::Bk_Remember(void)
     {
     for ( int i=0; i<=height+1; i++)
      for( int j=0; j<=lenth+2; j++)
        {
        BG_Mem[i][j][0] = (*video)[y1+i][x1+j][0];
        BG_Mem[i][j][1] = (*video)[y1+i][x1+j][1];
        };
     };
 void Window::Mem_Restore(void)
 {
     for ( int i=0; i<=height+1; i++)
      for( int j=0; j<=lenth+2; j++)
        {
        (*video)[y1+i][x1+j][0] = BG_Mem[i][j][0] ;
        (*video)[y1+i][x1+j][1] = BG_Mem[i][j][1] ;
        };
     };
=== final cut Inter.Cpp ===
=== start cut Work.Cpp ===
#include "inter.h"
#include "types.h"
#include "conio.h"
 void statist (void)
      {
      if(progons == 0)
        {
        Window W(10,10,60,12,14,4); // Init variable class
        W.Bk_Remember();
        W.Draw();
        write(12,11,14,4,"Œ®¤ã«ïæ¨ï ­¥ ¡ë«  ¯à®¨§¢¥¤¥­ . ˆ ¤ ­­ëå ­¥â :( ");
        getch();
        W.Mem_Restore();
        }
        else stat(Z);
      };
void main ()
  {
  int answ;
   video = (disp far*) 0xB8000000; // IMPORTANT !
   back_ground();
// SKIP
  }; === final cut Work.Cpp ===
                                                     Anton S. Maximenko
--- GoldED/386 2.50+
---------------
* Origin: Night is so beautiful (we need her as we need Day) (2:5020/535.29)

SOURCE: echomail via exec-pc

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.