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

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

[Dotgnu-pnet-commits] CVS: pnetlib/Xsharp InputOnlyWidget.cs,1.1,1.2 Inp


From: Rhys Weatherley <address@hidden>
Subject: [Dotgnu-pnet-commits] CVS: pnetlib/Xsharp InputOnlyWidget.cs,1.1,1.2 InputOutputWidget.cs,1.1,1.2 TopLevelWindow.cs,1.1,1.2 Widget.cs,1.1,1.2 EventHandlers.cs,1.1,NONE
Date: Fri, 06 Jun 2003 06:46:47 -0400

Update of /cvsroot/dotgnu-pnet/pnetlib/Xsharp
In directory subversions:/tmp/cvs-serv25713/Xsharp

Modified Files:
        InputOnlyWidget.cs InputOutputWidget.cs TopLevelWindow.cs 
        Widget.cs 
Removed Files:
        EventHandlers.cs 
Log Message:


Change event handlers into protected virtual methods in Xsharp,
to make it easier to use as the base of larger widget frameworks
(the framework can map the virtuals to events if necessary).


Index: InputOnlyWidget.cs
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnetlib/Xsharp/InputOnlyWidget.cs,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** InputOnlyWidget.cs  28 May 2003 04:17:53 -0000      1.1
--- InputOnlyWidget.cs  6 Jun 2003 10:46:45 -0000       1.2
***************
*** 35,40 ****
  {
        // Internal state.
-       private InputEventHandlers handlers;
        private bool focusable;
  
        /// <summary>
--- 35,41 ----
  {
        // Internal state.
        private bool focusable;
[...1057 lines suppressed...]
-                                               
widget.DeselectInput(EventMask.ButtonReleaseMask);
-                                       }
-                               }
- 
-       } // class InputEventHandlers
  
  } // class InputOnlyWidget
--- 688,699 ----
        internal void DispatchFocusIn(Widget oldWidget)
                        {
!                               OnFocusIn(oldWidget);
                        }
  
        // Dispatch a focus out event to this widget from the top-level window.
!       internal void DispatchFocusOut(Widget newWidget)
                        {
!                               OnFocusOut(newWidget);
                        }
  
  } // class InputOnlyWidget

Index: InputOutputWidget.cs
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnetlib/Xsharp/InputOutputWidget.cs,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** InputOutputWidget.cs        28 May 2003 04:17:53 -0000      1.1
--- InputOutputWidget.cs        6 Jun 2003 10:46:45 -0000       1.2
***************
*** 37,41 ****
        private Color background;
        private Pixmap backgroundPixmap;
-       private PaintEventHandler paint;
        private Region exposeRegion;
        internal InputOutputWidget nextExpose;
--- 37,40 ----
***************
*** 90,93 ****
--- 89,93 ----
                                foreground = new 
Color(StandardColor.Foreground);
                                background = new Color(StandardColor.Inherit);
+                               SelectInput(EventMask.ExposureMask);
                        }
  
***************
*** 150,153 ****
--- 150,154 ----
                                this.foreground = foreground;
                                this.background = background;
+                               SelectInput(EventMask.ExposureMask);
                        }
  
***************
*** 163,166 ****
--- 164,168 ----
                                this.foreground = foreground;
                                this.background = background;
+                               SelectInput(EventMask.ExposureMask);
                        }
  
***************
*** 361,390 ****
  
        /// <summary>
!       /// <para>Event that is raised when the widget needs to be
        /// painted in reponse to an <c>Expose</c> event.</para>
        /// </summary>
!       public event PaintEventHandler Paint
                        {
!                               add
!                               {
!                                       // Add ExposureMask to the widget's 
select mask if this
!                                       // is the first delegate that was added 
to the event.
!                                       if(paint == null)
!                                       {
!                                               
SelectInput(EventMask.ExposureMask);
!                                       }
!                                       paint += value;
!                               }
!                               remove
!                               {
!                                       // Remove ExposureMask from the 
widget's select mask if
!                                       // this was the last delegate to be 
removed from the event.
!                                       paint -= value;
!                                       if(paint == null)
!                                       {
!                                               
DeselectInput(EventMask.ExposureMask);
!                                               RemovePendingExpose();
!                                       }
!                               }
                        }
  
--- 363,379 ----
  
        /// <summary>
!       /// <para>Method that is raised when the widget needs to be
        /// painted in reponse to an <c>Expose</c> event.</para>
        /// </summary>
!       ///
!       /// <param name="graphics">
!       /// <para>The graphics object to use to repaint the widget.  This
!       /// graphics object will have been initialised with the widgets 
foreground
!       /// and background colors, and with the clipping region set to the area
!       /// that needs to be repainted.</para>
!       /// </param>
!       protected virtual void OnPaint(Graphics graphics)
                        {
!                               // Nothing to do in this class.
                        }
  
