📄 wdeinfo.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 <string.h>
#include <mbstring.h>
#include <stdlib.h>
#include "wdeglbl.h"
#include "wdemem.h"
#include "wdemsgbx.h"
#include "wdemsgs.gh"
#include "wderesin.h"
#include "wdegeted.h"
#include "wdeobjid.h"
#include "wde_wres.h"
#include "wdefutil.h"
#include "wderibbn.h"
#include "wdedebug.h"
#include "wdemain.h"
#include "wdectl3d.h"
#include "wde_rc.h"
#include "wdeinfo.h"
#include "wrutil.h"
#include "jdlg.h"
/****************************************************************************/
/* external function prototypes */
/****************************************************************************/
extern LRESULT WINEXPORT WdeInfoWndProc ( HWND, UINT, WPARAM, LPARAM );
/****************************************************************************/
/* external variables */
/****************************************************************************/
/****************************************************************************/
/* static function prototypes */
/****************************************************************************/
static void WdeEnableInfoWindowInput ( Bool );
static void WdeResetInfo ( void );
static void WdeChangeInfo ( void );
static void WdeDisplayDialogInfo ( WdeInfoStruct * );
static void WdeDisplayControlInfo ( WdeInfoStruct * );
static void WdeChangeDialogInfo ( WdeInfoStruct * );
static void WdeChangeControlInfo ( WdeInfoStruct * );
static void WdeInfoLookupComboEntry ( HWND, WORD );
static void WdeWriteSymInfo ( WdeInfoStruct *, Bool, char * );
static void WdeAddUniqueStringToCombo( HWND hdlg, int id, char *str );
/****************************************************************************/
/* static variables */
/****************************************************************************/
static HWND WdeInfoWindow = NULL;
static HBRUSH WdeInfoBrush = NULL;
static COLORREF WdeInfoColor = 0;
static int WdeInfoWindowDepth = 0;
static DLGPROC WdeInfoWinProc = NULL;
static WdeInfoStruct WdeCurrentInfo;
static char *WdeCaptionText = NULL;
static char *WdeDlgNameText = NULL;
static char *WdeTextText = NULL;
static char *WdeIDText = NULL;
static void WdeFiniInfoText( void )
{
if( WdeCaptionText != NULL ) {
WdeFreeRCString( WdeCaptionText );
}
if( WdeDlgNameText != NULL ) {
WdeFreeRCString( WdeDlgNameText );
}
if( WdeTextText != NULL ) {
WdeFreeRCString( WdeTextText );
}
if( WdeIDText != NULL ) {
WdeFreeRCString( WdeIDText );
}
}
static Bool WdeInitInfoText( void )
{
WdeCaptionText = WdeAllocRCString( WDE_INFOCAPTIONTEXT );
WdeDlgNameText = WdeAllocRCString( WDE_INFODLGNAMETEXT );
WdeTextText = WdeAllocRCString( WDE_INFOTEXTTEXT );
WdeIDText = WdeAllocRCString( WDE_INFOIDTEXT );
return( ( WdeCaptionText != NULL ) && ( WdeDlgNameText != NULL ) &&
( WdeTextText != NULL ) && ( WdeIDText != NULL ) );
}
void WdeAddUniqueStringToCombo( HWND hdlg, int id, char *str )
{
HWND cbox;
LRESULT pos;
cbox = GetDlgItem( hdlg, id );
if( cbox == (HWND)NULL ) {
return;
}
pos = SendMessage( cbox, CB_FINDSTRINGEXACT, 0, (LPARAM) (LPCSTR) str );
if( pos == CB_ERR ) {
SendMessage( cbox, CB_ADDSTRING, 0, (LPARAM) (LPCSTR) str );
}
}
void WdeSetFocusToInfo( void )
{
if( WdeInfoWindowDepth && ( WdeInfoWindow != (HWND)NULL ) ) {
SetFocus( WdeInfoWindow );
}
}
BOOL WdeIsInfoMessage ( MSG *msg )
{
if ( WdeInfoWindowDepth && WdeInfoWindow ) {
return ( IsDialogMessage ( WdeInfoWindow, msg ) );
} else {
return ( FALSE );
}
}
HWND WdeGetInfoWindowHandle ( void )
{
return ( WdeInfoWindow );
}
int WdeGetInfoWindowDepth ( void )
{
RECT rect;
if ( WdeInfoWindow && IsWindowVisible ( WdeInfoWindow) &&
!WdeInfoWindowDepth ) {
GetWindowRect( WdeInfoWindow, &rect );
WdeInfoWindowDepth = rect.bottom - rect.top;
}
return ( WdeInfoWindowDepth );
}
Bool WdeCreateInfoWindow ( HWND main_window, HINSTANCE inst )
{
if( !WdeInitInfoText() ) {
return( FALSE );
}
WdeInfoWinProc =
(DLGPROC) MakeProcInstance ( (FARPROC) WdeInfoWndProc, inst );
WdeInfoColor = GetSysColor( COLOR_BTNFACE );
WdeInfoBrush = CreateSolidBrush( WdeInfoColor );
WdeInfoWindow = JCreateDialog( inst, "WdeInfo",
main_window, WdeInfoWinProc );
/* if the window could not be created return FALSE */
if ( WdeInfoWindow == NULL ) {
WdeWriteTrail("WdeCreateInfoWindow: Could not create info window!");
return ( FALSE );
}
WdeInfoWindowDepth = 0;
WdeResizeWindows ();
return ( TRUE );
}
void WdeInfoFini ( void )
{
WdeFiniInfoText();
if ( WdeInfoWinProc ) {
FreeProcInstance ( (FARPROC) WdeInfoWinProc );
}
if ( WdeInfoBrush ) {
DeleteObject ( WdeInfoBrush );
}
}
void WdeDestroyInfoWindow ( void )
{
if ( WdeInfoWindow != NULL ) {
DestroyWindow ( WdeInfoWindow );
WdeInfoWindow = NULL;
WdeInfoWindowDepth = 0;
}
WdeResizeWindows ();
}
void WdeShowInfoWindow ( Bool show )
{
if ( WdeInfoWindowDepth ) {
if ( show ) {
ShowWindow ( WdeInfoWindow, SW_SHOW );
WdeInfoWindowDepth = WdeGetInfoWindowDepth ();
} else {
ShowWindow ( WdeInfoWindow, SW_HIDE );
WdeInfoWindowDepth = 0;
}
} else {
if ( show ) {
ShowWindow ( WdeInfoWindow, SW_SHOW );
}
}
WdeResizeWindows ();
}
void WdeEnableInfoWindowInput ( Bool enable )
{
HWND win;
static Bool last = TRUE;
if ( WdeInfoWindowDepth && ( last != enable ) ) {
win = GetDlgItem ( WdeInfoWindow, IDB_INFO_CAPTION );
EnableWindow ( win, enable );
win = GetDlgItem ( WdeInfoWindow, IDB_INFO_IDSTR );
EnableWindow ( win, enable );
win = GetDlgItem ( WdeInfoWindow, IDB_INFO_IDNUM );
EnableWindow ( win, enable );
win = GetDlgItem ( WdeInfoWindow, IDB_INFO_SET );
EnableWindow ( win, enable );
win = GetDlgItem ( WdeInfoWindow, IDB_INFO_RESET );;
EnableWindow ( win, enable );
last = enable;
}
}
void WdeResizeInfoWindow ( RECT *rect )
{
if ( WdeInfoWindowDepth && ( WdeInfoWindow != NULL ) ) {
MoveWindow ( WdeInfoWindow, 0, WdeGetRibbonHeight(),
( rect->right - rect->left ),
WdeInfoWindowDepth, TRUE );
RedrawWindow ( WdeInfoWindow, NULL, (HRGN) NULL,
RDW_INTERNALPAINT | RDW_INVALIDATE |
RDW_NOERASE | RDW_UPDATENOW );
}
}
void WdeWriteSymInfo ( WdeInfoStruct *is, Bool same_as_last, char *s )
{
Bool dirty;
OBJPTR obj;
if( is->res_info->hash_table ) {
dirty = WdeIsHashTableTouched( is->res_info->hash_table );
if( dirty && ( obj = GetMainObject() ) ) {
Forward( obj, RESOLVE_SYMBOL, NULL, NULL );
Forward( obj, RESOLVE_HELPSYMBOL, NULL, NULL ); /* JPK */
}
if( !same_as_last || dirty ) {
WdeAddSymbolsToComboBox( is->res_info->hash_table,
WdeInfoWindow, IDB_INFO_IDSTR );
WdeUntouchHashTable( is->res_info->hash_table );
}
} else {
if( !same_as_last ) {
SendDlgItemMessage( WdeInfoWindow, IDB_INFO_IDSTR,
CB_RESETCONTENT, 0, 0 );
}
}
if( s ) {
WdeSetComboWithStr( s, WdeInfoWindow, IDB_INFO_IDSTR );
}
}
void WdeWriteInfo ( WdeInfoStruct *is )
{
static WdeHashTable *last_table = NULL;
static WdeResInfo *last_res = NULL;
static OBJ_ID last_obj = 0;
char *cap_text, *id;
Bool same_hash;
if ( !WdeInfoWindowDepth || !WdeInfoWindow ) {
return;
}
if ( !is || !is->obj || !is->res_info ) {
WdeWriteTrail ("WdeWriteDialogInfo: NULL parameter!");
return;
}
/* make sure the resource window is not robbed of focus */
if ( GetFocus() != is->res_info->res_win ) {
SetFocus( is->res_info->res_win );
}
WdeCurrentInfo = *is;
same_hash = ( ( last_res == is->res_info ) &&
( last_table == is->res_info->hash_table ) );
WdeWriteSymInfo( is, same_hash, NULL );
last_table = is->res_info->hash_table;
last_res = is->res_info;
if( is->obj_id == BASE_OBJ ) {
WdeSetEditWithStr( "", WdeInfoWindow, IDB_INFO_SIZE );
WdeEnableInfoWindowInput( FALSE );
WdeSetEditWithStr( "", WdeInfoWindow, IDB_INFO_CAPTION );
WdeSetEditWithStr( "", WdeInfoWindow, IDB_INFO_IDSTR );
WdeSetEditWithStr( "", WdeInfoWindow, IDB_INFO_IDNUM );
} else {
WdeWriteObjectDimensions( (int_16)is->size.x, (int_16)is->size.y,
(int_16)is->size.width,
(int_16)is->size.height );
WdeEnableInfoWindowInput( TRUE );
if( is->obj_id == DIALOG_OBJ ) {
WdeDisplayDialogInfo( is );
} else if( is->obj_id == CONTROL_OBJ ) {
WdeDisplayControlInfo( is );
}
}
if( last_obj != is->obj_id ) {
if( is->obj_id == DIALOG_OBJ ) {
cap_text = WdeCaptionText;
id = WdeDlgNameText;
} else if( is->obj_id == CONTROL_OBJ ) {
cap_text = WdeTextText;
id = WdeIDText;
} else if( is->obj_id == BASE_OBJ ) {
cap_text = "";
id = "";
}
WdeSetEditWithStr( cap_text, WdeInfoWindow, IDB_INFO_CAPTEXT );
WdeSetEditWithStr( id, WdeInfoWindow, IDB_INFO_NAMETEXT );
last_obj = is->obj_id;
}
}
void WdeResetInfo ( void )
{
if ( WdeCurrentInfo.obj_id == DIALOG_OBJ ) {
WdeDisplayDialogInfo ( &WdeCurrentInfo );
} else if ( WdeCurrentInfo.obj_id == CONTROL_OBJ ) {
WdeDisplayControlInfo ( &WdeCurrentInfo );
}
}
void WdeDisplayDialogInfo ( WdeInfoStruct *is )
{
char *str;
WResID *name;
str = WRConvertStringFrom( is->d.caption, "\t\n", "tn" );
if( str == NULL ) {
WdeSetEditWithStr ( "", WdeInfoWindow, IDB_INFO_CAPTION );
} else {
WdeSetEditWithStr ( str, WdeInfoWindow, IDB_INFO_CAPTION );
WdeMemFree( str );
}
name = is->d.name;
if( name->IsName ) {
char *str1, *str2;
int len;
Bool ok;
ok = FALSE;
str1 = WResIDToStr( name );
if( str1 ) {
len = strlen( str1 ) + 3;
str2 = WdeMemAlloc( len );
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -