예제 #1
0
        public void MinSize()
        {
            var win = new Window();
            var w   = CreateWidget();

            win.Content = w;
            win.Show();

            Application.DispatchPendingEvents();

            var defw = w.Size.Width;
            var defh = w.Size.Height;

            w.MinWidth = 300;
            Assert.AreEqual(300, w.MinWidth);
            Assert.AreEqual(300, w.Size.Width);

            w.MinHeight = 400;
            Assert.AreEqual(400, w.MinHeight);
            Assert.AreEqual(400, w.Size.Height);

            w.MinWidth = -1;
            Assert.AreEqual(-1, w.MinWidth);
            Assert.AreEqual(defw, w.Size.Width);

            w.MinHeight = -1;
            Assert.AreEqual(-1, w.MinHeight);
            Assert.AreEqual(defh, w.Size.Height);

            win.Dispose();
        }
예제 #2
0
        public void Coordinates()
        {
            var win = new Window();
            var w   = CreateWidget();

            win.Content = w;
            win.Show();

            Application.DispatchPendingEvents();

            Assert.AreEqual(w.ScreenBounds, win.ScreenBounds);

            win.Dispose();
        }
예제 #3
0
        public void Focus()
        {
            var win = new Window();
            var w   = CreateWidget();

            Run(delegate {
                HBox box    = new HBox();
                TextEntry e = new TextEntry();
                box.PackStart(e);
                box.PackStart(w);
                win.Content = box;
                win.Show();
                win.Present();

//				for (int n=0; n < 500; n++) {
                Application.DispatchPendingEvents();
//					System.Threading.Thread.Sleep (10);
//				}

                e.SetFocus();

                Application.DispatchPendingEvents();

                Assert.IsFalse(w.HasFocus);
                //		Assert.IsTrue (w.CanGetFocus);

                int gotFocus = 0;
                w.GotFocus  += delegate {
                    gotFocus++;
                };

                w.SetFocus();
                Assert.IsTrue(w.HasFocus);
                Assert.AreEqual(1, gotFocus);

                int lostFocus = 0;
                w.LostFocus  += delegate {
                    lostFocus++;
                };

                e.SetFocus();

                Assert.IsFalse(w.HasFocus);
                //			Assert.AreEqual (1, lostFocus);

                win.Dispose();
            });
        }