bool GUIXInitHotSpots( int num_hot_spots, gui_resource *hot ) { int i; for( i = 0; i < num_hot_spots; i++ ) { #ifdef __NT__ if( hInstUser == NULL ) { hInstUser = GetModuleHandle( "USER32.DLL" ); pfnLoadImage = (PFNLI)GetProcAddress( hInstUser, "LoadImageA" ); } if( pfnLoadImage != NULL ) { GUIHotSpots[i].bitmap = pfnLoadImage( GUIResHInst, MAKEINTRESOURCE( hot[i].res ), IMAGE_BITMAP, 0, 0, LR_LOADMAP3DCOLORS ); } else { #endif GUIHotSpots[i].bitmap = _wpi_loadbitmap( GUIResHInst, _wpi_makeintresource( hot[i].res ) ); #ifdef __NT__ } #endif _wpi_getbitmapdim( GUIHotSpots[i].bitmap, &GUIHotSpots[i].size.x, &GUIHotSpots[i].size.y ); } return( TRUE ); }
/* * 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 */
bool GUIXCreateToolBarWithTips( gui_window *wnd, bool fixed, gui_ord height, int num_toolbar_items, gui_toolbar_struct *toolinfo, bool excl, gui_colour_set *plain, gui_colour_set *standout, gui_rect *float_pos, bool use_tips ) { gui_coord size; gui_coord pos; HWND parent; HWND toolhwnd; toolbarinfo *tbar; int i; TOOLITEMINFO info; int fixed_height; int fixed_width; int adjust_amount; int width; int new_right; int bm_h; int bm_w; GUI_RECTDIM left, top, right, bottom; int h; excl = excl; plain = plain; standout = standout; fixed_height = 0; fixed_width = 0; if( ( wnd == NULL ) || ( num_toolbar_items < 1 ) || ( toolinfo == NULL ) || ( wnd->hwnd == NULLHANDLE ) || ( wnd->root == NULLHANDLE ) ) { return( false ); } if( wnd->tbinfo != NULL ) { GUICloseToolBar( wnd ); } tbar = wnd->tbinfo = (toolbarinfo *)GUIMemAlloc( sizeof( toolbarinfo ) ); if( tbar == NULL ) { return( false ); } memset( tbar, 0, sizeof( toolbarinfo ) ); parent = wnd->root; tbar->fixedrect = wnd->hwnd_client_rect; tbar->bitmaps = (HBITMAP *)GUIMemAlloc( num_toolbar_items * sizeof( HBITMAP ) ); if( tbar->bitmaps == NULL ) { GUIMemFree( tbar ); wnd->tbinfo = NULL; return( false ); } for( i = 0; i < num_toolbar_items; i++ ) { tbar->bitmaps[i] = _wpi_loadbitmap( GUIResHInst, _wpi_makeintresource( toolinfo[i].bitmap ) ); if( height == 0 ) { _wpi_getbitmapdim( tbar->bitmaps[i], &bm_w, &bm_h ); if( bm_h > fixed_height ) { fixed_height = bm_h; } if( bm_w > fixed_width ) { fixed_width = bm_w; } } } tbar->info.border_size.x = BORDER_AMOUNT; tbar->info.border_size.y = BORDER_AMOUNT; /* space for border and space before border */ adjust_amount = 2*(_wpi_getsystemmetrics( SM_CYBORDER )+BORDER_AMOUNT); if( height == 0 ) { /* maintian # of pixels in bitmap */ height = fixed_height + adjust_amount + OUTLINE_AMOUNT; width = fixed_width + OUTLINE_AMOUNT; } else { /* only height of windows given, make bitmaps square */ size.x = 0; size.y = height - 2; GUIScaleToScreenR( &size ); height = size.y; width = size.y; } _wpi_getrectvalues( tbar->fixedrect, &left, &top, &right, &bottom ); h = _wpi_getheightrect( tbar->fixedrect ); bottom = _wpi_cvth_y_plus1( height, h ); top = _wpi_cvth_y_plus1( top, h ); _wpi_setwrectvalues( &tbar->fixedrect, left, top, right, bottom ); height -= adjust_amount; /* leaving just button size */ tbar->info.button_size.x = width; tbar->info.button_size.y = height; bottom = height + BORDER_AMOUNT * 2 + _wpi_getsystemmetrics( SM_CYCAPTION ) + 2 * ( _wpi_getsystemmetrics( SM_CYFRAME ) - _wpi_getsystemmetrics( SM_CYBORDER ) ); bottom = _wpi_cvth_y_plus1( bottom, h ); #ifdef __OS2_PM__ bottom -= 2; #endif new_right = width * num_toolbar_items - (num_toolbar_items - 1) * tbar->info.border_size.x + left + 2 * _wpi_getsystemmetrics( SM_CXFRAME ) + BORDER_AMOUNT * 2; if( new_right < right ) { right = new_right; } _wpi_setwrectvalues( &tbar->floatrect, left, top, right, bottom ); _wpi_mapwindowpoints( parent, HWND_DESKTOP, (WPI_PPOINT)&tbar->floatrect, 2 ); if( fixed ) { tbar->info.area = tbar->fixedrect; tbar->info.style = TOOLBAR_FIXED_STYLE; } else { if( float_pos != NULL ) { GUICalcLocation( float_pos, &pos, &size, parent ); _wpi_setwrectvalues( &tbar->floatrect, pos.x, pos.y, pos.x + size.x, pos.y + size.y ); _wpi_mapwindowpoints( parent, HWND_DESKTOP, (WPI_PPOINT)&tbar->floatrect, 2 ); } tbar->info.area = tbar->floatrect; tbar->info.style = TOOLBAR_FLOAT_STYLE; } tbar->info.hook = guiToolBarProc; tbar->info.helphook = guiToolBarHelp; tbar->info.background = 0; tbar->info.foreground = 0; tbar->num = num_toolbar_items; tbar->info.is_fixed = fixed; tbar->info.use_tips = use_tips; tbar->hdl = ToolBarInit( parent ); ToolBarDisplay( tbar->hdl, &tbar->info ); GUIResizeBackground( wnd, true ); for( i = 0; i < num_toolbar_items; i++ ) { info.u.bmp = tbar->bitmaps[i]; info.id = toolinfo[i].id; info.flags = 0; if( use_tips && toolinfo[i].tip != NULL ) { strncpy( info.tip, toolinfo[i].tip, MAX_TIP ); } else { info.tip[0] = '\0'; } ToolBarAddItem( tbar->hdl, &info ); } toolhwnd = ToolBarWindow( tbar->hdl ); _wpi_showwindow( toolhwnd, SW_SHOWNORMAL ); _wpi_updatewindow( toolhwnd ); return( true ); }
/* * PasteImage - paste the image in the clipboard at the current point * - first check to see if the image was cut/copied from our program * - if it was, then we use the hXorClipped and hAndClipped bitmaps * we created in order to preserve the screen colors if ther were used * - otherwise, just copy from the clipboard */ void PasteImage( WPI_POINT *pt, WPI_POINT pointsize, HWND hwnd ) { HBITMAP hbitmap; HBITMAP hbitmapdup; HBITMAP holddup; HBITMAP oldbitmap; HBITMAP oldbitmap2; WPI_PRES pres; WPI_PRES mempres; HDC memdc; WPI_PRES clippres; HDC clipdc; WPI_RECT client; WPI_POINT truept; short width; short height; short clipwidth; short clipheight; img_node *node; int fstretchbmp; int bm_width, bm_height; WPI_RECTDIM left; WPI_RECTDIM right; WPI_RECTDIM top; WPI_RECTDIM bottom; WPI_RECTDIM client_l; WPI_RECTDIM client_r; WPI_RECTDIM client_t; WPI_RECTDIM client_b; #ifdef __OS2_PM__ int src_y, dest_y; #endif if( fEnableCutCopy ) { _wpi_getwrectvalues( clipRect.rect, &left, &top, &right, &bottom ); truept.x = left; truept.y = top; fstretchbmp = StretchPastedImage(); } else { truept.x = pt->x / pointsize.x; truept.y = pt->y / pointsize.y; fstretchbmp = -1; } node = SelectImage( hwnd ); pres = _wpi_getpres( node->viewhwnd ); if( _wpi_getclipboardowner( Instance ) == HMainWindow && node->imgtype != BITMAP_IMG ) { _wpi_getbitmapdim( hAndClipped, &bm_width, &bm_height ); GetClientRect( node->hwnd, &client ); if( fEnableCutCopy ) { width = (short)_wpi_getwidthrect( clipRect.rect ); height = (short)_wpi_getheightrect( clipRect.rect ); } else { _wpi_getrectvalues( client, &client_l, &client_t, &client_r, &client_b ); width = (short)( client_r / pointsize.x - truept.x ); if( width > (short)bm_width ) width = (short)bm_width; height = (short)( client_b / pointsize.y - truept.y ); if( height > (short)bm_height ) { height = (short)bm_height; } } mempres = _wpi_createcompatiblepres( pres, Instance, &memdc ); _wpi_setstretchbltmode( mempres, COLORONCOLOR ); clippres = _wpi_createcompatiblepres( pres, Instance, &clipdc ); oldbitmap = _wpi_selectbitmap( mempres, node->handbitmap ); oldbitmap2 = _wpi_selectbitmap( clippres, hAndClipped ); if( fstretchbmp == FALSE ) { clipwidth = (short)bm_width; if( clipwidth > (short)width ) clipwidth = (short)width; clipheight = (short)bm_height; if( clipheight > (short)height ) clipheight = (short)height; _wpi_patblt( mempres, truept.x, truept.y, width, height, BLACKNESS ); _wpi_bitblt( mempres, truept.x, truept.y, clipwidth, clipheight, clippres, 0, 0, SRCCOPY ); } else if( fstretchbmp == TRUE ) { _wpi_stretchblt( mempres, truept.x, truept.y, width, height, clippres, 0, 0, bm_width, bm_height, SRCCOPY); } else { _wpi_bitblt( mempres, truept.x, truept.y, width, height, clippres, 0, 0, SRCCOPY ); } _wpi_getoldbitmap( mempres, oldbitmap ); oldbitmap = _wpi_selectbitmap( mempres, node->hxorbitmap ); hbitmapdup = DuplicateBitmap( hXorClipped ); _wpi_getoldbitmap( clippres, oldbitmap2 ); oldbitmap2 = _wpi_selectbitmap( clippres, hbitmapdup ); if( fstretchbmp == FALSE ) { clipwidth = (short)bm_width; if( clipwidth > (short)width ) clipwidth = (short)width; clipheight = (short)bm_height; if( clipheight > (short)height ) clipheight = (short)height; _wpi_patblt( mempres, truept.x, truept.y, width, height, WHITENESS ); #ifdef __OS2_PM__ if( bm_height > height ) { src_y = bm_height - height; dest_y = truept.y; } else { src_y = 0; dest_y = truept.y + (height - bm_height); } _wpi_bitblt( mempres, truept.x, dest_y, clipwidth, clipheight, clippres, 0, src_y, SRCCOPY ); #else _wpi_bitblt( mempres, truept.x, truept.y, clipwidth, clipheight, clippres, 0, 0, SRCCOPY ); #endif } else if( fstretchbmp == TRUE ) { _wpi_stretchblt( mempres, truept.x, truept.y, width, height, clippres, 0, 0, bm_width, bm_height, SRCCOPY ); } else { _wpi_bitblt( mempres, truept.x, truept.y, width, height, clippres, 0, 0, SRCCOPY ); } _wpi_getoldbitmap( mempres, oldbitmap ); _wpi_getoldbitmap( clippres, oldbitmap2 ); _wpi_deletebitmap( hbitmapdup ); _wpi_deletecompatiblepres( mempres, memdc ); _wpi_deletecompatiblepres( clippres, clipdc ); } else { if( node->imgtype != BITMAP_IMG ) { CleanupClipboard(); } _wpi_openclipboard( Instance, HMainWindow ); hbitmap = _wpi_getclipboarddata( Instance, CF_BITMAP ); hbitmapdup = DuplicateBitmap( hbitmap ); _wpi_closeclipboard( Instance ); _wpi_getbitmapdim( hbitmapdup, &bm_width, &bm_height ); GetClientRect( node->hwnd, &client ); if( fEnableCutCopy ) { width = (short)_wpi_getwidthrect( clipRect.rect ); height = (short)_wpi_getheightrect( clipRect.rect ); } else { _wpi_getrectvalues( client, &client_l, &client_t, &client_r, &client_b ); width = (short)( client_r / pointsize.x - truept.x ); if( width > (short)bm_width ) width = (short)bm_width; height = (short)( client_b / pointsize.y - truept.y ); if( height > (short)bm_height ) { height = (short)bm_height; } } clippres = _wpi_createcompatiblepres( pres, Instance, &clipdc ); mempres = _wpi_createcompatiblepres( pres, Instance, &memdc ); _wpi_setstretchbltmode( mempres, COLORONCOLOR ); holddup = _wpi_selectbitmap( clippres, hbitmapdup ); oldbitmap = _wpi_selectbitmap( mempres, node->hxorbitmap ); if( fstretchbmp == FALSE ) { clipwidth = (short)bm_width; if( clipwidth > (short)width ) clipwidth = (short)width; clipheight = (short)bm_height; if( clipheight > (short)height ) clipheight = (short)height; _wpi_patblt( mempres, truept.x, truept.y, width, height, WHITENESS ); #ifdef __OS2_PM__ if( bm_height > height ) { src_y = bm_height - height; dest_y = truept.y; } else { src_y = 0; dest_y = truept.y + (height - bm_height); } _wpi_bitblt( mempres, truept.x, dest_y, clipwidth, clipheight, clippres, 0, src_y, SRCCOPY ); #else _wpi_bitblt( mempres, truept.x, truept.y, clipwidth, clipheight, clippres, 0, 0, SRCCOPY ); #endif } else if( fstretchbmp == TRUE ) { _wpi_stretchblt( mempres, truept.x, truept.y, width, height, clippres, 0, 0, bm_width, bm_height, SRCCOPY ); } else { _wpi_bitblt( mempres, truept.x, truept.y, width, height, clippres, 0, 0, SRCCOPY ); } _wpi_getoldbitmap( clippres, holddup ); _wpi_deletebitmap( hbitmapdup ); _wpi_deletecompatiblepres( clippres, clipdc ); _wpi_getoldbitmap( mempres, oldbitmap ); oldbitmap = _wpi_selectbitmap( mempres, node->handbitmap ); _wpi_patblt( mempres, truept.x, truept.y, width, height, BLACKNESS ); _wpi_getoldbitmap( mempres, oldbitmap ); _wpi_deletecompatiblepres( mempres, memdc ); } ReleaseCapture(); _wpi_releasepres( node->viewhwnd, pres ); InvalidateRect( node->viewhwnd, NULL, TRUE ); if( !fEnableCutCopy ) { _wpi_setcursor( prevCursor ); _wpi_destroycursor( pointCursor ); SetToolType( prevToolType ); } fEnableCutCopy = FALSE; RecordImage( hwnd ); BlowupImage( NULL, NULL ); PrintHintTextByID( WIE_BITMAPPASTED, NULL ); } /* PasteImage */