curritem.c
来自「开放源码的编译器open watcom 1.6.0版的源代码」· C语言 代码 · 共 630 行 · 第 1/2 页
C
630 行
rect.left = (work.right+work.left)/2 - SQUAREWIDTH/2; /* top middle */
rect.right = (work.right+work.left)/2 + SQUAREWIDTH/2;
rect.top = work.top - SQUAREWIDTH/2;
rect.bottom = work.top;
MOVE_TO( hdc, rect.left, rect.bottom, NULL );
LineTo( hdc, rect.left, rect.top );
LineTo( hdc, rect.right, rect.top );
LineTo( hdc, rect.right, rect.bottom );
}
static void OutlineBottomMiddle( LPRECT currect, HDC hdc )
/********************************************************/
/* Outline box at bottom middle of current rectangle */
{
RECT work;
RECT rect;
work = *currect;
work.right --;
work.bottom--;
rect.left = (work.right+work.left)/2 - SQUAREWIDTH/2; /* bottom middle */
rect.right = (work.right+work.left)/2 + SQUAREWIDTH/2;
rect.top = work.bottom;
rect.bottom = work.bottom + SQUAREWIDTH / 2;
MOVE_TO( hdc, rect.left, rect.top, NULL );
LineTo( hdc, rect.left, rect.bottom );
LineTo( hdc, rect.right, rect.bottom );
LineTo( hdc, rect.right, rect.top );
}
static void OutlineLeftMiddle( LPRECT currect, HDC hdc )
/******************************************************/
/* Outline box at left middle of current rectangle */
{
RECT work;
RECT rect;
work = *currect;
work.right --;
work.bottom--;
rect.left = work.left - SQUAREWIDTH/2; /* left middle */
rect.right = work.left;
rect.top = ( work.bottom + work.top )/2 - SQUAREWIDTH/2;
rect.bottom = ( work.bottom + work.top )/2 + SQUAREWIDTH/2;
MOVE_TO( hdc, rect.right, rect.top, NULL );
LineTo( hdc, rect.left, rect.top );
LineTo( hdc, rect.left, rect.bottom );
LineTo( hdc, rect.right, rect.bottom );
}
static void OutlineRightMiddle( LPRECT currect, HDC hdc )
/*******************************************************/
/* Outline box at right middle of current rectangle */
{
RECT work;
RECT rect;
work = *currect;
work.right --;
work.bottom--;
rect.left = work.right; /* right middle */
rect.right = work.right + SQUAREWIDTH/2;
rect.top = ( work.bottom + work.top )/2 - SQUAREWIDTH/2;
rect.bottom = ( work.bottom + work.top )/2 + SQUAREWIDTH/2;
MOVE_TO( hdc, rect.left, rect.top, NULL );
LineTo( hdc, rect.right, rect.top );
LineTo( hdc, rect.right, rect.bottom );
LineTo( hdc, rect.left, rect.bottom );
}
static void OutlineBoxes( LPRECT currect, HDC hdc )
/*************************************************/
/* draws the outlined squares at the corners and sides of the current oject */
{
OutlineTopLeft( currect, hdc );
OutlineBottomLeft( currect, hdc );
OutlineBottomRight( currect, hdc );
OutlineTopRight( currect, hdc );
OutlineTopMiddle( currect, hdc );
OutlineBottomMiddle( currect, hdc );
OutlineLeftMiddle( currect, hdc );
OutlineRightMiddle( currect, hdc );
}
static void MarkBoxes( LPRECT currect, HDC hdc, RESIZE_ID sizeid )
/****************************************************************/
/* draws the black squares at the corners and sides of the current oject */
{
POINT point;
RECT work;
work = *currect;
OffsetRect( &work, -(SQUAREWIDTH/2), -(SQUAREWIDTH/2) );
if( ( sizeid & R_LEFT ) && ( sizeid & R_TOP ) ) {
point.x = work.left; /* top left */
point.y = work.top;
DrawSquare( hdc, point );
point.x += SQUAREWIDTH/2;
DrawSquare( hdc, point );
point.x = work.left;
point.y += SQUAREWIDTH/2;
DrawSquare( hdc, point );
} else {
OutlineTopLeft( currect, hdc );
}
if( ( sizeid & R_LEFT ) && ( sizeid & R_BOTTOM ) ) {
point.x = work.left; /* bottom left */
point.y = work.bottom;
DrawSquare( hdc, point );
point.y += SQUAREWIDTH/2;
DrawSquare( hdc, point );
point.x += SQUAREWIDTH/2;
DrawSquare( hdc, point );
} else {
OutlineBottomLeft( currect, hdc );
}
if( ( sizeid & R_RIGHT ) && ( sizeid & R_BOTTOM ) ) {
point.x = work.right; /* bottom right */
point.y = work.bottom + SQUAREWIDTH/2;
DrawSquare( hdc, point );
point.x += SQUAREWIDTH/2;
DrawSquare( hdc, point );
point.y -= SQUAREWIDTH/2;
DrawSquare( hdc, point );
} else {
OutlineBottomRight( currect, hdc );
}
if( ( sizeid & R_RIGHT ) && ( sizeid & R_TOP ) ) {
point.x = work.right + SQUAREWIDTH/2; /* top right */
point.y = work.top + SQUAREWIDTH/2;
DrawSquare( hdc, point );
point.y -= SQUAREWIDTH/2;
DrawSquare( hdc, point );
point.x -= SQUAREWIDTH/2;
DrawSquare( hdc, point );
} else {
OutlineTopRight( currect, hdc );
}
if( sizeid & R_TOP ) {
point.x = ( work.right + work.left )/2; /* top middle */
point.y = work.top;
DrawSquare( hdc, point );
point.x += SQUAREWIDTH/2;
DrawSquare( hdc, point );
} else {
OutlineTopMiddle( currect, hdc );
}
if( sizeid & R_BOTTOM ) {
point.x = (work.right + work.left)/2 +SQUAREWIDTH/2; /* bottom middle */
point.y = work.bottom + SQUAREWIDTH/2;
DrawSquare( hdc, point );
point.x -= SQUAREWIDTH/2;
DrawSquare( hdc, point );
} else {
OutlineBottomMiddle( currect, hdc );
}
if( sizeid & R_LEFT ) {
point.x = work.left; /* left middle */
point.y = ( work.bottom + work.top )/2;
DrawSquare( hdc, point );
point.y += SQUAREWIDTH/2;
DrawSquare( hdc, point );
} else {
OutlineLeftMiddle( currect, hdc );
}
if( sizeid & R_RIGHT ) {
point.x = work.right + SQUAREWIDTH/2; /* right middle */
point.y = ( work.bottom + work.top )/2 + SQUAREWIDTH/2;
DrawSquare( hdc, point );
point.y -= SQUAREWIDTH/2;
DrawSquare( hdc, point );
} else {
OutlineRightMiddle( currect, hdc );
}
}
long WINIEXP CurrItemWndProc( HWND wnd, unsigned message,
WPARAM wparam, LPARAM lparam )
/**********************************************************/
/* processes messages */
{
HDC hdc;
PAINTSTRUCT ps;
RESIZE_ID sizeid;
RECT rect;
CURRITEM * ci;
POINT offset;
switch( message ) {
case WM_PAINT :
ci = ( CURRITEM * ) GetWindowLong( wnd, 0 );
if( !InitStateFormID( ci->fmstate ) ) {
/* the correct state can't be found so just ignore */
/* this WM_PAINT */
BeginPaint( wnd, ( LPPAINTSTRUCT ) &ps );
EndPaint( wnd, ( LPPAINTSTRUCT ) &ps );
break;
}
Location( ci->obj, &rect );
GetOffset( &offset );
/* if the offset has changed move the window and leave the */
/* WM_PAINT pending (it will be resent) */
/* NOTE: the debuggin kernel will complain about no */
/* BeginPaint/EndPaint on WM_PAINT but we will eventually */
/* hit them */
if( ( offset.x != ci->offset.x ) || ( offset.y != ci->offset.y ) ) {
CopyRect( &ci->rect, &rect );
ci->offset = offset;
MoveWindow( wnd,
rect.left - offset.x - SQUAREWIDTH/2,
rect.top - offset.y - SQUAREWIDTH/2,
rect.right - rect.left + SQUAREWIDTH,
rect.bottom - rect.top + SQUAREWIDTH,
FALSE );
break;
}
/* if the object has changed size move the window and leave the */
/* WM_PAINT pending */
if( !EqualRect( &rect, &ci->rect ) ) {
CopyRect( &ci->rect, &rect );
ci->offset = offset;
MoveWindow( wnd,
rect.left - offset.x - SQUAREWIDTH/2,
rect.top - offset.y - SQUAREWIDTH/2,
rect.right - rect.left + SQUAREWIDTH,
rect.bottom - rect.top + SQUAREWIDTH,
TRUE );
break;
}
BeginPaint( wnd, ( LPPAINTSTRUCT ) &ps );
if( IsMarkValid( ci->obj ) && ci->show_sel_boxes ) {
hdc = ps.hdc;
switch( GetState() ) {
case DORMANT:
case OVERBOX:
case EDITING:
case PASTE_PENDING:
case MOVE_PENDING:
case ACTION_ABORTED:
GetClientRect( wnd, &rect );
InflateRect( &rect, -SQUAREWIDTH/2, -SQUAREWIDTH/2 );
if( !IsRectEmpty( &rect ) ) {
if( ci == GetPrimaryObject() ) {
sizeid = R_ALL;
GetResizeInfo( (OBJECT *)ci, &sizeid );
MarkBoxes( &rect, hdc, sizeid );
} else {
OutlineBoxes( &rect, hdc );
}
}
break;
}
}
EndPaint( wnd, ( LPPAINTSTRUCT ) &ps );
break;
case WM_DESTROY:
ci = ( CURRITEM * ) GetWindowLong( wnd, 0 );
ci->hwnd = NULL;
break;
default :
return( DefWindowProc( wnd, message, wparam, lparam ));
break;
}
return( 0L );
}
extern void InitCurrItem( void )
/******************************/
/* Initialization for CURRITEM objects - register the CurrItemClass */
{
WNDCLASS wc;
wc.style = 0;
wc.lpfnWndProc = CurrItemWndProc; /* Function to retrieve messages for*/
/* windows of this class. */
wc.cbClsExtra = 0; /* No per-class extra data. */
wc.cbWndExtra = sizeof(CURROBJPTR); /* Extra data for each window */
/* This stores the OBJPTR */
/* associated with each curritem */
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 = "CurrItemClass"; /* Name used in call to CreateWindow*/
RegisterClass( &wc );
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?