Platform Considerations

<< Click to Display Table of Contents >>

Navigation:  XStream® HDVR® SDK > Implementation Concepts > Mouse Adaptors >

Platform Considerations

Previous pageReturn to chapter overviewNext page

C++ C++ Java Java .NET .NET

Summary

 

The IMouseAdaptor and hdrcAdaptor classes connect to user interface devices. The connection between these adaptor classes and the desired user interface device generally requires platform-specific code that depends on the target operating system and language. The following sections provide code examples that show how to connect adaptor classes on a number of common development platforms including:

 

oMicrosoft Windows - MFC
oMicrosoft Windows - .NET Framework
oJava
oQT
oOSX

 

Microsoft Windows - MFC (C++)

 

Under Microsoft MFC, the IMouseAdaptor mouse action methods are called from MFC event handlers.

 

// Declare an IPanAdaptor member in the class header.

IPanAdaptor* m_pPanAdaptor = NULL;

 

// Create a IPanAdaptor object in a class method.

pLibrary->CreateObject(&CLSID_PanAdaptor, &m_pPanAdaptor);

 

// Attach the IPanAdaptor object to a RenderQueue

m_pPanAdaptor->SetRenderParamsReciever(m_pRenderQueue);

 

//

// Elsewhere in the code, call the adaptor interface functions from the appropriate mouse event handler.

//

 

void CClientAppDlg::OnLButtonDown(UINT nFlag,CPoint point) {

   SetCapture();

   if(m_pPanAdaptor != NULL) {

      m_pressed = true;

      m_pPanAdaptor->MousePressed(point.x,point.y);

   }

}

 

void CClientAppDlg::OnMouseMove(UINT nFlags, CPoint point)

{

   if(pPanAdaptor != NULL && m_pressed == true) {

      pPanAdaptor->MouseDragged(point.x,point.y);

   }

}

 

void CClientAppDlg::OnLButtonUp(UINT nFlag,CPoint point) {

   ReleaseCapture();

   if(m_pPanAdaptor != NULL) {

      m_pressed = false;

      m_pPanAdaptor->MouseReleased(point.x,point.y);

   }

}

 

Microsoft Windows - .NET Framework (C# / .NET)

 

Under the Microsoft .NET Framework, the hdrcAdaptor mouse action methods are called from .NET event handlers.

 

// Declare an hdrcPanAdaptor member in the class header.

protected hdrcPanAdaptor m_panAdaptor;

 

// Create a IPanAdaptor object in a class method.

m_panAdaptor = new hdrcPanAdaptor(renderQueue);

 

//

// Elsewhere in the code, call the adaptor interface functions from the appropriate mouse event handler.

//

 

private void Form1_MouseDown(object sender, MouseEventArgs e) {

   Capture = true;

   if (e.Button == MouseButtons.Left) {

      m_panAdaptor.mousePressed(e.X, e.Y);     

   }

}

 

private void Form1_MouseMove(object sender, MouseEventArgs e) {

   if (!Capture) {

      return;

   }

 

   if (e.Button == MouseButtons.Left) {

      m_panAdaptor.mouseDragged(e.X, e.Y);

   }

}

 

private void Form1_MouseUp(object sender, MouseEventArgs e) {

   if (e.Button == MouseButtons.Left) {

      m_panAdaptor.mouseReleased(e.X, e.Y);

   }

 

   if (Capture == true) {

      Capture = false;

   }

}

 

Java

 

Under the HDVR® Java API, the hdrcAdaptor classes implement the Java MouseListener and MouseMotionListener interfaces. Using the java.awt.Component.addMouseListener() and java.awt.Component.addMouseMotionListener() methods, the mouse adaptor classes can be added as event handlers directly to any class derived from the java.awt.Component class. In practice, most users implement their own mouse listener classes, and then explicitly call the HDVR® mouse adaptor event functions from within that class. An example of this is shown below.

 

// Define a MouseLister class

class UserMouseListener implements MouseListener {

   // HDVR mouse adaptor

   protected hdrcPanAdaptor m_panAdaptor;

 

   // Implement MouseListener inteface and call adaptor classes (partial list shown here).

   void mousePressed(MouseEvent e) {

      m_panAdaptor.mousePressed(e.getX(), e.getY());

   }

 

   void mouseDragged(MouseEvent e) {

      m_panAdaptor.mouseDragged(e.getX(), e.getY());

   }

 

   void mouseReleased(MouseEvent e) {

      m_panAdaptor.mouseReleased(e.getX(), e.getY());

   }

}

 

// In program code, declare user class and mouse adaptor classes.

UserMouseListener userMouseListener = new UserMouseListener();

userMouseListner.m_panAdaptor = new hdrcPanAdaptor()

 

// Add mouse listener as appropriate.

javaUserInterfaceObject.addMouseListener(userMouseListner);

javaUserInterfaceObject.addMouseMotionListener(userMouseListener);