Mail Archives: djgpp/1998/12/23/15:15:10
--------------4EBE1F8BB5B17BE4858E8E51
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
You see, I'm trying to write a fast svga GUI for DJGPP which will be up as freeware
and also will take part in a game I'm writing.
new_window creates a new window and adds its information to a linked list of
windows
the struct is..
#define WINHANDLE long
typedef struct type_winnode {
int Width,Height; //Width and Height of Window(in Pixels)
int X,Y; //X,Y Location;
int active; //Active or Inactive State
int depth; //Window Depth
unsigned char *ViewPort; //Windows Viewing Section
long *YTbl; //ViewPort Y-address Table
void (*funct)(); //Function Called
WINHANDLE WinHandle; //Window Handle
type_winnode *next; //Pointer To next Window in List
};
class winclass {
private:
type_winnode node; //Base window Node
WINHANDLE ActiveNode; //Current Active Window
long Number_Of_Nodes; //Number of Windows
long Handle_Count; //Handle Counter
long Curr_Depth; //Curent Depth
void sort_windows(WINHANDLE *SortList); //Sorts The Windows
void Activate(WINHANDLE Handle);
void DeActivate(WINHANDLE Handle);
public:
winclass(void);
~winclass(void);
WINHANDLE new_window(void);
void delete_window(WINHANDLE Handle);
type_winnode *window_info(WINHANDLE Handle);
WINHANDLE Create_Window(int x,int y,int xSize,int ySize,void
(*WinFunct)());
int wMouse_X(WINHANDLE Handle);
int wMouse_Y(WINHANDLE Handle);
int wMouse_S(WINHANDLE Handle);
void Display(void);
};
In another cpp file
class apiclass {
private:
btnclass BControl;
msgclass MControl;
winclass WControl;
public:
WINHANDLE new_window(int x,int y,int xSize,int ySize,void
(*WinFunct)());
BTNHANDLE new_button(int x,int y,int width, int height,int delay,void
(*Afunct)(),void (*Sfunct)());
MSGHANDLE new_message(int x,int y,char *msg,int width,int height);
void del_window(WINHANDLE Handle);
void del_button(BTNHANDLE Handle);
void del_message(MSGHANDLE Handle);
type_winnode *info_window(WINHANDLE Handle);
type_btnnode *info_button(BTNHANDLE Handle);
type_msgnode *info_message(MSGHANDLE Handle);
void display_windows(void);
void display_buttons(BTNHANDLE Handle,WINHANDLE wHandle);
void display_message(type_msgnode *Msg);
int window_mouse_x_position(WINHANDLE Handle);
int window_mouse_y_position(WINHANDLE Handle);
void input_message(type_msgnode *Msg);
void load_gui_font(char *FileName);
};
WINHANDLE apiclass::new_window(int x,int y,int xSize,int ySize,void
(*WinFunct)()) {
return(WControl.Create_Window(x,y,xSize,ySize,WinFunct));
}
BTNHANDLE apiclass::new_button(int x,int y,int width, int height,int
delay,void (*Afunct)(),void(*Sfunct)()) {
return(BControl.new_btn(x,y,width,height,delay,Afunct,Sfunct));
}
MSGHANDLE apiclass::new_message(int x,int y,char *msg,int width,int height) {
return(MControl.New_Msg(x,y,msg,width,height));
}
void apiclass::del_window(WINHANDLE Handle) {
WControl.delete_window(Handle);
}
void apiclass::del_button(BTNHANDLE Handle) {
BControl.delete_btn(Handle);
}
void apiclass::del_message(MSGHANDLE Handle) {
MControl.Delete_Msg(Handle);
}
type_winnode * apiclass::info_window(WINHANDLE Handle) {
return(WControl.window_info(Handle));
}
type_btnnode * apiclass::info_button(BTNHANDLE Handle) {
return(BControl.btn_info(Handle));
}
type_msgnode * apiclass::info_message(MSGHANDLE Handle) {
return(MControl.Msg_Info(Handle));
}
void apiclass::display_windows(void) {
WControl.Display();
}
void apiclass::display_buttons(BTNHANDLE Handle,WINHANDLE wHandle) {
BControl.display_btn(Handle,WControl.window_info(wHandle));
}
void apiclass::display_message(type_msgnode *Msg) {
MControl.FxText(Msg);
}
int apiclass::window_mouse_x_position(WINHANDLE Handle) {
return(WControl.wMouse_X(Handle));
}
int apiclass::window_mouse_y_position(WINHANDLE Handle) {
return(WControl.wMouse_Y(Handle));
}
void apiclass::input_message(type_msgnode *Msg) {
MControl.FxInput(Msg);
}
void apiclass::load_gui_font(char *FileName) {
MControl.LoadFont(FileName);
}
The reason why new_window is just a regualar function pointer is because then it is
more general and will hopefully work with many different classes.
Any suggestions to make it work without "castrationg" class functions? I was
thinking of makeing a global buffer and passing the private members of the desired
class in it to get around the need of using or passing a class function to the GUI
interface (such as ne_window). That would just defete the purpous of having
classes though, it could get really unorginized.
Thanks,
Ardy
--------------4EBE1F8BB5B17BE4858E8E51
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit
<HTML>
You see, I'm trying to write a fast svga GUI for DJGPP which will be up
as freeware and also will take part in a game I'm writing.
<BR> new_window creates a new window and adds its information
to a linked list of windows
<BR>the struct is..
<UL><B><I><FONT SIZE=-1>#define WINHANDLE
long</FONT></I></B>
<BR><B><I><FONT SIZE=-1>typedef struct type_winnode {</FONT></I></B>
<BR><B><I><FONT SIZE=-1> int Width,Height;
//Width and Height of Window(in Pixels)</FONT></I></B>
<BR><B><I><FONT SIZE=-1> int X,Y;
//X,Y Location;</FONT></I></B>
<BR><B><I><FONT SIZE=-1> int active;
//Active or Inactive State</FONT></I></B>
<BR><B><I><FONT SIZE=-1> int depth;
//Window Depth</FONT></I></B>
<BR><B><I><FONT SIZE=-1> unsigned char *ViewPort;
//Windows Viewing Section</FONT></I></B>
<BR><B><I><FONT SIZE=-1> long *YTbl;
//ViewPort Y-address Table</FONT></I></B>
<BR><B><I><FONT SIZE=-1> void (*funct)();
//Function Called</FONT></I></B>
<BR><B><I><FONT SIZE=-1> WINHANDLE WinHandle;
//Window Handle</FONT></I></B>
<BR><B><I><FONT SIZE=-1> type_winnode *next;
//Pointer To next Window in List</FONT></I></B>
<BR><B><I><FONT SIZE=-1>};</FONT></I></B>
<BR><B><I><FONT SIZE=-1>class winclass {</FONT></I></B>
<BR><B><I><FONT SIZE=-1> private:</FONT></I></B>
<BR><B><I><FONT SIZE=-1> type_winnode node;
//Base window Node</FONT></I></B>
<BR><B><I><FONT SIZE=-1> WINHANDLE ActiveNode;
//Current Active Window</FONT></I></B>
<BR><B><I><FONT SIZE=-1> long Number_Of_Nodes;
//Number of Windows</FONT></I></B>
<BR><B><I><FONT SIZE=-1> long Handle_Count;
//Handle Counter</FONT></I></B>
<BR><B><I><FONT SIZE=-1> long Curr_Depth;
//Curent Depth</FONT></I></B>
<BR><B><I><FONT SIZE=-1> void sort_windows(WINHANDLE
*SortList); //Sorts The Windows</FONT></I></B>
<BR><B><I><FONT SIZE=-1> void Activate(WINHANDLE
Handle);</FONT></I></B>
<BR><B><I><FONT SIZE=-1> void DeActivate(WINHANDLE
Handle);</FONT></I></B>
<BR><B><I><FONT SIZE=-1> public:</FONT></I></B>
<BR><B><I><FONT SIZE=-1> winclass(void);</FONT></I></B>
<BR><B><I><FONT SIZE=-1> ~winclass(void);</FONT></I></B>
<BR><B><I><FONT SIZE=-1> WINHANDLE new_window(void);</FONT></I></B>
<BR><B><I><FONT SIZE=-1> void delete_window(WINHANDLE
Handle);</FONT></I></B>
<BR><B><I><FONT SIZE=-1> type_winnode *window_info(WINHANDLE
Handle);</FONT></I></B>
<BR><B><I><FONT SIZE=-1> WINHANDLE Create_Window(int
x,int y,int xSize,int ySize,void (*WinFunct)());</FONT></I></B>
<BR><B><I><FONT SIZE=-1> int wMouse_X(WINHANDLE
Handle);</FONT></I></B>
<BR><B><I><FONT SIZE=-1> int wMouse_Y(WINHANDLE
Handle);</FONT></I></B>
<BR><B><I><FONT SIZE=-1> int wMouse_S(WINHANDLE
Handle);</FONT></I></B>
<BR><B><I><FONT SIZE=-1> void Display(void);</FONT></I></B>
<BR><B><I><FONT SIZE=-1>}</FONT></I></B>;
<BR>In another cpp file
<BR><B><I><FONT SIZE=-1>class apiclass {</FONT></I></B>
<BR><B><I><FONT SIZE=-1> private:</FONT></I></B>
<BR><B><I><FONT SIZE=-1> btnclass BControl;</FONT></I></B>
<BR><B><I><FONT SIZE=-1> msgclass MControl;</FONT></I></B>
<BR><B><I><FONT SIZE=-1> winclass WControl;</FONT></I></B>
<BR><B><I><FONT SIZE=-1> public:</FONT></I></B>
<BR><B><I><FONT SIZE=-1> WINHANDLE new_window(int
x,int y,int xSize,int ySize,void (*WinFunct)());</FONT></I></B>
<BR><B><I><FONT SIZE=-1> BTNHANDLE new_button(int
x,int y,int width, int height,int delay,void (*Afunct)(),void (*Sfunct)());</FONT></I></B>
<BR><B><I><FONT SIZE=-1> MSGHANDLE new_message(int
x,int y,char *msg,int width,int height);</FONT></I></B>
<BR><B><I><FONT SIZE=-1> void del_window(WINHANDLE
Handle);</FONT></I></B>
<BR><B><I><FONT SIZE=-1> void del_button(BTNHANDLE
Handle);</FONT></I></B>
<BR><B><I><FONT SIZE=-1> void del_message(MSGHANDLE
Handle);</FONT></I></B>
<BR><B><I><FONT SIZE=-1> type_winnode *info_window(WINHANDLE
Handle);</FONT></I></B>
<BR><B><I><FONT SIZE=-1> type_btnnode *info_button(BTNHANDLE
Handle);</FONT></I></B>
<BR><B><I><FONT SIZE=-1> type_msgnode *info_message(MSGHANDLE
Handle);</FONT></I></B>
<BR><B><I><FONT SIZE=-1> void display_windows(void);</FONT></I></B>
<BR><B><I><FONT SIZE=-1> void display_buttons(BTNHANDLE
Handle,WINHANDLE wHandle);</FONT></I></B>
<BR><B><I><FONT SIZE=-1> void display_message(type_msgnode
*Msg);</FONT></I></B>
<BR><B><I><FONT SIZE=-1> int window_mouse_x_position(WINHANDLE
Handle);</FONT></I></B>
<BR><B><I><FONT SIZE=-1> int window_mouse_y_position(WINHANDLE
Handle);</FONT></I></B>
<BR><B><I><FONT SIZE=-1> void input_message(type_msgnode
*Msg);</FONT></I></B>
<BR><B><I><FONT SIZE=-1> void load_gui_font(char
*FileName);</FONT></I></B>
<BR><B><I><FONT SIZE=-1>};</FONT></I></B>
<BR><B><I><FONT SIZE=-1>WINHANDLE apiclass::new_window(int x,int y,int
xSize,int ySize,void (*WinFunct)()) {</FONT></I></B>
<BR><B><I><FONT SIZE=-1> return(WControl.Create_Window(x,y,xSize,ySize,WinFunct));</FONT></I></B>
<BR><B><I><FONT SIZE=-1>}</FONT></I></B>
<BR><B><I><FONT SIZE=-1>BTNHANDLE apiclass::new_button(int x,int y,int
width, int height,int delay,void (*Afunct)(),void(*Sfunct)()) {</FONT></I></B>
<BR><B><I><FONT SIZE=-1> return(BControl.new_btn(x,y,width,height,delay,Afunct,Sfunct));</FONT></I></B>
<BR><B><I><FONT SIZE=-1>}</FONT></I></B>
<BR><B><I><FONT SIZE=-1>MSGHANDLE apiclass::new_message(int x,int y,char
*msg,int width,int height) {</FONT></I></B>
<BR><B><I><FONT SIZE=-1> return(MControl.New_Msg(x,y,msg,width,height));</FONT></I></B>
<BR><B><I><FONT SIZE=-1>}</FONT></I></B>
<BR><B><I><FONT SIZE=-1>void apiclass::del_window(WINHANDLE Handle) {</FONT></I></B>
<BR><B><I><FONT SIZE=-1> WControl.delete_window(Handle);</FONT></I></B>
<BR><B><I><FONT SIZE=-1>}</FONT></I></B>
<BR><B><I><FONT SIZE=-1>void apiclass::del_button(BTNHANDLE Handle) {</FONT></I></B>
<BR><B><I><FONT SIZE=-1> BControl.delete_btn(Handle);</FONT></I></B>
<BR><B><I><FONT SIZE=-1>}</FONT></I></B>
<BR><B><I><FONT SIZE=-1>void apiclass::del_message(MSGHANDLE Handle) {</FONT></I></B>
<BR><B><I><FONT SIZE=-1> MControl.Delete_Msg(Handle);</FONT></I></B>
<BR><B><I><FONT SIZE=-1>}</FONT></I></B>
<BR><B><I><FONT SIZE=-1>type_winnode * apiclass::info_window(WINHANDLE
Handle) {</FONT></I></B>
<BR><B><I><FONT SIZE=-1> return(WControl.window_info(Handle));</FONT></I></B>
<BR><B><I><FONT SIZE=-1>}</FONT></I></B>
<BR><B><I><FONT SIZE=-1>type_btnnode * apiclass::info_button(BTNHANDLE
Handle) {</FONT></I></B>
<BR><B><I><FONT SIZE=-1> return(BControl.btn_info(Handle));</FONT></I></B>
<BR><B><I><FONT SIZE=-1>}</FONT></I></B>
<BR><B><I><FONT SIZE=-1>type_msgnode * apiclass::info_message(MSGHANDLE
Handle) {</FONT></I></B>
<BR><B><I><FONT SIZE=-1> return(MControl.Msg_Info(Handle));</FONT></I></B>
<BR><B><I><FONT SIZE=-1>}</FONT></I></B>
<BR><B><I><FONT SIZE=-1>void apiclass::display_windows(void) {</FONT></I></B>
<BR><B><I><FONT SIZE=-1> WControl.Display();</FONT></I></B>
<BR><B><I><FONT SIZE=-1>}</FONT></I></B>
<BR><B><I><FONT SIZE=-1>void apiclass::display_buttons(BTNHANDLE Handle,WINHANDLE
wHandle) {</FONT></I></B>
<BR><B><I><FONT SIZE=-1> BControl.display_btn(Handle,WControl.window_info(wHandle));</FONT></I></B>
<BR><B><I><FONT SIZE=-1>}</FONT></I></B>
<BR><B><I><FONT SIZE=-1>void apiclass::display_message(type_msgnode *Msg)
{</FONT></I></B>
<BR><B><I><FONT SIZE=-1> MControl.FxText(Msg);</FONT></I></B>
<BR><B><I><FONT SIZE=-1>}</FONT></I></B>
<BR><B><I><FONT SIZE=-1>int apiclass::window_mouse_x_position(WINHANDLE
Handle) {</FONT></I></B>
<BR><B><I><FONT SIZE=-1> return(WControl.wMouse_X(Handle));</FONT></I></B>
<BR><B><I><FONT SIZE=-1>}</FONT></I></B>
<BR><B><I><FONT SIZE=-1>int apiclass::window_mouse_y_position(WINHANDLE
Handle) {</FONT></I></B>
<BR><B><I><FONT SIZE=-1> return(WControl.wMouse_Y(Handle));</FONT></I></B>
<BR><B><I><FONT SIZE=-1>}</FONT></I></B>
<BR><B><I><FONT SIZE=-1>void apiclass::input_message(type_msgnode *Msg)
{</FONT></I></B>
<BR><B><I><FONT SIZE=-1> MControl.FxInput(Msg);</FONT></I></B>
<BR><B><I><FONT SIZE=-1>}</FONT></I></B>
<BR><B><I><FONT SIZE=-1>void apiclass::load_gui_font(char *FileName) {</FONT></I></B>
<BR><B><I><FONT SIZE=-1> MControl.LoadFont(FileName);</FONT></I></B>
<BR><B><I><FONT SIZE=-1>}</FONT></I></B>
<BR> </UL>
The reason why new_window is just a regualar function pointer is because
then it is more general and will hopefully work with many different classes.
<P> Any suggestions to make it work without "castrationg"
class functions? I was thinking of makeing a global buffer and passing
the private members of the desired class in it to get around the need of
using or passing a class function to the GUI interface (such as ne_window).
That would just defete the purpous of having classes though, it could
get really unorginized.
<BR> Thanks,
<BR>
Ardy
<BR>
<BR> </HTML>
--------------4EBE1F8BB5B17BE4858E8E51--
- Raw text -