/////////////////////////////////////////// //! rcsid="$Id: exCanvas.cc,v 1.6 2000/02/26 18:07:03 ees1cg Exp $" #include "amma/GUI/Window.hh" #include "amma/GUI/CanvasF.hh" #include "amma/GUI/Manager.hh" #include "amma/GUI/LBox.hh" #include "amma/GUI/RenderTools.hh" #include "amma/Option.hh" #include "amma/EntryPnt.hh" #define GTKDEBUG 0 #if GTKDEBUG #define ONDEBUG(x) x #else #define ONDEBUG(x) #endif #define USEMT 0 void canvas_event(GUICanvasC &cv,const GUIMouseEventC &me,int &) { if(me.IsPressed(0)) cv.Put(GUIRenderPointC(me.X(),me.Y(),1)); //cerr << "X:" << me.X() << " y:" << me.Y() << "\n"; } int exCanvas(int nargs,char *args[]) { GUIManager.Init(nargs,args); // Initalise GUI manager, let it read args. // Do normal option processing .... OptionC option(nargs,args,TRUE); option.Check(); // Setup GUI... using namespace StdGUI; GUICanvasC draw; draw = Canvas(200,200,canvas_event,1); // Make a canvas to draw into. draw.SetMouseEventMask(TRUE,TRUE,TRUE); GUIWindowC win(300,300,"Hello"); // Make a new window called hello. win.Add(GUILBoxC(draw,FALSE)); // Put draw area inside a window. win.Show(); // Display this lot on the screen. #if USEMT GUIManager.Execute(); // Start X thread. #endif // Do some work with the gui... ONDEBUG(cerr << "Drawing stuff... \n"); draw.Put(GUIRenderLineC(10,10,100,100,1) + // Draw a line from 10,10 to 100,100 colour 1 GUIRenderLineC(100,10,10,100,2) + // Draw a line from 100,10 to 10,100 colour 2 GUIRenderLineC(10,10,100,10,3) + GUIRenderLineC(10,100,100,100,0) + GUIRenderTextC(10,50,"Hello!") ); ONDEBUG(cerr << "Executing manager... \n"); #if USEMT GUIManager.Wait(); // Wait for GUI to finish. #else GUIManager.Start(); // Wait for GUI to finish. #endif //cerr << "Terminating.!\n"; exit(0); return 0; } AMMA_ENTRY_POINT(exCanvas);