コード例 #1
0
ファイル: DropTarget.cs プロジェクト: ranganathsb/JavaSharp
        /// <summary>
        /// Notify the DropTarget that it has been disassociated from a Component
        ///
        /// **********************************************************************
        /// This method is usually called from java.awt.Component.removeNotify() of
        /// the Component associated with this DropTarget to notify the DropTarget
        /// that a ComponentPeer has been disassociated with that Component.
        ///
        /// Calling this method, other than to notify this DropTarget of the
        /// disassociation of the ComponentPeer from the Component may result in
        /// a malfunction of the DnD system.
        /// **********************************************************************
        /// <P> </summary>
        /// <param name="peer"> The Peer of the Component we are being disassociated from! </param>

        public virtual void RemoveNotify(ComponentPeer peer)
        {
            if (NativePeer != null)
            {
                ((DropTargetPeer)NativePeer).RemoveDropTarget(this);
            }

            ComponentPeer = NativePeer = null;

            lock (this)
            {
                if (IsDraggingInside)
                {
                    DragExit(new DropTargetEvent(DropTargetContext));
                }
            }
        }
コード例 #2
0
ファイル: DropTarget.cs プロジェクト: ranganathsb/JavaSharp
        /// <summary>
        /// Notify the DropTarget that it has been associated with a Component
        ///
        /// **********************************************************************
        /// This method is usually called from java.awt.Component.addNotify() of
        /// the Component associated with this DropTarget to notify the DropTarget
        /// that a ComponentPeer has been associated with that Component.
        ///
        /// Calling this method, other than to notify this DropTarget of the
        /// association of the ComponentPeer with the Component may result in
        /// a malfunction of the DnD system.
        /// **********************************************************************
        /// <P> </summary>
        /// <param name="peer"> The Peer of the Component we are associated with!
        ///  </param>

        public virtual void AddNotify(ComponentPeer peer)
        {
            if (peer == ComponentPeer)
            {
                return;
            }

            ComponentPeer = peer;

            for (Component c = Component_Renamed; c != null && peer is LightweightPeer; c = c.Parent)
            {
                peer = c.Peer;
            }

            if (peer is DropTargetPeer)
            {
                NativePeer = peer;
                ((DropTargetPeer)peer).AddDropTarget(this);
            }
            else
            {
                NativePeer = null;
            }
        }
コード例 #3
0
        /// <summary>
        /// Determines whether a Component is an acceptable choice as the new
        /// focus owner. The Component must be visible, displayable, and enabled
        /// to be accepted. If client code has explicitly set the focusability
        /// of the Component by either overriding
        /// <code>Component.isFocusTraversable()</code> or
        /// <code>Component.isFocusable()</code>, or by calling
        /// <code>Component.setFocusable()</code>, then the Component will be
        /// accepted if and only if it is focusable. If, however, the Component is
        /// relying on default focusability, then all Canvases, Labels, Panels,
        /// Scrollbars, ScrollPanes, Windows, and lightweight Components will be
        /// rejected.
        /// </summary>
        /// <param name="aComponent"> the Component whose fitness as a focus owner is to
        ///        be tested </param>
        /// <returns> <code>true</code> if aComponent meets the above requirements;
        ///         <code>false</code> otherwise </returns>
        protected internal override bool Accept(Component aComponent)
        {
            if (!(aComponent.Visible && aComponent.Displayable && aComponent.Enabled))
            {
                return(false);
            }

            // Verify that the Component is recursively enabled. Disabling a
            // heavyweight Container disables its children, whereas disabling
            // a lightweight Container does not.
            if (!(aComponent is Window))
            {
                for (Container enableTest = aComponent.Parent; enableTest != null; enableTest = enableTest.Parent)
                {
                    if (!(enableTest.Enabled || enableTest.Lightweight))
                    {
                        return(false);
                    }
                    if (enableTest is Window)
                    {
                        break;
                    }
                }
            }

            bool focusable = aComponent.Focusable;

            if (aComponent.FocusTraversableOverridden)
            {
                return(focusable);
            }

            ComponentPeer peer = aComponent.Peer;

            return(peer != null && peer.Focusable);
        }