示例#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 );
}
示例#2
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 );
}
示例#3
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 );
}
示例#4
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;
    }
}