***************
*** 397,427 ****
                                        case EventType.GraphicsExpose:
                                        {
!                                               // Process exposures, and call 
"Paint" when ready.
!                                               if(paint != null)
                                                {
!                                                       // Add the area to the 
expose region.
!                                                       if(exposeRegion == null)
!                                                       {
!                                                               // This is the 
first rectangle in an expose.
!                                                               exposeRegion = 
new Region
!                                                                       
(xevent.xexpose.x,
!                                                                        
xevent.xexpose.y,
!                                                                        
xevent.xexpose.width,
!                                                                        
xevent.xexpose.height);
! 
!                                                               // Queue this 
widget for later repainting.
!                                                               // We don't do 
it now or the system will be
!                                                               // very slow 
during opaque window drags.
!                                                               
dpy.AddPendingExpose(this);
!                                                       }
!                                                       else
!                                                       {
!                                                               // This is an 
extra rectangle in an expose.
!                                                               
exposeRegion.Union
!                                                                       
(xevent.xexpose.x,
!                                                                        
xevent.xexpose.y,
!                                                                        
xevent.xexpose.width,
!                                                                        
xevent.xexpose.height);
!                                                       }
                                                }
                                        }
--- 386,412 ----
                                        case EventType.GraphicsExpose:
                                        {
!                                               // Add the area to the expose 
region.
!                                               if(exposeRegion == null)
                                                {
!                                                       // This is the first 
rectangle in an expose.
!                                                       exposeRegion = new 
Region
!                                                               
(xevent.xexpose.x,
!                                                                
xevent.xexpose.y,
!                                                                
xevent.xexpose.width,
!                                                                
xevent.xexpose.height);
! 
!                                                       // Queue this widget 
for later repainting.
!                                                       // We don't do it now 
or the system will be
!                                                       // very slow during 
opaque window drags.
!                                                       
dpy.AddPendingExpose(this);
!                                               }
!                                               else
!                                               {
!                                                       // This is an extra 
rectangle in an expose.
!                                                       exposeRegion.Union
!                                                               
(xevent.xexpose.x,
!                                                                
xevent.xexpose.y,
!                                                                
xevent.xexpose.width,
!                                                                
xevent.xexpose.height);
                                                }
                                        }
***************
*** 449,464 ****
                                {
                                        exposeRegion = null;
!                                       if(paint != null)
!                                       {
!                                               Graphics graphics = new 
Graphics(this);
!                                               graphics.SetClipRegion(region);
!                                               region.Dispose();
!                                               paint(this, graphics);
!                                               graphics.Dispose();
!                                       }
!                                       else
!                                       {
!                                               region.Dispose();
!                                       }
                                }
                        }
--- 434,442 ----
                                {
                                        exposeRegion = null;
!                                       Graphics graphics = new Graphics(this);
!                                       graphics.SetClipRegion(region);
!                                       region.Dispose();
!                                       OnPaint(graphics);
!                                       graphics.Dispose();
                                }
                        }

Index: TopLevelWindow.cs
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnetlib/Xsharp/TopLevelWindow.cs,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** TopLevelWindow.cs   28 May 2003 04:17:53 -0000      1.1
--- TopLevelWindow.cs   6 Jun 2003 10:46:45 -0000       1.2
***************
*** 184,188 ****
                                                Xlib.XMapRaised(display, 
GetWidgetHandle());
                                                mapped = true;
!                                               MapStateChanged();
                                        }
                                }
--- 184,188 ----
                                                Xlib.XMapRaised(display, 
GetWidgetHandle());
                                                mapped = true;
!                                               OnMapStateChanged();
                                        }
                                }
***************
*** 208,212 ****
                                                        (display, 
GetWidgetHandle(), screen.ScreenNumber);
                                                mapped = false;
!                                               MapStateChanged();
                                        }
                                }
--- 208,212 ----
                                                        (display, 
GetWidgetHandle(), screen.ScreenNumber);
                                                mapped = false;
!                                               OnMapStateChanged();
                                        }
                                }
***************
*** 232,239 ****
                                                        (display, 
GetWidgetHandle(), screen.ScreenNumber);
                                                iconic = true;
!                                               if(IconicState != null)
!                                               {
!                                                       IconicState(this, true);
!                                               }
                                        }
                                }
--- 232,236 ----
                                                        (display, 
GetWidgetHandle(), screen.ScreenNumber);
                                                iconic = true;
!                                               OnIconicStateChanged(true);
                                        }
                                }
***************
*** 258,270 ****
                                                Xlib.XMapRaised(display, 
GetWidgetHandle());
                                                iconic = false;
