示例#1
0
        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);
        }
示例#2
0
		//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;
		}
示例#3
0
        protected override void OnMouseUp(Gtk.DrawingArea canvas, Gtk.ButtonReleaseEventArgs args, Cairo.PointD point)
        {
            Document doc = PintaCore.Workspace.ActiveDocument;

            base.OnMouseUp(canvas, args, point);

            ImageSurface surf = doc.CurrentLayer.Surface;

            using (Context g = new Context(surf)) {
                if (path != null)
                {
                    g.AppendPath(path);
                    (path as IDisposable).Dispose();
                    path = null;
                }

                g.FillRule = FillRule.EvenOdd;
                g.ClosePath();

                Path old = doc.SelectionPath;

                doc.SelectionPath = g.CopyPath();
                (old as IDisposable).Dispose();
            }

            doc.Workspace.Invalidate();
        }
		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 ();
		}
示例#5
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();
            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 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();
            // 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();
        }
示例#8
0
        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);
        }
示例#9
0
        protected override void OnMouseDown(Gtk.DrawingArea canvas,
                                            Gtk.ButtonPressEventArgs args,
                                            Cairo.PointD point)
        {
            Document doc = PintaCore.Workspace.ActiveDocument;

            if (IsActive)
            {
                return;
            }

            original_point = point;
            if (!doc.Workspace.PointInCanvas(point))
            {
                return;
            }

            if (args.Event.Button == GtkExtensions.MouseRightButton)
            {
                is_rotating = true;
            }
            else if (args.Event.State.IsControlPressed())
            {
                is_scaling = true;
            }
            else
            {
                is_dragging = true;
            }

            using_mouse = true;
            OnStartTransform();
        }
示例#10
0
		protected override void OnMouseDown (DrawingArea canvas, ButtonPressEventArgs args, Cairo.PointD point)
		{
			// Ignore extra button clicks while drawing
			if (is_drawing)
				return;

			Document doc = PintaCore.Workspace.ActiveDocument;
			hist = new SelectionHistoryItem(Icon, Name);
			hist.TakeSnapshot();

			reset_origin = args.Event.GetPoint();

            active_control = HandleResize (point);
			if (!active_control.HasValue)
			{
				combine_mode = PintaCore.Workspace.SelectionHandler.DetermineCombineMode(args);

				double x = Utility.Clamp(point.X, 0, doc.ImageSize.Width - 1);
				double y = Utility.Clamp(point.Y, 0, doc.ImageSize.Height - 1);
				shape_origin = new PointD(x, y);

                doc.PreviousSelection.Dispose ();
				doc.PreviousSelection = doc.Selection.Clone();
				doc.Selection.SelectionPolygons.Clear();

                // The bottom right corner should be selected.
                active_control = 3;
			}

            is_drawing = true;
		}
        public void Render(DrawingArea area, SettingsModel settings)
        {
            var width = area.Allocation.Width;
            var height = area.Allocation.Height;

            var kaleidoscope = _factory.Get (settings.Type);
            var rootNode = kaleidoscope.Generate (
                settings.GeometyWidth,
                settings.ImageUri,
                width, height);

            ImageSurface surface = new ImageSurface(Format.Argb32, width, height);

            using (var context = new Context (surface)) {
                context.Translate(width / 2, height / 2);
                rootNode.Render (context);
            }
            rootNode.Geometry.Dispose ();

            using (Context context = Gdk.CairoHelper.Create (area.GdkWindow)) {
                context.Rectangle(0, 0, width, height);
                context.SetSource(surface);
                context.Fill();
                context.GetTarget ().Dispose ();
            }
            surface.Dispose ();
        }
        public PlainSurfaceItem(int maxWidth, int maxHeight, int widthRequest = 0, int heightRequest = 0, string label = null)
        {
            //Console.WriteLine ("PlainSurfaceItem");
            _label = label;
            this._evtBox = new EventBox ();
            this._draw = new global::Gtk.DrawingArea ();
            if(widthRequest > 0) {
                _draw.WidthRequest = widthRequest;
            }
            if(heightRequest > 0) {
                _draw.HeightRequest = heightRequest;
            }

            this._evtBox.Add (this._draw);

            maxWidth = Math.Max (maxWidth, widthRequest);
            maxHeight = Math.Max (maxHeight, heightRequest);
            this._height = Math.Max(_draw.Allocation.Height, heightRequest);
            this._width = Math.Max(_draw.Allocation.Width, widthRequest);
            this._mode = DisplayMode.Snapshot;
            this._surface = new ImageSurface(Format.Argb32, maxWidth, maxHeight);
            this._button = MouseButton.None;
            this._background = new Color (1.0, 1.0, 1.0);

            _draw.ExposeEvent += DrawExpose;
            _evtBox.ButtonPressEvent += DrawButtonPressEvent;
            _evtBox.ButtonReleaseEvent += DrawButtonReleaseEvent;
            _evtBox.MotionNotifyEvent += DrawMotionNotifyEvent;
        }
