// Constructor.
		public CaptionButtonWidget(Widget parent, int x, int y,
								   int width, int height, MdiClientWidget mdi,
								   CaptionWidget.CaptionFlags flags)
				: base(parent, x, y, width, height)
				{
					this.mdi = mdi;
					this.flags = flags;
					this.pressed = false;
					this.Layer = 10;
				}
	/// <summary>
	/// <para>Constructs a new <see cref="T:Xsharp.TopLevelWindow"/>
	/// instance that appears as a child of this MDI client area.</para>
	/// </summary>
	///
	/// <param name="name">
	/// <para>The initial name to display in the title bar.</para>
	/// </param>
	///
	/// <param name="width">
	/// <para>The width of the new window.</para>
	/// </param>
	///
	/// <param name="height">
	/// <para>The height of the new window.</para>
	/// </param>
	///
	/// <param name="type">
	/// <para>The type of window to create.  This must inherit from
	/// the <see cref="T:Xsharp.TopLevelWindow"/> class.  The value
	/// <see langword="null"/> indicates to use
	/// <see cref="T:Xsharp.TopLevelWindow"/> as the type.</para>
	/// </param>
	///
	/// <exception cref="T:Xsharp.XException">
	/// <para>Raised if <paramref name="width"/> or <paramref name="height"/>
	/// is out of range, or <paramref name="type"/> does not inherit
	/// from <see cref="T:Xsharp.TopLevelWindow"/>.</para>
	/// </exception>
	public TopLevelWindow CreateChild(String name, int width, int height,
									  Type type)
			{
				CaptionWidget widget;
				if(type == null)
				{
					type = typeof(TopLevelWindow);
				}
				else if(!type.IsSubclassOf(typeof(TopLevelWindow)))
				{
					throw new XException(S._("X_TopLevelType"));
				}
				if(this.width != 1 && this.height != 1)
				{
					if(cascadeOffset >= (this.width - 64) ||
					   cascadeOffset >= (this.height - 64))
					{
						cascadeOffset = 0;
					}
				}
				widget = new CaptionWidget
					(this, name, cascadeOffset, cascadeOffset,
					 width, height, type);
				cascadeOffset += 22;
				if(maximized)
				{
					// The MDI client is in the maximized state,
					// so make sure that this window starts maximized.
					widget.MaximizeChild(true, HasControls());
				}
				return widget.Child;
			}
	// Select a new caption widget to become the active one.
	internal void SelectActive()
			{
				Widget widget;
				if(HasFocus())
				{
					widget = TopChild;
					while(widget != null)
					{
						if(widget is CaptionWidget && widget.IsMapped)
						{
							break;
						}
						widget = widget.NextBelow;
					}
				}
				else
				{
					widget = null;
				}
				if(widget != (Widget)activeChild)
				{
					if(activeChild != null)
					{
						activeChild.MakeInactive();
						OnDeactivateChild(activeChild.Child);
					}
					activeChild = (widget as CaptionWidget);
					if(activeChild != null)
					{
						activeChild.MakeActive();
						OnActivateChild(activeChild.Child);
					}
				}
				PositionControls();
			}
	// Pass a caption operation up to the caption parent, if there is one.
	// Returns true to perform the normal window manager processing.
	private bool Caption(CaptionWidget.Operation operation)
			{
				Widget parent = Parent;
				if(parent is CaptionWidget)
				{
					return ((CaptionWidget)parent).CaptionOperation(operation);
				}
				else
				{
					return true;
				}
			}