wpi_os2.h

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

H
1,411
字号

    #define _wpi_getbvalue( color ) ((BYTE) color)

    #define _wpi_getrgb( red, green, blue ) \
            (LONG)(((LONG) (red) << 16) + ((LONG) (green) << 8) + (LONG) (blue))

    #define _wpi_getmessage( inst, wpi_msg, hdl, first, last ) \
                    WinGetMsg( (inst).hab, wpi_msg, NULLHANDLE, first, last )

    #define _wpi_translatemessage( msg ) \
        // nothing

    #define _wpi_postquitmessage( parm ) \
      // nothing

extern void _wpi_setmodhandle( char *name, WPI_INST *inst );

    #define _wpi_issameinst( inst1, inst2 ) ( (inst1).hab == (inst2).hab && \
                                    (inst1).mod_handle == (inst2).mod_handle )

extern void _wpi_setwpiinst( HINSTANCE hinst, HMODULE module, WPI_INST *inst );

    #define _wpi_dispatchmessage( inst, msg ) WinDispatchMsg( inst.hab, msg )

    #define _wpi_postmessage( hwnd, msg, parm1, parm2 ) \
        WinPostMsg( hwnd, (WPI_MSG)msg, (WPI_PARAM1)parm1, (WPI_PARAM2)parm2 )

    #define _wpi_postappmessage( hmq, msg, parm1, parm2 ) \
        WinPostMsg( hmq, (WPI_MSG)msg, (WPI_PARAM1)parm1, (WPI_PARAM2)parm2 )

    #define _wpi_peekmessage( inst, qmsg, hwnd, min, max, remove ) \
                        WinPeekMsg( (inst).hab, qmsg, hwnd, min, max, remove )

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

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

    #define _wpi_getdlgitemcbtext( hwnd, item, selection, len, text ) \
        _wpi_senddlgitemmessage( hwnd, item, CB_GETLBTEXT, \
                        MPFROM2SHORT( selection, len ), (DWORD)(LPSTR) text )

    #define _wpi_getdlgitemlbtext( hwnd, item, selection, len, text ) \
        _wpi_senddlgitemmessage( hwnd, item, LB_GETTEXT, \
                        MPFROM2SHORT( selection, len ), (DWORD)(LPSTR) text )

    #define _wpi_setdlgitemtext( hwnd, item, text ) \
                                WinSetDlgItemText( hwnd, (ULONG) item, text )

    #define _wpi_getdlgitemtext( hwnd, item, text, size ) \
                        WinQueryDlgItemText( hwnd, (ULONG) item, size, text )

extern short _wpi_getdlgitemshort( HWND hwnd, int item, BOOL *trans, BOOL issigned );
extern int _wpi_getdlgitemint( HWND hwnd, int item, BOOL *retcode, BOOL issigned );

    #define _wpi_setdlgitemshort( hwnd, item, value, signed ) \
        WinSetDlgItemShort( hwnd, (ULONG) item, (USHORT) value, (BOOL) signed )

    #define _wpi_setdlgitemint( hwnd, item, value, signed ) \
        WinSetDlgItemShort( hwnd, (ULONG) item, (USHORT) value, (BOOL) signed )

    #define _wpi_getdlgitem( parent, id ) WinWindowFromID( parent, id )

    #define _wpi_ret_wminitdlg( bool_val ) ( (WPI_DLGRESULT) !bool_val )

extern void _wpi_preparemono( WPI_PRES hps, WPI_COLOUR colour,
                                                    WPI_COLOUR back_colour );

    #define _wpi_torgbmode( pres ) GpiCreateLogColorTable( pres, 0L, \
                                                    LCOLF_RGB, 0L, 0L, NULL )

extern void _wpi_bitblt( WPI_PRES dest, int x_dest, int y_dest, int cx,
                int cy, WPI_PRES source, int x_src, int y_src, LONG format );
extern void _wpi_patblt( WPI_PRES dest, int x_pos, int y_pos, int cx,
                                                        int cy, LONG format );
