Skip to content

Commit

Permalink
gui: a little optimize code and do it more transparent
Browse files Browse the repository at this point in the history
  • Loading branch information
jmalak committed Jul 26, 2024
1 parent 70a0c43 commit 64193ed
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 22 deletions.
16 changes: 8 additions & 8 deletions bld/gui/ui/c/guixdraw.c
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
* ========================================================================
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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 );
}
}
2 changes: 1 addition & 1 deletion bld/gui/ui/c/guixutil.c
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down
3 changes: 2 additions & 1 deletion bld/gui/ui/h/guixdraw.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
* ========================================================================
Expand Down Expand Up @@ -30,4 +31,4 @@
****************************************************************************/


extern void GUIWndRfrshArea( gui_window *, SAREA * );
extern void GUIWndRefreshArea( gui_window *, SAREA * );
3 changes: 1 addition & 2 deletions bld/gui/win/c/guiscrol.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
}

/*
Expand Down
10 changes: 5 additions & 5 deletions bld/gui/win/c/guixdraw.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 ) {
Expand Down
6 changes: 1 addition & 5 deletions bld/gui/win/c/guixutil.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
}
}

Expand Down

0 comments on commit 64193ed

Please sign in to comment.