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

📄 wdeftabc.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 <win1632.h>

#include "wdeglbl.h"
#include "wdemem.h"
#include "wderesin.h"
#include "wdeobjid.h"
#include "wdefutil.h"
#include "wde_wres.h"
#include "wdemain.h"
#include "wdeoinfo.h"
#include "wdedefsz.h"
#include "wdedebug.h"
#include "wde_rc.h"
#include "wdesdup.h"
#include "wdecctl.h"
#include "wdeftabc.h"

/****************************************************************************/
/* type definitions                                                         */
/****************************************************************************/
typedef struct {
    FARPROC     dispatcher;
    OBJPTR      object_handle;
    OBJ_ID      object_id;
    OBJPTR      control;
} WdeTabCObject;

/****************************************************************************/
/* external function prototypes                                             */
/****************************************************************************/
extern BOOL    WINEXPORT WdeTabCDispatcher  ( ACTION, WdeTabCObject *, void *,
                                              void *);
extern LRESULT WINEXPORT WdeTabCSuperClassProc ( HWND, UINT, WPARAM, LPARAM);

/****************************************************************************/
/* static function prototypes                                               */
/****************************************************************************/
static OBJPTR   WdeMakeTabC             ( OBJPTR, RECT *, OBJPTR, DialogStyle,
                                          char *, OBJ_ID );
static OBJPTR   WdeTCCreate             ( OBJPTR, RECT *, OBJPTR,
                                          OBJ_ID, WdeDialogBoxControl *);
static BOOL     WdeTabCDestroy          ( WdeTabCObject *, BOOL *, void *);
static BOOL     WdeTabCValidateAction   ( WdeTabCObject *, ACTION *, void *);
static BOOL     WdeTabCCopyObject       ( WdeTabCObject *, WdeTabCObject **,
                                          WdeTabCObject *);
static BOOL     WdeTabCIdentify         ( WdeTabCObject *, OBJ_ID *, void *);
static BOOL     WdeTabCGetWndProc       ( WdeTabCObject *, WNDPROC *, void *);
static BOOL     WdeTabCGetWindowClass   ( WdeTabCObject *, char **, void *);
static BOOL     WdeTabCDefine           ( WdeTabCObject *, POINT *, void *);
static void     WdeTabCSetDefineInfo    ( WdeDefineObjectInfo *, HWND );
static void     WdeTabCGetDefineInfo    ( WdeDefineObjectInfo *, HWND );
static BOOL     WdeTabCDefineHook       ( HWND, UINT, WPARAM, LPARAM,
                                          DialogStyle );

/****************************************************************************/
/* static variables                                                         */
/****************************************************************************/
static HINSTANCE                WdeApplicationInstance;
static FARPROC                  WdeTabCDispatch;
static WdeDialogBoxControl      *WdeDefaultTabC = NULL;
static int                      WdeTabCWndExtra;
static WNDPROC                  WdeOriginalTabCProc;
//static WNDPROC                        WdeTabCProc;

#define WWC_TABCONTROL   WC_TABCONTROL

static DISPATCH_ITEM WdeTabCActions[] = {
    { DESTROY           ,  (BOOL (*)(OBJPTR, void *, void *))WdeTabCDestroy               }
,   { COPY              ,  (BOOL (*)(OBJPTR, void *, void *))WdeTabCCopyObject            }
,   { VALIDATE_ACTION   ,  (BOOL (*)(OBJPTR, void *, void *))WdeTabCValidateAction        }
,   { IDENTIFY          ,  (BOOL (*)(OBJPTR, void *, void *))WdeTabCIdentify              }
,   { GET_WINDOW_CLASS  ,  (BOOL (*)(OBJPTR, void *, void *))WdeTabCGetWindowClass        }
,   { DEFINE            ,  (BOOL (*)(OBJPTR, void *, void *))WdeTabCDefine                }
,   { GET_WND_PROC      ,  (BOOL (*)(OBJPTR, void *, void *))WdeTabCGetWndProc            }
};

#define MAX_ACTIONS      (sizeof(WdeTabCActions)/sizeof (DISPATCH_ITEM))

OBJPTR WINEXPORT WdeTabCCreate( OBJPTR parent, RECT *obj_rect, OBJPTR handle)
{
    if( handle == NULL ) {
        return( WdeMakeTabC( parent, obj_rect, handle,
                              0, "", TABCNTL_OBJ ) );
    } else {
        return( WdeTCCreate( parent, obj_rect, NULL, TABCNTL_OBJ,
                             (WdeDialogBoxControl *) handle) );
    }
}

OBJPTR WdeMakeTabC( OBJPTR parent, RECT *obj_rect, OBJPTR handle,
                    DialogStyle style, char *text, OBJ_ID id )
{
    OBJPTR new;

    style |= WS_BORDER | WS_VISIBLE | WS_TABSTOP | WS_CHILD;

    SETCTL_STYLE( WdeDefaultTabC, style );
    SETCTL_TEXT( WdeDefaultTabC, ResStrToNameOrOrd( text ) );
    SETCTL_ID( WdeDefaultTabC, WdeGetNextControlID() );

    WdeChangeSizeToDefIfSmallRect ( parent, id, obj_rect );

    new = WdeTCCreate ( parent, obj_rect, handle, id, WdeDefaultTabC );

    WdeMemFree( GETCTL_TEXT(WdeDefaultTabC) );
    SETCTL_TEXT( WdeDefaultTabC, NULL );

    return ( new );
}

OBJPTR WdeTCCreate( OBJPTR parent, RECT *obj_rect, OBJPTR handle,
                    OBJ_ID id, WdeDialogBoxControl *info)
{
    WdeTabCObject *new;

    WdeDebugCreate("TabC", parent, obj_rect, handle);

    if ( parent == NULL ) {
        WdeWriteTrail("WdeTabCCreate: TabC has no parent!");
        return ( NULL );
    }

    new = (WdeTabCObject *) WdeMemAlloc ( sizeof(WdeTabCObject) );
    if ( new == NULL ) {
        WdeWriteTrail("WdeTabCCreate: Object malloc failed");
        return ( NULL );
    }

    new->dispatcher = WdeTabCDispatch;

    new->object_id = id;

    if ( handle ==  NULL ) {
        new->object_handle = new;
    } else {
        new->object_handle = handle;
    }

    new->control = Create( CONTROL_OBJ, parent, obj_rect, new->object_handle);

    if (new->control == NULL) {
        WdeWriteTrail("WdeTabCCreate: CONTROL_OBJ not created!");
        WdeMemFree ( new );
        return ( NULL );
    }

    if (!Forward ( (OBJPTR)new->object_handle, SET_OBJECT_INFO, info, NULL) ) {
        WdeWriteTrail("WdeTabCCreate: SET_OBJECT_INFO failed!");
        Destroy ( new->control, FALSE );
        WdeMemFree ( new );
        return ( NULL );
    }

    if (!Forward ( (OBJPTR)new->object_handle, CREATE_WINDOW,
                   NULL, NULL) ) {
        WdeWriteTrail("WdeTabCCreate: CREATE_WINDOW failed!");
        Destroy ( new->control, FALSE );
        WdeMemFree ( new );
        return ( NULL );
    }

    return ( new );
}

BOOL WINEXPORT WdeTabCDispatcher ( ACTION act, WdeTabCObject *obj,
                                     void *p1, void *p2)
{
    int     i;

    WdeDebugDispatch("TabC", act, obj, p1, p2);

    for ( i = 0; i < MAX_ACTIONS; i++ ) {
        if( WdeTabCActions[i].id == act ) {
            return( (WdeTabCActions[i].rtn)( obj, p1, p2 ) );
        }
    }

    return (Forward ((OBJPTR)obj->control, act, p1, p2));
}

Bool WdeTabCInit( Bool first )
{
    WNDCLASS    wc;

    WdeApplicationInstance = WdeGetAppInstance();
    GetClassInfo( (HINSTANCE)NULL, WWC_TABCONTROL, &wc );
    WdeOriginalTabCProc = wc.lpfnWndProc;
    WdeTabCWndExtra = wc.cbWndExtra;

    if( first ) {
#if 0
        if ( wc.style & CS_GLOBALCLASS ) {
            wc.style ^= CS_GLOBALCLASS;
        }
        if ( wc.style & CS_PARENTDC ) {
            wc.style ^= CS_PARENTDC;
        }
        wc.style |= ( CS_HREDRAW | CS_VREDRAW );
        wc.hInstance     = WdeApplicationInstance;
        wc.lpszClassName = "wdeedit";
        wc.cbWndExtra  += sizeof( OBJPTR );
        //wc.lpfnWndProc      = WdeTabCSuperClassProc;
        if( !RegisterClass( &wc ) ) {
            WdeWriteTrail("WdeTabCInit: RegisterClass failed.");
        }
#endif
    }

    WdeDefaultTabC = WdeAllocDialogBoxControl ();
    if( !WdeDefaultTabC ) {
        WdeWriteTrail ("WdeTabCInit: Alloc of control failed!");
        return( FALSE );
    }

    /* set up the default control structure */
    SETCTL_STYLE( WdeDefaultTabC, WS_BORDER | WS_VISIBLE | WS_TABSTOP | WS_GROUP );
    SETCTL_ID( WdeDefaultTabC, 0 );
    SETCTL_EXTRABYTES( WdeDefaultTabC, 0 );
    SETCTL_SIZEX( WdeDefaultTabC, 0 );
    SETCTL_SIZEY( WdeDefaultTabC, 0 );
    SETCTL_SIZEW( WdeDefaultTabC, 0 );
    SETCTL_SIZEH( WdeDefaultTabC, 0 );
    SETCTL_TEXT( WdeDefaultTabC, NULL );
    SETCTL_CLASSID( WdeDefaultTabC, WdeStrToControlClass( WWC_TABCONTROL ) );

    WdeTabCDispatch = MakeProcInstance((FARPROC)WdeTabCDispatcher,
                                           WdeGetAppInstance());
    return( TRUE );
}

void WdeTabCFini ( void )
{
    WdeFreeDialogBoxControl ( &WdeDefaultTabC );
    FreeProcInstance        ( WdeTabCDispatch );
}

BOOL WdeTabCDestroy ( WdeTabCObject *obj, BOOL *flag, void *p2 )
{
    /* touch unused vars to get rid of warning */
    _wde_touch(p2);

    if ( !Forward ( obj->control, DESTROY, flag, NULL ) ) {
        WdeWriteTrail("WdeTabCDestroy: Control DESTROY failed");
        return ( FALSE );
    }

    WdeMemFree( obj );

    return ( TRUE );
}

BOOL WdeTabCValidateAction ( WdeTabCObject *obj, ACTION *act, void *p2 )
{
    int     i;

    /* touch unused vars to get rid of warning */
    _wde_touch(p2);

    for ( i = 0; i < MAX_ACTIONS; i++ ) {
        if( WdeTabCActions[i].id == *act ) {
            return ( TRUE );
        }
    }

    return ( ValidateAction( (OBJPTR) obj->control, *act, p2 ) );
}

BOOL WdeTabCCopyObject ( WdeTabCObject *obj, WdeTabCObject **new,

⌨️ 快捷键说明

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