GtkSharp/gtk/Window.custom

160 lines
5.4 KiB
Plaintext
Raw Normal View History

// Gtk.Window.custom - Gtk Window class customizations
//
// Author: Mike Kestner <mkestner@ximian.com>
//
// Copyright (c) 2001 Mike Kestner
// Copyright (c) 2004 Novell, Inc.
//
// This code is inserted after the automatically generated code.
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of version 2 of the Lesser GNU General
// Public License as published by the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this program; if not, write to the
// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
// Boston, MA 02111-1307, USA.
public Window (String title) : this (WindowType.Toplevel)
{
this.Title = title;
}
[DllImport ("libgtk-win32-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
static extern IntPtr gtk_window_get_default_icon_list();
[DllImport ("libgtk-win32-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
static extern void gtk_window_set_default_icon_list(IntPtr list);
public static Gdk.Pixbuf[] DefaultIconList {
get {
IntPtr raw_ret = gtk_window_get_default_icon_list();
if (raw_ret == IntPtr.Zero)
return new Gdk.Pixbuf [0];
GLib.List list = new GLib.List(raw_ret);
Gdk.Pixbuf[] result = new Gdk.Pixbuf [list.Count];
for (int i = 0; i < list.Count; i++)
result [i] = list [i] as Gdk.Pixbuf;
return result;
}
set {
GLib.List list = new GLib.List(IntPtr.Zero);
foreach (Gdk.Pixbuf val in value)
list.Append (val.Handle);
gtk_window_set_default_icon_list(list.Handle);
}
}
[DllImport ("libgtk-win32-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
static extern IntPtr gtk_window_get_icon_list(IntPtr raw);
[DllImport ("libgtk-win32-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
static extern void gtk_window_set_icon_list(IntPtr raw, IntPtr list);
public Gdk.Pixbuf[] IconList {
get {
IntPtr raw_ret = gtk_window_get_icon_list(Handle);
if (raw_ret == IntPtr.Zero)
return new Gdk.Pixbuf [0];
GLib.List list = new GLib.List(raw_ret);
Gdk.Pixbuf[] result = new Gdk.Pixbuf [list.Count];
for (int i = 0; i < list.Count; i++)
result [i] = list [i] as Gdk.Pixbuf;
return result;
}
set {
GLib.List list = new GLib.List(IntPtr.Zero);
foreach (Gdk.Pixbuf val in value)
list.Append (val.Handle);
gtk_window_set_icon_list(Handle, list.Handle);
}
}
public Gdk.Size DefaultSize {
get {
return new Gdk.Size (DefaultWidth, DefaultHeight);
}
set {
DefaultWidth = value.Width;
DefaultHeight = value.Height;
}
}
[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
delegate void MoveFocusSignalDelegate (IntPtr arg0, int arg1, IntPtr gch);
static void MoveFocusSignalCallback (IntPtr arg0, int arg1, IntPtr gch)
{
Gtk.MoveFocusArgs args = new Gtk.MoveFocusArgs ();
try {
GLib.Signal sig = ((GCHandle) gch).Target as GLib.Signal;
if (sig == null)
throw new Exception("Unknown signal GC handle received " + gch);
args.Args = new object[1];
args.Args[0] = (Gtk.DirectionType) arg1;
Gtk.MoveFocusHandler handler = (Gtk.MoveFocusHandler) sig.Handler;
handler (GLib.Object.GetObject (arg0), args);
} catch (Exception e) {
GLib.ExceptionManager.RaiseUnhandledException (e, false);
}
}
[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
delegate void MoveFocusVMDelegate (IntPtr window, int direction);
static MoveFocusVMDelegate MoveFocusVMCallback;
static void movefocus_cb (IntPtr window, int direction)
{
try {
Window window_managed = GLib.Object.GetObject (window, false) as Window;
window_managed.OnMoveFocus ((Gtk.DirectionType) direction);
} catch (Exception e) {
GLib.ExceptionManager.RaiseUnhandledException (e, false);
}
}
private static void OverrideMoveFocus (GLib.GType gtype)
{
if (MoveFocusVMCallback == null)
MoveFocusVMCallback = new MoveFocusVMDelegate (movefocus_cb);
OverrideVirtualMethod (gtype, "move_focus", MoveFocusVMCallback);
}
[Obsolete ("Replaced by Keybinding signal on Gtk.Widget")]
[GLib.DefaultSignalHandler(Type=typeof(Gtk.Window), ConnectionMethod="OverrideMoveFocus")]
protected virtual void OnMoveFocus (Gtk.DirectionType direction)
{
GLib.Value ret = GLib.Value.Empty;
GLib.ValueArray inst_and_params = new GLib.ValueArray (2);
GLib.Value[] vals = new GLib.Value [2];
vals [0] = new GLib.Value (this);
inst_and_params.Append (vals [0]);
vals [1] = new GLib.Value (direction);
inst_and_params.Append (vals [1]);
g_signal_chain_from_overridden (inst_and_params.ArrayPtr, ref ret);
foreach (GLib.Value v in vals)
v.Dispose ();
}
[Obsolete ("Replaced by Keybinding signal on Gtk.Widget")]
[GLib.Signal("move_focus")]
public event Gtk.MoveFocusHandler MoveFocus {
add {
GLib.Signal sig = GLib.Signal.Lookup (this, "move_focus", new MoveFocusSignalDelegate(MoveFocusSignalCallback));
sig.AddDelegate (value);
}
remove {
GLib.Signal sig = GLib.Signal.Lookup (this, "move_focus", new MoveFocusSignalDelegate(MoveFocusSignalCallback));
sig.RemoveDelegate (value);
}
}