Index: trunk/MagicSoft/Cosy/caos/CaosIncl.h
===================================================================
--- trunk/MagicSoft/Cosy/caos/CaosIncl.h	(revision 1799)
+++ trunk/MagicSoft/Cosy/caos/CaosIncl.h	(revision 1799)
@@ -0,0 +1,3 @@
+#ifndef __CINT__
+
+#endif // __CINT__
Index: trunk/MagicSoft/Cosy/caos/CaosLinkDef.h
===================================================================
--- trunk/MagicSoft/Cosy/caos/CaosLinkDef.h	(revision 1798)
+++ trunk/MagicSoft/Cosy/caos/CaosLinkDef.h	(revision 1799)
@@ -4,20 +4,4 @@
 #pragma link off all classes;
 #pragma link off all functions;
-
-#pragma link C++ class MGAccuracy+;
-
-#pragma link C++ class MGCoordinate+;
-#pragma link C++ class MGCoordinates+;
-
-#pragma link C++ class MGEmbeddedCanvas+;
-
-#pragma link C++ class MGImage+;
-
-#pragma link C++ class MGSkyPosition+;
-#pragma link C++ class MGVelocity+;
-
-#pragma link C++ class MGCosy+;
-#pragma link C++ class MGStarguider+;
-#pragma link C++ class MGPngReader+;
 
 #pragma link C++ class Led+;
Index: trunk/MagicSoft/Cosy/caos/Makefile
===================================================================
--- trunk/MagicSoft/Cosy/caos/Makefile	(revision 1798)
+++ trunk/MagicSoft/Cosy/caos/Makefile	(revision 1799)
@@ -20,11 +20,10 @@
 # @endcode 
 
-INCLUDES = -I. -I.. -I../base -I../slalib -I../candrv -I../incl \
-	   -I../catalog -I../videodev -I../main
+INCLUDES = -I. -I..
 
 # @code 
 
-CINT     = Gui
-LIB      = gui.a
+CINT     = Caos
+LIB      = caos.a
 
 #------------------------------------------------------------------------------
@@ -32,16 +31,5 @@
 .SUFFIXES: .c .cc .cxx .h .hxx .o 
 
-SRCFILES = MGCoordinate.cc \
-	   MGCoordinates.cc \
-	   MGCosy.cc \
-	   MGImage.cc \
-	   MGEmbeddedCanvas.cc \
-	   MGAccuracy.cc \
-	   MGVelocity.cc \
-           MGStarguider.cc \
-           MGPngReader.cc \
-	   MGSkyPosition.cc \
-           MGMenu.cc \
-           Led.cc \
+SRCFILES = Led.cc \
            Leds.cc \
            Ring.cc \
Index: trunk/MagicSoft/Cosy/gui/MGMenu.cc
===================================================================
--- trunk/MagicSoft/Cosy/gui/MGMenu.cc	(revision 1799)
+++ trunk/MagicSoft/Cosy/gui/MGMenu.cc	(revision 1799)
@@ -0,0 +1,197 @@
+#include "MGMenu.h"
+
+
+MGMenuEntry::MGMenuEntry(TGMenuEntry *ent)
+{
+    memcpy(this, ent, sizeof(*ent));
+}
+
+// -------------------------------------------------------------
+//
+// Return the keycode corresponding to the hot string of
+// a TGmenuEntry
+//
+UInt_t MGPopupMenu::GetKeyCode(TGMenuEntry *el)
+{
+    TGHotString *str = MGMenuEntry(el).GetLabel();
+    return gVirtualX->KeysymToKeycode(str->GetHotChar());
+}
+
+// -------------------------------------------------------------
+//
+// Bind all hot keys used in this popup menu subsequentlt
+// to the TGMainFrame and send a HandleKey message to the
+// TGWindow
+//
+void MGPopupMenu::BindKeys(const TGWindow *w, TGMainFrame *frame)
+{
+    TIter Next(fEntryList);
+    TGMenuEntry *el;
+
+    //
+    // Loop Through all entries
+    //
+    while ((el=(TGMenuEntry*)Next()))
+    {
+        switch (el->GetType())
+        {
+            //
+            // For seperators and labels nothing to do
+            //
+        case kMenuSeparator:
+        case kMenuLabel:
+            continue;
+
+            //
+            // For an entry and a popup menu bind the hot key
+            // In case of a popup menu call BindKeys subsequently
+            //
+        case kMenuEntry:
+        case kMenuPopup:
+            frame->BindKey(w, GetKeyCode(el), kKeyMod1Mask);
+            if (el->GetType()==kMenuPopup)
+                MGMenuEntry(el).GetPopup()->BindKeys(w, frame);
+            continue;
+        }
+    }
+}
+
+/*
+ kMenuActiveMask  = BIT(0),
+ kMenuEnableMask  = BIT(1),
+ kMenuDefaultMask = BIT(2),
+ kMenuCheckedMask = BIT(3),
+ kMenuRadioMask   = BIT(4),
+ kMenuHideMask    = BIT(5)
+ */
+
+// -------------------------------------------------------------
+//
+//  Handle a keyboard event. Return kFALSE in case of a
+//  successfully send message, which means: close all open
+//  popups.
+//
+Bool_t MGPopupMenu::HandleKey(Event_t *evt)
+{
+    //
+    // Loop through all entries in this popup menu. If the entry is
+    // an open popup menu send the key event to the open popup.
+    //
+    TIter Next(fEntryList);
+    TGMenuEntry *el;
+    while ((el=(TGMenuEntry*)Next()))
+    {
+        if (el->GetType()==kMenuPopup && el->GetStatus()&kMenuActiveMask)
+            return MGMenuEntry(el).GetPopup()->HandleKey(evt);
+    }
+
+    Next.Reset();
+
+    //
+    // If no open popup is found search the pressed key in this
+    // popup menu.
+    //
+    while ((el=(TGMenuEntry*)Next()))
+    {
+        switch (el->GetType())
+        {
+            //
+            // Do nothing
+            //
+        case kMenuSeparator:
+        case kMenuLabel:
+            continue;
+
+            //
+            // If the keycode corresponds to the hot key
+            // of this entry and the entry is enabled activate the entry
+            // and send the corresponding message/
+            //
+        case kMenuEntry:
+            if (GetKeyCode(el)==evt->fCode && el->GetStatus()&kMenuEnableMask)
+            {
+                Activate(el);
+                SendMessage(fMsgWindow, MK_MSG(kC_COMMAND, kCM_MENU),
+                            el->GetEntryId(), (Long_t)MGMenuEntry(el).GetUserData());
+                return kFALSE;
+            }
+            continue;
+
+            //
+            // If the keycode corresponds to the hot key
+            // of this popup menu activate the popup menu.
+            //
+        case kMenuPopup:
+            if (GetKeyCode(el)!=evt->fCode)
+                continue;
+
+            Activate(el);
+            HandleTimer(NULL);
+            return kTRUE;
+        }
+    }
+    return kTRUE;
+}
+
+// -------------------------------------------------------------
+//
+// Bind the keys of all popups subsequently to the given main
+// frame. The menu bar hot keys are already bound by TGMenuBar.
+// Bind the Escape key to close the popups, too.
+//
+void MGMenuBar::BindKeys(TGMainFrame *frame)
+{
+    TGFrameElement *el=NULL;
+    TIter Next(fList);
+    while ((el = (TGFrameElement *)Next()))
+        ((MGPopupMenu*)((TGMenuTitle *) el->fFrame)->GetMenu())->BindKeys(this, frame);
+
+    frame->BindKey(this, 9/*ESC*/, 0);
+}
+
+// -------------------------------------------------------------
+//
+// Handle the keyboard event send to this menu bar.
+//
+Bool_t MGMenuBar::HandleKey(Event_t *event)
+{
+    //
+    // If this isn't a pressed key do nothing
+    //
+    if (event->fType != kGKeyPress)
+        return kTRUE;
+
+    //
+    // Check whether one popup is alreadu open
+    //
+    TGFrameElement *el=NULL;
+    TIter Next(fList);
+    while ((el = (TGFrameElement *)Next()))
+    {
+        if (!((TGMenuTitle*)el->fFrame)->GetState())
+            continue;
+
+        TGMenuTitle &f = *(TGMenuTitle*)el->fFrame;
+
+        //
+        // If a open popup is found redirect the key event to this
+        // popup menu
+        //
+        Bool_t rc = ((MGPopupMenu*)f.GetMenu())->HandleKey(event);
+
+        //
+        // If a message could be successfully send or the escape key
+        // was pressed close the popup.
+        //
+        if (!rc || event->fCode==9/*ESC*/)
+        {
+            f.SetState(kFALSE);
+            gVirtualX->GrabPointer(0, 0, 0, 0, kFALSE);  // ungrab pointer
+            fCurrent = 0;
+        }
+
+        return kTRUE;
+    }
+
+    return TGMenuBar::HandleKey(event);
+}
Index: trunk/MagicSoft/Cosy/gui/MGMenu.h
===================================================================
--- trunk/MagicSoft/Cosy/gui/MGMenu.h	(revision 1799)
+++ trunk/MagicSoft/Cosy/gui/MGMenu.h	(revision 1799)
@@ -0,0 +1,53 @@
+#ifndef COSY_MGMenu
+#define COSY_MGMenu
+
+#ifndef ROOT_TGMenu
+#include <TGMenu.h>
+#endif
+
+class MGPopupMenu;
+
+class MGMenuEntry : public TGMenuEntry
+{
+    /*
+     Workaround for the protected data mambers of TGMenuEntry
+     */
+public:
+    MGMenuEntry(TGMenuEntry *ent);
+    ~MGMenuEntry()
+    {
+        fLabel=0;
+    }
+
+    MGPopupMenu *GetPopup() { return (MGPopupMenu*)fPopup; }
+    TGHotString *GetLabel() { return fLabel; }
+    void *GetUserData()     { return fUserData; }
+};
+
+class MGPopupMenu : public TGPopupMenu
+{
+public:
+    MGPopupMenu(const TGWindow* p = 0, UInt_t w = 10, UInt_t h = 10, UInt_t options = 0) :
+        TGPopupMenu(p, w, h, options)
+    {
+    }
+
+    UInt_t GetKeyCode(TGMenuEntry *el);
+
+    void BindKeys(const TGWindow *w, TGMainFrame *frame);
+
+    Bool_t HandleKey(Event_t *evt);
+};
+
+class MGMenuBar : public TGMenuBar
+{
+public:
+    MGMenuBar(const TGWindow* p, UInt_t w, UInt_t h, UInt_t options = kHorizontalFrame|kRaisedFrame) :
+        TGMenuBar(p, w, h, options) {}
+
+    void BindKeys(TGMainFrame *frame);
+
+    Bool_t HandleKey(Event_t *event);
+};
+
+#endif
