I'm creating a set of classes that mimic standard VC controls (such as command buttons, etc.) on the console. My base class,
ConsoleObject, works beautifully. I added a few function pointers that can be set to handle events:
Code:
void (*onFocusEventHandler)(void);
void (*onLoseFocusEventHandler)(void);
void (*onClickEventHandler)(unsigned __int32 mouseX,unsigned __int32 mouseY,unsigned __int8 button);
void (*onDoubleClickEventHandler)(unsigned __int32 mouseX,unsigned __int32 mouseY,unsigned __int8 button);
void (*onMouseOverEventHandler)(unsigned __int32 mouseX,unsigned __int32 mouseY);
void (*onMouseOutEventHandler)(unsigned __int32 mouseX,unsigned __int32 mouseY);
void (*onDestroyEventHandler)(void);
Users could set the function pointers to their own function. However, when a derived class,
WindowTitleBar, tries to set the function pointers, I get the following compile error:
cannot convert from 'void (__thiscall WindowTitleBar::*)(unsigned __int32,unsigned __int32,unsigned __int8)' to
'void (__cdecl *)unsigned __int32,unsigned __int32,unsigned __int8)'
Typecasting didn't work. I tried using template classes, but then the
WindowTitleBar can't set the handler functions (which belong to
WindowTitleBar) to the command buttons (also derived from
ConsoleObject)that they're for. I get the following error:
cannot convert from 'void (__thiscall WindowTitleBar::* )(unsigned __int32,unsigned __int32,unsigned __8)' to
'void (__thiscall CommandButton::* )(unsigned __int32,unsigned __int32,unsigned __8)'
In addition, when a derived class
Window tries to instantiate a variable of type
WindowEventHandler which is not derived from
ConsoleObject, I get illogical compile errors:
Code:
eventHandler = new WindowEventHandler(objects,this);
/*
Note that WindowEventHandler has a constructor:
WindowEventHandler(ConsoleObject<Object> **objList,ConsoleObject<Window> *parent)
*/
Causes the error:
'WindowEventHandler::WindowEventHandler(ConsoleObj ect<objClass> **,ConsoleObject<Window> *)' :
cannot convert parameter 1 from 'ConsoleObject<objClass> **' to 'ConsoleObject<objClass> **'
Last time I checked, ConsoleObject<objClass> ** and ConsoleObject <objClass> ** are the same thing.
Can someone please help me? I know this is confusing, and real GUIs are much more efficient, but I just like doing things myself and this is a major obstacle for me. I'm attaching the source code to this post. (It's a header (.h) file, but I had to change the extension to .txt to upload it.)
I have a bad habit of not documenting my code very well, so if you need further clarification, just let me know.)
Thanks in advance.