📄 semdiag.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!
*
****************************************************************************/
/*
The data structure for DIALOGEX's is as follows:
struct DialogSettings {
WORD wVersion; // Always 00 01
WORD wAlwaysFF; // Always FF FF
DWORD HelpId;
DWORD ExStyle;
DWORD Style;
WORD NumberOfItems;
WORD x;
WORD y;
WORD cx;
WORD cy;
[Name/Ord] MenuName;
[Name/Ord] ClassName;
WCHAR szCaption[]
WORD fontHeight;
WORD fontWeight;
WORD italic;
WCHAR szFontName[];
}
struct ControlData {
DWORD HelpId;
DWORD ExStyle;
DWORD Style;
WORD x;
WORD y;
WORD cx;
WORD cy;
DWORD id;
[Name/Ord] classId;
[Name/Ord] text;
WORD numBytes; // Number of bytes of data elements that follow.
}
*/
#include <stddef.h>
#include <string.h>
#include "wresall.h"
#include "rcmem.h"
#include "global.h"
#include "errors.h"
#include "ytab.gh"
#include "semantic.h"
#include "semdiag.h"
static FullDialogBoxHeader * NewDialogBoxHeader( void )
/******************************************************/
{
FullDialogBoxHeader * newheader;
newheader = RcMemMalloc( sizeof(FullDialogBoxHeader) );
if( CmdLineParms.TargetOS == RC_TARGET_OS_WIN16 ) {
newheader->Win32 = FALSE;
newheader->u.Head.Style = 0L;
newheader->u.Head.NumOfItems = 0;
newheader->u.Head.Size.x = 0;
newheader->u.Head.Size.y = 0;
newheader->u.Head.Size.width = 0;
newheader->u.Head.Size.height = 0;
newheader->u.Head.MenuName = NULL;
newheader->u.Head.ClassName = NULL;
newheader->u.Head.Caption = NULL;
newheader->u.Head.PointSize = 0;
newheader->u.Head.FontName = NULL;
} else {
newheader->Win32 = TRUE;
newheader->u.Head32.Head.Style = 0L;
newheader->u.Head32.Head.ExtendedStyle = 0L;
newheader->u.Head32.Head.NumOfItems = 0;
newheader->u.Head32.Head.Size.x = 0;
newheader->u.Head32.Head.Size.y = 0;
newheader->u.Head32.Head.Size.width = 0;
newheader->u.Head32.Head.Size.height = 0;
newheader->u.Head32.Head.MenuName = NULL;
newheader->u.Head32.Head.ClassName = NULL;
newheader->u.Head32.Head.Caption = NULL;
newheader->u.Head32.Head.PointSize = 0;
newheader->u.Head32.Head.FontName = NULL;
newheader->u.Head32.ExHead.FontWeight = 0;
newheader->u.Head32.ExHead.FontItalic = 0;
newheader->u.Head32.ExHead.FontExtra = 1;
newheader->u.Head32.ExHead.HelpId = 0L;
newheader->u.Head32.ExHead.FontWeightDefined = FALSE;
newheader->u.Head32.ExHead.FontItalicDefined = FALSE;
}
newheader->StyleGiven = FALSE;
return( newheader );
} /* NewDialogBoxHeader */
extern FullDialogBoxHeader * SemNewDiagOptions( FullDialogOptions * opt )
/***********************************************************************/
{
FullDialogBoxHeader * newheader;
newheader = NewDialogBoxHeader();
return( SemDiagOptions( newheader, opt ) );
} /* SemNewDiagOptions */
static void AddDiagOption( DialogBoxHeader * head, FullDialogOptions * opt )
/***************************************************************************/
{
switch (opt->token) {
case Y_STYLE:
head->Style |= opt->Opt.Style;
break;
case Y_MENU:
if (head->MenuName != NULL) {
RcMemFree( head->MenuName );
}
head->MenuName = opt->Opt.Name;
break;
case Y_CLASS:
if (head->ClassName != NULL) {
RcMemFree( head->ClassName );
}
head->ClassName = opt->Opt.Name;
break;
case Y_FONT:
head->Style |= DS_SETFONT;
head->PointSize = opt->Opt.Font.PointSize;
if (head->FontName != NULL) {
RcMemFree( head->FontName );
}
head->FontName = opt->Opt.Font.FontName;
break;
case Y_CAPTION:
head->Style |= WS_CAPTION;
if (head->Caption != NULL) {
RcMemFree( head->Caption );
}
head->Caption = opt->Opt.Str;
break;
case Y_EXSTYLE:
RcWarning( ERR_NT_KEYWORD, SemTokenToString( opt->token ) );
break;
}
} /* AddDiagOptions */
static void AddDiagOption32( DlgHeader32 * head,
FullDialogOptions * opt )
/*****************************************************/
{
switch (opt->token) {
case Y_STYLE:
head->Head.Style |= opt->Opt.Style;
break;
case Y_EXSTYLE:
head->Head.ExtendedStyle |= opt->Opt.Exstyle;
break;
case Y_MENU:
if (head->Head.MenuName != NULL) {
RcMemFree( head->Head.MenuName );
}
head->Head.MenuName = opt->Opt.Name;
break;
case Y_CLASS:
if (head->Head.ClassName != NULL) {
RcMemFree( head->Head.ClassName );
}
head->Head.ClassName = opt->Opt.Name;
break;
case Y_FONT:
head->Head.Style |= DS_SETFONT;
head->Head.PointSize = opt->Opt.Font.PointSize;
if (head->Head.FontName != NULL) {
RcMemFree( head->Head.FontName );
}
head->Head.FontName = opt->Opt.Font.FontName;
head->ExHead.FontItalic = opt->Opt.Font.FontItalic;
head->ExHead.FontWeight = opt->Opt.Font.FontWeight;
head->ExHead.FontExtra = opt->Opt.Font.FontExtra;
head->ExHead.FontItalicDefined = opt->Opt.Font.FontItalicDefined;
head->ExHead.FontWeightDefined = opt->Opt.Font.FontWeightDefined;
break;
case Y_CAPTION:
head->Head.Style |= WS_CAPTION;
if (head->Head.Caption != NULL) {
RcMemFree( head->Head.Caption );
}
head->Head.Caption = opt->Opt.Str;
break;
case Y_LANGUAGE:
SemSetResourceLanguage( &opt->Opt.lang, TRUE );
break;
}
} /* AddDiagOptions32 */
extern FullDialogBoxHeader * SemDiagOptions( FullDialogBoxHeader * head,
FullDialogOptions * opt )
/**********************************************************************/
{
if( head->Win32 ) {
AddDiagOption32( &head->u.Head32, opt );
} else {
AddDiagOption( &head->u.Head, opt );
}
if( opt->token == Y_STYLE ) {
head->StyleGiven = TRUE;
}
return( head );
}
extern FullDiagCtrlList * SemEmptyDiagCtrlList( void ) {
/*******************************************************/
FullDiagCtrlList * newlist;
newlist = RcMemMalloc( sizeof(FullDiagCtrlList) );
newlist->head = NULL;
newlist->tail = NULL;
newlist->numctrls = 0;
return( newlist );
}
extern FullDiagCtrlList * SemNewDiagCtrlList( FullDialogBoxControl * ctrl,
DataElemList * list )
/*************************************************************************/
{
FullDiagCtrlList * newlist;
newlist = SemEmptyDiagCtrlList();
return( SemAddDiagCtrlList( newlist, ctrl, list ) );
} /* SemNewDiagCtrlList */
extern FullDiagCtrlList * SemAddDiagCtrlList( FullDiagCtrlList * list,
FullDialogBoxControl * ctrl, DataElemList * dataList )
/********************************************************************/
{
if( ctrl != NULL ) {
ctrl->dataListHead = dataList;
ResAddLLItemAtEnd( (void **) &(list->head), (void **) &(list->tail), ctrl );
list->numctrls++;
}
return( list );
} /* SemAddDiagCtrlList */
extern FullDialogBoxControl * SemInitDiagCtrl( void )
/***************************************************/
{
FullDialogBoxControl * newctrl;
newctrl = RcMemMalloc( sizeof(FullDialogBoxControl) );
newctrl->next = NULL;
newctrl->prev = NULL;
newctrl->Win32 = (CmdLineParms.TargetOS == RC_TARGET_OS_WIN32);
return( newctrl );
} /* SemInitDiagCtrl */
/* These are the default styles used for all dialog box control statmens */
/* except the control statement (see rc.y for it). The HI style contains */
/* all the WS_ styles that are applicable (the high word) and the LO style */
/* contains the styles that are particular to the class of the control */
#define DEF_LTEXT_HI (WS_CHILD|WS_VISIBLE|WS_GROUP)
#define DEF_LTEXT_LO (SS_LEFT)
#define DEF_RTEXT_HI (WS_CHILD|WS_VISIBLE|WS_GROUP)
#define DEF_RTEXT_LO (SS_RIGHT)
#define DEF_CTEXT_HI (WS_CHILD|WS_VISIBLE|WS_GROUP)
#define DEF_CTEXT_LO (SS_CENTER)
#define DEF_AUTO3STATE_HI (WS_CHILD|WS_VISIBLE|WS_TABSTOP)
#define DEF_AUTO3STATE_LO (BS_AUTO3STATE)
#define DEF_AUTOCHECKBOX_HI (WS_CHILD|WS_VISIBLE|WS_TABSTOP)
#define DEF_AUTOCHECKBOX_LO (BS_AUTOCHECKBOX)
#define DEF_AUTORADIOBUTTON_HI (WS_CHILD|WS_VISIBLE|WS_TABSTOP)
#define DEF_AUTORADIOBUTTON_LO (BS_AUTORADIOBUTTON)
#define DEF_CHECKBOX_HI (WS_CHILD|WS_VISIBLE|WS_TABSTOP)
#define DEF_CHECKBOX_LO (BS_CHECKBOX)
#define DEF_PUSHBUTTON_HI (WS_CHILD|WS_VISIBLE|WS_TABSTOP)
#define DEF_PUSHBUTTON_LO (BS_PUSHBUTTON)
//#define DEF_PUSHBOX_HI (WS_CHILD|WS_VISIBLE|WS_TABSTOP)
//#define DEF_PUSHBOX_LO (BS_PUSHBOX)
#define DEF_LISTBOX_HI (WS_CHILD|WS_VISIBLE|WS_BORDER)
#define DEF_LISTBOX_LO (LBS_NOTIFY)
#define DEF_GROUPBOX_HI (WS_CHILD|WS_VISIBLE)
#define DEF_GROUPBOX_LO (BS_GROUPBOX)
#define DEF_DEFPUSHBUTTON_HI (WS_CHILD|WS_VISIBLE|WS_TABSTOP)
#define DEF_DEFPUSHBUTTON_LO (BS_DEFPUSHBUTTON)
#define DEF_RADIOBUTTON_HI (WS_CHILD|WS_VISIBLE)
#define DEF_RADIOBUTTON_LO (BS_RADIOBUTTON)
#define DEF_EDITTEXT_HI (WS_CHILD|WS_VISIBLE|WS_TABSTOP|WS_BORDER)
#define DEF_EDITTEXT_LO (ES_LEFT)
#define DEF_COMBOBOX_HI (WS_CHILD|WS_VISIBLE|WS_TABSTOP)
#define DEF_COMBOBOX_LO (CBS_SIMPLE)
#define DEF_ICON_HI (WS_CHILD|WS_VISIBLE)
#define DEF_ICON_LO (SS_ICON)
#define DEF_SCROLLBAR_HI (WS_CHILD|WS_VISIBLE)
#define DEF_SCROLLBAR_LO (SBS_HORZ)
#define DEF_STATE3_HI (WS_CHILD|WS_VISIBLE|WS_TABSTOP)
#define DEF_STATE3_LO (BS_3STATE)
#define LO_WORD 0x0000ffff
#define HI_WORD 0xffff0000
extern FullDialogBoxControl * SemNewDiagCtrl( uint_8 token,
FullDiagCtrlOptions opts )
/*********************************************************/
{
FullDialogBoxControl * newctrl;
uint_32 style_mask; /* for the style of the control */
uint_32 style_value;
uint_32 defstyle_hi = 0;
uint_32 defstyle_lo = 0;
uint_32 style_hi;
uint_32 style_lo;
uint_16 class = 0;
uint_16 tmp_mask;
ControlClass * cont_class;
switch (token) {
case Y_LTEXT:
class = CLASS_STATIC;
defstyle_hi = DEF_LTEXT_HI;
defstyle_lo = DEF_LTEXT_LO;
break;
case Y_RTEXT:
class = CLASS_STATIC;
defstyle_hi = DEF_RTEXT_HI;
defstyle_lo = DEF_RTEXT_LO;
break;
case Y_CTEXT:
class = CLASS_STATIC;
defstyle_hi = DEF_CTEXT_HI;
defstyle_lo = DEF_CTEXT_LO;
break;
case Y_CHECKBOX:
class = CLASS_BUTTON;
defstyle_hi = DEF_CHECKBOX_HI;
defstyle_lo = DEF_CHECKBOX_LO;
break;
case Y_PUSHBUTTON:
class = CLASS_BUTTON;
defstyle_hi = DEF_PUSHBUTTON_HI;
defstyle_lo = DEF_PUSHBUTTON_LO;
break;
case Y_LISTBOX:
class = CLASS_LISTBOX;
defstyle_hi = DEF_LISTBOX_HI;
defstyle_lo = DEF_LISTBOX_LO;
break;
case Y_GROUPBOX:
class = CLASS_BUTTON;
defstyle_hi = DEF_GROUPBOX_HI;
defstyle_lo = DEF_GROUPBOX_LO;
break;
case Y_DEFPUSHBUTTON:
class = CLASS_BUTTON;
defstyle_hi = DEF_DEFPUSHBUTTON_HI;
defstyle_lo = DEF_DEFPUSHBUTTON_LO;
break;
case Y_RADIOBUTTON:
class = CLASS_BUTTON;
defstyle_hi = DEF_RADIOBUTTON_HI;
defstyle_lo = DEF_RADIOBUTTON_LO;
break;
case Y_EDITTEXT:
class = CLASS_EDIT;
defstyle_hi = DEF_EDITTEXT_HI;
defstyle_lo = DEF_EDITTEXT_LO;
break;
case Y_COMBOBOX:
class = CLASS_COMBOBOX;
defstyle_hi = DEF_COMBOBOX_HI;
defstyle_lo = DEF_COMBOBOX_LO;
break;
case Y_ICON:
class = CLASS_STATIC;
defstyle_hi = DEF_ICON_HI;
defstyle_lo = DEF_ICON_LO;
break;
case Y_SCROLLBAR:
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -