Changeset 12508


Ignore:
Timestamp:
Dec 1, 1999, 7:23:29 PM (25 years ago)
Author:
cbratschi
Message:

enhanced edit control

Location:
tags/trunk/src/user32
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified tags/trunk/src/user32/edit.cpp

    r12446 r12508  
    1 /* $Id: edit.cpp,v 1.19 1999-11-27 14:16:34 cbratschi Exp $ */
     1/* $Id: edit.cpp,v 1.20 1999-12-01 18:23:27 cbratschi Exp $ */
    22/*
    33 *      Edit control
     
    1111 * WINE version: 991031
    1212 *
    13  * Status:  in progress
    14  * Version: ?.??
    15  */
    16 
    17 /*
    18  *      please read EDIT.TODO (and update it when you change things)
     13 * Status:  complete
     14 * Version: 5.00 (without undocumented specs)
    1915 */
    2016
    2117/* CB: todo
    22   - EN_UPDATE: send before update
    23   - EN_CHANGE: send after update -> WM_PAINT isn't the right place
    24   - EN_HSCROLL/EN_VSCROLL: send before update
    25   - WS_BORDER -> bug in Win32BaseWindow::SetWindowLong
    26   - many messages, styles, notifications
     18  - EN_ALIGN_LTR_EC, EN_ALIGN_RTL_EC -> undocumented notifications
     19  - EM_SETIMESTATUS, EM_GETITEMSTATUS -> undocumented messages
     20  - text alignment for single and multi line (ES_LEFT, ES_RIGHT, ES_CENTER)
     21    new in Win98, Win2k: for single line too
     22  - WinNT/Win2k: higher size limits (single: 0x7FFFFFFE, multi: none)
     23  - problems with OS/2 PM font kerning:
     24    TabbedTextOutA
     25    GetTextExtentPoint32A
     26    WINE code uses relative positions -> rewrite to absolute!
    2727*/
    2828
     
    3939                                           FIXME: BTW, Win95 specs say 65535 (do you dare ???) */
    4040#define BUFLIMIT_SINGLE         32766   /* maximum buffer size (not including '\0') */
     41
     42//#define BUFLIMIT_MULTI  0xFFFFFFFE
     43//#define BUFLIMIT_SINGLE 0x7FFFFFFF
     44
    4145#define BUFSTART_MULTI          1024    /* starting size */
    4246#define BUFSTART_SINGLE         256     /* starting size */
     
    190194static LRESULT  EDIT_EM_CharFromPos(HWND hwnd, EDITSTATE *es, INT x, INT y);
    191195static BOOL     EDIT_EM_FmtLines(HWND hwnd, EDITSTATE *es, BOOL add_eol);
     196static INT      EDIT_EM_GetFirstVisibleLine(HWND hwnd,EDITSTATE *es);
    192197static HLOCAL   EDIT_EM_GetHandle(HWND hwnd, EDITSTATE *es);
     198static INT      EDIT_EM_GetLimitText(HWND hwnd,EDITSTATE *es);
    193199static INT      EDIT_EM_GetLine(HWND hwnd, EDITSTATE *es, INT line, LPSTR lpch);
     200static INT      EDIT_EM_GetLineCount(HWND hwnd,EDITSTATE *es);
     201static LONG     EDIT_EM_GetMargins(HWND hwnd,EDITSTATE *es);
     202static BOOL     EDIT_EM_GetModify(HWND hwnd,EDITSTATE *es);
     203static CHAR     EDIT_EM_GetPasswordChar(HWND hwnd,EDITSTATE *es);
     204static VOID     EDIT_EM_GetRect(HWND hwnd,EDITSTATE *es,LPRECT lprc);
    194205static LRESULT  EDIT_EM_GetSel(HWND hwnd, EDITSTATE *es, LPUINT start, LPUINT end);
    195206static LRESULT  EDIT_EM_GetThumb(HWND hwnd, EDITSTATE *es);
     207static PVOID    EDIT_EM_GetWordbreakProc(HWND hwnd,EDITSTATE *es);
    196208static INT      EDIT_EM_LineFromChar(HWND hwnd, EDITSTATE *es, INT index);
    197209static INT      EDIT_EM_LineIndex(HWND hwnd, EDITSTATE *es, INT line);
     
    205217static void     EDIT_EM_SetLimitText(HWND hwnd, EDITSTATE *es, INT limit);
    206218static void     EDIT_EM_SetMargins(HWND hwnd, EDITSTATE *es, INT action, INT left, INT right);
     219static void     EDIT_EM_SetModify(HWND hwnd,EDITSTATE *es,BOOL fModified);
    207220static void     EDIT_EM_SetPasswordChar(HWND hwnd, EDITSTATE *es, CHAR c);
     221static BOOL     EDIT_EM_SetReadOnly(HWND hwnd,EDITSTATE *es,BOOL fReadOnly);
     222static void     EDIT_EM_SetRect(HWND hwnd,EDITSTATE *es,LPRECT lprc);
     223static void     EDIT_EM_SetRectNP(HWND hwnd,EDITSTATE *es,LPRECT lprc);
    208224static void     EDIT_EM_SetSel(HWND hwnd, EDITSTATE *es, UINT start, UINT end, BOOL after_wrap);
    209225static BOOL     EDIT_EM_SetTabStops(HWND hwnd, EDITSTATE *es, INT count, LPINT tabs);
    210226static void     EDIT_EM_SetWordBreakProc(HWND hwnd, EDITSTATE *es, EDITWORDBREAKPROCA wbp);
    211227static BOOL     EDIT_EM_Undo(HWND hwnd, EDITSTATE *es);
     228static LRESULT  EDIT_EM_SetImeStatus(HWND hwnd,EDITSTATE *es,WPARAM wParam,LPARAM lParam);
     229static LRESULT  EDIT_EM_GetImeStatus(HWND hwnd,EDITSTATE *es,WPARAM wParam,LPARAM lParam);
    212230/*
    213231 *      WM_XXX message handlers
     
    345363        case EM_GETRECT:
    346364                //DPRINTF_EDIT_MSG32("EM_GETRECT");
    347                 if (lParam)
    348                         CopyRect((LPRECT)lParam, &es->format_rect);
     365                EDIT_EM_GetRect(hwnd,es,(LPRECT)lParam);
    349366                break;
    350367
    351368        case EM_SETRECT:
    352369                //DPRINTF_EDIT_MSG32("EM_SETRECT");
    353                 if ((es->style & ES_MULTILINE) && lParam) {
    354                         EDIT_SetRectNP(hwnd, es, (LPRECT)lParam);
    355                         EDIT_Refresh(hwnd,es);
    356                 }
     370                EDIT_EM_SetRect(hwnd,es,(LPRECT)lParam);
    357371                break;
    358372
    359373        case EM_SETRECTNP:
    360374                //DPRINTF_EDIT_MSG32("EM_SETRECTNP");
    361                 if ((es->style & ES_MULTILINE) && lParam)
    362                         EDIT_SetRectNP(hwnd, es, (LPRECT)lParam);
     375                EDIT_EM_SetRectNP(hwnd,es,(LPRECT)lParam);
    363376                break;
    364377
     
    381394        case EM_GETMODIFY:
    382395                //DPRINTF_EDIT_MSG32("EM_GETMODIFY");
    383                 result = ((es->flags & EF_MODIFIED) != 0);
     396                result = (LRESULT)EDIT_EM_GetModify(hwnd,es);
    384397                break;
    385398
    386399        case EM_SETMODIFY:
    387400                //DPRINTF_EDIT_MSG32("EM_SETMODIFY");
    388                 if (wParam)
    389                         es->flags |= EF_MODIFIED;
    390                 else
    391                         es->flags &= ~(EF_MODIFIED | EF_UPDATE);  /* reset pending updates */
     401                EDIT_EM_SetModify(hwnd,es,(BOOL)wParam);
    392402                break;
    393403
    394404        case EM_GETLINECOUNT:
    395405                //DPRINTF_EDIT_MSG32("EM_GETLINECOUNT");
    396                 result = (es->style & ES_MULTILINE) ? es->line_count : 1;
     406                result = (LRESULT)EDIT_EM_GetLineCount(hwnd,es);
    397407                break;
    398408
     
    515525        case EM_GETFIRSTVISIBLELINE:
    516526                //DPRINTF_EDIT_MSG32("EM_GETFIRSTVISIBLELINE");
    517                 result = (es->style & ES_MULTILINE) ? es->y_offset : es->x_offset;
     527                result = (LRESULT)EDIT_EM_GetFirstVisibleLine(hwnd,es);
    518528                break;
    519529
    520530        case EM_SETREADONLY:
    521531                //DPRINTF_EDIT_MSG32("EM_SETREADONLY");
    522                 if (wParam)
    523                 {
    524                   SetWindowLongA(hwnd,GWL_STYLE,GetWindowLongA(hwnd,GWL_STYLE) | ES_READONLY);
    525                   es->style |= ES_READONLY;
    526                 } else
    527                 {
    528                   SetWindowLongA(hwnd,GWL_STYLE,GetWindowLongA(hwnd,GWL_STYLE) & ~ES_READONLY);
    529                   es->style &= ~ES_READONLY;
    530                 }
    531                 result = 1;
     532                result = (LRESULT)EDIT_EM_SetReadOnly(hwnd,es,(BOOL)wParam);
    532533                break;
    533534
     
    539540        case EM_GETWORDBREAKPROC:
    540541                //DPRINTF_EDIT_MSG32("EM_GETWORDBREAKPROC");
    541                 result = (LRESULT)es->word_break_procA;
     542                result = (LRESULT)EDIT_EM_GetWordbreakProc(hwnd,es);
    542543                break;
    543544
    544545        case EM_GETPASSWORDCHAR:
    545546                //DPRINTF_EDIT_MSG32("EM_GETPASSWORDCHAR");
    546                 result = es->password_char;
     547                result = (LRESULT)EDIT_EM_GetPasswordChar(hwnd,es);
    547548                break;
    548549
     
    556557        case EM_GETMARGINS:
    557558                //DPRINTF_EDIT_MSG32("EM_GETMARGINS");
    558                 result = MAKELONG(es->left_margin, es->right_margin);
     559                result = EDIT_EM_GetMargins(hwnd,es);
    559560                break;
    560561
    561562        case EM_GETLIMITTEXT:
    562563                //DPRINTF_EDIT_MSG32("EM_GETLIMITTEXT");
    563                 result = es->buffer_limit;
     564                result = (LRESULT)EDIT_EM_GetLimitText(hwnd,es);
    564565                break;
    565566
     
    572573                //DPRINTF_EDIT_MSG32("EM_CHARFROMPOS");
    573574                result = EDIT_EM_CharFromPos(hwnd, es, SLOWORD(lParam), SHIWORD(lParam));
     575                break;
     576
     577        case EM_SETIMESTATUS:
     578                result = EDIT_EM_SetImeStatus(hwnd,es,wParam,lParam);
     579                break;
     580
     581        case EM_GETIMESTATUS:
     582                result = EDIT_EM_GetImeStatus(hwnd,es,wParam,lParam);
    574583                break;
    575584
     
    17851794 *      NB : Q137805 is unclear about this. POINT * pointer in lParam apply
    17861795 *      to Richedit, not to the edit control. Original documentation is valid.
    1787  *      FIXME: do the specs mean to return -1 if outside client area or
    1788  *              if outside formatting rectangle ???
    17891796 *
    17901797 */
     
    17921799{
    17931800        POINT pt;
    1794         RECT rc;
    17951801        INT index;
    17961802
    17971803        pt.x = x;
    17981804        pt.y = y;
    1799         GetClientRect(hwnd, &rc);
    1800         if (!PtInRect(&rc, pt))
    1801                 return -1;
     1805
     1806        if (!PtInRect(&es->format_rect,pt)) return -1;
    18021807
    18031808        index = EDIT_CharFromPos(hwnd, es, x, y, NULL);
     
    18171822        if (add_eol) {
    18181823                es->flags |= EF_USE_SOFTBRK;
    1819                 //FIXME_(edit)("soft break enabled, not implemented\n");
     1824                dprintf(("EDIT: EM_FMTLINES: soft break enabled, not implemented\n"));
    18201825        }
    18211826        return add_eol;
    18221827}
    18231828
     1829static INT EDIT_EM_GetFirstVisibleLine(HWND hwnd,EDITSTATE *es)
     1830{
     1831  return (es->style & ES_MULTILINE) ? es->y_offset : es->x_offset;
     1832}
    18241833
    18251834/*********************************************************************
     
    18741883}
    18751884
     1885static INT EDIT_EM_GetLimitText(HWND hwnd,EDITSTATE *es)
     1886{
     1887  return es->buffer_limit;
     1888}
     1889
    18761890/*********************************************************************
    18771891 *
     
    18841898        INT len;
    18851899        INT i;
     1900
     1901        if (!lpch || *(WORD*)lpch == 0) return 0;
    18861902
    18871903        if (es->style & ES_MULTILINE) {
     
    18921908        i = EDIT_EM_LineIndex(hwnd, es, line);
    18931909        src = es->text + i;
    1894         //SvL: Shouldn't this be *lpch-1? For terminating 0
    1895         //len = MIN(*(WORD *)lpch-1, EDIT_EM_LineLength(hwnd, es, i));
    18961910        len = MIN(*(WORD *)lpch, EDIT_EM_LineLength(hwnd, es, i));
    18971911        for (i = 0 ; i < len ; i++) {
     
    19011915        }
    19021916        //SvL: Terminate string
    1903         //*lpch = 0;
     1917        *lpch = 0;
    19041918        return (LRESULT)len;
    19051919}
    19061920
     1921static INT EDIT_EM_GetLineCount(HWND hwnd,EDITSTATE *es)
     1922{
     1923  return (es->style & ES_MULTILINE) ? es->line_count : 1;
     1924}
     1925
     1926static LONG EDIT_EM_GetMargins(HWND hwnd,EDITSTATE *es)
     1927{
     1928  return MAKELONG(es->left_margin, es->right_margin);
     1929}
     1930
     1931static BOOL EDIT_EM_GetModify(HWND hwnd,EDITSTATE *es)
     1932{
     1933  return ((es->flags & EF_MODIFIED) != 0);
     1934}
     1935
     1936static CHAR EDIT_EM_GetPasswordChar(HWND hwnd,EDITSTATE *es)
     1937{
     1938  return es->password_char;
     1939}
     1940
     1941static VOID EDIT_EM_GetRect(HWND hwnd,EDITSTATE *es,LPRECT lprc)
     1942{
     1943  if (lprc) CopyRect(lprc,&es->format_rect);
     1944}
    19071945
    19081946/*********************************************************************
     
    19171955
    19181956        ORDER_UINT(s, e);
     1957
    19191958        if (start)
    19201959                *start = s;
     
    19241963}
    19251964
    1926 
    19271965/*********************************************************************
    19281966 *
    19291967 *      EM_GETTHUMB
    1930  *
    1931  *      FIXME: is this right ?  (or should it be only VSCROLL)
    1932  *      (and maybe only for edit controls that really have their
    1933  *      own scrollbars) (and maybe only for multiline controls ?)
    1934  *      All in all: very poorly documented
    1935  *
    1936  *      FIXME: now it's also broken, because of the new WM_HSCROLL /
    1937  *              WM_VSCROLL handlers
    1938  *
    19391968 */
    19401969static LRESULT EDIT_EM_GetThumb(HWND hwnd, EDITSTATE *es)
    19411970{
    1942         return MAKELONG(EDIT_WM_VScroll(hwnd, es, EM_GETTHUMB, 0, 0),
    1943                 EDIT_WM_HScroll(hwnd, es, EM_GETTHUMB, 0, 0));
    1944 }
    1945 
     1971  SCROLLINFO si;
     1972
     1973  if (!(es->style & ES_MULTILINE)) return 0;
     1974
     1975  si.cbSize = sizeof(si);
     1976  si.fMask  = SIF_TRACKPOS;
     1977  return GetScrollInfo(hwnd,SB_VERT,&si) ? si.nTrackPos:0;
     1978}
     1979
     1980static PVOID EDIT_EM_GetWordbreakProc(HWND hwnd,EDITSTATE *es)
     1981{
     1982  return es->word_break_procA;
     1983}
    19461984
    19471985/*********************************************************************
     
    19601998                return es->line_count - 1;
    19611999        if (index == -1)
    1962                 index = MIN(es->selection_start, es->selection_end);
     2000                index = MIN(es->selection_start, es->selection_end); //selection_end == caret pos
    19632001
    19642002        line = 0;
     
    20212059                return lstrlenA(es->text);
    20222060
    2023         if (index == -1) {
    2024                 /* FIXME: broken
    2025                 INT32 sl = EDIT_EM_LineFromChar(wnd, es, es->selection_start);
    2026                 INT32 el = EDIT_EM_LineFromChar(wnd, es, es->selection_end);
    2027                 return es->selection_start - es->line_defs[sl].offset +
    2028                                 es->line_defs[el].offset +
    2029                                 es->line_defs[el].length - es->selection_end;
    2030                 */
    2031                 return 0;
     2061        if (index == -1)
     2062        {
     2063          INT sl = EDIT_EM_LineFromChar(hwnd,es,MIN(es->selection_start,es->selection_end));
     2064          INT el = EDIT_EM_LineFromChar(hwnd,es,MAX(es->selection_start,es->selection_end));
     2065
     2066          if (sl == el)
     2067            return EDIT_EM_LineLength(hwnd,es,sl)+es->selection_start-es->selection_end;
     2068          else
     2069            return es->selection_start+EDIT_EM_LineLength(hwnd,es,el)-es->selection_end;
    20322070        }
    20332071        line_def = es->first_line_def;
     
    20962134                nyoff = es->line_count - 1;
    20972135        dy = (es->y_offset - nyoff) * es->line_height;
    2098         if (dx || dy) {
     2136        if (dx || dy)
     2137        {
    20992138                RECT rc1;
    21002139                RECT rc;
     2140
     2141                if (dx && !(es->flags & EF_HSCROLL_TRACK))
     2142                  EDIT_NOTIFY_PARENT(hwnd, EN_HSCROLL);
     2143                if (dy && !(es->flags & EF_VSCROLL_TRACK))
     2144                  EDIT_NOTIFY_PARENT(hwnd, EN_VSCROLL);
     2145
    21012146                GetClientRect(hwnd, &rc1);
    21022147                IntersectRect(&rc, &rc1, &es->format_rect);
     
    21082153                EDIT_UpdateScrollBars(hwnd,es,dx,dy);
    21092154        }
    2110         if (dx && !(es->flags & EF_HSCROLL_TRACK))
    2111                 EDIT_NOTIFY_PARENT(hwnd, EN_HSCROLL);
    2112         if (dy && !(es->flags & EF_VSCROLL_TRACK))
    2113                 EDIT_NOTIFY_PARENT(hwnd, EN_VSCROLL);
     2155
    21142156        return TRUE;
    21152157}
     
    21782220}
    21792221
     2222BOOL EDIT_CheckNumber(CHAR *text)
     2223{
     2224  if (!text) return TRUE;
     2225
     2226  while (text[0] != 0)
     2227  {
     2228    if ((BYTE)text[0] < '0' || (BYTE)text[0] > '9') return FALSE;
     2229    text++;
     2230  }
     2231
     2232  return TRUE;
     2233}
    21802234
    21812235/*********************************************************************
    21822236 *
    21832237 *      EM_REPLACESEL
    2184  *
    2185  *      FIXME: handle ES_NUMBER and ES_OEMCONVERT here
    21862238 *
    21872239 */
     
    22372289                lstrcpyA(es->text + s, es->text + e);
    22382290        }
    2239         if (strl) {
    2240                 /* there is an insertion */
    2241                 if (can_undo) {
    2242                         if ((s == es->undo_position) ||
    2243                                         ((es->undo_insert_count) &&
    2244                                         (s == es->undo_position + es->undo_insert_count)))
    2245                                 /*
    2246                                  * insertion is new and at delete position or
    2247                                  * an extension to either left or right
    2248                                  */
    2249                                 es->undo_insert_count += strl;
    2250                         else {
    2251                                 /* new insertion undo */
    2252                                 es->undo_position = s;
    2253                                 es->undo_insert_count = strl;
    2254                                 /* new insertion makes old delete-buffer invalid */
    2255                                 *es->undo_text = '\0';
    2256                         }
    2257                 } else
    2258                         EDIT_EM_EmptyUndoBuffer(hwnd, es);
    2259 
    2260                 /* now insert */
    2261                 tl = lstrlenA(es->text);
    2262                 for (p = es->text + tl ; p >= es->text + s ; p--)
    2263                         p[strl] = p[0];
    2264                 for (i = 0 , p = es->text + s ; i < strl ; i++)
    2265                         p[i] = lpsz_replace[i];
    2266                 if(es->style & ES_UPPERCASE)
    2267                         CharUpperBuffA(p, strl);
    2268                 else if(es->style & ES_LOWERCASE)
    2269                         CharLowerBuffA(p, strl);
    2270                 s += strl;
     2291        if (strl)
     2292        {
     2293          if (es->style & ES_NUMBER && !EDIT_CheckNumber((CHAR*)lpsz_replace))
     2294            MessageBeep(MB_ICONEXCLAMATION);
     2295          else
     2296          {
     2297            /* there is an insertion */
     2298            if (can_undo) {
     2299              if ((s == es->undo_position) ||
     2300                  ((es->undo_insert_count) &&
     2301                  (s == es->undo_position + es->undo_insert_count)))
     2302                  /*
     2303                   * insertion is new and at delete position or
     2304                   * an extension to either left or right
     2305                   */
     2306                  es->undo_insert_count += strl;
     2307              else {
     2308                /* new insertion undo */
     2309                es->undo_position = s;
     2310                es->undo_insert_count = strl;
     2311                /* new insertion makes old delete-buffer invalid */
     2312                *es->undo_text = '\0';
     2313              }
     2314            } else
     2315              EDIT_EM_EmptyUndoBuffer(hwnd, es);
     2316
     2317
     2318            /* now insert */
     2319            tl = lstrlenA(es->text);
     2320            for (p = es->text + tl ; p >= es->text + s ; p--)
     2321            p[strl] = p[0];
     2322            for (i = 0 , p = es->text + s ; i < strl ; i++)
     2323              p[i] = lpsz_replace[i];
     2324
     2325            if (es->style & ES_OEMCONVERT)
     2326            {
     2327              CHAR *text = (LPSTR)HeapAlloc(es->heap,0,strl);
     2328
     2329              CharToOemBuffA(lpsz_replace,text,strl);
     2330              OemToCharBuffA(text,p,strl);
     2331              HeapFree(es->heap,0,text);
     2332            }
     2333
     2334            if(es->style & ES_UPPERCASE)
     2335              CharUpperBuffA(p, strl);
     2336            else if(es->style & ES_LOWERCASE)
     2337              CharLowerBuffA(p, strl);
     2338
     2339            s += strl;
     2340          }
    22712341        }
    22722342        /* FIXME: really inefficient */
     
    23192389        }
    23202390        if (dy) {
     2391                EDIT_NOTIFY_PARENT(hwnd, EN_VSCROLL);
    23212392                EDIT_EM_LineScroll(hwnd, es, 0, dy);
    2322                 EDIT_NOTIFY_PARENT(hwnd, EN_VSCROLL);
    23232393        }
    23242394        return MAKELONG((INT16)dy, (BOOL16)TRUE);
     
    24002470 *      EM_SETHANDLE
    24012471 *
    2402  *      FIXME:  ES_LOWERCASE, ES_UPPERCASE, ES_OEMCONVERT, ES_NUMBER ???
    2403  *
    24042472 */
    24052473static void EDIT_EM_SetHandle(HWND hwnd, EDITSTATE *es, HLOCAL hloc)
     
    24262494        es->buffer_size = LocalSize(es->hloc) - 1;
    24272495        EDIT_LockBuffer(hwnd, es);
     2496
     2497        if (es->text && es->text[0] != 0)
     2498        {
     2499          if (es->style & ES_NUMBER)
     2500          {
     2501            //CB: todo
     2502          }
     2503
     2504          if (es->style & ES_OEMCONVERT)
     2505          {
     2506            INT len = lstrlenA(es->text);
     2507            CHAR *text = (LPSTR)HeapAlloc(es->heap,0,len);
     2508
     2509            CharToOemBuffA(es->text,text,len);
     2510            OemToCharBuffA(text,es->text,len);
     2511            HeapFree(es->heap,0,text);
     2512          }
     2513
     2514          if(es->style & ES_UPPERCASE)
     2515            CharUpperA(es->text);
     2516          else if(es->style & ES_LOWERCASE)
     2517            CharLowerA(es->text);
     2518        }
    24282519
    24292520        es->x_offset = es->y_offset = 0;
     
    24742565                               INT left, INT right)
    24752566{
     2567        RECT r;
     2568        INT oldLeft = es->left_margin,oldRight = es->right_margin;
     2569
    24762570        if (action & EC_LEFTMARGIN) {
    24772571                if (left != EC_USEFONTINFO)
     
    24882582        }
    24892583        //TRACE_(edit)("left=%d, right=%d\n", es->left_margin, es->right_margin);
    2490 }
    2491 
     2584
     2585        if (oldLeft != es->left_margin || oldRight != es->right_margin)
     2586        {
     2587          GetClientRect(hwnd, &r);
     2588          EDIT_SetRectNP(hwnd, es, &r);
     2589          if (es->style & ES_MULTILINE)
     2590                  EDIT_BuildLineDefs_ML(hwnd, es);
     2591
     2592          EDIT_Refresh(hwnd,es);
     2593          if (es->flags & EF_FOCUSED) {
     2594                  DestroyCaret();
     2595                  CreateCaret(hwnd, 0, 2, es->line_height);
     2596                  EDIT_SetCaretPos(hwnd, es, es->selection_end,
     2597                                   es->flags & EF_AFTER_WRAP);
     2598                  ShowCaret(hwnd);
     2599          }
     2600        }
     2601}
     2602
     2603static void EDIT_EM_SetModify(HWND hwnd,EDITSTATE *es,BOOL fModified)
     2604{
     2605  if (fModified)
     2606    es->flags |= EF_MODIFIED;
     2607  else
     2608    es->flags &= ~(EF_MODIFIED | EF_UPDATE);  /* reset pending updates */
     2609}
    24922610
    24932611/*********************************************************************
     
    25152633}
    25162634
     2635static BOOL EDIT_EM_SetReadOnly(HWND hwnd,EDITSTATE *es,BOOL fReadOnly)
     2636{
     2637  if (fReadOnly)
     2638  {
     2639    SetWindowLongA(hwnd,GWL_STYLE,GetWindowLongA(hwnd,GWL_STYLE) | ES_READONLY);
     2640    es->style |= ES_READONLY;
     2641  } else
     2642  {
     2643    SetWindowLongA(hwnd,GWL_STYLE,GetWindowLongA(hwnd,GWL_STYLE) & ~ES_READONLY);
     2644    es->style &= ~ES_READONLY;
     2645  }
     2646
     2647  return TRUE;
     2648}
     2649
     2650static void EDIT_EM_SetRect(HWND hwnd,EDITSTATE *es,LPRECT lprc)
     2651{
     2652  if ((es->style & ES_MULTILINE) && lprc)
     2653  {
     2654    EDIT_SetRectNP(hwnd,es,lprc);
     2655    EDIT_Refresh(hwnd,es);
     2656  }
     2657}
     2658
     2659static void EDIT_EM_SetRectNP(HWND hwnd,EDITSTATE *es,LPRECT lprc)
     2660{
     2661  if ((es->style & ES_MULTILINE) && lprc)
     2662    EDIT_SetRectNP(hwnd,es,lprc);
     2663}
    25172664
    25182665/*********************************************************************
     
    26422789}
    26432790
     2791static LRESULT EDIT_EM_SetImeStatus(HWND hwnd,EDITSTATE *es,WPARAM wParam,LPARAM lParam)
     2792{
     2793  //CB: undocumented!
     2794
     2795  return 0;
     2796}
     2797
     2798static LRESULT EDIT_EM_GetImeStatus(HWND hwnd,EDITSTATE *es,WPARAM wParam,LPARAM lParam)
     2799{
     2800  //CB: undocumented!
     2801
     2802  return 0;
     2803}
    26442804
    26452805/*********************************************************************
     
    26552815            /* If the edit doesn't want the return and it's not a multiline edit, do nothing */
    26562816            if(!(es->style & ES_MULTILINE) && !(es->style & ES_WANTRETURN))
    2657                 break;
     2817            {
     2818              MessageBeep(MB_ICONEXCLAMATION);
     2819              break;
     2820            }
    26582821        case '\n':
    26592822                if (es->style & ES_MULTILINE) {
     
    26822845                break;
    26832846        default:
    2684                 if (!(es->style & ES_READONLY) && ((BYTE)c >= ' ') && (c != 127)) {
    2685                         char str[2];
    2686                         str[0] = c;
    2687                         str[1] = '\0';
    2688                         EDIT_EM_ReplaceSel(hwnd, es, TRUE, str);
    2689                 }
     2847                if (!(es->style & ES_READONLY) && ((BYTE)c >= ' ') && (c != 127))
     2848                {
     2849                  char str[2];
     2850
     2851                  if (es->style & ES_NUMBER)
     2852                  {
     2853                    if ((BYTE)c < '0' || (BYTE)c > '9') MessageBeep(MB_ICONEXCLAMATION);
     2854                    return;
     2855                  }
     2856                  str[0] = c;
     2857                  str[1] = '\0';
     2858                  EDIT_EM_ReplaceSel(hwnd, es, TRUE, str);
     2859                } else MessageBeep(MB_ICONEXCLAMATION);
    26902860                break;
    26912861        }
     
    27582928        EnableMenuItem(popup, 0, MF_BYPOSITION | (EDIT_EM_CanUndo(hwnd, es) ? MF_ENABLED : MF_GRAYED));
    27592929        /* cut */
    2760         EnableMenuItem(popup, 2, MF_BYPOSITION | ((end - start) && !(es->style & ES_PASSWORD) ? MF_ENABLED : MF_GRAYED));
     2930        EnableMenuItem(popup, 2, MF_BYPOSITION | ((end - start) && !(es->style & (ES_PASSWORD | ES_READONLY)) ? MF_ENABLED : MF_GRAYED));
    27612931        /* copy */
    27622932        EnableMenuItem(popup, 3, MF_BYPOSITION | ((end - start) && !(es->style & ES_PASSWORD) ? MF_ENABLED : MF_GRAYED));
    27632933        /* paste */
    2764         EnableMenuItem(popup, 4, MF_BYPOSITION | (IsClipboardFormatAvailable(CF_TEXT) ? MF_ENABLED : MF_GRAYED));
     2934        EnableMenuItem(popup, 4, MF_BYPOSITION | (IsClipboardFormatAvailable(CF_TEXT) && !(es->style & ES_READONLY) ? MF_ENABLED : MF_GRAYED));
    27652935        /* delete */
    2766         EnableMenuItem(popup, 5, MF_BYPOSITION | ((end - start) ? MF_ENABLED : MF_GRAYED));
     2936        EnableMenuItem(popup, 5, MF_BYPOSITION | ((end - start) && !(es->style & ES_READONLY) ? MF_ENABLED : MF_GRAYED));
    27672937        /* select all */
    27682938        EnableMenuItem(popup, 7, MF_BYPOSITION | (start || (end != lstrlenA(es->text)) ? MF_ENABLED : MF_GRAYED));
     
    35003670  ShowCaret(hwnd);
    35013671
    3502   //CB: replace
    35033672  if (es->flags & EF_UPDATE)
    35043673  {
     
    36043773        RECT r;
    36053774
    3606         es->font = font;
    36073775        dc = GetDC(hwnd);
    36083776        if (font)
    36093777                old_font = SelectObject(dc, font);
    3610         GetTextMetricsA(dc, &tm);
     3778        if (!GetTextMetricsA(dc, &tm))
     3779        {
     3780          SelectObject(dc,old_font);
     3781          ReleaseDC(hwnd,dc);
     3782
     3783          return;
     3784        }
     3785        es->font = font;
    36113786        es->line_height = tm.tmHeight;
    3612 
    3613         //@@@PH 1999/11/08 prevent division by zero
    3614         if (es->line_height == 0)
    3615           es->line_height = 12; // reasonable default?
    36163787
    36173788        es->char_width = tm.tmAveCharWidth;
     
    37213892                EDIT_MoveForward(hwnd, es, TRUE);
    37223893        }
    3723 /*
    3724  *      FIXME: gotta do some vertical scrolling here, like
    3725  *              EDIT_EM_LineScroll(wnd, 0, 1);
    3726  */
     3894
     3895        if (!(es->style & ES_MULTILINE)) return;
     3896
     3897        if (es->region_posy < 0)
     3898        {
     3899          EDIT_MoveUp_ML(hwnd,es,TRUE);
     3900        } else if (es->region_posy > 0)
     3901        {
     3902          EDIT_MoveDown_ML(hwnd,es,TRUE);
     3903        }
    37273904}
    37283905
  • TabularUnified tags/trunk/src/user32/pmframe.cpp

    r12291 r12508  
    1 /* $Id: pmframe.cpp,v 1.24 1999-11-11 17:13:45 cbratschi Exp $ */
     1/* $Id: pmframe.cpp,v 1.25 1999-12-01 18:23:28 cbratschi Exp $ */
    22/*
    33 * Win32 Frame Managment Code for OS/2
     
    312312        goto RunDefFrameProc; //CB: must call def frame proc or frame control activation is broken
    313313    }
    314        
     314
    315315    case WM_WINDOWPOSCHANGED:
    316316    {
  • TabularUnified tags/trunk/src/user32/scroll.cpp

    r12414 r12508  
    1 /* $Id: scroll.cpp,v 1.25 1999-11-24 18:21:37 cbratschi Exp $ */
     1/* $Id: scroll.cpp,v 1.26 1999-12-01 18:23:28 cbratschi Exp $ */
    22/*
    33 * Scrollbar control
     
    8383      {
    8484        Win32BaseWindow *win32wnd = Win32BaseWindow::GetWindowFromHandle(hwnd);
     85
    8586        if (!win32wnd) return 0;
    86         if (nBar == SB_HORZ) return  Win32BaseWindow::OS2ToWin32Handle(win32wnd->getHorzScrollHandle());
    87         else return  Win32BaseWindow::OS2ToWin32Handle(win32wnd->getVertScrollHandle());
     87        if (nBar == SB_HORZ)
     88          return  (win32wnd->getStyle() & WS_HSCROLL) ? Win32BaseWindow::OS2ToWin32Handle(win32wnd->getHorzScrollHandle()):0;
     89        else
     90          return (win32wnd->getStyle() & WS_VSCROLL) ? Win32BaseWindow::OS2ToWin32Handle(win32wnd->getVertScrollHandle()):0;
    8891      }
     92
    8993    case SB_CTL:
    9094      return hwnd;
     
    14221426        {
    14231427          action = SA_SSI_HIDE;
     1428          infoPtr->flags = 0;
    14241429          goto done;
    14251430        }
     
    16301635        dprintf(("ShowScrollBar window not found!"));
    16311636        SetLastError(ERROR_INVALID_WINDOW_HANDLE);
    1632         return 0;
     1637        return FALSE;
    16331638      }
    16341639
     
    16631668  {
    16641669    Win32BaseWindow *window = Win32BaseWindow::GetWindowFromHandle(hwnd);
     1670
    16651671    if(!window)
    16661672    {
     
    16741680      BOOL rc = FALSE;
    16751681
    1676       if (nBar == SB_VERT || nBar == SB_BOTH)
     1682      if ((nBar == SB_VERT || nBar == SB_BOTH) && window->getStyle() & WS_VSCROLL)
    16771683      {
    16781684        HWND hwndScroll =  Win32BaseWindow::OS2ToWin32Handle(window->getVertScrollHandle());
     
    16901696        }
    16911697      }
    1692       if (nBar == SB_HORZ || (rc && nBar == SB_BOTH))
     1698      if ((nBar == SB_HORZ || (rc && nBar == SB_BOTH)) && window->getStyle() & WS_HSCROLL)
    16931699      {
    1694         HWND hwndScroll =  Win32BaseWindow::OS2ToWin32Handle(window->getVertScrollHandle());
     1700        HWND hwndScroll =  Win32BaseWindow::OS2ToWin32Handle(window->getHorzScrollHandle());
    16951701
    16961702        infoPtr = SCROLL_GetInfoPtr(hwndScroll,SB_VERT);
  • TabularUnified tags/trunk/src/user32/win32wbase.cpp

    r12503 r12508  
    1 /* $Id: win32wbase.cpp,v 1.99 1999-12-01 10:49:45 sandervl Exp $ */
     1/* $Id: win32wbase.cpp,v 1.100 1999-12-01 18:23:29 cbratschi Exp $ */
    22/*
    33 * Win32 Window Base Class for OS/2
     
    13461346    {
    13471347      DWORD newFlags;
     1348
    13481349      rc = FrameShowScrollBars(this,showHorz,showVert,fShow,FALSE,&newFlags);
    13491350      flags |= newFlags;
Note: See TracChangeset for help on using the changeset viewer.