wpi_os2.h

来自「开放源码的编译器open watcom 1.6.0版的源代码」· C头文件 代码 · 共 1,411 行 · 第 1/4 页

H
1,411
字号
/****************************************************************************
*
*                            Open Watcom Project
*
*    Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
*
*  ========================================================================
*
*    This file contains Original Code and/or Modifications of Original
*    Code as defined in and that are subject to the Sybase Open Watcom
*    Public License version 1.0 (the 'License'). You may not use this file
*    except in compliance with the License. BY USING THIS FILE YOU AGREE TO
*    ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is
*    provided with the Original Code and Modifications, and is also
*    available at www.sybase.com/developer/opensource.
*
*    The Original Code and all software distributed under the License are
*    distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
*    EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM
*    ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
*    MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR
*    NON-INFRINGEMENT. Please see the License for the specific language
*    governing rights and limitations under the License.
*
*  ========================================================================
*
* Description:  WHEN YOU FIGURE OUT WHAT THIS FILE DOES, PLEASE
*               DESCRIBE IT HERE!
*
****************************************************************************/


/*--------------------------------------------------------------------------
   FUNCTIONS
        NOTE- When adding macros to this file, be sure to append them to the
              END of the file.  This file will eventually be converted to
              a library.  The method of conversion will be from the start
              of the file to the end.
 ---------------------------------------------------------------------------*/

/************************************************************************/
/* The following macros represent Windows APIs that have corresponding  */
/* PM APIs.  Hence you may leave the API name as the Windows API and    */
/* WPI will translate it to the equivalent PM API.                      */
/************************************************************************/

    #define GetBkColor( pres ) GpiQueryBackColor( pres )

    #define lstrlen( buf ) strlen( buf )

    #define LOWORD( word ) LOUSHORT( (ULONG) word )

    #define HIWORD( word ) HIUSHORT( (ULONG) word )

    #define LPtoDP( pres, line, num ) \
        // nothing

    #define DPtoLP( pres, line, num ) \
        // nothing

    #define CopyRect( dst, src ) memcpy( (dst), (src), sizeof(WPI_RECT) )

    #define RectVisible( pres, rect ) GpiRectVisible( pres, rect )

    #define PtVisible( pres, pt ) GpiPtVisible( pres, pt )

    #define IsDlgButtonChecked( hwnd, id ) WinQueryButtonCheckstate( hwnd, id )

    #define CheckDlgButton( hwnd, id, action ) WinCheckButton( \
                                 hwnd, (USHORT) id, (USHORT) action )

    #define LoadString( inst, id, value, len ) WinLoadString( \
                                inst.hab, inst.mod_handle, (ULONG) id, (LONG) len, (PSZ) value )

    #define GetClassName( hwnd, buf, size ) WinQueryClassName( \
                                hwnd, (LONG) size, (PCH) buf )

    #define SaveDC( pres ) GpiSavePS( pres )

    #define RestoreDC( pres, pres_id ) GpiRestorePS( pres, pres_id )

    #define GetMessage( wpi_msg, hdl, first, last ) WinGetMsg( hdl.hab, wpi_msg, NULLHANDLE, first, last )

    #define PostAppMessage( hmq, msg, parm1, parm2 ) WinPostMsg( hmq, msg, (WPI_PARAM1) parm1, (WPI_PARAM2) parm2 )

    #define MessageBox( parent, text, title, style ) WinMessageBox( HWND_DESKTOP, parent, text, title, 0, style )

    #define SendMessage( hwnd, msgid, parm1, parm2 ) WinSendMsg( hwnd, \
                (WPI_MSG) msgid, (WPI_PARAM1) parm1, (WPI_PARAM2) parm2 )

    #define SendDlgItemMessage( hwnd, item, msgid, parm1, parm2 ) \
        WinSendDlgItemMsg( hwnd, (ULONG)item, (ULONG)msgid, \
                                        (WPI_PARAM1)parm1, (WPI_PARAM2)parm2 )

    #define SetDlgItemText( hwnd, item, text ) \
        WinSetDlgItemText( (HWND) hwnd, (ULONG) item, (PSZ) text )

    #define GetDlgItemText( hwnd, item, text, size ) \
        WinQueryDlgItemText( (HWND)hwnd, (ULONG)item, (LONG)size, (PSZ)text )

    #define InvalidateRect( hwnd, rect, erase ) WinInvalidateRect( hwnd, rect, erase )

    #define GetWindowTextLength( hwnd ) WinQueryWindowTextLength( hwnd )

    #define SetBkMode( pres, mode ) GpiSetBackMix( pres, mode )

    #define GetBkMode( pres, mode ) GpiQueryBackMix( pres, mode )

    #define GetFocus() PM1632WinQueryFocus( HWND_DESKTOP )

    #define SetFocus( hwnd ) WinSetFocus( HWND_DESKTOP, hwnd )

    #define GetObject( obj, len, into ) len

    #define GlobalHandle( ptr ) ptr

    #define GlobalLock( hmem ) hmem

    #define GlobalUnlock( hmem ) \
        // nothing

    #define GlobalUnlockCheck( hmem ) TRUE

    #define GlobalAlloc( flags, size ) _wpi_malloc( (size_t) size )

    #define GlobalFree( hmem ) _wpi_free( (void *) hmem )

    #define GlobalReAlloc( hmem, size, flags ) (HANDLE) _wpi_realloc( hmem, size )

    #define LocalHandle( ptr ) ptr

    #define LocalLock( hmem ) hmem

    #define LocalUnlock( hmem ) \
        // nothing

    #define LocalUnlockCheck( hmem ) TRUE

    #define LocalAlloc( flags, size ) _wpi_malloc( (size_t) size )

    #define LocalFree( hmem ) _wpi_free( (void *) hmem )

    #define LocalReAlloc(hmem, size, flags) _wpi_realloc((void *)hmem, (size_t)size)

    #define Catch( buf ) setjmp( buf )

    #define Throw( buf, error ) longjmp( buf, error )

    #define GetMenu(hframe) WinWindowFromID(hframe, FID_MENU)

