Google

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 
00033 SCF_VERSION (iBeAssistant, 0, 0, 1);
00034 
00035 struct iBeAssistant : public iBase {
00042   virtual bool UserAction (BMessage*) = 0;
00043 
00048   virtual bool SetCursor(csMouseCursorID) = 0;
00049 
00059   //virtual bool BeginUI() = 0;
00060 
00064   virtual bool Quit() = 0;
00065 
00069   virtual bool ContextClose(iGraphics2D*) = 0;
00070 };
00071 
00072 class BeAssistant : public iBeAssistant, public BHandler {
00073 //typedef iBeAssistant superclass
00074 protected:
00075   enum { CSBE_MOUSE_BUTTON_COUNT = 3 };
00076 
00077   bool running;
00078   BMessageQueue message_queue;
00079   iEventOutlet* event_outlet;
00080   bool shift_down;
00081   bool alt_down;
00082   bool ctrl_down;
00083   bool button_state[CSBE_MOUSE_BUTTON_COUNT];
00084   bool real_mouse;
00085   bool mouse_moved;
00086   BPoint mouse_point;
00087   iObjectRegistry *object_reg;
00088   iEventQueue *event_queue;
00089 
00090   static int32 ThreadEntry(void*);
00091   void HideMouse();
00092   void ShowMouse();
00093   void DispatchMessage(BMessage*);
00094   void CheckMouseMoved();
00095   void DoContextClose(BMessage*);
00096   void DoMouseMotion(BMessage*);
00097   void DoMouseAction(BMessage*);
00098   void DoKeyAction(BMessage*);
00099   void QueueMouseEvent(int button, bool down, BPoint);
00100   void CheckButton(int button, int32 buttons, int32 mask, BPoint);
00101   void CheckButtons(BMessage*);
00102   void CheckModifiers(BMessage*);
00103   void CheckModifier(long flags, long mask, int tag, bool& state) const;
00104   void ClassifyFunctionKey(BMessage*, int& cs_key, int& cs_char) const;
00105   void ClassifyNormalKey(int, BMessage*, int& cs_key, int& cs_char) const;
00106   int ClassifyUnicodeKey(BMessage*) const;
00107   virtual void MessageReceived(BMessage*); // BHandler override.
00108 
00109 public:
00110   BeAssistant(iObjectRegistry*);
00111   virtual ~BeAssistant();
00112 
00113   bool HandleEvent(iEvent& e);
00114   virtual bool UserAction (BMessage*);
00115   virtual bool SetCursor(csMouseCursorID);
00116   virtual bool Quit();
00117   virtual bool ContextClose(iGraphics2D*);
00118 
00119   bool SetMouse(csMouseCursorID shape);
00120   bool RunBeApp();
00121   bool QueueMessage(BMessage*);
00122   bool QueueMessage(uint32, void const* = 0);
00123 
00124   struct eiEventPlug : public iEventPlug
00125   {
00126     SCF_DECLARE_EMBEDDED_IBASE(BeAssistant);
00127     virtual uint GetPotentiallyConflictingEvents();
00128     virtual uint QueryEventPriority(uint type);
00129   } scfiEventPlug;
00130 
00131   struct eiEventHandler : public iEventHandler
00132   {
00133     SCF_DECLARE_EMBEDDED_IBASE (BeAssistant);
00134     virtual bool HandleEvent (iEvent& e) { return scfParent->HandleEvent(e); }
00135   } scfiEventHandler;
00136 
00137   SCF_DECLARE_IBASE;
00138 };
00139 
00140 class SysSystemDriver : public csSystemDriver
00141 {
00142 public:
00143   SysSystemDriver(iObjectRegistry* r) : csSystemDriver(r) {}
00144 };
00145 
00146 #endif // __CS_CSBE_H__

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