Download Source Code

CMovableObj Class Reference

Assists in building graphical editors by managing object movement. More...

#include <MovableObj.h>

List of all members.

Public Member Functions

void Destroy ()
 Releases all resources.
BOOL Move (LPPOINT pPt)
 Moves objects if needed.
virtual BOOL OnMouseMove (UINT uFlags, LPPOINT pPt)
 Call in response to a WM_MOUSEMOVE message.
virtual BOOL OnLButtonDown (UINT uFlags, LPPOINT pPt)
 Call in response to a WM_LBUTTONDOWN message.
virtual BOOL OnLButtonUp (UINT uFlags, LPPOINT pPt)
 Call in response to a WM_LBUTTONUP message.
BOOL SetCursor (LPPOINT pt)
 Sets the needed mouse cursor.
virtual HCURSOR GetCursor (DWORD dwCursor)
 Returns the appropriate mouse cursor for a user action.
DWORD GetCursorFlags (LPPOINT pPt)
 Returns the user interaction code for a particular cursor position.
BOOL Draw (HDC hDC, LPRECT pRect)
 Draws a select box around the active area.
 CMovableObj (LPRECT pRect=NULL)
 Default constructor.
virtual ~CMovableObj ()
 Destructor.
LPRECT GetRect ()
 Returns the current size and position.
 operator LPRECT ()
 Returns the current size and position.
double SetAngle (DWORD i, double v)
 Sets the object rotation angle for the specified index.
void SetDistance (double v)
 Sets the distance for resolution calculations.
double GetAngle (DWORD i)
 Returns the specified angle value.
double GetDistance ()
 Returns the distance value used in resolution calculations.
long GetX ()
 Returns object horizontal offset.
long GetY ()
 Returns object vertical offset.
void SetRect (LPRECT pRect)
 Sets the object size and position.
void GetRect (LPRECT pRect)
 Returns the objects size and position.
long GetWidth ()
 Returns the object width.
long GetHeight ()
 Returns the object height.
void SetOffset (long x, long y)
 Sets the objects horizontal and vertical offset.
long Left ()
 Returns the horizontal offset of the objects left side.
long Top ()
 Returns the horizontal offset of the objects top side.
long Right ()
 Returns the horizontal offset of the objects right side.
long Bottom ()
 Returns the horizontal offset of the objects bottom side.
virtual BOOL OnDraw (HDC hDc, LPRECT pRect)
 Called when the object needs redrawing.
void Select (BOOL bSelect)
 Set the select state.
BOOL IsSelected ()
 Returns non-zero if object is selected.
BOOL PtInRect (LPPOINT pt)
 Returns non-zero if the specified point is within the object bounds.


Detailed Description

Assists in building graphical editors by managing object movement.

This class assists in graphical editor building by managing user interactions with elements. Simple interactions such as movement, rectangular resizing, and rotation are supported.


Member Function Documentation

BOOL CMovableObj::Draw HDC  hDC,
LPRECT  pRect
 

Draws a select box around the active area.

Parameters:
[in] hDC - Handle to DC that receives the image
[in] pRect - Size of the area in hDC
Returns:
Non-zero if success
See also:

double CMovableObj::GetAngle DWORD  i  )  [inline]
 

Returns the specified angle value.

Parameters:
[in] i - Angle index
Returns:
Angle value for index i
See also:

HCURSOR CMovableObj::GetCursor DWORD  dwCursor  )  [virtual]
 

Returns the appropriate mouse cursor for a user action.

Parameters:
[in] dwCursor - User interaction code
Returns:
Handle to cursor
See also:

DWORD CMovableObj::GetCursorFlags LPPOINT  pPt  ) 
 

Returns the user interaction code for a particular cursor position.

Parameters:
[in] pPt - Cursor position
Returns:
User interaction code / Cursor flags
See also:

void CMovableObj::GetRect LPRECT  pRect  )  [inline]
 

Returns the objects size and position.

Parameters:
[out] pRect - Receives object size and position

BOOL CMovableObj::Move LPPOINT  pPt  ) 
 

Moves objects if needed.

Parameters:
[in] pPt - Cursor position
Returns:
Non-zero if success
See also:

virtual BOOL CMovableObj::OnDraw HDC  hDc,
LPRECT  pRect
[inline, virtual]
 

Called when the object needs redrawing.

Parameters:
[in] hDc - Handle to DC for drawing
[in] pRect - Size of hDC
If you derive from this class, you can provide custom drawing here.

Returns:
Non-zero if drawing is done
See also:

BOOL CMovableObj::OnLButtonDown UINT  uFlags,
LPPOINT  pPt
[virtual]
 

Call in response to a WM_LBUTTONDOWN message.

Parameters:
[in] uFlags - Mouse flags
[in] pPt - Cursor position
Returns:
Non-zero if redraw is required
See also:

BOOL CMovableObj::OnLButtonUp UINT  uFlags,
LPPOINT  pPt
[virtual]
 

Call in response to a WM_LBUTTONUP message.

Parameters:
[in] uFlags - Mouse flags
[in] pPt - Cursor position
Returns:
Non-zero if redraw is required
See also:

BOOL CMovableObj::OnMouseMove UINT  uFlags,
LPPOINT  pPt
[virtual]
 

Call in response to a WM_MOUSEMOVE message.

Parameters:
[in] uFlags - Mouse flags
[in] pPt - Cursor position
Returns:
Non-zero if redraw is required
See also:

BOOL CMovableObj::PtInRect LPPOINT  pt  )  [inline]
 

Returns non-zero if the specified point is within the object bounds.

Parameters:
[in] pt - Point to test
Returns:
Non-zero if the point is within the object bounds
See also:

void CMovableObj::Select BOOL  bSelect  )  [inline]
 

Set the select state.

Parameters:
[in] bSelect - Selected state

double CMovableObj::SetAngle DWORD  i,
double  v
[inline]
 

Sets the object rotation angle for the specified index.

Parameters:
[in] i - Angle index
[in] v - Angle value
Returns:
Value in v
See also:

BOOL CMovableObj::SetCursor LPPOINT  pt  ) 
 

Sets the needed mouse cursor.

Parameters:
[in] pt - Cursor position
Call this from within mouse move and click events to set the appropriate mouse cursor.

Returns:
Non-zero if success
See also:

void CMovableObj::SetDistance double  v  )  [inline]
 

Sets the distance for resolution calculations.

Parameters:
[in] v - Distance value

void CMovableObj::SetOffset long  x,
long  y
[inline]
 

Sets the objects horizontal and vertical offset.

Parameters:
[in] x - Horizontal offset
[in] y - Vertical offset

void CMovableObj::SetRect LPRECT  pRect  )  [inline]
 

Sets the object size and position.

Parameters:
[in] pRect - Object size and position


The documentation for this class was generated from the following files:
  • inc/MovableObj.h
  • MovableObj.cpp
Copyright Robert Umbehant
This documentation is covered by the LGPL