|
|
@@ -22,6 +22,8 @@ namespace ThePimp |
|
|
|
{ |
|
|
|
private Pipi.Picture _p; |
|
|
|
private Adjustment _hadj = null, _vadj = null; |
|
|
|
private bool _drag = false; |
|
|
|
private double _xdrag, _ydrag; |
|
|
|
|
|
|
|
void HAdjust(object sender, EventArgs args) |
|
|
|
{ |
|
|
@@ -37,6 +39,9 @@ namespace ThePimp |
|
|
|
{ |
|
|
|
bool ret = base.OnExposeEvent(e); |
|
|
|
|
|
|
|
if(_hadj == null || _vadj == null) |
|
|
|
return ret; |
|
|
|
|
|
|
|
using (Gdk.GC gc = new Gdk.GC(GdkWindow)) |
|
|
|
{ |
|
|
|
int w = e.Area.Width; |
|
|
@@ -61,6 +66,55 @@ namespace ThePimp |
|
|
|
base.OnRealized(); |
|
|
|
} |
|
|
|
|
|
|
|
protected override bool OnButtonPressEvent(Gdk.EventButton e) |
|
|
|
{ |
|
|
|
if(e.Button == 2) |
|
|
|
{ |
|
|
|
GdkWindow.Cursor = new Gdk.Cursor(Gdk.CursorType.Hand1); |
|
|
|
_drag = true; |
|
|
|
_xdrag = e.X; |
|
|
|
_ydrag = e.Y; |
|
|
|
} |
|
|
|
|
|
|
|
return base.OnButtonPressEvent(e); |
|
|
|
} |
|
|
|
|
|
|
|
protected override bool OnButtonReleaseEvent(Gdk.EventButton e) |
|
|
|
{ |
|
|
|
if(e.Button == 2) |
|
|
|
{ |
|
|
|
GdkWindow.Cursor = null; |
|
|
|
_drag = false; |
|
|
|
} |
|
|
|
|
|
|
|
return base.OnButtonReleaseEvent(e); |
|
|
|
} |
|
|
|
|
|
|
|
protected override bool OnMotionNotifyEvent(Gdk.EventMotion e) |
|
|
|
{ |
|
|
|
if(_drag) |
|
|
|
{ |
|
|
|
if(_hadj != null && e.X != _xdrag) |
|
|
|
{ |
|
|
|
_hadj.Value += _xdrag - e.X; |
|
|
|
_xdrag = e.X; |
|
|
|
if(_hadj.Value + Allocation.Width > _p.Width) |
|
|
|
_hadj.Value = _p.Width - Allocation.Width; |
|
|
|
_hadj.ChangeValue(); |
|
|
|
} |
|
|
|
if(_vadj != null && e.Y != _ydrag) |
|
|
|
{ |
|
|
|
_vadj.Value += _ydrag - e.Y; |
|
|
|
_ydrag = e.Y; |
|
|
|
if(_vadj.Value + Allocation.Height > _p.Height) |
|
|
|
_vadj.Value = _p.Height - Allocation.Height; |
|
|
|
_vadj.ChangeValue(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return base.OnMotionNotifyEvent(e); |
|
|
|
} |
|
|
|
|
|
|
|
protected override void OnSetScrollAdjustments(Adjustment hadj, |
|
|
|
Adjustment vadj) |
|
|
|
{ |
|
|
@@ -115,6 +169,10 @@ namespace ThePimp |
|
|
|
public PictureArea(Picture p) |
|
|
|
{ |
|
|
|
_p = p; |
|
|
|
|
|
|
|
AddEvents((int)Gdk.EventMask.ButtonPressMask); |
|
|
|
AddEvents((int)Gdk.EventMask.ButtonReleaseMask); |
|
|
|
AddEvents((int)Gdk.EventMask.PointerMotionMask); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|