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

📄 wdefstat.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 "wdeglbl.h"
#include "wdemem.h"
#include "wderesin.h"
#include "wdeobjid.h"
#include "wdefutil.h"
#include "wde_wres.h"
#include "wdemain.h"
#include "wdedebug.h"
#include "wdedefsz.h"
#include "wdeoinfo.h"
#include "wde_rc.h"
#include "wdecctl.h"
#include "wdefstat.h"

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

/****************************************************************************/
/* external function prototypes                                             */
/****************************************************************************/
extern LRESULT WINEXPORT WdeStaticSuperClassProc (HWND, UINT, WPARAM, LPARAM);
extern BOOL    WINEXPORT WdeStaticDispatcher( ACTION, WdeStaticObject *,
                                              void *, void *);

/****************************************************************************/
/* static function prototypes                                               */
/****************************************************************************/
static OBJPTR   WdeMakeStatic           ( OBJPTR, RECT *, OBJPTR, DialogStyle,
                                          char *, OBJ_ID );
static OBJPTR   WdeStatCreate           ( OBJPTR, RECT *, OBJPTR, OBJ_ID,
                                          WdeDialogBoxControl *);
static BOOL     WdeStaticDestroy        ( WdeStaticObject *, BOOL *, void *);
static BOOL     WdeStaticValidateAction ( WdeStaticObject *, ACTION *, void *);
static BOOL     WdeStaticCopyObject     ( WdeStaticObject *, WdeStaticObject **,
                                          WdeStaticObject *);
static BOOL     WdeStaticIdentify       ( WdeStaticObject *, OBJ_ID *, void *);
static BOOL     WdeStaticGetWndProc     ( WdeStaticObject *, WNDPROC *, void * );
static BOOL     WdeStaticGetWindowClass ( WdeStaticObject *, char **, void *);
static BOOL     WdeStaticDefine         ( WdeStaticObject *, POINT *, void *);
static void     WdeStaticSetDefineInfo  ( WdeDefineObjectInfo *, HWND );
static void     WdeStaticGetDefineInfo  ( WdeDefineObjectInfo *, HWND );

/****************************************************************************/
/* static variables                                                         */
/****************************************************************************/
static HINSTANCE                WdeApplicationInstance;
static FARPROC                  WdeStaticDispatch;
static WdeDialogBoxControl      *WdeDefaultStatic = NULL;
static int                      WdeStaticWndExtra;
static WNDPROC                  WdeOriginalStaticProc;
//static WNDPROC                        WdeStaticProc;

static DISPATCH_ITEM WdeStaticActions[] = {
    { DESTROY           ,  (BOOL (*)(OBJPTR, void *, void *))WdeStaticDestroy             }
,   { COPY              ,  (BOOL (*)(OBJPTR, void *, void *))WdeStaticCopyObject          }
,   { VALIDATE_ACTION   ,  (BOOL (*)(OBJPTR, void *, void *))WdeStaticValidateAction      }
,   { IDENTIFY          ,  (BOOL (*)(OBJPTR, void *, void *))WdeStaticIdentify            }
,   { GET_WINDOW_CLASS  ,  (BOOL (*)(OBJPTR, void *, void *))WdeStaticGetWindowClass      }
,   { DEFINE            ,  (BOOL (*)(OBJPTR, void *, void *))WdeStaticDefine              }
,   { GET_WND_PROC      ,  (BOOL (*)(OBJPTR, void *, void *))WdeStaticGetWndProc          }
};

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

OBJPTR WINEXPORT WdeFrameCreate ( OBJPTR parent, RECT *obj_rect,
                                 OBJPTR handle)
{
    if ( handle == NULL ) {
        return (WdeMakeStatic ( parent, obj_rect, handle,
                                SS_BLACKFRAME,
                                "",
                                FRAME_OBJ));
    } else {
        return ( WdeStatCreate ( parent, obj_rect, NULL,
                                 FRAME_OBJ, (WdeDialogBoxControl *) handle) );
    }
}

OBJPTR WINEXPORT WdeTextCreate ( OBJPTR parent, RECT *obj_rect,
                                 OBJPTR handle)
{
    if ( handle == NULL ) {
        return (WdeMakeStatic ( parent, obj_rect, handle,
                                SS_LEFT,
                                "Text",
                                TEXT_OBJ));
    } else {
        return ( WdeStatCreate ( parent, obj_rect, NULL,
                                 TEXT_OBJ, (WdeDialogBoxControl *) handle) );
    }
}

OBJPTR WINEXPORT WdeIconCreate ( OBJPTR parent, RECT *obj_rect,
                                 OBJPTR handle)
{
    if ( handle == NULL ) {
        return (WdeMakeStatic ( parent, obj_rect, handle,
                                SS_ICON,
                                "DefaultIcon",
                                ICON_OBJ));
    } else {
        return ( WdeStatCreate ( parent, obj_rect, NULL,
                                 ICON_OBJ, (WdeDialogBoxControl *) handle) );
    }
}

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

    style |= WS_VISIBLE | WS_CHILD;
    SETCTL_STYLE( WdeDefaultStatic, style );
    SETCTL_TEXT( WdeDefaultStatic, ResStrToNameOrOrd(text) );
    SETCTL_ID( WdeDefaultStatic, WdeGetNextControlID() );

    WdeChangeSizeToDefIfSmallRect ( parent, id, obj_rect );

    new = WdeStatCreate ( parent, obj_rect, handle, id, WdeDefaultStatic );

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

    return ( new );
}

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

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

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

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

    new->dispatcher = WdeStaticDispatch;

    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("WdeStaticCreate: CONTROL_OBJ not created!");
        WdeMemFree ( new );
        return ( NULL );
    }

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

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

    return ( new );
}

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

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

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

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

Bool WdeStaticInit( Bool first )
{
    WNDCLASS    wc;

    WdeApplicationInstance = WdeGetAppInstance();
    GetClassInfo( (HINSTANCE)NULL, "STATIC", &wc );
    WdeOriginalStaticProc = wc.lpfnWndProc;
    WdeStaticWndExtra = 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 = "wdestatic";
        wc.cbWndExtra    += sizeof( OBJPTR );
        //wc.lpfnWndProc        = WdeStaticSuperClassProc;
        if( !RegisterClass( &wc ) ) {
            WdeWriteTrail("WdeStaticInit: RegisterClass failed.");
        }
#endif
    }

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

    /* set up the default control structure */
    SETCTL_STYLE( WdeDefaultStatic, 0 );
    SETCTL_ID( WdeDefaultStatic, 0 );
    SETCTL_EXTRABYTES( WdeDefaultStatic, 0 );
    SETCTL_SIZEX( WdeDefaultStatic, 0 );
    SETCTL_SIZEY( WdeDefaultStatic, 0 );
    SETCTL_SIZEW( WdeDefaultStatic, 0 );
    SETCTL_SIZEH( WdeDefaultStatic, 0 );
    SETCTL_TEXT( WdeDefaultStatic, NULL );
    SETCTL_CLASSID( WdeDefaultStatic, ResNumToControlClass( CLASS_STATIC ) );

    WdeStaticDispatch = MakeProcInstance((FARPROC)WdeStaticDispatcher,
                                           WdeGetAppInstance());
    return( TRUE );
}

void WdeStaticFini ( void )
{
    WdeFreeDialogBoxControl ( &WdeDefaultStatic );
    FreeProcInstance        ( WdeStaticDispatch );
}

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

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

    WdeMemFree( obj );

    return ( TRUE );
}

BOOL WdeStaticValidateAction ( WdeStaticObject *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( WdeStaticActions[i].id == *act ) {
            return ( TRUE );
        }
    }

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

BOOL WdeStaticCopyObject ( WdeStaticObject *obj, WdeStaticObject **new,
                           WdeStaticObject *handle )
{
    if (new == NULL) {
        WdeWriteTrail("WdeStaticCopyObject: Invalid new object!");
        return ( FALSE );
    }

    *new = (WdeStaticObject *) WdeMemAlloc ( sizeof(WdeStaticObject) );

    if ( *new == NULL ) {
        WdeWriteTrail("WdeStaticCopyObject: Object malloc failed");
        return ( FALSE );
    }

⌨️ 快捷键说明

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