/* * PlaceAndPaste - find out where the image is to be placed and then paste it there */ void PlaceAndPaste( void ) { HBITMAP hbitmap; WPI_POINT pointsize; img_node *node; WPI_POINT pt; unsigned long format; int bm_width; int bm_height; format = 0; node = GetCurrentNode(); if( node == NULL ) { return; } if( !_wpi_isclipboardformatavailable( Instance, CF_BITMAP, &format ) ) { PrintHintTextByID( WIE_NOBITMAPINCLIPBOARD, NULL ); return; } pointsize = GetPointSize( node->hwnd ); if( fEnableCutCopy ) { RedrawPrevClip( node->hwnd ); PasteImage( NULL, pointsize, node->hwnd ); fEnableCutCopy = FALSE; return; } prevToolType = SetToolType( IMGED_PASTE ); pointCursor = _wpi_loadcursor( Instance, POINT_CUR ); prevCursor = _wpi_setcursor( pointCursor ); _wpi_openclipboard( Instance, HMainWindow ); hbitmap = _wpi_getclipboarddata( Instance, CF_BITMAP ); _wpi_getbitmapdim( hbitmap, &bm_width, &bm_height ); _wpi_closeclipboard( Instance ); dragWidth = (short)(bm_width * pointsize.x); dragHeight = (short)(bm_height * pointsize.y); WriteSetSizeText( WIE_CLIPBOARDBITMAPSIZE, bm_width, bm_height); _wpi_getcursorpos( &pt ); _wpi_screentoclient( node->hwnd, &pt ); pt.x = pt.x / pointsize.x; pt.y = pt.y / pointsize.y; _wpi_setcapture( node->hwnd ); firstTime = true; DragClipBitmap( node->hwnd, &pt, pointsize ); } /* PlaceAndPaste */
static void SetGridSize( int x, int y ) { WriteSetSizeText( WIE_NEWGRIDSIZE, x, y ); } /* SetGridSize */
/* * SetBrushSize - sets the size of the brush for the brush tool option. */ void SetBrushSize( short new_size ) { ImgedConfigInfo.brush_size = new_size; WriteSetSizeText( WIE_NEWBRUSHSIZE, new_size, new_size ); } /* SetBrushSize */
/* * ChangeImageSize - changes the size of the current image being edited */ void ChangeImageSize( void ) { img_node *node; WPI_DLGPROC dlgproc; WPI_DLGRESULT button_type; img_node new_node; WPI_PRES pres; HDC srcdc; WPI_PRES srcpres; HDC destdc; WPI_PRES destpres; HBITMAP oldsrc; HBITMAP olddest; int retcode; WPI_PARAM2 lparam; WPI_RECT rc; short new_width; short new_height; int y_src; int y_dest; char *title; char *text; node = GetCurrentNode(); if( node == NULL ) { return; } if( node->imgtype != BITMAP_IMG ) { return; } imgHeight = node->height; imgWidth = node->width; dlgproc = _wpi_makedlgprocinstance( ChangeSizeDlgProc, Instance ); button_type = _wpi_dialogbox( HMainWindow, dlgproc, Instance, IMAGESIZE, 0L ); _wpi_freedlgprocinstance( dlgproc ); if( button_type == DLGID_CANCEL ) { return; } if( imgWidth == node->width && imgHeight == node->height ) { PrintHintTextByID( WIE_IMAGESIZEUNCHANGED, NULL ); return; } title = IEAllocRCString( WIE_INFORMATIONTEXT ); text = IEAllocRCString( WIE_RESETUNDOSTACKWARNING ); retcode = _wpi_messagebox( HMainWindow, text, title, MB_YESNO | MB_ICONINFORMATION ); if( text != NULL ) { IEFreeRCString( text ); } if( title != NULL ) { IEFreeRCString( title ); } if( retcode == WPI_IDNO ) { return; } new_node.width = (short)imgWidth; new_node.height = (short)imgHeight; new_node.bitcount = node->bitcount; new_node.imgtype = BITMAP_IMG; MakeBitmap( &new_node, TRUE ); pres = _wpi_getpres( HWND_DESKTOP ); srcpres = _wpi_createcompatiblepres( pres, Instance, &srcdc ); destpres = _wpi_createcompatiblepres( pres, Instance, &destdc ); _wpi_releasepres( HWND_DESKTOP, pres ); oldsrc = _wpi_selectbitmap( srcpres, node->hxorbitmap ); olddest = _wpi_selectbitmap( destpres, new_node.hxorbitmap ); if( stretchImage ) { _wpi_stretchblt( destpres, 0, 0, imgWidth, imgHeight, srcpres, 0, 0, node->width, node->height, SRCCOPY ); } else { #ifdef __OS2_PM__ y_src = node->height - imgHeight; if( y_src < 0 ) { y_src = 0; y_dest = imgHeight - node->height; } else { y_dest = 0; } #else y_src = 0; y_dest = 0; #endif _wpi_bitblt( destpres, 0, y_dest, node->width, node->height, srcpres, 0, y_src, SRCCOPY ); } _wpi_getoldbitmap( srcpres, oldsrc ); oldsrc = _wpi_selectbitmap( srcpres, node->handbitmap ); _wpi_getoldbitmap( destpres, olddest ); olddest = _wpi_selectbitmap( destpres, new_node.handbitmap ); if( stretchImage ) { _wpi_stretchblt( destpres, 0, 0, imgWidth, imgHeight, srcpres, 0, 0, node->width, node->height, SRCCOPY ); } else { _wpi_bitblt( destpres, 0, 0, node->width, node->height, srcpres, 0, 0, SRCCOPY ); } _wpi_getoldbitmap( srcpres, oldsrc ); _wpi_getoldbitmap( destpres, olddest ); _wpi_deletebitmap( node->hxorbitmap ); _wpi_deletebitmap( node->handbitmap ); _wpi_deletecompatiblepres( srcpres, srcdc ); _wpi_deletecompatiblepres( destpres, destdc ); node->hxorbitmap = new_node.hxorbitmap; node->handbitmap = new_node.handbitmap; node->width = (short)imgWidth; node->height = (short)imgHeight; SetIsSaved( node->hwnd, FALSE ); ResetUndoStack( node ); RePositionViewWnd( node ); _wpi_getclientrect( node->hwnd, &rc ); new_width = (short)_wpi_getwidthrect( rc ); new_height = (short)_wpi_getheightrect( rc ); lparam = WPI_MAKEP2( new_width, new_height ); ResizeChild( lparam, node->hwnd, false ); DisplayImageText( node ); WriteSetSizeText( WIE_NEWIMAGESIZE, imgWidth, imgHeight ); } /* ChangeImageSize */
/* * SetToolType - set 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 != NULL ) { RedrawPrevClip( node->hwnd ); SetRectExists( FALSE ); } } prev_tool = toolType; toolType = toolid; if( toolid == IMGED_PASTE || toolid == IMGED_SNAP ) { return( prev_tool ); } if( HMainWindow == NULL ) { 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 */