So am I really going about this the wrong way?
Should I be looking at creating interfaces?
What is the more standard approach to this problem within C++/VC++?
:p
CToolBox.h
#ifndef C_TOOLBOX
#define C_TOOLBOX
#if _WIN32
#pragma once
#endif
#include "NMMain.h"
#include "CTool.h"
#include "2DLocker.h"
#define TOOLSET_SIZE 32
class CToolset
{
private:
vector<CTool*> Drawer;
public:
CToolset(){Drawer.reserve(TOOLSET_SIZE);};
void PutInDrawer(CTool* store){Drawer.push_back(store);};
void RemoveFromDrawer();
UINT ReturnSize(){return Drawer.size();};
CTool* CheckoutTool(UINT ptr){ return Drawer.at(ptr);};
};
class CToolBox
{
private:
HRESULT ActivateTool();
HRESULT LoadTB();
public:
CToolBox(UI_TOOLBOX_ID ident) : UI_TB_ID(ident) {LoadTB();}
HRESULT MouseActivityTB(SMouseStroke*, CToolBox*);
POINT GetObjToolboxHandle(){return objToolboxHandle;};
POINT GetPntBoundingBox_1(){return pntBoundingBox_1;};
POINT GetPntBoundingBox_2(){return pntBoundingBox_2;};
private:
UI_TOOLBOX_ID UI_TB_ID;
CToolset Toolset;
C2DModel tb_surface;
POINT objToolboxHandle;
POINT pntBoundingBox_1;
POINT pntBoundingBox_2;
CTool* ToolActive;
};
class CNonActiveToolbox : public CToolBox
{
public:
CNonActiveToolbox() : CToolBox(UI_DEFAULT) {}
bool isDevToolActive;
};
class CUserInterfaceEditor : public CToolBox
{
public:
CUserInterfaceEditor() : CToolBox(UI_DEV_TOOL) {}
HRESULT SaveUI();
HRESULT DeleteUI();
HRESULT RenameUI();
HRESULT SaveToolBox();
HRESULT DeleteToolBox();
public:
bool isActive;
};
#endif
CToolBox.cpp
#include "CToolBox.h"
HRESULT CToolBox::LoadTB()
{
HRESULT hr = S_OK;;
Toolset.PutInDrawer(new CToolPoly);
ToolActive = Toolset.CheckoutTool(0);
return S_OK;
}
HRESULT CToolBox::MouseActivityTB(SMouseStroke* ptrMouseStroke,CToolBox* ToolboxHit)
{
HRESULT hr = S_OK;;
if(ToolboxHit == NULL && ToolActive != NULL)
ToolActive->Execute();
else if(ToolboxHit == this && ToolActive == NULL)
ActivateTool();
return S_OK;
}
CTool.h
#ifndef C_TOOL
#define C_TOOL
#if _WIN32
#pragma once
#endif
#include "NMMain.h"
class CTool
{
private:
UI_TOOL UI_T_ID;
public:
CTool(UI_TOOL ident) : UI_T_ID(ident) {}
HRESULT Execute();
//POINT pointOnClick;
};
class CToolPoly : public CTool
{
public:
CToolPoly() : CTool(TOOL_POLY){}
HRESULT PerformDuties();
};
#endif
CTool.cpp
#include "CTool.h"
HRESULT CTool::Execute()
{
switch(this->UI_T_ID)
{
case TOOL_POLY:
static_cast<CToolPoly*>(this)->PerformDuties();
break;
}
}


Sign In
Create Account


Back to top