extern WPI_PRES _wpi_createos2normpres( WPI_INST inst, HWND hwnd );
extern void _wpi_deleteos2normpres( WPI_PRES pres );
extern WPI_PRES _wpi_createcompatiblepres( WPI_PRES pres, WPI_INST inst, HDC *hdc );
extern void _wpi_deletepres( WPI_PRES pres, HDC hdc );
extern void _wpi_deletecompatiblepres( WPI_PRES pres, HDC hdc );
extern WPI_HANDLE _wpi_selectbitmap( WPI_PRES pres, WPI_HANDLE bitmap );
extern void _wpi_getoldbitmap( WPI_PRES pres, WPI_HANDLE oldobj );
extern void _wpi_deletebitmap( WPI_HANDLE bmp );

    #define _wpi_translateaccelerator( inst, hwnd, accel, msg ) \
                            WinTranslateAccel( (inst).hab, hwnd, accel, msg )

    #define _wpi_loadaccelerators( inst, id ) \
            WinLoadAccelTable( (inst).hab, (inst).mod_handle, (ULONG)id )

    #define _wpi_getscreenpres() WinGetScreenPS( HWND_DESKTOP )

    #define _wpi_releasescreenpres( hps ) // nothing

extern WPI_HANDLE _wpi_loadbitmap( WPI_INST inst, int id );
extern void _wpi_getbitmapdim( WPI_HANDLE hbmp, int *pwidth, int *pheight );
extern WPI_PRES _wpi_getpres( HWND hwnd );
extern WPI_HANDLE _wpi_createcompatiblebitmap( WPI_PRES pres, int width, int height );

    #define _wpi_preparesyscolour() WinSetSysColors( HWND_DESKTOP, LCOL_RESET, \
                                    LCOLF_INDRGB, 0L, (ULONG) 0, (PLONG) NULL )

    #define _wpi_getsyscolour( format ) \
                                    WinQuerySysColor( HWND_DESKTOP, format, 0L )

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

    #define _wpi_getcursorpos( ppt ) WinQueryPointerPos(HWND_DESKTOP, ppt)

    #define _wpi_getnearestcolor( pres, colour ) \
                                        GpiQueryNearestColor( pres, 0L, colour )

    #define _wpi_offsetrect( inst, rect, x, y ) \
                                        WinOffsetRect( (inst).hab, rect, x, y )

extern void _wpi_fillrect( WPI_PRES pres, WPI_RECT *rect, WPI_COLOUR colour,
                                                            HBRUSH brush );

    #define _wpi_beginpaint( hwnd, pres, paint ) \
                                            WinBeginPaint( hwnd, pres, paint )

    #define _wpi_endpaint( hwnd, pres, paint ) WinEndPaint( pres )

    #define _wpi_registerclass( cl ) WinRegisterClass( (cl)->hInstance.hab, \
        (cl)->lpszClassName, (cl)->lpfnWndProc, (cl)->style, (cl)->cbWndExtra )

extern BOOL _wpi_getclassinfo( WPI_INST inst, PSZ name, WPI_WNDCLASS *info );

    #define _wpi_getclassproc( class ) (class)->lpfnWndProc

    #define _wpi_getcreateparms( lpcs ) lpcs->pCtlData

extern HWND _wpi_createwindow( LPSTR class, LPSTR name, ULONG frame_style,
                        ULONG create_flags, ULONG client_style, int x, int y,
                        int width, int height, HWND parent, HMENU menu,
                        WPI_INST inst, void *param, HWND *frame_hwnd );
extern HWND _wpi_createobjwindow( LPSTR class, LPSTR name, ULONG style, int x,
                        int y, int width, int height, HWND parent, HMENU menu,
                        WPI_INST inst, void *pparam, HWND *pframe );

    #define _wpi_getwindowtext( hwnd, text, size ) \
                                        WinQueryWindowText( hwnd, size, text )

    #define _wpi_getwindowword( hwnd, id ) WinQueryWindowUShort( hwnd, id )

    #define _wpi_setwindowword( hwnd, id, data  ) \
                                        WinSetWindowUShort( hwnd, id, data )

    #define _wpi_getwindowlong( hwnd, id ) WinQueryWindowULong( hwnd, id )

    #define _wpi_setwindowlong( hwnd, id, data ) \
                                            WinSetWindowULong( hwnd, id, data )

    #define _wpi_makeprocinstance( proc, inst ) ( (WPI_PROC) proc )

    #define _wpi_makeenumprocinstance( proc, inst ) ( (WPI_ENUMPROC) proc )

    #define _wpi_makelineddaprocinstance( proc, inst ) ((WPI_LINEDDAPROC)proc)

    #define _wpi_defdlgproc( hwnd, msg, mp1, mp2 ) \
                                            WinDefDlgProc(hwnd, msg, mp1, mp2)

    #define _wpi_callwindowproc( proc, hwnd, msg, parm1, parm2 ) \
        ((proc)( hwnd, msg, (WPI_PARAM1) parm1, (WPI_PARAM2) parm2 ))

extern void _wpi_enddialog( HWND hwnd, ULONG result );
extern int _wpi_dialogbox( HWND parent, WPI_PROC proc, WPI_INST inst,
                                                    int res_id, void *data );
extern void _wpi_stretchblt( WPI_PRES dest, int x_dest, int y_dest,
        int cx_dest, int cy_dest, WPI_PRES src, int x_src, int y_src, int cx_src,
        int cy_src, LONG rop );
extern void _wpi_setrectvalues( WPI_RECT *rect, WPI_RECTDIM in_left,
            WPI_RECTDIM in_top, WPI_RECTDIM in_right, WPI_RECTDIM in_bottom );
extern void _wpi_getrectvalues( WPI_RECT rect, WPI_RECTDIM *left,
                WPI_RECTDIM *top, WPI_RECTDIM *right, WPI_RECTDIM *bottom );
extern void _wpi_setwrectvalues( WPI_RECT *rect, WPI_RECTDIM in_left,
            WPI_RECTDIM in_top, WPI_RECTDIM in_right, WPI_RECTDIM in_bottom );
extern void _wpi_getwrectvalues( WPI_RECT rect, WPI_RECTDIM *left,
                WPI_RECTDIM *top, WPI_RECTDIM *right, WPI_RECTDIM *bottom);
extern void _wpi_setintrectvalues( WPI_RECT *rect, int in_left, int in_top,
                                                int in_right, int in_bottom );
extern void _wpi_getintrectvalues( WPI_RECT rect, int *left, int *top,
                                                    int *right, int *bottom );
extern void _wpi_setintwrectvalues( WPI_RECT *rect, int in_left, int in_top,
                                                int in_right, int in_bottom );
extern void _wpi_getintwrectvalues( WPI_RECT rect, int *left, int *top,
                                                    int *right, int *bottom);
extern void GetClientRect( HWND hwnd, WPI_RECT *prect );

    #define _wpi_getclientrect( hwnd, prect ) GetClientRect( hwnd, prect )

    #define _wpi_cvth_y( y, h )  ((h) - (y) - 1)

    #define _wpi_cvth_pt( pt, h ) (pt)->y = ((h) - (pt)->y - 1)

extern void _wpi_cvth_rect( WPI_RECT *rect, LONG height );
extern LONG _wpi_cvth_wanchor( LONG y, LONG window_height, LONG parent_height );

    #define _wpi_cvts_y( y ) \
        _wpi_cvth_y( y, (int)WinQuerySysValue( HWND_DESKTOP, SV_CYSCREEN ) )

