Example #1
0
void    WndDirtyRect( a_window wnd, gui_ord x, wnd_row y, gui_ord width, wnd_row height )
{
    gui_rect    rect;

    rect.x = x;
    rect.y = WndScreenRow( wnd, y ) * WndMaxCharY( wnd );
    rect.width = width;
    rect.height = height * WndMaxCharY( wnd );
    GUIWndDirtyRect( wnd->gui, &rect );
}
Example #2
0
void WndPaintDirt( a_window *wnd )
{
    int                 i;
    wnd_line_piece      line;
    wnd_line_piece      next_piece_line;
    gui_rect            rect;
    wnd_dirt            *dirt;
    gui_coord           size;
    gui_coord           half_char;
    a_window            *next;
//    a_window            *last;

//    last = NULL;
    for( wnd = WndNext( NULL ); wnd != NULL; wnd = next ) {
        next = WndNext( wnd );
        if( wnd->vscroll_pending != 0 ) {
            if( wnd->hscroll_pending != -1 ) {
                _Set( wnd, WSW_REPAINT );
            }
            if( _Is( wnd, WSW_REPAINT ) ) {
                if( wnd->hscroll_pending != -1 ) {
                    GUIInitHScroll( wnd->gui, wnd->hscroll_pending );
                }
                WndRepaint( wnd );
                wnd->hscroll_pending = -1;
                wnd->vscroll_pending = 0;
            } else {
                for( i = 0; i < wnd->title_size; ++i ) {
                    GUIDrawTextExtent( wnd->gui, " ", 1, i, 0, GUI_BACKGROUND, GUI_NO_COLUMN );
                }
                GUIDoVScrollClip( wnd->gui, wnd->vscroll_pending,
                                  wnd->title_size, wnd->rows - 1 );
                wnd->vscroll_pending = 0;
            }
        }
        if( _Is( wnd, WSW_REPAINT ) ) {
            _Clr( wnd, WSW_REPAINT );
            WndKillCacheLines( wnd );
            WndCheckCurrentValid( wnd );
            GUIWndDirty( wnd->gui );
            if( wnd->max_indent != 0 && wnd->width >= wnd->max_indent ) {
                GUISetHScroll( wnd->gui, 0 );
                wnd->hscroll_pending = -1;
                GUISetHScrollRange( wnd->gui, wnd->max_indent );
            }
            next = wnd;
        } else {
            for( i = 0; i < wnd->dirtyrects; ++i ) {
                dirt = &wnd->dirty[i];
                if( dirt->row < 0 ) continue;
                if( dirt->row >= wnd->rows ) continue;
                if( dirt->piece == WND_NO_PIECE ) {
                    if( !WndGetLine( wnd, dirt->row, 0, &line ) ) continue;
                    GUIWndDirtyRow( wnd->gui, dirt->row );
                } else {
                    if( !WndGetLine( wnd, dirt->row, dirt->piece, &line ) ) continue;
                    if( line.bitmap ) {
                        GUIGetHotSpotSize( line.text[0], &size );
                        rect.x = line.indent;
                        rect.y = dirt->row * wnd->max_char.y;
                        rect.width = line.length;
                        rect.height = size.y;
                    } else if( dirt->col != WND_NO_COL ) {
                        if( line.length == 0 ) line.text = " ";
                        rect.x = line.indent;
                        rect.x += GUIGetExtentX(wnd->gui, line.text, dirt->col);
                        rect.y = dirt->row * wnd->max_char.y;
                        rect.width = GUIGetExtentX( wnd->gui, line.text+dirt->col, dirt->end_col-dirt->col+GUICharLen( line.text[dirt->col] ) );
                        rect.height = wnd->max_char.y;
                    } else if( line.extent == WND_MAX_EXTEND || line.master_tabstop ) {
                        rect.width = 0;
                        rect.height = 0;
                        GUIWndDirtyRow( wnd->gui, dirt->row );
                    } else {
                        rect.x = line.indent;
                        if( WndGetLine( wnd, dirt->row, dirt->piece+1, &next_piece_line ) ) {
                            if( next_piece_line.indent < line.indent ) {
                                rect.width = WND_APPROX_SIZE;
                            } else {
                                rect.width = next_piece_line.indent - line.indent;
                            }
                        } else {
                            rect.width = WND_APPROX_SIZE;
                        }
                        rect.y = dirt->row * wnd->max_char.y;
                        rect.height = wnd->max_char.y;
                    }
                    /* begin kludge for Kerning problem */
                    if( rect.width != 0 || rect.height != 0 ) {
                        half_char.x = WndAvgCharX( wnd ) / 2;
                        half_char.y = 0;
                        GUITruncToPixel( &half_char );
                        if( rect.x < half_char.x ) {
                            rect.width += half_char.x + rect.x;
                            rect.x = 0;
                        } else {
                            rect.x -= half_char.x;
                            rect.width += half_char.x + half_char.x;
                        }
                        GUIWndDirtyRect( wnd->gui, &rect );
                    }
                }
            }
        }
        if( wnd->hscroll_pending != -1 ) {
            GUISetHScroll( wnd->gui, wnd->hscroll_pending );
            wnd->hscroll_pending = -1;
        }
        wnd->dirtyrects = 0;
        WndSetThumb( wnd );
    }
}
Example #3
0
void StatusAmount( long parts_complete, long parts_injob )
/********************************************************/
// Display slider bar indicating percentage complete
{
    int                 old_percent;

    Parts_Injob = parts_injob;
    Parts_Complete = parts_complete;
    old_percent = Percent;
    if( parts_injob == 0 ) {
        if( parts_complete == 0 ) {
            Percent = 0;
        } else {
            Percent = 100;
        }
    } else {
        if( Parts_Complete > Parts_Injob ) {
            Parts_Complete = Parts_Injob;
        }
        if( Parts_Injob > 100000 ) {
            Percent = Parts_Complete / (Parts_Injob / 100);
        } else {
            Percent = (100 * Parts_Complete) / Parts_Injob;
        }
        if( Percent > 100 ) {
            Percent = 100;
        }
    }
    if( old_percent == Percent ) return;
    if( Percent != 0 && Percent < old_percent ) {
        Percent = old_percent;
        return;
    }
    if( StatusWnd == NULL ) return;
#ifdef _UI
    GUIWndDirty( StatusWnd );
#else
    {
        gui_ord         bar_width, old_divider, divider;
        gui_rect        rect;

        sprintf( StatusBarBuf, "%d%%", Percent );

        // 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;
        }
        old_divider = (bar_width * (long)old_percent) / 100;
        if( old_divider < 0 ) {
            old_divider = 0;
        } else if( old_divider > bar_width ) {
            old_divider = bar_width;
        }
        if( divider <= old_divider ) {
            GUIWndDirty( StatusWnd );
        } else {
            // dirty new bit of bar
            divider += StatusBarRect.x;
            old_divider += StatusBarRect.x;
            rect = StatusBarRect;
            rect.width = GUIGetExtentX( StatusWnd, StatusBarBuf, strlen( StatusBarBuf ) );
            rect.x = StatusBarRect.x + (StatusBarRect.width - rect.width) / 2;
            rect.x -= CharSize.x / 2;
            rect.width += CharSize.x;
            GUIWndDirtyRect( StatusWnd, &rect ); // dirty text
            rect.x = old_divider - CharSize.x;
            rect.width = divider - old_divider + 2 * CharSize.x;
            GUIWndDirtyRect( StatusWnd, &rect ); // dirty new bit of bar
        }
    }
#endif
}