!                                               if(IconicState != null)
!                                               {
!                                                       IconicState(this, 
false);
!                                               }
                                                if(!mapped)
                                                {
                                                        // We are mapped now as 
well.
                                                        mapped = true;
!                                                       MapStateChanged();
                                                }
                                        }
--- 255,264 ----
                                                Xlib.XMapRaised(display, 
GetWidgetHandle());
                                                iconic = false;
!                                               OnIconicStateChanged(false);
                                                if(!mapped)
                                                {
                                                        // We are mapped now as 
well.
                                                        mapped = true;
!                                                       OnMapStateChanged();
                                                }
                                        }
***************
*** 284,288 ****
        /// <para>Returns <see langword="true"/> if the window was destroyed,
        /// or <see langword="false"/> if the window is still active
!       /// because one of the close event handlers reported
        /// <see langword="false"/>.</para>
        /// </returns>
--- 278,282 ----
        /// <para>Returns <see langword="true"/> if the window was destroyed,
        /// or <see langword="false"/> if the window is still active
!       /// because the <c>OnClose</c> method returned
        /// <see langword="false"/>.</para>
        /// </returns>
***************
*** 295,320 ****
                                }
  
!                               // Call each of the "Closed" event handlers in 
turn,
!                               // until one returns false or the window is 
destroyed.
!                               if(Closed != null)
!                               {
!                                       Delegate[] list = 
Closed.GetInvocationList();
!                                       int index;
!                                       ClosedEventHandler handler;
!                                       for(index = 0; index < list.Length; 
++index)
!                                       {
!                                               handler = 
(ClosedEventHandler)(list[index]);
!                                               if(!handler(this))
!                                               {
!                                                       // This handler wanted 
us to bail out.
!                                                       return (handle == 
Xlib.Drawable.Zero);
!                                               }
!                                               else if(handle == 
Xlib.Drawable.Zero)
!                                               {
!                                                       // The handler 
destroyed the window: we assume
!                                                       // that it didn't want 
the standard quit logic.
!                                                       return true;
!                                               }
!                                       }
                                }
  
--- 289,296 ----
                                }
  
!                               // Ask the "OnClose" method if we can close or 
not.
!                               if(!OnClose())
!                               {
!                                       return false;
                                }
  
***************
*** 427,460 ****
  
        /// <summary>
!       /// <para>Event that is raised when the window's iconic state
        /// changes.</para>
        /// </summary>
!       public event IconicStateEventHandler IconicState;
  
        /// <summary>
!       /// <para>Event that is raised when the window's close box is
        /// clicked by the user.</para>
        /// </summary>
        ///
!       /// <remarks>
!       /// <para>The system will call each close handler in turn.  If one
!       /// of them returns <see langword="false"/>, the process stops
!       /// and no further actions are taken.</para>
!       ///
!       /// <para>If all handlers return <see langword="true"/>, or there
!       /// are no handlers registered, then <c>Destroy</c> will be called
!       /// to destroy the window.  If this was the last mapped top-level
!       /// window attached to the screen, then <c>Display.Quit</c> will
!       /// then be called to quit the application.</para>
!       ///
!       /// <para>If an event handler wants to remove the window from the
!       /// screen without destroying it or quitting, it should call
!       /// <c>Unmap</c> and then return <see langword="false"/>.</para>
!       ///
!       /// <para>If an event handler wants to destroy a window without
!       /// quitting, it should call <c>Destroy</c> and then return
!       /// <see langword="false"/>.</para>
!       /// </remarks>
!       public event ClosedEventHandler Closed;
  
        // Detect that this top-level window has gained the primary focus.
--- 403,427 ----
  
        /// <summary>
!       /// <para>Method that is called when the window's iconic state
        /// changes.</para>
        /// </summary>
!       protected virtual void OnIconicStateChanged(bool iconfiy)
!                       {
!                               // Nothing to do in this base class.
!                       }
  
        /// <summary>
!       /// <para>Method that is called when the window's close box is
        /// clicked by the user.</para>
        /// </summary>
        ///
!       /// <returns>
!       /// <value>Returns <see langword="true"/> to destroy the window,
!       /// or <see langword="false"/> to ignore the close message.
!       /// </returns>
!       protected virtual bool OnClose()
!                       {
!                               return true;
!                       }
  
        // Detect that this top-level window has gained the primary focus.

Index: Widget.cs
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnetlib/Xsharp/Widget.cs,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** Widget.cs   28 May 2003 04:17:53 -0000      1.1
--- Widget.cs   6 Jun 2003 10:46:45 -0000       1.2
***************
*** 754,761 ****
                                                AdjustPositionAndSize(display, 
x, y,
                                                                                
          this.width, this.height);
