📄 ieutil.c
字号:
MemAlloc( strlen( IEAppTitle ) + strlen( title ) + 3 + 1 );
if( main_title ) {
strcpy( main_title, IEAppTitle );
strcat( main_title, " - " );
strcat( main_title, title );
_wpi_setwindowtext( HMainWindow, main_title );
MemFree( main_title );
}
} else {
_wpi_getwindowtext( _wpi_getframe(node->hwnd), title, 14 );
if( strnicmp( title, IEImageUntitled, strlen( IEImageUntitled ) ) == 0 ) {
return;
} else if (title[strlen(title)-1] == '*') {
return;
} else {
strcat( title, "*" );
_wpi_setwindowtext( _wpi_getframe(node->hwnd), (LPSTR)title );
}
}
} /* SetIsSaved */
/*
* OutlineRectangle - This routine outlines a rectangle with the xor pen.
*/
void OutlineRectangle( BOOL firsttime, WPI_PRES pres, WPI_RECT *prevrc,
WPI_RECT *newrc )
{
int prevrop2;
HBRUSH holdbrush;
HBRUSH nullbrush;
HPEN holdpen;
HPEN whitepen;
int left, top, right, bottom;
_wpi_torgbmode( pres );
nullbrush = _wpi_createnullbrush();
whitepen = _wpi_createpen( PS_SOLID, 0, WHITE );
holdbrush = _wpi_selectobject( pres, nullbrush );
holdpen = _wpi_selectobject( pres, whitepen );
prevrop2 = _wpi_setrop2( pres, R2_XORPEN );
if (!firsttime) {
_wpi_getintrectvalues( *prevrc, &left, &top, &right, &bottom );
/*
* In this case don't call _wpi_convertheight because of the
* way the rectangle values are set in iedraw.c
*/
_wpi_rectangle( pres, left, top, right, bottom );
}
_wpi_getintrectvalues( *newrc, &left, &top, &right, &bottom );
_wpi_rectangle( pres, left, top, right, bottom );
_wpi_selectobject( pres, holdbrush );
_wpi_selectobject( pres, holdpen );
_wpi_setrop2( pres, prevrop2 );
_wpi_deleteobject( whitepen );
_wpi_deletenullbrush( nullbrush );
} /* OutlineRectangle */
/*
* GetFnameFromPath - given a full pathname, return just the file name.
*/
void GetFnameFromPath( char *fullpath, char *fname )
{
char filename[ _MAX_FNAME ];
char ext[ _MAX_EXT ];
if( strnicmp( fullpath, IEImageUntitled, strlen( IEImageUntitled ) ) == 0 ) {
strcpy( fname, fullpath );
return;
}
_splitpath( fullpath, NULL, NULL, filename, ext );
strcpy( fname, strupr(filename) );
strcat( fname, strupr(ext) );
} /* GetFnameFromPath */
/*
* GrayEditOptions - grays the edit options (at the beginning and when an
* image is closed).
*/
void GrayEditOptions( void )
{
HMENU hmenu;
if (!HMainWindow) return;
hmenu = _wpi_getmenu( _wpi_getframe(HMainWindow) );
_wpi_enablemenuitem( hmenu, IMGED_UNDO, FALSE, FALSE );
_wpi_enablemenuitem( hmenu, IMGED_REDO, FALSE, FALSE );
_wpi_enablemenuitem( hmenu, IMGED_REST, FALSE, FALSE );
_wpi_enablemenuitem( hmenu, IMGED_CUT, FALSE, FALSE );
_wpi_enablemenuitem( hmenu, IMGED_COPY, FALSE, FALSE );
_wpi_enablemenuitem( hmenu, IMGED_PASTE, FALSE, FALSE );
_wpi_enablemenuitem( hmenu, IMGED_SNAP, FALSE, FALSE );
_wpi_enablemenuitem( hmenu, IMGED_CLEAR, FALSE, FALSE );
_wpi_enablemenuitem( hmenu, IMGED_NEWIMG, FALSE, FALSE );
_wpi_enablemenuitem( hmenu, IMGED_SELIMG, FALSE, FALSE );
_wpi_enablemenuitem( hmenu, IMGED_DELIMG, FALSE, FALSE );
_wpi_enablemenuitem( hmenu, IMGED_RIGHT, FALSE, FALSE );
_wpi_enablemenuitem( hmenu, IMGED_LEFT, FALSE, FALSE );
_wpi_enablemenuitem( hmenu, IMGED_UP, FALSE, FALSE );
_wpi_enablemenuitem( hmenu, IMGED_DOWN, FALSE, FALSE );
_wpi_enablemenuitem( hmenu, IMGED_FLIPHORZ, FALSE, FALSE );
_wpi_enablemenuitem( hmenu, IMGED_FLIPVERT, FALSE, FALSE );
_wpi_enablemenuitem( hmenu, IMGED_ROTATECC, FALSE, FALSE );
_wpi_enablemenuitem( hmenu, IMGED_ROTATECL, FALSE, FALSE );
} /* GrayEditOptions */
/*
* GetPosProc - used to get the position of all the child windows
*/
BOOL CALLBACK GetPosProc( HWND hwnd, LONG lparam )
{
WPI_RECT windowrect;
WPI_POINT topleft; // this ends up being bottom left for PM
WPI_RECTDIM left, top;
lparam = lparam;
#ifdef __OS2_PM__
if( windowIndex >= imageMax ) {
return 0;
}
#endif
if ( _wpi_getowner(hwnd) ) {
return 1;
}
if ( _wpi_isiconic(hwnd) ) {
windowCoords[windowIndex].x = -1;
windowCoords[windowIndex].y = -1;
++windowIndex;
return 1;
}
_wpi_getwindowrect( hwnd, &windowrect );
_wpi_getrectvalues( windowrect, &left, &top, NULL, NULL );
topleft.x = left;
topleft.y = top;
_wpi_screentoclient( ClientWindow, &topleft );
if (topleft.x < 0) {
topleft.x = 0;
}
#ifndef __OS2_PM__
if (topleft.y < 0) {
topleft.y = 0;
}
#endif
windowCoords[windowIndex] = topleft;
++windowIndex;
return 1;
} /* GetPosProc */
/*
* FindOrigin - This function "cascades" the windows to find the placement
* of the new mdi child. Origin is expected to come in as 0,0
* or the equivalent for PM.
*/
void FindOrigin( WPI_POINT *new_origin )
{
WPI_ENUMPROC fp;
int image_count;
int i,j;
WPI_POINT temp;
WPI_RECT proposed;
int width;
int base;
image_count = DoImagesExist();
if (!image_count) return;
#ifdef __OS2_PM__
imageMax = image_count;
#endif
windowCoords = MemAlloc( image_count * sizeof(WPI_POINT) );
windowIndex = 0;
fp = _wpi_makeenumprocinstance( GetPosProc, Instance );
_wpi_enumchildwindows( ClientWindow, fp, 0L );
_wpi_freeprocinstance( fp );
/*
* I'm just using a simple bubble sort ... we're using small amounts of data
*/
for (i=0; i < image_count; ++i) {
for (j=0; j < image_count-i-1; ++j) {
if ( windowCoords[j].x > windowCoords[j+1].x ) {
temp = windowCoords[j];
windowCoords[j] = windowCoords[j+1];
windowCoords[j+1] = temp;
}
}
}
/*
* minimized windows will have coordinates set to negative, and we only
* want non-minimized windows.
*/
for (base=0; base < image_count; ++ base) {
if (windowCoords[base].x >= 0) {
break;
}
}
if (base >= image_count) {
MemFree( windowCoords );
return;
}
width = _wpi_getsystemmetrics( SM_CYCAPTION );
#ifndef __OS2_PM__
_wpi_setintrectvalues(&proposed, new_origin->x, new_origin->y,
new_origin->x + width, new_origin->y + width);
#else
_wpi_setrectvalues(&proposed, new_origin->x, new_origin->y - 1,
new_origin->x + width, new_origin->y + width-1);
#endif
/*
* try to place at the origin passed in if we can
*/
if ( !_wpi_ptinrect(&proposed, windowCoords[base]) ) {
MemFree( windowCoords );
return;
}
for (i=base; i < image_count-1; ++i) {
if ( windowCoords[i+1].x - windowCoords[i].x > 2*width ) {
break;
}
}
temp.x = windowCoords[i].x + width;
#ifndef __OS2_PM__
temp.y = windowCoords[i].x + width;
#else
temp.y = windowCoords[i].y - width;
#endif
_wpi_getclientrect( ClientWindow, &proposed );
#ifndef __OS2_PM__
if ( !_wpi_ptinrect(&proposed, temp) ) {
return;
} else {
new_origin->x = temp.x;
new_origin->y = temp.y;
}
#else
new_origin->x = temp.x;
new_origin->y = temp.y;
#endif
MemFree( windowCoords );
} /* FindOrigin */
/*
* SetMenus - sets the menu options for the new image.
*/
void SetMenus( img_node *node )
{
HMENU hmenu;
hmenu = _wpi_getmenu( _wpi_getframe(HMainWindow) );
_wpi_enablemenuitem( hmenu, IMGED_SNAP, TRUE, FALSE );
_wpi_enablemenuitem( hmenu, IMGED_CUT, TRUE, FALSE );
_wpi_enablemenuitem( hmenu, IMGED_COPY, TRUE, FALSE );
_wpi_enablemenuitem( hmenu, IMGED_CLEAR, TRUE, FALSE );
#ifndef __OS2_PM__
SetColourMenus( node );
#endif
if (node->imgtype == BITMAP_IMG) {
DisplayScreenClrs( FALSE );
AddHotSpotTool( FALSE );
_wpi_enablemenuitem( hmenu, IMGED_NEWIMG, FALSE, FALSE );
_wpi_enablemenuitem( hmenu, IMGED_SELIMG, FALSE, FALSE );
_wpi_enablemenuitem( hmenu, IMGED_DELIMG, FALSE, FALSE );
_wpi_enablemenuitem( hmenu, IMGED_SIZE, TRUE, FALSE );
} else if (node->imgtype == ICON_IMG) {
DisplayScreenClrs( TRUE );
AddHotSpotTool( FALSE );
_wpi_enablemenuitem( hmenu, IMGED_SELIMG, TRUE, FALSE );
if ( node->num_of_images < NUM_OF_ICONS ) {
_wpi_enablemenuitem( hmenu, IMGED_NEWIMG, TRUE, FALSE );
} else {
_wpi_enablemenuitem( hmenu, IMGED_NEWIMG, FALSE, FALSE );
}
if ( node->num_of_images > 1 ) {
_wpi_enablemenuitem( hmenu, IMGED_DELIMG, TRUE, FALSE );
_wpi_enablemenuitem( hmenu, IMGED_SELIMG, TRUE, FALSE );
} else {
_wpi_enablemenuitem( hmenu, IMGED_DELIMG, FALSE, FALSE );
_wpi_enablemenuitem( hmenu, IMGED_SELIMG, FALSE, FALSE );
}
_wpi_enablemenuitem( hmenu, IMGED_SIZE, FALSE, FALSE );
SetIconInfo( node );
} else if (node->imgtype == CURSOR_IMG) {
DisplayScreenClrs( TRUE );
AddHotSpotTool( TRUE );
_wpi_enablemenuitem( hmenu, IMGED_NEWIMG, FALSE, FALSE );
_wpi_enablemenuitem( hmenu, IMGED_SELIMG, FALSE, FALSE );
_wpi_enablemenuitem( hmenu, IMGED_DELIMG, FALSE, FALSE );
_wpi_enablemenuitem( hmenu, IMGED_SIZE, FALSE, FALSE );
}
} /* SetMenus */
#if 0
/* This routine is not necessary as far as I can see.
* ConvertToDIBitmap - converts the device dependent bitmap to a DI bitmap
*/
void ConvertToDIBitmap( HBITMAP hbitmap )
{
HDC hdc;
BITMAPINFO *bmi;
BYTE *bits;
BITMAP bm;
img_node *node;
/*
* Fill the info structure with information about the current image
* we are editing.
*/
node = GetCurrentNode();
bmi = GetDIBitmapInfo( node );
GetObject( hbitmap, sizeof(BITMAP), &bm );
/*
* Replace the fields on the info header with values for *this* bitmap.
*/
bmi->bmiHeader.biWidth = bm.bmWidth;
bmi->bmiHeader.biHeight = bm.bmHeight;
if (bmi->bmiHeader.bmWidth > 32 && FALSE) {
bmi->bmiHeader.biSizeImage = BITS_INTO_BYTES( bmi->bmiHeader.biBitCount *
bm.bmWidth, bm.bmHeight );
} else {
bmi->bmiHeader.biSizeImage = BITS_TO_BYTES( bmi->bmiHeader.biBitCount *
bm.bmWidth, bm.bmHeight );
}
bits = MemAlloc( bmi->bmiHeader.biSizeImage );
hdc = GetDC( NULL );
GetDIBits(hdc, hbitmap, 0, bmi->bmiHeader.biHeight, bits, bmi,
DIB_RGB_COLORS);
SetDIBits( hdc, hbitmap, 0, bmi->bmiHeader.biHeight, bits, bmi,
DIB_RGB_COLORS);
ReleaseDC( NULL, hdc );
FreeDIBitmapInfo( bmi );
MemFree( bits );
} /* ConvertToDIBitmap */
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -