M
mosfet
Hi,
here is my problem. I have a base class and two class deriving from it
that I use to handle different UI context.
These classes are used inside another UI class called CMainView
// definition
class UIContext
{
public:
UIContext(CMainView* pView, LPListInfo_t lpListInfo = NULL) = 0;
virtual ~UIContext();
virtual void DoLayout() = 0;
virtual void SetListView() = 0;
virtual LPListInfo_t GetListInfo();
protected:
LPListInfo_t m_lpListInfo;
int m_nItemCount;
CMainView* m_pView;
};
class UIContextMain : public UIContext
{
public:
UIContextMain( CMainView* pView );
virtual ~UIContextMain() {}
virtual void DoLayout();
virtual void SetListView();
};
class UIContextSettings : public UIContext
{
public:
UIContextSettings( CMainView* pView );
virtual ~UIContextSettings() {}
virtual void DoLayout();
virtual void SetListView();
};
class CMainView : public CBaseView
{
....
protected:
UIContext* m_pCurCtx; // Current context
UIContextMain* m_pCtxMain; // Main Context
UIContextSchedule* m_pCtxSchedule; // Scheduling context
UIContextSettings* m_pCtxSettings; // Settings Context
}
----------------------------------------------------------------
Implemntation:
UIContext::UIContext(CMainView* pView, LPListInfo_t lpListInfo)
{
m_pView = pView;
m_lpListInfo = NULL;
}
void UIContextMain::SetListView()
{
CString strText;
CSyncClient* pSyncClient = CSyncClient::GetInstance();
int nIndex = 0;
for (int i = 0; i < m_nItemCount ; i++)
{
strText = m_pView->GetResText(m_lpListInfo.TextId);
...
}
}
The problem with this approach is that I need to use m_pView everytime I
need to access to my CMainView*.
How can I have a class that can directly access to CMainView members
without having to deference a pointer ?
here is my problem. I have a base class and two class deriving from it
that I use to handle different UI context.
These classes are used inside another UI class called CMainView
// definition
class UIContext
{
public:
UIContext(CMainView* pView, LPListInfo_t lpListInfo = NULL) = 0;
virtual ~UIContext();
virtual void DoLayout() = 0;
virtual void SetListView() = 0;
virtual LPListInfo_t GetListInfo();
protected:
LPListInfo_t m_lpListInfo;
int m_nItemCount;
CMainView* m_pView;
};
class UIContextMain : public UIContext
{
public:
UIContextMain( CMainView* pView );
virtual ~UIContextMain() {}
virtual void DoLayout();
virtual void SetListView();
};
class UIContextSettings : public UIContext
{
public:
UIContextSettings( CMainView* pView );
virtual ~UIContextSettings() {}
virtual void DoLayout();
virtual void SetListView();
};
class CMainView : public CBaseView
{
....
protected:
UIContext* m_pCurCtx; // Current context
UIContextMain* m_pCtxMain; // Main Context
UIContextSchedule* m_pCtxSchedule; // Scheduling context
UIContextSettings* m_pCtxSettings; // Settings Context
}
----------------------------------------------------------------
Implemntation:
UIContext::UIContext(CMainView* pView, LPListInfo_t lpListInfo)
{
m_pView = pView;
m_lpListInfo = NULL;
}
void UIContextMain::SetListView()
{
CString strText;
CSyncClient* pSyncClient = CSyncClient::GetInstance();
int nIndex = 0;
for (int i = 0; i < m_nItemCount ; i++)
{
strText = m_pView->GetResText(m_lpListInfo.TextId);
...
}
}
The problem with this approach is that I need to use m_pView everytime I
need to access to my CMainView*.
How can I have a class that can directly access to CMainView members
without having to deference a pointer ?