⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 iconinfo.c

📁 开放源码的编译器open watcom 1.6.0版的源代码
💻 C
📖 第 1 页 / 共 2 页
字号:
/****************************************************************************
*
*                            Open Watcom Project
*
*    Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
*
*  ========================================================================
*
*    This file contains Original Code and/or Modifications of Original
*    Code as defined in and that are subject to the Sybase Open Watcom
*    Public License version 1.0 (the 'License'). You may not use this file
*    except in compliance with the License. BY USING THIS FILE YOU AGREE TO
*    ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is
*    provided with the Original Code and Modifications, and is also
*    available at www.sybase.com/developer/opensource.
*
*    The Original Code and all software distributed under the License are
*    distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
*    EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM
*    ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
*    MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR
*    NON-INFRINGEMENT. Please see the License for the specific language
*    governing rights and limitations under the License.
*
*  ========================================================================
*
* Description:  WHEN YOU FIGURE OUT WHAT THIS FILE DOES, PLEASE
*               DESCRIBE IT HERE!
*
****************************************************************************/


#include "imgedit.h"
#include "iconinfo.h"

static icon_info_struct iconInfo[NUM_OF_ICONS];
static int              iconType;
static int              iconNumber[NUM_OF_ICONS];
static int              numberOfIcons = 0;
static int              iconOperation = 0;
static char             *dialogBoxText[4];

/*
 * getIconType - returns the index of the icon resource.
 */
static short getIconType( int bitcount, int width, int height )
{
    /*
    if (bitcount == 24) {
        if (height == 32)
             return( XX );               // True col, 32x32
        else if (height == 16)
             return( XX );               // True col, 16x16
        else if (height == 48)
             return( XX );               // True col, 48x48
        else
             return ( -1 );
    } else
    */
    if (bitcount == 8) {
        if (height == 96)
            return( 15 );              // 256 col, 96x96
        else if (height == 64)
            return( 12 );              // 256 col, 64x64
        else if (height == 32)
            return( 8 );               // 256 col, 32x32
        else if (height == 16)
            return( 9 );               // 256 col, 16x16
        else if (height == 48)
            return( 5 );               // 256 col, 48x48
        else
            return ( -1 );
    } else if (bitcount == 4) {
        if (height == 96)
            return( 14 );              // 16 col, 96x96
        else if (height == 64)
            return( 11 );              // 16 col, 64x64
        else if (height == 32)
            return( 0 );               // 16 col, 32x32
        else if (height == 16)
            return( 3 );               // 16 col, 16x16
        else if (height == 48)          
            return( 6 );               // 16 col, 48x48
        else if (height == 24)          
            return( 7 );               // 16 col, 24x24
        else
            return( -1 );
    } else if (bitcount == 1) {
        if (height == 96)               
            return( 13 );              // 2 col, 96x96
        else if (height == 64)               
            return( 10 );              // 2 col, 32x32
        else if (height == 32)              
            return( 1 );               // 2 col, 32x32
        else if (height == 16) {      
            if (width == 32)
                return( 2 );           // 2 col, 32x16
            else if (width == 16)      
                return( 4 );           // 2 col, 16x16
            else
                return( -1 );
        } else {
            return( -1 );
        }
    } else {
        return( -1 );
    }
} /* getIconType */

/*
 * FiniIconInfo - Free what was allocated in Init below.
 */
void FiniIconInfo( void )
{
    int i;

    for( i = 0; i < NUM_OF_ICONS; ++i ) {
        if( iconInfo[i].text != NULL )
            IEFreeRCString( iconInfo[i].text );
    }

    for (i = 0; i < SEL_ICON_OP+1; i++) {
        if (dialogBoxText[i] != NULL)
            IEFreeRCString(dialogBoxText[i]);
    }
}

/*
 * InitIconInfo - Initializes some icon information needed later.
 */
