Main Page   Class Hierarchy   Compound List   File List   Compound Members  

csbe.h

00001 /*
00002     Copyright (C) 1999-2000 by Eric Sunshine <sunshine@sunshineco.com>
00003   
00004     This library is free software; you can redistribute it and/or
00005     modify it under the terms of the GNU Library General Public
00006     License as published by the Free Software Foundation; either
00007     version 2 of the License, or (at your option) any later version.
00008   
00009     This library is distributed in the hope that it will be useful,
00010     but WITHOUT ANY WARRANTY; without even the implied warranty of
00011     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012     Library General Public License for more details.
00013   
00014     You should have received a copy of the GNU Library General Public
00015     License along with this library; if not, write to the Free
00016     Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00017 */
00018 
00019 #ifndef __CS_CSBE_H__
00020 #define __CS_CSBE_H__
00021 
00022 #include "csutil/scf.h"
00023 #include "csutil/csinput.h"
00024 #include "cssys/system.h"
00025 #include "iutil/event.h"
00026 #include "iutil/eventh.h"
00027 #include "ivideo/graph2d.h" // csMouseCursorID
00028 #include <Handler.h>
00029 #include <MessageQueue.h>
00030 #include "cssys/be/behelp.h"
00031 
00032 class SysSystemDriver;
00033 struct iObjectRegistry;
00034 struct iEvent;
00035 
00039 class BeHelper : public iBeHelper
00040 {
00041 private:
00042   SysSystemDriver* sys;
00043 
00044 public:
00045   BeHelper (SysSystemDriver* sys);
00046   virtual ~BeHelper ();
00047 
00048   SCF_DECLARE_IBASE;
00049   virtual bool UserAction (BMessage* msg);
00050   virtual bool SetCursor (csMouseCursorID id);
00051   virtual bool BeginUI ();
00052   virtual bool Quit ();
00053   virtual bool ContextClose (iGraphics2D* g2d);
00054 };
00055 
00056 class SysSystemDriver :
00057   public csSystemDriver, public iEventPlug, public BHandler
00058 {
00059   typedef csSystemDriver superclass;
00060 
00061 public:
00062   // Public functions for BeHelper.
00063   bool SetMouse(csMouseCursorID shape);
00064   bool RunBeApp();
00065   bool QueueMessage(BMessage*);
00066   bool QueueMessage(uint32, void const* = 0);
00067 
00068 protected:
00069   enum { CSBE_MOUSE_BUTTON_COUNT = 3 };
00070 
00071   bool running;
00072   BMessageQueue message_queue;
00073   iEventOutlet* event_outlet;
00074   bool shift_down;
00075   bool alt_down;
00076   bool ctrl_down;
00077   bool button_state[CSBE_MOUSE_BUTTON_COUNT];
00078   bool real_mouse;
00079   bool mouse_moved;
00080   BPoint mouse_point;
00081 
00082   static int32 ThreadEntry(void*);
00083   void HideMouse();
00084   void ShowMouse();
00085   void DispatchMessage(BMessage*);
00086   void CheckMouseMoved();
00087   void DoContextClose(BMessage*);
00088   void DoMouseMotion(BMessage*);
00089   void DoMouseAction(BMessage*);
00090   void DoKeyAction(BMessage*);
00091   void QueueMouseEvent(int button, bool down, BPoint);
00092   void CheckButton(int button, int32 buttons, int32 mask, BPoint);
00093   void CheckButtons(BMessage*);
00094   void CheckModifiers(BMessage*);
00095   void CheckModifier(long flags, long mask, int tag, bool& state) const;
00096   void ClassifyFunctionKey(BMessage*, int& cs_key, int& cs_char) const;
00097   void ClassifyNormalKey(int, BMessage*, int& cs_key, int& cs_char) const;
00098   int ClassifyUnicodeKey(BMessage*) const;
00099   virtual void MessageReceived(BMessage*); // BHandler override.
00100 
00101 public:
00102   SCF_DECLARE_IBASE_EXT(csSystemDriver);
00103 
00104   SysSystemDriver(iObjectRegistry* object_reg);
00105   ~SysSystemDriver();
00106 
00107   // Implementation of the system.
00108   virtual bool Initialize();
00109   bool HandleEvent(iEvent& ev);
00110 
00111   // Implementation of iEventPlug.
00112   virtual unsigned int GetPotentiallyConflictingEvents();
00113   virtual unsigned int QueryEventPriority(unsigned int);
00114 
00115   struct eiEventHandler : public iEventHandler
00116   {
00117     SCF_DECLARE_EMBEDDED_IBASE (SysSystemDriver);
00118     virtual bool HandleEvent (iEvent& e) { return scfParent->HandleEvent (e); }
00119   } scfiEventHandler;
00120 };
00121 
00122 #endif // __CS_CSBE_H__

Generated for Crystal Space by doxygen 1.2.5 written by Dimitri van Heesch, ©1997-2000