示例#13
0
        protected override void OnMouseUp(Gtk.DrawingArea canvas, Gtk.ButtonReleaseEventArgs args, Cairo.PointD point)
        {
            Document doc = PintaCore.Workspace.ActiveDocument;

            ImageSurface surf = doc.SelectionLayer.Surface;

            using (Context g = new Context(surf)) {
                if (path != null)
                {
                    g.AppendPath(path);
                    (path as IDisposable).Dispose();
                    path = null;
                }

                g.FillRule = FillRule.EvenOdd;
                g.ClosePath();
            }

            doc.Selection.SelectionPolygons.Clear();
            doc.Selection.SelectionPolygons.Add(lasso_polygon.ToList());
            SelectionModeHandler.PerformSelectionMode(combine_mode, doc.Selection.SelectionPolygons);
            doc.Workspace.Invalidate();

            if (hist != null)
            {
                doc.History.PushNewItem(hist);
                hist = null;
            }

            lasso_polygon.Clear();
            is_drawing = false;
        }
示例#14
0
        public override Gtk.Widget GetDisplayWidget()
        {
            DrawingArea colorPreview = new DrawingArea ();

            colorPreview.ModifyBg(StateType.Normal, GetColor ());
            colorPreview.WidthRequest = 15;

            Alignment colorPreviewAlign = new Alignment (0, 0, 0, 1);
            colorPreviewAlign.SetPadding (2, 2, 2, 2);
            colorPreviewAlign.Add (colorPreview);

            string labelText;

            System.Drawing.Color color = (System.Drawing.Color) parentRow.PropertyValue;
            //TODO: dropdown known color selector so this does something
            if (color.IsKnownColor)
                labelText = color.Name;
            else if (color.IsEmpty)
                labelText = "[empty]";
            else
                labelText = String.Format("#{0:x2}{1:x2}{2:x2}", color.R, color.G, color.B);

            //we use StringValue as it auto-bolds the text for non-default values
            Label theLabel = (Label) base.StringValue (labelText);
            theLabel.Xalign = 0;
            theLabel.Xpad = 3;

            HBox hbox = new HBox ();
            hbox.PackStart (colorPreviewAlign, false, false, 0);
            hbox.PackStart (theLabel, true, true, 0);

            return hbox;
        }
示例#15
0
        public override void EditPlayer(Text text)
        {
            playerText = text;
            if (playerDialog == null) {
                Gtk.Dialog d = new Gtk.Dialog (Catalog.GetString ("Select player"),
                                   this, DialogFlags.Modal | DialogFlags.DestroyWithParent,
                                   Stock.Cancel, ResponseType.Cancel);
                d.WidthRequest = 600;
                d.HeightRequest = 400;

                DrawingArea da = new DrawingArea ();
                TeamTagger tagger = new TeamTagger (new WidgetWrapper (da));
                tagger.ShowSubstitutionButtons = false;
                tagger.LoadTeams ((ViewModel.Project as ProjectLongoMatch).LocalTeamTemplate, (ViewModel.Project as ProjectLongoMatch).VisitorTeamTemplate,
                                  (ViewModel.Project as ProjectLongoMatch).Dashboard.FieldBackground);
                tagger.PlayersSelectionChangedEvent += players => {
                    if (players.Count == 1) {
                        Player p = players [0];
                        playerText.Value = p.ToString ();
                        d.Respond (ResponseType.Ok);
                    }
                    tagger.ResetSelection ();
                };
                d.VBox.PackStart (da, true, true, 0);
                d.ShowAll ();
                playerDialog = d;
            }
            if (playerDialog.Run () != (int)ResponseType.Ok) {
                text.Value = null;
            }
            playerDialog.Hide ();
        }
示例#16
0
        protected override void OnMouseDown(Gtk.DrawingArea canvas, Gtk.ButtonPressEventArgs args, Cairo.PointD point)
        {
            if (surface_modified)
            {
                return;
            }

            surface_modified = false;
            undo_surface     = PintaCore.Workspace.ActiveDocument.CurrentLayer.Surface.Clone();
            Color tool_color;

            if (args.Event.Button == 1)             // left
            {
                tool_color = PintaCore.Palette.PrimaryColor;
            }
            else if (args.Event.Button == 3)             // right
            {
                tool_color = PintaCore.Palette.SecondaryColor;
            }
            else
            {
                last_point = point_empty;
                return;
            }

            Draw(canvas, tool_color, point, true);
        }
示例#17
0
        protected override void OnMouseDown(Gtk.DrawingArea canvas, Gtk.ButtonPressEventArgs args, Cairo.PointD point)
        {
            // If we are already drawing, ignore any additional mouse down events
            if (mouse_button > 0)
            {
                return;
            }

            surface_modified = false;
            undo_surface     = PintaCore.Workspace.ActiveDocument.CurrentUserLayer.Surface.Clone();
            mouse_button     = args.Event.Button;
            Color tool_color;

            if (mouse_button == 1)
            {
                tool_color = PintaCore.Palette.PrimaryColor;
            }
            else if (mouse_button == 3)
            {
                tool_color = PintaCore.Palette.SecondaryColor;
            }
            else
            {
                last_point = point_empty;
                return;
            }

            Draw(canvas, tool_color, point, true);
        }
        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";
        }
        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);
        }
示例#20
0
        protected override void OnMouseUp(Gtk.DrawingArea canvas, Gtk.ButtonReleaseEventArgs args, Cairo.PointD point)
        {
            Document doc = PintaCore.Workspace.ActiveDocument;

            doc.ToolLayer.Hidden = true;

            if (surface_modified)
            {
                PintaCore.History.PushNewItem(new SimpleHistoryItem(Icon, Name, undo_surface, doc.CurrentLayerIndex));
            }
            else if (undo_surface != null)
            {
                (undo_surface as IDisposable).Dispose();
            }

            surface_modified = false;
            ImageSurface surf = doc.CurrentLayer.Surface;

            using (Context g = new Context(surf)) {
                g.AppendPath(doc.Selection.SelectionPath);
                g.FillRule = FillRule.EvenOdd;
                g.Clip();

                g.Antialias = UseAntialiasing ? Antialias.Subpixel : Antialias.None;

                if (path != null)
                {
                    g.AppendPath(path);
                    (path as IDisposable).Dispose();
                    path = null;
                }

                g.ClosePath();
                g.LineWidth = BrushWidth;
                g.LineJoin  = LineJoin.Round;
                g.LineCap   = LineCap.Round;
                g.FillRule  = FillRule.EvenOdd;

                if (FillShape && StrokeShape)
                {
                    g.Color = fill_color;
                    g.FillPreserve();
                    g.Color = outline_color;
                    g.Stroke();
                }
                else if (FillShape)
                {
                    g.Color = outline_color;
                    g.Fill();
                }
                else
                {
                    g.Color = outline_color;
                    g.Stroke();
                }
            }

            doc.Workspace.Invalidate();
        }
 public WorkspaceService(Gtk.Bin mainWindow, DrawingArea designArea,DrawingArea previewArea, PropertyGrid.PropertyGrid propertyGrid,Gtk.Label statusLabel)
 {
     this.designArea = designArea;
     this.previewArea = previewArea;
     this.propertyGrid = propertyGrid;
     this.mainControl = mainWindow;
     this.StatusLabel = statusLabel;
 }
示例#22
0
        protected override void OnMouseDown(DrawingArea canvas, ButtonPressEventArgs args, Cairo.PointD point)
        {
            shape_origin = point;
            is_drawing = true;

            hist = new SelectionHistoryItem (Icon, Name);
            hist.TakeSnapshot ();
        }
示例#23
0
 ///<summary>
 /// Realizes the areas.
 ///</summary>
 public void Realize(Gtk.DrawingArea da)
 {
     areaGroup.DrawingArea = da;
     foreach (Area a in areaGroup.Areas)
     {
         a.Realize();
     }
 }
示例#24
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;
 }
示例#25
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;
 }
示例#26
0
    //called for cleaning the graph of a event done before than the current
    public static void ClearDrawingArea(Gtk.DrawingArea da, Gdk.Pixmap px)
    {
        if (px == null)
        {
            px = new Gdk.Pixmap(da.GdkWindow, da.Allocation.Width, da.Allocation.Height, -1);
        }

        UtilGtk.ErasePaint(da, px);
    }
示例#27
0
 // --- Constructor of class -------------------
 public AlexPloygon() : base("AlexPloygon")
 {
     // Create a drawing surface
     drawingArea = new Gtk.DrawingArea();
     // Insert it into the window
     this.Add(drawingArea);
     // Display the drawing surface
     drawingArea.Show();
 }
示例#28
0
        protected override void OnMouseUp(Gtk.DrawingArea canvas, Gtk.ButtonReleaseEventArgs args, Cairo.PointD point)
        {
            if (!IsActive || !using_mouse)
            {
                return;
            }

            OnFinishTransform(transform);
        }
示例#29
0
        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();
        }
示例#30
0
        public VideoView()
        {
            preview_pos = PreviewPos.ButtonRight;

            VBox vbox = new VBox(false, 0);

            vbox.Show();

            Frame frame = new Frame();

            //frame.BorderWidth = 5;
            frame.Show();

            vbox.Add(frame);

            mainView = new Gtk.EventBox();
            mainView.WidthRequest  = 400;
            mainView.HeightRequest = 300;
            mainView.ModifyBg(Gtk.StateType.Normal, new Gdk.Color(255, 255, 255));
            mainView.ModifyBg(Gtk.StateType.Active, new Gdk.Color(255, 255, 255));
            mainView.Show();

            //this.WidthRequest = 333; // 500; //250;
            //this.HeightRequest = 250; // 375; //187; 250
            preview = new Gtk.DrawingArea();
            preview.WidthRequest  = 120;            // 75; //150;
            preview.HeightRequest = 90;             // 56; //112;
            preview.ModifyBg(Gtk.StateType.Normal, new Gdk.Color(0, 0, 0));
            preview.ModifyBg(Gtk.StateType.Active, new Gdk.Color(0, 0, 0));
            preview.Show();

            fix = new Gtk.Fixed();
            fix.Put(preview, space, space);
            fix.Show();
            mainView.Add(fix);

            frame.Add(mainView);

//			Label label = new Label(Catalog.GetString("Video Chat in progress..."));

//			label.Show();
//			vbox.PackStart(label, false, true, 0);

            Button button = new Button(Catalog.GetString("End Call"));

            button.Clicked += OnCloseVideoClicked;
            button.Show();
            vbox.PackStart(button, false, false, 5);

            this.Add(vbox);
            mainView.SizeAllocated += OnSizeAllocated;
//			this.SizeRequested += OnsizeRequested;
            this.QueueResize();
            MovePreview();
        }
示例#31
0
        private Cell firstLinkingCell; // premiere cellule à lier à une deuxième

        #endregion Fields

        #region Constructors

        // Constructeur
        public Circuit(DrawingArea drawingAera, Label cellCount)
        {
            cells = new List<Cell>();
            ios = new List<InOut>();
            color = new Colors();
            this.drawingAera = drawingAera;
            this.cellCount = cellCount;
            showLayer = new bool[] {true, true};
            updateStatusBarCellCount();
            draw();
        }
示例#32
0
        protected override void OnMouseDown(Gtk.DrawingArea canvas, Gtk.ButtonPressEventArgs args, Cairo.PointD point)
        {
            Document doc = PintaCore.Workspace.ActiveDocument;

            surface_modified = false;
            undo_surface     = doc.CurrentUserLayer.Surface.Clone();
            path             = null;

            doc.ToolLayer.Clear();
            doc.ToolLayer.Hidden = false;
        }
示例#33
0
		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 ();
		}
示例#34
0
	public override void Realize()
	{
		Gtk.DrawingArea da = areaGroup.DrawingArea;
		
		drawer = new DummyDrawer(da, drawerInformation);

		lineGC = new Gdk.GC(da.GdkWindow);

		lineGC.RgbFgColor = drawer.Info.fgNormal[(int)Drawer.RowType.Even, (int)Drawer.ColumnType.Even];

		base.Realize();
	}
示例#35
0
        /// <summary>
        /// Creates and shows samplePlot [index]
        /// </summary>
        private void ShowSample(int index)
        {
            layout.Remove(plotCanvas);                          // remove previous sample

            currentType   = sampleTypes [index];
            currentSample = (PlotSample)Activator.CreateInstance(currentType);
            plotCanvas    = currentSample.Canvas;

            infoBox.Buffer.Text = currentSample.InfoText;               // update info Text
            layout.Attach(plotCanvas, 0, 8, 0, 8);                      // attach new sample
            ShowAll();
        }
示例#36
0
        protected override void OnMouseDown(DrawingArea canvas, ButtonPressEventArgs args, Cairo.PointD point)
        {
            // Ignore extra button clicks while drawing
            if (is_drawing)
                return;

            shape_origin = point;
            is_drawing = true;

            hist = new SelectionHistoryItem (Icon, Name);
            hist.TakeSnapshot ();
        }
示例#37
0
 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);
 }
示例#38
0
文件: VideoView.cs 项目: GNOME/banter
        public VideoView()
        {
            preview_pos = PreviewPos.ButtonRight;

            VBox vbox = new VBox(false, 0);
            vbox.Show();

            Frame frame = new Frame();
            //frame.BorderWidth = 5;
            frame.Show();

            vbox.Add(frame);

            mainView = new Gtk.EventBox();
            mainView.WidthRequest = 400;
            mainView.HeightRequest = 300;
            mainView.ModifyBg (Gtk.StateType.Normal, new Gdk.Color (255,255,255));
            mainView.ModifyBg (Gtk.StateType.Active, new Gdk.Color (255,255,255));
            mainView.Show();

            //this.WidthRequest = 333; // 500; //250;
            //this.HeightRequest = 250; // 375; //187; 250
            preview = new Gtk.DrawingArea ();
            preview.WidthRequest = 120; // 75; //150;
            preview.HeightRequest = 90; // 56; //112;
            preview.ModifyBg (Gtk.StateType.Normal, new Gdk.Color (0,0,0));
            preview.ModifyBg (Gtk.StateType.Active, new Gdk.Color (0,0,0));
            preview.Show();

            fix = new Gtk.Fixed ();
            fix.Put (preview, space, space);
            fix.Show();
            mainView.Add(fix);

            frame.Add(mainView);

            //			Label label = new Label(Catalog.GetString("Video Chat in progress..."));

            //			label.Show();
            //			vbox.PackStart(label, false, true, 0);

            Button button = new Button(Catalog.GetString("End Call"));
            button.Clicked += OnCloseVideoClicked;
            button.Show();
            vbox.PackStart(button, false, false, 5);

            this.Add(vbox);
            mainView.SizeAllocated += OnSizeAllocated;
            //			this.SizeRequested += OnsizeRequested;
            this.QueueResize ();
            MovePreview ();
        }
示例#39
0
    void CreateWindow()
    {
        window = new Gtk.Window("animation viewer");
        window.SetDefaultSize(640, 480);

        drawing_area = new Gtk.DrawingArea();

        painter = new Painter(drawing_area, 200);
        painter.Add(Layer.Background, DrawFrame);

        window.Add(drawing_area);
        window.ShowAll();
    }
