Ejemplo n.º 1
0
		public void NativeWindowFrameHasCorrectScreenBounds ()
		{
			var nativeWindow = new Gtk.Window ("Foo");
			nativeWindow.Resize (450, 320);
			nativeWindow.Move (13, 50);
			nativeWindow.ShowAll ();

			WaitForEvents ();

			var window = Toolkit.CurrentEngine.WrapWindow (nativeWindow);
			var bounds = window.ScreenBounds;
			Assert.AreEqual (450, bounds.Width);
			Assert.AreEqual (320, bounds.Height);
			Assert.AreEqual (13, bounds.X);
			Assert.AreEqual (50, bounds.Y);

			nativeWindow.Move (30, 100);
			WaitForEvents ();
			bounds = window.ScreenBounds;
			Assert.AreEqual (30, bounds.X);
			Assert.AreEqual (100, bounds.Y);
			Assert.AreEqual (450, bounds.Width);
			Assert.AreEqual (320, bounds.Height);

			nativeWindow.Resize (100, 100);
			WaitForEvents ();
			bounds = window.ScreenBounds;
			Assert.AreEqual (30, bounds.X);
			Assert.AreEqual (100, bounds.Y);
			Assert.AreEqual (100, bounds.Width);
			Assert.AreEqual (100, bounds.Height);
		}
        public void NativeWindowFrameHasCorrectScreenBounds()
        {
            var nativeWindow = new Gtk.Window("Foo");

            nativeWindow.Resize(450, 320);
            nativeWindow.Move(13, 50);
            nativeWindow.ShowAll();

            WaitForEvents();

            var window = Toolkit.CurrentEngine.WrapWindow(nativeWindow);
            var bounds = window.ScreenBounds;

            Assert.AreEqual(450, bounds.Width);
            Assert.AreEqual(320, bounds.Height);
            Assert.AreEqual(13, bounds.X);
            Assert.AreEqual(50, bounds.Y);

            nativeWindow.Move(30, 100);
            WaitForEvents();
            bounds = window.ScreenBounds;
            Assert.AreEqual(30, bounds.X);
            Assert.AreEqual(100, bounds.Y);
            Assert.AreEqual(450, bounds.Width);
            Assert.AreEqual(320, bounds.Height);

            nativeWindow.Resize(100, 100);
            WaitForEvents();
            bounds = window.ScreenBounds;
            Assert.AreEqual(30, bounds.X);
            Assert.AreEqual(100, bounds.Y);
            Assert.AreEqual(100, bounds.Width);
            Assert.AreEqual(100, bounds.Height);
        }
Ejemplo n.º 3
0
        static void RunGtkWindow()
        {
            Gtk.Application.Init();
            Gtk.Window myWin = new Gtk.Window("My first GTK# Application! ");
            myWin.Resize(200, 200);
            myWin.ButtonPressEvent += (s, ev) =>
            {
            };
            //Create a label and put some text in it.

            Gtk.Label myLabel = new Gtk.Label();
            myLabel.Text = "Hello World!!!!";

            //Add the label to the form
            // myWin.Add(myLabel);

            Gtk.Button gtk_but = new Gtk.Button();
            gtk_but.HeightRequest = 100;
            gtk_but.WidthRequest  = 100;
            gtk_but.Label         = "button";
            myWin.Add(gtk_but);
            //Show Everything

            myWin.ShowAll();

            Gtk.Application.Run();
        }
        private static void RestoreWindowState(Gtk.Window window)
        {
            var position      = Properties.Settings.Default.WindowPosition;
            var positionValid = false;

            foreach (var desktopWorkArea in Gdk.Global.DesktopWorkareas)
            {
                positionValid = desktopWorkArea.Contains(position);
                if (positionValid)
                {
                    break;
                }
            }
            if (!positionValid)
            {
                var desktop = Gdk.Global.CurrentDesktop;
                var currentDesktopWorkArea = Gdk.Global.DesktopWorkareas[desktop];
                position.X = currentDesktopWorkArea.Left + 40;
                position.Y = currentDesktopWorkArea.Top + 40;
            }
            var size  = Properties.Settings.Default.WindowSize;
            var state = Properties.Settings.Default.WindowState;

            window.Move(position.X, position.Y);
            window.Resize(size.Width, size.Height);
            if (state.HasFlag(Gdk.WindowState.Maximized))
            {
                window.Maximize();
            }
            if (state.HasFlag(Gdk.WindowState.Fullscreen))
            {
                window.Fullscreen();
            }
        }
Ejemplo n.º 5
0
        public void TestResultsWindowIsBelowMainWindow()
        {
            Gtk.Window main    = new Gtk.Window("Test Main Window");
            Gtk.Window results = new Gtk.Window("Test Results Window");

            main.Resize(200, 100);
            results.Resize(200, 100);

            Gdk.Rectangle resultsOffset = new Gdk.Rectangle(0, 10, 0, 0);

            var positioner = new PositionWindow(main, results);

            positioner.UpdatePosition(10, Pane.First, resultsOffset);

            // Drain the event loop
            while (Gtk.Global.EventsPending)
            {
                Gtk.Main.Iteration();
            }

            int main_x, main_y;
            int results_x, results_y;

            main.GetPosition(out main_x, out main_y);
            results.GetPosition(out results_x, out results_y);
            Assert.Greater(results_y, main_y + 100);
        }
