dotgnu-pnet-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Dotgnu-pnet-commits] CVS: pnetlib/System.Windows.Forms PopupControl.cs


From: Rhys Weatherley <address@hidden>
Subject: [Dotgnu-pnet-commits] CVS: pnetlib/System.Windows.Forms PopupControl.cs,NONE,1.1
Date: Tue, 24 Jun 2003 03:52:51 -0400

Update of /cvsroot/dotgnu-pnet/pnetlib/System.Windows.Forms
In directory subversions:/tmp/cvs-serv10584/System.Windows.Forms

Added Files:
        PopupControl.cs 
Log Message:


Add the internal "PopupControl" class to Forms, to support popup menus and
combox box drop-down lists.


--- NEW FILE ---
/*
 * PopupControl.cs - Implementation of the
 *                      "System.Windows.Forms.PopupControl" class.
 *
 * 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 System.Windows.Forms
{

using System.Drawing;
using System.Drawing.Toolkit;

// This class is used to parent top-level popup windows such as
// menus and combo box drop-down lists.  The mouse and keyboard
// are grabbed while a popup control is visible on-screen.

internal class PopupControl : Control
{
        // Constructor.
        public PopupControl()
                        {
                                // Popups are not visible by default.
                                visible = false;
                        }

        // Create the toolkit window underlying this control.
        internal override IToolkitWindow CreateToolkitWindow(IToolkitWindow 
parent)
                        {
                                CreateParams cp = CreateParams;
                                return ToolkitManager.Toolkit.CreatePopupWindow
                                                (cp.X, cp.Y, cp.Width, 
cp.Height);
                        }

        // Trap the "OnMouseDown" event and pop down the window if a
        // mouse click occurs outside the control's bounds.
        protected override void OnMouseDown(MouseEventArgs e)
                        {
                                // Handle the event normally.
                                base.OnMouseDown(e);

                                // If the click was outside, then pop down the 
window.
                                int x = e.X;
                                int y = e.Y;
                                if(x < 0 || x >= Width || y < 0 || y >= Height)
                                {
                                        Hide();
                                }
                        }

}; // class PopupControl

}; // namespace System.Windows.Forms





reply via email to

[Prev in Thread] Current Thread [Next in Thread]