📄 drawproc.c
字号:
case IMGED_LINE:
case IMGED_RECTO:
case IMGED_RECTF:
case IMGED_CIRCLEO:
case IMGED_CIRCLEF:
case IMGED_CLIP:
if ((flbuttondown) || (frbuttondown)) {
if (((new_pt.x/pointsize.x) != (end_pt.x/pointsize.x)) ||
((new_pt.y/pointsize.y) != (end_pt.y/pointsize.y))) {
if (toolType == IMGED_LINE) {
OutlineLine(hwnd, &start_pt, &new_pt, &prev_pt, FALSE);
} else if (toolType == IMGED_CLIP) {
OutlineClip(hwnd, &start_pt, &new_pt, &prev_pt, FALSE);
} else {
OutlineRegion(hwnd, &start_pt, &new_pt, &prev_pt, FALSE);
}
end_pt = new_pt;
SetSizeInStatus( hwnd, &start_pt, &new_pt, &pointsize );
}
} else {
SetPosInStatus(&new_pt, &pointsize, hwnd);
}
break;
case IMGED_FILL:
SetPosInStatus(&new_pt, &pointsize, hwnd);
break;
default:
SetPosInStatus(&new_pt, &pointsize, hwnd);
break;
}
prev_pt = new_pt;
return 0;
case WM_LBUTTONDOWN:
case WM_RBUTTONDOWN:
pointsize = GetPointSize( hwnd );
SetCapture(hwnd);
if( msg == WM_LBUTTONDOWN ) {
if( frbuttondown ) {
break;
}
#ifdef __OS2_PM__
node = GetCurrentNode();
if( hwnd != node->hwnd ) {
break;
}
#endif
flbuttondown = TRUE;
mousebutton = LMOUSEBUTTON;
} else {
if( flbuttondown ) {
break;
}
node = GetCurrentNode();
if( hwnd != node->hwnd ) {
break;
}
frbuttondown = TRUE;
mousebutton = RMOUSEBUTTON;
}
fdraw_shape = TRUE;
IMGED_MAKEPOINT( wparam, lparam, start_pt );
IMGED_MAKEPOINT( wparam, lparam, new_pt );
switch(toolType) {
case IMGED_SNAP:
#ifndef __OS2_PM__
TransferImage(hwnd);
#endif
fdraw_shape = FALSE;
flbuttondown = FALSE;
frbuttondown = FALSE;
break;
case IMGED_FREEHAND:
case IMGED_BRUSH:
BeginFreeHand(hwnd);
DrawSinglePoint( hwnd, &start_pt, mousebutton );
break;
case IMGED_LINE:
IMGED_MAKEPOINT( wparam, lparam, end_pt );
OutlineLine(hwnd, &start_pt, &new_pt, &prev_pt, TRUE);
break;
case IMGED_RECTO:
case IMGED_RECTF:
case IMGED_CIRCLEO:
case IMGED_CIRCLEF:
IMGED_MAKEPOINT( wparam, lparam, end_pt );
OutlineRegion(hwnd, &start_pt, &new_pt, &prev_pt, TRUE);
break;
case IMGED_CLIP:
IMGED_MAKEPOINT( wparam, lparam, end_pt );
RedrawPrevClip(hwnd);
OutlineClip(hwnd, &start_pt, &new_pt, &prev_pt, TRUE);
break;
case IMGED_FILL:
FillArea(&start_pt, mousebutton);
RecordImage(hwnd);
break;
case IMGED_HOTSPOT:
SetIsSaved( hwnd, FALSE );
prev_pt.x = start_pt.x / pointsize.x;
prev_pt.y = start_pt.y / pointsize.y;
SetNewHotSpot( &prev_pt );
break;
default:
break;
}
prev_pt = new_pt;
return 0;
case WM_LBUTTONUP:
case WM_RBUTTONUP:
pointsize = GetPointSize( hwnd );
IMGED_MAKEPOINT( wparam, lparam, end_pt );
IMGED_MAKEPOINT( wparam, lparam, new_pt );
if (msg == WM_LBUTTONUP) {
mousebutton = LMOUSEBUTTON;
} else {
mousebutton = RMOUSEBUTTON;
}
if (fdraw_shape) {
switch(toolType) {
case IMGED_PASTE:
PasteImage( &start_pt, pointsize, hwnd );
flbuttondown = FALSE;
frbuttondown = FALSE;
break;
case IMGED_FREEHAND:
case IMGED_BRUSH:
if ((flbuttondown) || (frbuttondown)) {
EndFreeHand(hwnd);
RecordImage(hwnd);
}
break;
case IMGED_LINE:
DrawLine(hwnd, &start_pt, &end_pt, mousebutton);
RecordImage(hwnd);
break;
case IMGED_RECTO:
case IMGED_RECTF:
case IMGED_CIRCLEO:
case IMGED_CIRCLEF:
DisplayRegion(hwnd, &start_pt, &end_pt, mousebutton);
RecordImage(hwnd);
break;
case IMGED_CLIP:
SetClipRect(hwnd, &start_pt, &end_pt, pointsize);
break;
default:
break;
}
fdraw_shape = FALSE;
}
ReleaseCapture();
flbuttondown = FALSE;
frbuttondown = FALSE;
prev_pt = new_pt;
return 0;
case WM_PAINT:
RepaintDrawArea(hwnd);
return 0;
case WM_QUERYENDSESSION:
case WM_CLOSE:
if (lastChanceSave(hwnd)) {
CloseCurrentImage(hwnd);
return (MRESULT)1;
} else {
return (MRESULT)0;
}
#ifndef __OS2_PM__
case WM_DESTROY:
SetCursor( LoadCursor( NULL, IDC_ARROW ));
return 0;
#endif
default:
break;
}
return( _imgwpi_defMDIchildproc( hwnd, msg, wparam, lparam ) );
} /* DrawAreaWinProc */
/*
* SetToolType - sets the tool type.
*/
int SetToolType( int toolid )
{
HMENU hmenu;
int i;
int prev_tool;
img_node *node;
if (toolType == IMGED_CLIP) {
node = GetCurrentNode();
if (node) {
RedrawPrevClip(node->hwnd);
SetRectExists( FALSE );
}
}
prev_tool = toolType;
toolType = toolid;
if ( (toolid==IMGED_PASTE) || (toolid==IMGED_SNAP) ) {
return( prev_tool );
}
if (!HMainWindow) return(0);
hmenu = _wpi_getmenu( _wpi_getframe(HMainWindow) );
switch( toolid ) {
case IMGED_FREEHAND:
setTheCursor( PENCIL_CUR, NULL );
break;
case IMGED_LINE:
setTheCursor( CROSS_CUR, NULL );
break;
case IMGED_HOTSPOT:
setTheCursor( HOTSPOT_CUR, NULL );
break;
case IMGED_RECTO:
setTheCursor( CROSS_CUR, NULL );
break;
case IMGED_RECTF:
setTheCursor( CROSS_CUR, NULL );
break;
case IMGED_CIRCLEO:
setTheCursor( CROSS_CUR, NULL );
break;
case IMGED_CIRCLEF:
setTheCursor( CROSS_CUR, NULL );
break;
case IMGED_FILL:
setTheCursor( FILL_CUR, NULL );
break;
case IMGED_BRUSH:
setTheCursor( BRUSH_CUR, NULL );
if( (prev_tool != IMGED_PASTE) && (prev_tool !=IMGED_SNAP) ) {
WriteSetSizeText( WIE_BRUSHSIZEIS, ImgedConfigInfo.brush_size,
ImgedConfigInfo.brush_size );
}
break;
case IMGED_CLIP:
setTheCursor( CROSS_CUR, NULL );
break;
default:
setTheCursor( PENCIL_CUR, NULL );
toolType = IMGED_FREEHAND;
break;
}
for( i = IMGED_CLIP; i <= IMGED_HOTSPOT; ++i) {
#if 0
if ( _wpi_isitemenabled( hmenu, i ) ) {
_wpi_checkmenuitem( hmenu, i, FALSE, FALSE );
}
#else
if ( _wpi_isitemchecked( hmenu, i ) ) {
_wpi_checkmenuitem( hmenu, i, FALSE, FALSE );
}
#endif
}
_wpi_checkmenuitem( hmenu, toolType, TRUE, FALSE );
SetDrawTool( toolType );
return( prev_tool );
} /* SetToolType */
/*
* InitializeCursors - initializes the cursors ... should be cleaned up with
* CleanupCursors.
*/
void InitializeCursors( void )
{
hCursor[PENCIL_CUR] = _wpi_loadcursor(Instance, PENCILCURSOR);
hCursor[CROSS_CUR] = _wpi_loadcursor(Instance, CROSSHAIRSCUR);
hCursor[FILL_CUR] = _wpi_loadcursor(Instance, FILLCURSOR);
hCursor[BRUSH_CUR] = _wpi_loadcursor(Instance, PAINTBRUSHCUR);
hCursor[HOTSPOT_CUR] = _wpi_loadcursor(Instance, HOTSPOTCUR);
} /* InitializeCursors */
/*
* CleanupCursors - cleans up the initialized cursors.
*/
void CleanupCursors( void )
{
_wpi_destroycursor( hCursor[PENCIL_CUR] );
_wpi_destroycursor( hCursor[CROSS_CUR] );
_wpi_destroycursor( hCursor[FILL_CUR] );
_wpi_destroycursor( hCursor[BRUSH_CUR] );
_wpi_destroycursor( hCursor[HOTSPOT_CUR] );
} /* CleanupCursors */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -