public static void AdjustWindowSize(HuffLibrary.Tree HTree, DrawingArea Canvas) { int ImageWidth, ImageHeight; Canvas.SetSizeRequest (0, 0); //Reduce window size in case our tree is small GetAreaSize (HTree.GetRootNode (), out ImageWidth, out ImageHeight, cellsize); int width, height; Canvas.GdkWindow.GetSize (out width, out height); Canvas.SetSizeRequest (ImageWidth, ImageHeight); if (height > ImageHeight) Canvas.GdkWindow.Resize (width, ImageHeight); }
public DemoColorSelection () : base ("Color Selection") { BorderWidth = 8; VBox vbox = new VBox (false,8); vbox.BorderWidth = 8; Add (vbox); // Create the color swatch area Frame frame = new Frame (); frame.ShadowType = ShadowType.In; vbox.PackStart (frame, true, true, 0); drawingArea = new DrawingArea (); drawingArea.ExposeEvent += new ExposeEventHandler (ExposeEventCallback); // set a minimum size drawingArea.SetSizeRequest (200,200); // set the color color = new Gdk.Color (0, 0, 0xff); drawingArea.ModifyBg (StateType.Normal, color); frame.Add (drawingArea); Alignment alignment = new Alignment (1.0f, 0.5f, 0.0f, 0.0f); Button button = new Button ("_Change the above color"); button.Clicked += new EventHandler (ChangeColorCallback); alignment.Add (button); vbox.PackStart (alignment); ShowAll (); }
//private static Gdk.Pixmap pixmap = null; //private static Gtk.InputDialog inputDialog = null; public static int Main15 (string[] args) { Application.Init (); win = new Gtk.Window ("Scribble XInput Demo"); win.DeleteEvent += new DeleteEventHandler (WindowDelete); vBox = new VBox (false, 0); win.Add (vBox); darea = new Gtk.DrawingArea (); darea.SetSizeRequest (200, 200); // darea.ExtensionEvents=ExtensionMode.Cursor; vBox.PackStart (darea, true, true, 0); //darea.ExposeEvent += new ExposeEventHandler (ExposeEvent); darea.ConfigureEvent += new ConfigureEventHandler (ConfigureEvent); darea.MotionNotifyEvent += new MotionNotifyEventHandler (MotionNotifyEvent); darea.ButtonPressEvent += new ButtonPressEventHandler (ButtonPressEvent); darea.Events = EventMask.ExposureMask | EventMask.LeaveNotifyMask | EventMask.ButtonPressMask | EventMask.PointerMotionMask; inputButton = new Button("Input Dialog"); vBox.PackStart (inputButton, false, false, 0); inputButton.Clicked += new EventHandler (InputButtonClicked); quitButton = new Button("Quit"); vBox.PackStart (quitButton, false, false, 0); quitButton.Clicked += new EventHandler (QuitButtonClicked); win.ShowAll (); Application.Run (); return 0; }
public DemoColorSelection () : base ("Color Selection") { BorderWidth = 8; VBox vbox = new VBox (false,8); vbox.BorderWidth = 8; Add (vbox); // Create the color swatch area Frame frame = new Frame (); frame.ShadowType = ShadowType.In; vbox.PackStart (frame, true, true, 0); drawingArea = new DrawingArea (); // set a minimum size drawingArea.SetSizeRequest (200,200); // set the color color.Red = 0; color.Green = 0; color.Blue = 1; color.Alpha = 1; drawingArea.OverrideBackgroundColor (StateFlags.Normal, color); frame.Add (drawingArea); Alignment alignment = new Alignment (1.0f, 0.5f, 0.0f, 0.0f); Button button = new Button ("_Change the above color"); button.Clicked += new EventHandler (ChangeColorCallback); alignment.Add (button); vbox.PackStart (alignment, false, false, 0); ShowAll (); }
private void BuildInterface() { VBox vbox = this.Child as VBox; HButtonBox buttonBox = new HButtonBox (); drawingArea = new DrawingArea (); drawingArea.SetSizeRequest (640, 480); captureButton = new Button ("Capture"); previewButton = new Button ("Preview"); previewButton.Sensitive = false; saveButton = new Button ("Save"); saveButton.Sensitive = false; cancelButton = new Button ("Cancel"); buttonBox.PackStart (captureButton); buttonBox.PackStart (previewButton); buttonBox.PackStart (saveButton); buttonBox.PackStart (cancelButton); buttonBox.LayoutStyle = ButtonBoxStyle.Center; vbox.PackStart (drawingArea); vbox.PackStart (buttonBox, false, true, 8); this.ShowAll (); this.DeleteEvent += new DeleteEventHandler(OnDelete); captureButton.Clicked += new EventHandler (CaptureButtonClicked); previewButton.Clicked += new EventHandler(PreviewButtonClicked); saveButton.Clicked += new EventHandler (SaveButtonClicked); cancelButton.Clicked += new EventHandler (CancelButtonClicked); }
public DemoColorSelection() : base("Color Selection") { BorderWidth = 8; VBox vbox = new VBox(false, 8); vbox.BorderWidth = 8; Add(vbox); // Create the color swatch area Frame frame = new Frame(); frame.ShadowType = ShadowType.In; vbox.PackStart(frame, true, true, 0); drawingArea = new DrawingArea(); // set a minimum size drawingArea.SetSizeRequest(200, 200); // set the color color.Red = 0; color.Green = 0; color.Blue = 1; color.Alpha = 1; drawingArea.OverrideBackgroundColor(StateFlags.Normal, color); frame.Add(drawingArea); Alignment alignment = new Alignment(1.0f, 0.5f, 0.0f, 0.0f); Button button = new Button("_Change the above color"); button.Clicked += new EventHandler(ChangeColorCallback); alignment.Add(button); vbox.PackStart(alignment, false, false, 0); ShowAll(); }
public DemoColorSelection() : base("Color Selection") { BorderWidth = 8; VBox vbox = new VBox(false, 8); vbox.BorderWidth = 8; Add(vbox); // Create the color swatch area Frame frame = new Frame(); frame.ShadowType = ShadowType.In; vbox.PackStart(frame, true, true, 0); drawingArea = new DrawingArea(); drawingArea.ExposeEvent += new ExposeEventHandler(ExposeEventCallback); // set a minimum size drawingArea.SetSizeRequest(200, 200); // set the color color = new Gdk.Color(0, 0, 0xff); drawingArea.ModifyBg(StateType.Normal, color); frame.Add(drawingArea); Alignment alignment = new Alignment(1.0f, 0.5f, 0.0f, 0.0f); Button button = new Button("_Change the above color"); button.Clicked += new EventHandler(ChangeColorCallback); alignment.Add(button); vbox.PackStart(alignment); ShowAll(); }
public GlToggleButton(GdkGL.Config config) { // VBox. VBox vbox = new VBox (false, 0); vbox.BorderWidth = 10; // Drawing area for drawing OpenGL scene. DrawingArea drawing_area = new DrawingArea (); drawing_area.SetSizeRequest (200, 200); // Set OpenGL-capability to the widget. m_gl = new GlWidget (drawing_area, config); drawing_area.Realized += new EventHandler (Realize); drawing_area.ConfigureEvent += new ConfigureEventHandler (Configure); drawing_area.ExposeEvent += new ExposeEventHandler (Expose); drawing_area.Unrealized += new EventHandler (Unrealize); drawing_area.VisibilityNotifyEvent += new VisibilityNotifyEventHandler (VisibilityNotify); vbox.PackStart (drawing_area, true, true, 0); drawing_area.Show (); // Label. Label label = new Label ("Toggle Animation"); vbox.PackStart (label, false, false, 10); label.Show (); Toggled += new EventHandler (ToggleAnimation); // Add VBox. vbox.Show (); Add (vbox); }
public static int Main(string[] args) { Application.Init(); win = new Gtk.Window("Scribble XInput Demo"); win.DeleteEvent += new DeleteEventHandler(WindowDelete); vBox = new VBox(false, 0); win.Add(vBox); darea = new Gtk.DrawingArea(); darea.SetSizeRequest(200, 200); darea.ExtensionEvents = ExtensionMode.Cursor; vBox.PackStart(darea, true, true, 0); darea.ExposeEvent += new ExposeEventHandler(ExposeEvent); darea.ConfigureEvent += new ConfigureEventHandler(ConfigureEvent); darea.MotionNotifyEvent += new MotionNotifyEventHandler(MotionNotifyEvent); darea.ButtonPressEvent += new ButtonPressEventHandler(ButtonPressEvent); darea.Events = EventMask.ExposureMask | EventMask.LeaveNotifyMask | EventMask.ButtonPressMask | EventMask.PointerMotionMask; inputButton = new Button("Input Dialog"); vBox.PackStart(inputButton, false, false, 0); inputButton.Clicked += new EventHandler(InputButtonClicked); quitButton = new Button("Quit"); vBox.PackStart(quitButton, false, false, 0); quitButton.Clicked += new EventHandler(QuitButtonClicked); win.ShowAll(); Application.Run(); return(0); }
public BoardRenderer(Gtk.DrawingArea area, int width, int height, int fieldSize) { area.SetSizeRequest(width * fieldSize, height * fieldSize); this.area = area; this.width = width; this.height = height; this.fieldSize = fieldSize; }
public MainWindow_Widget2() : base("Widget2") { SetDefaultSize(800, 600); SetPosition(WindowPosition.Center); BorderWidth = 7; DeleteEvent += delegate { Application.Quit(); }; _label = new Label("..."); Entry entry = new Entry(); entry.Changed += OnChangedEntry; // scale and image HScale scale = new HScale(0, 100, 1); { scale.SetSizeRequest(160, 35); scale.ValueChanged += OnChangeScale; LoadImage(); _image = new Image(img1); } // Color ToggleButton red = new ToggleButton("red"); { red.SetSizeRequest(80, 35); red.Clicked += OnRed; _area = new DrawingArea(); _area.SetSizeRequest(150, 150); } Calendar calendar = new Calendar(); { calendar.DaySelected += OnDaySelected; } Fixed fix = new Fixed(); fix.Put(entry, 60, 100); fix.Put(_label, 60, 40); fix.Put(scale, 60, 200); fix.Put(_image, 10, 240); fix.Put(red, 300, 250); fix.Put(_area, 300, 500); fix.Put(calendar, 500, 300); Add(fix); ShowAll(); }
public DemoDrawingArea () : base ("Drawing Area") { BorderWidth = 8; VBox vbox = new VBox (false, 8); vbox.BorderWidth = 8; Add (vbox); // Create the checkerboard area Label label = new Label ("<u>Checkerboard pattern</u>"); label.UseMarkup = true; vbox.PackStart (label, false, false, 0); Frame frame = new Frame (); frame.ShadowType = ShadowType.In; vbox.PackStart (frame, true, true, 0); DrawingArea da = new DrawingArea (); // set a minimum size da.SetSizeRequest (100,100); frame.Add (da); da.ExposeEvent += new ExposeEventHandler (CheckerboardExpose); // Create the scribble area label = new Label ("<u>Scribble area</u>"); label.UseMarkup = true; vbox.PackStart (label, false, false, 0); frame = new Frame (); frame.ShadowType = ShadowType.In; vbox.PackStart (frame, true, true, 0); da = new DrawingArea (); // set a minimum size da.SetSizeRequest (100, 100); frame.Add (da); // Signals used to handle backing pixmap da.ExposeEvent += new ExposeEventHandler (ScribbleExpose); da.ConfigureEvent += new ConfigureEventHandler (ScribbleConfigure); // Event signals da.MotionNotifyEvent += new MotionNotifyEventHandler (ScribbleMotionNotify); da.ButtonPressEvent += new ButtonPressEventHandler (ScribbleButtonPress); // Ask to receive events the drawing area doesn't normally // subscribe to da.Events |= EventMask.LeaveNotifyMask | EventMask.ButtonPressMask | EventMask.PointerMotionMask | EventMask.PointerMotionHintMask; ShowAll (); }
public MainWindow() : base("Overlaytest") { VBox vBox = new VBox (); _da = new DrawingArea (); _da.ModifyBg (Gtk.StateType.Normal, new Gdk.Color (0, 0, 0)); _da.SetSizeRequest (400, 300); _da.DoubleBuffered = false; vBox.PackStart (_da, false, false, 0); _scale = new HScale (0, 1, 0.01); _scale.DrawValue = false; _scale.ValueChanged += ScaleValueChanged; vBox.PackStart (_scale, false, false, 0); HBox hBox = new HBox (); Button btnOpen = new Button (); btnOpen.Label = "Open"; btnOpen.Clicked += ButtonOpenClicked; hBox.PackStart (btnOpen, false, false, 0); Button btnPlay = new Button (); btnPlay.Label = "Play"; btnPlay.Clicked += ButtonPlayClicked; hBox.PackStart (btnPlay, false, false, 0); Button btnPause = new Button (); btnPause.Label = "Pause"; btnPause.Clicked += ButtonPauseClicked; hBox.PackStart (btnPause, false, false, 0); _lbl = new Label (); _lbl.Text = "00:00 / 00:00"; hBox.PackEnd (_lbl, false, false, 0); vBox.PackStart (hBox, false, false, 3); Add (vBox); WindowPosition = Gtk.WindowPosition.Center; DeleteEvent += OnDeleteEvent; GLib.Timeout.Add (1000, new GLib.TimeoutHandler (UpdatePos)); }
// }}} // MainWindow::initDrawingArea() {{{ /// <summary>Init the drawing area and put some layout's property</summary> /// <param name="area">The drawing area</param> /// <returns>void</returns> public void initDrawingArea(DrawingArea area) { area.SetSizeRequest(this.pref.mainWindowWidth, this.pref.mainWindowHeight); area.ExposeEvent += onExposeEvent; // define some colors Gdk.Color white = new Gdk.Color(); Gdk.Color black = new Gdk.Color(); Gdk.Color.Parse("white", ref white); Gdk.Color.Parse("black", ref black); // define area colors area.ModifyBg(StateType.Normal, white); area.ModifyBase(StateType.Normal, black); // XXX move out ? this.layout.Width = Pango.Units.FromPixels(this.pref.mainWindowWidth); this.layout.Wrap = Pango.WrapMode.Word; this.layout.Alignment = Pango.Alignment.Left; }
public GrabHandle(int w, int h) { da = new DrawingArea (); da.SetSizeRequest (w, h); Orientation = Gtk.Orientation.Vertical; Child = da; ShowAll (); ButtonPressEvent += (o, a) => Dragging = true; ButtonReleaseEvent += (o, a) => Dragging = false; EnterNotifyEvent += (o, a) => Inside = true; LeaveNotifyEvent += (o, a) => Inside = false; da.Drawn += (o, a) => { da.StyleContext.Save (); da.StyleContext.AddClass ("pane-separator"); da.StyleContext.RenderHandle (a.Cr, 0, 0, da.Allocation.Width, da.Allocation.Height); da.StyleContext.Restore (); }; }
public GrabHandle (int w, int h) { da = new DrawingArea (); da.SetSizeRequest (w, h); Orientation = Gtk.Orientation.Vertical; Child = da; ShowAll (); ButtonPressEvent += (o, a) => Dragging = true; ButtonReleaseEvent += (o, a) => Dragging = false; EnterNotifyEvent += (o, a) => Inside = true; LeaveNotifyEvent += (o, a) => Inside = false; da.ExposeEvent += (o, a) => { if (da.IsDrawable) { Gtk.Style.PaintHandle (da.Style, da.GdkWindow, da.State, ShadowType.In, a.Event.Area, this, "entry", 0, 0, da.Allocation.Width, da.Allocation.Height, Orientation); } }; }
/// <summary> /// Tunes the middle dock item or the data visualizer. /// </summary> private void TuneMiddleDockItem() { // Attach the comboBox first. vbMiddle.PackStart(comboBox, false, false, 0); ScrolledWindow scroll = new ScrolledWindow(); // Attach the treeView to the scroll bar. scroll.AddWithViewport(treeView); // Attach the scrollBar to the box. vbMiddle.PackStart(scroll, true, true, 0); // Set up DrawingArea. drawingArea = new DrawingArea(); drawingArea.SetSizeRequest(800, 500); ScrolledWindow scrollDA = new ScrolledWindow(); Gtk.VBox vBoxDA = new Gtk.VBox(); Viewport viewPortDA = new Viewport(); viewPortDA.Add(drawingArea); scrollDA.Add(viewPortDA); vBoxDA.PackStart(scrollDA, true, true, 0); // Add Paned container in order to make the two boxes resizable Gtk.VPaned splitter = new Gtk.VPaned(); splitter.Pack1(vBoxDA, true, true); splitter.Pack2(vbMiddle, true, true); splitter.Position = 400; splitter.ShowAll(); nbMiddleDock.AppendPage(splitter, new Gtk.Label("Schema Visualizer")); nbMiddleDock.ShowAll(); schemaV = new SchemaVisualizer(drawingArea); // Get the selected shape. SelectionModel selectionModel = schemaV.Selection; selectionModel.ModelChanged += HandleSelectionModelChanged; }
public static int Main (string[] args) { Application.Init (); Gtk.Window win = new Gtk.Window ("Scribble demo"); win.DeleteEvent += new DeleteEventHandler (Window_Delete); darea = new Gtk.DrawingArea (); darea.SetSizeRequest (200, 200); win.Add (darea); darea.ExposeEvent += new ExposeEventHandler (ExposeEvent); darea.ConfigureEvent += new ConfigureEventHandler (ConfigureEvent); darea.MotionNotifyEvent += new MotionNotifyEventHandler (MotionNotifyEvent); darea.ButtonPressEvent += new ButtonPressEventHandler (ButtonPressEvent); darea.Events = EventMask.ExposureMask | EventMask.LeaveNotifyMask | EventMask.ButtonPressMask | EventMask.PointerMotionMask | EventMask.PointerMotionHintMask; win.ShowAll (); Application.Run (); return 0; }
public static int Main(string[] args) { Application.Init(); Gtk.Window win = new Gtk.Window("Scribble demo"); win.DeleteEvent += new DeleteEventHandler(Window_Delete); darea = new Gtk.DrawingArea(); darea.SetSizeRequest(200, 200); win.Add(darea); darea.ExposeEvent += new ExposeEventHandler(ExposeEvent); darea.ConfigureEvent += new ConfigureEventHandler(ConfigureEvent); darea.MotionNotifyEvent += new MotionNotifyEventHandler(MotionNotifyEvent); darea.ButtonPressEvent += new ButtonPressEventHandler(ButtonPressEvent); darea.Events = EventMask.ExposureMask | EventMask.LeaveNotifyMask | EventMask.ButtonPressMask | EventMask.PointerMotionMask | EventMask.PointerMotionHintMask; win.ShowAll(); Application.Run(); return(0); }
public GrabHandle(int w, int h) { da = new DrawingArea(); da.SetSizeRequest(w, h); Orientation = Gtk.Orientation.Vertical; Child = da; ShowAll(); ButtonPressEvent += (o, a) => Dragging = true; ButtonReleaseEvent += (o, a) => Dragging = false; EnterNotifyEvent += (o, a) => Inside = true; LeaveNotifyEvent += (o, a) => Inside = false; da.ExposeEvent += (o, a) => { if (da.IsDrawable) { Gtk.Style.PaintHandle(da.Style, da.GdkWindow, da.State, ShadowType.In, a.Event.Area, this, "entry", 0, 0, da.Allocation.Width, da.Allocation.Height, Orientation); } }; }
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); }
public LcdDisplay (DrawingArea drawingArea) { this.drawingArea = drawingArea; drawingArea.SetSizeRequest (Width, Height); gc = new Gdk.GC((Drawable)drawingArea.GdkWindow); rowSize = ((backGroundPixBuffer.Width * backGroundPixBuffer.NChannels) + backGroundPixBuffer.Rowstride)/2; }
//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"; }