From 64193ed7f2479088ea89ef3622bb77c56638e283 Mon Sep 17 00:00:00 2001 From: Jiri Malak Date: Fri, 26 Jul 2024 21:10:50 +0200 Subject: [PATCH] gui: a little optimize code and do it more transparent --- bld/gui/ui/c/guixdraw.c | 16 ++++++++-------- bld/gui/ui/c/guixutil.c | 2 +- bld/gui/ui/h/guixdraw.h | 3 ++- bld/gui/win/c/guiscrol.c | 3 +-- bld/gui/win/c/guixdraw.c | 10 +++++----- bld/gui/win/c/guixutil.c | 6 +----- 6 files changed, 18 insertions(+), 22 deletions(-) diff --git a/bld/gui/ui/c/guixdraw.c b/bld/gui/ui/c/guixdraw.c index 27ae99def8..0d0d5723b7 100644 --- a/bld/gui/ui/c/guixdraw.c +++ b/bld/gui/ui/c/guixdraw.c @@ -2,7 +2,7 @@ * * Open Watcom Project * -* Copyright (c) 2002-2021 The Open Watcom Contributors. All Rights Reserved. +* Copyright (c) 2002-2024 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -322,10 +322,10 @@ static void WndClean( gui_window *wnd ) } /* - * GUIWndRfrshArea -- refresh a portion of the use are of the screen + * GUIWndRefreshArea -- refresh a portion of the use are of the screen */ -void GUIWndRfrshArea( gui_window *wnd, SAREA *area ) +void GUIWndRefreshArea( gui_window *wnd, SAREA *area ) { gui_control *control; gui_row_num row_num; @@ -400,14 +400,14 @@ void GUIAPI GUIWndUpdate( gui_window *wnd ) if( !GUIIsOpen( wnd ) ) { return; } - if( GUI_WND_VISIBLE( wnd ) && GUI_WND_MINIMIZED( wnd ) ) { - GUIDrawIcon( wnd ); - } else { - if( GUI_WND_VISIBLE( wnd ) ) { + if( GUI_WND_VISIBLE( wnd ) ) { + if( GUI_WND_MINIMIZED( wnd ) ) { + GUIDrawIcon( wnd ); + } else { DrawFrame( wnd ); DrawGadget( wnd, wnd->vgadget, VSCROLL_INVALID ); DrawGadget( wnd, wnd->hgadget, HSCROLL_INVALID ); + GUIWndRefreshArea( wnd, &wnd->dirty ); } - GUIWndRfrshArea( wnd, &wnd->dirty ); } } diff --git a/bld/gui/ui/c/guixutil.c b/bld/gui/ui/c/guixutil.c index 6b4ecd2638..a5fcd5d479 100644 --- a/bld/gui/ui/c/guixutil.c +++ b/bld/gui/ui/c/guixutil.c @@ -378,7 +378,7 @@ bool GUIInArea( ORD row, ORD col, SAREA *area ) void GUIDirtyArea( gui_window *wnd, SAREA *area ) { wnd->flags |= CONTENTS_INVALID; - GUIWndRfrshArea( wnd, area ); + GUIWndRefreshArea( wnd, area ); uirefresh(); } diff --git a/bld/gui/ui/h/guixdraw.h b/bld/gui/ui/h/guixdraw.h index 47e4098b15..481e5b04da 100644 --- a/bld/gui/ui/h/guixdraw.h +++ b/bld/gui/ui/h/guixdraw.h @@ -2,6 +2,7 @@ * * Open Watcom Project * +* Copyright (c) 2024 The Open Watcom Contributors. All Rights Reserved. * Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved. * * ======================================================================== @@ -30,4 +31,4 @@ ****************************************************************************/ -extern void GUIWndRfrshArea( gui_window *, SAREA * ); +extern void GUIWndRefreshArea( gui_window *, SAREA * ); diff --git a/bld/gui/win/c/guiscrol.c b/bld/gui/win/c/guiscrol.c index 4ccd75cf6a..8ac7c15bf1 100644 --- a/bld/gui/win/c/guiscrol.c +++ b/bld/gui/win/c/guiscrol.c @@ -348,12 +348,11 @@ static void DoSetScroll( gui_window *wnd, int bar, bool range_set, if( !chars ) { *p_range = range + screen_size; } - GUISetScrollRange( wnd, bar, 0, range, true ); } else { range = screen_size + GUIGetScrollPos( wnd, bar ); *p_range = range + screen_size; - GUISetScrollRange( wnd, bar, 0, range, true ); } + GUISetScrollRange( wnd, bar, 0, range, true ); } /* diff --git a/bld/gui/win/c/guixdraw.c b/bld/gui/win/c/guixdraw.c index 2579e8a339..6c3e531e8a 100644 --- a/bld/gui/win/c/guixdraw.c +++ b/bld/gui/win/c/guixdraw.c @@ -78,6 +78,7 @@ static void GUIDrawTextBitmapRGB( gui_window *wnd, const char *text, size_t num_chars; WPI_RECT wpi_rect; guix_ord hscroll_pos; + guix_ord vscroll_pos; WPI_COLOUR colour; WPI_RECTDIM left, top, right, bottom; WPI_RECTDIM paint_left, paint_top, paint_right, paint_bottom; @@ -114,16 +115,15 @@ static void GUIDrawTextBitmapRGB( gui_window *wnd, const char *text, top = paint_top / height * height; bottom = ( paint_bottom + height - 1 ) / height * height; + hscroll_pos = 0; if( GUI_DO_HSCROLL( wnd ) ) { hscroll_pos = GUIGetScrollPos( wnd, SB_HORZ ); - } else { - hscroll_pos = 0; } - - nDrawY = GUIScaleToScreenV( pos->y ); + vscroll_pos = 0; if( GUI_DO_VSCROLL( wnd ) ) { - nDrawY -= GUIGetScrollPos( wnd, SB_VERT ); + vscroll_pos = GUIGetScrollPos( wnd, SB_VERT ); } + nDrawY = GUIScaleToScreenV( pos->y ) - vscroll_pos; nDrawX = left + GUIScaleToScreenH( pos->x ) - hscroll_pos; if( draw_extent ) { diff --git a/bld/gui/win/c/guixutil.c b/bld/gui/win/c/guixutil.c index 09709f65ee..2fbdc23a8f 100644 --- a/bld/gui/win/c/guixutil.c +++ b/bld/gui/win/c/guixutil.c @@ -538,11 +538,7 @@ void GUISetScrollRange( gui_window *wnd, int bar, int min, int max, bool redraw { if( ChangeScrollRange( wnd, bar, max - min ) ) { _wpi_setscrollrange( GUIGetParentFrameHWND( wnd ), bar, min, max, ( redraw ) ? TRUE : FALSE ); - if( bar == SB_HORZ ) { - GUIRedrawScroll( wnd, SB_HORZ, redraw ); - } else { - GUIRedrawScroll( wnd, SB_VERT, redraw ); - } + GUIRedrawScroll( wnd, bar, redraw ); } }