Changeset 9857 for trunk/src


Ignore:
Timestamp:
Feb 25, 2003, 3:37:05 PM (23 years ago)
Author:
sandervl
Message:

Added support for EM_SETCHARFORMAT (text & background color) & EM_SETBKGNDCOLOR

Location:
trunk/src/riched32
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/riched32/makefile

    r9410 r9857  
    1 # $Id: makefile,v 1.9 2002-11-15 19:34:36 sandervl Exp $
     1# $Id: makefile,v 1.10 2003-02-25 14:37:05 sandervl Exp $
    22
    33#
     
    4040$(ODIN32_LIB)/kernel32.lib \
    4141$(ODIN32_LIB)/user32.lib \
     42$(ODIN32_LIB)/gdi32.lib \
    4243$(ODIN32_LIB)/$(ODINCRT).lib \
    4344OS2386.LIB \
  • trunk/src/riched32/richedit.c

    r9641 r9857  
    5252                     hwnd, (UINT)wParam, (UINT)lParam)
    5353
     54#ifdef __WIN32OS2__
     55#define RICHEDIT_WND_PROP       "RICHEDIT_PROP"
     56
     57#endif
    5458
    5559/***********************************************************************
     
    110114    LONG style = 0;
    111115
     116#ifdef __WIN32OS2__
     117    HWND hwndEdit;
     118    HWND hwndParent;
     119    char* rtfBuffer;
     120    HANDLE hProp = 0;
     121    int rtfBufferSize;
     122
     123    CHARRANGE *cr;
     124#else
    112125    static HWND hwndEdit;
    113126    static HWND hwndParent;
     
    117130    CHARRANGE *cr;
    118131    TRACE("previous hwndEdit: %p hwndParent %p\n",hwndEdit,hwndParent);
     132#endif
    119133    hwndEdit = GetWindow(hwnd,GW_CHILD);
    120134    TRACE("uMsg: 0x%x hwnd: %p hwndEdit: %p\n",uMsg,hwnd,hwndEdit);
     
    143157
    144158            SetWindowLongA(hwnd,GWL_STYLE, newstyle);
     159#ifdef __WIN32OS2__
     160          {
     161            CHARFORMAT2A *pcf;
     162
     163            hProp = GlobalAlloc(GMEM_MOVEABLE|GMEM_ZEROINIT, sizeof(CHARFORMAT2A));
     164            SetPropA(hwnd, RICHEDIT_WND_PROP, hProp);
     165            pcf = (CHARFORMAT2A *)GlobalLock(hProp);
     166            if(pcf) {
     167                pcf->cbSize = sizeof(CHARFORMAT2A);
     168                GlobalUnlock(hProp);
     169            }
     170          }
     171#endif
    145172            return 0 ;
    146173
     
    400427
    401428    case EM_SETBKGNDCOLOR:
     429#ifdef __WIN32OS2__
     430{
     431            CHARFORMAT2A *pcf;
     432
     433            hProp = GetPropA(hwnd, RICHEDIT_WND_PROP);
     434            pcf = (CHARFORMAT2A *)GlobalLock(hProp);
     435            if(pcf)
     436            {
     437                pcf->dwMask     |= CFM_BACKCOLOR;
     438                pcf->crBackColor = (wParam) ? GetSysColor(COLOR_BACKGROUND) : (COLORREF)lParam;
     439
     440                //Destroy old brush if present
     441                if(pcf->dwReserved) DeleteObject(pcf->dwReserved);
     442
     443                //Create a brush that we return in WM_CTLCOLORSTATIC
     444                pcf->dwReserved  = (DWORD)CreateSolidBrush(pcf->crBackColor);
     445 
     446                dprintf(("Set background color to %x brush %x", pcf->crBackColor, pcf->dwReserved));
     447
     448                GlobalUnlock(hProp);
     449            }
     450}
     451#endif
    402452            DPRINTF_EDIT_MSG32("EM_SETBKGNDCOLOR Ignored");
    403453            return 0;
    404454
    405455    case EM_SETCHARFORMAT:
     456#ifdef __WIN32OS2__
     457    {
     458            CHARFORMAT2A *pnewcf = (CHARFORMAT2A *)lParam;
     459            CHARFORMAT2A *pcf;
     460
     461            hProp = GetPropA(hwnd, RICHEDIT_WND_PROP);
     462            pcf = (CHARFORMAT2A *)GlobalLock(hProp);
     463            if(pcf && pnewcf && pnewcf->cbSize >= sizeof(CHARFORMATA))
     464            {
     465                if((pnewcf->dwMask & CFM_COLOR) && !(pnewcf->dwEffects & CFE_AUTOCOLOR)) {
     466                    pcf->dwMask     |= CFM_COLOR;
     467                    pcf->crTextColor = pnewcf->crTextColor;
     468                    dprintf(("Set text color to %x", pcf->crTextColor));
     469                }
     470                if(pnewcf->cbSize == sizeof(CHARFORMAT2A))
     471                {
     472                    if((pnewcf->dwMask & CFM_BACKCOLOR) && !(pnewcf->dwEffects & CFE_AUTOBACKCOLOR))
     473                    {
     474                        pcf->dwMask     |= CFM_BACKCOLOR;
     475                        pcf->crBackColor = pnewcf->crBackColor;
     476 
     477                        //Destroy old brush if present
     478                        if(pcf->dwReserved) DeleteObject(pcf->dwReserved);
     479
     480                        //Create a brush that we return in WM_CTLCOLORSTATIC
     481                        pcf->dwReserved  = (DWORD)CreateSolidBrush(pcf->crBackColor);
     482 
     483                        dprintf(("Set background color to %x brush %x", pcf->crBackColor, pcf->dwReserved));
     484                    }
     485                }
     486            }
     487
     488            if(pcf) GlobalUnlock(hProp);
     489    }
     490#else
    406491            DPRINTF_EDIT_MSG32("EM_SETCHARFORMAT Ignored");
     492#endif
    407493            return 0;
    408494
     
    657743        return DefWindowProcA( hwnd,uMsg,wParam,lParam);
    658744    case WM_DESTROY:
     745#ifdef __WIN32OS2__
     746    {
     747        CHARFORMAT2A *pcf;
     748
     749        hProp = GetPropA(hwnd, RICHEDIT_WND_PROP);
     750        pcf = (CHARFORMAT2A *)GlobalLock(hProp);
     751        if(pcf) {
     752            //Destroy old brush if present
     753            if(pcf->dwReserved) DeleteObject(pcf->dwReserved);
     754            GlobalUnlock(hProp);
     755        }
     756
     757        if(hProp) GlobalFree(hProp);
     758        RemovePropA(hwnd, RICHEDIT_WND_PROP);
     759    }
     760#endif
    659761        DPRINTF_EDIT_MSG32("WM_DESTROY Passed to default");
    660762        return DefWindowProcA( hwnd,uMsg,wParam,lParam);
     
    672774        DPRINTF_EDIT_MSG32("WM_INITIALUPDATE Passed to default");
    673775        return DefWindowProcA( hwnd,uMsg,wParam,lParam); */
     776#ifndef __WIN32OS2__
    674777    case WM_CTLCOLOREDIT:
    675778        DPRINTF_EDIT_MSG32("WM_CTLCOLOREDIT Passed to default");
    676779        return DefWindowProcA( hwnd,uMsg,wParam,lParam);
     780#endif
    677781    case WM_SETCURSOR:
    678782        DPRINTF_EDIT_MSG32("WM_SETCURSOR Passed to default");
     
    700804        return DefWindowProcA( hwnd,uMsg,wParam,lParam);
    701805    case WM_CTLCOLORSTATIC:
     806#ifdef __WIN32OS2__
     807    case WM_CTLCOLOREDIT:
     808{
     809            CHARFORMAT2A *pcf;
     810            HBRUSH hBrush = 0;
     811            HDC hdc = (HDC)wParam;
     812
     813            hProp = GetPropA(hwnd, RICHEDIT_WND_PROP);
     814            pcf = (CHARFORMAT2A *)GlobalLock(hProp);
     815            if(pcf)
     816            {
     817                if(pcf->dwMask & CFM_BACKCOLOR) {
     818                    SetBkColor(hdc, pcf->crBackColor);
     819                    hBrush = pcf->dwReserved;
     820                }
     821                if(pcf->dwMask & CFM_COLOR) {
     822                    SetTextColor(hdc, pcf->crTextColor);
     823                }
     824            }
     825            if(pcf) GlobalUnlock(hProp);
     826
     827            if(hBrush) return hBrush;         
     828}
     829#endif
    702830        DPRINTF_EDIT_MSG32("WM_CTLCOLORSTATIC Passed to default");
    703831        return DefWindowProcA( hwnd,uMsg,wParam,lParam);
Note: See TracChangeset for help on using the changeset viewer.