dbgpaint.c
来自「开放源码的编译器open watcom 1.6.0版的源代码」· C语言 代码 · 共 551 行 · 第 1/2 页
C
551 行
}
Error( ERR_LOC, LIT( ERR_BAD_WINDOW_ATTR ) );
return( 0 );
}
static gui_colour ScanColour( void )
{
colour_bits bits;
int i;
bits = 0;
for( ;; ) {
i = ScanCmd( ColourNameTab );
if( i == 0 ) break;
bits |= ColourBits[ i-1 ];
if( bits != CLR_NONE && bits != CLR_BRIGHT ) break;
}
for( i = 0; i < ArraySize( ColourMap ); ++i ) {
if( ColourMap[i].bits == bits ) {
return( ColourMap[i].colour );
}
}
Error( ERR_LOC, LIT( ERR_BAD_COLOUR_ATTR ) );
return( 0 );
}
void ProcPaint( void )
{
wnd_class class;
wnd_attr attr;
gui_colour fore;
gui_colour back;
gui_colour_set *set;
bool dialog;
int dlg_attr;
class = WND_NO_CLASS;
if( ScanStatus() ) {
dialog = FALSE;
} else if( ScanCmd( "DIalog\0" ) ) {
dlg_attr = ScanAttr( DlgAttrMap, ArraySize( DlgAttrMap ) );
dialog = TRUE;
} else {
class = ReqWndName();
attr = ScanAttr( AttrMap, ArraySize( AttrMap ) );
}
fore = ScanColour();
ScanCmd( "On\0" );
back = ScanColour();
ReqEOC();
if( class == WND_NO_CLASS ) {
if( dialog ) {
GUIGetDialogColours( WndDlgColours );
WndDlgColours[ dlg_attr ].fore = fore;
WndDlgColours[ dlg_attr ].back = back;
if( dlg_attr == GUI_DLG_NORMAL ) {
WndDlgColours[ GUI_DLG_SCROLL_ICON ].fore = fore;
WndDlgColours[ GUI_DLG_SCROLL_ICON ].back = back;
WndDlgColours[ GUI_DLG_SCROLL_BAR ].fore = fore;
WndDlgColours[ GUI_DLG_SCROLL_BAR ].back = back;
}
GUISetDialogColours( WndDlgColours );
} else {
WndStatusColour.fore = fore;
WndStatusColour.back = back;
if( WndHaveStatusWindow() ) {
WndCloseStatusWindow();
WndCreateStatusWindow( &WndStatusColour );
}
}
} else {
set = WndClassColour[ class ];
if( set == NULL ) {
set = WndAlloc( sizeof( WndColours ) );
memcpy( set, WndColours, sizeof( WndColours ) );
WndClassColour[ class ] = set;
}
set[ attr ].fore = fore;
set[ attr ].back = back;
if( attr == WND_PLAIN ) {
set[ GUI_BACKGROUND ] = set[ attr ];
}
if( class == WND_ALL ) {
for( class = 0; class < WND_NUM_CLASSES; ++class ) {
if( WndClassColour[ class ] != NULL ) {
WndClassColour[ class ][ attr ] = set[ attr ];
if( attr == WND_PLAIN ) {
WndClassColour[ class ][ GUI_BACKGROUND ] = set[ attr ];
}
}
}
}
_SwitchOn( SW_PENDING_REPAINT );
}
}
void ProcPendingPaint( void )
{
gui_colour_set *set;
a_window *wnd;
if( _IsOff( SW_PENDING_REPAINT ) ) return;
_SwitchOff( SW_PENDING_REPAINT );
for( wnd = WndNext( NULL ); wnd != NULL; wnd = WndNext( wnd ) ) {
if( WndHasClass( wnd ) ) {
set = WndClassColour[ WndClass( wnd ) ];
} else {
set = NULL;
}
if( set == NULL ) {
set = WndClassColour[ WND_ALL ];
}
if( set == NULL ) {
set = WndColours;
}
WndSetFontInfo( wnd, GetWndFont( wnd ) );
WndSetColours( wnd, WndNumColours, set );
}
}
void FiniPaint( void )
{
int i;
for( i = 0; i < WND_NUM_CLASSES; ++i ) {
if( WndClassColour[ i ] != NULL ) {
WndFree( WndClassColour[ i ] );
WndClassColour[ i ] = NULL;
}
}
}
extern gui_colour_set *GetWndColours( wnd_class class )
{
if( class == WND_NO_CLASS ) return( WndColours );
if( WndClassColour[ class ] != NULL ) return( WndClassColour[ class ] );
if( WndClassColour[ WND_ALL ] != NULL ) return( WndClassColour[ WND_ALL ] );
return( WndColours );
}
static void GetAttrName( attr_map *map, int i, char *buff )
{
attr_bits bits;
bool blank;
char *p;
bits = map[i].bits;
p = buff;
for( i = 1;; ++i ) {
if( bits & 1 ) {
p = GetCmdEntry( AttrNameTab, i, p );
blank = TRUE;
} else {
blank = FALSE;
}
bits >>= 1;
if( bits == 0 ) break;
if( blank ) {
*p++ = ' ';
}
}
*p = '\0';
}
static void GetColourName( gui_colour colour, char *buff )
{
colour_bits bits;
int i;
char *p;
for( i = 0; i < ArraySize( ColourMap ); ++i ) {
if( ColourMap[i].colour == colour ) {
bits = ColourMap[i].bits;
break;
}
}
p = buff;
if( bits & CLR_BRIGHT ) {
p = StrCopy( "bright ", p );
bits &= ~CLR_BRIGHT;
}
for( i = 1;; ++i ) {
if( bits & 1 ) {
p = GetCmdEntry( ColourNameTab, i, p );
break;
}
bits >>= 1;
}
*p = '\0';
}
static void PrintStatusColour( void )
{
char fore[20];
char back[20];
GetColourName( WndStatusColour.fore, fore );
GetColourName( WndStatusColour.back, back );
Format( TxtBuff, "%s status %s on %s", GetCmdName( CMD_PAINT ), fore, back );
WndDlgTxt( TxtBuff );
}
static void PrintDialogColours( void )
{
int i;
char fore[20];
char back[20];
char attr[30];
GUIGetDialogColours( WndDlgColours );
for( i = 0; i < ArraySize( DlgAttrMap ); ++i ) {
if( i == GUI_DLG_SCROLL_ICON ) continue;
if( i == GUI_DLG_SCROLL_BAR ) continue;
GetAttrName( DlgAttrMap, i, attr );
GetColourName( WndDlgColours[ i ].fore, fore );
GetColourName( WndDlgColours[ i ].back, back );
Format( TxtBuff, "%s dialog %s %s on %s", GetCmdName( CMD_PAINT ), attr, fore, back );
WndDlgTxt( TxtBuff );
}
}
static void PrintColours( wnd_class class,
gui_colour_set *set, gui_colour_set *def )
{
char wndname[20];
char attr[30];
char fore[20];
char back[20];
int i;
GetCmdEntry( WndNameTab, class+1, wndname );
for( i = 0; i < ArraySize( AttrMap ); ++i ) {
if( i == GUI_BACKGROUND ) continue;
if( i == GUI_FRAME_RESIZE ) continue;
if( def == NULL || memcmp( &set[i], &def[i], sizeof( *set ) ) != 0 ) {
GetAttrName( AttrMap, i, attr );
GetColourName( set[i].fore, fore );
GetColourName( set[i].back, back );
Format( TxtBuff, "%s %s %s %s on %s", GetCmdName( CMD_PAINT ), wndname, attr, fore, back );
WndDlgTxt( TxtBuff );
}
}
}
void ConfigPaint( void )
{
gui_colour_set *def;
int i;
def = WndClassColour[ WND_ALL ];
if( def == NULL ) {
def = WndColours;
}
PrintColours( WND_ALL, def, NULL );
for( i = 0; i < WND_NUM_CLASSES; ++i ) {
if( i == WND_ALL ) continue;
if( WndClassColour[ i ] != NULL ) {
PrintColours( i, WndClassColour[ i ], def );
}
}
PrintStatusColour();
PrintDialogColours();
}
void InitPaint( void )
{
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?