public Application() { Glade.XML gxml = new Glade.XML(null, "tiler.glade", null, null); gxml.Autoconnect(this); if (MainWindow == null || DrawingArea == null || AppBar == null) { throw new Exception("soem widgets not found"); } DrawingArea.AddEvents((int)Gdk.EventMask.ButtonPressMask); DrawingArea.AddEvents((int)Gdk.EventMask.ButtonReleaseMask); DrawingArea.AddEvents((int)Gdk.EventMask.ButtonMotionMask); // libglade missed interactivity property :-/ MainLayout.Remove(AppBar); AppBar = new AppBar(true, true, PreferencesType.Always); AppBar.UserResponse += new EventHandler(OnAppBarUserResponse); MainLayout.PackStart(AppBar, false, false, 0); AppBar.Show(); TileGroupComboBox.Entry.Activated += new EventHandler(OnTileGroupComboBoxEntryActivated); MainWindow.Show(); }
public WidgetWrapper(DrawingArea widget) { this.widget = widget; MoveWaitMS = 200; widget.AddEvents ((int)EventMask.PointerMotionMask); widget.AddEvents ((int)EventMask.ButtonPressMask); widget.AddEvents ((int)EventMask.ButtonReleaseMask); widget.AddEvents ((int)EventMask.KeyPressMask); widget.ExposeEvent += HandleExposeEvent; widget.ButtonPressEvent += HandleButtonPressEvent; widget.ButtonReleaseEvent += HandleButtonReleaseEvent; widget.MotionNotifyEvent += HandleMotionNotifyEvent; }
public Application() { Glade.XML gxml = new Glade.XML(null, "tiler.glade", null, null); gxml.Autoconnect(this); if (MainWindow == null || DrawingArea == null || RemapDialog == null) { throw new Exception("some widgets not found"); } DrawingArea.AddEvents((int)Gdk.EventMask.ButtonPressMask); DrawingArea.AddEvents((int)Gdk.EventMask.ButtonReleaseMask); DrawingArea.AddEvents((int)Gdk.EventMask.ButtonMotionMask); MainWindow.Show(); }
public SharpApp() : base("Simple drawing") { SetDefaultSize(400, 400); SetPosition(WindowPosition.Center); DeleteEvent += delegate { Application.Quit(); }; DrawingArea darea = new DrawingArea(); darea.ExposeEvent += OnExpose; darea.AddEvents ((int)Gdk.EventMask.ButtonPressMask); //darea.ButtonPressEvent += onButtonPress; ButtonPressEvent += onButtonPress; System.Console.WriteLine ("ctor"); Add(darea); ShowAll(); }
static void initialise_lunar() { w = new Gtk.Window("Lunar Lander"); VBox v = new VBox(); // w.SetDefaultSize (200, 500); v.Spacing = 12; w.Add(v); area = new DrawingArea(); area.SetSizeRequest(200, 500); area.ExposeEvent += Expose_Event; area.ButtonPressEvent += new ButtonPressEventHandler(ButtonPressHandler); area.ButtonReleaseEvent += new ButtonReleaseEventHandler(ButtonReleaseHandler); area.AddEvents((int)(EventMask.ButtonPressMask | EventMask.ButtonReleaseMask)); // v.Add (area); v.PackStart(area); HBox h = new HBox(); start_game = new Button("Start Game"); start_game.Clicked += do_start; h.PackStart(start_game, false, false, 0); v.PackEnd(h, false, false, 0); w.ShowAll(); w.Resizable = false; w.DeleteEvent += Window_Delete; context = Gdk.CairoHelper.Create(area.GdkWindow); GLib.Timeout.Add(1000 / 10, update_handler); }
///<summary>Create a DataViewDisplay</summary> public DataViewDisplay(DataView dv) { dataView = dv; // load the default layout from the data directory layout = new Layout(FileResourcePath.GetDataPath("bless-default.layout")); // initialize scrollbar Gtk.Adjustment adj = new Gtk.Adjustment(0.0, 0.0, 1.0, 1.0, 10.0, 0.0); vscroll = new Gtk.VScrollbar(adj); adj.ValueChanged += OnScrolled; // initialize drawing area drawingArea = new Gtk.DrawingArea(); drawingArea.Realized += OnRealized; drawingArea.ExposeEvent += OnExposed; drawingArea.ConfigureEvent += OnConfigured; drawingArea.ModifyBg(StateType.Normal, new Gdk.Color(0xff, 0xff, 0xff)); // add events that we want to handle drawingArea.AddEvents((int)Gdk.EventMask.ButtonPressMask); drawingArea.AddEvents((int)Gdk.EventMask.ButtonReleaseMask); drawingArea.AddEvents((int)Gdk.EventMask.PointerMotionMask); drawingArea.AddEvents((int)Gdk.EventMask.PointerMotionHintMask); drawingArea.AddEvents((int)Gdk.EventMask.KeyPressMask); drawingArea.AddEvents((int)Gdk.EventMask.KeyReleaseMask); drawingArea.CanFocus = true; // needed to catch key events hbox = new Gtk.HBox(); hbox.PackStart(drawingArea, true, true, 0); hbox.PackStart(vscroll, false, false, 0); this.PackStart(hbox); }
//Contains all of the components which are on the window private void setupWindow() { //Vertical box (3 sections) which is the main container VBox MainVBox = new VBox(false, 6); /*********************Start of menu bar components*********************/ //Note: Flow of menus are: //Menubar contains MenuItems (e.g. File, Edit, About, etc...) //MenuItems contains one Menu (i.e. a Submenu) //Menu contains multiple MenuItems (e.g. Save, Save As, Load, etc...) MenuBar MainMenuBar = new MenuBar (); Menu FileMenu = new Menu (); MenuItem File = new MenuItem ("File"); File.Submenu = FileMenu; MenuItem ExitItem = new MenuItem ("Exit"); ExitItem.Activated += quitProgram; FileMenu.Append (ExitItem); Menu GestureMenu = new Menu (); MenuItem Gesture = new MenuItem ("Gestures"); Gesture.Submenu = GestureMenu; MenuItem LoadGesture = new MenuItem ("Load Gesture"); LoadGesture.Activated += openGesture; GestureMenu.Append (LoadGesture); MenuItem SaveGestureItem = new MenuItem ("Save Gesture"); SaveGestureItem.Activated += createGesture; GestureMenu.Append (SaveGestureItem); Menu PointsMenu = new Menu (); MenuItem Points = new MenuItem ("Data Points"); Points.Submenu = PointsMenu; MenuItem LoadPointsItem = new MenuItem ("Load Points"); LoadPointsItem.Activated += loadDataPoints; PointsMenu.Append (LoadPointsItem); MenuItem RecordPointsItem = new MenuItem ("Record Points"); RecordPointsItem.Activated += recordPoints; PointsMenu.Append (RecordPointsItem); MenuItem BatchRecognizeItem = new MenuItem ("Batch Recognize"); BatchRecognizeItem.Activated += batchRecognize; PointsMenu.Append (BatchRecognizeItem); Menu HelpMenu = new Menu (); MenuItem Help = new MenuItem ("Help"); Help.Submenu = HelpMenu; MenuItem AboutMenuItem = new MenuItem("About"); HelpMenu.Append (AboutMenuItem); MainMenuBar.Append (File); MainMenuBar.Append (Gesture); MainMenuBar.Append (Points); MainMenuBar.Append (Help); /*********************End of menu bar components*********************/ //Drawing area which is the core component of the application dArea = new DrawingArea (); dArea.SetSizeRequest (500, 500); //Horizontal box (4 sections) which contains all of the buttons along the //bottom of the window HBox ButtonHBox = new HBox (false, 6); /*********************Start of Buttons*********************/ Button BtnCreateGesture = new Button ("Create"); Button BtnRecognizeGesture = new Button ("Recognize"); Button BtnClearScreen = new Button ("Clear"); Button BtnRecordPoints = new Button ("Record points"); Button BtnChangeColour = new Button ("Change colour"); //Button functions BtnCreateGesture.Clicked += new EventHandler (createGesture); BtnRecognizeGesture.Clicked += new EventHandler (recognizeGesture); BtnClearScreen.Clicked += new EventHandler (clearScreen); BtnRecordPoints.Clicked += new EventHandler (recordPoints); BtnChangeColour.Clicked += changeColour; //Adding buttons to the current horizontal box ButtonHBox.PackStart (BtnCreateGesture, true, false, 0); ButtonHBox.PackStart (BtnRecognizeGesture, true, false, 0); ButtonHBox.PackStart (BtnClearScreen, true, false, 0); ButtonHBox.PackStart (BtnRecordPoints, true, false, 0); ButtonHBox.PackStart (BtnChangeColour, true, false, 0); /*********************End of Buttons*********************/ //Status bar which shows the score and recognized gesture sBar = new Statusbar (); sBar.Push (1, "Ready"); //Entry box for batch function name to be used on the files batchFunctionName = new Entry ("Recorded points function name"); batchFunctionName.AddEvents ( (int)Gdk.EventMask.ButtonPressMask ); batchFunctionName.ButtonPressEvent += clearTextBox; //Adding all components to the Vertical box MainVBox.PackStart (MainMenuBar, false, false, 0); MainVBox.PackStart (dArea, false, false, 0); MainVBox.PackStart (ButtonHBox, false, false, 0); MainVBox.PackStart (batchFunctionName, false, false, 0); MainVBox.PackStart (sBar, false, false, 0); Add (MainVBox); ShowAll (); //Surface 'pattern' for area to be covered surface = new ImageSurface(Format.Argb32, 500, 500); //Adding mouse events to the drawing area and assigning functions dArea.AddEvents( //Mouse Related Events (int)Gdk.EventMask.PointerMotionMask |(int)Gdk.EventMask.ButtonPressMask |(int)Gdk.EventMask.ButtonReleaseMask ); //Repaint the Canvas Internally. dArea.ExposeEvent += OnDrawingAreaExposed; //Do this on MousePress inside Area dArea.ButtonPressEvent += OnMousePress; //Do this on MouseReleased inside Area dArea.ButtonReleaseEvent += OnMouseRelease; //Do this if a Motion Occurs inside the Drawing Area dArea.MotionNotifyEvent += OnMouseMotion2; //Assigning close function to the window DeleteEvent += delegate { Application.Quit(); }; //Checking to see if bool for using the dot function is true //And assigning the required function as the delegate's operation //Note: This will always be true, no current way to switch while //application is running, has not been needed as of yet if (isDot) { Painter = new DrawShape (DrawDot); myoPainter = new DrawShape (DrawDot); } else { Painter = new DrawShape (DrawLine); } }
private bool coordsActive_ = true; // Shows X,Y in Tooltip #endregion Fields #region Constructors /// <summary> /// Default Constructor /// </summary> public InteractivePlotSurface2D() : base() { canvas = new DrawingArea (); // allocate local DrawingArea canvas.CanFocus = true; // enable to receive the focus // Link the event handlers into the DrawingArea events (default is none) canvas.SizeAllocated += new SizeAllocatedHandler (SizeAllocated); canvas.ExposeEvent += new ExposeEventHandler (ExposeEvent); canvas.EnterNotifyEvent += new EnterNotifyEventHandler (EnterNotify); canvas.LeaveNotifyEvent += new LeaveNotifyEventHandler (LeaveNotify); canvas.ButtonPressEvent += new ButtonPressEventHandler (ButtonPress); canvas.MotionNotifyEvent += new MotionNotifyEventHandler (MotionNotify); canvas.ButtonReleaseEvent += new ButtonReleaseEventHandler (ButtonRelease); canvas.ScrollEvent += new ScrollEventHandler (ScrollNotify); canvas.KeyPressEvent += new KeyPressEventHandler (KeyPressed); canvas.KeyReleaseEvent += new KeyReleaseEventHandler (KeyReleased); // Subscribe to DrawingArea mouse movement and button press events. // Enter and Leave notification is necessary to make ToolTips work. // Specify PointerMotionHint to prevent being deluged with motion events. canvas.AddEvents ((int)Gdk.EventMask.EnterNotifyMask); canvas.AddEvents ((int)Gdk.EventMask.LeaveNotifyMask); canvas.AddEvents ((int)Gdk.EventMask.ButtonPressMask); canvas.AddEvents ((int)Gdk.EventMask.ButtonReleaseMask); canvas.AddEvents ((int)Gdk.EventMask.PointerMotionMask); canvas.AddEvents ((int)Gdk.EventMask.PointerMotionHintMask); canvas.AddEvents ((int)Gdk.EventMask.ScrollMask); canvas.SetSizeRequest (400, 300); // Set DrawingArea size // Set up ToolTips to show coordinates. NB works via Enter/Leave events // TODO: ToolTips do not work well yet - needs review of approach this.Canvas.TooltipText = "Coordinates will display here"; }