Jump to content

  • Log In with Google      Sign In   
  • Create Account


#Actualkrippy2k8

Posted 11 September 2012 - 11:17 PM

Given your current constraints, what I would do is make each control responsible for adding itself.

i.e.:

class Control
{
public:
   virtual void addToWindow( KBMWindow& window )
   {
	  throw std::logic_error("This control type not implemented for KBM.");
   }
   virtual void addToWindow( TouchWindow& window )
   {
	  throw std::logic_error("This control type not implemented for Touch.");
   }
};

class Button: public Control
{
public:
   virtual void addToWindow( KBMWindow& window )
   {
	  window.uiWindow().addControl( getKBMButton() );
   }
   virtual void addToWindow( TouchWindow& window )
   {
	  window.uiWindow().addControl( getTouchButton() );
   }
};

class KBMWindow: public Window
{
   KBM::Window m_window;
public:
   void addControl(Control *ctrl)
   {
	  ctrl->addToWindow(m_window);
   }

   KBM::Window& uiWindow(){ return m_window; }
};

class TouchWindow: public Window
{
   Touch::Window m_window;
public:
   void addControl(Control *ctrl)
   {
	  ctrl->addToWindow(m_window);
   }

   Touch::Window& uiWindow(){ return m_window; }
};

#4krippy2k8

Posted 11 September 2012 - 11:16 PM

Given your current constraints, what I would do is make each control responsible for adding itself.

i.e.:

class Control
{
public:
   virtual void addToWindow( KBMWindow& window )
   {
	  throw std::logic_error("This control type not implemented for KBM.");
   }
   virtual void addToWindow( TouchWindow& window )
   {
	  throw std::logic_error("This control type not implemented for Touch.");
   }
};

class Button: public Control
{
public:
   virtual void addToWindow( KBMWindow& window )
   {
	  window.uiWindow().addControl( getKBMButton() );
   }
   virtual void addToWindow( TouchWindow& window )
   {
	  window.uiWindow().addControl( getTouchButton() );
   }
};

class KBMWindow: public Window
{
   KBM::Window m_window;	// The actual button object.
public:
   void addControl(Control *ctrl)
   {
	  ctrl->addToWindow(m_window);
   }

   KBM::Window& uiWindow(){ return m_window; }
};

class TouchWindow: public Window
{
   Touch::Window m_window;	// The actual button object.
public:
   void addControl(Control *ctrl)
   {
	  ctrl->addToWindow(m_window);
   }

   Touch::Window& uiWindow(){ return m_window; }
};

#3krippy2k8

Posted 11 September 2012 - 11:13 PM

Given your current constraints, what I would do is make each control responsible for adding itself.

i.e.:

class Control
{
public:
   virtual void addToWindow( KBMWindow& window )
   {
	  throw std::logic_error("This control type not implemented for KBM.");
   }
   virtual void addToWindow( TouchWindow& window )
   {
	  throw std::logic_error("This control type not implemented for Touch.");
   }
};

class Button: public Control
{
public:
   virtual void addToWindow( KBMWindow& window )
   {
	  window.uiWindow().addControl( getKBMButton() );
   }
   virtual void addToWindow( TouchWindow& window )
   {
	  window.uiWindow().addControl( getTouchButton() );
   }
};

class KBMWindow: public Window
{
   KBM::Window m_window;	// The actual button object.
public:
   void addControl(Control *ctrl)
   {
	  ctrl->addToWindow(m_window);
   }

   KBM::Window& uiWindow(){ return m_window; }
};

class TouchWindow: public Window
{
   Touch::Window m_window;	// The actual button object.
public:
   void addControl(Control *ctrl)
   {
	  ctrl->addToWindow(m_window);
   }

   Touch::Window& uiWindow(){ return m_window; }
};

#2krippy2k8

Posted 11 September 2012 - 10:32 PM

Given your current constraints, what I would do is make each control responsible for adding itself.

i.e.:

class Control
{
public:
   virtual void addToWindow( KBMWindow& window )
   {
	  throw std::logic_error("This control type not implemented for KBM.");
   }
   virtual void addToWindow( TouchWindow& window )
   {
	  throw std::logic_error("This control type not implemented for Touch.");
   }
};

class Button: public Control
{
public:
   virtual void addToWindow( KBMWindow& window )
   {
	  window.addControl( getKBMButton() );
   }
   virtual void addToWindow( TouchWindow& window )
   {
	  window.addControl( getTouchButton() );
   }
};

class KBMWindow: public Window
{
   KBM::Window m_window;    // The actual button object.
public:
   void addControl(Control *ctrl)
   {
	  ctrl->addToWindow(m_window);
   }
};

class TouchWindow: public Window
{
   Touch::Window m_window;    // The actual button object.
public:
   void addControl(Control *ctrl)
   {
	  ctrl->addToWindow(m_window);
   }
};

#1krippy2k8

Posted 11 September 2012 - 10:28 PM

Given your current constraints, what I would do is make each control responsible for adding itself.

i.e.:

class Control
{
public:
   virtual void addToWindow( KBMWindow& window )
   { 
	  throw std::logic_error("This control type not implemented for KBM.");
   }
   virtual void addToWindow( TouchWindow& window )
   {
	  throw std::logic_error("This control type not implemented for Touch.");
   }
};

class Button: public Control
{
public:
   virtual void addToWindow( KBMWindow& window )
   {
	  window.addControl( getKBMButton() );
   }
   virtual void addToWindow( TouchWindow& window )
   {
	  window.addControl( getTouchButton() );
   }
};

class FooWindow: public Window
{
   Foo::Window m_window;    // The actual button object.
public:
   void addControl(Control *ctrl)
   {
	  ctrl->addToWindow(m_window);
   }
};


PARTNERS