📄 wdeftvw.c
字号:
/****************************************************************************
*
* 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 "wdeftvw.h"
/****************************************************************************/
/* type definitions */
/****************************************************************************/
typedef struct {
FARPROC dispatcher;
OBJPTR object_handle;
OBJ_ID object_id;
OBJPTR control;
} WdeTViewObject;
/****************************************************************************/
/* external function prototypes */
/****************************************************************************/
extern BOOL WINEXPORT WdeTViewDispatcher ( ACTION, WdeTViewObject *, void *,
void *);
extern LRESULT WINEXPORT WdeTViewSuperClassProc ( HWND, UINT, WPARAM, LPARAM);
/****************************************************************************/
/* static function prototypes */
/****************************************************************************/
static OBJPTR WdeMakeTView ( OBJPTR, RECT *, OBJPTR, DialogStyle,
char *, OBJ_ID );
static OBJPTR WdeTVCreate ( OBJPTR, RECT *, OBJPTR,
OBJ_ID, WdeDialogBoxControl *);
static BOOL WdeTViewDestroy ( WdeTViewObject *, BOOL *, void *);
static BOOL WdeTViewValidateAction ( WdeTViewObject *, ACTION *, void *);
static BOOL WdeTViewCopyObject ( WdeTViewObject *, WdeTViewObject **,
WdeTViewObject *);
static BOOL WdeTViewIdentify ( WdeTViewObject *, OBJ_ID *, void *);
static BOOL WdeTViewGetWndProc ( WdeTViewObject *, WNDPROC *, void *);
static BOOL WdeTViewGetWindowClass ( WdeTViewObject *, char **, void *);
static BOOL WdeTViewDefine ( WdeTViewObject *, POINT *, void *);
static void WdeTViewSetDefineInfo ( WdeDefineObjectInfo *, HWND );
static void WdeTViewGetDefineInfo ( WdeDefineObjectInfo *, HWND );
static BOOL WdeTViewDefineHook ( HWND, UINT, WPARAM, LPARAM,
DialogStyle );
/****************************************************************************/
/* static variables */
/****************************************************************************/
static HINSTANCE WdeApplicationInstance;
static FARPROC WdeTViewDispatch;
static WdeDialogBoxControl *WdeDefaultTView = NULL;
static int WdeTViewWndExtra;
static WNDPROC WdeOriginalTViewProc;
//static WNDPROC WdeTViewProc;
#define WWC_TREEVIEW WC_TREEVIEW
static DISPATCH_ITEM WdeTViewActions[] = {
{ DESTROY , (BOOL (*)(OBJPTR, void *, void *))WdeTViewDestroy }
, { COPY , (BOOL (*)(OBJPTR, void *, void *))WdeTViewCopyObject }
, { VALIDATE_ACTION , (BOOL (*)(OBJPTR, void *, void *))WdeTViewValidateAction }
, { IDENTIFY , (BOOL (*)(OBJPTR, void *, void *))WdeTViewIdentify }
, { GET_WINDOW_CLASS , (BOOL (*)(OBJPTR, void *, void *))WdeTViewGetWindowClass }
, { DEFINE , (BOOL (*)(OBJPTR, void *, void *))WdeTViewDefine }
, { GET_WND_PROC , (BOOL (*)(OBJPTR, void *, void *))WdeTViewGetWndProc }
};
#define MAX_ACTIONS (sizeof(WdeTViewActions)/sizeof (DISPATCH_ITEM))
OBJPTR WINEXPORT WdeTViewCreate( OBJPTR parent, RECT *obj_rect, OBJPTR handle)
{
if( handle == NULL ) {
return( WdeMakeTView( parent, obj_rect, handle,
0, "", TVIEW_OBJ ) );
} else {
return( WdeTVCreate( parent, obj_rect, NULL, TVIEW_OBJ,
(WdeDialogBoxControl *) handle) );
}
}
OBJPTR WdeMakeTView( 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( WdeDefaultTView, style );
SETCTL_TEXT( WdeDefaultTView, ResStrToNameOrOrd( text ) );
SETCTL_ID( WdeDefaultTView, WdeGetNextControlID() );
WdeChangeSizeToDefIfSmallRect ( parent, id, obj_rect );
new = WdeTVCreate ( parent, obj_rect, handle, id, WdeDefaultTView );
WdeMemFree( GETCTL_TEXT(WdeDefaultTView) );
SETCTL_TEXT( WdeDefaultTView, NULL );
return ( new );
}
OBJPTR WdeTVCreate( OBJPTR parent, RECT *obj_rect, OBJPTR handle,
OBJ_ID id, WdeDialogBoxControl *info)
{
WdeTViewObject *new;
WdeDebugCreate("TView", parent, obj_rect, handle);
if ( parent == NULL ) {
WdeWriteTrail("WdeTViewCreate: TView has no parent!");
return ( NULL );
}
new = (WdeTViewObject *) WdeMemAlloc ( sizeof(WdeTViewObject) );
if ( new == NULL ) {
WdeWriteTrail("WdeTViewCreate: Object malloc failed");
return ( NULL );
}
new->dispatcher = WdeTViewDispatch;
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("WdeTViewCreate: CONTROL_OBJ not created!");
WdeMemFree ( new );
return ( NULL );
}
if (!Forward ( (OBJPTR)new->object_handle, SET_OBJECT_INFO, info, NULL) ) {
WdeWriteTrail("WdeTViewCreate: SET_OBJECT_INFO failed!");
Destroy ( new->control, FALSE );
WdeMemFree ( new );
return ( NULL );
}
if (!Forward ( (OBJPTR)new->object_handle, CREATE_WINDOW,
NULL, NULL) ) {
WdeWriteTrail("WdeTViewCreate: CREATE_WINDOW failed!");
Destroy ( new->control, FALSE );
WdeMemFree ( new );
return ( NULL );
}
return ( new );
}
BOOL WINEXPORT WdeTViewDispatcher ( ACTION act, WdeTViewObject *obj,
void *p1, void *p2)
{
int i;
WdeDebugDispatch("TView", act, obj, p1, p2);
for ( i = 0; i < MAX_ACTIONS; i++ ) {
if( WdeTViewActions[i].id == act ) {
return( (WdeTViewActions[i].rtn)( obj, p1, p2 ) );
}
}
return (Forward ((OBJPTR)obj->control, act, p1, p2));
}
Bool WdeTViewInit( Bool first )
{
WNDCLASS wc;
WdeApplicationInstance = WdeGetAppInstance();
GetClassInfo( (HINSTANCE)NULL, WWC_TREEVIEW, &wc );
WdeOriginalTViewProc = wc.lpfnWndProc;
WdeTViewWndExtra = 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 = WdeTViewSuperClassProc;
if( !RegisterClass( &wc ) ) {
WdeWriteTrail("WdeTViewInit: RegisterClass failed.");
}
#endif
}
WdeDefaultTView = WdeAllocDialogBoxControl ();
if( !WdeDefaultTView ) {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -