I'm trying to design my gui so that it is flexible, and I've got a 'level' based system worked out:
- IWidget
- CText, CImage
- CProgressBar, CGroupBox, CButton
- CFader, CRoller
- CScrollBar
- CEditBox
- CListBox
- CDropDownList
class IDialog
{
WidgetVector /*std::vector<IWidget*>*/ m_Widgets;
public:
virtual void Initialize() = 0;
virtual void Destroy() = 0;
virtual void Draw(ID3DXSprite* pSprite, IDirect3DTexture9* pTexture) = 0;
virtual void HandleMessage(IEvent* pEvent) = 0;
};
The user then derives a class from IDialog (I will provide sample classes), instances some widgets and viola, you've got a dialog. Or you can instance, and have them on the main screen (i.e. health bar, text box, etc.)
Basically, each level depends on one or more of the items in the previous levels. For example:
CScrollBar (level 5) requires a CFader and a CRoller from level 4.
CButton (level 3) requires a CText
etc
I have a few questions:
1) Are there any widgets that I missed (other than tabs, I'm thinking about implementing them, but I'm not sure.)
2) Does my implementation seem logical?
3) Should I have my GUI enviroment class have a function like so:
void HandleWndProc(UINT nMsg, WPARAM wParam, LPARAM lParam);
And have the user call that in their wndproc, or is there a different way?
Nothing has been coded yet, I'm still working on the design.
Thanks!
Also: Should I track how many widgets are in the dialog (actually, I should ask: does std::vector track it, or does it iterate through and count each node when size() is called)?
Edit: I just noticed that I had missed CImage on level 2. Its been added
Edit: I forgot to mention, I'm thinking of adding a layer system so that you could layer, say a CBitmap on top of a progress bar, for a nifty little health bar (ala Diablo).
[Edited by - Programmer16 on August 3, 2005 2:40:59 PM]