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

📄 wreres.c

📁 开放源码的编译器open watcom 1.6.0版的源代码
💻 C
📖 第 1 页 / 共 3 页
字号:
/****************************************************************************
*
*                            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 <windows.h>
#include <stdio.h>
#include <string.h>
#include <ddeml.h>

#include "waccel.h"
#include "wmenu.h"
#include "wstring.h"

#include "wreglbl.h"
#include "wreres.h"
#include "wregetfn.h"
#include "wrestrdp.h"
#include "wremain.h"
#include "wrewait.h"
#include "wremsg.h"
#include "wremsgs.gh"
#include "wremem.h"
#include "wreselft.h"
#include "wrenames.h"
#include "wrectl3d.h"
#include "wrelist.h"
#include "wregcres.h"
#include "wredde.h"
#include "wreaccel.h"
#include "wremenu.h"
#include "wrestr.h"
#include "wredlg.h"
#include "wreimg.h"
#include "wreimage.h"
#include "wreftype.h"
#include "wresym.h"
#include "wre_rc.h"
#include "wrdll.h"
#include "wrutil.h"
#include "jdlg.h"
#include "win1632.h"

/****************************************************************************/
/* macro definitions                                                        */
/****************************************************************************/
#define GB_PAD 9
#define LB_PAD 7

/****************************************************************************/
/* external function prototypes                                             */
/****************************************************************************/
extern LRESULT WINEXPORT WREResWndProc   ( HWND, UINT, WPARAM, LPARAM );
extern LRESULT WINEXPORT WREResInfoProc  ( HWND, UINT, WPARAM, LPARAM );

/****************************************************************************/
/* static function prototypes                                               */
/****************************************************************************/
static int         WREIncNumRes               ( void );
static int         WREDecNumRes               ( void );
static Bool        WREIsCurrentMDIWindowZoomed( void );
static WREResInfo *WRELoadResource            ( const char * );
static void        WREActivateResourceWindow  ( WREResInfo *, WPARAM, LPARAM );
static Bool        WREQuerySaveResOnDeleteRes ( WREResInfo *, Bool );
static Bool        WREQuerySaveSymOnDeleteRes ( WREResInfo *, Bool );
static Bool        WRESaveResourceToFile      ( WREResInfo * );
static Bool        WRECreateResourceWindow    ( WREResInfo * );
static Bool        WREDestroyResourceWindow   ( WREResInfo * );
static Bool        WRECreateResInfoWindow     ( WREResInfo * );

Bool        WRERemoveResource          ( WREResInfo * );

/****************************************************************************/
/* external variables                                                       */
/****************************************************************************/
char    *WREResUntitled         = NULL;
char    *WREResOpenTitle        = NULL;
char    *WREResSaveTitle        = NULL;
char    *WREResSaveIntoTitle    = NULL;
char    *WREResSaveAsTitle      = NULL;
char    *WREResFilter           = NULL;
char    *WREResSaveMltFilter    = NULL;
char    *WRESymSaveFilter       = NULL;
char    *WRESymLoadTitle        = NULL;
char    *WRESymSaveTitle        = NULL;

char    *WREAccelFilter         = NULL;
char    *WREMenuFilter          = NULL;
char    *WREStringFilter        = NULL;

/****************************************************************************/
/* static variables                                                         */
/****************************************************************************/
static char             WREResClass[]           = "WREResClass";
static LIST             *WREResList             = NULL;
static unsigned         WREResCounter           = 0;
static int              WRENumRes               = 0;
static WREResInfo       *WRECurrentRes          = NULL;
static DLGPROC          WREResInfoWinProc       = NULL;
static HINSTANCE        WREAppInst              = NULL;
static HBRUSH           WREResInfoBrush         = NULL;

extern Bool WRENoInterface;

static void WREMassageFilter( char *filter )
{
    WRMassageFilter( filter );
}

static void WREFiniStaticVars( void )
{
    if( WREResUntitled != NULL ) {
        WREFreeRCString( WREResUntitled );
        WREResUntitled = NULL;
    }
    if( WREResOpenTitle != NULL ) {
        WREFreeRCString( WREResOpenTitle );
        WREResOpenTitle = NULL;
    }
    if( WREResSaveTitle != NULL ) {
        WREFreeRCString( WREResSaveTitle );
        WREResSaveTitle = NULL;
    }
    if( WREResSaveIntoTitle != NULL ) {
        WREFreeRCString( WREResSaveIntoTitle );
        WREResSaveIntoTitle = NULL;
    }
    if( WREResSaveAsTitle != NULL ) {
        WREFreeRCString( WREResSaveAsTitle );
        WREResSaveAsTitle = NULL;
    }
    if( WREResFilter != NULL ) {
        WREFreeRCString( WREResFilter );
        WREResFilter = NULL;
    }
    if( WREResSaveMltFilter != NULL ) {
        WREFreeRCString( WREResSaveMltFilter );
        WREResSaveMltFilter = NULL;
    }
    if( WRESymSaveFilter != NULL ) {
        WREFreeRCString( WRESymSaveFilter );
        WRESymSaveFilter = NULL;
    }
    if( WRESymSaveTitle != NULL ) {
        WREFreeRCString( WRESymSaveTitle );
        WRESymSaveTitle = NULL;
    }
    if( WRESymLoadTitle != NULL ) {
        WREFreeRCString( WRESymLoadTitle );
        WRESymLoadTitle = NULL;
    }
    if( WREAccelFilter != NULL ) {
        WREFreeRCString( WREAccelFilter );
        WREAccelFilter = NULL;
    }
    if( WREMenuFilter != NULL ) {
        WREFreeRCString( WREMenuFilter );
        WREMenuFilter = NULL;
    }
    if( WREStringFilter != NULL ) {
        WREFreeRCString( WREStringFilter );
        WREStringFilter = NULL;
    }
}

static Bool WREInitStaticVars( void )
{
    Bool        ok;

    WREResUntitled = WREAllocRCString( WRE_UNTITLED );
    ok = ( WREResUntitled != NULL );

    if( ok ) {
        WREResOpenTitle = WREAllocRCString( WRE_OPENPROJECTTITLE );
        ok = ( WREResOpenTitle != NULL );
    }

    if( ok ) {
        WREResSaveTitle = WREAllocRCString( WRE_SAVEPROJECTTITLE );
        ok = ( WREResSaveTitle != NULL );
    }

    if( ok ) {
        WREResSaveIntoTitle = WREAllocRCString( WRE_COPYINTOPROJECTTITLE );
        ok = ( WREResSaveIntoTitle != NULL );
    }

    if( ok ) {
        WREResSaveAsTitle = WREAllocRCString( WRE_SAVEASPROJECTTITLE );
        ok = ( WREResSaveAsTitle != NULL );
    }

    if( ok ) {
        WREResFilter = WREAllocRCString( WRE_PROJECTFILTER );
        ok = ( WREResFilter != NULL );
        if( ok ) {
            WREMassageFilter( WREResFilter );
        }
    }

    if( ok ) {
        WREResSaveMltFilter = WREAllocRCString( WRE_SAVEMLTFILTER );
        ok = ( WREResSaveMltFilter != NULL );
        if( ok ) {
            WREMassageFilter( WREResSaveMltFilter );
        }
    }

    if( ok ) {
        WRESymSaveFilter = WREAllocRCString( WRE_SYMFILTER );
        ok = ( WRESymSaveFilter != NULL );
        if( ok ) {
            WREMassageFilter( WRESymSaveFilter );
        }
    }

    if( ok ) {
        WRESymLoadTitle = WREAllocRCString( WRE_LOADSYMTITLE );
        ok = ( WRESymLoadTitle != NULL );
    }

    if( ok ) {
        WRESymSaveTitle = WREAllocRCString( WRE_SAVESYMTITLE );
        ok = ( WRESymSaveTitle != NULL );
    }

    if( ok ) {
        WREAccelFilter = WREAllocRCString( WRE_ACCELFILTER );
        ok = ( WREAccelFilter != NULL );
        if( ok ) {
            WREMassageFilter( WREAccelFilter );
        }
    }

    if( ok ) {
        WREMenuFilter = WREAllocRCString( WRE_MENUFILTER );
        ok = ( WREMenuFilter != NULL );
        if( ok ) {
            WREMassageFilter( WREMenuFilter );
        }
    }

    if( ok ) {
        WREStringFilter = WREAllocRCString( WRE_STRINGFILTER );
        ok = ( WREStringFilter != NULL );
        if( ok ) {
            WREMassageFilter( WREStringFilter );
        }
    }

    if( !ok ) {
        WREFiniStaticVars();
    }

    return( ok );
}

typedef struct infopadstruct {
    POINT       dlg_min_size;
    POINT       dlg_nc_size;
    POINT       dlg_border;
    int         text_y;
    POINT       type;
    POINT       total;
} infopadstruct;

static infopadstruct    InfoPad;
static Bool             InfoPadInit = FALSE;

static void InitInfoPad( HWND info_dlg )
{
    HWND        win;
    RECT        rect1;

    GetWindowRect( info_dlg, &rect1 );
    InfoPad.dlg_min_size.x = rect1.right - rect1.left;
    InfoPad.dlg_min_size.y = rect1.bottom - rect1.top;
    GetClientRect( info_dlg, &rect1 );
    InfoPad.dlg_nc_size.x = InfoPad.dlg_min_size.x - rect1.right - rect1.left;
    InfoPad.dlg_nc_size.y = InfoPad.dlg_min_size.y - rect1.bottom - rect1.top;

    win = GetDlgItem( info_dlg, IDM_RNTYPETEXT );
    GetWindowRect( win, &rect1 );
    MapWindowPoints( (HWND)NULL, info_dlg, (POINT *)&rect1, 2 );
    InfoPad.dlg_border.x = rect1.left;
    InfoPad.dlg_border.y = rect1.top;
    InfoPad.type.x = rect1.right - rect1.left;
    InfoPad.type.y = rect1.bottom - rect1.top;

    win = GetDlgItem( info_dlg, IDM_RNTOTALTEXT );
    GetWindowRect( win, &rect1 );
    InfoPad.total.x = rect1.right - rect1.left;
    InfoPad.total.y = rect1.bottom - rect1.top;

    win = GetDlgItem( info_dlg, IDM_RNTYPE );
    GetWindowRect( win, &rect1 );
    MapWindowPoints( (HWND)NULL, info_dlg, (POINT *)&rect1, 2 );
    InfoPad.text_y = rect1.top - InfoPad.type.y - InfoPad.dlg_border.y;
}

