guimain.c
来自「开放源码的编译器open watcom 1.6.0版的源代码」· C语言 代码 · 共 586 行 · 第 1/2 页
C
586 行
/****************************************************************************
*
* 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 MODULE DOES, PLEASE
* DESCRIBE IT HERE!
*
****************************************************************************/
#include "auipvt.h"//
#include <ctype.h>
gui_coord WndMax;
gui_coord WndScreen;
gui_coord WndScale;
a_window *WndMain;
wnd_switches WndSwitches;
int WndMaxDirtyRects = 6;
int WndDClick = 300;
bool WndIgnoreAllEvents = FALSE;
static int wndProcNesting = 0;
static gui_colour_set Colours = { GUI_BLACK, GUI_BLACK };
static gui_mouse_cursor wndCursorType;
static char * BusyString;
int WndGetDClick( void )
{
return( WndDClick );
}
void WndSetDClick( int new )
{
WndDClick = new;
GUISetDClickRate( new );
}
static void Rescale( void )
{
gui_coord scale;
gui_rect rect;
scale.x = WND_APPROX_SIZE;
scale.y = WND_APPROX_SIZE;
WndScreen = scale;
GUIGetRoundScale( &scale );
WndScale = scale;
rect.x = 0;
rect.y = 0;
rect.width = scale.x;
rect.height = scale.y;
GUISetScale( &rect );
WndMax = scale;
}
static bool WndInitBody( char *str, int resource_menu )
{
wnd_create_struct info;
if( !GUIWndInit( WndDClick, WndStyle ) ) return( FALSE );
GUIMDIInitMenuOnly();
GUI3DDialogInit();
GUISetBackgroundColour( &Colours );
GUISetBetweenTitles( 2 );
Rescale();
WndSysInit();
WndInitWndMain( &info );
info.text = str;
info.info = &NoInfo;
info.class = WND_NO_CLASS;
info.extra = NULL;
WndSetWndMainSize( &info );
WndMain = WndCreateWithStructAndMenuRes( &info, resource_menu );
Rescale();
if( WndBackgroundChar == 0 ) {
WndBackgroundChar = GUIGetCharacter( GUI_SCROLL_SLIDER );
}
GUISetBackgroundChar( WndMain->gui, WndBackgroundChar );
WndSetWndMax();
return( TRUE );
}
bool WndInit( char *str )
{
return( WndInitBody( str, 0 ) );
}
bool WndInitWithMenuRes( char *str, int resource_menu )
{
return( WndInitBody( str, resource_menu ) );
}
void WndShowWndMain( void )
{
WndShowWindow( WndMain );
}
bool WndFini( void )
{
if( !WndShutDownHook() ) return( FALSE );
GUIDestroyWnd( NULL );
if( BusyString != NULL ) {
WndFree( BusyString );
BusyString = NULL;
}
return( TRUE );
}
void WndInitNumRows( a_window *wnd )
{
wnd->rows = GUIGetNumRows( wnd->gui );
}
static void WndMoveResize( a_window *wnd )
{
gui_text_metrics text;
gui_rect rect;
wnd_coord save_curr;
if( WndMain != NULL && WndIsMinimized( WndMain ) ) return;
GUIGetTextMetrics( wnd->gui, &text );
GUIGetClientRect( wnd->gui, &rect );
wnd->width = rect.width;
wnd->max_char.x = text.max.x;
wnd->max_char.y = text.max.y;
wnd->avg_char_x = text.avg.x;
wnd->mid_char_x = ( text.max.x + text.avg.x ) / 2;
WndInitNumRows( wnd );
if( wnd->max_indent != 0 ) {
if( wnd->width >= wnd->max_indent ) {
WndSetHScroll( wnd, 0 );
}
GUISetHScrollRange( wnd->gui, wnd->max_indent );
}
if( WndHasCurrent( wnd ) ) {
if( wnd->current.row >= wnd->rows ) {
save_curr = wnd->current;
WndDirtyCurr( wnd );
WndScroll( wnd, wnd->current.row - wnd->rows + 1 );
wnd->current = save_curr;
wnd->current.row = wnd->rows - 1;
}
WndDirtyCurr( wnd );
}
WndKillCacheLines( wnd );
if( wnd == WndMain ) {
WndSetWndMax();
}
WndResizeHook( wnd );
}
static void WndKeyEnter( a_window *wnd )
{
if( WndHasCurrent( wnd ) ) {
if( !WndPieceIsTab( wnd, wnd->current.row, wnd->current.piece ) &&
_Is( wnd, WSW_ONLY_MODIFY_TABSTOP ) ) {
return;
}
WndModify( wnd, wnd->current.row, wnd->current.piece );
} else {
if( _Is( wnd, WSW_ONLY_MODIFY_TABSTOP ) ) {
return;
}
WndModify( wnd, WND_NO_ROW, WND_NO_PIECE );
}
}
typedef struct {
gui_window *gui;
gui_event event;
void *parm;
bool ret;
} spawn_parms;
WNDCLICKHOOK *WndClickHook;
void WndInstallClickHook( WNDCLICKHOOK *rtn )
{
WndClickHook = rtn;
}
static void DoMainEventProc( spawn_parms *spawnp )
{
a_window *wnd;
bool ret;
gui_key key;
gui_keystate state;
unsigned id;
int scroll;
void *cursor;
gui_window *gui = spawnp->gui;
gui_event event = spawnp->event;
void *parm = spawnp->parm;
wnd = GUIGetExtra( gui );
spawnp->ret = FALSE;
if( wnd == NULL ) return;
if( WndIgnoreAllEvents ) {
if( event == GUI_PAINT ) {
WndRepaint( wnd );
}
if( event == GUI_MOUSEMOVE && GUIIsGUI() ) {
GUISetMouseCursor( GUI_HOURGLASS_CURSOR );
}
return;
}
if( event == GUI_MOUSEMOVE ) {
GUISetMouseCursor( wndCursorType );
if( WndIgnoreMouseMove( wnd ) ) return;
}
if( !WndDoingRefresh && wndProcNesting == 1 ) WndDoInput();
ret = TRUE;
WndChooseEvent( wnd, event, parm );
WndSelectEvent( wnd, event, parm );
switch( event ) {
case GUI_STATUS_CLEARED:
return;
case GUI_ACTIVATEAPP:
return;
case GUI_INITMENUPOPUP:
GUI_GETID( parm, id );
WndSetPopup( id );
break;
case GUI_INIT_WINDOW:
WndSetPopUpMenu( wnd, wnd->info->popupmenu, wnd->info->num_popups );
wnd->gui = gui;
cursor = WndHourGlass( NULL );
WndMoveResize( wnd );
ret = WndEvent( wnd, event, parm );
WndSetThumb( wnd );
WndHourGlass( cursor );
break;
case GUI_SCROLL_VERTICAL:
GUI_GET_SCROLL( parm, scroll );
WndScroll( wnd, scroll );
break;
case GUI_SCROLL_UP:
WndScrollUp( wnd );
break;
case GUI_SCROLL_DOWN:
WndScrollDown( wnd );
break;
case GUI_SCROLL_PAGE_UP:
if( WndEvent( wnd, GUI_SCROLL_PAGE_UP, parm ) ) break;
WndPageUp( wnd );
break;
case GUI_SCROLL_PAGE_DOWN:
if( WndEvent( wnd, GUI_SCROLL_PAGE_DOWN, parm ) ) break;
WndPageDown( wnd );
break;
case GUI_NOW_ACTIVE:
if( wnd == WndMain ) {
WndNextNonIconToFront( WndNext( NULL ) );
} else {
_Set( wnd, WSW_ACTIVE );
WndAddPopupMenu( wnd );
WndEvent( wnd, event, parm );
}
ret = FALSE;
break;
case GUI_NOT_ACTIVE:
_Clr( wnd, WSW_ACTIVE );
if( wnd != WndMain ) {
WndEvent( wnd, event, parm );
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?