📄 iconinfo.c
字号:
_wpi_enddialog( hwnd, DLGID_CANCEL );
break;
default:
return( _wpi_defdlgproc(hwnd, msg, wparam, lparam) );
}
}
_wpi_dlgreturn( FALSE );
} /* SelNonExistingProc */
/*
* SelExistingProc - select an existing icon (ie for edit or delete)
*/
WPI_DLGRESULT CALLBACK SelExistingProc( HWND hwnd, WPI_MSG msg,
WPI_PARAM1 wparam,
WPI_PARAM2 lparam )
{
MRESULT mresult;
int index;
int i;
static int lbindex[NUM_OF_ICONS];
if( _wpi_dlg_command( hwnd, &msg, &wparam, &lparam ) ) {
switch( LOWORD(wparam) ) {
case DLGID_OK:
mresult = _wpi_senddlgitemmessage( hwnd, TARGETLISTBOX,
LB_GETCURSEL, 0, 0L );
index = _imgwpi_mresulttoint( mresult );
iconType = lbindex[index];
_wpi_enddialog( hwnd, DLGID_OK );
break;
case DLGID_CANCEL:
_wpi_enddialog( hwnd, DLGID_CANCEL );
break;
case IDB_HELP:
IEHelpRoutine();
return( FALSE );
default:
return( FALSE );
}
} else {
switch( msg ) {
case WM_INITDIALOG:
_wpi_setdlgitemtext(hwnd, DIALOGTEXT, dialogBoxText[iconOperation]);
index = 0;
for (i = 0; i < numberOfIcons; ++i) {
if (iconInfo[iconNumber[i]].exists) {
mresult = _wpi_senddlgitemmessage( hwnd, TARGETLISTBOX,
LB_INSERTSTRING, -1,
(LPARAM)((LPSTR)iconInfo[iconNumber[i]].text));
index = _imgwpi_mresulttoint( mresult );
lbindex[index] = iconNumber[i];
++index;
}
}
_wpi_senddlgitemmessage( hwnd, TARGETLISTBOX, LB_SETCURSEL, 0, 0L );
return( TRUE );
#ifndef __OS2_PM__
case WM_SYSCOLORCHANGE:
IECtl3dColorChange();
break;
#endif
case WM_CLOSE:
_wpi_enddialog( hwnd, DLGID_CANCEL );
break;
default:
return( _wpi_defdlgproc(hwnd, msg, wparam, lparam) );
}
}
_wpi_dlgreturn( FALSE );
} /* SelExistingProc */
/*
* CreateNewIcon - selects the icon from the listbox (used by FILE.NEW).
* If is_icon is FALSE, then this is a pointer (cursor).
*/
BOOL CreateNewIcon( short *width, short *height, short *bitcount, BOOL is_icon )
{
WPI_PROC fp;
int button_type;
iconOperation = NEW_ICON_OP;
resetIconInfo();
fp = _wpi_makeprocinstance( (WPI_PROC)SelNonExistingProc, Instance );
if( is_icon ) {
button_type = _wpi_dialogbox( HMainWindow, fp, Instance, ICONTYPE, 0L );
} else {
button_type = _wpi_dialogbox(HMainWindow, fp, Instance, CURSORTYPE, 0L);
}
_wpi_freeprocinstance( fp );
if (button_type == DLGID_CANCEL) {
return( FALSE );
}
*width = iconInfo[iconType].width;
*height = iconInfo[iconType].height;
*bitcount = iconInfo[iconType].bitcount;
iconInfo[iconType].exists = TRUE;
iconNumber[numberOfIcons] = iconType;
++numberOfIcons;
return( TRUE );
} /* CreateNewIcon */
/*
* AddNewIcon - Add a new icon in the current icon file.
*/
void AddNewIcon( void )
{
WPI_PROC fp;
int button_type;
img_node *currentnode;
img_node *node;
img_node new_icon;
int i;
int imagecount;
HMENU hmenu;
currentnode = GetCurrentNode();
if (currentnode->imgtype != ICON_IMG) {
return;
}
node = GetImageNode( currentnode->hwnd );
iconOperation = ADD_ICON_OP;
fp = _wpi_makeprocinstance( (WPI_PROC)SelNonExistingProc, Instance );
button_type = _wpi_dialogbox( HMainWindow, fp, Instance, ICONTYPE, 0L );
_wpi_freeprocinstance( fp );
if (button_type == DLGID_CANCEL) {
return;
}
imagecount = node->num_of_images;
currentnode = node;
for (i=0; i < imagecount; ++i) {
if (!currentnode) {
break;
}
currentnode->num_of_images += 1;
currentnode = currentnode->nexticon;
}
memcpy( &new_icon, node, sizeof(img_node) );
new_icon.width = iconInfo[iconType].width;
new_icon.height = iconInfo[iconType].height;
new_icon.bitcount = iconInfo[iconType].bitcount;
new_icon.next = NULL;
new_icon.nexticon = NULL;
/*
* this will make the xor and the and bitmaps
*/
MakeIcon( &new_icon, TRUE );
AddIconToList( &new_icon, node );
iconInfo[iconType].exists = TRUE;
iconNumber[numberOfIcons] = iconType;
++numberOfIcons;
AddIconUndoStack( &new_icon );
SelectIcon( imagecount );
SetIsSaved( new_icon.hwnd, FALSE );
hmenu = _wpi_getmenu( _wpi_getframe(HMainWindow) );
_wpi_enablemenuitem( hmenu, IMGED_SELIMG, TRUE, FALSE );
PrintHintTextByID( WIE_ICONADDEDTEXT, NULL );
} /* AddNewIcon */
/*
* DeleteIconImg - delete one of the icons from the current icon file.
*/
void DeleteIconImg( void )
{
WPI_PROC fp;
int button_type;
int icon_index;
img_node *currentnode;
img_node *node;
img_node *newnode;
short i;
HMENU hmenu;
currentnode = GetCurrentNode();
if (currentnode->imgtype != ICON_IMG) {
return;
}
node = GetImageNode( currentnode->hwnd );
iconOperation = DELETE_ICON_OP;
fp = _wpi_makeprocinstance( (WPI_PROC)SelExistingProc, Instance );
button_type = _wpi_dialogbox( HMainWindow, fp, Instance, ICONTYPE, 0L );
_wpi_freeprocinstance( fp );
if (button_type == DLGID_CANCEL) {
return;
}
icon_index = getIconIndex( iconType );
if (icon_index < 0) {
WImgEditError( WIE_ERR_BAD_ICONINDEX, WIE_INTERNAL_004 );
return;
}
iconInfo[iconType].exists = FALSE;
currentnode = node;
while(currentnode) {
currentnode->num_of_images -= 1;
currentnode = currentnode->nexticon;
}
newnode = RemoveIconFromList( node, icon_index );
DelIconUndoStack( newnode, icon_index );
MakeIcon( newnode, FALSE ); // This will set it as active image
for (i=icon_index; i < numberOfIcons-1; ++i) {
iconNumber[i] = iconNumber[i+1];
}
--numberOfIcons;
if (numberOfIcons < 2) {
hmenu = GetMenu( _wpi_getframe(HMainWindow) );
_wpi_enablemenuitem( hmenu, IMGED_SELIMG, FALSE, FALSE );
}
SelectIcon( 0 );
PrintHintTextByID( WIE_ICONDELETEDTEXT, NULL );
} /* DeleteIconImg */
/*
* SelectIconImg - Select an icon from a multiple icon editing session.
*/
void SelectIconImg( void )
{
WPI_PROC fp;
int button_type;
int icon_index;
img_node *currentnode;
img_node *node;
currentnode = GetCurrentNode();
if (currentnode->imgtype != ICON_IMG) {
return;
}
node = GetImageNode( currentnode->hwnd );
iconOperation = SEL_ICON_OP;
fp = _wpi_makeprocinstance( (WPI_PROC)SelExistingProc, Instance );
button_type = _wpi_dialogbox( HMainWindow, fp, Instance, ICONTYPE, 0L );
_wpi_freeprocinstance( fp );
if (button_type == DLGID_CANCEL) {
return;
}
icon_index = getIconIndex( iconType );
if (icon_index < 0) {
WImgEditError( WIE_ERR_BAD_ICONINDEX, WIE_INTERNAL_005 );
return;
}
SelectIcon( icon_index );
} /* SelectIconImg */
/*
* SetIconInfo - sets the icon information when an icon is opened or focused
* on.
*/
void SetIconInfo( img_node *node )
{
int i;
int icon_type;
img_node *icon;
if (node->imgtype != ICON_IMG) {
return;
}
resetIconInfo();
icon = GetImageNode( node->hwnd );
numberOfIcons = node->num_of_images;
for (i=0; i < numberOfIcons; ++i) {
if (!icon) {
WImgEditError( WIE_ERR_BAD_ICONINDEX, WIE_INTERNAL_008 );
break;
}
icon_type = getIconType( icon->bitcount, icon->width, icon->height );
iconNumber[i] = icon_type;
iconInfo[icon_type].exists = TRUE;
icon = icon->nexticon;
}
} /* SetIconInfo */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -