does any one has any good ideas to solve this problem.
I have a base window class that is called GfxWindow that generates a number of events. These events are given notifications within the GfxWindowListener class.
I then create adapter classes which will be used to derive fromCode:class GfxWindowListener { public: virtual void ModifiedTitle(GfxWindow* window, const std::string& str) = 0; virtual void DeleteWindow(GfxWindow* window) = 0; virtual void Select(GfxWindow* window) = 0; virtual void UnSelect(GfxWindow* window) = 0; virtual void Select2(GfxWindow* window) = 0; };
The problem is that GfxWindow will be derived from GfxListBox that will have its own set of events. I could do something likeCode:class GfxInfoAdapter : public GfxWindowListener { public: virtual void OnSelect(GfxWindow* window) { } virtual void OnUnSelect(GfxWindow* window) { } virtual void OnSelect2(GfxWindow* window) { } }; class GfxSelectAdapter : public GfxWindowListener { public: virtual void ModifiedTitle(GfxWindow* window, const std::string& str) { } virtual void DeleteWindow(GfxWindow* window) { } };
but this would mean that cilent programers would not be able to use the GfxWindow adapter class. Thus, I do something likeCode:class GfxListBoxListener : public GfxWindowListener
Is this a good thing or should I create separate adapters for GfxListBox?Code:template<class GFX_WINDOW_LISTENER = GfxWindowListener> class GfxListBoxListener : public GFX_WINDOW_LISTENER { public: typedef long int SizeType; // when the user has requested to insert a string virtual void RequestInsertString(GfxListBox* lb, SizeType place) = 0; virtual void InsertString(GfxListBox* lb, const std::string& str, SizeType place) = 0; virtual void AddString(GfxListBox* lb, const std::string& str) = 0; virtual void ReplaceString(GfxListBox* lb, SizeType item, const std::string& str) = 0; virtual void DeleteItem(GfxListBox* lb, SizeType item) = 0; };



LinkBack URL
About LinkBacks


