Skip to content
Permalink
Browse files

Merge pull request #22 from shoo/add_moving_and_sizing

Add onMoving event and onSizing event
  • Loading branch information...
Rayerd committed Jan 13, 2015
2 parents a00bffa + b1a47c1 commit 93d1fd707e2a055558d3858304ed428ad6389d6b
Showing with 129 additions and 17 deletions.
  1. +101 −0 win32/dfl/base.d
  2. +28 −17 win32/dfl/control.d
@@ -764,6 +764,107 @@ class CancelEventArgs: EventArgs
bool cncl;
}

///
class SizingEventArgs: EventArgs
{
///
// Initialize cancel to false.
this(Size sz) pure nothrow
{
_sz = sz;
}

///
@property Size size() pure nothrow
{
return _sz;
}

/// ditto
@property void size(Size sz) pure nothrow
{
_sz = sz;
}

///
@property void width(size_t w) pure nothrow
{
_sz.width = w;
}

/// ditto
@property size_t width() pure nothrow
{
return _sz.width;
}

///
@property void height(size_t h) pure nothrow
{
_sz.height = h;
}

/// ditto
@property size_t height() pure nothrow
{
return _sz.height;
}


private:
Size _sz;
}

///
class MovingEventArgs: EventArgs
{
///
// Initialize cancel to false.
this(Point loc) pure nothrow
{
_loc = loc;
}

///
@property Point location() pure nothrow
{
return _loc;
}

/// ditto
@property void location(Point loc) pure nothrow
{
_loc = loc;
}

///
@property void x(size_t posX) pure nothrow
{
_loc.x = posX;
}

/// ditto
@property size_t x() pure nothrow
{
return _loc.x;
}

///
@property void y(size_t posY) pure nothrow
{
_loc.y = posY;
}

/// ditto
@property size_t y() pure nothrow
{
return _loc.y;
}


private:
Point _loc;
}

///
class KeyEventArgs: EventArgs
@@ -4147,6 +4147,11 @@ class Control: DObject, IWindow // docmain
}


protected void onMoving(MovingEventArgs cea)
{
moving(this, cea);
}

///
protected void onMove(EventArgs ea)
{
@@ -4163,6 +4168,11 @@ class Control: DObject, IWindow // docmain
alias onMove onLocationChanged;


protected void onSizing(SizingEventArgs cea)
{
sizing(this, cea);
}

///
protected void onResize(EventArgs ea)
{
@@ -4745,31 +4755,28 @@ class Control: DObject, IWindow // docmain
}
break;

/+
case WM_WINDOWPOSCHANGING:
{
WINDOWPOS* wp = cast(WINDOWPOS*)msg.lParam;

/+
//if(!(wp.flags & SWP_NOSIZE))
if(width != wp.cx || height != wp.cy)
if (!(wp.flags & SWP_NOMOVE)
&& (location.x != wp.x || location.y != wp.y))
{
scope BeforeResizeEventArgs ea = new BeforeResizeEventArgs(wp.cx, wp.cy);
onBeforeResize(ea);
/+if(wp.cx == ea.width && wp.cy == ea.height)
{
wp.flags |= SWP_NOSIZE;
}
else+/
{
wp.cx = ea.width;
wp.cy = ea.height;
}
scope e = new MovingEventArgs(Point(wp.x, wp.y));
onMoving(e);
wp.x = e.x;
wp.y = e.y;
}
if (!(wp.flags & SWP_NOSIZE)
&& (width != wp.cx || height != wp.cy))
{
scope e = new SizingEventArgs(Size(wp.cx, wp.cy));
onSizing(e);
wp.cx = e.width;
wp.cy = e.height;
}
+/
}
break;
+/

case WM_MOUSEMOVE:
if(_clicking)
@@ -5943,6 +5950,8 @@ class Control: DObject, IWindow // docmain
Event!(Control, MouseEventArgs) mouseUp; ///
//MouseEventHandler mouseWheel;
Event!(Control, MouseEventArgs) mouseWheel; ///
//EventHandler moving;
Event!(Control, MovingEventArgs) moving; ///
//EventHandler move;
Event!(Control, EventArgs) move; ///
//EventHandler locationChanged;
@@ -5951,6 +5960,8 @@ class Control: DObject, IWindow // docmain
Event!(Control, PaintEventArgs) paint; ///
//EventHandler parentChanged;
Event!(Control, EventArgs) parentChanged; ///
//EventHandler sizing;
Event!(Control, SizingEventArgs) sizing; ///
//EventHandler resize;
Event!(Control, EventArgs) resize; ///
//EventHandler sizeChanged;

0 comments on commit 93d1fd7

Please sign in to comment.
You can’t perform that action at this time.