コード例 #1
0
static bool DrawRect( gui_window *wnd, gui_rect *rect, gui_attr attr,
                      bool fill, bool outline, char draw_char )
{
    SAREA       area;
    gui_coord   coord;

    if( ( rect->width == 0 ) || ( rect->height == 0 ) || ( (wnd->flags & CONTENTS_INVALID) == 0 ) ) {
        return( false );
    }
    coord.x = rect->x;
    coord.y = rect->y;
    GUIScaleToScreenR( &coord );
    area.col = coord.x;
    area.row = coord.y;
    coord.x = rect->width;
    coord.y = rect->height;
    GUIScaleToScreenR( &coord );
    area.width = coord.x;
    area.height = coord.y;
    if( AdjustRect( wnd, &area ) ) {
        if( fill ) {
            uivfill( &wnd->screen, area, wnd->colours[attr], draw_char );
        }
        if( outline ) {
            uidrawbox( &wnd->screen, &area, wnd->colours[attr], NULL );
        }
    }
    return( true );
}
コード例 #2
0
void GUICalcLocation( gui_rect *rect, gui_coord *pos, gui_coord *size,
                      HWND parent )
{
    WPI_RECT    r;
    GUI_RECTDIM left, top, right, bottom;

    if( parent == NULLHANDLE ) {
        parent = HWND_DESKTOP;
    }
    pos->x = rect->x;
    pos->y = rect->y;
    size->x = rect->width;
    size->y = rect->height;
    if( parent == HWND_DESKTOP ) {
        GUIScaleToScreen( pos );
    } else {
        GUIScaleToScreenR( pos );
        _wpi_getclientrect( parent, &r );
        _wpi_getrectvalues( r, &left, &top, &right, &bottom );
        pos->x += left;
        pos->y += top;
    }
    GUIScaleToScreenR( size );

    pos->y = _wpi_cvtc_y_size_plus1( parent, pos->y, size->y );
}
コード例 #3
0
ファイル: guiscrol.c プロジェクト: Azarien/open-watcom-v2
static void Scrl( p_gadget gadget, gui_ord scroll_pos, bool scale,
                  void (*fn)( p_gadget, int ) )
{
    gui_coord coord;
    gui_ord   pos;

    if( gadget != NULL ) {
        if( scale ) {
            if( gadget->dir == VERTICAL ) {
                coord.y  = scroll_pos;
            } else {
                coord.x = scroll_pos;
            }
            GUIScaleToScreenR( &coord );
            if( gadget->dir == VERTICAL ) {
                pos  = coord.y;
            } else {
                pos = coord.x;
            }
            if( ( pos == 0 ) && ( scroll_pos != 0 ) ) {
                pos++;
            }
            scroll_pos = pos;
        }
        (*fn)( gadget, scroll_pos );
    }
}
コード例 #4
0
ファイル: guistrin.c プロジェクト: ABratovic/open-watcom-v2
extern gui_ord GUIGetStringPos( gui_window *wnd, gui_ord indent,
                                const char *string, int mouse_x )