Ejemplo n.º 6
0
 private static void ApplyNewSize(Gtk.Window window, int width, int height)
 {
     if (width > MinWidth &&
         height > MinHeight)
     {
         window.Resize(width, height);
     }
 }
Ejemplo n.º 7
0
        public void Restore()
        {
            if ((options & WindowPersistOptions.Size) != 0)
            {
                int width  = WidthSchema.Get();
                int height = HeightSchema.Get();

                if (width != 0 && height != 0)
                {
                    window.Resize(width, height);
                }
            }

            if ((options & WindowPersistOptions.Position) != 0)
            {
                int x = XPosSchema.Get();
                int y = YPosSchema.Get();

                if (x == 0 && y == 0)
                {
                    window.SetPosition(Gtk.WindowPosition.Center);
                }
                else
                {
                    window.Move(x, y);
                }
            }

            if ((options & WindowPersistOptions.Size) != 0)
            {
                if (MaximizedSchema.Get())
                {
                    window.Maximize();
                }
                else
                {
                    window.Unmaximize();
                }
            }
        }
Ejemplo n.º 8
0
        public void DetachPlayer()
        {
            bool isPlaying = ViewModel.VideoPlayer.Playing;

            /* Pause the player here to prevent the sink drawing while the windows
             * are beeing changed */
            ViewModel.VideoPlayer.Pause();
            if (!detachedPlayer)
            {
                Log.Debug("Detaching player");

                ExternalWindow playerWindow = new ExternalWindow();
                this.playerWindow  = playerWindow;
                playerWindow.Title = Constants.SOFTWARE_NAME;
                int player_width  = playercapturer.Allocation.Width;
                int player_height = playercapturer.Allocation.Height;
                playerWindow.SetDefaultSize(player_width, player_height);
                playerWindow.DeleteEvent += (o, args) => DetachPlayer();
                playerWindow.Show();
                playercapturer.Reparent(playerWindow.Box);
                // Hack to reposition video window in widget for OSX
                playerWindow.Resize(player_width + 10, player_height);
                videowidgetsbox.Visible   = false;
                playsSelection.ExpandTabs = true;
            }
            else
            {
                Log.Debug("Attaching player again");
                videowidgetsbox.Visible = true;
                playercapturer.Reparent(this.videowidgetsbox);
                playerWindow.Destroy();
                playsSelection.ExpandTabs = false;
            }
            if (isPlaying)
            {
                ViewModel.VideoPlayer.Play();
            }
            detachedPlayer = !detachedPlayer;
            playercapturer.AttachPlayer(detachedPlayer);
        }
Ejemplo n.º 9
0
        internal void SetFloatMode(Gdk.Rectangle rect)
        {
            if (floatingWindow == null)
            {
                ResetMode();
                SetRegionStyle(frame.GetRegionStyleForItem(this));

                floatingWindow = new DockFloatingWindow((Gtk.Window)frame.Toplevel, GetWindowTitle());
                Ide.IdeApp.CommandService.RegisterTopWindow(floatingWindow);

                Gtk.VBox box = new Gtk.VBox();
                box.Show();
                box.PackStart(TitleTab, false, false, 0);
                box.PackStart(Widget, true, true, 0);
                floatingWindow.Add(box);
                floatingWindow.DeleteEvent += delegate(object o, Gtk.DeleteEventArgs a) {
                    if (behavior == DockItemBehavior.CantClose)
                    {
                        Status = DockItemStatus.Dockable;
                    }
                    else
                    {
                        Visible = false;
                    }
                    a.RetVal = true;
                };
            }
            floatingWindow.Move(rect.X, rect.Y);
            floatingWindow.Resize(rect.Width, rect.Height);
            floatingWindow.Show();
            if (titleTab != null)
            {
                titleTab.UpdateBehavior();
            }
            Widget.Show();
        }
Ejemplo n.º 10
0
 internal virtual void PlaceWindow(Gtk.Window window, int x, int y, int width, int height)
 {
     window.Move(x, y);
     window.Resize(width, height);
 }
Ejemplo n.º 11
0
 public Window(string title = null)
 {
     window = new Gtk.Window(title);
     window.Resize(200, 100);
     window.DeleteEvent += (i, j) => LuadicrousApplication.Quit();
 }
Ejemplo n.º 12
0
        private void ShowStats(string title, int lines, int words,
		                        int chars)
        {
            Logger.Log ("Wordcount: {0}: {1} {2} {3}", title, lines,
                words, chars);

            stat_win = new Gtk.Window (String.Format (
                "{0} - Word count", title));
            stat_win.Resize (200, 100);

            Gtk.VBox box = new Gtk.VBox (false, 0);

            Gtk.Label stat_label = new Gtk.Label ();
            stat_label.Text = String.Format (
                "{0}\n\nLines: {1}\nWords: {2}\nCharacters: {3}\n",
                title, lines, words, chars);

            box.PackStart (stat_label, true, true, 0);

            Gtk.Button ok = new Gtk.Button ("Close");
            ok.Clicked += new EventHandler (OkHandler);
            box.PackStart (ok, true, true, 0);

            stat_win.Add (box);
            stat_win.ShowAll ();
        }