예제 #1
0
/*
 * _AnotherWindowData - create yet another window data item
 */
LPWDATA _AnotherWindowData( HWND hwnd, va_list al )
{
    LPWDATA     w;
    int         h,hcnt,*hlist;

    w = _MemAlloc( sizeof( window_data ) );
    FARmemset( w, 0, sizeof( window_data ) );
    _MainWindowData->windows = _MemReAlloc( _MainWindowData->windows,
                sizeof( LPWDATA ) * ( _MainWindowData->window_count + 1 ) );
    _MainWindowData->windows[_MainWindowData->window_count] = w;
    _MainWindowData->window_count++;

    w->CurrentLineNumber = 1L;
    w->TopLineNumber = 1L;
    w->LastLineNumber = 1L;
    w->tmpbuff = _MemAlloc( sizeof( line_data ) + MAX_BUFF+1 );
    w->CaretType = ORIGINAL_CURSOR;
    w->hwnd = hwnd;

    hcnt = 0;
    hlist = NULL;
    while( 1 ) {
        h = va_arg( al, int );
        if( h == -1 ) break;
        hlist = realloc( hlist, (hcnt+1) * sizeof( h ) );
        hlist[hcnt] = h;
        hcnt++;
    }
    w->handles = hlist;
    w->handle_cnt = hcnt;
    return( w );

} /* _AnotherWindowData */
예제 #2
0
/*
 * _InitMainWindowData - set up main window data area
 */
void _InitMainWindowData( HANDLE inst )
{

    _MainWindowData = _MemAlloc( sizeof( window_data ) );
    FARmemset( _MainWindowData, 0, sizeof( window_data ) );
    _MainWindowData->inst = inst;
    _MainWindowData->window_count = 0;
    _MainWindowData->windows = NULL;

} /* _InitMainWindowData */
예제 #3
0
/*
 * _InitMainWindowData - set up main window data area
 */
void _InitMainWindowData( HANDLE inst )
{

    _MainWindowData = FARmalloc( sizeof( main_window_data ) );
    if( _MainWindowData == NULL )
        _OutOfMemoryExit();
    FARmemset( _MainWindowData, 0, sizeof( main_window_data ) );
    _MainWindowData->inst = inst;
    _MainWindowData->window_count = 0;
    _MainWindowData->windows = NULL;

} /* _InitMainWindowData */
예제 #4
0
/*
 * _ClearWindow - erase a window
 */
void _ClearWindow( LPWDATA w )
{
    HWND        hwnd;

    hwnd = w->hwnd;

    /*** Clear the w->image array ***/
#ifdef _MBCS
    {
        mb_char         mbc;
        int             count;

        mbc = _mbsnextc( (unsigned char *)" " );
        for( count=0; count < w->width * w->height; count++ ) {
            w->image[count] = mbc;              /* store space in w->image */
        }
    }
#else
    FARmemset( w->image, 0x20, w->width*w->height );
#endif

#if defined( __OS2__ )
    {
        HPS     ps;
        RECTL   rcl;

        ps = WinGetPS( hwnd );
        WinQueryWindowRect( hwnd, &rcl );
        WinFillRect( ps, &rcl, CLR_WHITE );
        WinReleasePS( ps );
    }
#else
    {
        RECT    rect;
        HDC     dc;

        dc = GetDC( hwnd );
    #ifndef __NT__
        UnrealizeObject( w->brush );
    #endif
        SelectObject( dc, w->brush );
    #ifdef __NT__
        SetBrushOrgEx( dc, 0, 0, NULL  );
    #endif
        GetClientRect( hwnd, &rect );
        FillRect( dc, &rect, w->brush );
        ReleaseDC( hwnd, dc );
    }
#endif

} /* _ClearWindow */
예제 #5
0
/*
 * _MemAlloc - allocate some memory
 */
void _WCI86FAR *_MemAlloc( unsigned size )
{
    void _WCI86FAR      *tmp;

    tmp = FARmalloc( size );
    if( tmp == NULL ) {
        _OutOfMemory();
        while( _MessageLoop( FALSE ) );
        _WindowsExitRtn = NULL;
        exit( 0 );
    }
    FARmemset( tmp, 0, size );
    return( tmp );

} /* _MemAlloc */
예제 #6
0
/*
 * _ResizeWin - give a window a new size/location
 */
void _ResizeWin( LPWDATA w, int x1, int y1, int x2, int y2 )
{
    int height;

    height = (y2 - y1 + 1) / w->ychar + 1;
    if( w->CurrentLineNumber - w->TopLineNumber >= height ) {
        w->CurrentLineNumber = w->TopLineNumber + height - 1;
    }

    w->x1 = x1;
    w->x2 = x2;
    w->y1 = y1;
    w->y2 = y2;
    w->width = (x2 - x1 + 1) / w->xchar + 1;
    w->height = height;

    /*** Initialize a new w->image array ***/
    _MemFree( w->image );
#ifdef _MBCS
    {
        mb_char         mbc;
        int             count;

        w->image = _MemAlloc( sizeof( mb_char ) * w->width * w->height );
        mbc = _mbsnextc( (unsigned char *)" " );
        for( count = 0; count < w->width * w->height; count++ ) {
            w->image[count] = mbc;              /* store space in w->image */
        }
    }
#else
    w->image = _MemAlloc( w->width * w->height );
    FARmemset( w->image, 0x20, w->width * w->height );
#endif

    if( w->width > w->maxwidth ) {
        w->maxwidth = w->width;
    }

} /* _ResizeWin */
예제 #7
0
/*
 * _DisplayLineInWindowWithColor - as it sounds!
 */
