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

📄 wdecust.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 <windows.h>
#include "wdecust.h"
#include <win1632.h>

#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <ctype.h>
#include "wdemem.h"
#include "wdemsgbx.h"
#include "wdemsgs.gh"
#include "wdemain.h"
#include "wdefont.h"
#include "wdegetfn.h"
#include "wdestat.h"
#include "wdelist.h"
#include "wdedebug.h"
#include "wde_rc.h"
#include "jdlg.h"

/****************************************************************************/
/* macro definitions                                                        */
/****************************************************************************/
#define WDE_NUM_CUSTOMS  2
#define WDE_CHECK_WHICH(w) (((w<0)||(w>=WDE_NUM_CUSTOMS)) ?FALSE :TRUE)
#define WDE_PREVIEW_PAD  10

/****************************************************************************/
/* external function prototypes                                             */
/****************************************************************************/
extern BOOL WINEXPORT WdeSelectCustProc    ( HWND, UINT, WPARAM, LPARAM );

/****************************************************************************/
/* static function prototypes                                               */
/****************************************************************************/
static BOOL        WdeLoadMSCustomControls    ( WdeCustLib * );
static WdeCustLib *WdeAllocCustLib            ( void );
static BOOL        WdeFreeCustLib             ( WdeCustLib * );
static void        WdeFreeSelectWinCBox       ( HWND );
static Bool        WdeSetSelectWinCBox        ( HWND, WdeCustLib * );
static Bool        WdeSetSelectWin            ( HWND );
static Bool        WdeSetCurrentControl       ( HWND, int );
static Bool        WdePreviewSelected         ( HWND );

/****************************************************************************/
/* extern variables                                                         */
/****************************************************************************/
extern char     *WdeCustOpenTitle;
extern char     *WdeCustFilter;

/****************************************************************************/
/* static variables                                                         */
/****************************************************************************/
static HFONT WdeSelectFont      = NULL;
static LIST *WdeCustomLibList   = NULL;
static LIST *WdeLibList         = NULL;

WdeCurrCustControl WdeCurrControl[WDE_NUM_CUSTOMS]  =
{
    { NULL, 0 }
,   { NULL, 0 }
};

Bool WdeIsBorBtnIDSupported ( uint_16 id )
{
    /* touch unused vars to get rid of warning */
    _wde_touch(id);

    return ( FALSE );
}

void WdeGetCurrentCustControl ( int which, WdeCustLib **lib, UINT *index )
{
    if ( !WDE_CHECK_WHICH(which) ) {
        WdeWriteTrail("WdeGetCurrentCustControl: bad which!");
        return;
    }
    *lib   = WdeCurrControl[which].lib;
    *index = WdeCurrControl[which].index;
}

Bool WdeIsCurrentCustControlSet( int which )
{
    if( WDE_CHECK_WHICH(which) ) {
        if( WdeCurrControl[which].lib != NULL ) {
            return( TRUE );
        }
    }
    return( FALSE );
}

Bool WdeCustControlsLoaded( void )
{
    return( WdeCustomLibList != NULL );
}

Bool WdeSetCurrentCustControl ( int which )
{
    int       ret;
    HINSTANCE inst;
    FARPROC   proc;

    if ( WdeCustomLibList == NULL ) {
        WdeSetStatusByID( -1, WDE_NOCUSTLOADED );
        return ( TRUE );
    }

    if ( !WDE_CHECK_WHICH(which) ) {
        WdeWriteTrail("WdeSetCurrentCustControl: bad which!");
        return ( FALSE );
    }

    inst = WdeGetAppInstance();

    proc = MakeProcInstance ( (FARPROC) WdeSelectCustProc, inst );

    if ( proc == NULL ) {
        WdeWriteTrail("WdeSetCurrentCustomControl: MakeProcInstnce failed!");
        return ( FALSE );
    }

    ret = JDialogBoxParam( inst, "WdeSelectCustom", WdeGetMainWindowHandle(),
                           (DLGPROC) proc, (LPARAM) &which );

    FreeProcInstance( proc );

    /* if the window could not be created return FALSE */
    if ( ret == -1 ) {
        WdeWriteTrail("WdeSetCurrentCustomControl: "
                      "Could not create selection window!");
        return ( FALSE );
    }

    return ( TRUE );
}

