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 IconLoader {
00026
00027 public static Gdk.Pixbuf LoadIcon(Gtk.Widget widget, string name, Gtk.IconSize size, int sz) {
00028 Gdk.Pixbuf res = widget.RenderIcon(name, size, null);
00029 if ((res != null)) {
00030 return res;
00031 }
00032 else {
00033 try {
00034 return Gtk.IconTheme.Default.LoadIcon(name, sz, 0);
00035 }
00036 catch (System.Exception ) {
00037 if ((name != "gtk-missing-image")) {
00038 return Stetic.IconLoader.LoadIcon(widget, "gtk-missing-image", size, sz);
00039 }
00040 else {
00041 Gdk.Pixmap pmap = new Gdk.Pixmap(Gdk.Screen.Default.RootWindow, sz, sz);
00042 Gdk.GC gc = new Gdk.GC(pmap);
00043 gc.RgbFgColor = new Gdk.Color(255, 255, 255);
00044 pmap.DrawRectangle(gc, true, 0, 0, sz, sz);
00045 gc.RgbFgColor = new Gdk.Color(0, 0, 0);
00046 pmap.DrawRectangle(gc, false, 0, 0, (sz - 1), (sz - 1));
00047 gc.SetLineAttributes(3, Gdk.LineStyle.Solid, Gdk.CapStyle.Round, Gdk.JoinStyle.Round);
00048 gc.RgbFgColor = new Gdk.Color(255, 0, 0);
00049 pmap.DrawLine(gc, (sz / 4), (sz / 4), ((sz - 1) - (sz / 4)), ((sz - 1) - (sz / 4)));
00050 pmap.DrawLine(gc, ((sz - 1) - (sz / 4)), (sz / 4), (sz / 4), ((sz - 1) - (sz / 4)));
00051 return Gdk.Pixbuf.FromDrawable(pmap, pmap.Colormap, 0, 0, 0, 0, sz, sz);
00052 }
00053 }
00054 }
00055 }
00056 }
00057
00058 internal class BinContainer {
00059
00060 private Gtk.Widget child;
00061
00062 private Gtk.UIManager uimanager;
00063
00064 public static BinContainer Attach(Gtk.Bin bin) {
00065 BinContainer bc = new BinContainer();
00066 bin.SizeRequested += new Gtk.SizeRequestedHandler(bc.OnSizeRequested);
00067 bin.SizeAllocated += new Gtk.SizeAllocatedHandler(bc.OnSizeAllocated);
00068 bin.Added += new Gtk.AddedHandler(bc.OnAdded);
00069 return bc;
00070 }
00071
00072 private void OnSizeRequested(object sender, Gtk.SizeRequestedArgs args) {
00073 if ((this.child != null)) {
00074 args.Requisition = this.child.SizeRequest();
00075 }
00076 }
00077
00078 private void OnSizeAllocated(object sender, Gtk.SizeAllocatedArgs args) {
00079 if ((this.child != null)) {
00080 this.child.Allocation = args.Allocation;
00081 }
00082 }
00083
00084 private void OnAdded(object sender, Gtk.AddedArgs args) {
00085 this.child = args.Widget;
00086 }
00087
00088 public void SetUiManager(Gtk.UIManager uim) {
00089 this.uimanager = uim;
00090 this.child.Realized += new System.EventHandler(this.OnRealized);
00091 }
00092
00093 private void OnRealized(object sender, System.EventArgs args) {
00094 if ((this.uimanager != null)) {
00095 Gtk.Widget w;
00096 w = this.child.Toplevel;
00097 if (((w != null) && typeof(Gtk.Window).IsInstanceOfType(w))) {
00098 ((Gtk.Window)(w)).AddAccelGroup(this.uimanager.AccelGroup);
00099 this.uimanager = null;
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 }