00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 namespace Stetic {
00012
00013
00014 internal class Gui {
00015
00016 private static bool initialized;
00017
00018 internal static void Initialize(Gtk.Widget iconRenderer) {
00019 if ((Stetic.Gui.initialized == false)) {
00020 Stetic.Gui.initialized = true;
00021 }
00022 }
00023 }
00024
00025 internal class BinContainer {
00026
00027 private Gtk.Widget child;
00028
00029 private Gtk.UIManager uimanager;
00030
00031 public static BinContainer Attach(Gtk.Bin bin) {
00032 BinContainer bc = new BinContainer();
00033 bin.SizeRequested += new Gtk.SizeRequestedHandler(bc.OnSizeRequested);
00034 bin.SizeAllocated += new Gtk.SizeAllocatedHandler(bc.OnSizeAllocated);
00035 bin.Added += new Gtk.AddedHandler(bc.OnAdded);
00036 return bc;
00037 }
00038
00039 private void OnSizeRequested(object sender, Gtk.SizeRequestedArgs args) {
00040 if ((this.child != null)) {
00041 args.Requisition = this.child.SizeRequest();
00042 }
00043 }
00044
00045 private void OnSizeAllocated(object sender, Gtk.SizeAllocatedArgs args) {
00046 if ((this.child != null)) {
00047 this.child.Allocation = args.Allocation;
00048 }
00049 }
00050
00051 private void OnAdded(object sender, Gtk.AddedArgs args) {
00052 this.child = args.Widget;
00053 }
00054
00055 public void SetUiManager(Gtk.UIManager uim) {
00056 this.uimanager = uim;
00057 this.child.Realized += new System.EventHandler(this.OnRealized);
00058 }
00059
00060 private void OnRealized(object sender, System.EventArgs args) {
00061 if ((this.uimanager != null)) {
00062 Gtk.Widget w;
00063 w = this.child.Toplevel;
00064 if (((w != null) && typeof(Gtk.Window).IsInstanceOfType(w))) {
00065 ((Gtk.Window)(w)).AddAccelGroup(this.uimanager.AccelGroup);
00066 this.uimanager = null;
00067 }
00068 }
00069 }
00070 }
00071
00072 internal class IconLoader {
00073
00074 public static Gdk.Pixbuf LoadIcon(Gtk.Widget widget, string name, Gtk.IconSize size, int sz) {
00075 Gdk.Pixbuf res = widget.RenderIcon(name, size, null);
00076 if ((res != null)) {
00077 return res;
00078 }
00079 else {
00080 try {
00081 return Gtk.IconTheme.Default.LoadIcon(name, sz, 0);
00082 }
00083 catch (System.Exception ) {
00084 if ((name != "gtk-missing-image")) {
00085 return Stetic.IconLoader.LoadIcon(widget, "gtk-missing-image", size, sz);
00086 }
00087 else {
00088 Gdk.Pixmap pmap = new Gdk.Pixmap(Gdk.Screen.Default.RootWindow, sz, sz);
00089 Gdk.GC gc = new Gdk.GC(pmap);
00090 gc.RgbFgColor = new Gdk.Color(255, 255, 255);
00091 pmap.DrawRectangle(gc, true, 0, 0, sz, sz);
00092 gc.RgbFgColor = new Gdk.Color(0, 0, 0);
00093 pmap.DrawRectangle(gc, false, 0, 0, (sz - 1), (sz - 1));
00094 gc.SetLineAttributes(3, Gdk.LineStyle.Solid, Gdk.CapStyle.Round, Gdk.JoinStyle.Round);
00095 gc.RgbFgColor = new Gdk.Color(255, 0, 0);
00096 pmap.DrawLine(gc, (sz / 4), (sz / 4), ((sz - 1) - (sz / 4)), ((sz - 1) - (sz / 4)));
00097 pmap.DrawLine(gc, ((sz - 1) - (sz / 4)), (sz / 4), (sz / 4), ((sz - 1) - (sz / 4)));
00098 return Gdk.Pixbuf.FromDrawable(pmap, pmap.Colormap, 0, 0, 0, 0, sz, sz);
00099 }
00100 }
00101 }
00102 }
00103 }
00104
00105 internal class ActionGroups {
00106
00107 public static Gtk.ActionGroup GetActionGroup(System.Type type) {
00108 return Stetic.ActionGroups.GetActionGroup(type.FullName);
00109 }
00110
00111 public static Gtk.ActionGroup GetActionGroup(string name) {
00112 return null;
00113 }
00114 }
00115 }