From: "Steven S. Falls" Newsgroups: comp.os.msdos.djgpp Subject: Re: Function Pointer Problem Date: Wed, 23 Dec 1998 11:42:28 -0800 References: <367F672B DOT E7A3F4CA AT earthlink DOT net> <367f982c DOT 23433981 AT news DOT snafu DOT de> <367FFB4D DOT DE5C6EFC AT earthlink DOT net> <368027fa DOT 60253828 AT news DOT snafu DOT de> X-Posted-Path-Was: not-for-mail Content-Type: multipart/alternative; boundary="------------4EBE1F8BB5B17BE4858E8E51" X-ELN-Date: 23 Dec 1998 19:39:22 GMT X-ELN-Insert-Date: Wed Dec 23 11:45:03 1998 Organization: EarthLink Network, Inc. Lines: 321 Mime-Version: 1.0 NNTP-Posting-Host: ip222.san-francisco22.ca.pub-ip.psi.net Message-ID: <368147A4.C2FC96D4@earthlink.net> X-Mailer: Mozilla 4.02 [en]C-DIAL (Win95; U) To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com --------------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 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.. 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--