1

次のように Build() 関数を含む gtk にウィンドウがあります。

protected virtual void Build()
{
    global::Stetic.Gui.Initialize(this);
    // Widget Client.Forms.Notification
    this.Name = "Client.Forms.Notification";
    this.Title = "Notification";
    this.TypeHint = Gdk.WindowTypeHint.Normal;
    //this.TypeHint = ((global::Gdk.WindowTypeHint)(4));
    this.WindowPosition = ((global::Gtk.WindowPosition)(4));
    // Container child Client.Forms.Notification.Gtk.Container+ContainerChild
    this.vbox1 = new global::Gtk.VBox();
    this.vbox1.Name = "vbox1";
    this.vbox1.Spacing = 6;
    // Container child vbox1.Gtk.Box+BoxChild
    this.label1 = new global::Gtk.Label();
    this.label1.HeightRequest = 20;
    this.label1.Name = "label1";
    this.label1.LabelProp = "Notification";
    this.vbox1.Add(this.label1);
    global::Gtk.Box.BoxChild w1 = ((global::Gtk.Box.BoxChild)(this.vbox1[this.label1]));
    w1.Position = 0;
    w1.Expand = false;
    w1.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.image1 = new global::Gtk.Image();
    this.image1.Name = "image1";
    this.image1.Pixbuf = global::Gdk.Pixbuf.LoadFromResource("Client.Resources.icon.png");
    this.hbox1.Add(this.image1);
    global::Gtk.Box.BoxChild w2 = ((global::Gtk.Box.BoxChild)(this.hbox1[this.image1]));
    w2.Position = 0;
    w2.Expand = false;
    w2.Fill = false;
    // Container child hbox1.Gtk.Box+BoxChild
    this.label2 = new global::Gtk.Label();
    this.label2.Name = "label2";
    this.label2.WidthRequest = 260;
    this.label2.Wrap = true;
    this.label2.LabelProp = "Description";
    this.hbox1.Add(this.label2);
    global::Gtk.Box.BoxChild w3 = ((global::Gtk.Box.BoxChild)(this.hbox1[this.label2]));
    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;
    this.label1.ModifyBase(Gtk.StateType.Normal, Core.fromColor(System.Drawing.Color.Orange));
    this.ModifyBase(Gtk.StateType.Normal, Core.fromColor(System.Drawing.Color.Orange));
    this.vbox1.ModifyBase(Gtk.StateType.Normal, Core.fromColor(System.Drawing.Color.Orange));
    root = new Gtk.EventBox();
    root.Add(this.vbox1);
    this.Decorated = false;
    this.Add(root);
    if ((this.Child != null))
    {
        this.Child.ShowAll();
    }
    this.DefaultWidth = 460;
    this.DefaultHeight = 220;
}

(このウィンドウ全体のソース コード: https://github.com/pidgeonproject/pidgeon/blob/master/Forms/Notification.cs )

ご覧のとおり、呼び出し中です

this.ModifyBase(Gtk.StateType.Normal, Core.fromColor(System.Drawing.Color.Orange));

背景をオレンジ色に変更する必要がありますが、そうではありません。

ウィンドウ要素に同様の関数を挿入しようとしましたが、どちらも機能しません。ウィンドウの背景色を変更する方法を知っている人はいますか?

私がやりたいのは、特定の色とテキストの装飾のない小さなウィンドウ (つまり、長方形のみ) を作成することです。このウィンドウは透明であるはずで (現在は機能しています)、画像とテキスト付きの 2 つのラベルがあり、クリックすると消えます。これはすべて機能しますが、背景を灰色からより良い色に変更することはできません。他の方法でこれを行うことができる回答があれば幸いです(描画領域だけで小さなフォームを作成し、それを色でペイントしてからテキストもペイントすることを考えることができますが、私にはかなり複雑に聞こえます私がやりたいほど単純なことのために)。

注: mono は GTK 2 を使用しており、.Net 用の GTK# のバージョンは 2.12.20 を使用しています。

4

3 に答える 3

4

イベントボックスを使ってみてください。動作するようです

于 2013-04-05T19:17:03.293 に答える