00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
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"
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
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*);
00100
00101 public:
00102 SCF_DECLARE_IBASE_EXT(csSystemDriver);
00103
00104 SysSystemDriver(iObjectRegistry* object_reg);
00105 ~SysSystemDriver();
00106
00107
00108 virtual bool Initialize();
00109 bool HandleEvent(iEvent& ev);
00110
00111
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__