Exemplo n.º 1
0
void WndShrinkToMouse( a_window wnd, wnd_metrics *metrics )
{
    gui_rect            rect,client;
    gui_point           mouse;
    gui_coord           round;
    gui_ord             max_width;
    gui_ord             min_width;
    int                 rows;

    GUIGetRect( wnd->gui, &rect );
    GUIGetClientRect( wnd->gui, &client );
    max_width = metrics->max_cols * WndAvgCharX( wnd );
    min_width = metrics->min_cols * WndAvgCharX( wnd );
    rect.width = wnd->max_indent + rect.width - client.width;
    if( max_width != 0 && rect.width > max_width ) {
        rect.width = max_width;
    }
    if( min_width != 0 && rect.width < min_width ) {
        rect.width = min_width;
    }
    if( rect.width > WndMax.x )
        rect.width = WndMax.x;
    rows = wnd->max_row + 1;
    if( metrics->max_rows != 0 && rows > metrics->max_rows ) {
        rows = metrics->max_rows;
    }
    if( metrics->min_rows != 0 && rows < metrics->min_rows ) {
        rows = metrics->min_rows;
    }
    if( rows > rect.height / WndMaxCharY( wnd ) ) {
        rows = rect.height / WndMaxCharY( wnd );
    }
    rect.height = rows * WndMaxCharY( wnd ) + rect.height - client.height;
    if( rect.height > WndMax.y )
        rect.height = WndMax.y;
    GUIGetMousePosn( WndMain->gui, &mouse );
    if( mouse.x < 0 )
        mouse.x = 0;
    if( mouse.y < 0 )
        mouse.y = 0;
    if( rect.width / 2 > mouse.x ) {
        rect.x = 0;
    } else if( ( rect.width / 2 ) + mouse.x > WndMax.x ) {
        rect.x = WndMax.x - rect.width;
    } else {
        rect.x = mouse.x - rect.width / 2;
    }
    if( mouse.y + rect.height > WndMax.y ) {
        rect.y = WndMax.y - rect.height;
    } else {
        rect.y = mouse.y;
        round.y = WndMaxCharY( wnd ) / 2;
        round.x = 0;
        GUITruncToPixel( &round );
        rect.y -= round.y;
    }
    GUISetRestoredSize( wnd->gui, &rect );
}
Exemplo n.º 2
0
static  bool    CallGetLine( a_window *wnd, int row, int piece, wnd_line_piece *line )
{
    call_chain  *chain;
    call_window *call = WndCall( wnd );

    chain = GetCallChain( &call->tb, row );
    if( chain == NULL )
        return( false );
    line->extent = WND_MAX_EXTEND;
    switch( piece ) {
    case PIECE_SYMBOL:
        StrCopy( ":", StrCopy( chain->symbol, TxtBuff ) );
        line->text = TxtBuff;
        return( true );
    case PIECE_SOURCE:
        line->indent = call->max_sym_len + 3 * WndAvgCharX( wnd );
        line->tabstop = FALSE;
        line->use_prev_attr = TRUE;
        if( chain->source_line == NULL ) {
            line->text = TxtBuff;
            UnAsm( chain->lc.execution, TxtBuff, TXT_LEN );
        } else {
            line->text = chain->source_line;
        }
        return( true );
    default:
        return( false );
    }
}
Exemplo n.º 3
0
static  bool    FuncGetLine( a_window *wnd, int row, int piece,
                             wnd_line_piece *line )
{
    address     addr;
    func_window *func = WndFunc( wnd );

    if( row >= NameListNumRows( NameList( func ) ) ) return( FALSE );
    addr = NameListAddr( NameList( func ), row );
    switch( piece ) {
    case PIECE_BREAK:
        FileBreakGadget( wnd, line, FALSE, FindBreak( addr ) );
        return( TRUE );
    case PIECE_NAME:
        line->indent = MaxGadgetLength;
        line->text = TxtBuff;
        line->extent = WND_MAX_EXTEND;
        FuncGetSourceName( wnd, row );
        return( TRUE );
    case PIECE_DEMANGLED:
        if( NameListName( NameList( func ), row, TxtBuff, SN_DEMANGLED ) == 0 ) {
            return( FALSE );
        }
        line->text = TxtBuff;
        line->use_prev_attr = TRUE;
        line->indent = MaxGadgetLength + func->max_name + 2 * WndAvgCharX( wnd );
        return( TRUE );
    default:
        return( FALSE );
    }
}
Exemplo n.º 4
0
static void     BrkInit( a_window *wnd )
{
    gui_ord             length, max;
    break_window        *wndbreak;
    brkp                *bp;
    int                 count;

    wndbreak = WndBreak( wnd );
    max = 0;
    count = 0;
    for( bp = BrkList; bp != NULL; bp = bp->next ) {
        GetBPAddr( bp, TxtBuff );
        length = WndExtentX( wnd, TxtBuff );
        if( max < length )
            max = length;
        ++count;
    }
    length = MaxGadgetLength + WndAvgCharX( wnd );
#ifdef OPENER_GADGET
    length += length;
#endif
    wndbreak->addr_indent = length;

    length += max + 2 * WndMaxCharX( wnd );
    wndbreak->source_indent = length;

    if( wndbreak->toggled_break ) {
        wndbreak->toggled_break = false;
        return;
    }
    WndNoSelect( wnd );
    WndRepaint( wnd );
}
Exemplo n.º 5
0
static  bool    BrkGetLine( a_window *wnd, int row, int piece,
                             wnd_line_piece *line )
{
    brkp                *bp;
    break_window        *wndbreak;
    bool                curr;

    wndbreak = WndBreak( wnd );
    bp = BrkGetBP( row );
    if( bp == NULL )
        return( false );
    line->text = TxtBuff;
    line->tabstop = false;
    switch( piece ) {
#ifdef OPENER_GADGET
    case PIECE_OPENER:
    {
        mod_handle              mh;
        line->text = LIT_DUI( Empty );
        if( bp->size == 0 ) {
            DeAliasAddrMod( bp->loc.addr, &mh );
            bp->status.b.source_open =
                OpenGadget( wnd, line, mh, bp->source_line != NULL );
        }
        return( true );
    }
#endif
    case PIECE_ACTIVE:
#ifdef OPENER_GADGET
        line->indent = MaxGadgetLength + WndAvgCharX( wnd );
#endif
        curr = AddrComp( bp->loc.addr, Context.execution ) == 0;
        FileBreakGadget( wnd, line, curr, bp );
        return( true );
    case PIECE_ADDR:
        line->indent = wndbreak->addr_indent;
        line->extent = WND_MAX_EXTEND;
        line->tabstop = true;
        GetBPAddr( bp, TxtBuff );
        return( true );
    case PIECE_SOURCE:
        line->indent = wndbreak->source_indent;
        line->tabstop = false;
        line->use_prev_attr = true;
        GetBPText( bp, TxtBuff );
        return( true );
    default:
        return( false );
    }
}
Exemplo n.º 6
0
static void     VarSetWidth( a_window *wnd )
/*
    Always leave room for a vertical scroll bar. It's most annoying
    having the window repaint whenever it appears/disappears.
 */
{
    var_window  *var = WndVar( wnd );

    var->last_width = WndWidth( wnd );
    if( VarRowTotal( &var->i ) <= WndRows( wnd ) ) {
        var->last_width -= WndVScrollWidth( wnd );
    }
    var->last_width -= WndAvgCharX( wnd ) / 2;

}
Exemplo n.º 7
0
extern  bool    W5GetLine( a_window *wnd, int row, int piece,
                             wnd_line_piece *line )
{
    static char buff[20];

    if( row >= NUM_ROWS ) return( FALSE );
    if( piece == 0 ) {
        itoa( row, buff, 10 );
        line->text = buff;
    } else if( piece == 1 ) {
        line->text = "This is text";
        line->extent = WND_MAX_EXTEND;
        line->indent = 5*WndAvgCharX( wnd );
    } else {
        return( FALSE );
    }
    return( TRUE );
}
Exemplo n.º 8
0
static bool    W5GetLine( a_window wnd, wnd_row row, wnd_piece piece, wnd_line_piece *line )
{
    static char buff[20];

    if( row >= NUM_ROWS )
        return( false );
    if( piece == 0 ) {
        itoa( row, buff, 10 );
        line->text = buff;
    } else if( piece == 1 ) {
        line->text = "This is text";
        line->extent = WND_MAX_EXTEND;
        line->indent = 5 * WndAvgCharX( wnd );
    } else {
        return( false );
    }
    return( true );
}
Exemplo n.º 9
0
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 );
}
Exemplo n.º 10
0
static  bool    TrdGetLine( a_window *wnd, int row, int piece,
                             wnd_line_piece *line )
{
    thread_state        *thd = GetThreadRow( row );

    line->indent = Indents[piece] * WndAvgCharX( wnd );
    if( row < 0 ) {
        row += TITLE_SIZE;
        switch( row ) {
        case 0:
            switch( piece ) {
            case PIECE_ID:
                line->text = LIT_DUI( ID );
                return( true );
            case PIECE_STATE:
                line->text = LIT_DUI( State );
                return( true );
            case PIECE_NAME:
                line->text = TxtBuff;
                RemoteThdName( 0, TxtBuff ); // nyi - pui - line up in proportional font
                return( true );
            default:
                return( false );
            }
        case 1:
            if( piece != 0 )
                return( false );
            SetUnderLine( wnd, line );
            return( true );
        default:
            return( false );
        }
    } else {
        if( thd == NULL )
            return( false );
        line->tabstop = false;
        line->use_prev_attr = true;
        line->extent = WND_MAX_EXTEND;
        switch( piece ) {
        case PIECE_ID:
            line->tabstop = true;
            line->use_prev_attr = false;
            line->text = TxtBuff;
            CnvULongHex( thd->tid, TxtBuff, TXT_LEN );
            return( true );
        case PIECE_STATE:
            if( IsThdCurr( thd ) ) {
                line->text = LIT_ENG( Current );
            } else {
                switch( thd->state ) {
                case THD_THAW:
                    line->text = LIT_ENG( Runnable );
                    break;
                case THD_FREEZE:
                    line->text = LIT_ENG( Frozen );
                    break;
                case THD_WAIT:
                    line->text = LIT_ENG( Wait );
                    break;  
                case THD_SIGNAL:
                    line->text = LIT_ENG( Signal );
                    break;  
                case THD_KEYBOARD:
                    line->text = LIT_ENG( Keyboard );
                    break;  
                case THD_BLOCKED:
                    line->text = LIT_ENG( Blocked );
                    break;  
                case THD_RUN:
                    line->text = LIT_ENG( Executing );
                    break;  
                case THD_DEBUG:
                    line->text = LIT_ENG( Debug );
                    break;
                case THD_DEAD:
                    line->text = LIT_ENG( Dead );
                    break;
                }
            }
            return( true );
        case PIECE_NAME:
            line->tabstop = false;
            line->use_prev_attr = true;
            line->text = thd->name;
            return( true );
        }
    }
    return( false );
}
Exemplo n.º 11
0
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;
    }
}
Exemplo n.º 12
0
static  bool    RunTrdGetLine( a_window *wnd, int row, int piece,
                               wnd_line_piece *line )
{
    thread_state        *thd = GetThreadRow( row );

    line->indent = Indents[ piece ] * WndAvgCharX( wnd );
    if( row < 0 ) {
        row += TITLE_SIZE;
        switch( row ) {
        case 0:
            if( piece < PieceCount ) {
                line->text = HeaderArr[ piece ];
                return( TRUE );
            } 
            return( FALSE );
        case 1:
            if( piece != 0 ) return( FALSE );
            SetUnderLine( wnd, line );
            return( TRUE );
        default:
            return( FALSE );
        }
    } else {
        if( thd == NULL ) return( FALSE );
        line->tabstop = FALSE;
        line->use_prev_attr = TRUE;
        line->extent = WND_MAX_EXTEND;
        switch( InfoType[ piece ] ) {
        case RUN_THREAD_INFO_TYPE_NAME:
            line->tabstop = TRUE;
            line->use_prev_attr = FALSE;
            line->text = thd->name;
            return( TRUE );
        case RUN_THREAD_INFO_TYPE_STATE:
            if( IsThdCurr( thd ) && ( thd->state == THD_DEBUG ) ) {
                line->text = LIT( Current );
            } else {
                switch( thd->state ) {
                case THD_THAW:
                    line->text = LIT( Runnable );
                    break;
                case THD_FREEZE:
                    line->text = LIT( Frozen );
                    break;
                case THD_WAIT:
                    line->text = LIT( Wait );
                    break;  
                case THD_SIGNAL:
                    line->text = LIT( Signal );
                    break;  
                case THD_KEYBOARD:
                    line->text = LIT( Keyboard );
                    break;  
                case THD_BLOCKED:
                    line->text = LIT( Blocked );
                    break;  
                case THD_RUN:
                    line->text = LIT( Executing );
                    break;  
                case THD_DEBUG:
                    line->text = LIT( Debug );
                    break;
                case THD_DEAD:
                    line->text = LIT( Dead );
                    break;
                }
            }
            return( TRUE );
        case RUN_THREAD_INFO_TYPE_EXTRA:
            line->tabstop = FALSE;
            line->use_prev_attr = TRUE;
            line->text = thd->extra;
            return( TRUE );
        case RUN_THREAD_INFO_TYPE_CS_EIP:
            line->tabstop = FALSE;
            line->use_prev_attr = TRUE;
            if( thd->cs ) {
                sprintf(TxtBuff, "%04hX:%08lX", thd->cs, thd->eip );
                line->text = TxtBuff;
            } else {
                line->text = "";
            }
            return( TRUE );
        }
    }
    return( FALSE );
}
Exemplo n.º 13
0
static bool RegResize( a_window *wnd )
{
    reg_window          *reg = WndReg( wnd );
    gui_ord             space;
    int                 old_up;
    int                 i,j;
    reg_display_piece   disp;
    gui_ord             max_extent;
    gui_ord             max_descript;
    a_reg_info          *info;
    gui_ord             indent;
    gui_ord             value,descript;
    char                *p;
    unsigned            len;

    old_up = reg->up;
    reg->up = 1;

    RegFindData( reg->kind, &reg->data );
    reg->count = 0;
    while( GetDisplayPiece( &disp, reg, DbgRegs, reg->count ) ) {
        reg->count++;
    }

    WndFree( reg->info );
    reg->info = WndMustAlloc( reg->count * sizeof( *reg->info ) );
    space = WndAvgCharX( wnd );

    max_extent = 0;
    max_descript = 0;
    for( i = 0; i < reg->count; ++i ) {
        GetDisplayPiece( &disp, reg, DbgRegs, i );
        if( disp.max_value == 0 && disp.reginfo != NULL ) {
            disp.max_value = GetMADMaxFormatWidth( disp.disp_type );
        }
        info = &reg->info[i];
        info->max_value = disp.max_value;
        info->info = disp.reginfo;
        if( disp.max_descript > strlen( disp.descript ) ) {
            info->max_descript = space + disp.max_descript * WndAvgCharX( wnd );
        } else {
            info->max_descript = space + WndExtentX( wnd, disp.descript );
        }
        info->max_extent = space + disp.max_value * WndAvgCharX( wnd );
        info->standout = false;
        if( max_extent < info->max_extent ) {
            max_extent = info->max_extent;
        }
        if( max_descript < info->max_descript ) {
            max_descript = info->max_descript;
        }
    }

    reg->up = MADRegSetDisplayGrouping( reg->data );
    if( reg->up == 0 ) {
        reg->up = WndWidth( wnd ) / ( max_extent + max_descript );
        if( reg->up < 1 )
            reg->up = 1;
        if( reg->up > reg->count ) {
            reg->up = reg->count;
        }
    }
    reg->rows = ( reg->count + reg->up - 1 ) / reg->up;

    // calculate the indents

    WndFree( reg->indents );
    reg->indents = WndMustAlloc( reg->count * sizeof( *reg->indents ) );

    // For each column
    for( i = 0; i < reg->up; ++i ) {
        reg->indents[i].descript = 0;
        reg->indents[i].value = 0;
        // Calc max widths for column
        for( j = i; j < reg->count; j += reg->up ) {
            if( reg->indents[i].value < reg->info[j].max_extent ) {
                reg->indents[i].value = reg->info[j].max_extent;
            }
            if( reg->indents[i].descript < reg->info[j].max_descript ) {
                reg->indents[i].descript = reg->info[j].max_descript;
            }
        }
    }
    // Calc indents for each column
    indent = 0;
    value = 0;
    descript = 0;
    // For each column
    for( i = 0; i < reg->up; ++i ) {
        value = reg->indents[i].value;
        descript = reg->indents[i].descript;
        reg->indents[i].descript = indent;
        reg->indents[i].value = indent + descript;
        indent += value + descript;
#if ( defined( __GUI__ ) && defined( __OS2__ ) )
        // OS/2 PM GUI needs more space between columns
        indent += space;
#endif
    }
    // Copy indents to all registers by column
    for( i = reg->up; i < reg->count; ++i ) {
        reg->indents[i] = reg->indents[i % reg->up];
    }

    if( reg->up != old_up ) {
        WndScrollAbs( wnd, 0 );
        WndNoCurrent( wnd );
    }

    p = TxtBuff + MADCliString( MADRegSetName( reg->data ), TxtBuff, TXT_LEN );
    *p++ = ' ';
    *p++ = '(';
    len = MADRegSetLevel( reg->data, p, TXT_LEN - ( p - TxtBuff ) );
    if( len == 0 ) {
        p -= 2;
    } else {
        p += len;
        *p++ = ')';
    }
    *p++ = NULLCHAR;
    WndSetTitle( wnd, TxtBuff );

    return( true );
}
Exemplo n.º 14
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 );
    }
}
Exemplo n.º 15
0
static void DoWndDump( a_window *wnd, WRITERTN *rtn, handle file )
{
    int                 row;
    int                 piece;
    wnd_line_piece      line;
    int                 indent_per_char;
    int                 chars_written;
    int                 indent_pos;
    char                *font;
    gui_ord             gadget_len;
    char                *p;
    char                buff[TXT_LEN];
//    int                 len;
    int                 i;

    font = WndGetFontInfo( wnd );
    gadget_len = MaxGadgetLength;
    MaxGadgetLength = ( strlen( WndGadgetArray[0].chars ) + 1 ) * WndAvgCharX( wnd );
    WndSetSysFont( wnd, TRUE );
    indent_per_char = WndAvgCharX( wnd );
//    len = WndGetTitle( wnd, buff, TXT_LEN );
    WndGetTitle( wnd, buff, TXT_LEN );
    p = TxtBuff;
    for( i = 0; i < 7; ++i ) {
        *p++ = '=';
    }
    *p++ = '|';
    *p++ = ' ';
    p = StrCopy( buff, p );
    *p++ = ' ';
    *p++ = '|';
    for( i = 0; i < 7; ++i ) {
        *p++ = '=';
    }
    *p = '\0';
    rtn( file, TxtBuff );
    for( row = -WndTitleSize( wnd );; ++row ) {
        p = buff;
        chars_written = 0;
        for( piece = 0; ; ++piece ) {
            if( !WndGetLineAbs( wnd, row, piece, &line ) )
                break;
            indent_pos = line.indent / indent_per_char;
            while( indent_pos > chars_written ) {
                p = StrCopy( " ", p );
                ++chars_written;
            }
            if( line.bitmap ) {
                line.text = WndGadgetArray[(int)line.text[0]].chars;
                line.length = strlen( line.text );
            }
            p = StrCopy( line.text, p );
            chars_written += line.length;
        }
        if( piece == 0 )
            break;
        rtn( file, buff );
    }
    MaxGadgetLength = gadget_len;
    if( font != NULL )
        WndSetFontInfo( wnd, font );
    GUIMemFree( font );
}