STATIC bool 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( false ); if( piece == PIECE_MOUSE_CATCHER ) { line->indent = 0; line->tabstop = false; line->attr = WPA_PLAIN; line->text = LIT( Empty_Str ); line->extent = WndWidth( wnd ); return( 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( true ); }
static void WndDrawTheLine( a_window *wnd, wnd_line_piece *line, wnd_row row ) { gui_ord extent; gui_point start,end; gui_ord max_y; gui_ord max_x; wnd_bar_info *bar_info; if( _Isnt( wnd, WSW_NOT_TO_SCREEN ) ) { if( line->underline ) { max_y = WndMaxCharY( wnd ); start.x = line->indent; start.y = row * max_y + max_y / 2; end.x = line->indent + line->extent; end.y = start.y; GUIDrawLine( wnd->gui, &start, &end, GUI_PEN_SOLID, 0, line->attr ); return; } else if( line->vertical_line ) { max_y = WndMaxCharY( wnd ); max_x = WndAvgCharX( wnd ); start.x = line->indent + max_x / 2; end.x = start.x; start.y = row * max_y; end.y = start.y + max_y; GUIDrawLine( wnd->gui, &start, &end, GUI_PEN_SOLID, 0, line->attr ); return; } else if( line->draw_hook | line->draw_line_hook ) { if( GUIIsGUI() ) { max_y = WndMaxCharY( wnd ); max_x = WndAvgCharX( wnd ); start.x = line->indent + max_x / 2; end.x = start.x + max_x; start.y = row * max_y + max_y / 2; end.y = start.y; GUIDrawLine( wnd->gui, &start, &end, GUI_PEN_SOLID, 0, line->attr ); start.x = line->indent + max_x / 2; end.x = start.x; start.y = row * max_y; end.y = start.y; if( line->draw_hook ) { end.y += max_y / 2; } else { end.y += max_y; } GUIDrawLine( wnd->gui, &start, &end, GUI_PEN_SOLID, 0, line->attr ); } else { char ch[3]; if( line->draw_hook ) { ch[0] = GUIGetCharacter( GUI_INACT_FRAME_LL_CORNER ); } else { ch[0] = GUIGetCharacter( GUI_INACT_RIGHT_TITLE_MARK ); } ch[1] = GUIGetCharacter( GUI_INACT_FRAME_BOTTOM ); ch[2] = '\0'; GUIDrawText( wnd->gui, ch, 2, row, line->indent, line->attr ); } return; } else if( line->draw_bar ) { bar_info = (wnd_bar_info *)line->text; if( bar_info->bar_group ) { GUIDrawBarGroup( wnd->gui, row, line->indent, line->extent - bar_info->bar_size2, bar_info->bar_size2, bar_info->bar_style, bar_info->bar_colour, bar_info->bar_colour2, bar_info->bar_selected ); } else { GUIDrawBar( wnd->gui, row, line->indent, line->extent, bar_info->bar_style, bar_info->bar_colour, bar_info->bar_selected ); } return; } else if( line->bitmap ) { GUIDrawHotSpot( wnd->gui, line->text[0], row, line->indent, line->attr ); return; } else if( line->extent == WND_NO_EXTEND ) { GUIDrawText( wnd->gui, line->text, line->length, row, line->indent, line->attr ); } else { GUIDrawTextExtent( wnd->gui, line->text, line->length, row, line->indent, line->attr, line->extent ); } } extent = GUIGetExtentX( wnd->gui, line->text, line->length ); if( line->extent != WND_MAX_EXTEND ) { if( line->extent > extent ) { extent = line->extent; } } if( line->indent + extent > wnd->max_indent ) { wnd->max_indent = line->indent + extent; } }
static bool StatusEventProc( gui_window *gui, gui_event gui_ev, void *parm ) /**************************************************************************/ { static bool button_pressed = false; gui_ctl_id id; gui_key key; gui_keystate state; const char *msg; parm = parm; if( gui == NULL ) return( false ); switch( gui_ev ) { case GUI_INIT_WINDOW: return( true ); case GUI_PAINT: { if( StatusBarLen == 0 ) { break; } msg = GetVariableStrVal( Messages[MsgLine0] ); GUIDrawTextExtent( gui, msg, strlen( msg ), LINE0_ROW, LINE0_COL * CharSize.x, WND_STATUS_TEXT, GUI_NO_COLUMN ); GUIDrawTextExtent( gui, StatusLine1, strlen( StatusLine1 ), LINE1_ROW, LINE1_COL * CharSize.x, WND_STATUS_TEXT, GUI_NO_COLUMN ); #ifdef _UI { int len1, len2; char num[20]; memset( StatusBarBuf, ' ', StatusBarLen ); StatusBarBuf[StatusBarLen] = '\0'; itoa( Percent, num, 10 ); strcat( num, "%" ); memcpy( StatusBarBuf + StatusBarLen / 2 - 1, num, strlen( num ) ); // draw bar in two parts len1 = (StatusBarLen * (long)Percent) / 100; if( len1 < 0 ) { len1 = 0; } else if( len1 > StatusBarLen ) { len1 = StatusBarLen; } len2 = StatusBarLen - len1; if( len1 > 0 ) { GUIDrawText( gui, StatusBarBuf, len1, STATUS_ROW, StatusBarRect.x, WND_STATUS_BAR ); } if( len2 > 0 ) { GUIDrawText( gui, StatusBarBuf + len1, len2, STATUS_ROW, StatusBarRect.x + len1 * CharSize.x, WND_STATUS_TEXT ); } memset( StatusBarBuf, UiGChar[UI_SBOX_TOP_LINE], StatusBarLen ); GUIDrawText( gui, StatusBarBuf, StatusBarLen, STATUS_ROW - 1, StatusBarRect.x, WND_STATUS_TEXT ); GUIDrawText( gui, StatusBarBuf, StatusBarLen, STATUS_ROW + 1, StatusBarRect.x, WND_STATUS_TEXT ); } #else { gui_coord coord; int str_len, width, height; int bar_width, len1, len2, divider; gui_point start, end; gui_rect rStatusBar; // sprintf( StatusBarBuf, "%d%%", Percent ); // clear whole bar GUIFillRect( gui, &StatusBarRect, WND_STATUS_BAR ); // calculate where divider splits rectangle bar_width = StatusBarRect.width; divider = (bar_width * (long)Percent) / 100; if( divider < 0 ) { divider = 0; } else if( divider > bar_width ) { divider = bar_width; } rStatusBar = StatusBarRect; rStatusBar.width = divider; // calculate position for text (centre it) str_len = strlen( StatusBarBuf ); width = GUIGetExtentX( gui, StatusBarBuf, str_len ); height = GUIGetExtentY( gui, StatusBarBuf ); coord.y = StatusBarRect.y + (StatusBarRect.height - height) / 2; coord.x = StatusBarRect.x + (StatusBarRect.width - width) / 2; divider += StatusBarRect.x; if( coord.x > divider ) { // text is completely to right of divider GUIFillRect( gui, &rStatusBar, WND_STATUS_TEXT ); GUIDrawTextPos( gui, StatusBarBuf, str_len, &coord, WND_STATUS_TEXT ); } else if( coord.x + width < divider ) { // text is completely to left of divider GUIFillRect( gui, &rStatusBar, WND_STATUS_TEXT ); GUIDrawTextPos( gui, StatusBarBuf, str_len, &coord, WND_STATUS_BAR ); } else { // need to split text len1 = ((long)(divider - coord.x) * str_len) / width; if( len1 < 0 ) { len1 = 0; } else if( len1 > str_len ) { len1 = str_len; } len2 = str_len - len1; // recalc divider, so it falls on a character boundary divider = coord.x + GUIGetExtentX( gui, StatusBarBuf, len1 ); rStatusBar.width = divider - StatusBarRect.x; GUIFillRect( gui, &rStatusBar, WND_STATUS_TEXT ); if( len1 > 0 ) { GUIDrawTextPos( gui, StatusBarBuf, len1, &coord, WND_STATUS_BAR ); } if( len2 > 0 ) { coord.x = divider; GUIDrawTextPos( gui, StatusBarBuf + len1, len2, &coord, WND_STATUS_TEXT ); } } // draw frame start.x = StatusBarRect.x; start.y = StatusBarRect.y; end.x = StatusBarRect.width + StatusBarRect.x; end.y = start.y; // top line GUIDrawLine( gui, &start, &end, GUI_PEN_SOLID, 1, WND_STATUS_FRAME ); start.y = StatusBarRect.y + StatusBarRect.height; // bottom line end.y = start.y; GUIDrawLine( gui, &start, &end, GUI_PEN_SOLID, 1, WND_STATUS_FRAME ); end.y = StatusBarRect.y; start.x = StatusBarRect.x; end.x = start.x; // left side GUIDrawLine( gui, &start, &end, GUI_PEN_SOLID, 1, WND_STATUS_FRAME ); start.x = StatusBarRect.x + StatusBarRect.width; end.x = start.x; // right side GUIDrawLine( gui, &start, &end, GUI_PEN_SOLID, 1, WND_STATUS_FRAME ); } #endif return( false ); } case GUI_DESTROY: StatusWnd = NULL; return( false ); case GUI_CONTROL_CLICKED: GUIGetFocus( gui, &id ); GUI_GETID( parm, id ); switch( id ) { case CTL_CANCEL: if( !button_pressed ) { button_pressed = true; if( MsgBox( gui, "IDS_QUERYABORT", GUI_YES_NO ) == GUI_RET_YES ) { CancelSetup = true; } button_pressed = false; break; } case CTL_DONE: if( !button_pressed ) { CancelSetup = true; break; } } return( true ); case GUI_KEYDOWN: GUI_GET_KEY_STATE( parm, key, state ); state = state; switch( key ) { case GUI_KEY_ESCAPE: if( !button_pressed ) { button_pressed = true; if( MsgBox( gui, "IDS_QUERYABORT", GUI_YES_NO ) == GUI_RET_YES ) { CancelSetup = true; } button_pressed = false; break; } default: break; } return( true ); default: break; } return( false ); }