extern BOOL _wpi_showwindow( HWND hwnd, int state );

    #define ShowWindow(hwnd, state) _wpi_showwindow( hwnd, state )

    #define SetWindowText( hwnd, text ) WinSetWindowText(hwnd, text)

    #define DefWindowProc(hwnd, msg, mp1, mp2) \
                                        WinDefWindowProc(hwnd, msg, mp1, mp2)

    #define DestroyWindow( hwnd ) WinDestroyWindow( hwnd )

    #define SetWindowPos(hwnd, z, x, y, cx, cy, flags) \
                        WinSetWindowPos(hwnd, z, x, y, cx, cy, flags)

extern void GetWindowRect( HWND hwnd, WPI_RECT *rect );

    #define UpdateWindow( hwnd ) WinUpdateWindow(hwnd)

    #define SetCapture( hwnd ) WinSetCapture(HWND_DESKTOP, hwnd)

    #define ReleaseCapture() WinSetCapture(HWND_DESKTOP, NULLHANDLE)

    #define SelectPalette(hps, hpal) GpiSelectPalette(hps, hpal)

    #define SetStretchBltMode( hdc, mode ) \
                // do nothing

    #define MapWindowsPoints( hfrom, hto, ppts, num ) \
                                WinMapWindowsPoints( hfrom, hto, ppts, num )

