wpsamp.c
来自「开放源码的编译器open watcom 1.6.0版的源代码」· C语言 代码 · 共 1,543 行 · 第 1/4 页
C
1,543 行
return( sampleSetLine( wnd, row, piece, line ) );
}
STATIC bint sampleProcTopStatus( a_window *wnd, int row, int piece,
wnd_line_piece *line )
/*****************************************************************/
{
gui_point start;
gui_point end;
gui_ord vertical_x;
gui_ord max_x;
gui_ord max_y;
gui_ord client_width;
gui_ord cross_y;
row=row;
piece=piece;
line=line;
if( piece > PIECE_DRAW_LINE ) return( B_FALSE );
if( piece == PIECE_MOUSE_CATCHER ) {
line->indent = 0;
line->tabstop = B_FALSE;
line->attr = WPA_PLAIN;
line->text = LIT( Empty_Str );
line->extent = WndWidth( wnd );
return( B_TRUE );
}
max_y = WndMaxCharY( wnd );
max_x = WndAvgCharX( wnd );
vertical_x = SEPARATOR_POINT + max_x / 2;
client_width = WPGetClientWidth( wnd );
cross_y = max_y * (STATUS_ROW-1) - max_y/4;
start.x = 0;
end.x = client_width;
start.y = cross_y;
end.y = start.y;
GUIDrawLine( WndGui( wnd ), &start, &end, GUI_PEN_SOLID, 0, WPA_PLAIN );
start.x = vertical_x;
end.x = start.x;
start.y = 0;
end.y = cross_y;
GUIDrawLine( WndGui( wnd ), &start, &end, GUI_PEN_SOLID, 0, WPA_PLAIN );
return( B_TRUE );
}
STATIC bint sampleProcBotStatus( a_window *wnd, int row, int piece,
wnd_line_piece *line )
/*******************************************************************/
{
gui_point start;
gui_point end;
gui_ord vertical_x;
gui_ord max_x;
gui_ord max_y;
gui_ord client_height;
gui_ord client_width;
gui_ord cross_y;
row=row;
piece=piece;
line=line;
if( piece > PIECE_DRAW_LINE ) return( B_FALSE );
if( piece == PIECE_MOUSE_CATCHER ) {
line->indent = 0;
line->tabstop = B_FALSE;
line->attr = WPA_PLAIN;
line->text = LIT( Empty_Str );
line->extent = WndWidth( wnd );
return( B_TRUE );
}
max_y = WndMaxCharY( wnd );
max_x = WndAvgCharX( wnd );
vertical_x = SEPARATOR_POINT + max_x / 2;
client_height = WPGetClientHeight( wnd );
client_width = WPGetClientWidth( wnd );
cross_y = max_y * STATUS_ROW + max_y/4;
start.x = 0;
end.x = client_width;
start.y = cross_y;
end.y = start.y;
GUIDrawLine( WndGui( wnd ), &start, &end, GUI_PEN_SOLID, 0, WPA_PLAIN );
start.x = vertical_x;
end.x = vertical_x;
start.y = cross_y;
end.y = client_height;
GUIDrawLine( WndGui( wnd ), &start, &end, GUI_PEN_SOLID, 0, WPA_PLAIN );
return( B_TRUE );
}
STATIC bint sampleProcStatus( a_window *wnd, int row, int piece,
wnd_line_piece *line )
/***************************************************************/
{
sio_data *curr_sio;
clicks_t abs_count;
clicks_t rel_count;
gui_ord point_adjust;
row=row;
if( piece >= PIECE_HEADER_LAST ) {
return( B_FALSE );
}
curr_sio = WndExtra( wnd );
if( piece == PIECE_MOUSE_CATCHER ) {
line->indent = 0;
line->tabstop = B_FALSE;
line->attr = WPA_PLAIN;
line->text = LIT( Empty_Str );
abs_count = curr_sio->abs_count;
rel_count = curr_sio->rel_count;
snprintf( relData, sizeof( relData ), "%ld.%ld%%", rel_count/10,
rel_count-((rel_count/10)*10) );
snprintf( absData, sizeof( absData ), "%ld.%ld%%", abs_count/10,
abs_count-((abs_count/10)*10) );
if( WPPixelTruncWidth( WndMaxCharX( wnd ) / 2 ) == 0 ) {
point_adjust = WndMaxCharX( wnd ) / 2;
} else {
point_adjust = 0;
}
absPctStatusIndent = BAR_TAIL_POINT - WndExtentX( wnd, absData )
- point_adjust;
indentPiece = BAR_TAIL_POINT - WndExtentX( wnd, "199.9%" )
- (2 * WndExtentX( wnd, " " )) - point_adjust;
relPctStatusIndent = indentPiece - WndExtentX( wnd, relData );
indentPiece -= WndExtentX( wnd, "199.9%" );
if( GUIIsGUI() ) {
indentPiece -= WndExtentX( wnd, LIT( Rel_Header ) )
+ WndExtentX( wnd, LIT( Abs_Header ) );
relPctStatusIndent -= WndExtentX( wnd, LIT( Abs_Header ) );
line->extent = indentPiece;
}
} else if( piece == PIECE_REL_HEADER ) {
line->indent = indentPiece;
if( GUIIsGUI() ) {
line->text = LIT( Rel_Header );
} else {
line->text = LIT( Empty_Str );
}
line->tabstop = B_FALSE;
if( relGraphBar ) {
line->attr = WPA_REL_BAR;
} else {
line->attr = WPA_PLAIN_INACTIVE;
}
} else if( piece == PIECE_REL_PERCENT ) {
line->text = relData;
line->indent = relPctStatusIndent;
line->tabstop = B_FALSE;
if( curr_sio->rel_on_screen ) {
line->attr = WPA_REL_BAR;
} else {
line->attr = WPA_PLAIN_INACTIVE;
}
} else if( piece == PIECE_ABS_HEADER ) {
indentPiece = BAR_TAIL_POINT - WndExtentX( wnd, "199.9%" );
if( GUIIsGUI() ) {
line->text = LIT( Abs_Header );
indentPiece -= WndExtentX( wnd, LIT( Abs_Header ) );
} else {
line->text = LIT( Empty_Str );
}
line->indent = indentPiece;
line->tabstop = B_FALSE;
if( curr_sio->abs_on_screen ) {
line->attr = WPA_ABS_BAR;
} else {
line->attr = WPA_PLAIN_INACTIVE;
}
} else if( piece == PIECE_ABS_PERCENT ) {
line->text = absData;
line->indent = absPctStatusIndent;
line->tabstop = B_FALSE;
if( curr_sio->abs_on_screen ) {
line->attr = WPA_ABS_BAR;
} else {
line->attr = WPA_PLAIN_INACTIVE;
}
} else if( piece == PIECE_PERCENT_SEPARATOR ) {
if( !GUIIsGUI() ) {
line->vertical_line = B_TRUE;
}
line->indent = SEPARATOR_POINT;
line->text = LIT( Empty_Str );
line->attr = WPA_PLAIN;
line->tabstop = B_FALSE;
} else if( piece == PIECE_DETAIL_TITLE ) {
line->indent = SEPARATOR_POINT + WndMaxCharX( wnd );
curr_sio = WndExtra( wnd );
if( curr_sio->level_open == LEVEL_ROUTINE ) {
snprintf( lineData, sizeof( lineData ), "%s: %.5d",
statusHeaders[curr_sio->level_open],
curr_sio->curr_display_row+1 );
line->text = lineData;
} else {
line->text = statusHeaders[curr_sio->level_open];
}
line->tabstop = B_FALSE;
line->attr = WPA_PLAIN;
}
return( B_TRUE );
}
STATIC bint sampleProcOverview( a_window * wnd, int row, int piece,
wnd_line_piece * line )
/******************************************************************/
{
sio_data * curr_sio;
clicks_t tick_count;
clicks_t total_ticks;
char * text;
if( piece >= PIECE_LAST ) {
return( B_FALSE );
}
curr_sio = WndExtra( wnd );
row += STATUS_ROW + 1;
text = LIT( Empty_Str );
tick_count = 0;
if( row <= curr_sio->level_open ) {
if( row == 0 ) {
text = curr_sio->samp_file_name;
tick_count = curr_sio->total_samples;
} else if( row == 1 ) {
text = curr_sio->curr_image->name;
tick_count = curr_sio->curr_image->agg_count;
} else if( row == 2 ) {
text = curr_sio->curr_mod->name;
tick_count = curr_sio->curr_mod->agg_count;
} else if( row == 3 ) {
text = curr_sio->curr_file->name;
tick_count = curr_sio->curr_file->agg_count;
} else if( row == 4 ) {
text = curr_sio->curr_rtn->name;
tick_count = curr_sio->curr_rtn->tick_count;
}
}
if( piece == PIECE_MOUSE_CATCHER ) {
line->indent = 0;
line->tabstop = B_FALSE;
line->master_tabstop = B_TRUE;
line->attr = WPA_PLAIN;
line->text = LIT( Empty_Str );
if( row <= curr_sio->level_open ) {
line->extent = BAR_TAIL_POINT;
}
} else if( piece == PIECE_BAR ) {
line->indent = BAR_TAIL_POINT;
if( curr_sio->total_samples == 0 ) {
curr_sio->total_samples = 1;
}
total_ticks = curr_sio->total_samples;
line->attr = WPA_PLAIN;
line->tabstop = B_FALSE;
line->master_tabstop = B_TRUE;
if( row > curr_sio->level_open ) {
line->text = LIT( Empty_Str );
} else {
line->draw_bar = B_TRUE;
barData.bar_style = GUI_BAR_SHADOW;
barData.bar_colour = WPA_ABS_BAR;
barData.bar_group = B_FALSE;
barData.bar_selected = B_FALSE;
tick_count *= BAR_TAIL_POINT - (WndMaxCharX( wnd ) / 2);
line->extent = tick_count / total_ticks;
if( line->extent == 0 && tick_count != 0 ) {
line->extent = 1;
}
line->indent -= line->extent;
line->text = (char *)&barData;
}
} else if( piece == PIECE_SEPARATOR ) {
indentPiece = SEPARATOR_POINT;
line->indent = indentPiece;
line->vertical_line = B_TRUE;
line->text = LIT( Empty_Str );
line->attr = WPA_PLAIN;
line->tabstop = B_FALSE;
line->master_tabstop = B_TRUE;
} else if( piece == PIECE_HOOK ) {
if( row > curr_sio->level_open ) {
return( B_FALSE );
}
line->tabstop = B_FALSE;
line->master_tabstop = B_TRUE;
line->text = LIT( Empty_Str );
if( row == 0 ) {
indentPiece += WndMaxCharX( wnd );
} else {
indentPiece += (row*2 - 1) * WndMaxCharX( wnd );
line->indent = indentPiece;
indentPiece += 2 * WndMaxCharX( wnd );
line->draw_hook = B_TRUE;
line->attr = WPA_PLAIN;
}
} else if( piece == PIECE_NAME_TITLE ) {
line->indent = indentPiece;
nameBuff = ProfRealloc( nameBuff, strlen( overviewHeaders[row] ) + 1 );
strcpy( nameBuff, overviewHeaders[row] );
line->text = nameBuff;
line->tabstop = B_FALSE;
line->master_tabstop = B_TRUE;
if( curr_sio->level_open == row ) {
line->attr = WPA_OVERVIEW_NAME;
} else {
line->attr = WPA_PLAIN;
}
indentPiece += WndExtentX( wnd, nameBuff );
} else {
line->indent = indentPiece;
nameBuff = ProfRealloc( nameBuff, strlen( text ) + 1 );
strcpy( nameBuff, text );
line->text = nameBuff;
line->tabstop = B_FALSE;
line->master_tabstop = B_TRUE;
if( curr_sio->level_open == row ) {
line->attr = WPA_OVERVIEW_NAME;
} else {
line->attr = WPA_PLAIN;
}
}
return( B_TRUE );
}
STATIC bint simageGetLine( a_window * wnd, int row )
/**************************************************/
{
sio_data * curr_sio;
image_info * image;
curr_sio = WndExtra( wnd );
sampNewRow = row != curr_sio->curr_proc_row;
if( sampNewRow ) {
curr_sio->curr_proc_row = row;
image = SImageGetImage( wnd, row );
if( image == NULL ) {
return( B_FALSE );
}
curr_sio->curr_image = image;
dispHighLight = image->main_load;
dispName = image->name;
dispCount = image->agg_count;
localTicks = curr_sio->total_samples;
maxTime = curr_sio->max_time;
barMaxTime = curr_sio->bar_max;
absGraphBar = curr_sio->abs_bar;
relGraphBar = curr_sio->rel_bar;
}
return( B_TRUE );
}
STATIC bint smodGetLine( a_window *wnd, int row )
/***********************************************/
{
sio_data *curr_sio;
mod_info *mod;
curr_sio = WndExtra( wnd );
sampNewRow = row != curr_sio->curr_proc_row;
if( sampNewRow ) {
curr_sio->curr_proc_row = row;
mod = SModGetModule( wnd, row );
if( mod == NULL ) {
return( B_FALSE );
}
curr_sio->curr_mod = mod;
dispHighLight = B_FALSE;
dispName = mod->name;
dispCount = mod->agg_count;
localTicks = curr_sio->curr_image->agg_count;
maxTime = curr_sio->curr_image->max_time;
barMaxTime = curr_sio->curr_image->bar_max;
absGraphBar = curr_sio->curr_image->abs_bar;
relGraphBar = curr_sio->curr_image->rel_bar;
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?