void InitIconInfo( void )
{
    short       i;

    for( i = 0; i < NUM_OF_ICONS; ++i ) {
        iconInfo[i].exists = FALSE;
        iconInfo[i].width = 32;
        iconInfo[i].height = 32;
    }

    iconInfo[2].height = 16;
    iconInfo[3].height = iconInfo[3].width = 16;
    iconInfo[4].height = iconInfo[4].width = 16;
    iconInfo[5].height = iconInfo[5].width = 48;
    iconInfo[6].height = iconInfo[6].width = 48;
    iconInfo[7].height = iconInfo[7].width = 24;

    // iconInfo[8].height = iconInfo[8].width = 32;
    iconInfo[9].height = iconInfo[9].width = 16;

    iconInfo[10].height = iconInfo[10].width = 64;
    iconInfo[11].height = iconInfo[11].width = 64;
    iconInfo[12].height = iconInfo[12].width = 64;
    iconInfo[13].height = iconInfo[13].width = 96;
    iconInfo[14].height = iconInfo[14].width = 96;
    iconInfo[15].height = iconInfo[15].width = 96;

    /*
    // iconInfo[XX].height = iconInfo[10].width = 32;
    iconInfo[XX].height = iconInfo[11].width = 16;
    iconInfo[XX].height = iconInfo[12].width = 48;
    */
    
    iconInfo[0].text = IEAllocRCString( WIE_16COLOUR32X32 );
    iconInfo[1].text = IEAllocRCString( WIE_2COLOUR32X32 );
    iconInfo[2].text = IEAllocRCString( WIE_2COLOUR32X16 );
    iconInfo[3].text = IEAllocRCString( WIE_16COLOUR16X16 );
    iconInfo[4].text = IEAllocRCString( WIE_2COLOUR16X16 );
    iconInfo[5].text = IEAllocRCString( WIE_256COLOUR48X48 );
    iconInfo[6].text = IEAllocRCString( WIE_16COLOUR48X48 );
    iconInfo[7].text = IEAllocRCString( WIE_16COLOUR24X24 );

    iconInfo[8].text = IEAllocRCString( WIE_256COLOUR32X32 );
    iconInfo[9].text = IEAllocRCString( WIE_256COLOUR16X16 );

    iconInfo[10].text = IEAllocRCString( WIE_2COLOUR64X64 );
    iconInfo[11].text = IEAllocRCString( WIE_16COLOUR64X64 );
    iconInfo[12].text = IEAllocRCString( WIE_256COLOUR64X64 );
    iconInfo[13].text = IEAllocRCString( WIE_2COLOUR96X96 );
    iconInfo[14].text = IEAllocRCString( WIE_16COLOUR96X96 );
    iconInfo[15].text = IEAllocRCString( WIE_256COLOUR96X96 );
    /*
    iconInfo[XX].text = IEAllocRCString( WIE_TRUECOLOUR32X32 );
    iconInfo[XX].text = IEAllocRCString( WIE_TRUECOLOUR16X16 );
    iconInfo[XX].text = IEAllocRCString( WIE_TRUECOLOUR48X48 );
    */
    
    iconInfo[0].bitcount = 4;
    iconInfo[1].bitcount = 1;
    iconInfo[2].bitcount = 1;
    iconInfo[3].bitcount = 4;
    iconInfo[4].bitcount = 1;
    iconInfo[5].bitcount = 8;
    iconInfo[6].bitcount = 4;
    iconInfo[7].bitcount = 4;

    iconInfo[8].bitcount = 8;
    iconInfo[9].bitcount = 8;

    iconInfo[10].bitcount = 2;
    iconInfo[11].bitcount = 4;
    iconInfo[12].bitcount = 8;
    iconInfo[13].bitcount = 2;
    iconInfo[14].bitcount = 4;
    iconInfo[15].bitcount = 8;
    
    /*
    iconInfo[XX].bitcount = 24;
    iconInfo[XX].bitcount = 24;
    iconInfo[XX].bitcount = 24;
    */

    dialogBoxText[NEW_ICON_OP]    = IEAllocRCString( WIE_SELECTTARGETICON );
    dialogBoxText[ADD_ICON_OP]    = IEAllocRCString( WIE_SELECTTYPEOFNEWICON );
    dialogBoxText[DELETE_ICON_OP] = IEAllocRCString( WIE_SELECTICONTODELETE );
    dialogBoxText[SEL_ICON_OP]    = IEAllocRCString( WIE_SELECTICONTOEDIT );
} /* InitIconInfo */

/*
 * resetIconInfo - reset the icon information
 */
static void resetIconInfo( void )
{
    short       i;

    for (i=0; i < NUM_OF_ICONS; ++i) {
        iconInfo[i].exists = FALSE;
        iconNumber[i] = -1;
    }
    numberOfIcons = 0;
} /* resetIconInfo */

/*
 * getIconIndex - given an icon type (0-6) return that icon's index.  (we can
 *                only have one of each type of icon.
 */
static short getIconIndex( int icon_type )
{
    short       i;

    for (i=0; i < numberOfIcons; ++i) {
        if (iconNumber[i] == icon_type) {
            return( i );
        }
    }
    return( -1 );
} /* getIconIndex */

/*
 * SelNonExistingProc - select an icon that does not exist (ie for ADD or NEW)
 */
WPI_DLGRESULT CALLBACK SelNonExistingProc( HWND hwnd, WPI_MSG msg,
                                                        WPI_PARAM1 wparam,
                                                        WPI_PARAM2 lparam )
{
    int         index;
    MRESULT     mresult;
    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 < NUM_OF_ICONS; ++i) {
                if (!(iconInfo[i].exists)) {
                    mresult = _wpi_senddlgitemmessage( hwnd, TARGETLISTBOX,
                                            LB_INSERTSTRING, -1,
                                            (LPARAM)((LPSTR)iconInfo[i].text));
                    index = _imgwpi_mresulttoint( mresult );
                    lbindex[index] = i;
                    ++index;
                }
            }
            _wpi_senddlgitemmessage( hwnd, TARGETLISTBOX, LB_SETCURSEL, 0, 0L );
            return( TRUE );

#ifndef __OS2_PM__
        case WM_SYSCOLORCHANGE:
            IECtl3dColorChange();
            break;
#endif
        case WM_CLOSE:

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -