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

📄 wdeflvw.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 "wdeflvw.h"

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

/****************************************************************************/
/* external function prototypes                                             */
/****************************************************************************/
extern BOOL    WINEXPORT WdeLViewDispatcher  ( ACTION, WdeLViewObject *, void *,
                                              void *);
extern LRESULT WINEXPORT WdeLViewSuperClassProc ( HWND, UINT, WPARAM, LPARAM);

/****************************************************************************/
/* static function prototypes                                               */
/****************************************************************************/
static OBJPTR   WdeMakeLView            ( OBJPTR, RECT *, OBJPTR, DialogStyle,
                                          char *, OBJ_ID );
static OBJPTR   WdeLVCreate             ( OBJPTR, RECT *, OBJPTR,
                                          OBJ_ID, WdeDialogBoxControl *);
static BOOL     WdeLViewDestroy         ( WdeLViewObject *, BOOL *, void *);
static BOOL     WdeLViewValidateAction  ( WdeLViewObject *, ACTION *, void *);
static BOOL     WdeLViewCopyObject      ( WdeLViewObject *, WdeLViewObject **,
                                          WdeLViewObject *);
static BOOL     WdeLViewIdentify                ( WdeLViewObject *, OBJ_ID *, void *);
static BOOL     WdeLViewGetWndProc      ( WdeLViewObject *, WNDPROC *, void *);
static BOOL     WdeLViewGetWindowClass  ( WdeLViewObject *, char **, void *);
static BOOL     WdeLViewDefine          ( WdeLViewObject *, POINT *, void *);
static void     WdeLViewSetDefineInfo   ( WdeDefineObjectInfo *, HWND );
static void     WdeLViewGetDefineInfo   ( WdeDefineObjectInfo *, HWND );
static BOOL     WdeLViewDefineHook      ( HWND, UINT, WPARAM, LPARAM,
                                          DialogStyle );

/****************************************************************************/
/* static variables                                                         */
/****************************************************************************/
static HINSTANCE                WdeApplicationInstance;
static FARPROC                  WdeLViewDispatch;
static WdeDialogBoxControl      *WdeDefaultLView = NULL;
static int                      WdeLViewWndExtra;
static WNDPROC                  WdeOriginalLViewProc;
//static WNDPROC                        WdeLViewProc;

#define WWC_LISTVIEW     WC_LISTVIEW

static DISPATCH_ITEM WdeLViewActions[] = {
    { DESTROY           ,  (BOOL (*)(OBJPTR, void *, void *))WdeLViewDestroy              }
,   { COPY              ,  (BOOL (*)(OBJPTR, void *, void *))WdeLViewCopyObject           }
,   { VALIDATE_ACTION   ,  (BOOL (*)(OBJPTR, void *, void *))WdeLViewValidateAction       }
,   { IDENTIFY          ,  (BOOL (*)(OBJPTR, void *, void *))WdeLViewIdentify             }
,   { GET_WINDOW_CLASS  ,  (BOOL (*)(OBJPTR, void *, void *))WdeLViewGetWindowClass       }
,   { DEFINE            ,  (BOOL (*)(OBJPTR, void *, void *))WdeLViewDefine               }
,   { GET_WND_PROC      ,  (BOOL (*)(OBJPTR, void *, void *))WdeLViewGetWndProc           }
};

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

OBJPTR WINEXPORT WdeLViewCreate( OBJPTR parent, RECT *obj_rect, OBJPTR handle)
{
    if( handle == NULL ) {
        return( WdeMakeLView( parent, obj_rect, handle,
                              0, "", LVIEW_OBJ ) );
    } else {
        return( WdeLVCreate( parent, obj_rect, NULL, LVIEW_OBJ,
                             (WdeDialogBoxControl *) handle) );
    }
}

OBJPTR WdeMakeLView( 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( WdeDefaultLView, style );
    SETCTL_TEXT( WdeDefaultLView, ResStrToNameOrOrd( text ) );
    SETCTL_ID( WdeDefaultLView, WdeGetNextControlID() );

    WdeChangeSizeToDefIfSmallRect ( parent, id, obj_rect );

    new = WdeLVCreate ( parent, obj_rect, handle, id, WdeDefaultLView );

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

    return ( new );
}

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

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

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

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

    new->dispatcher = WdeLViewDispatch;

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

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

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

    return ( new );
}

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

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

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

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

Bool WdeLViewInit( Bool first )
{
    WNDCLASS    wc;

    WdeApplicationInstance = WdeGetAppInstance();
    GetClassInfo( (HINSTANCE)NULL, WWC_LISTVIEW, &wc );
    WdeOriginalLViewProc = wc.lpfnWndProc;
    WdeLViewWndExtra = 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      = WdeLViewSuperClassProc;
        if( !RegisterClass( &wc ) ) {
            WdeWriteTrail("WdeLViewInit: RegisterClass failed.");
        }
#endif
    }

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

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

    WdeLViewDispatch = MakeProcInstance((FARPROC)WdeLViewDispatcher,
                                           WdeGetAppInstance());
    return( TRUE );
}

void WdeLViewFini ( void )
{
    WdeFreeDialogBoxControl ( &WdeDefaultLView );
    FreeProcInstance        ( WdeLViewDispatch );
}

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

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

⌨️ 快捷键说明

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