i'm not exactly sure what i'm looking for but here goes.
i've started making an editor for an engine that i started making, it supports meshes and textures so far, but i have no editor for it. i'm using simple windows controls that i researched on msdn. in the past i've made very unreusable code, and this time around i wasn't going to make the same mistake this time. i thought in addition to the 4 views in the editor, i'd make a 'internal plugin system' where you could make a new class called CTabbedPlugin or something like that. when you made one, it would have a few functions you had to write. a function called when it recieved the WM_CREATE message, and then a function to respond to when that tab gets switched to (haven't learned that yet), a function that fills the HWND of the tab area, a wndProc that responds to messages in that HWND, and finally a destroy message. so in the class i'd need to somehow call functions you pointed to the class
so for a texture browser for an example you'd go
Code:
CTabbedPlugin * TextureBrowser;
TextureBrowser = NULL;
TextureBrowser = new CTabbedPlugin(HWND parentWindowToPutTabIn, char * Name);
i've already figured that part out, i've got a class that does that. now what i need is a way to 'bind' functions to calls in the class. so if the WM_CREATE message came along, it'd go TextureBrowser->CreateControls();
then i'd need a function like this
Code:
void CTabbedPlugin::CreateControls(void)
{
callSpecifiedFunctionForCreate();
}
i think what i need are like the things in WNDCLASS, the WNDPROC lpfnWndProc. it lets you specify a function to use as the message processor. that way when you made a new CTabbedPlugin, you'd go through and set each function to use. you'd have to make and set a CreateControls(), a Proc(), and a Destroy() and probably a few others i haven't thought of yet. so if i made the TextureBrowser plugin, i'd need to do something like this:
Code:
CTabbedPlugin * TextureBrowser;
TextureBrowser = NULL;
TextureBrowser = new CTabbedPlugin(HWND parentWindowToPutTabIn, char * Name);
if(TextureBrowser == NULL)
{
//error
}
TextureBrowser->SetCreateControls(??? aCreateControls function);
TextureBrowser->SetProcess(??? a function for processing messages from the controls you created);
TextureBrowser->SetDestroyControls(??? a function that is called on quit, lets you unload any viewports/controls/etc. that you might ahve created in this window);
i realize that is really incoherent and stuipd sounding, and i probably have something wrong, but basically i just need a way to set a function that gets called from a class without having to make a unique class for each 'plugin' or browser.
another idea i had to solve this problem is make the same class but with each of the 3 functions virtual, so to make a plugin you'd inherit the CTabbedPlugin and overwrite the 3 virtual functions.