extern LONG _wpi_cvtc_y( HWND hwnd, LONG y );
extern void _wpi_cvtc_rect( HWND hwnd, WPI_RECT *rect );

    #define _wpi_cvts_pt( pt ) \
        _wpi_cvth_pt( pt, (int)WinQuerySysValue( HWND_DESKTOP, SV_CYSCREEN ) )

    #define _wpi_cvts_rect( rect, h ) \
        _wpi_cvth_rect( rect, (int)WinQuerySysValue(HWND_DESKTOP, SV_CYSCREEN) )

extern LONG _wpi_cvts_wanchor( LONG y, LONG window_height );

    #define _wpi_convertheight( h, top, bottom ) bottom + ( top - h - 1 )

    #define _wpi_borderrect( pres, rect, brush, fore, back ) \
        WinDrawBorder( pres, rect, 1, 1, fore, back, DB_STANDARD )

    #define _wpi_getdlgctrlid( hwnd ) WinQueryWindowUShort( hwnd, QWS_ID )

    #define _wpi_getwindowid( hwnd ) WinQueryWindowUShort( hwnd, QWS_ID )

    #define _wpi_isrightid( hwnd, id ) (id==WinQueryWindowUShort(hwnd, QWS_ID))

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

extern BOOL _wpi_ptinrect( WPI_RECT *prect, WPI_POINT pt );

    #define _wpi_createrectrgn( pres, rects ) GpiCreateRegion( pres, 1, rects )

    #define _wpi_deletecliprgn( pres, rgn ) GpiDestroyRegion( pres, rgn )

extern int _wpi_selectcliprgn( WPI_PRES pres, HRGN rgn );

    #define _wpi_getboss( hwnd ) PM1632WinQueryWindow( hwnd, QW_OWNER )

    #define _wpi_ischild( hwnd1, hwnd2 ) WinIsChild( hwnd1, hwnd2 )

    #define _wpi_getowner( hwnd ) PM1632WinQueryWindow( hwnd, QW_OWNER )

    #define _wpi_setowner( win, who ) WinSetOwner( win, who )

    #define _wpi_getvk( parm1, parm2 ) SHORT2FROMMP( parm2 )

    #define _wpi_getmousex( parm1, parm2 ) ( ( (SHORT) parm1 ) )

    #define _wpi_getmousey( parm1, parm2 ) ( ( (LONG) parm1 >> 16 ) )

    #define _wpi_getwmsizex( parm1, parm2 ) ( ( (SHORT) parm2 ) )

    #define _wpi_getwmsizey( parm1, parm2 ) ( ( (LONG) parm2 >> 16 ) )

    #define _wpi_ismsgsetfocus( msg, parm2 ) \
                                ( msg == WM_SETFOCUS && SHORT1FROMMP( parm2 ) )

    #define _wpi_ismsgkillfocus( msg, parm2 ) \
                                ( msg == WM_SETFOCUS && !SHORT1FROMMP( parm2 ) )

    #define _wpi_ismsgkeydown( msg, parm1 ) \
         ( msg == WM_CHAR && !(SHORT1FROMMP( parm1 ) == KC_KEYUP ) )

    #define _wpi_ismsgkeyup( msg, parm1 ) \
         ( msg == WM_CHAR && (SHORT1FROMMP( parm1 ) == KC_KEYUP ) )

    #define _wpi_isdown( parm1, parm2 ) ( !( (int) parm2 & KC_KEYUP ) )

extern HFILE _wpi_fileopen( LPSTR filename, int format );
extern HFILE _wpi_filecreate( LPSTR filename, int format );
extern PM1632_FILESIZETYPE _wpi_fileclose( HFILE hfile );
extern PM1632_FILESIZETYPE _wpi_filewrite( HFILE hfile, void *buf,
                                                    PM1632_FILESIZETYPE size );
extern PM1632_FILESIZETYPE _wpi_fileread( HFILE hfile, void *buf,
                                                    PM1632_FILESIZETYPE size );

    #define _wpi_isdialogmessage( win_hld, wpi_msg ) ( (wpi_msg)->hwnd == win_hld )
    #define _wpi_ismessage( wpi_msg, id ) ( (wpi_msg).msg == id )

    #define _wpi_isntdblclk( parm1, parm2 ) SHORT2FROMMP( parm1 ) != LN_ENTER