/************************************************************************/
/* The following macros macro the Windows APIs to PM APIs using the     */
/* WPI naming convention.                                               */
/************************************************************************/

    /* I'm leaving this as a macro mainly because win1632 has the point */
    /* parameter passed by value and to change this to a function would */
    /* cause a whole bunch of 'pt not assigned a value' warnings.       */
    #define WPI_MAKEPOINT( mp1, mp2, pt ) \
    { \
        POINTS  newpt; \
        newpt = (*((POINTS FAR*)&(mp1))); \
        (pt).x = newpt.x; \
        (pt).y = newpt.y; \
    }

    #define _wpi_intersectrect( inst, prdest, prsrc1, prsrc2 ) \
                      WinIntersectRect( inst.hab, prdest, prsrc1, prsrc2 )

    #define _wpi_isrectempty( inst, prect ) \
                      WinIsRectEmpty( inst.hab, prect )

    #define _wpi_lptodp( pres, line, num ) \
        // nothing

    #define _wpi_dptolp( pres, line, num ) \
        // nothing

extern void _wpi_releasepres( HWND hwnd, WPI_PRES pres );

    #define _wpi_screentoclient( hclient, ppt ) \
        WinMapWindowPoints(HWND_DESKTOP, hclient, ppt, 1)

    #define _wpi_clienttoscreen( hclient, ppt ) \
        WinMapWindowPoints(hclient, HWND_DESKTOP, ppt, 1)

    #define _wpi_mapwindowpoints( hfrom, hto, ppts, num ) \
                                WinMapWindowPoints( hfrom, hto, ppts, num )

    #define _wpi_clipcursor( rect ) \
        // nothing

    #define _wpi_unregisterclass( name, inst ) \
        // nothing

    #define _wpi_freeprocinstance( proc ) \
        // nothing

    #define _wpi_setinst( class, inst ) \
        // nothing

    #define _wpi_setclassproc( class, proc ) (class)->lpfnWndProc = (PFNWP)proc

    #define _wpi_setclassinst( class, inst ) (class)->hInstance = inst

    #define _wpi_setclassname( class, name ) (class)->lpszClassName = name

    #define _wpi_setclassstyle( class, wpi_style ) (class)->style = wpi_style

    #define _wpi_setclassbackground( class, background ) \
                                            (class)->hbrBackground = background

    #define _wpi_setclassextra( class, extra ) (class)->cbWndExtra = extra

    #define _wpi_setstretchbltmode( mem, mode ) \
        // nothing

extern void _wpi_setqmsgvalues( WPI_QMSG *qmsg, HWND hwnd, WPI_MSG message,
                        WPI_PARAM1 parm1, WPI_PARAM2 parm2, ULONG wpi_time,
                        WPI_POINT wpi_pt );
extern void _wpi_getqmsgvalues( WPI_QMSG qmsg, HWND *hwnd, WPI_MSG *message,
                        WPI_PARAM1 *parm1, WPI_PARAM2 *parm2, ULONG *wpi_time,
                        WPI_POINT *wpi_pt );

    #define _wpi_qmsgmessage( pwpi_qmsg ) (pwpi_qmsg)->msg

    #define _wpi_qmsgparam1( pwpi_qmsg ) (pwpi_qmsg)->mp1

    #define _wpi_qmsgparam2( pwpi_qmsg ) (pwpi_qmsg)->mp2

    #define _wpi_drawhwnd( drw ) (drw)->hwnd

    #define _wpi_drawpres( drw ) (drw)->hps

extern void _wpi_suspendthread( UINT thread_id, WPI_QMSG *msg );

    #define _wpi_resumethread( thread_id ) DosResumeThread( thread_id )

    #define _wpi_settextalign( pres, horiz_flags, vert_flags ) \
        GpiSetTextAlignment( pres, horiz_flags, vert_flags )

    #define _wpi_setbrushorigin( pres, pt ) GpiSetPatternRefPoint( pres, pt )

extern void _wpi_setlogbrushsolid( LOGBRUSH *brush );
extern void _wpi_setlogbrushnull( LOGBRUSH *brush );
extern void _wpi_setlogbrushhollow( LOGBRUSH *brush );

    #define _wpi_setlogbrushstyle( plogbrush, style ) \
                                        (plogbrush)->usMixMode = style

    #define _wpi_setlogbrushsymbol( plogbrush, symbol ) \
                                        (plogbrush)->usSymbol = symbol

    #define _wpi_setlogbrushcolour( plogbrush, colour ) \
                                        (plogbrush)->lColor = colour

    #define _wpi_logbrushcolour( plogbrush ) (plogbrush)->lColor

