mono gtk最大化,但仍然在顶部空间

时间:2013-06-06 12:29:16

标签: mono monodevelop gtk# maximize-window

Hy all,

我正在玩monodevelop并且正在使用gtk作为窗口。我当然使用的是Windows 7 x64。

我遇到的问题是,当我最大化窗口(手动或程序,无关紧要)时,页面顶部仍有一些空间。并且它在屏幕底部连接不好。因此看起来整个程序最大化,然后放下几个像素。

这是最大化窗口的屏幕截图: Maximized Windows

正如您在第二个版画屏幕中看到的那样,将程序置于最顶层是可行的: small window that can reach the top

所以我的问题很简单......我怎样才能以一种正常的方式最大化窗口...

修改 MainWindow.cs中的代码(root / gtk-gui / MainWindow.cs)

// This file has been generated by the GUI designer. Do not modify.
public partial class MainWindow
{
    private global::Gtk.UIManager UIManager;
    private global::Gtk.Action FileAction;
    private global::Gtk.Action stopAction;
    private global::Gtk.HPaned hpaned1;
    private global::Gtk.VBox vbox1;
    private global::Gtk.MenuBar menubar2;
    private global::Gtk.HBox hbox1;
    private global::Gtk.Button button1;
    private global::Gtk.HPaned hpaned3;
    private global::Gtk.ScrolledWindow GtkScrolledWindow;
    private global::Gtk.TreeView treeview1;
    private global::Gtk.ProgressBar progressbar1;

    protected virtual void Build ()
    {
        global::Stetic.Gui.Initialize (this);
        // Widget MainWindow
        this.UIManager = new global::Gtk.UIManager ();
        global::Gtk.ActionGroup w1 = new global::Gtk.ActionGroup ("Default");
        this.FileAction = new global::Gtk.Action ("FileAction", global::Mono.Unix.Catalog.GetString ("File"), null, null);
        this.FileAction.ShortLabel = global::Mono.Unix.Catalog.GetString ("File");
        w1.Add (this.FileAction, null);
        this.stopAction = new global::Gtk.Action ("stopAction", global::Mono.Unix.Catalog.GetString ("Exit"), null, "gtk-stop");
        this.stopAction.ShortLabel = global::Mono.Unix.Catalog.GetString ("Exit");
        w1.Add (this.stopAction, null);
        this.UIManager.InsertActionGroup (w1, 0);
        this.AddAccelGroup (this.UIManager.AccelGroup);
        this.Name = "MainWindow";
        this.Title = global::Mono.Unix.Catalog.GetString ("Maximized Window");
        this.WindowPosition = ((global::Gtk.WindowPosition)(3));
        this.AllowShrink = true;
        this.DefaultWidth = 1024;
        this.DefaultHeight = 768;
        // Container child MainWindow.Gtk.Container+ContainerChild
        this.hpaned1 = new global::Gtk.HPaned ();
        this.hpaned1.CanFocus = true;
        this.hpaned1.Name = "hpaned1";
        this.hpaned1.Position = 1;
        // Container child hpaned1.Gtk.Paned+PanedChild
        this.vbox1 = new global::Gtk.VBox ();
        this.vbox1.Name = "vbox1";
        this.vbox1.Spacing = 6;
        // Container child vbox1.Gtk.Box+BoxChild
        this.UIManager.AddUiFromString ("<ui><menubar name=\'menubar2\'><menu name=\'FileAction\' action=\'FileAction\'><menuite" +
                "m name=\'stopAction\' action=\'stopAction\'/></menu></menubar></ui>");
        this.menubar2 = ((global::Gtk.MenuBar)(this.UIManager.GetWidget ("/menubar2")));
        this.menubar2.Name = "menubar2";
        this.vbox1.Add (this.menubar2);
        global::Gtk.Box.BoxChild w2 = ((global::Gtk.Box.BoxChild)(this.vbox1 [this.menubar2]));
        w2.Position = 0;
        w2.Expand = false;
        w2.Fill = false;
        // Container child vbox1.Gtk.Box+BoxChild
        this.hbox1 = new global::Gtk.HBox ();
        this.hbox1.Name = "hbox1";
        this.hbox1.Spacing = 6;
        // Container child hbox1.Gtk.Box+BoxChild
        this.button1 = new global::Gtk.Button ();
        this.button1.CanFocus = true;
        this.button1.Name = "button1";
        this.button1.UseUnderline = true;
        this.button1.Label = global::Mono.Unix.Catalog.GetString ("GtkButton");
        this.hbox1.Add (this.button1);
        global::Gtk.Box.BoxChild w3 = ((global::Gtk.Box.BoxChild)(this.hbox1 [this.button1]));
        w3.Position = 1;
        w3.Expand = false;
        w3.Fill = false;
        this.vbox1.Add (this.hbox1);
        global::Gtk.Box.BoxChild w4 = ((global::Gtk.Box.BoxChild)(this.vbox1 [this.hbox1]));
        w4.Position = 1;
        w4.Expand = false;
        w4.Fill = false;
        // Container child vbox1.Gtk.Box+BoxChild
        this.hpaned3 = new global::Gtk.HPaned ();
        this.hpaned3.CanFocus = true;
        this.hpaned3.Name = "hpaned3";
        this.hpaned3.Position = 91;
        this.hpaned3.BorderWidth = ((uint)(2));
        // Container child hpaned3.Gtk.Paned+PanedChild
        this.GtkScrolledWindow = new global::Gtk.ScrolledWindow ();
        this.GtkScrolledWindow.Name = "GtkScrolledWindow";
        this.GtkScrolledWindow.ShadowType = ((global::Gtk.ShadowType)(1));
        // Container child GtkScrolledWindow.Gtk.Container+ContainerChild
        this.treeview1 = new global::Gtk.TreeView ();
        this.treeview1.CanFocus = true;
        this.treeview1.Name = "treeview1";
        this.GtkScrolledWindow.Add (this.treeview1);
        this.hpaned3.Add (this.GtkScrolledWindow);
        global::Gtk.Paned.PanedChild w6 = ((global::Gtk.Paned.PanedChild)(this.hpaned3 [this.GtkScrolledWindow]));
        w6.Resize = false;
        this.vbox1.Add (this.hpaned3);
        global::Gtk.Box.BoxChild w7 = ((global::Gtk.Box.BoxChild)(this.vbox1 [this.hpaned3]));
        w7.Position = 2;
        // Container child vbox1.Gtk.Box+BoxChild
        this.progressbar1 = new global::Gtk.ProgressBar ();
        this.progressbar1.Name = "progressbar1";
        this.vbox1.Add (this.progressbar1);
        global::Gtk.Box.BoxChild w8 = ((global::Gtk.Box.BoxChild)(this.vbox1 [this.progressbar1]));
        w8.Position = 3;
        w8.Expand = false;
        w8.Fill = false;
        this.hpaned1.Add (this.vbox1);
        this.Add (this.hpaned1);
        if ((this.Child != null)) {
            this.Child.ShowAll ();
        }
        this.Show ();
        this.DeleteEvent += new global::Gtk.DeleteEventHandler (this.OnDeleteEvent);
        this.stopAction.Activated += new global::System.EventHandler (this.stopProgram);
    }
}

1 个答案:

答案 0 :(得分:1)

我可以在Windows 8机器上成功重现此行为。

似乎来自设置为WindowPosition的{​​{1}}。然而documentation警告我们使用:

  

请注意,使用 GTK_WIN_POS_CENTER_ALWAYS 几乎总是糟糕的主意。它不一定适用于所有窗口管理器或所有窗口系统。

CenterAlways设置为WindowPosition(0)可以解决我的问题。