guixutil.c
来自「开放源码的编译器open watcom 1.6.0版的源代码」· C语言 代码 · 共 722 行 · 第 1/2 页
C
722 行
GUIMDIDelete( wnd );
if( GUICurrWnd == wnd ) {
GUICurrWnd = NULL;
}
GUIFreePopupList( wnd );
}
GUIDeleteFromList( wnd );
/* If the window being deleted was the current window, choose a new
* window to bring to front. Don't do this if the window that's being
* destroyed is being destroyed because it's parent is being destroyed
* (ie never got WM_CLOSE so DOING_CLOSE isn't set).
*/
if( !dialog && ( wnd->flags & DOING_CLOSE ) && ( GUICurrWnd == NULL ) &&
!GUIIsParentADialog( wnd ) ) {
// if the root window has received a WM_DESTROY then just run away
root = GUIGetRootWindow();
if( root && !( root->flags & DOING_DESTROY ) ) {
GUIBringNewToFront( wnd );
}
}
if( wnd->hdc != (WPI_PRES)NULL ) {
_wpi_releasepres( wnd->hwnd, wnd->hdc );
wnd->hdc = NULL;
}
#ifdef __OS2_PM__
GUIFreeWndPaintHandles( wnd, TRUE );
if( wnd->root_pinfo.normal_pres != (WPI_PRES)NULL ) {
_wpi_deleteos2normpres( wnd->root_pinfo.normal_pres );
wnd->root_pinfo.normal_pres = (WPI_PRES)NULL;
}
if( wnd->hwnd_pinfo.normal_pres != (WPI_PRES)NULL ) {
_wpi_deleteos2normpres( wnd->hwnd_pinfo.normal_pres );
wnd->hwnd_pinfo.normal_pres = (WPI_PRES)NULL;
}
#endif
GUIMemFree( wnd );
}
bool GUIScrollOn( gui_window *wnd, int bar )
{
if( ( bar == SB_VERT ) && GUI_VSCROLL_ON( wnd ) ) {
return( TRUE );
}
if( ( bar == SB_HORZ ) && GUI_HSCROLL_ON( wnd ) ) {
return( TRUE );
}
return( FALSE );
}
void GUISetRowCol( gui_window *wnd, gui_coord *size )
{
gui_coord my_size;
if( size == NULL ) {
my_size.y = _wpi_getheightrect( wnd->hwnd_client );
my_size.x = _wpi_getwidthrect( wnd->hwnd_client );
} else {
my_size = *size;
}
GUIToText( &my_size, wnd );
wnd->num_rows = my_size.y;
wnd->num_cols = my_size.x;
}
/*
* GUIInvalidateResize -- invalidate the bottom portion of the window that
* may now contain a line of text
*/
void GUIInvalidateResize( gui_window *wnd )
{
WPI_RECT rect;
GUI_RECTDIM left, top, right, bottom;
if( ( wnd->flags & NEEDS_RESIZE_REDRAW ) &&
( wnd->old_rows != wnd->num_rows ) ) {
_wpi_getrectvalues( wnd->hwnd_client, &left, &top, &right, &bottom );
GUIGetMetrics( wnd );
if( wnd->old_rows < wnd->num_rows ) {
/* window grew */
top = wnd->old_rows * AVGYCHAR( GUItm );
} else {
/* window shrunk */
top = wnd->num_rows * AVGYCHAR( GUItm );
}
_wpi_setrectvalues( &rect, left, top, right, bottom );
_wpi_invalidaterect( wnd->hwnd, &rect, TRUE );
wnd->flags &= ~NEEDS_RESIZE_REDRAW;
}
wnd->old_rows = wnd->num_rows;
}
WPI_MRESULT GUISendMessage( HWND hwnd, WPI_MSG msg, WPI_PARAM1 wparam,
WPI_PARAM2 lparam )
{
if( hwnd != NULLHANDLE ) {
return( _wpi_sendmessage( hwnd, msg, wparam, lparam ) );
} else {
return( 0L );
}
}
WPI_MRESULT GUISendDlgItemMessage( HWND parent, int control, WPI_MSG msg,
WPI_PARAM1 wparam, WPI_PARAM2 lparam )
{
HWND hwnd;
hwnd = _wpi_getdlgitem( parent, control );
if( hwnd != NULLHANDLE ) {
return( _wpi_sendmessage( hwnd, msg, wparam, lparam ) );
} else {
return( 0L );
}
}
void GUIMakeRelative( gui_window *wnd, WPI_POINT *pt, gui_point *point )
{
WPI_RECT rect;
GUI_RECTDIM left, top, right, bottom;
rect = wnd->hwnd_client;
_wpi_mapwindowpoints( wnd->hwnd, HWND_DESKTOP, (WPI_LPPOINT)&rect, 2 );
_wpi_getrectvalues( rect, &left, &top, &right, &bottom );
point->x = pt->x - left;
point->y = pt->y - top;
if( GUI_DO_HSCROLL( wnd ) || GUI_DO_VSCROLL( wnd ) ) {
if( GUI_DO_HSCROLL( wnd ) ) {
point->x += GUIGetScrollPos( wnd, SB_HORZ );
}
if( GUI_DO_VSCROLL( wnd ) ) {
point->y += GUIGetScrollPos( wnd, SB_VERT );
}
}
GUIScreenToScaleRPt( point );
}
HWND GUIGetScrollHWND( gui_window *wnd )
{
if( wnd == NULL ) {
return( NULL );
}
if( wnd->root != NULLHANDLE ) {
return( wnd->root );
}
return( wnd->hwnd );
}
void GUISetScrollPos( gui_window *wnd, int bar, int new, bool redraw )
{
int *pos;
redraw = redraw;
if( bar == SB_HORZ ) {
pos = &wnd->hpos;
} else {
pos = &wnd->vpos;
}
if( *pos != new ) {
*pos = new;
_wpi_setscrollpos( GUIGetParentFrameHWND( wnd ), bar, new, redraw );
}
}
int GUIGetScrollPos( gui_window *wnd, int bar )
{
if( bar == SB_HORZ ) {
return( wnd->hpos );
} else {
return( wnd->vpos );
}
}
void GUISetScrollRange( gui_window *wnd, int bar, int min, int max,
bool redraw )
{
int *old_range;
if( bar == SB_HORZ ) {
old_range = &wnd->hrange;
} else {
old_range = &wnd->vrange;
}
if( ( max - min ) != *old_range ) {
*old_range = max - min;
_wpi_setscrollrange( GUIGetParentFrameHWND( wnd ), bar, min, max, redraw );
if( bar == SB_HORZ ) {
GUIRedrawScroll( wnd, SB_HORZ, redraw );
} else {
GUIRedrawScroll( wnd, SB_VERT, redraw );
}
}
}
int GUIGetScrollRange( gui_window *wnd, int bar )
{
if( bar == SB_HORZ ) {
return( wnd->hrange );
} else {
return( wnd->vrange );
}
}
void GUISetRangePos( gui_window *wnd, int bar )
{
int range;
int pos;
range = GUIGetScrollRange( wnd, bar );
pos = GUIGetScrollPos( wnd, bar );
_wpi_setscrollrange( GUIGetParentFrameHWND( wnd ), bar, 0, range, FALSE );
_wpi_setscrollpos( GUIGetParentFrameHWND( wnd ), bar, pos, TRUE );
}
void GUIRedrawScroll( gui_window *wnd, int bar, bool redraw_now )
{
WPI_RECT rect;
WPI_RECT client;
HWND hwnd;
GUI_RECTDIM left, top, right, bottom;
GUI_RECTDIM clleft, cltop, clright, clbottom;
hwnd = GUIGetParentFrameHWND( wnd );
_wpi_getwindowrect( hwnd, &rect );
_wpi_getclientrect( hwnd, &client );
_wpi_mapwindowpoints( HWND_DESKTOP, hwnd, (WPI_LPPOINT)&rect, 2 );
_wpi_getrectvalues( rect, &left, &top, &right, &bottom );
_wpi_getrectvalues( client, &clleft, &cltop, &clright, &clbottom );
if( bar == SB_HORZ ) {
top = clbottom;
} else {
left = clright;
}
_wpi_setrectvalues( &rect, left, top, right, bottom );
GUIInvalidatePaintHandles( wnd );
_wpi_invalidaterect( hwnd, &rect, TRUE );
if( redraw_now && !( wnd->flags & NEEDS_RESIZE_REDRAW ) ) {
_wpi_updatewindow( hwnd );
}
}
HWND GUIGetParentHWND( gui_window *wnd )
{
if( wnd == NULL ) {
return( NULL );
}
if( wnd->root != NULLHANDLE ) {
return( wnd->root );
}
return( wnd->hwnd );
}
HWND GUIGetParentFrameHWND( gui_window *wnd )
{
if( wnd == NULL ) {
return( NULL );
}
if( wnd->root_frame != NULLHANDLE ) {
return( wnd->root_frame );
}
return( wnd->hwnd_frame );
}
HWND GUIGetTopParentHWND( HWND hwnd )
{
HWND curr_hwnd;
HWND parent;
curr_hwnd = hwnd;
for( ;; ) {
parent = _wpi_getparent( curr_hwnd );
if( parent == HWND_DESKTOP ) break;
curr_hwnd = parent;
}
return( curr_hwnd );
}
gui_window *GUIGetTopGUIWindow( HWND hwnd )
{
hwnd = hwnd;
return( GUIGetRootWindow() );
}
/*
* GUIGetWindow - get the gui_window associated with the hwnd
*/
gui_window *GUIGetWindow( HWND hwnd )
{
gui_window *wnd;
if( ( hwnd != NULLHANDLE ) && ( hwnd != HWND_DESKTOP ) ) {
wnd = (gui_window *)
_wpi_getwindowlong( hwnd, GUI_EXTRA_WORD * EXTRA_SIZE );
return( wnd );
}
return( NULL );
}
gui_window *GUIGetParentWindow( gui_window *wnd )
{
if( wnd != NULL ) {
return( wnd->parent );
} else {
return( NULL );
}
}
bool GUIParentHasFlags( gui_window *wnd, gui_flags flags )
{
while( wnd ) {
if( wnd->flags & flags ) {
return( TRUE );
}
wnd = GUIGetParentWindow( wnd );
}
return( FALSE );
}
gui_window *GUIGetFirstSibling( gui_window *wnd )
{
gui_window *parent;
if( wnd == NULL ) {
return( NULL );
}
parent = wnd->parent;
if( ( parent == NULL ) || ( parent->flags & IS_DIALOG ) ) {
return( NULL );
}
return( GUIFindFirstChild( parent ) );
}
WPI_FONT GUIGetSystemFont( void )
{
WPI_FONT font;
#ifdef __OS2_PM__
WPI_FONT ret;
font = NULL;
ret = _wpi_getsystemfont();
if( ret ) {
font = (WPI_FONT) GUIMemAlloc( sizeof( *font ) );
if( font ) {
*font = *ret;
}
}
#else
font = _wpi_getsystemfont();
#endif
return( font );
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?