extern HPEN _wpi_createpen( USHORT type, short width, WPI_COLOUR colour );
extern void _wpi_setpoint( WPI_POINT *pt, int x, int y );

    #define _wpi_moveto( pres, point ) GpiSetCurrentPosition( pres, point )

    #define _wpi_movetoex( pres, point, extra ) \
                                        GpiSetCurrentPosition( pres, point )

    #define _wpi_lineto( pres, point ) GpiLine( pres, point )

extern WPI_COLOUR _wpi_setpixel( WPI_PRES hps, int x, int y, WPI_COLOUR clr );
extern void _wpi_drawfocusrect( WPI_PRES pres, WPI_RECT *rect );
extern BOOL _wpi_rectangle( WPI_PRES pres, int left, int top, int right,
                                                                int bottom );
extern BOOL _wpi_polygon( WPI_PRES pres, WPI_POINT *pts, int num_pts );
extern int _wpi_devicecapableinch( WPI_PRES pres, int what );

    #define _wpi_getcurrenttime( inst ) WinGetCurrentTime( (inst).hab )

    #define _wpi_getcurrpos( pres, pt ) GpiQueryCurrentPosition( pres, pt )

extern HBRUSH _wpi_createpatternbrush( WPI_HANDLE bitmap );
extern HBRUSH _wpi_createsolidbrush( WPI_COLOUR colour );
extern HBRUSH _wpi_createnullbrush( void );
extern HPEN _wpi_createnullpen( void );

    #define _wpi_deletebrush( brush ) _wpi_free( (WPI_OBJECT *)brush )

    #define _wpi_deletenullbrush( brush ) _wpi_free( (WPI_OBJECT *)brush )

    #define _wpi_deletenullpen( pen ) _wpi_free( (WPI_OBJECT *)pen )

    #define _wpi_deletepen( pen ) _wpi_free( (WPI_OBJECT *)pen )

    #define _wpi_gpipop( pres, num ) GpiPop( pres, num )

    #define _wpi_preserveattrs( pres ) GpiSetAttrMode( pres, AM_PRESERVE )

extern void _wpi_getpaintrect( PAINTSTRUCT *ps, WPI_RECT *rect );

    #define _wpi_muldiv( a, b, c ) ((int)(((long)(a) * (long)(b)) / (long)(c)))

extern void _wpi_setmaxtracksize( WPI_MINMAXINFO *info, int width, int height );
extern void _wpi_setmintracksize( WPI_MINMAXINFO *info, int width, int height );

    #define _wpi_setdoubleclicktime( rate ) \
                            WinSetSysValue( HWND_DESKTOP, SV_DBLCLKTIME, rate )

    #define _wpi_iswindowenabled( hwnd ) WinIsWindowEnabled( hwnd )

extern void _wpi_hitrect( int xc, int yc, int ytop, int ybottom, int xleft,
                                            int xright, int mxp, int myp );
extern void _wpi_arc( WPI_PRES pres, int xx1, int yy1, int xx2, int yy2,
                                         int xx3, int yy3, int xx4, int yy4 );
extern void _wpi_pie( WPI_PRES pres, int xx1, int yy1, int xx2, int yy2,
                                         int xx3, int yy3, int xx4, int yy4 );
extern BOOL _wpi_ellipse( WPI_PRES pres, int left, int top, int right,
                                                                int bottom );
    #define _wpi_setmapmode( pres, what ) what

extern WPI_TASK _wpi_getcurrenttask( void );

    #define _wpi_getrvalue( color ) ((BYTE) (color >> 16))

    #define _wpi_getgvalue( color ) ((BYTE) ((WORD) color >> 8))

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?