📄 wdeopts.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 <string.h>
#include <stdlib.h>
#include "wdeglbl.h"
#include "wdemem.h"
#include "wdemsgbx.h"
#include "wdemsgs.gh"
#include "wderesin.h"
#include "wdegeted.h"
#include "wdedebug.h"
#include "wdesdup.h"
#include "wdefutil.h"
#include "wdegetfn.h"
#include "wdemain.h"
#include "wdestat.h"
#include "wdectl3d.h"
#include "wde_rc.h"
#include "wdeopts.h"
#include "jdlg.h"
#include "watini.h"
#include "inipath.h"
/****************************************************************************/
/* macro definitions */
/****************************************************************************/
#define MAIN_WIN_START_X 0
#define MAIN_WIN_START_Y 50
#define MAIN_WIN_SIZE_X 620
#define MAIN_WIN_SIZE_Y 300
/****************************************************************************/
/* type definitions */
/****************************************************************************/
typedef struct {
Bool is_wres_fmt;
Bool use_def_dlg;
int grid_x;
int grid_y;
Bool ignore_inc;
char *inc_path;
RECT screen_pos;
RECT control_toolbar_pos;
Bool is_screen_maximized;
Bool is_ctoolbar_visible;
Bool is_ribbon_visible;
char *last_directory;
char *last_file_filter;
Bool use_3d_effects;
} WdeOptState;
/****************************************************************************/
/* external function prototypes */
/****************************************************************************/
extern BOOL WINEXPORT WdeOptionsProc ( HWND, UINT, WPARAM, LPARAM );
/****************************************************************************/
/* static function prototypes */
/*****************************************************************************/
//static void WdeResetOpts ( void ); // prevent warning
void WdeResetOpts ( void );
/****************************************************************************/
/* external variables */
/****************************************************************************/
char WdeProfileName[_MAX_PATH] = WATCOM_INI;
char WdeSectionName[] = "wde";
/****************************************************************************/
/* static variables */
/****************************************************************************/
static WdeOptState WdeCurrentState;
static HWND WdeOptWin = NULL;
static WdeOptState WdeDefaultState =
{
FALSE /* initial resource format is MS */
, TRUE /* initial define dialog is default */
, 1, 1 /* initial grid size */
, TRUE /* ignore INCLUDE env variable */
, NULL /* extra include path */
, { MAIN_WIN_START_X, /* initial screen pos */
MAIN_WIN_START_Y,
MAIN_WIN_START_X +
MAIN_WIN_SIZE_X,
MAIN_WIN_START_Y +
MAIN_WIN_SIZE_Y
}
, { 0, 0, 0, 0 } /* initial controls toolbar pos */
, FALSE /* is the window maximized */
, TRUE /* is the controls toolbar visible */
, TRUE /* is the ribbon visible */
, NULL /* last open/save directory */
, NULL /* last file filter */
, TRUE /* use 3d effects */
};
static Bool WdeWriteIntOpt( char *entry, int i )
{
char str[12];
Bool ret;
ltoa( i, str, 10 );
ret = WritePrivateProfileString( WdeSectionName, entry, str,
WdeProfileName );
return( ret );
}
static Bool WdeGetIntOpt( char *entry, int *i )
{
int val;
val = (int) GetPrivateProfileInt ( WdeSectionName, entry,
0x7fff, WdeProfileName );
if ( val != 0x7fff ) {
*i = val;
return ( TRUE );
} else {
return ( FALSE );
}
}
static Bool WdeWriteRectOpt( char *entry, RECT *r )
{
char *str;
Bool ret;
ret = FALSE;
str = WdeRectToStr( r );
if( str ) {
ret = WritePrivateProfileString( WdeSectionName, entry, str,
WdeProfileName );
WdeMemFree( str );
}
return( ret );
}
static Bool WdeGetRectOpt( char *entry, RECT *r )
{
char str[41];
Bool ret;
ret = GetPrivateProfileString( WdeSectionName, entry, "0, 0, 0, 0",
str, 40, WdeProfileName );
if( ret && strcmp( "0, 0, 0, 0", str ) ) {
WdeStrToRect( str, r );
return( TRUE );
}
return( FALSE );
}
static Bool WdeGetStrOpt( char *entry, char **opt )
{
char str[_MAX_PATH];
Bool ret;
ret = GetPrivateProfileString( WdeSectionName, entry, "",
str, _MAX_PATH-1, WdeProfileName );
if( ret ) {
if( !WdeIsStrSpace ( str ) ) {
ret = ( ( *opt = WdeStrDup( str ) ) != NULL );
}
}
return( ret );
}
static Bool WdeReadOpts ( WdeOptState *s )
{
Bool ret;
ret = WdeGetIntOpt ( "WResFmt", &s->is_wres_fmt );
ret &= WdeGetIntOpt ( "UseDefDlg", &s->use_def_dlg );
ret &= WdeGetIntOpt ( "GridX", &s->grid_x );
ret &= WdeGetIntOpt ( "GridY", &s->grid_y );
ret &= WdeGetIntOpt ( "IgnoreIncPath", &s->ignore_inc );
ret &= WdeGetRectOpt( "ScreenPos", &s->screen_pos );
ret &= WdeGetRectOpt( "CTBarPos", &s->control_toolbar_pos );
ret &= WdeGetIntOpt ( "ScreenMaxed", &s->is_screen_maximized );
ret &= WdeGetIntOpt ( "CTBarVis", &s->is_ctoolbar_visible );
ret &= WdeGetIntOpt ( "RibbonVis", &s->is_ribbon_visible );
ret &= WdeGetIntOpt ( "Use3DEffects", &s->use_3d_effects );
ret &= WdeGetStrOpt ( "FileFilter", &s->last_file_filter );
ret &= WdeGetStrOpt ( "IncPath", &s->inc_path );
ret &= WdeGetStrOpt ( "LastDir", &s->last_directory );
return( ret );
}
static void WdeWriteOpts ( WdeOptState *o )
{
WdeWriteIntOpt( "WResFmt", o->is_wres_fmt );
WdeWriteIntOpt( "UseDefDlg", o->use_def_dlg );
WdeWriteIntOpt( "GridX", o->grid_x );
WdeWriteIntOpt( "GridY", o->grid_y );
WdeWriteIntOpt( "IgnoreIncPath", o->ignore_inc );
WdeWriteRectOpt( "ScreenPos", &o->screen_pos );
WdeWriteRectOpt( "CTBarPos", &o->control_toolbar_pos );
WdeWriteIntOpt( "ScreenMaxed", o->is_screen_maximized );
WdeWriteIntOpt( "CTBarVis", o->is_ctoolbar_visible );
WdeWriteIntOpt( "RibbonVis", o->is_ribbon_visible );
WdeWriteIntOpt( "Use3DEffects", o->use_3d_effects );
WritePrivateProfileString( WdeSectionName, "FileFilter",
o->last_file_filter, WdeProfileName );
WritePrivateProfileString( WdeSectionName, "IncPath",
o->inc_path, WdeProfileName );
WritePrivateProfileString( WdeSectionName, "LastDir",
o->last_directory, WdeProfileName );
}
void WdeOptsShutdown ( void )
{
if( WdeCurrentState.last_directory ) {
WdeMemFree( WdeCurrentState.last_directory );
}
if ( WdeCurrentState.last_file_filter ) {
WdeMemFree( WdeCurrentState.last_file_filter );
}
WdeCurrentState.last_directory = WdeStrDup( WdeGetInitialDir () );
WdeCurrentState.last_file_filter = WdeGetFileFilter();
WdeWriteOpts( &WdeCurrentState );
if( WdeCurrentState.last_directory ) {
WdeMemFree( WdeCurrentState.last_directory );
}
if( WdeCurrentState.inc_path ) {
WdeMemFree( WdeCurrentState.inc_path );
}
}
void WdeInitOpts ( void )
{
WdeCurrentState = WdeDefaultState;
GetConfigFilePath( WdeProfileName, sizeof(WdeProfileName) );
strcat( WdeProfileName, "\\" WATCOM_INI );
WdeReadOpts( &WdeCurrentState );
if ( WdeCurrentState.last_directory ) {
WdeSetInitialDir ( WdeCurrentState.last_directory );
}
WdeSetFileFilter ( WdeCurrentState.last_file_filter );
}
void WdeResetOpts ( void )
{
if ( WdeCurrentState.inc_path != NULL ) {
WdeMemFree ( WdeCurrentState.inc_path );
}
WdeCurrentState.is_wres_fmt = WdeDefaultState.is_wres_fmt;
WdeCurrentState.use_def_dlg = WdeDefaultState.use_def_dlg;
WdeCurrentState.grid_x = WdeDefaultState.grid_x;
WdeCurrentState.grid_y = WdeDefaultState.grid_y;
WdeCurrentState.ignore_inc = WdeDefaultState.ignore_inc;
WdeCurrentState.inc_path = WdeStrDup ( WdeDefaultState.inc_path );
}
int WdeGetOption ( WdeOptReq req )
{
int ret;
switch ( req ) {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -