[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Dotgnu-pnet-commits] CVS: pnetlib/Xsharp PlaceholderWindow.cs,NONE,1.1
From: |
Rhys Weatherley <address@hidden> |
Subject: |
[Dotgnu-pnet-commits] CVS: pnetlib/Xsharp PlaceholderWindow.cs,NONE,1.1 RootWindow.cs,1.1,1.2 Screen.cs,1.1,1.2 TopLevelWindow.cs,1.3,1.4 Widget.cs,1.3,1.4 Xlib.cs.in,1.3,1.4 |
Date: |
Fri, 06 Jun 2003 20:13:11 -0400 |
Update of /cvsroot/dotgnu-pnet/pnetlib/Xsharp
In directory subversions:/tmp/cvs-serv8555/Xsharp
Modified Files:
RootWindow.cs Screen.cs TopLevelWindow.cs Widget.cs Xlib.cs.in
Added Files:
PlaceholderWindow.cs
Log Message:
Implement "parent-less" widgets using a placeholder window;
add support for widget reparenting.
--- NEW FILE ---
/*
* PlaceholderWindow.cs - Placeholder for unparented widgets.
*
* Copyright (C) 2003 Southern Storm Software, Pty Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* 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 General Public License for more details.
*
* You should have received a copy of the GNU 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
*/
namespace Xsharp
{
using System;
// Special window that holds child widgets that don't yet have real parents.
internal class PlaceholderWindow : InputOutputWidget
{
// Constructor.
public PlaceholderWindow(Widget parent)
: base(parent, 0, 0, 1, 1,
new Color(StandardColor.Foreground),
new Color(StandardColor.Background),
true, true)
{
autoMapChildren = false;
}
// Disable certain widget operations which we don't want.
public override void Destroy()
{
// Nothing to do here.
}
public override void Map()
{
throw new XInvalidOperationException
(S._("X_NonPlaceholderOperation"));
}
public override void Unmap()
{
throw new XInvalidOperationException
(S._("X_NonPlaceholderOperation"));
}
public override void Reparent(Widget newParent, int x, int y)
{
throw new XInvalidOperationException
(S._("X_NonPlaceholderOperation"));
}
} // class PlaceholderWindow
} // namespace Xsharp
Index: RootWindow.cs
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnetlib/Xsharp/RootWindow.cs,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** RootWindow.cs 28 May 2003 04:17:53 -0000 1.1
--- RootWindow.cs 7 Jun 2003 00:13:09 -0000 1.2
***************
*** 50,54 ****
height =
(int)(Xlib.XHeightOfScreen(screen.screen));
mapped = true;
! AutoMapChildren = false;
}
--- 50,54 ----
height =
(int)(Xlib.XHeightOfScreen(screen.screen));
mapped = true;
! autoMapChildren = false;
}
***************
*** 124,127 ****
--- 124,136 ----
/// </summary>
public override void Unmap()
+ {
+ throw new XInvalidOperationException
+ (S._("X_NonRootOperation"));
+ }
+
+ /// <summary>
+ /// <para>Reparenting is disabled for the root window.</para>
+ /// </summary>
+ public override void Reparent(Widget newParent, int x, int y)
{
throw new XInvalidOperationException
Index: Screen.cs
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnetlib/Xsharp/Screen.cs,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** Screen.cs 28 May 2003 04:17:53 -0000 1.1
--- Screen.cs 7 Jun 2003 00:13:09 -0000 1.2
***************
*** 36,39 ****
--- 36,40 ----
internal IntPtr screen;
private Xsharp.RootWindow rootWindow;
+ private Widget placeholder;
private IntPtr visual;
private Colormap defaultColormap;
***************
*** 70,73 ****
--- 71,77 ----
// Initialize the standard colors.
InitStandardColors();
+
+ // Create the placeholder window for
parent-less widgets.
+ placeholder = new PlaceholderWindow(rootWindow);
}
***************
*** 200,203 ****
--- 204,234 ----
dpy.Unlock();
}
+ }
+ }
+
+ /// <summary>
+ /// <para>Get the placeholder widget for this screen.</para>
+ /// </summary>
+ ///
+ /// <value>
+ /// <para>The placeholder widget.</para>
+ /// </value>
+ ///
+ /// <remarks>
+ /// <para>All widgets in X11 must have a parent, but sometimes
+ /// upper layers want to create widgets independently of their final
+ /// position and then reparent them into place afterwards. The
+ /// placeholder widget can be used to hold a widget while it is
+ /// in the "parent-less" state.</para>
+ ///
+ /// <para>When a widget is a child of the placeholder, its
+ /// <c>Parent</c>, <c>NextAbove</c>, and <c>NextBelow</c> properties
+ /// will all return <see langword="null"/>.</para>
+ /// </remarks>
+ public Widget Placeholder
+ {
+ get
+ {
+ return placeholder;
}
}
Index: TopLevelWindow.cs
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnetlib/Xsharp/TopLevelWindow.cs,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -r1.3 -r1.4
*** TopLevelWindow.cs 6 Jun 2003 12:59:44 -0000 1.3
--- TopLevelWindow.cs 7 Jun 2003 00:13:09 -0000 1.4
***************
*** 165,169 ****
// Helper method to get the root window of a specified screen.
! private static Widget GetRoot(Screen screen)
{
if(screen == null)
--- 165,169 ----
// Helper method to get the root window of a specified screen.
! internal static Widget GetRoot(Screen screen)
{
if(screen == null)
***************
*** 223,226 ****
--- 223,235 ----
dpy.Unlock();
}
+ }
+
+ /// <summary>
+ /// <para>Reparenting is not supported for top-level windows.</para>
+ /// </summary>
+ public override void Reparent(Widget newParent, int x, int y)
+ {
+ throw new XInvalidOperationException
+ (S._("X_NonTopLevelOperation"));
}
Index: Widget.cs
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnetlib/Xsharp/Widget.cs,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -r1.3 -r1.4
*** Widget.cs 6 Jun 2003 12:59:44 -0000 1.3
--- Widget.cs 7 Jun 2003 00:13:09 -0000 1.4
***************
*** 42,46 ****
internal int layer;
internal bool mapped;
! private bool autoMapChildren;
private bool sensitive;
private bool ancestorSensitive;
--- 42,46 ----
internal int layer;
internal bool mapped;
! internal bool autoMapChildren;
private bool sensitive;
private bool ancestorSensitive;
***************
*** 415,419 ****
get
{
! return parent;
}
}
--- 415,426 ----
get
{
! if(parent is PlaceholderWindow)
! {
! return null;
! }
! else
! {
! return parent;
! }
}
}
***************
*** 461,465 ****
get
{
! return nextAbove;
}
}
--- 468,479 ----
get
{
! if(parent is PlaceholderWindow)
! {
! return null;
! }
! else
! {
! return nextAbove;
! }
}
}
***************
*** 484,488 ****
get
{
! return nextBelow;
}
}
--- 498,509 ----
get
{
! if(parent is PlaceholderWindow)
! {
! return null;
! }
! else
! {
! return nextBelow;
! }
}
}
***************
*** 929,932 ****
--- 950,1090 ----
child = child.nextBelow;
}
+ }
+
+ /// <summary>
+ /// <para>Reparent this widget underneath a new parent.</para>
+ /// </summary>
+ ///
+ /// <param name="newParent">
+ /// <para>The new parent widget. This should be the placeholder widget
+ /// for the screen if you wish to give this widget "no parent".</para>
+ /// </param>
+ ///
+ /// <param name="x">
+ /// <para>The X co-ordinate of the new top-left widget corner.</para>
+ /// </param>
+ ///
+ /// <param name="y">
+ /// <para>The Y co-ordinate of the new top-left widget corner.</para>
+ /// </param>
+ ///
+ /// <exception cref="T:System.ArgumentNullException">
+ /// <para>Raised if <paramref name="newParent"/> is
+ /// <see langword="null"/>.</para>
+ /// </exception>
+ ///
+ /// <exception cref="T:Xsharp.XException">
+ /// <para>Raised if <paramref name="x"/> or <paramref name="y"/>
+ /// is out of range.</para>
+ /// </exception>
+ ///
+ /// <exception cref="T:Xsharp.XInvalidOperationException">
+ /// <para>Raised if <paramref name="newParent"/> is a descendent
+ /// of this widget, which would create a circularity.</para>
+ /// </exception>
+ ///
+ /// <exception cref="T:Xsharp.XInvalidOperationException">
+ /// <para>Raised if <paramref name="newParent"/> is on a different
+ /// screen from this widget.</para>
+ /// </exception>
+ ///
+ /// <exception cref="T:Xsharp.XInvalidOperationException">
+ /// <para>Raised if <paramref name="newParent"/> is an input only
+ /// widget, but this widget is input-output.</para>
+ /// </exception>
+ ///
+ /// <exception cref="T:Xsharp.XInvalidOperationException">
+ /// <para>Raised if an attempt is made to reparent the root window
+ /// or a top-level window.</para>
+ /// </exception>
+ public virtual void Reparent(Widget newParent, int x, int y)
+ {
+ // Validate the parameters.
+ if(newParent == null)
+ {
+ throw new
ArgumentNullException("newParent");
+ }
+ if(x < -32768 || x > 32767 ||
+ y < -32768 || y > 32767)
+ {
+ throw new
XException(S._("X_InvalidPosition"));
+ }
+ Widget temp = newParent;
+ while(temp != null && temp != this)
+ {
+ temp = temp.parent;
+ }
+ if(temp != null)
+ {
+ throw new XInvalidOperationException
+ (S._("X_InvalidReparent"));
+ }
+ if(screen != newParent.screen)
+ {
+ throw new XInvalidOperationException
+ (S._("X_InvalidReparent"));
+ }
+ if(!(newParent is InputOutputWidget) &&
+ this is InputOutputWidget)
+ {
+ throw new XInvalidOperationException
+ (S._("X_InvalidReparent"));
+ }
+
+ // If the new parent is the same as the old,
then simply
+ // move and raise the widget, but do nothing
else.
+ if(newParent == parent)
+ {
+ Move(x, y);
+ Raise();
+ return;
+ }
+
+ // Detach the widget from its current parent.
+ if(nextBelow != null)
+ {
+ nextBelow.nextAbove = nextAbove;
+ }
+ if(nextAbove != null)
+ {
+ nextAbove.nextBelow = nextBelow;
+ }
+ else if(parent != null)
+ {
+ parent.topChild = nextBelow;
+ }
+
+ // Attach the widget to its new parent as the
top-most child.
+ nextBelow = newParent.topChild;
+ nextAbove = null;
+ if(newParent.topChild != null)
+ {
+ newParent.topChild.nextAbove = this;
+ }
+ newParent.topChild = this;
+ parent = newParent;
+
+ // Temporarily put the widget in the top-most
layer.
+ int saveLayer = layer;
+ layer = 0x7FFFFFFF;
+
+ // Perform the actual reparent operation. This
will
+ // put the window at the top of the stacking
order.
+ try
+ {
+ IntPtr display = dpy.Lock();
+ Xlib.Window widget = GetWidgetHandle();
+ Xlib.Window pwidget =
newParent.GetWidgetHandle();
+ Xlib.XReparentWindow(display, widget,
pwidget, x, y);
+ this.x = x;
+ this.y = y;
+ }
+ finally
+ {
+ dpy.Unlock();
+ }
+
+ // Push the widget down to its original layer
position.
+ Layer = saveLayer;
}
Index: Xlib.cs.in
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnetlib/Xsharp/Xlib.cs.in,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -r1.3 -r1.4
*** Xlib.cs.in 6 Jun 2003 12:59:44 -0000 1.3
--- Xlib.cs.in 7 Jun 2003 00:13:09 -0000 1.4
***************
*** 176,179 ****
--- 176,183 ----
[DllImport("X11")]
+ extern public static @X_int@ XReparentWindow
+ (IntPtr display, Window w, Window parent, @X_int@ x,
@X_int@ y);
+
+ [DllImport("X11")]
extern public static Cursor XCreateFontCursor
(IntPtr display, @X_uint@ shape);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Dotgnu-pnet-commits] CVS: pnetlib/Xsharp PlaceholderWindow.cs,NONE,1.1 RootWindow.cs,1.1,1.2 Screen.cs,1.1,1.2 TopLevelWindow.cs,1.3,1.4 Widget.cs,1.3,1.4 Xlib.cs.in,1.3,1.4,
Rhys Weatherley <address@hidden> <=
- Prev by Date:
[Dotgnu-pnet-commits] CVS: pnetlib/resources/en_US/Xsharp Xsharp.txt,1.2,1.3
- Next by Date:
[Dotgnu-pnet-commits] CVS: pnetlib/Xsharp XsharpSupport.c,NONE,1.1 .cvsignore,1.1,1.2 Makefile.am,1.1,1.2 Makefile.in,1.1,1.2
- Previous by thread:
[Dotgnu-pnet-commits] CVS: pnetlib/resources/en_US/Xsharp Xsharp.txt,1.2,1.3
- Next by thread:
[Dotgnu-pnet-commits] CVS: pnetlib/Xsharp XsharpSupport.c,NONE,1.1 .cvsignore,1.1,1.2 Makefile.am,1.1,1.2 Makefile.in,1.1,1.2
- Index(es):