- Timestamp:
- Oct 6, 2008, 11:33:30 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libpipi/trunk/ThePimp/PictureView.cs
r2874 r2889 23 23 private Pipi.Picture _p; 24 24 private Adjustment _hadj = null, _vadj = null; 25 private bool _drag = false; 26 private double _xdrag, _ydrag; 25 27 26 28 void HAdjust(object sender, EventArgs args) … … 37 39 { 38 40 bool ret = base.OnExposeEvent(e); 41 42 if(_hadj == null || _vadj == null) 43 return ret; 39 44 40 45 using (Gdk.GC gc = new Gdk.GC(GdkWindow)) … … 60 65 { 61 66 base.OnRealized(); 67 } 68 69 protected override bool OnButtonPressEvent(Gdk.EventButton e) 70 { 71 if(e.Button == 2) 72 { 73 GdkWindow.Cursor = new Gdk.Cursor(Gdk.CursorType.Hand1); 74 _drag = true; 75 _xdrag = e.X; 76 _ydrag = e.Y; 77 } 78 79 return base.OnButtonPressEvent(e); 80 } 81 82 protected override bool OnButtonReleaseEvent(Gdk.EventButton e) 83 { 84 if(e.Button == 2) 85 { 86 GdkWindow.Cursor = null; 87 _drag = false; 88 } 89 90 return base.OnButtonReleaseEvent(e); 91 } 92 93 protected override bool OnMotionNotifyEvent(Gdk.EventMotion e) 94 { 95 if(_drag) 96 { 97 if(_hadj != null && e.X != _xdrag) 98 { 99 _hadj.Value += _xdrag - e.X; 100 _xdrag = e.X; 101 if(_hadj.Value + Allocation.Width > _p.Width) 102 _hadj.Value = _p.Width - Allocation.Width; 103 _hadj.ChangeValue(); 104 } 105 if(_vadj != null && e.Y != _ydrag) 106 { 107 _vadj.Value += _ydrag - e.Y; 108 _ydrag = e.Y; 109 if(_vadj.Value + Allocation.Height > _p.Height) 110 _vadj.Value = _p.Height - Allocation.Height; 111 _vadj.ChangeValue(); 112 } 113 } 114 115 return base.OnMotionNotifyEvent(e); 62 116 } 63 117 … … 116 170 { 117 171 _p = p; 172 173 AddEvents((int)Gdk.EventMask.ButtonPressMask); 174 AddEvents((int)Gdk.EventMask.ButtonReleaseMask); 175 AddEvents((int)Gdk.EventMask.PointerMotionMask); 118 176 } 119 177 }
Note: See TracChangeset
for help on using the changeset viewer.