static void WResizeInfoWindow( WREResInfo *info )
{
    HWND        win;
    RECT        rect;
    int         dwidth, dheight;
    int         x, y, width, height;
    Bool        ok;

    if( !info || ( info->info_win == (HWND)NULL ) ) {
        return;
    }

    if( !InfoPadInit ) {
        InitInfoPad( info->info_win );
        InfoPadInit = TRUE;
    }

    GetClientRect( info->res_win, &rect );
    dwidth = max( InfoPad.dlg_min_size.x, rect.right - rect.left );
    dheight = max( InfoPad.dlg_min_size.y, rect.bottom - rect.top );
    ok = SetWindowPos( info->info_win, (HWND)NULL, 0, 0,
                       dwidth, dheight, SWP_NOZORDER );

    if( ok ) {
        // resize the type list box
        win = GetDlgItem( info->info_win, IDM_RNTYPE );
        ok = ( win != (HWND)NULL );
    }

    if( ok ) {
        width = dwidth - InfoPad.dlg_border.x * 3 - InfoPad.dlg_nc_size.x;
        height = dheight - InfoPad.dlg_border.y * 2 - InfoPad.type.y -
                 InfoPad.total.y - InfoPad.text_y * 2 - InfoPad.dlg_nc_size.y;
        ok = SetWindowPos( win, (HWND)NULL, 0, 0, ( width * 2 ) / 5, height,
                           SWP_NOMOVE | SWP_NOZORDER );
    }

    if( ok ) {
        // move and size the resource listbox
        win = GetDlgItem( info->info_win, IDM_RNRES );
        ok = ( win != (HWND)NULL );
    }

    if( ok ) {
        GetWindowRect( win, &rect );
        MapWindowPoints( (HWND)NULL, info->info_win, (POINT *)&rect, 2 );
        x = InfoPad.dlg_border.x * 2 + ( width * 2 ) / 5;
        y = rect.top;
        ok = SetWindowPos( win, (HWND)NULL, x, y, ( width * 3 ) / 5,
                           height, SWP_NOZORDER );
    }

    if( ok ) {
        // move the resource text static
        win = GetDlgItem( info->info_win, IDM_RNRESTEXT );
        ok = ( win != (HWND)NULL );
    }

    if( ok ) {
        GetWindowRect( win, &rect );
        MapWindowPoints( (HWND)NULL, info->info_win, (POINT *)&rect, 2 );
        y = rect.top;
        ok = SetWindowPos( win, (HWND)NULL, x, y, 0, 0,
                           SWP_NOSIZE | SWP_NOZORDER );
    }

    if( ok ) {
        // move the resource total static
        win = GetDlgItem( info->info_win, IDM_RNTOTALTEXT );
        ok = ( win != (HWND)NULL );
    }

    if( ok ) {
        GetWindowRect( win, &rect );
        MapWindowPoints( (HWND)NULL, info->info_win, (POINT *)&rect, 2 );
        x = x + ( width * 3 ) / 5 - InfoPad.total.x;
        y = InfoPad.dlg_border.y + InfoPad.type.y + InfoPad.text_y * 2 +
            height;
        ok = SetWindowPos( win, (HWND)NULL, x, y, 0, 0,
                           SWP_NOSIZE | SWP_NOZORDER );
    }

    return;
}

Bool pleaseOpenFile( UINT msg )
{
    char                *filter;
    char                *title;
    char                *name;
    WREResInfo          *res_info;
    WREResInfo          *old_info;
    WREGetFileStruct    gf;
    uint_16             type;
    Bool                ok;

    old_info = WREGetCurrentRes();
    res_info = NULL;
    filter = NULL;
    title = NULL;
    name = NULL;

    if( msg == ACCEL_PLEASE_OPENME ) {
        filter = WREAccelFilter;
        title = WREAllocRCString( WRE_OPENACCEL );
        type = (uint_16)RT_ACCELERATOR;
    } else if( msg == MENU_PLEASE_OPENME ) {
        filter = WREMenuFilter;
        title = WREAllocRCString( WRE_OPENMENU );
        type = (uint_16)RT_MENU;
    } else if( msg == STRING_PLEASE_OPENME ) {
        filter = WREStringFilter;
        title = WREAllocRCString( WRE_OPENSTRING );
        type = (uint_16)RT_STRING;

⌨️ 快捷键说明

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