Blender  V2.59
GlutKeyboardManager.h
Go to the documentation of this file.
00001 
00029 #ifndef NAN_INCLUDED_GlutKeyboardManager
00030 #define NAN_INCLUDED_GlutKeyboardManager
00031 
00032 #include "MEM_NonCopyable.h"
00033 #include "MEM_SmartPtr.h"
00034 
00035 // So pissed off with Glut callback stuff
00036 // that is impossible to call objects unless they are global
00037 
00038 // inherit from GlutKeyboardHandler and installl the drawer in the singleton
00039 // class GlutKeyboardManager.
00040 
00041 class GlutKeyboardHandler : public MEM_NonCopyable {
00042 public :
00043 
00044         virtual 
00045                 void
00046         HandleKeyboard(
00047                 unsigned char key,
00048                 int x,
00049                 int y
00050         )= 0;
00051 
00052         virtual 
00053         ~GlutKeyboardHandler(
00054         ){};            
00055 };
00056 
00057 class GlutKeyboardManager : public MEM_NonCopyable{
00058 
00059 public :
00060 
00061         static
00062                 GlutKeyboardManager *
00063         Instance(
00064         );
00065 
00066         // this is the function you should pass to glut
00067 
00068         static
00069                 void
00070         HandleKeyboard(
00071                 unsigned char key,
00072                 int x,
00073                 int y
00074         );
00075 
00076                 void
00077         InstallHandler(
00078                 GlutKeyboardHandler *
00079         );
00080 
00081                 void
00082         ReleaseHandler(
00083         );
00084 
00085         ~GlutKeyboardManager(
00086         );
00087 
00088 private :
00089 
00090         GlutKeyboardManager (
00091         ) :
00092                 m_handler (0)
00093         {
00094         };
00095         
00096         GlutKeyboardHandler * m_handler;
00097 
00098         static MEM_SmartPtr<GlutKeyboardManager> m_s_instance;
00099 };      
00100 
00101 #endif
00102