示例#40
0
	void CreateWindow ()
	{
		window = new Gtk.Window ("animation viewer");
		window.SetDefaultSize (640, 480);

		drawing_area = new Gtk.DrawingArea ();

		painter = new Painter (drawing_area, 200);
		painter.Add (Layer.Background, DrawFrame);

		window.Add (drawing_area);
		window.ShowAll ();
	}
示例#41
0
 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;
 }
示例#42
0
        ///<summary>Handle mouse motion</summary>
        internal void OnMotionNotify(object o, MotionNotifyEventArgs args)
        {
            Gdk.EventMotion e = args.Event;
            Gtk.DrawingArea da = (Gtk.DrawingArea)o;
            int             x, y;

            Gdk.ModifierType state;

            if (e.IsHint)
            {
                da.GdkWindow.GetPointer(out x, out y, out state);
            }
            else
            {
                x     = (int)e.X;
                y     = (int)e.Y;
                state = e.State;
            }

            // if left mouse button is not down
            if ((state & Gdk.ModifierType.Button1Mask) == 0)
            {
                return;
            }

            // find in which area the pointer is
            Area clickArea = GetAreaByXY(x, y);

            if (clickArea == null)
            {
                return;
            }

            // get the position in the file
            Position pos = new Position();

            CalculatePosition(clickArea, (int)(x - clickArea.X), (int)(y - clickArea.Y), ref pos);

            // update selection and cursor if they have changed externally
            UpdateSelection(pos.First != pos.Second);

            // Evaluate selection before moving the cursor
            // for better visual result
            selEndPos = pos;

            // give the focus to the appropriate area
            // do this before setting the new cursor/selection
            UpdateFocus(clickArea);

            EvaluateSelection(DataViewDisplay.ShowType.Closest);
        }
示例#43
0
        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));
        }
示例#44
0
		public DemoRotatedText () : base ("Rotated text")
		{
			DrawingArea drawingArea = new DrawingArea ();
			Gdk.Color white = new Gdk.Color (0xff, 0xff, 0xff);

			// This overrides the background color from the theme
			drawingArea.ModifyBg (StateType.Normal, white);
			drawingArea.ExposeEvent += new ExposeEventHandler (RotatedTextExposeEvent);

			this.Add (drawingArea);
			this.DeleteEvent += new DeleteEventHandler (OnWinDelete);
			this.SetDefaultSize (2 * RADIUS, 2 * RADIUS);
			this.ShowAll ();
		}
示例#45
0
        public MainWindow_Cairo()
            : base("Simple Drawing")
        {
            SetDefaultSize(800, 600);
            SetPosition(WindowPosition.Center);
            DeleteEvent += delegate { Application.Quit(); };

            DrawingArea draw = new DrawingArea();

            draw.ExposeEvent += OnExpose;

            Add(draw);

            ShowAll();
        }
示例#46
0
        protected override void OnMouseUp(Gtk.DrawingArea canvas, Gtk.ButtonReleaseEventArgs args, Cairo.PointD point)
        {
            Document doc = PintaCore.Workspace.ActiveDocument;

            if (surface_modified)
            {
                doc.History.PushNewItem(new SimpleHistoryItem(Icon, Name, undo_surface, doc.CurrentLayerIndex));
            }
            else if (undo_surface != null)
            {
                (undo_surface as IDisposable).Dispose();
            }

            surface_modified = false;
        }
示例#47
0
        protected override void OnMouseUp(Gtk.DrawingArea canvas, Gtk.ButtonReleaseEventArgs args, Cairo.PointD point)
        {
            // If we were dragging the text around, finish that up
            if (tracking)
            {
                Cairo.PointD delta = new Cairo.PointD(point.X - startMouseXY.X, point.Y - startMouseXY.Y);

                clickPoint = new Point((int)(startClickPoint.X + delta.X), (int)(startClickPoint.Y + delta.Y));
                CurrentTextEngine.Origin = clickPoint;

                RedrawText(false, true);
                tracking = false;
                SetCursor(null);
            }
        }
