forked from MonoGame/MonoGame
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathStyles.Linux.cs
124 lines (100 loc) · 4.33 KB
/
Styles.Linux.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
// MonoGame - Copyright (C) The MonoGame Team
// This file is subject to the terms and conditions defined in
// file 'LICENSE.txt', which is part of this source code package.
using System;
using System.Runtime.InteropServices;
using Eto;
using Eto.GtkSharp.Forms;
using Eto.GtkSharp.Forms.Controls;
using Eto.GtkSharp.Forms.ToolBar;
namespace MonoGame.Tools.Pipeline
{
static partial class Gtk3Wrapper
{
public const string gtklibpath = "libgtk-3.so.0";
[DllImport(gtklibpath, CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr gtk_header_bar_new();
[DllImport(gtklibpath, CallingConvention = CallingConvention.Cdecl)]
public static extern void gtk_window_set_titlebar(IntPtr window, IntPtr widget);
[DllImport(gtklibpath, CallingConvention = CallingConvention.Cdecl)]
public static extern void gtk_header_bar_pack_start(IntPtr bar, IntPtr child);
[DllImport(gtklibpath, CallingConvention = CallingConvention.Cdecl)]
public static extern void gtk_header_bar_pack_end(IntPtr bar, IntPtr child);
[DllImport(gtklibpath, CallingConvention = CallingConvention.Cdecl)]
public static extern void gtk_header_bar_set_show_close_button(IntPtr handle, bool show);
}
public static class Styles
{
public static void Load()
{
Style.Add<DialogHandler>("HeaderBar", h =>
{
var title = h.Title;
var headerBar = Gtk3Wrapper.gtk_header_bar_new();
Gtk3Wrapper.gtk_window_set_titlebar(h.Control.Handle, headerBar);
h.Title = title;
if (h.AbortButton.Text == "Close")
{
Gtk3Wrapper.gtk_header_bar_set_show_close_button(headerBar, true);
return;
}
var defButton = (Gtk.Button)h.DefaultButton.ControlObject;
defButton.StyleContext.AddClass("suggested-action");
Gtk3Wrapper.gtk_header_bar_pack_end(headerBar, defButton.Handle);
Gtk3Wrapper.gtk_header_bar_pack_start(headerBar, ((Gtk.Button)h.AbortButton.ControlObject).Handle);
});
Style.Add<LabelHandler>("Wrap", h => h.Control.MaxWidthChars = 55);
Style.Add<ToolBarHandler>("ToolBar", h =>
{
h.Control.ToolbarStyle = Gtk.ToolbarStyle.Icons;
h.Control.IconSize = Gtk.IconSize.SmallToolbar;
});
Style.Add<TreeViewHandler>("Scroll", h =>
{
var treeView = h.Control.Child as Gtk.TreeView;
Gtk.TreeIter lastIter, iter;
if (treeView.Model.GetIterFirst(out iter))
{
do
{
lastIter = iter;
}
while (treeView.Model.IterNext(ref iter));
var path = treeView.Model.GetPath(lastIter);
treeView.ScrollToCell(path, null, false, 0, 0);
}
});
Style.Add<DrawableHandler>("Stretch", h =>
{
var parent = h.Control.Parent.Parent.Parent.Parent.Parent.Parent;
parent.SizeAllocated += delegate
{
var al = h.Control.Allocation;
al.Width = parent.AllocatedWidth - 2;
h.Control.SetAllocation(al);
};
});
Style.Add<PixelLayoutHandler>("Stretch", h =>
{
var parent = h.Control.Parent.Parent.Parent.Parent.Parent;
parent.SizeAllocated += delegate
{
var al = h.Control.Allocation;
al.Width = parent.AllocatedWidth;
h.Control.SetAllocation(al);
};
});
Style.Add<DropDownHandler>("OverrideSize", h =>
{
var cell = (h.Control.Child as Gtk.ComboBox).Cells[0] as Gtk.CellRendererText;
cell.Ellipsize = Pango.EllipsizeMode.End;
h.Control.SizeAllocated += delegate
{
var al = h.Control.Allocation;
al.Height = CellCombo.Height;
h.Control.SetAllocation(al);
};
});
}
}
}