internal void Initialize () {
// Initialize the event handlers
Carbon.EventHandler.Driver = this;
ApplicationHandler = new Carbon.ApplicationHandler (this);
ControlHandler = new Carbon.ControlHandler (this);
HIObjectHandler = new Carbon.HIObjectHandler (this);
KeyboardHandler = new Carbon.KeyboardHandler (this);
MouseHandler = new Carbon.MouseHandler (this);
WindowHandler = new Carbon.WindowHandler (this);
// Initilize the mouse controls
Hover.Interval = 500;
Hover.Timer = new Timer ();
Hover.Timer.Enabled = false;
Hover.Timer.Interval = Hover.Interval;
Hover.Timer.Tick += new EventHandler (HoverCallback);
Hover.X = -1;
Hover.Y = -1;
MouseState = MouseButtons.None;
mouse_position = Point.Empty;
// Initialize the Caret
Caret.Timer = new Timer ();
Caret.Timer.Interval = 500;
Caret.Timer.Tick += new EventHandler (CaretCallback);
// Initialize the D&D
Dnd = new Carbon.Dnd ();
// Initialize the Carbon Specific stuff
WindowMapping = new Hashtable ();
HandleMapping = new Hashtable ();
UtilityWindows = new ArrayList ();
// Initialize the FosterParent
Carbon.Rect rect = new Carbon.Rect ();
SetRect (ref rect, (short)0, (short)0, (short)0, (short)0);
Carbon.ProcessSerialNumber psn = new Carbon.ProcessSerialNumber();
GetCurrentProcess( ref psn );
TransformProcessType (ref psn, 1);
SetFrontProcess (ref psn);
HIObjectRegisterSubclass (__CFStringMakeConstantString ("com.novell.mwfview"), __CFStringMakeConstantString ("com.apple.hiview"), 0, Carbon.EventHandler.EventHandlerDelegate, (uint)Carbon.EventHandler.HIObjectEvents.Length, Carbon.EventHandler.HIObjectEvents, IntPtr.Zero, ref Subclass);
Carbon.EventHandler.InstallApplicationHandler ();
CreateNewWindow (Carbon.WindowClass.kDocumentWindowClass, Carbon.WindowAttributes.kWindowStandardHandlerAttribute | Carbon.WindowAttributes.kWindowCloseBoxAttribute | Carbon.WindowAttributes.kWindowFullZoomAttribute | Carbon.WindowAttributes.kWindowCollapseBoxAttribute | Carbon.WindowAttributes.kWindowResizableAttribute | Carbon.WindowAttributes.kWindowCompositingAttribute, ref rect, ref FosterParent);
CreateNewWindow (Carbon.WindowClass.kOverlayWindowClass, Carbon.WindowAttributes.kWindowNoUpdatesAttribute | Carbon.WindowAttributes.kWindowNoActivatesAttribute, ref rect, ref ReverseWindow);
CreateNewWindow (Carbon.WindowClass.kOverlayWindowClass, Carbon.WindowAttributes.kWindowNoUpdatesAttribute | Carbon.WindowAttributes.kWindowNoActivatesAttribute, ref rect, ref CaretWindow);
// Get some values about bar heights
Carbon.Rect structRect = new Carbon.Rect ();
Carbon.Rect contentRect = new Carbon.Rect ();
GetWindowBounds (FosterParent, 32, ref structRect);
GetWindowBounds (FosterParent, 33, ref contentRect);
MenuBarHeight = GetMBarHeight ();
// Focus
FocusWindow = IntPtr.Zero;
// Message loop
GetMessageResult = true;
ReverseWindowMapped = false;
}