!                                               if(Moved != null)
!                                               {
!                                                       Moved(this, x, y);
!                                               }
                                        }
                                }
--- 754,758 ----
                                                AdjustPositionAndSize(display, 
x, y,
                                                                                
          this.width, this.height);
!                                               OnMove(x, y);
                                        }
                                }
***************
*** 796,803 ****
                                                AdjustPositionAndSize(display, 
this.x, this.y,
                                                                                
          width, height);
!                                               if(Resized != null)
!                                               {
!                                                       Resized(this, width, 
height);
!                                               }
                                        }
                                }
--- 793,797 ----
                                                AdjustPositionAndSize(display, 
this.x, this.y,
                                                                                
          width, height);
!                                               OnResize(width, height);
                                        }
                                }
***************
*** 846,853 ****
                                                Xlib.XMapWindow(display, 
GetWidgetHandle());
                                                mapped = true;
!                                               if(MapState != null)
!                                               {
!                                                       MapState(this, true);
!                                               }
                                        }
                                }
--- 840,844 ----
                                                Xlib.XMapWindow(display, 
GetWidgetHandle());
                                                mapped = true;
!                                               OnMapStateChanged();
                                        }
                                }
***************
*** 870,877 ****
                                                Xlib.XUnmapWindow(display, 
GetWidgetHandle());
                                                mapped = false;
!                                               if(MapState != null)
!                                               {
!                                                       MapState(this, false);
!                                               }
                                        }
                                }
--- 861,865 ----
                                                Xlib.XUnmapWindow(display, 
GetWidgetHandle());
                                                mapped = false;
!                                               OnMapStateChanged();
                                        }
                                }
***************
*** 882,894 ****
                        }
  
-       // Record a change in map state from a subclass.
-       internal void MapStateChanged()
-                       {
-                               if(MapState != null)
-                               {
-                                       MapState(this, mapped);
-                               }
-                       }
- 
        /// <summary>
        /// <para>Process a color theme change for this widget.</para>
--- 870,873 ----
***************
*** 908,915 ****
                        {
                                // Notify everyone who is interested in our 
sensitivity change.
!                               if(SensitivityChanged != null)
!                               {
!                                       SensitivityChanged(this);
!                               }
  
                                // Modify the ancestor sensitivity of the child 
widgets.
--- 887,891 ----
                        {
                                // Notify everyone who is interested in our 
sensitivity change.
!                               OnSensitivityChanged();
  
                                // Modify the ancestor sensitivity of the child 
widgets.
***************
*** 1194,1217 ****
  
        /// <summary>
!       /// <para>Event that is raised when the widget is moved to a
        /// new position.</para>
        /// </summary>
!       public event MovedEventHandler Moved;
  
        /// <summary>
!       /// <para>Event that is raised when the widget is resized to
!       /// a new size.</para>
        /// </summary>
!       public event ResizedEventHandler Resized;
  
        /// <summary>
!       /// <para>Event that is raised when the widget's map state 
changes.</para>
        /// </summary>
!       public event MapStateEventHandler MapState;
  
        /// <summary>
!       /// <para>Event that is raised when the widget's sensitivity 
changes.</para>
        /// </summary>
!       public event SensitivityChangedEventHandler SensitivityChanged;
  
  } // class Widget
--- 1170,1223 ----
  
        /// <summary>
!       /// <para>Method that is called when the widget is moved to a
        /// new position.</para>
        /// </summary>
!       ///
!       /// <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>
!       protected virtual void OnMove(int x, int y)
!                       {
!                               // Nothing to do in the base class.
!                       }
  
        /// <summary>
!       /// <para>Method that is called when the widget is resized to a
!       /// new size.</para>
        /// </summary>
!       ///
!       /// <param name="width">
!       /// <para>The new width for the widget.</para>
!       /// </param>
!       ///
!       /// <param name="height">
!       /// <para>The new width for the widget.</para>
!       /// </param>
!       protected virtual void OnResize(int width, int height)
!                       {
!                               // Nothing to do in the base class.
!                       }
  
        /// <summary>
!       /// <para>Method that is called when the widget is mapped or
!       /// unmapped.</para>
        /// </summary>
!       protected virtual void OnMapStateChanged()
!                       {
!                               // Nothing to do in the base class.
!                       }
  
        /// <summary>
!       /// <para>Method that is called when the widget's sensitivity
!       /// changes.</para>
        /// </summary>
!       protected virtual void OnSensitivityChanged()
!                       {
!                               // Nothing to do in the base class.
!                       }
  
  } // class Widget

--- EventHandlers.cs DELETED ---





reply via email to

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