/[dotgnu-pnet]/pnetlib/System.Windows.Forms/ScrollableControl.cs
ViewVC logotype

Diff of /pnetlib/System.Windows.Forms/ScrollableControl.cs

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.10 by drobosson, Mon Nov 7 00:28:51 2005 UTC revision 1.11 by drobosson, Mon Nov 7 02:21:46 2005 UTC
# Line 317  public class ScrollableControl : Control Line 317  public class ScrollableControl : Control
317                                  ScrollByOffset(new Size(xOffset,yOffset));                                  ScrollByOffset(new Size(xOffset,yOffset));
318                          }                          }
319    
         [TODO]  
320          // Handle a mouse wheel event.          // Handle a mouse wheel event.
321          protected override void OnMouseWheel(MouseEventArgs e)          protected override void OnMouseWheel(MouseEventArgs e)
322                          {                          {
323                                    int value = 0;
324                                    int min = 0;
325                                    int max = 0;
326    
327                                    // if both are visible, logic tells us to use
328                                    // the verticle scroll.  If only verticle, use
329                                    // it, otherwise, horizontal of course if it
330                                    // is visible.
331                                    if(hScrollBar.Visible && vScrollBar.Visible)
332                                    {
333                                            value = vScrollBar.Value;
334                                            min = vScrollBar.Minimum;
335                                            max = vScrollBar.Maximum;
336                                    }
337                                    else if(vScrollBar.Visible && !hScrollBar.Visible)
338                                    {
339                                            value = vScrollBar.Value;
340                                            min = vScrollBar.Minimum;
341                                            max = vScrollBar.Maximum;
342                                    }
343                                    else if(hScrollBar.Visible && !vScrollBar.Visible)
344                                    {
345                                            value = hScrollBar.Value;
346                                            min = hScrollBar.Minimum;
347                                            max = hScrollBar.Maximum;
348                                    }
349    
350                                    if(e.Delta == 120) // wheel up
351                                    {
352                                            if(value - SystemInformation.MouseWheelScrollLines >= min)
353                                            {
354                                                    value -= SystemInformation.MouseWheelScrollLines;
355                                            }
356                                    }
357                                    else if(e.Delta == -120) // wheel down
358                                    {
359                                            if(value + SystemInformation.MouseWheelScrollLines <= max)
360                                            {
361                                                    value += SystemInformation.MouseWheelScrollLines;
362                                            }
363                                    }
364    
365                                    if(hScrollBar.Visible && vScrollBar.Visible)
366                                    {
367                                            vScrollBar.Value = value;
368                                            ScrollByOffset(new Size(0, autoScrollPosition.Y + value));
369                                            UpdateScrollBars();
370                                    }
371                                    else if(vScrollBar.Visible && !hScrollBar.Visible)
372                                    {
373                                            vScrollBar.Value = value;
374                                            ScrollByOffset(new Size(0, autoScrollPosition.Y + value));
375                                            UpdateScrollBars();
376                                    }
377                                    else if(hScrollBar.Visible && !vScrollBar.Visible)
378                                    {
379                                            hScrollBar.Value = value;
380                                            ScrollByOffset(new Size(autoScrollPosition.X + value, 0));
381                                            UpdateScrollBars();
382                                    }
383    
384                                  base.OnMouseWheel(e);                                  base.OnMouseWheel(e);
385                          }                          }
386    

Legend:
Removed from v.1.10  
changed lines
  Added in v.1.11

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26