{
    gui_coord diff;
    int       guess;
    int       length;
    int       curr;
    int       new_curr;
    bool      got_new;

    if( indent > mouse_x ) {
        return( GUI_NO_COLUMN );
    }

    got_new = GUIGetTheDC( wnd );

    diff.x = mouse_x - indent;
    GUIScaleToScreenR( &diff );
    length = strlen( string );
    guess = length;
    curr = GUIGetTextExtentX( wnd, string, guess );
    if( curr < diff.x ) {
        return( DoReturn( GUI_NO_COLUMN, wnd, got_new ) );
    }
    if( curr == diff.x ) {
        return( DoReturn( (gui_ord)guess, wnd, got_new ) );
    }
    guess = diff.x * (long)length / curr;
    curr = GUIGetTextExtentX( wnd, string, guess );
    if( curr == diff.x ) {
        return( DoReturn( (gui_ord)guess, wnd, got_new ) );
    }
    if( curr < diff.x ) {
        guess++;
    } else {
        guess--;
    }
    for( ; ; ) {
        new_curr = GUIGetTextExtentX( wnd, string, guess );

        if( new_curr == diff.x ) {
            return( DoReturn( (gui_ord) guess, wnd, got_new ) );
        }
        if( ( new_curr < diff.x ) && ( curr > diff.x ) ) {
            return( DoReturn( (gui_ord)guess, wnd, got_new ) );
        }
        if( ( new_curr > diff.x ) && ( curr < diff.x ) ) {
            return( DoReturn( (gui_ord)guess - 1, wnd, got_new ) );
        }
        if( new_curr < diff.x ) {
            guess++;
        } else {
            guess--;
        }
        curr = new_curr;
    }
}
コード例 #5
0
ファイル: guistat.c プロジェクト: Azarien/open-watcom-v2
static void CalcStatusRect( gui_window *wnd, gui_ord x, gui_ord height,
                            WPI_RECT *rect )
{
    gui_text_metrics    metrics;
    gui_coord           size;
    gui_coord           pos;

    pos.x = x;
    GUIScaleToScreenR( &pos );
    if( height == 0 ) {
        GUIGetTextMetrics( wnd, &metrics );
        size.y = metrics.max.y;
    } else {
        size.y = height;
    }
    GUIScaleToScreenR( &size );
    if( height == 0 ) {
        size.y += TOTAL_VERT + 2; /* windows is 2 pixels higher than client */
    }
    SetStatusRect( wnd->root, rect, pos.x, size.y );
}
コード例 #6
0
ファイル: guixtext.c プロジェクト: Azarien/open-watcom-v2
bool GUISetHorizontalExtent( gui_window *wnd, gui_ctl_id id, int extent )
{
#ifndef __OS2_PM__
    gui_coord   coord;

    coord.x = extent;
    GUIScaleToScreenR( &coord );
    GUIToComboList( wnd, id, LB_SETHORIZONTALEXTENT, LB_SETHORIZONTALEXTENT,
                    coord.x, (WPI_PARAM2)NULL, (WPI_MRESULT)NULL );
    return( true );
#else
    wnd = wnd;
    id = id;
    extent = extent;
    return( false );
#endif
}
コード例 #7
0
ファイル: guitool.c プロジェクト: bhanug/open-watcom-v2
bool GUIXCreateToolBarWithTips( gui_window *wnd, bool fixed, gui_ord height,
                                int num_toolbar_items, gui_toolbar_struct *toolinfo,
                                bool excl, gui_colour_set *plain,
                                gui_colour_set *standout, gui_rect *float_pos,
                                bool use_tips )
{
    gui_coord           size;
    gui_coord           pos;
    HWND                parent;
    HWND                toolhwnd;
    toolbarinfo         *tbar;
    int                 i;
    TOOLITEMINFO        info;
    int                 fixed_height;
    int                 fixed_width;
    int                 adjust_amount;
    int                 width;
    int                 new_right;
    int                 bm_h;
    int                 bm_w;
    GUI_RECTDIM         left, top, right, bottom;
    int                 h;

    excl = excl;
    plain = plain;
    standout = standout;
    fixed_height = 0;
    fixed_width = 0;
    if( ( wnd == NULL ) || ( num_toolbar_items < 1 ) || ( toolinfo == NULL ) ||
        ( wnd->hwnd == NULLHANDLE ) || ( wnd->root == NULLHANDLE ) ) {
        return( false );
    }
    if( wnd->tbinfo != NULL ) {
        GUICloseToolBar( wnd );
    }
    tbar = wnd->tbinfo = (toolbarinfo *)GUIMemAlloc( sizeof( toolbarinfo ) );
    if( tbar == NULL ) {
        return( false );
    }
    memset( tbar, 0, sizeof( toolbarinfo ) );
    parent = wnd->root;
    tbar->fixedrect = wnd->hwnd_client_rect;
    tbar->bitmaps = (HBITMAP *)GUIMemAlloc( num_toolbar_items * sizeof( HBITMAP ) );
    if( tbar->bitmaps == NULL ) {
        GUIMemFree( tbar );
        wnd->tbinfo = NULL;
        return( false );
    }
    for( i = 0; i < num_toolbar_items; i++ ) {
        tbar->bitmaps[i] = _wpi_loadbitmap( GUIResHInst,
                                _wpi_makeintresource( toolinfo[i].bitmap ) );
        if( height == 0 ) {
            _wpi_getbitmapdim( tbar->bitmaps[i], &bm_w, &bm_h );
            if( bm_h > fixed_height ) {
                fixed_height = bm_h;
            }
            if( bm_w > fixed_width ) {
                fixed_width = bm_w;
            }
        }
    }
    tbar->info.border_size.x = BORDER_AMOUNT;
    tbar->info.border_size.y = BORDER_AMOUNT;
    /* space for border and space before border */
    adjust_amount = 2*(_wpi_getsystemmetrics( SM_CYBORDER )+BORDER_AMOUNT);
    if( height == 0 ) { /* maintian # of pixels in bitmap */
        height = fixed_height + adjust_amount + OUTLINE_AMOUNT;
        width = fixed_width + OUTLINE_AMOUNT;
    } else {
        /* only height of windows given, make bitmaps square */
        size.x = 0;
        size.y = height - 2;
        GUIScaleToScreenR( &size );
        height = size.y;
        width = size.y;
    }

    _wpi_getrectvalues( tbar->fixedrect, &left, &top, &right, &bottom );
    h      = _wpi_getheightrect( tbar->fixedrect );
    bottom = _wpi_cvth_y_plus1( height, h );
    top    = _wpi_cvth_y_plus1( top, h );
    _wpi_setwrectvalues( &tbar->fixedrect, left, top, right, bottom );
    height -= adjust_amount; /* leaving just button size */
    tbar->info.button_size.x = width;
    tbar->info.button_size.y = height;
    bottom = height + BORDER_AMOUNT * 2 +
             _wpi_getsystemmetrics( SM_CYCAPTION ) +
             2 * ( _wpi_getsystemmetrics( SM_CYFRAME ) -
                   _wpi_getsystemmetrics( SM_CYBORDER ) );
    bottom = _wpi_cvth_y_plus1( bottom, h );
#ifdef __OS2_PM__
    bottom -= 2;
#endif
    new_right = width * num_toolbar_items -
                (num_toolbar_items - 1) * tbar->info.border_size.x +
                left + 2 * _wpi_getsystemmetrics( SM_CXFRAME ) +
                BORDER_AMOUNT * 2;
    if( new_right < right ) {
        right = new_right;
    }

    _wpi_setwrectvalues( &tbar->floatrect, left, top, right, bottom );
    _wpi_mapwindowpoints( parent, HWND_DESKTOP, (WPI_PPOINT)&tbar->floatrect, 2 );

    if( fixed ) {
        tbar->info.area = tbar->fixedrect;
        tbar->info.style = TOOLBAR_FIXED_STYLE;
    } else {
        if( float_pos != NULL ) {
            GUICalcLocation( float_pos, &pos, &size, parent );
            _wpi_setwrectvalues( &tbar->floatrect, pos.x, pos.y,
                                 pos.x + size.x, pos.y + size.y );
            _wpi_mapwindowpoints( parent, HWND_DESKTOP, (WPI_PPOINT)&tbar->floatrect, 2 );
        }
        tbar->info.area = tbar->floatrect;
        tbar->info.style = TOOLBAR_FLOAT_STYLE;
    }

    tbar->info.hook = guiToolBarProc;
    tbar->info.helphook = guiToolBarHelp;
    tbar->info.background = 0;
    tbar->info.foreground = 0;
    tbar->num = num_toolbar_items;
    tbar->info.is_fixed = fixed;
    tbar->info.use_tips = use_tips;

    tbar->hdl = ToolBarInit( parent );

    ToolBarDisplay( tbar->hdl, &tbar->info );

    GUIResizeBackground( wnd, true );

    for( i = 0; i < num_toolbar_items; i++ ) {
        info.u.bmp = tbar->bitmaps[i];
        info.id = toolinfo[i].id;
        info.flags = 0;
        if( use_tips && toolinfo[i].tip != NULL ) {
            strncpy( info.tip, toolinfo[i].tip, MAX_TIP );
        } else {
            info.tip[0] = '\0';
        }
        ToolBarAddItem( tbar->hdl, &info );
    }
    toolhwnd = ToolBarWindow( tbar->hdl );
    _wpi_showwindow( toolhwnd, SW_SHOWNORMAL );
    _wpi_updatewindow( toolhwnd );
    return( true );
}
コード例 #8
0
ファイル: guidrawr.c プロジェクト: Azarien/open-watcom-v2
static bool DrawRect( gui_window *wnd, gui_rect *rect, WPI_COLOUR colour,
                      bool fill, bool outline )
{
    WPI_RECT    wnd_rect;
    gui_coord   pos;
    gui_coord   size;
    HBRUSH      brush;
    int         hscroll;
    int         vscroll;
    int         win_height;

    if( ( rect->width == 0 ) || ( rect->height == 0 ) ) {
        return( false );
    }

    if( GUI_DO_VSCROLL( wnd ) ) {
        vscroll = GUIGetScrollPos( wnd, SB_VERT );
    } else {
        vscroll = 0;
    }

    if( GUI_DO_HSCROLL( wnd ) ) {
        hscroll = GUIGetScrollPos( wnd, SB_HORZ );
    } else {
        hscroll = 0;
    }

    win_height = _wpi_getheightrect( wnd->hwnd_client_rect );

    pos.x = rect->x;
    pos.y = rect->y;
    size.x = rect->width;
    if( rect->width < 0 ) {
        pos.x += rect->width;
        size.x *= -1;
    }
    size.y = rect->height;
    if( rect->height < 0 ) {
        pos.y += rect->height;
        size.y *= -1;
    }

    GUIScaleToScreenR( &pos );
    GUIScaleToScreenR( &size );

    pos.x -= hscroll;
    pos.y -= vscroll;

    pos.y  = _wpi_cvth_y_size_plus1( pos.y, win_height, size.y );

    _wpi_setrectvalues( &wnd_rect, pos.x, pos.y, pos.x + size.x, pos.y + size.y );
    if( GUIIsRectInUpdateRect( wnd, &wnd_rect ) ) {
        brush = _wpi_createsolidbrush( colour );
        if( fill ) {
            _wpi_fillrect( wnd->hdc, &wnd_rect, colour, brush );
        }
        if( outline ) {
            _wpi_borderrect( wnd->hdc, &wnd_rect, brush, colour, colour );
        }
        _wpi_deletebrush( brush );
    }
    return( true );
}
コード例 #9
0
ファイル: guidrawr.c プロジェクト: Azarien/open-watcom-v2
static bool DrawLine( gui_window *wnd, gui_point *start, gui_point *end,
                      gui_line_styles style, gui_ord thickness,
                      WPI_COLOUR colour )
{
    gui_point   my_start;
    gui_point   my_end;
    HPEN        pen;
    int         win_style;
    gui_coord   coord;
    HPEN        old_pen;
    int         hscroll;
    int         vscroll;
    WPI_POINT   pt;
    int         win_height;

    my_start = *start;
    my_end = *end;
    GUIScaleToScreenRPt( &my_start );
    GUIScaleToScreenRPt( &my_end );
    if( GUI_DO_VSCROLL( wnd ) ) {
        vscroll = GUIGetScrollPos( wnd, SB_VERT );
    } else {
        vscroll = 0;
    }
    if( GUI_DO_HSCROLL( wnd ) ) {
        hscroll = GUIGetScrollPos( wnd, SB_HORZ );
    } else {
        hscroll = 0;
    }
    switch( style ) {
    case GUI_PEN_SOLID :
        win_style = PS_SOLID;
        coord.x = thickness;
        GUIScaleToScreenR( &coord );
        break;
    case GUI_PEN_DASH :
        coord.x = 1;
        win_style = PS_DASH;
        break;
    case GUI_PEN_DOT :
        coord.x = 1;
        win_style = PS_DOT;
        break;
    case GUI_PEN_DASHDOT :
        coord.x = 1;
        win_style = PS_DASHDOT;
        break;
    case GUI_PEN_DASHDOTDOT :
        coord.x = 1;
        win_style = PS_DASHDOTDOT;
        break;
    default:
        coord.x = 0;
        win_style = 0;
        break;
    }
    pen = _wpi_createpen( win_style, coord.x, colour );

    old_pen = _wpi_selectpen( wnd->hdc, pen );

    win_height = _wpi_getheightrect( wnd->hwnd_client_rect );

    pt.x = my_start.x - hscroll;
    pt.y = my_start.y - vscroll;
    pt.y = _wpi_cvth_y_plus1( pt.y, win_height );
    _wpi_movetoex( wnd->hdc, &pt, &pt );

    pt.x = my_end.x - hscroll;
    pt.y = my_end.y - vscroll;
    pt.y = _wpi_cvth_y_plus1( pt.y, win_height );
    _wpi_lineto( wnd->hdc, &pt );

    if( old_pen != NULLHANDLE ) {
        _wpi_getoldpen( wnd->hdc, old_pen );
    }

    _wpi_deletepen( pen );

    return( true );
}
コード例 #10
0
void GUIDrawTextBitmapRGB( gui_window *wnd, const char *text,
                            size_t length, int height, gui_coord *pos,
                            WPI_COLOUR fore, WPI_COLOUR back, gui_ord extentx,
                            bool draw_extent, int bitmap )
{
    int         nDrawX, nDrawY;
    UINT        lenx;
    HBRUSH      brush;
    HBRUSH      old_brush;
    HPEN        pen;
    HPEN        old_pen;
    int         old_rop;
    size_t      num_chars;
    WPI_RECT    rect;
    gui_coord   indent;
    int         hscroll_pos;
    gui_coord   extent;
    WPI_COLOUR  colour;
    GUI_RECTDIM left, top, right, bottom;
    GUI_RECTDIM paint_left, paint_top, paint_right, paint_bottom;
    WPI_RECT    paint_rect;
    WPI_RECT    draw_rect;
    //draw_cache        dcache;

    if( ( wnd->hdc == NULLHANDLE ) || ( wnd->ps == NULL ) ||
        ( ( text == NULL ) && ( bitmap == 0 ) ) ||
        ( ( bitmap != 0 ) && ( height == 0 ) ) ) {
        return;
    }
    old_rop = 0;
    old_brush = (HBRUSH)NULL;
    brush = (HBRUSH)NULL;
    old_pen = (HPEN)NULL;
    pen = (HPEN)NULL;
    GUIGetMetrics( wnd );
    if( !bitmap ) {
        height = AVGYCHAR(GUItm);
    }
    rect = wnd->hwnd_client;
    _wpi_getrectvalues( rect, &left, &top, &right, &bottom);
    _wpi_getpaintrect( wnd->ps, &paint_rect );
    _wpi_getwrectvalues( paint_rect, &paint_left, &paint_top, &paint_right,
                         &paint_bottom );
    top = paint_top / height * height;
    bottom = ( paint_bottom + height - 1) / height * height;

    if( GUI_DO_HSCROLL( wnd ) ) {
        hscroll_pos = GUIGetScrollPos( wnd, SB_HORZ );
    } else {
        hscroll_pos = 0;
    }

    if( bitmap == 0 ) {
        num_chars = strlen( text );
        if( num_chars > length ) {
            num_chars = length;
        }
    }

    indent.x = pos->x;
    indent.y = pos->y;
    GUIScaleToScreenR( &indent );
    nDrawY = indent.y;
    if( GUI_DO_VSCROLL( wnd ) ) {
        nDrawY -= GUIGetScrollPos( wnd, SB_VERT );
    }
    nDrawX = left;
    nDrawX += ( indent.x - hscroll_pos );

    if( bitmap > 0 ) {
        lenx = length ;
    } else {
        lenx = GUIGetTextExtentX( wnd, text, num_chars );
    }

    if( draw_extent ) {
        /* blanks out some portion of rest of the line */
        if( extentx != GUI_NO_COLUMN ) {
            extent.x = extentx;
            GUIScaleToScreen( &extent );
            right = nDrawX + extent.x;
        }
    } else {
        right = nDrawX + lenx;
    }
    nDrawY = _wpi_cvth_y_size( nDrawY, _wpi_getheightrect(wnd->hwnd_client), height );

    _wpi_setrectvalues( &draw_rect, nDrawX, nDrawY, right, nDrawY+height );
    if( GUIIsRectInUpdateRect( wnd, &draw_rect ) ) {
        colour = _wpi_getnearestcolor( wnd->hdc, back );
        brush = _wpi_createsolidbrush( colour );
        pen = _wpi_createpen( PS_SOLID, 1, colour );
        if( pen == NULLHANDLE ) {
            GUIError(LIT( Pen_Failed ));
        }
        old_brush = _wpi_selectbrush( wnd->hdc, brush );
        old_pen = _wpi_selectpen( wnd->hdc, pen );
#ifdef __OS2_PM__
        _wpi_rectangle( wnd->hdc, nDrawX, nDrawY+1, right, nDrawY + height - 1 );
#else
        _wpi_rectangle( wnd->hdc, nDrawX, nDrawY, right, nDrawY + height);
#endif

        /* if visible even with scrolling */
        if( nDrawX < ( paint_right + hscroll_pos ) ) {
            if( bitmap > 0 ) {
                GUIDrawBitmap( bitmap, wnd->hdc, nDrawX, nDrawY, colour);
            } else {
#ifdef __OS2_PM__
                nDrawY += _wpi_metricdescent( GUItm );
#endif
                old_rop = _wpi_setrop2( wnd->hdc, R2_COPYPEN );
                SetText( wnd, fore, back );
                _wpi_textout( wnd->hdc, nDrawX, nDrawY, text, num_chars );
            }
        }
        /* restore old resources */
        if( old_rop != 0 ) {
            _wpi_setrop2( wnd->hdc, old_rop );
        }
        if( old_brush != (HBRUSH)NULL ) {
            _wpi_getoldbrush( wnd->hdc, old_brush );
        }
        if( brush != (HBRUSH)NULL ) {
            _wpi_deletebrush( brush );
        }
        if( old_pen != (HPEN)NULL ) {
            _wpi_getoldpen( wnd->hdc, old_pen );
        }
        if( pen != (HPEN)NULL ) {
            _wpi_deletepen( pen );
        }
    }
}
コード例 #11
0
void GUIXDrawText( gui_window *wnd, const char *text, size_t length, gui_coord *in_pos,
                  gui_attr attr, gui_ord extentx, bool draw_extent )
{
    int         vscroll;        /* vertical scroll adjust amount */
    int         hscroll;        /* horizontal scroll adjust amount */
    size_t      my_length;      /* actual length of text (may be > length) */
    gui_coord   my_pos;         /* pos in screen coords */
    int         pos;            /* position to draw on VSCREEN */
    int         col;            /* index into string */
    gui_coord   extent;
    SAREA       area;
    int         width;
    int         frame_adjust;

    if( attr >= wnd->num_attrs ) {
        return;
    }
    if( !( wnd->style & GUI_VISIBLE ) ) {
         return;
    }

    if( wnd->style & GUI_NOFRAME ) {
        frame_adjust = 0;
    } else {
        frame_adjust = 1;
    }

    my_pos.x = in_pos->x;
    my_pos.y = in_pos->y;
    GUIScaleToScreenR( &my_pos );

    /* adjust for scrolling */
    vscroll = 0;
    if( ( wnd->vgadget != NULL ) && ( !GUI_VSCROLL_EVENTS_SET( wnd ) ) ) {
        vscroll += wnd->vgadget->pos;
    }
    hscroll = 0;
    if( ( wnd->hgadget != NULL ) && !GUI_HSCROLL_EVENTS_SET( wnd ) ) {
        hscroll += wnd->hgadget->pos;
    }

    if( ( my_pos.y - vscroll + frame_adjust ) < frame_adjust ) {
        /* row to draw is not visible with vertical scrolling */
        return;
    }

    if( text != NULL ) {
        my_length = strlen( text );
        if( my_length < length ) {
            length = my_length;
        }
    } else {
        my_length = 0;
    }

    /* if text shows even with scrolling */
    if( ( my_pos.x + length ) > hscroll ) {
        pos = frame_adjust;  /* position on VSCREEN */
        col = 0;             /* index into curr string */

        /* start of text in dirty region */
        if( ( ( wnd->dirty.col - 1 ) <= ( my_pos.x - hscroll ) ) &&
            ( my_pos.x >= hscroll ) ) {
            pos += ( my_pos.x - hscroll );
        } else {
            /* start of text to left of dirty region */
            pos += wnd->dirty.col - 1;
            if( my_pos.x < hscroll ) {
                /* start of text scrolled off screen */
                col    += ( hscroll - my_pos.x + wnd->dirty.col - 1 );
                length -= ( hscroll - my_pos.x + wnd->dirty.col - 1 );
            } else {
                /* start of text visible but to left of dirty region */
                col    += ( wnd->dirty.col  - 1 + hscroll - my_pos.x );
                length -= ( wnd->dirty.col  - 1 + hscroll - my_pos.x );
            }
        }
        /* should deal with decreasing length due to text off screen
            to right */
        if( ( length > 0 ) &&
            ( ( col - hscroll ) < ( wnd->dirty.col + wnd->dirty.width ) ) ) {
            if( ( pos + length ) > ( wnd->dirty.col + wnd->dirty.width ) ) {
                length = wnd->dirty.col + wnd->dirty.width - pos;
            }
            if( length > 0 ) {
                char        *p;
                const char  *cp;

                for( cp = text; cp < text+col; cp += GUICharLen( *cp ) ) ;
                if( cp != text + col ) {
                    p = alloca( length );
                    cp = memcpy( p, text+col, length );
                    p[0] = ' ';
                }
                uivtextput( &wnd->screen, my_pos.y - vscroll + frame_adjust,
                            pos, wnd->colours[attr], cp, length );
            } else {
                length = 0;
            }
        } else {
            length = 0;
        }
    } else {
        pos = -length + 1; /* so (pos+length) will be 1 for drawing extent */
    }
    if( draw_extent ) {
        if( extentx == GUI_NO_COLUMN ) {
            /* this is the most that will be covered.  It will be adjust for
               starting position and dirty rect */
            extentx = wnd->use.width;
        } else {
            /* record total width user wants to cover, adjusting for
             * portion not visible due to scrolling scrolling
             */
            extent.x = extentx + in_pos->x;
            GUIScaleToScreenR( &extent );
            extentx = extent.x - hscroll;
        }

        if( ( pos + length ) <= extentx ) {
            area.row = my_pos.y - vscroll + frame_adjust;
            area.height = 1;
            area.col = pos + length;
            /* adjust left border for dirty area */
            if( area.col < wnd->dirty.col ) {
                area.col = wnd->dirty.col;
            }
            width = extentx - area.col + 1;
            /* adjust right border for dirty area */
            if( ( area.col + width ) > ( wnd->dirty.col + wnd->dirty.width ) ) {
                width = wnd->dirty.width + wnd->dirty.col - area.col;
            }
            if( width > 0 )  {
                area.width = width;
                uivfill( &wnd->screen, area, wnd->colours[attr], ' ' );
            }
        }
    }
}