extern HBRUSH _wpi_createbrush( LOGBRUSH *log_brush );

    #define _wpi_getstockobject( object ) 0

    #define _wpi_dlgbaseheight( inst, size ) \
        { \
            HDC                 dc; \
            DEVOPENSTRUC        dop = { NULL, "DISPLAY", NULL, NULL, \
                                        NULL, NULL, NULL, NULL, NULL }; \
            dc = DevOpenDC( inst.hab, OD_MEMORY, "*", 5L, (PDEVOPENDATA) &dop, \
                                                        NULLHANDLE ); \
            DevQueryCaps( dc, CAPS_CHAR_HEIGHT, 1L, (LONG *) size ); \
            DevCloseDC( dc ); \
         }

    #define _wpi_dlgbasewidth( inst, size ) \
        { \
            HDC                 dc; \
            DEVOPENSTRUC        dop = { NULL, "DISPLAY", NULL, NULL, \
                                        NULL, NULL, NULL, NULL, NULL }; \
            dc = DevOpenDC( inst.hab, OD_MEMORY, "*", 5L, (PDEVOPENDATA) &dop, \
                                                        NULLHANDLE ); \
            DevQueryCaps( dc, CAPS_CHAR_WIDTH, 1L, (LONG *) size ); \
            DevCloseDC( dc ); \
         }

extern WPI_COLOUR _wpi_settextcolor( WPI_PRES, WPI_COLOUR );
extern WPI_COLOUR _wpi_setbackcolour( WPI_PRES, WPI_COLOUR );

    #define _wpi_getbackcolour( pres ) GpiQueryBackColor( pres )

extern BOOL _wpi_textout( WPI_PRES pres, int left, int top, LPSTR text, ULONG
                                                                        len );
    #define _wpi_getdeffm( fm ) memset( &fm, 0, sizeof( FONTMETRICS ) )

    #define _wpi_getfontattrs2( fm, attr ) \
        (attr)->usRecordLength = sizeof( FATTRS ); \
        (attr)->fsSelection = (fm).fsSelection; \
        (attr)->lMatch = (fm).lMatch; \
        if( (fm).szFacename != NULL ) { \
            strcpy( (attr)->szFacename, (fm).szFacename ); \
        } else { \
            (attr)->szFacename[0] = '\0'; \
        } \
        (attr)->idRegistry = (fm).idRegistry; \
        (attr)->usCodePage = (fm).usCodePage; \
        (attr)->fsType = (fm).fsType; \
        (attr)->lMaxBaselineExt = (fm).lMaxBaselineExt; \
        (attr)->lAveCharWidth = (fm).lAveCharWidth; \
        (attr)->fsFontUse = FATTR_FONTUSE_NOMIX;


    /***** _WPI_F_* Font Functions *****/
    /* These functions are a set of replacement WPI font functions
       which should work. All the other functions are crap; this
       is an attempt to do it right. DJP */

    #define _wpi_f_setfontitalic( font, style ) \
                        (font)->attr.fsSelection = \
                        ( (font)->attr.fsSelection & ~FATTR_SEL_ITALIC ) + \
                        ( (style) ? FATTR_SEL_ITALIC : 0 )

    #define _wpi_f_setfontunderline( font, style ) \
                        (font)->attr.fsSelection = \
                        ( (font)->attr.fsSelection & ~FATTR_SEL_UNDERSCORE ) + \
                        ( (style) ? FATTR_SEL_UNDERSCORE : 0 )

    #define _wpi_f_setfontstrikeout( font, style ) \
                        (font)->attr.fsSelection = \
                        ( (font)->attr.fsSelection & ~FATTR_SEL_STRIKEOUT ) + \
                        ( (style) ? FATTR_SEL_STRIKEOUT : 0 )

⌨️ 快捷键说明

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