void _DisplayLineInWindowWithColor( LPWDATA w, int line, LPSTR text, int c1,
                        int c2, int extra, int startcol )
{
  #ifdef _MBCS
    LPBYTE          tmp;
  #else
    LPSTR           tmp;
  #endif
    char            buff[256];
    int             start,end,a,spend,cnt1,cnt2;
    WORD            i;
    HWND            hwnd;

    hwnd = w->hwnd;

    /*** Find dimensions of line ***/
  #ifdef _MBCS
    tmp = FAR_mbsninc( (LPBYTE)text, startcol );
    a = FAR_mbslen( tmp );
    if( line < 1 || line >= w->height )
        return;
    start = 0;
    spend = end = w->width - extra;
    if( end > a )
        end = a;
    cnt1 = FAR_mbsnbcnt( tmp, end - start );
    cnt2 = spend - end;
    FAR_mbsnbcpy( (LPBYTE)buff, tmp, cnt1 - start );
    FARmemset( buff + cnt1, ' ', cnt2 );
    tmp = FAR_mbsninc( (LPBYTE)buff, cnt1 + cnt2 );
    *tmp = '\0';
  #else
    tmp = text;
    tmp += startcol;
    a = FARstrlen( tmp );
    if( line < 1 || line >= w->height )
        return;
    start = 0;
    spend = end = w->width - extra;
    if( end > a )
        end = a;
    cnt1 = end - start;
    cnt2 = spend - end;
    FARmemcpy( buff, tmp, cnt1 );
    FARmemset( buff + cnt1, ' ', cnt2 );
    buff[cnt1 + cnt2] = 0;
  #endif
    line--;

#if defined( __OS2__ )
    {
        RECTL           rcl;
        HPS             ps;
        POINTL          ptl;
        POINTL          points[TXTBOX_COUNT];

        ptl.x = 0;
        ptl.y = (w->y2 - w->y1) - (line+1)*w->ychar + w->base_offset;
        ps = WinGetPS( hwnd );
        _SelectFont( ps );
        GpiQueryTextBox( ps, startcol, w->tmpbuff->data, TXTBOX_COUNT, points );
        rcl.xLeft = points[TXTBOX_BOTTOMRIGHT].x;
    #ifdef _MBCS
        GpiQueryTextBox( ps, __mbslen( (unsigned char *)buff ), buff, TXTBOX_COUNT, points );
    #else
        GpiQueryTextBox( ps, strlen( buff ), buff, TXTBOX_COUNT, points );
    #endif
        rcl.xRight = points[TXTBOX_BOTTOMRIGHT].x;
        rcl.yTop = (w->y2 - w->y1) - line*w->ychar;
        rcl.yBottom = rcl.yTop - w->ychar;
        WinFillRect( ps, &rcl, c1 );
        GpiSetColor( ps, c2 );
    #ifdef _MBCS
        GpiCharStringAt( ps, &ptl, _mbsnbcnt(buff,w->width), buff );
    #else
        GpiCharStringAt( ps, &ptl, w->width, buff );
    #endif
        WinReleasePS( ps );
    }
#else
    {
        HDC     dc;
//      SIZE    size;
//      RECT    rect;

        dc = GetDC( hwnd );
        _SetMyDC( dc, _ColorMap[c2], _ColorMap[c1] );
//      #ifdef __NT__
//          GetTextExtentPoint32( dc, buff, strlen(buff), &size );
//      #else
//          GetTextExtentPoint( dc, buff, strlen(buff), &size );
//      #endif
//
    #ifdef _MBCS
        TextOut( dc, 0, line * w->ychar, (LPSTR)buff, FAR_mbsnbcnt( (LPBYTE)buff, w->width ) );
    #else
        TextOut( dc, 0, line * w->ychar, buff, w->width );
    #endif

        /*** Clear to end of line to remove any residue ***/
//      GetClientRect( w->hwnd, &rect );
//      rect.top = line * w->ychar;
//      rect.bottom = (line+1) * w->ychar ;
//      rect.left = size.cx;
//      FillRect( dc, &rect, w->brush );
        ReleaseDC( hwnd, dc );
    }
#endif

    /*** Update the w->image array ***/
#ifdef _MBCS
    {
        mb_char         mbc;
        unsigned char   *curMbc;
        int             count;

        i = line * w->width + startcol;
        for( count = 0, curMbc = (unsigned char *)buff; count < w->width - startcol; count++ ) {
            mbc = _mbsnextc( curMbc );          /* get the character */
            curMbc = _mbsinc( curMbc );         /* point to next char */
            w->image[i + count] = mbc;          /* store it in w->image */
        }
    }
#else
    i = line * w->width + startcol;
    FARmemcpy( &w->image[i], buff, w->width - startcol );
#endif
} /* _DisplayLineInWindowWithColor */