示例#48
0
文件: Main.cs 项目: dskynar/Exercises
        public static void Main(string[] args)
        {
            Application.Init ();
            MainWindow win = new MainWindow ();
            DrawingArea a = new DrawingArea ();
            a.ButtonPressEvent += HandleAButtonPressEvent;
            a.ButtonPressEvent += delegate(object o, ButtonPressEventArgs PressArgs) {
                Console.WriteLine ("Button Pressed");
            };

            win.Add (a);

            win.Show ();
            Application.Run ();
        }
示例#49
0
        protected override void OnMouseDown(Gtk.DrawingArea canvas, Gtk.ButtonPressEventArgs args, Cairo.PointD point)
        {
            // If we are already drawing, ignore any additional mouse down events
            if (mouse_button > 0)
            {
                return;
            }

            Document doc = PintaCore.Workspace.ActiveDocument;

            surface_modified = false;
            undo_surface     = doc.CurrentUserLayer.Surface.Clone();
            mouse_button     = args.Event.Button;

            OnMouseMove(canvas, null, point);
        }
示例#50
0
 // }}}
 // 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;
 }
示例#51
0
        protected override void OnMouseDown(DrawingArea canvas, ButtonPressEventArgs args, Cairo.PointD point)
        {
            // Ignore extra button clicks while drawing
            if (is_drawing)
                return;

            Document doc = PintaCore.Workspace.ActiveDocument;

            // Selection is around the pixel selection so add 1 pixel
            double x = Utility.Clamp (point.X, 0, doc.ImageSize.Width);
            double y = Utility.Clamp (point.Y, 0, doc.ImageSize.Height);
            shape_origin = new PointD (x, y);

            is_drawing = true;

            hist = new SelectionHistoryItem (Icon, Name);
            hist.TakeSnapshot ();
        }
示例#52
0
		public void BackGroundColorChangeMenuBar()
		{
			try {

				da1 = new DrawingArea ();
				da1.ExposeEvent += OnExposed1;

				Gdk.Color col = new Gdk.Color ();
				Gdk.Color.Parse ("#3b5998", ref col);

				ModifyBg (StateType.Normal, col);
				da1.ModifyBg (StateType.Normal, col);



			} catch (Exception ex) {
				Console.Write (ex.Message);
			}
		}
示例#53
0
        protected override void OnMouseDown(Gtk.DrawingArea canvas, Gtk.ButtonPressEventArgs args, Cairo.PointD point)
        {
            if (is_drawing)
            {
                return;
            }

            hist = new SelectionHistoryItem(Icon, Name);
            hist.TakeSnapshot();

            combine_mode = PintaCore.Workspace.SelectionHandler.DetermineCombineMode(args);
            path         = null;
            is_drawing   = true;

            var doc = PintaCore.Workspace.ActiveDocument;

            doc.PreviousSelection.Dispose();
            doc.PreviousSelection = doc.Selection.Clone();
        }
示例#54
0
        public MainWindow_Cairo2()
            : base("Cairo2")
        {
            SetDefaultSize(350, 250);
            SetPosition(WindowPosition.Center);
            DeleteEvent += delegate
            {
                    Application.Quit();
            };

            GLib.Timeout.Add(100, new GLib.TimeoutHandler(OnTimer));

            _area = new DrawingArea();
            _area.ExposeEvent += OnExpose;

            Add(_area);

            ShowAll();
        }
示例#55
0
        static void OnExposed(object o, ExposeEventArgs args)
        {
            if (Graphics.DrawingThread.IsAlive)
            {
                Graphics.DrawingThread.Join();
            }

            Gdk.Threads.Enter();

            Gtk.DrawingArea area = (DrawingArea)o;
            Gdk.Window      win  = area.GdkWindow;
            Gdk.GC          gc   = new Gdk.GC(win);
            //Cairo.Context g = CairoHelper.Create(win);

            win.DrawDrawable(gc, Graphics.Pixmap, 0, 0, 0, 0, Globals.WIDTH, Globals.HEIGHT);

            //((IDisposable)g.Target).Dispose();
            //((IDisposable)g).Dispose();

            Gdk.Threads.Leave();
        }
示例#56
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.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 ();
            };
        }
示例#57
0
        /// <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 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);
                }
            };
        }
示例#59
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);
        }
示例#60
0
        ///<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);
        }