eatom.c
来自「开放源码的编译器open watcom 1.6.0版的源代码」· C语言 代码 · 共 674 行 · 第 1/2 页
C
674 行
point.y = obj->rect.bottom - obj->rect.top;
if( point.x < 0 ) {
point.x = 0;
}
if( point.y < 0 ) {
point.y = 0;
}
#if USE_OWN_WINDOW
if( obj->show ) {
MoveWindow( obj->hwnd, obj->rect.left - scrolloffset.x,
obj->rect.top - scrolloffset.y,
point.x,
point.y,
FALSE );
}
#endif
MouseAction( &obj->rect );
ShowEAtomRect( obj );
}
return( TRUE );
}
static BOOL EAtomRecreate( OBJPTR _obj, void * _pt, void * p2 )
/*************************************************************/
/* Recreate the passed object by using the point in anchor as one
* corner and the passed point as the other
*/
{
EATOM *obj = _obj;
POINT *pt = _pt;
POINT scrolloffset;
RECT drawrect;
RECT newrect;
POINT delta;
p2 = p2; /* ref'd to avoid warning */
CalcDrawRect( &obj->rect, &drawrect );
CopyRect( &newrect, &obj->rect );
if( pt->x < obj->anchor.x ) {
delta.x = pt->x - obj->rect.left;
newrect.left = pt->x;
newrect.right = obj->anchor.x;
} else {
delta.x = pt->x - obj->rect.right;
newrect.left = obj->anchor.x;
newrect.right = pt->x;
}
if( pt->y < obj->anchor.y ) {
delta.y = pt->y - obj->rect.top;
newrect.top = pt->y;
newrect.bottom = obj->anchor.y;
} else {
delta.y = pt->y - obj->rect.bottom;
newrect.top = obj->anchor.y;
newrect.bottom = pt->y;
}
if( !EqualRect( &obj->rect, &newrect ) ) {
HideEAtomRect( obj );
AutoScroll( newrect, delta );
GetOffset( &scrolloffset );
CopyRect( &obj->rect, &newrect );
#if USE_OWN_WINDOW
if( obj->show ) {
InvalidateRect( obj->hwnd, NULL, TRUE );
MoveWindow( obj->hwnd, obj->rect.left - scrolloffset.x,
obj->rect.top - scrolloffset.y,
obj->rect.right - obj->rect.left,
obj->rect.bottom - obj->rect.top,
FALSE );
}
#endif
if( GetState() != SELECTING ) {
MouseAction( &obj->rect );
}
ShowEAtomRect( obj );
}
return( TRUE );
}
static BOOL EAtomRegister( OBJPTR _obj, void * p1, void * p2 )
/************************************************************/
/* register the object */
{
EATOM *obj = _obj;
BOOL ret;
OBJPTR new;
CURROBJPTR currobj;
STATE_ID state;
POINT off;
p1 = p1; /* ref'd to avoid warning */
p2 = p2; /* ref'd to avoid warning */
ret = TRUE;
currobj = GetCurrObjptr( obj );
state = GetState();
if( !IsRectEmpty( (LPRECT) &obj->rect ) || state == CREATING ) {
/* register the completed action with the appropriate object */
switch( state ) {
case CREATING :
DeleteCurrObject( currobj );
new = Create( GetBaseObjType(), obj->obj, &obj->rect, NULL );
if( new != NULL ) {
if( Register( new ) ) {
AddCurrObject( new );
} else {
ret = FALSE;
Destroy( new, FALSE );
}
} else {
ret = FALSE;
}
Destroy( (OBJECT *)obj, FALSE );
break;
case MOVING :
off.x = obj->rect.left;
off.y = obj->rect.top;
SnapPointToGrid( &off );
off.x -= obj->anchor.x;
off.y -= obj->anchor.y;
ret = Move( obj->obj, &off, TRUE );
if( ret ) {
obj->offset = off;
currobj = GetCurrObjptr( obj->obj );
if( currobj != NULL ) {
SetPrimaryObject( currobj );
} else {
AddCurrObject( obj->obj );
}
}
break;
case SIZING :
DeleteCurrObject( currobj );
Resize( obj->obj, &obj->rect, TRUE );
AddCurrObject( obj->obj );
Destroy( (OBJECT *)obj, FALSE );
break;
#ifdef DEBUG_ON
default :
MessageBox( GFileIO.hWnd, ( LPSTR ) "MOVE\RESIZE Error",
NULL, MB_OK | MB_ICONSTOP );
#endif
}
UpdateScroll();
} else {
/* a single click on the object implies making it current */
AddCurrObject( obj->obj );
Destroy( (OBJECT *)obj, FALSE );
}
return( ret );
}
static BOOL EAtomDestroy( OBJPTR _obj, void * p1, void * p2 )
/***********************************************************/
/* destroy the EATOM */
{
EATOM *obj = _obj;
p1 = p1; /* ref'd to avoid warning */
p2 = p2; /* ref'd to avoid warning */
#if USE_OWN_WINDOW
if( obj->show ) {
SendMessage( obj->hwnd, WM_KILLFOCUS, 0, 0 );
DestroyWindow( obj->hwnd );
}
#else
HideEAtomRect( obj );
#endif
EdFree( obj );
return( TRUE );
}
static BOOL EAtomDraw( OBJPTR _obj, void * _rect, void * _hdc )
/**********************************************************/
{
EATOM *obj = _obj;
RECT *rect = _rect;
HDC *hdc = _hdc;
RECT intersect;
hdc = hdc; /* ref'd to avoid warning */
if( obj->displayed && IntersectRect( &intersect, rect, &obj->rect ) ) {
DrawEAtomRect( obj );
}
return( TRUE );
}
static BOOL EAtomGetObjptr( OBJPTR _obj, void * _newobj, void * p2 )
/******************************************************************/
/* Get the OBJPTR of the object associated with this EATOM */
{
EATOM *obj = _obj;
OBJPTR *newobj = _newobj;
p2 = p2; /* ref'd to avoid warning */
if( newobj != NULL ) {
*newobj = obj->obj;
}
return( TRUE );
}
static BOOL EAtomUndoMove( OBJPTR _obj, void * p1, void * p2 )
/************************************************************/
{
EATOM *obj = _obj;
p1 = p1; /* ref'd to avoid warning */
p2 = p2; /* ref'd to avoid warning */
GetObjectParent( obj->obj, &obj->parent );
if( obj->parent != NULL ) {
RemoveObject( obj->parent, obj->obj );
obj->offset.x = - obj->offset.x;
obj->offset.y = - obj->offset.y;
return( Move( obj->obj, &obj->offset, TRUE ));
} else {
return( FALSE );
}
}
static BOOL EAtomRemoveFromParent( OBJPTR _obj, void * p1, void * p2 )
/********************************************************************/
{
EATOM *obj = _obj;
p1 = p1; /* ref'd to avoid warning */
p2 = p2; /* ref'd to avoid warning */
GetObjectParent( obj->obj, &obj->parent );
if( obj->parent != NULL ) {
RemoveObject( obj->parent, obj->obj );
return( TRUE );
} else {
return( TRUE );
}
}
static BOOL EAtomGetAnchor( OBJPTR _obj, void * _pt, void * p2 )
/**************************************************************/
{
EATOM *obj = _obj;
POINT *pt = _pt;
p2 = p2;
*pt = obj->anchor;
return( TRUE );
}
static BOOL EAtomIsMarkValid( OBJPTR obj, void * valid, void * p2 )
/******************************************************************/
{
obj = obj;
p2 = p2;
*(BOOL *)valid = FALSE;
return( TRUE );
} /* EAtomIsMarkValid */
static BOOL EAtomNotify( OBJPTR _obj, void * _id, void * p2 )
/*************************************************************/
{
EATOM *obj = _obj;
NOTE_ID *id = _id;
switch( *id ) {
case MOVE_START:
case MOVE_END:
if( obj->obj != NULL ) {
return( Forward( obj->obj, NOTIFY, id, p2 ) );
} else {
return( FALSE );
}
break;
default:
return( FALSE );
break;
}
} /* EAtomNotify */
long WINIEXP EAtomWndProc( HWND wnd, unsigned message,
WPARAM wparam, LPARAM lparam )
/****************************************************/
/* processes messages */
{
PAINTSTRUCT ps;
switch( message ) {
case WM_PAINT :
BeginPaint( wnd, ( LPPAINTSTRUCT ) &ps );
EndPaint( wnd, ( LPPAINTSTRUCT ) &ps );
break;
default :
return( DefWindowProc( wnd, message, wparam, lparam ));
break;
}
return( 0L );
}
extern void InitEAtom( void )
/***************************/
/* Initialization for EATOM objects - register the EAtomClass */
{
WNDCLASS wc;
wc.style = 0;
wc.lpfnWndProc = EAtomWndProc; /* Function to retrieve messages for*/
/* windows of this class. */
wc.cbClsExtra = 0; /* No per-class extra data. */
wc.cbWndExtra = 0; /* No extra data for each window */
wc.hInstance = GetInst(); /* Application that owns the class. */
wc.hIcon = NULL;
wc.hCursor = NULL;
wc.hbrBackground = NULL; /* NULL background-invisible window */
wc.lpszMenuName = NULL;
wc.lpszClassName = "EAtomClass"; /* Name used in call to CreateWindow*/
RegisterClass( &wc );
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?