Bool WdeLoadCustomLib ( Bool nt_lib, Bool load_only )
{
    char              *name;
    HINSTANCE          inst;
    WdeCustLib        *lib;
    BOOL               ret;
    WdeGetFileStruct   gf;

    gf.file_name = NULL;
    gf.title     = WdeCustOpenTitle;
    gf.filter    = WdeCustFilter;

    name = WdeGetOpenFileName ( &gf );

    if ( !name ) {
        return ( FALSE );
    }

    inst = LoadLibrary ( name );

    if ( inst == (HANDLE) NULL ) {
        WdeWriteTrail("WdeLoadCustomLib: LoadLibrary call failed!");
        WdeMemFree ( name );
        return ( FALSE );
    }

    lib = WdeAllocCustLib ();
    if ( lib == NULL ) {
        WdeWriteTrail("WdeLoadCustomLib: WdeAllocCustLib failed!");
        WdeMemFree ( name );
        FreeLibrary ( inst );
        return ( FALSE );
    }

    lib->inst      = inst;
    lib->nt_lib    = nt_lib;
    lib->load_only = load_only;
    lib->file_name = name;

    if ( load_only ) {
        WdeSetStatusByID( -1, WDE_LIBRARYLOADED );
        ret = TRUE;
    } else {
        if ( nt_lib ) {
            ret = WdeLoadMSCustomControls ( lib );
        } else {
            ret = TRUE;
        }
    }

    if ( !ret ) {
        WdeFreeCustLib ( lib );
        return ( FALSE );
    }

    if ( load_only ) {
        WdeInsertObject ( &WdeLibList, (void *) lib );
    } else {
        WdeInsertObject ( &WdeCustomLibList, (void *) lib );
    }

    return ( TRUE );
}

BOOL WdeLoadMSCustomControls ( WdeCustLib *lib )
{
    LPFNCCINFO  info_proc;
    UINT        num_classes;

    info_proc = (LPFNCCINFO)
        GetProcAddress ( lib->inst, "CustomControlInfoA" );

    if ( info_proc == NULL ) {
        info_proc = (LPFNCCINFO)
            GetProcAddress( lib->inst, "CustomControlInfoA" );
        if ( info_proc == NULL ) {
            WdeWriteTrail("WdeLoadMSCustomControls: Info Proc not found!");
        } else {
            WdeSetStatusByID( -1, WDE_UNICUSTNOTSUPPORTED );
        }
        return ( FALSE );
    }

    num_classes = (*info_proc) ( NULL );

    if ( !num_classes ) {
        WdeWriteTrail("WdeLoadMSCustomControls: Info Proc returned NULL!");
        return ( FALSE );
    }

    lib->lpcci = (LPCCINFO) WdeMemAlloc ( sizeof(CCINFO) * num_classes );
    if ( !lib->lpcci ) {
        WdeWriteTrail("WdeLoadMSCustomControls: LPCCINFO alloc failed!");
        return ( FALSE );
    }
    memset ( lib->lpcci, 0, sizeof(CCINFO) * num_classes );

    lib->num_classes = (*info_proc) ( lib->lpcci );

    if (  lib->num_classes != num_classes ) {
        WdeWriteTrail("WdeLoadMSCustomControls: LPCCINFO inconsistent!");
    }

    return ( TRUE );
}

WdeCustLib *WdeAllocCustLib ( void )
{
    WdeCustLib  *lib;

    lib = (WdeCustLib *) WdeMemAlloc ( sizeof(WdeCustLib) );

    if ( lib == NULL ) {
        WdeWriteTrail("WdeAllocCustLib: WdeCustLib alloc failed!");
        return ( NULL );
    }

    memset ( lib, 0, sizeof(WdeCustLib) );

    WdeMemValidate ( lib );

    return ( lib );
}

Bool WdeFreeAllCustLibs ( void )
{
    LIST        *llist;
    WdeCustLib  *lib;

    if ( WdeCustomLibList != NULL ) {
        for ( llist = WdeCustomLibList; llist; llist = ListNext(llist) ) {
            lib = (WdeCustLib *) ListElement(llist);
            WdeFreeCustLib ( lib );
        }
        ListFree ( WdeCustomLibList );
        WdeCustomLibList = NULL;
    }

    if ( WdeLibList != NULL ) {
        for ( llist = WdeLibList; llist; llist = ListNext(llist) ) {
            lib = (WdeCustLib *) ListElement(llist);
            WdeFreeCustLib ( lib );
        }
        ListFree ( WdeLibList );
        WdeLibList = NULL;
    }

    return ( TRUE );
}

BOOL WdeFreeCustLib ( WdeCustLib *lib )
{
    if (lib != NULL) {
        if ( lib->file_name != NULL ) {
            WdeMemFree ( lib->file_name );
        }
        if  ( lib->inst != NULL ) {
            FreeLibrary ( lib->inst );
        }
        if  ( lib->lpcci != NULL ) {
            WdeMemFree ( lib->lpcci );
        }
        WdeMemFree ( lib );
    } else {
        WdeWriteTrail("WdeFreeCustLib: NULL lib!");
        return ( FALSE );
    }

    return ( TRUE );
}

void WdeFindClassInAllCustLibs ( char *class, LIST **list )
{
    LIST        *llist;
    WdeCustLib  *lib;

⌨️ 快捷键说明

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