Mail Archives: djgpp/2000/06/22/06:32:28
From: | highlander88 AT my-deja DOT com
|
Newsgroups: | comp.os.msdos.djgpp
|
Subject: | Vanishing class
|
Date: | Thu, 22 Jun 2000 10:17:39 GMT
|
Organization: | Deja.com - Before you buy.
|
Lines: | 489
|
Message-ID: | <8isp3r$pim$1@nnrp1.deja.com>
|
NNTP-Posting-Host: | 64.56.225.20
|
X-Article-Creation-Date: | Thu Jun 22 10:17:39 2000 GMT
|
X-Http-User-Agent: | Mozilla/4.6 [en] (Win95; I)
|
X-Http-Proxy: | 1.0 x63.deja.com:80 (Squid/1.1.22) for client 64.56.225.20
|
X-MyDeja-Info: | XMYDJUIDhighlander88
|
To: | djgpp AT delorie DOT com
|
DJ-Gateway: | from newsgroup comp.os.msdos.djgpp
|
Reply-To: | djgpp AT delorie DOT com
|
Is there some restriction on instantiating objets of a base class? I
don't remember reading anything about that.
In my testapp.cc I am trying to instantiate an objet of class window and
get an error.
As a workaround I defined new class based on window (pov_window) and
then instantiated that class. The instantiation in just above the
declaration of main.
I had similar problem in the win_mgr.hh when I tried to create pointers
to window in the win_mgr class. It disappeared when I based win_mgr on
window( which is not really desirable unless I can assign a pointer to
the window part of win_mgr to my window_list array.)
I am working in DJGPP.
Can anyone shed any light on this? Pleeeeease.
testapp.cc
**************************
#define COMPILE_GLOBALS 1
#include "key_def.h"
//#include "applib.h"
//#include "conio.h"
#include "stdio.h"
#include "pc.h"
//#include "diskutil.h"
#include "win_mgr.hh"
#define MAX_MENU_ITEMS 10
class pov_window:public window{};
SUBMENU exit_items[] = { { "Exit", 3 ,0, 0, 1, 0, (void (*)())-1L },
{ "", 0, 0, 0, 0, 0, (void (*)())0L } };
SUBMENU no_items[] = { { "", 0, 0, 0, 0, 0, (void (*)())0L } };
MENU main_items[] = { { "Exit", 1, 0, 4, 1, 0, 0, (SUBMENU*)exit_items
},
{ "\0", 0, 0, 0, 0, 0, 0, ( SUBMENU*)no_items } };
extern int menu_master_mode;
/* want to be able to discard
changes. */
char title[] = "Temp Application";
char blank_str[] = "";
int orig_cursor;
system *sys_environment;
win_mgr *win_manager;
sys_colors *system_colors;
pov_window *main_window; /*** window *main_window; does not work
******/
int main( int, char *[] );
void main( int argc, char *argv[] )
{
//WINDOW *app_win;
//struct text_info tx_info;
//int ret_val;
//long color;
int i;
int x;
sys_environment = new system;
win_manager = new win_mgr;
main_window = new pov_window;
x = 3;
i = i + x;
delete main_window;
delete win_manager;
delete sys_environment;
}
void exit_func()
{
}
*************
win_mgr.hh
****************
// class win_manager must do some tasks that windows normaly does. */
/* currently the thing I can think off is keeping list of all windows */
/* and dispatching key presses to the currently active window which */
/* in turn may pass it to its parent ( the DIALOG box ) if it does not
*/
/* process the key. The dialog box*/
//#include "applib.h"
#include "conio.h"
#define NULL 0
typedef struct
{
char text[21];
int row;
int col;
int len;
int active;
int hotkey;
void (*func)();
}SUBMENU;
class MENU
{
public:
char text[21];
int row;
int col;
int len;
int active;
int sub_items;
int hotkey;
SUBMENU *sub_item;
};
/* video buffer definition: provides the information to child windows */
/* (of the each applications main window) about the location of the */
/* temporary buffer used to contain each overlapped or popup window. */
/* All windows of these two types have their own buffer to which all */
/* child windows paint themselves. In other words, if there is a chance
*/
/* that the window will be directly on top of the desktop (window
managers*/
/* window), it must have its own buffer. The buffer is created in the
window*/
/* constructor */
typedef struct
{
char *v_buff;
int width;
}VBUFF_DEF;
class rect
{
public:
int left;
int top;
int right;
int bottom;
};
class sys_colors
{
public:
sys_colors();
long get_color( char* system_color )
{
return ( 1L );
}
struct
{
char *name;
long color;
} all_colors[150];
};
class window:public rect
{
public:
//friend class win_mgr;
window();
window( char *i_title, int i_style, int i_x, int i_y, int i_x_size,
int i_y_size, window *i_parent, MENU *i_menu, int i_instance
);
~window();
void paint( );
VBUFF_DEF *get_vbuff_def( window* = NULL );
char title[81];
int style;
int x;
int y;
int x_size;
int y_size;
window *parent;
MENU *menu;
int instance;
VBUFF_DEF *vbuff_def;
window **children;
int list_size;
int list_items;
};
class system
{
public:
//friend class win_mgr;
system();
struct text_info orig_tx_info;
struct text_info cur_tx_info;
};
class win_mgr :public window
{
public:
win_mgr( );
win_mgr( int table_size );
~win_mgr();
window **window_list;
private:
int list_size;
int list_items;
};
class button: public window
{
public:
int state;
button( char *title, int style, int x, int y, int x_size, int y_size,
window *parent, MENU *menu, int instance );
;void paint();
};
****************************
win_mgr.cc
****************************
#include "win_mgr.hh"
#include "typeinfo"
// this may in the future be the multitasking OS's job.
// for now this will save the entire screen under the application
// keep track of all 'popup'/'parent' windows and paste their contents
on
// the screen. Also dispathes messages to all windows (mouse and
keyboard)
// and provides other system services.
// all windows paint themselves into a buffer axactly the right size
// then the parent is responsible for pasting it into it's buffer and
passing
// it to it's parrent (grrrr).
// The system class may in the future be responsible for loading the
appropriate
// graphics library (text/graphics) depending on the current mode or
// requested mode (after the graphics mode has been set in response to
some
// command line parameter or application ini file .)
extern system *sys_environment;
extern char* blank_str;
system::system()
{
gettextinfo( &orig_tx_info );
memcpy( &cur_tx_info, &orig_tx_info, sizeof orig_tx_info );
// memcpy( &cur_tx_info, &orig_tx_info, size_of ( struct text_info )
);
}
sys_colors::sys_colors()
{
all_colors[0].name = "Desktop";
all_colors[0].color = 0;
all_colors[1].name= "Window";
all_colors[1].color = 1;
}
window::window( char *i_title, int i_style, int i_x, int i_y, int
i_x_size,
int i_y_size, window *i_parent, MENU *i_menu, int i_instance )
{
children = (window**)(new int[256]);
list_size = 256;
list_items = 0;
strcpy( title, i_title );
style = i_style;
x = i_x;
y = i_y;
x_size = i_x_size;
y_size = i_y_size;
parent = i_parent;
menu = i_menu;
instance = i_instance;
if ( parent != NULL )
vbuff_def = parent->get_vbuff_def( );
else
{
vbuff_def = new VBUFF_DEF;
vbuff_def->v_buff = new char[ x_size * y_size * 2];
}
}
window::window()
{
children = (window**)(new int[256]);
list_size = 256;
list_items = 0;
strcpy( title, "" );
style = 0;
x = -1;
y = 0;
x_size = 0;
y_size = 0;
parent = (window*)0;
menu = (MENU*)0;
instance = 0;
// if ( parent != NULL )
// vbuff_def = parent->get_vbuff_def( );
// else
vbuff_def = new VBUFF_DEF;
vbuff_def->v_buff = new char[ x_size * y_size * 2];
}
VBUFF_DEF *window::get_vbuff_def( window* req_parent)
{
// if ( style && WS_POPUP )
/* finish later - get win_managers vbuff_def */
// if ( parent == this )
if ( req_parent == NULL )
{
if ( parent == NULL )
return( vbuff_def );
else
return ( parent->get_vbuff_def( ) );
}
else
{
if ( typeid( req_parent )== typeid( VBUFF_DEF ) )
{
req_parent->get_vbuff_def();
}
else
return( (VBUFF_DEF*)0 );
}
}
void window::paint()
{
return;
}
window::~window()
{
int i;
for ( i = 0; children[i] != NULL; i++ )
{
delete children[i];
}
delete[] (int*)children;
if ( parent == NULL )
{
delete[] vbuff_def->v_buff;
delete vbuff_def;
// vbuff_def = NULL;
}
}
win_mgr::win_mgr( int table_size )//:
//window( (char *) NULL, 0, -1, 0, 0, 0,
// (window *)NULL, (MENU *)NULL, 0 )
{
unsigned int *temp;
window *temp_win;
list_size = table_size;
temp = new unsigned int[table_size];
window_list = (window**)(&temp);
// window_list[0] = new rect;
// window_list[0]= new window( NULL, 0,
temp_win = new window( NULL, 0,
sys_environment->cur_tx_info.winleft,
sys_environment->cur_tx_info.wintop,
sys_environment->cur_tx_info.winright,
sys_environment->cur_tx_info.winbottom,
NULL, NULL, 0 );
window_list[0] = temp_win;
list_items = 1;
}
win_mgr::win_mgr( void )
//window( (char *) NULL, 0, -1, 0, 0, 0,
// (rect *)NULL, (MENU *)NULL, 0 )
{
unsigned int *temp;
window *temp_win;
list_size = 100;
list_items = 0;
// window_list[0] = new window;
temp = new unsigned int[100];
window_list = (window**)(temp);
temp_win = new window( NULL, 0,
sys_environment->cur_tx_info.winleft,
sys_environment->cur_tx_info.wintop,
sys_environment->cur_tx_info.winright,
sys_environment->cur_tx_info.winbottom,
NULL, NULL, 0 );
window_list[0] = temp_win;
list_items = 1;
}
win_mgr::~win_mgr()
{
delete[] (int*)window_list;
window_list = (window**)0;
}
button::button( char *title, int style, int x, int y, int x_size, int
y_size,
window *parent, MENU *menu, int instance ):
window( title, style, x, y, x_size, y_size,
parent, (MENU *)NULL, instance )
{
state = 0;
}
Sent via Deja.com http://www.deja.com/
Before you buy.
- Raw text -