Changeset 1525 for trunk/src/user32


Ignore:
Timestamp:
Oct 30, 1999, 8:40:49 PM (26 years ago)
Author:
cbratschi
Message:

button, static, scroll and dialog fixes

Location:
trunk/src/user32
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/user32/button.cpp

    r1433 r1525  
    1 /* $Id: button.cpp,v 1.15 1999-10-24 22:56:00 sandervl Exp $ */
     1/* $Id: button.cpp,v 1.16 1999-10-30 18:40:43 cbratschi Exp $ */
    22/* File: button.cpp -- Button type widgets
    33 *
     
    626626}
    627627
     628static INT BUTTON_GetTextFormat(DWORD dwStyle,INT defHorz,INT defVert)
     629{
     630  INT format = 0;
     631
     632  if (dwStyle & BS_LEFT) format = DT_LEFT;
     633  else if (dwStyle & BS_CENTER) format = DT_CENTER;
     634  else if (dwStyle & BS_RIGHT) format = DT_RIGHT;
     635  else format = defHorz;
     636
     637  if (dwStyle & BS_TOP) format |= DT_TOP;
     638  else if (dwStyle & BS_VCENTER) format |= DT_VCENTER;
     639  else if (dwStyle & BS_BOTTOM) format |= DT_BOTTOM;
     640  else format |= defVert;
     641
     642  if (!(dwStyle & BS_MULTILINE)) format |= DT_SINGLELINE;
     643
     644  return format;
     645}
     646
    628647/**********************************************************************
    629648 * This method will actually do the drawing of the pushbutton
     
    692711    if (textLen > 0 && (!(dwStyle & (BS_ICON|BS_BITMAP))))
    693712    {
     713        INT format = BUTTON_GetTextFormat(dwStyle,DT_CENTER,DT_VCENTER);
     714
    694715        textLen++;
    695716        text = (char*)malloc(textLen);
    696717        GetWindowTextA(hwnd,text,textLen);
    697718
    698         if (dwStyle & WS_DISABLED) DrawDisabledText(hDC,text,&rc,DT_SINGLELINE | DT_CENTER | DT_VCENTER); else
     719        if (dwStyle & WS_DISABLED) DrawDisabledText(hDC,text,&rc,format); else
    699720        {
    700             SetTextColor( hDC, GetSysColor(COLOR_BTNTEXT) );
    701             DrawTextA( hDC, text, -1, &rc,
    702                          DT_SINGLELINE | DT_CENTER | DT_VCENTER );
     721            SetTextColor(hDC,GetSysColor(COLOR_BTNTEXT));
     722            DrawTextA(hDC,text,-1,&rc,format);
    703723            /* do we have the focus?
    704724             * Win9x draws focus last with a size prop. to the button
     
    903923        if( text && action != ODA_SELECT )
    904924        {
    905 
    906           if (dwStyle & WS_DISABLED) DrawDisabledText(hDC,text,&rtext,DT_SINGLELINE | DT_VCENTER);
    907           else DrawTextA(hDC,text,-1,&rtext,DT_SINGLELINE | DT_VCENTER);
     925          INT format = BUTTON_GetTextFormat(dwStyle,DT_TOP,DT_VCENTER);
     926
     927          if (dwStyle & WS_DISABLED) DrawDisabledText(hDC,text,&rtext,format);
     928          else DrawTextA(hDC,text,-1,&rtext,format);
    908929        }
    909930    }
     
    916937        SetRectEmpty(&rbox);
    917938        if(textLen > 0)
    918           DrawTextA( hDC, text, -1, &rbox,
    919                      DT_SINGLELINE | DT_CALCRECT );
     939          DrawTextA(hDC,text,-1,&rbox,DT_SINGLELINE | DT_CALCRECT);
    920940        textLen = rbox.bottom - rbox.top;
    921941        delta = ((rtext.bottom - rtext.top) - textLen)/2;
     
    943963    parent = GetParent(hwnd);
    944964    /* assure that starting control is not disabled or invisible */
    945 //    start = sibling = GetNextDlgGroupItem( parent, hwnd, TRUE );
     965    start = sibling = GetNextDlgGroupItem( parent, hwnd, TRUE );
    946966    //@YD: bugfix
    947     start = sibling = GetNextDlgGroupItem( parent, hwnd, FALSE );
     967    //CB: doesn't work!
     968    //start = sibling = GetNextDlgGroupItem( parent, hwnd, FALSE );
    948969    do
    949970    {
     
    9871008    if (textLen > 0)
    9881009    {
    989         textLen++;
    990         text = (char*)malloc(textLen);
    991         GetWindowTextA(hwnd,text,textLen);
    992         if (infoPtr->hFont) SelectObject( hDC, infoPtr->hFont );
    993         rc.left += 10;
    994 
    995         if (dwStyle & WS_DISABLED) DrawDisabledText(hDC,text,&rc,DT_SINGLELINE | DT_NOCLIP); else
    996         {
    997             SetTextColor( hDC, GetSysColor(COLOR_BTNTEXT) );
    998             DrawTextA( hDC, text, -1, &rc,
    999                          DT_SINGLELINE | DT_NOCLIP );
    1000         }
    1001 
    1002         free(text);
     1010      INT format = BUTTON_GetTextFormat(dwStyle,DT_LEFT,DT_TOP) | DT_NOCLIP | DT_SINGLELINE;
     1011
     1012      textLen++;
     1013      text = (char*)malloc(textLen);
     1014      GetWindowTextA(hwnd,text,textLen);
     1015      if (infoPtr->hFont) SelectObject( hDC, infoPtr->hFont );
     1016      rc.left += 10;
     1017
     1018      if (dwStyle & WS_DISABLED) DrawDisabledText(hDC,text,&rc,format); else
     1019      {
     1020        SetTextColor(hDC,GetSysColor(COLOR_BTNTEXT));
     1021        DrawTextA(hDC,text,-1,&rc,format);
     1022      }
     1023
     1024      free(text);
    10031025    }
    10041026}
  • trunk/src/user32/dc.cpp

    r1405 r1525  
    1 /* $Id: dc.cpp,v 1.17 1999-10-22 18:11:43 sandervl Exp $ */
     1/* $Id: dc.cpp,v 1.18 1999-10-30 18:40:43 cbratschi Exp $ */
    22
    33/*
     
    13421342    HRGN  hrgn;
    13431343
     1344    if (scrollFlag & SW_SMOOTHSCROLL_W)
     1345    {
     1346      INT time = (scrollFlag >> 16) & 0xFFFF;
     1347
     1348      //CB: todo, scroll in several steps
     1349      //    is time in ms? time <-> iteration count?
     1350    }
     1351
    13441352    LONG lComplexity = WinScrollWindow (window->getOS2WindowHandle(), dx, dy,
    13451353                                        (pScroll) ? &scrollRect : NULL,
  • trunk/src/user32/dc.h

    r1405 r1525  
    1 /* $Id: dc.h,v 1.5 1999-10-22 18:11:44 sandervl Exp $ */
     1/* $Id: dc.h,v 1.6 1999-10-30 18:40:44 cbratschi Exp $ */
    22/*
    33 * public dc functions
     
    145145#define SW_INVALIDATE_W        0x0002
    146146#define SW_ERASE_W             0x0004
     147#define SW_SMOOTHSCROLL_W      0x0010
    147148
    148149/*********************/
     
    164165
    165166    return yyrc;
    166 } 
     167}
    167168
    168169//LONG    APIENTRY GpiQueryYInversion (HPS hps);
     
    179180
    180181    return yyrc;
    181 } 
     182}
    182183
    183184PVOID   APIENTRY _GpiQueryDCData (HPS hps);
     
    192193
    193194    return yyrc;
    194 } 
     195}
    195196
    196197HDC     OPEN32API _HPSToHDC (HWND hwnd, HPS hps, HDC hdc, PVOID a);
     
    205206
    206207    return yyrc;
    207 } 
     208}
    208209
    209210void    OPEN32API _DeleteHDC (HDC hdc);
     
    215216    _DeleteHDC(hdc);
    216217    SetFS(sel);
    217 } 
     218}
    218219
    219220BOOL    OPEN32API _O32_EndPaint (HWND hwnd, const PAINTSTRUCT_W *lpps);
     
    228229
    229230    return yyrc;
    230 } 
     231}
    231232
    232233int     OPEN32API _O32_GetUpdateRgn (HWND hwnd, HRGN hrgn, BOOL erase);
     
    241242
    242243    return yyrc;
    243 } 
     244}
    244245
    245246ULONG   OPEN32API _O32_GetRegionData (HRGN hrgn, ULONG count, PRGNDATA_W pData);
     
    254255
    255256    return yyrc;
    256 } 
     257}
    257258
    258259BOOL    OPEN32API _O32_DeleteObject (LHANDLE hgdiobj);
     
    267268
    268269    return yyrc;
    269 } 
     270}
    270271
    271272int     OPEN32API _O32_ReleaseDC (HWND hwnd, HDC hdc);
     
    280281
    281282    return yyrc;
    282 } 
     283}
    283284
    284285VOID    OPEN32API _O32_SetLastError( DWORD );
     
    290291    _O32_SetLastError(a);
    291292    SetFS(sel);
    292 } 
     293}
    293294
    294295BOOL    OPEN32API _O32_SetRectRgn (HRGN dest, int left, int top, int right, int bottom);
     
    303304
    304305    return yyrc;
    305 } 
     306}
    306307
    307308int     OPEN32API _O32_CombineRgn (HRGN dest, HRGN src1, HRGN src2, int mode);
     
    316317
    317318    return yyrc;
    318 } 
     319}
    319320
    320321HRGN    OPEN32API _O32_CreateRectRgn (int left, int top, int right, int bottom);
     
    329330
    330331    return yyrc;
    331 } 
     332}
    332333
    333334BOOL OPEN32API _O32_CreateCaret (HWND hwnd, HBITMAP hbm, int width, int height);
     
    342343
    343344    return yyrc;
    344 } 
     345}
    345346
    346347BOOL    APIENTRY  __DestroyCaret (void);
     
    355356
    356357    return yyrc;
    357 } 
     358}
    358359
    359360UINT    APIENTRY  __GetCaretBlinkTime (void);
     
    368369
    369370    return yyrc;
    370 } 
     371}
    371372
    372373BOOL    APIENTRY  __HideCaret (HWND hwnd);
     
    382383    return yyrc;
    383384}
    384  
     385
    385386BOOL    APIENTRY  __SetCaretBlinkTime (UINT mSecs);
    386387
     
    394395
    395396    return yyrc;
    396 } 
     397}
    397398
    398399BOOL    APIENTRY  __ShowCaret (HWND hwnd);
     
    407408
    408409    return yyrc;
    409 } 
     410}
    410411
    411412#endif //INCLUDED_BY_DC
  • trunk/src/user32/pmframe.cpp

    r1511 r1525  
    1 /* $Id: pmframe.cpp,v 1.13 1999-10-29 16:06:55 cbratschi Exp $ */
     1/* $Id: pmframe.cpp,v 1.14 1999-10-30 18:40:44 cbratschi Exp $ */
    22/*
    33 * Win32 Frame Managment Code for OS/2
     
    387387
    388388PosChangedEnd:
    389         RestoreOS2TIB();
     389        RestoreOS2TIB();
    390390        return rc;
    391391    }
     
    426426#else
    427427    case WM_ACTIVATE:
     428      {
     429        RestoreOS2TIB();
     430        MRESULT rc = OldFrameProc(hwnd,msg,mp1,mp2);
     431        //CB: overwrite OS/2's default frame
    428432        DrawActivate(win32wnd, hwnd);
    429         goto RunDefFrameProc;
     433        return rc;
     434      }
     435
    430436#endif
    431437#else
  • trunk/src/user32/scroll.cpp

    r1511 r1525  
    1 /* $Id: scroll.cpp,v 1.16 1999-10-29 16:06:56 cbratschi Exp $ */
     1/* $Id: scroll.cpp,v 1.17 1999-10-30 18:40:45 cbratschi Exp $ */
    22/*
    33 * Scrollbar control
     
    99 *
    1010 * WINE version: 990923
     11 *
     12 * Status:  complete
     13 * Version: 5.00
    1114 */
    1215
     
    879882        if (msg == WM_LBUTTONUP)
    880883          KillSystemTimer(hwnd,SCROLL_TIMER);
    881         else if (msg == WM_LBUTTONDOWN || !timerRunning)
     884        else if (msg == WM_LBUTTONDOWN || (!timerRunning && msg == WM_SYSTIMER))
    882885        {
    883886          SetSystemTimer( hwnd, SCROLL_TIMER, (msg == WM_LBUTTONDOWN) ?
     
    900903        if (msg == WM_LBUTTONUP)
    901904          KillSystemTimer(hwnd,SCROLL_TIMER);
    902         else if (msg == WM_LBUTTONDOWN || !timerRunning)
     905        else if (msg == WM_LBUTTONDOWN || (!timerRunning && msg == WM_SYSTIMER))
    903906        {
    904907          SetSystemTimer( hwnd, SCROLL_TIMER, (msg == WM_LBUTTONDOWN) ?
     
    974977        if (msg == WM_LBUTTONUP)
    975978          KillSystemTimer(hwnd,SCROLL_TIMER);
    976         else if (msg == WM_LBUTTONDOWN || !timerRunning)
     979        else if (msg == WM_LBUTTONDOWN || (!timerRunning && msg == WM_SYSTIMER))
    977980        {
    978981          SetSystemTimer( hwnd, SCROLL_TIMER, (msg == WM_LBUTTONDOWN) ?
     
    9981001        if (msg == WM_LBUTTONUP)
    9991002          KillSystemTimer(hwnd,SCROLL_TIMER);
    1000         else if (msg == WM_LBUTTONDOWN || !timerRunning)
     1003        else if (msg == WM_LBUTTONDOWN || (!timerRunning && msg == WM_SYSTIMER))
    10011004        {
    10021005          SetSystemTimer( hwnd, SCROLL_TIMER, (msg == WM_LBUTTONDOWN) ?
     
    16061609    return TRUE;
    16071610}
     1611
    16081612/*************************************************************************
    16091613 *           EnableScrollBar   (USER32.171)
     
    16771681    }
    16781682  }
     1683
     1684  return TRUE;
     1685}
     1686
     1687//CB: not listed in user32.exp -> don't know the id!
     1688
     1689BOOL WINAPI GetScrollBarInfo(HWND hwnd,LONG idObject,PSCROLLBARINFO psbi)
     1690{
     1691  if (!psbi || psbi->cbSize != sizeof(SCROLLBARINFO))
     1692  {
     1693    SetLastError(ERROR_INVALID_PARAMETER);
     1694
     1695    return FALSE;
     1696  }
     1697
     1698  HWND hwndScroll;
     1699  INT nBar,arrowSize;
     1700
     1701  switch (idObject)
     1702  {
     1703    case OBJID_CLIENT:
     1704      nBar = SB_CTL;
     1705      hwndScroll = hwnd;
     1706      break;
     1707
     1708    case OBJID_HSCROLL:
     1709      nBar = SB_HORZ;
     1710      hwndScroll = SCROLL_GetScrollHandle(hwnd,SB_HORZ);
     1711      break;
     1712
     1713    case OBJID_VSCROLL:
     1714      nBar = SB_VERT;
     1715      hwndScroll = SCROLL_GetScrollHandle(hwnd,SB_VERT);
     1716      break;
     1717
     1718    default:
     1719      return FALSE;
     1720  }
     1721
     1722  if (!hwndScroll) return FALSE;
     1723
     1724  SCROLL_GetScrollBarRect(hwndScroll,nBar,&psbi->rcScrollBar,&arrowSize,&psbi->dxyLineButton,&psbi->xyThumbTop);
     1725  psbi->xyThumbBottom = psbi->xyThumbTop+psbi->dxyLineButton;
     1726  psbi->bogus = 0; //CB: undocumented!
     1727  psbi->rgstate[0] = IsWindowVisible(hwndScroll) ? STATE_SYSTEM_INVISIBLE:0;
     1728  psbi->rgstate[1] = psbi->rgstate[2] = psbi->rgstate[3] = psbi->rgstate[4] = psbi->rgstate[5] = psbi->rgstate[0]; //CB: todo
    16791729
    16801730  return TRUE;
  • trunk/src/user32/static.cpp

    r1433 r1525  
    1 /* $Id: static.cpp,v 1.7 1999-10-24 22:56:07 sandervl Exp $ */
     1/* $Id: static.cpp,v 1.8 1999-10-30 18:40:46 cbratschi Exp $ */
    22/*
    33 * Static control
    44 *
    5  * Copyright 1999 Christoph Bratschi (ported from WINE)
     5 * Copyright 1999 Christoph Bratschi
    66 *
    77 * Copyright  David W. Metcalfe, 1993
    88 *
    99 * WINE version: 990923
     10 *
     11 * Status:  complete
     12 * Version: 5.00
    1013 */
    1114
     
    2124static void STATIC_PaintIconfn( HWND hwnd, HDC hdc );
    2225static void STATIC_PaintBitmapfn( HWND hwnd, HDC hdc );
     26static void STATIC_PaintMetafilefn(HWND hwnd,HDC hdc);
     27static void STATIC_PaintOwnerDrawfn(HWND hwnd,HDC hdc);
    2328static void STATIC_PaintEtchedfn( HWND hwnd, HDC hdc );
    2429
     
    4045    STATIC_PaintRectfn,      /* SS_GRAYFRAME */
    4146    STATIC_PaintRectfn,      /* SS_WHITEFRAME */
    42     NULL,                    /* Not defined */
     47    NULL,                    /* SS_USERITEM */
    4348    STATIC_PaintTextfn,      /* SS_SIMPLE */
    4449    STATIC_PaintTextfn,      /* SS_LEFTNOWORDWRAP */
    45     NULL,                    /* SS_OWNERDRAW */
     50    STATIC_PaintOwnerDrawfn, /* SS_OWNERDRAW */
    4651    STATIC_PaintBitmapfn,    /* SS_BITMAP */
    47     NULL,                    /* SS_ENHMETAFILE */
     52    STATIC_PaintMetafilefn,  /* SS_ENHMETAFILE */
    4853    STATIC_PaintEtchedfn,    /* SS_ETCHEDHORIZ */
    4954    STATIC_PaintEtchedfn,    /* SS_ETCHEDVERT */
     
    5156};
    5257
     58static void STATIC_ResizeWindow(HWND hwnd,DWORD dwStyle,INT w,INT h)
     59{
     60  if (dwStyle & SS_RIGHTJUST)
     61  {
     62    RECT rect;
     63
     64    GetWindowRect(hwnd,&rect);
     65    SetWindowPos(hwnd,0,rect.right-w,rect.bottom-h,w,h,SWP_NOACTIVATE | SWP_NOZORDER);
     66  } else SetWindowPos(hwnd,0,0,0,w,h,SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOZORDER);
     67}
    5368
    5469/***********************************************************************
     
    7186    infoPtr->hIcon = hicon;
    7287
    73     GetIconInfo(hicon,&ii);
     88    if (!GetIconInfo(hicon,&ii)) return prevIcon;
    7489    GetObjectA(ii.hbmColor,sizeof(BITMAP),(LPVOID)&bmp);
    7590
    76     SetWindowPos(hwnd,0,0,0,bmp.bmWidth,bmp.bmHeight,SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOZORDER );
     91    if (!(dwStyle & (SS_CENTERIMAGE | SS_REALSIZEIMAGE))) STATIC_ResizeWindow(hwnd,dwStyle,bmp.bmWidth,bmp.bmHeight);
    7792
    7893    return prevIcon;
     
    98113    hOldBitmap = infoPtr->hIcon;
    99114    infoPtr->hIcon = hBitmap;
    100     if (hBitmap)
     115    if (hBitmap && !(dwStyle & (SS_CENTERIMAGE | SS_REALSIZEIMAGE)))
    101116    {
    102         BITMAP bm;
    103         GetObjectA(hBitmap, sizeof(bm), &bm);
    104         SetWindowPos( hwnd, 0, 0, 0, bm.bmWidth, bm.bmHeight,
    105                       SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOZORDER );
     117      BITMAP bm;
     118
     119      GetObjectA(hBitmap,sizeof(bm),&bm);
     120      STATIC_ResizeWindow(hwnd,dwStyle,bm.bmWidth,bm.bmHeight);
    106121    }
     122
    107123    return hOldBitmap;
     124}
     125
     126static HENHMETAFILE STATIC_SetMetafile(HWND hwnd,HENHMETAFILE hMetafile)
     127{
     128  HENHMETAFILE hOldMetafile;
     129
     130  STATICINFO *infoPtr = (STATICINFO *)GetInfoPtr(hwnd);
     131  DWORD dwStyle = GetWindowLongA(hwnd,GWL_STYLE);
     132
     133  if ((dwStyle & SS_TYPEMASK) != SS_ENHMETAFILE) return 0;
     134
     135  hOldMetafile = infoPtr->hIcon;
     136  infoPtr->hIcon = hMetafile;
     137
     138  return hOldMetafile;
    108139}
    109140
     
    142173}
    143174
     175static HBITMAP STATIC_LoadMetafile(HWND hwnd,LPCSTR name)
     176{
     177  HENHMETAFILE hMetafile;
     178
     179  hMetafile = GetEnhMetaFileA(name); //CB: right?
     180
     181  return hMetafile;
     182}
     183
    144184/* message handler */
    145185
    146186LRESULT STATIC_NCCreate(HWND hwnd,WPARAM wParam,LPARAM lParam)
    147187{
    148   CREATESTRUCTA *cs = (CREATESTRUCTA *)lParam;
     188  CREATESTRUCTA *cs = (CREATESTRUCTA*)lParam;
    149189  STATICINFO* infoPtr;
    150190  DWORD dwStyle = GetWindowLongA(hwnd,GWL_STYLE);
     
    166206  if (style == SS_ICON)
    167207  {
    168     if (cs->lpszName)
     208    if (cs->lpszName) //CB: is 0 a valid icon id? winhlp32: lpszName = NULL
    169209    {
    170210      if (!HIWORD(cs->lpszName) || cs->lpszName[0])
     
    179219    return TRUE;
    180220  }
     221  if (style == SS_ENHMETAFILE)
     222  {
     223    if (cs->lpszName) STATIC_SetMetafile(hwnd,STATIC_LoadMetafile(hwnd,cs->lpszName));
     224    return TRUE;
     225  }
    181226  if (!HIWORD(cs->lpszName) && (cs->lpszName)) return TRUE;
    182227
     
    213258  {
    214259    DeleteObject(infoPtr->hIcon);
     260  } else if (style == SS_ENHMETAFILE && infoPtr->hIcon)
     261  {
     262    DeleteEnhMetaFile((HENHMETAFILE)infoPtr->hIcon);
    215263  }
    216264
     
    234282LRESULT STATIC_Enable(HWND hwnd,WPARAM wParam,LPARAM lParam)
    235283{
     284  DWORD dwStyle = GetWindowLongA(hwnd,GWL_STYLE);
     285
     286  if (dwStyle & SS_NOTIFY) SendMessageA(GetParent(hwnd),WM_COMMAND,MAKEWPARAM(GetWindowLongA(hwnd,GWL_ID),wParam ? STN_ENABLE:STN_DISABLE),hwnd);
     287
    236288  InvalidateRect(hwnd,NULL,FALSE);
    237289
     
    258310  else if (style == SS_BITMAP)
    259311    STATIC_SetBitmap(hwnd,STATIC_LoadBitmap(hwnd,(LPCSTR)lParam));
     312  else if (style == SS_ENHMETAFILE)
     313    STATIC_SetMetafile(hwnd,STATIC_LoadMetafile(hwnd,(LPCSTR)lParam));
    260314  else
    261315    DefWindowProcA(hwnd,WM_SETTEXT,wParam,lParam);
     
    274328  if (style == SS_ICON) return 0;
    275329  if (style == SS_BITMAP) return 0;
     330  if (style == SS_ENHMETAFILE) return 0;
    276331
    277332  infoPtr->hFont = (HFONT)wParam;
     
    310365}
    311366
     367LRESULT STATIC_GetImage(HWND hwnd,WPARAM wParam,LPARAM lParam)
     368{
     369  STATICINFO* infoPtr = (STATICINFO*)GetInfoPtr(hwnd);
     370  DWORD style = GetWindowLongA(hwnd,GWL_STYLE) & SS_TYPEMASK;
     371
     372  switch (wParam)
     373  {
     374    case IMAGE_BITMAP:
     375      if (style & SS_BITMAP) return infoPtr->hIcon;
     376      break;
     377
     378    case IMAGE_CURSOR:
     379    case IMAGE_ICON:
     380      if (style & SS_ICON) return infoPtr->hIcon;
     381      break;
     382
     383    case IMAGE_ENHMETAFILE:
     384      if (style & SS_ENHMETAFILE) return infoPtr->hIcon;
     385      break;
     386
     387    default:
     388      break;
     389  }
     390
     391  return 0;
     392}
     393
    312394LRESULT STATIC_SetImage(HWND hwnd,WPARAM wParam,LPARAM lParam)
    313395{
    314   LRESULT lResult;
     396  LRESULT lResult = 0;
    315397
    316398  switch (wParam)
     
    320402      lResult = STATIC_SetIcon(hwnd,(HICON)lParam);
    321403      break;
     404
    322405    case IMAGE_BITMAP:
    323406      lResult = STATIC_SetBitmap(hwnd,(HBITMAP)lParam);
     407      break;
     408
    324409    case IMAGE_ENHMETAFILE:
    325       return 0; //CB: not supported!
     410      lResult = STATIC_SetMetafile(hwnd,(HENHMETAFILE)lParam);
     411      break;
     412
    326413    default:
    327414      return 0;
    328415  }
    329416
     417  if (lResult) InvalidateRect(hwnd,NULL,FALSE);
     418
     419  return lResult;
     420}
     421
     422LRESULT STATIC_SetIconMsg(HWND hwnd,WPARAM wParam,LPARAM lParam)
     423{
     424  LRESULT lResult;
     425
     426  lResult = STATIC_SetIcon(hwnd,(HICON)wParam);
     427
    330428  InvalidateRect(hwnd,NULL,FALSE);
    331   UpdateWindow(hwnd);
    332429
    333430  return lResult;
    334431}
    335432
    336 LRESULT STATIC_SetIcon(HWND hwnd,WPARAM wParam,LPARAM lParam)
    337 {
    338   LRESULT lResult;
    339 
    340   lResult = STATIC_SetIcon(hwnd,(HICON)wParam);
    341 
    342   InvalidateRect(hwnd,NULL,FALSE);
    343   UpdateWindow(hwnd);
    344 
    345   return lResult;
     433LRESULT STATIC_Click(HWND hwnd,UINT uMsg,WPARAM wParam,LPARAM lParam)
     434{
     435  DWORD dwStyle = GetWindowLongA(hwnd,GWL_STYLE);
     436
     437  if (dwStyle & SS_NOTIFY) SendMessageA(GetParent(hwnd),WM_COMMAND,MAKEWPARAM(GetWindowLongA(hwnd,GWL_ID),STN_CLICKED),hwnd);
     438
     439  return DefWindowProcA(hwnd,uMsg,wParam,lParam);
     440}
     441
     442LRESULT STATIC_DoubleClick(HWND hwnd,UINT uMsg,WPARAM wParam,LPARAM lParam)
     443{
     444  DWORD dwStyle = GetWindowLongA(hwnd,GWL_STYLE);
     445
     446  if (dwStyle & SS_NOTIFY) SendMessageA(GetParent(hwnd),WM_COMMAND,MAKEWPARAM(GetWindowLongA(hwnd,GWL_ID),STN_DBLCLK),hwnd);
     447
     448  return DefWindowProcA(hwnd,uMsg,wParam,lParam);
    346449}
    347450
     
    386489      return STATIC_GetDlgCode(hwnd,wParam,lParam);
    387490
     491    case WM_LBUTTONDOWN:
     492    case WM_NCLBUTTONDOWN:
     493      return STATIC_Click(hwnd,uMsg,wParam,lParam);
     494
     495    case WM_LBUTTONDBLCLK:
     496    case WM_NCLBUTTONDBLCLK:
     497      return STATIC_DoubleClick(hwnd,uMsg,wParam,lParam);
     498
    388499    case STM_GETIMAGE:
     500      return STATIC_GetImage(hwnd,wParam,lParam);
     501
    389502    case STM_GETICON:
    390503      return STATIC_GetIcon(hwnd,wParam,lParam);
     
    394507
    395508    case STM_SETICON:
    396       return STATIC_SetIcon(hwnd,wParam,lParam);
     509      return STATIC_SetIconMsg(hwnd,wParam,lParam);
     510
     511    case STM_MSGMAX:
     512      return 0; //CB: undocumented!
    397513
    398514    default:
     
    411527    WORD wFormat;
    412528    DWORD dwStyle = GetWindowLongA(hwnd,GWL_STYLE);
    413     LONG style = dwStyle;
    414529    STATICINFO *infoPtr = (STATICINFO *)GetInfoPtr(hwnd);
    415530    INT textLen;
     
    417532    GetClientRect(hwnd,&rc);
    418533
    419     switch (style & SS_TYPEMASK)
     534    switch (dwStyle & SS_TYPEMASK)
    420535    {
    421     case SS_LEFT:
     536      case SS_LEFT:
    422537        wFormat = DT_LEFT | DT_EXPANDTABS | DT_WORDBREAK | DT_NOCLIP;
    423538        break;
    424539
    425     case SS_CENTER:
     540      case SS_CENTER:
     541      case SS_CENTERIMAGE:
    426542        wFormat = DT_CENTER | DT_EXPANDTABS | DT_WORDBREAK | DT_NOCLIP;
    427543        break;
    428544
    429     case SS_RIGHT:
     545      case SS_RIGHT:
    430546        wFormat = DT_RIGHT | DT_EXPANDTABS | DT_WORDBREAK | DT_NOCLIP;
    431547        break;
    432548
    433     case SS_SIMPLE:
     549      case SS_SIMPLE:
    434550        wFormat = DT_LEFT | DT_SINGLELINE | DT_VCENTER | DT_NOCLIP;
    435551        break;
    436552
    437     case SS_LEFTNOWORDWRAP:
     553      case SS_LEFTNOWORDWRAP:
    438554        wFormat = DT_LEFT | DT_EXPANDTABS | DT_VCENTER;
    439555        break;
    440556
    441     default:
     557      default:
    442558        return;
    443559    }
    444560
    445     if (style & SS_NOPREFIX)
    446         wFormat |= DT_NOPREFIX;
     561    if (dwStyle & SS_NOPREFIX) wFormat |= DT_NOPREFIX;
     562    if (dwStyle & SS_ENDELLIPSIS) wFormat |= DT_END_ELLIPSIS;
     563    if (dwStyle & SS_PATHELLIPSIS) wFormat |= DT_PATH_ELLIPSIS;
     564    if (dwStyle & SS_WORDELLIPSIS) wFormat |= DT_WORD_ELLIPSIS;
    447565
    448566    if (infoPtr->hFont) SelectObject( hdc, infoPtr->hFont );
     
    462580      text = (char*)malloc(textLen);
    463581      GetWindowTextA(hwnd,text,textLen);
    464       DrawTextA( hdc, text, -1, &rc, wFormat );
     582      DrawTextExA(hdc,text,-1,&rc,wFormat,NULL);
    465583      free(text);
    466584    }
     
    513631    HBRUSH hbrush;
    514632    STATICINFO *infoPtr = (STATICINFO *)GetInfoPtr(hwnd);
     633    DWORD dwStyle = GetWindowLongA(hwnd,GWL_STYLE);
    515634
    516635    GetClientRect( hwnd, &rc );
     
    518637                             hdc, hwnd );
    519638    FillRect( hdc, &rc, hbrush );
    520     if (infoPtr->hIcon) DrawIcon( hdc, rc.left, rc.top, infoPtr->hIcon );
     639    if (dwStyle & SS_CENTERIMAGE)
     640    {
     641      ICONINFO ii;
     642      BITMAP bmp;
     643
     644      if (!GetIconInfo(infoPtr->hIcon,&ii)) return;
     645      GetObjectA(ii.hbmColor,sizeof(BITMAP),(LPVOID)&bmp);
     646      DrawIcon(hdc,(rc.right-bmp.bmWidth)/2,(rc.bottom-bmp.bmHeight)/2,infoPtr->hIcon);
     647    } else if (infoPtr->hIcon) DrawIcon(hdc,rc.left,rc.top,infoPtr->hIcon);
    521648}
    522649
     
    526653    HBRUSH hbrush;
    527654    STATICINFO *infoPtr = (STATICINFO *)GetInfoPtr(hwnd);
     655    DWORD dwStyle = GetWindowLongA(hwnd,GWL_STYLE);
    528656    HDC hMemDC;
    529657    HBITMAP oldbitmap;
     
    544672        GetBitmapDimensionEx(infoPtr->hIcon, &sz);
    545673        oldbitmap = SelectObject(hMemDC, infoPtr->hIcon);
    546         BitBlt(hdc, sz.cx, sz.cy, bm.bmWidth, bm.bmHeight, hMemDC, 0, 0,
    547                SRCCOPY);
     674        if (dwStyle & SS_CENTERIMAGE)
     675          BitBlt(hdc,sz.cx,sz.cy,bm.bmWidth,bm.bmHeight,hMemDC,(rc.right-bm.bmWidth)/2,(rc.bottom-bm.bmHeight)/2,SRCCOPY);
     676        else
     677          BitBlt(hdc,sz.cx,sz.cy,bm.bmWidth,bm.bmHeight,hMemDC,0,0,SRCCOPY);
    548678        SelectObject(hMemDC, oldbitmap);
    549679        DeleteDC(hMemDC);
     
    551681}
    552682
     683static void STATIC_PaintMetafilefn(HWND hwnd,HDC hdc)
     684{
     685    RECT rect;
     686    HBRUSH hbrush;
     687    STATICINFO *infoPtr = (STATICINFO *)GetInfoPtr(hwnd);
     688
     689    GetClientRect(hwnd,&rect);
     690    hbrush = SendMessageA(GetParent(hwnd),WM_CTLCOLORSTATIC,hdc,hwnd);
     691    FillRect(hdc,&rect,hbrush);
     692
     693    if (infoPtr->hIcon) PlayEnhMetaFile(hdc,(HENHMETAFILE)infoPtr->hIcon,&rect);
     694}
     695
     696static void STATIC_PaintOwnerDrawfn(HWND hwnd,HDC hdc)
     697{
     698  DRAWITEMSTRUCT di;
     699
     700  di.CtlType    = ODT_STATIC;
     701  di.CtlID      = GetWindowLongA(hwnd,GWL_ID);
     702  di.itemID     = 0;
     703  di.itemAction = ODA_DRAWENTIRE;
     704  di.itemState  = ODS_DEFAULT;
     705  di.hwndItem   = hwnd;
     706  di.hDC        = hdc;
     707  GetClientRect(hwnd,&di.rcItem);
     708  di.itemData   = 0;
     709
     710  SendMessageA(GetParent(hwnd),WM_DRAWITEM,GetWindowLongA(hwnd,GWL_ID),(LPARAM)&di);
     711}
    553712
    554713static void STATIC_PaintEtchedfn( HWND hwnd, HDC hdc )
  • trunk/src/user32/win32dlg.cpp

    r1523 r1525  
    1 /* $Id: win32dlg.cpp,v 1.24 1999-10-30 18:08:19 dengert Exp $ */
     1/* $Id: win32dlg.cpp,v 1.25 1999-10-30 18:40:47 cbratschi Exp $ */
    22/*
    33 * Win32 Dialog Code for OS/2
     
    4646
    4747    dprintf(("********* CREATE DIALOG ************"));
    48     if(fInitialized == FALSE) {
    49         if(DIALOG_Init() == FALSE) {
    50             dprintf(("DIALOG_Init FAILED!"));
    51             DebugInt3();
    52             SetLastError(ERROR_GEN_FAILURE);
    53             return;
    54         }
    55         fInitialized = TRUE;
    56     }
    57     xUnit = xBaseUnit;
    58     yUnit = yBaseUnit;
     48    xUnit = getXBaseUnit();
     49    yUnit = getYBaseUnit();
    5950
    6051    /* Parse dialog template */
     
    236227    dprintf(("********* DIALOG CREATION FAILED! ************"));
    237228    return FALSE;
    238 }
    239 //******************************************************************************
    240 //******************************************************************************
    241 BOOL Win32Dialog::MapDialogRect(LPRECT rect)
    242 {
    243     rect->left   = (rect->left * xUnit) / 4;
    244     rect->right  = (rect->right * xUnit) / 4;
    245     rect->top    = (rect->top * yUnit) / 8;
    246     rect->bottom = (rect->bottom * yUnit) / 8;
    247     return TRUE;
    248229}
    249230/***********************************************************************
     
    331312}
    332313/***********************************************************************
    333  *           DIALOG_Init
    334  *
    335  * Initialisation of the dialog manager.
    336  */
    337 BOOL Win32Dialog::DIALOG_Init(void)
    338 {
    339     HDC hdc;
    340     SIZE size;
    341 
    342     /* Calculate the dialog base units */
    343     if (!(hdc = CreateDCA( "DISPLAY", NULL, NULL, NULL ))) return FALSE;
    344     if (!getCharSizeFromDC( hdc, 0, &size )) return FALSE;
    345     DeleteDC( hdc );
    346     xBaseUnit = size.cx;
    347     yBaseUnit = size.cy;
    348 
    349     return TRUE;
    350 }
    351 /***********************************************************************
    352  *           DIALOG_GetCharSizeFromDC
    353  *
    354  *
    355  *  Calculates the *true* average size of English characters in the
    356  *  specified font as oppposed to the one returned by GetTextMetrics.
    357  */
    358 BOOL Win32Dialog::getCharSizeFromDC( HDC hDC, HFONT hUserFont, SIZE * pSize )
    359 {
    360     BOOL Success = FALSE;
    361     HFONT hUserFontPrev = 0;
    362     pSize->cx = xBaseUnit;
    363     pSize->cy = yBaseUnit;
    364 
    365     if ( hDC )
    366     {
    367         /* select the font */
    368         TEXTMETRICA tm;
    369         memset(&tm,0,sizeof(tm));
    370         if (hUserFont) hUserFontPrev = SelectFont(hDC,hUserFont);
    371         if (GetTextMetricsA(hDC,&tm))
    372         {
    373             pSize->cx = tm.tmAveCharWidth;
    374             pSize->cy = tm.tmHeight;
    375 
    376             /* if variable width font */
    377             if (tm.tmPitchAndFamily & TMPF_FIXED_PITCH)
    378             {
    379                 SIZE total;
    380                 static const char szAvgChars[53] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
    381 
    382                 /* Calculate a true average as opposed to the one returned
    383                  * by tmAveCharWidth. This works better when dealing with
    384                  * proportional spaced fonts and (more important) that's
    385                  * how Microsoft's dialog creation code calculates the size
    386                  * of the font
    387                  */
    388                 if (GetTextExtentPointA(hDC,szAvgChars,sizeof(szAvgChars),&total))
    389                 {
    390                    /* round up */
    391                     pSize->cx = ((2*total.cx/sizeof(szAvgChars)) + 1)/2;
    392                     Success = TRUE;
    393                 }
    394             }
    395             else
    396             {
    397                 Success = TRUE;
    398             }
    399         }
    400 
    401         /* select the original font */
    402         if (hUserFontPrev) SelectFont(hDC,hUserFontPrev);
    403     }
    404     return (Success);
    405 }
    406 /***********************************************************************
    407  *           DIALOG_GetCharSize
    408  *
    409  *
    410  *  Calculates the *true* average size of English characters in the
    411  *  specified font as oppposed to the one returned by GetTextMetrics.
    412  *  A convenient variant of DIALOG_GetCharSizeFromDC.
    413  */
    414 BOOL Win32Dialog::getCharSize( HFONT hUserFont, SIZE * pSize )
    415 {
    416     HDC  hDC = GetDC(0);
    417     BOOL Success = getCharSizeFromDC( hDC, hUserFont, pSize );
    418     ReleaseDC(0, hDC);
    419     return Success;
    420 }
    421 /***********************************************************************
    422314 *           DIALOG_ParseTemplate32
    423315 *
     
    1012904}
    1013905//******************************************************************************
    1014 // GetNextDlgTabItem32   (USER32.276)
    1015 //******************************************************************************
    1016 HWND Win32Dialog::getNextDlgTabItem(HWND hwndCtrl, BOOL fPrevious)
    1017 {
    1018  Win32BaseWindow *child, *nextchild, *lastchild;
    1019  HWND retvalue;
    1020 
    1021     if (hwndCtrl)
    1022     {
    1023         child = GetWindowFromHandle(hwndCtrl);
    1024         if (!child)
    1025         {
    1026             retvalue = 0;
    1027             goto END;
    1028         }
    1029         /* Make sure hwndCtrl is a top-level child */
    1030         while ((child->getStyle() & WS_CHILD) && (child->getParent() != this))
    1031         {
    1032             child = child->getParent();
    1033             if(child == NULL) break;
    1034         }
    1035 
    1036         if (!child || child->getParent() != this)
    1037         {
    1038             retvalue = 0;
    1039             goto END;
    1040         }
    1041     }
    1042     else
    1043     {
    1044         /* No ctrl specified -> start from the beginning */
    1045         child = (Win32BaseWindow *)getFirstChild();
    1046         if (!child)
    1047         {
    1048             retvalue = 0;
    1049             goto END;
    1050         }
    1051 
    1052         if (!fPrevious)
    1053         {
    1054             while (child->getNextChild())
    1055             {
    1056                 child = (Win32BaseWindow *)child->getNextChild();
    1057             }
    1058         }
    1059     }
    1060 
    1061     lastchild = child;
    1062     nextchild = (Win32BaseWindow *)child->getNextChild();
    1063     while (TRUE)
    1064     {
    1065         if (!nextchild) nextchild = (Win32BaseWindow *)getFirstChild();
    1066 
    1067         if (child == nextchild) break;
    1068 
    1069         if ((nextchild->getStyle() & WS_TABSTOP) && (nextchild->getStyle() & WS_VISIBLE) &&
    1070             !(nextchild->getStyle() & WS_DISABLED))
    1071         {
    1072             lastchild = nextchild;
    1073             if (!fPrevious) break;
    1074         }
    1075         nextchild = (Win32BaseWindow *)nextchild->getNextChild();
    1076     }
    1077     retvalue = lastchild->getWindowHandle();
    1078 
    1079 END:
    1080     return retvalue;
    1081 }
    1082 //******************************************************************************
    1083 //******************************************************************************
    1084 HWND Win32Dialog::getNextDlgGroupItem(HWND hwndCtrl, BOOL fPrevious)
    1085 {
    1086  Win32BaseWindow *child, *nextchild, *lastchild;
    1087  HWND retvalue;
    1088 
    1089     if (hwndCtrl)
    1090     {
    1091         child = GetWindowFromHandle(hwndCtrl);
    1092         if (!child)
    1093         {
    1094             retvalue = 0;
    1095             goto END;
    1096         }
    1097         /* Make sure hwndCtrl is a top-level child */
    1098         while ((child->getStyle() & WS_CHILD) && (child->getParent() != this))
    1099         {
    1100             child = child->getParent();
    1101             if(child == NULL) break;
    1102         }
    1103 
    1104         if (!child || child->getParent() != this)
    1105         {
    1106             retvalue = 0;
    1107             goto END;
    1108         }
    1109     }
    1110     else
    1111     {
    1112         /* No ctrl specified -> start from the beginning */
    1113         child = (Win32BaseWindow *)getFirstChild();
    1114         if (!child)
    1115         {
    1116             retvalue = 0;
    1117             goto END;
    1118         }
    1119 
    1120         if (fPrevious)
    1121         {
    1122             while (child->getNextChild())
    1123             {
    1124                 child = (Win32BaseWindow *)child->getNextChild();
    1125             }
    1126         }
    1127     }
    1128 
    1129     lastchild = child;
    1130     nextchild = (Win32BaseWindow *)child->getNextChild();
    1131     while (TRUE)
    1132     {
    1133         if (!nextchild || nextchild->getStyle() & WS_GROUP)
    1134         {
    1135             /* Wrap-around to the beginning of the group */
    1136             Win32BaseWindow *pWndTemp;
    1137 
    1138             nextchild = (Win32BaseWindow *)getFirstChild();
    1139 
    1140             for(pWndTemp = nextchild;pWndTemp;pWndTemp = (Win32BaseWindow *)pWndTemp->getNextChild())
    1141             {
    1142                 if (pWndTemp->getStyle() & WS_GROUP)
    1143                     nextchild = pWndTemp;
    1144 
    1145                 if (pWndTemp == child)
    1146                     break;
    1147             }
    1148 
    1149         }
    1150         if (nextchild == child)
    1151             break;
    1152 
    1153         if ((nextchild->getStyle() & WS_VISIBLE) && !(nextchild->getStyle() & WS_DISABLED))
    1154         {
    1155             lastchild = nextchild;
    1156 
    1157             if (!fPrevious)
    1158                 break;
    1159         }
    1160 
    1161         nextchild = (Win32BaseWindow *)nextchild->getNextChild();
    1162     }
    1163     retvalue = lastchild->getWindowHandle();
    1164 END:
    1165     return retvalue;
    1166 }
    1167 //******************************************************************************
    1168906//******************************************************************************
    1169907BOOL Win32Dialog::endDialog(int retval)
     
    1240978//******************************************************************************
    1241979//******************************************************************************
    1242 BOOL Win32Dialog::fInitialized = FALSE;
    1243 int  Win32Dialog::xBaseUnit    = 10;
    1244 int  Win32Dialog::yBaseUnit    = 20;
     980
  • trunk/src/user32/win32dlg.h

    r1516 r1525  
    1 /* $Id: win32dlg.h,v 1.5 1999-10-30 10:55:16 sandervl Exp $ */
     1/* $Id: win32dlg.h,v 1.6 1999-10-30 18:40:47 cbratschi Exp $ */
    22/*
    33 * Win32 Dialog Code for OS/2
     
    6969Win32BaseWindow *getDlgItem(int id) { return FindWindowById(id); };
    7070
    71          HWND   getNextDlgTabItem(HWND hwndCtrl, BOOL fPrevious);
    72          HWND   getNextDlgGroupItem(HWND hwndCtrl, BOOL fPrevious);
    7371         BOOL   endDialog(int retval);
    74 
    75          BOOL   MapDialogRect(LPRECT rect);
    7672
    7773virtual  ULONG  MsgCreate(HWND hwndFrame, HWND hwndClient);
    7874
    79 virtual  LONG   SetWindowLongA(int index, ULONG value);
    80 virtual  ULONG  GetWindowLongA(int index);
     75virtual  LONG   SetWindowLongA(int index, ULONG value);
     76virtual  ULONG  GetWindowLongA(int index);
    8177
    82 static   ULONG  GetDialogBaseUnits()  { return MAKELONG(xBaseUnit, yBaseUnit); };
    83 
    84            INT  doDialogBox();
     78           INT  doDialogBox();
    8579
    8680protected:
    87         BOOL    DIALOG_Init(void);
    88         BOOL    getCharSizeFromDC( HDC hDC, HFONT hFont, SIZE * pSize );
    89         BOOL    getCharSize( HFONT hFont, SIZE * pSize);
    90         LPCSTR  parseTemplate( LPCSTR dlgtemplate, DLG_TEMPLATE *result);
     81        LPCSTR  parseTemplate( LPCSTR dlgtemplate, DLG_TEMPLATE *result);
    9182        WORD   *getControl(const WORD *p, DLG_CONTROL_INFO *info, BOOL dialogEx);
    92         BOOL    createControls(LPCSTR dlgtemplate, HINSTANCE hInst);
    93        
    94         LRESULT DefDlg_Proc(UINT msg, WPARAM wParam, LPARAM lParam);
     83        BOOL    createControls(LPCSTR dlgtemplate, HINSTANCE hInst);
     84
     85        LRESULT DefDlg_Proc(UINT msg, WPARAM wParam, LPARAM lParam);
    9586        LRESULT DefDlg_Epilog(UINT msg, BOOL fResult);
    9687
    97         BOOL    setDefButton(HWND hwndNew );
    98         HWND    findDefButton();
    99         BOOL    saveFocus();
    100         BOOL    restoreFocus();
    101         void    setFocus(HWND hwndCtrl );
     88        BOOL    setDefButton(HWND hwndNew );
     89        HWND    findDefButton();
     90        BOOL    saveFocus();
     91        BOOL    restoreFocus();
     92        void    setFocus(HWND hwndCtrl );
    10293
    103         // values normally contained in the standard dialog words
    104       DLGPROC   Win32DlgProc;   //DWL_WNDPROC
    105         ULONG   msgResult;      //DWL_MSGRESULT
    106         ULONG   userDlgData;    //DWL_USER
     94        // values normally contained in the standard dialog words
     95      DLGPROC   Win32DlgProc;   //DWL_WNDPROC
     96        ULONG   msgResult;      //DWL_MSGRESULT
     97        ULONG   userDlgData;    //DWL_USER
    10798
    10899   DLG_TEMPLATE dlgInfo;
    109         WORD    xUnit;
    110         WORD    yUnit;
    111         HWND    hwndFocus;
    112         HFONT   hUserFont;
    113         HMENU   hMenu;
    114         DWORD   idResult;
    115         DWORD   dialogFlags;
     100        WORD    xUnit;
     101        WORD    yUnit;
     102        HWND    hwndFocus;
     103        HFONT   hUserFont;
     104        HMENU   hMenu;
     105        DWORD   idResult;
     106        DWORD   dialogFlags;
    116107
    117         DWORD   tmpParam;       //set in ctor, used in MsgCreate method
    118         LPSTR   tmpDlgTemplate; //set in ctor, used in MsgCreate method
    119 private:
    120  static BOOL    fInitialized;
    121  static int     xBaseUnit;
    122  static int     yBaseUnit;
     108        DWORD   tmpParam;       //set in ctor, used in MsgCreate method
     109        LPSTR   tmpDlgTemplate; //set in ctor, used in MsgCreate method
    123110};
    124111
  • trunk/src/user32/win32wbase.cpp

    r1513 r1525  
    1 /* $Id: win32wbase.cpp,v 1.68 1999-10-30 09:19:45 sandervl Exp $ */
     1/* $Id: win32wbase.cpp,v 1.69 1999-10-30 18:40:48 cbratschi Exp $ */
    22/*
    33 * Win32 Window Base Class for OS/2
     
    1616 */
    1717#include <os2win.h>
     18#include <windowsx.h>
    1819#include <win.h>
    1920#include <stdlib.h>
     
    190191
    191192  ownDC              = 0;
     193
     194  //set dialog base units
     195  if(fInitialized == FALSE) {
     196    if(DIALOG_Init() == FALSE) {
     197      dprintf(("DIALOG_Init FAILED!"));
     198      DebugInt3();
     199      SetLastError(ERROR_GEN_FAILURE);
     200      return;
     201    }
     202    fInitialized = TRUE;
     203  }
     204
    192205}
    193206//******************************************************************************
     
    15841597    case WM_SETTEXT:
    15851598    {
    1586         if(!fInternalMsg) 
     1599        if(!fInternalMsg)
    15871600        {
    15881601           LRESULT result;
     
    27392752//    else    return hwnd;    //OS/2 window handle
    27402753}
     2754/***********************************************************************
     2755 *           DIALOG_Init
     2756 *
     2757 * Initialisation of the dialog manager.
     2758 */
     2759BOOL Win32BaseWindow::DIALOG_Init(void)
     2760{
     2761    HDC hdc;
     2762    SIZE size;
     2763
     2764    /* Calculate the dialog base units */
     2765    if (!(hdc = CreateDCA( "DISPLAY", NULL, NULL, NULL ))) return FALSE;
     2766    if (!getCharSizeFromDC( hdc, 0, &size )) return FALSE;
     2767    DeleteDC( hdc );
     2768    xBaseUnit = size.cx;
     2769    yBaseUnit = size.cy;
     2770
     2771    return TRUE;
     2772}
     2773/***********************************************************************
     2774 *           DIALOG_GetCharSizeFromDC
     2775 *
     2776 *
     2777 *  Calculates the *true* average size of English characters in the
     2778 *  specified font as oppposed to the one returned by GetTextMetrics.
     2779 */
     2780BOOL Win32BaseWindow::getCharSizeFromDC( HDC hDC, HFONT hUserFont, SIZE * pSize )
     2781{
     2782    BOOL Success = FALSE;
     2783    HFONT hUserFontPrev = 0;
     2784    pSize->cx = xBaseUnit;
     2785    pSize->cy = yBaseUnit;
     2786
     2787    if ( hDC )
     2788    {
     2789        /* select the font */
     2790        TEXTMETRICA tm;
     2791        memset(&tm,0,sizeof(tm));
     2792        if (hUserFont) hUserFontPrev = SelectFont(hDC,hUserFont);
     2793        if (GetTextMetricsA(hDC,&tm))
     2794        {
     2795            pSize->cx = tm.tmAveCharWidth;
     2796            pSize->cy = tm.tmHeight;
     2797
     2798            /* if variable width font */
     2799            if (tm.tmPitchAndFamily & TMPF_FIXED_PITCH)
     2800            {
     2801                SIZE total;
     2802                static const char szAvgChars[53] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
     2803
     2804                /* Calculate a true average as opposed to the one returned
     2805                 * by tmAveCharWidth. This works better when dealing with
     2806                 * proportional spaced fonts and (more important) that's
     2807                 * how Microsoft's dialog creation code calculates the size
     2808                 * of the font
     2809                 */
     2810                if (GetTextExtentPointA(hDC,szAvgChars,sizeof(szAvgChars),&total))
     2811                {
     2812                   /* round up */
     2813                    pSize->cx = ((2*total.cx/sizeof(szAvgChars)) + 1)/2;
     2814                    Success = TRUE;
     2815                }
     2816            }
     2817            else
     2818            {
     2819                Success = TRUE;
     2820            }
     2821        }
     2822
     2823        /* select the original font */
     2824        if (hUserFontPrev) SelectFont(hDC,hUserFontPrev);
     2825    }
     2826    return (Success);
     2827}
     2828/***********************************************************************
     2829 *           DIALOG_GetCharSize
     2830 *
     2831 *
     2832 *  Calculates the *true* average size of English characters in the
     2833 *  specified font as oppposed to the one returned by GetTextMetrics.
     2834 *  A convenient variant of DIALOG_GetCharSizeFromDC.
     2835 */
     2836BOOL Win32BaseWindow::getCharSize( HFONT hUserFont, SIZE * pSize )
     2837{
     2838    HDC  hDC = GetDC(0);
     2839    BOOL Success = getCharSizeFromDC( hDC, hUserFont, pSize );
     2840    ReleaseDC(0, hDC);
     2841    return Success;
     2842}
     2843//******************************************************************************
     2844// GetNextDlgTabItem32   (USER32.276)
     2845//******************************************************************************
     2846HWND Win32BaseWindow::getNextDlgTabItem(HWND hwndCtrl, BOOL fPrevious)
     2847{
     2848 Win32BaseWindow *child, *nextchild, *lastchild;
     2849 HWND retvalue;
     2850
     2851    if (hwndCtrl)
     2852    {
     2853        child = GetWindowFromHandle(hwndCtrl);
     2854        if (!child)
     2855        {
     2856            retvalue = 0;
     2857            goto END;
     2858        }
     2859        /* Make sure hwndCtrl is a top-level child */
     2860        while ((child->getStyle() & WS_CHILD) && (child->getParent() != this))
     2861        {
     2862            child = child->getParent();
     2863            if(child == NULL) break;
     2864        }
     2865
     2866        if (!child || child->getParent() != this)
     2867        {
     2868            retvalue = 0;
     2869            goto END;
     2870        }
     2871    }
     2872    else
     2873    {
     2874        /* No ctrl specified -> start from the beginning */
     2875        child = (Win32BaseWindow *)getFirstChild();
     2876        if (!child)
     2877        {
     2878            retvalue = 0;
     2879            goto END;
     2880        }
     2881
     2882        if (!fPrevious)
     2883        {
     2884            while (child->getNextChild())
     2885            {
     2886                child = (Win32BaseWindow *)child->getNextChild();
     2887            }
     2888        }
     2889    }
     2890
     2891    lastchild = child;
     2892    nextchild = (Win32BaseWindow *)child->getNextChild();
     2893    while (TRUE)
     2894    {
     2895        if (!nextchild) nextchild = (Win32BaseWindow *)getFirstChild();
     2896
     2897        if (child == nextchild) break;
     2898
     2899        if ((nextchild->getStyle() & WS_TABSTOP) && (nextchild->getStyle() & WS_VISIBLE) &&
     2900            !(nextchild->getStyle() & WS_DISABLED))
     2901        {
     2902            lastchild = nextchild;
     2903            if (!fPrevious) break;
     2904        }
     2905        nextchild = (Win32BaseWindow *)nextchild->getNextChild();
     2906    }
     2907    retvalue = lastchild->getWindowHandle();
     2908
     2909END:
     2910    return retvalue;
     2911}
     2912//******************************************************************************
     2913//******************************************************************************
     2914HWND Win32BaseWindow::getNextDlgGroupItem(HWND hwndCtrl, BOOL fPrevious)
     2915{
     2916 Win32BaseWindow *child, *nextchild, *lastchild;
     2917 HWND retvalue;
     2918
     2919    if (hwndCtrl)
     2920    {
     2921        child = GetWindowFromHandle(hwndCtrl);
     2922        if (!child)
     2923        {
     2924            retvalue = 0;
     2925            goto END;
     2926        }
     2927        /* Make sure hwndCtrl is a top-level child */
     2928        while ((child->getStyle() & WS_CHILD) && (child->getParent() != this))
     2929        {
     2930            child = child->getParent();
     2931            if(child == NULL) break;
     2932        }
     2933
     2934        if (!child || child->getParent() != this)
     2935        {
     2936            retvalue = 0;
     2937            goto END;
     2938        }
     2939    }
     2940    else
     2941    {
     2942        /* No ctrl specified -> start from the beginning */
     2943        child = (Win32BaseWindow *)getFirstChild();
     2944        if (!child)
     2945        {
     2946            retvalue = 0;
     2947            goto END;
     2948        }
     2949
     2950        if (fPrevious)
     2951        {
     2952            while (child->getNextChild())
     2953            {
     2954                child = (Win32BaseWindow *)child->getNextChild();
     2955            }
     2956        }
     2957    }
     2958
     2959    lastchild = child;
     2960    nextchild = (Win32BaseWindow *)child->getNextChild();
     2961    while (TRUE)
     2962    {
     2963        if (!nextchild || nextchild->getStyle() & WS_GROUP)
     2964        {
     2965            /* Wrap-around to the beginning of the group */
     2966            Win32BaseWindow *pWndTemp;
     2967
     2968            nextchild = (Win32BaseWindow *)getFirstChild();
     2969
     2970            for(pWndTemp = nextchild;pWndTemp;pWndTemp = (Win32BaseWindow *)pWndTemp->getNextChild())
     2971            {
     2972                if (pWndTemp->getStyle() & WS_GROUP)
     2973                    nextchild = pWndTemp;
     2974
     2975                if (pWndTemp == child)
     2976                    break;
     2977            }
     2978
     2979        }
     2980        if (nextchild == child)
     2981            break;
     2982
     2983        if ((nextchild->getStyle() & WS_VISIBLE) && !(nextchild->getStyle() & WS_DISABLED))
     2984        {
     2985            lastchild = nextchild;
     2986
     2987            if (!fPrevious)
     2988                break;
     2989        }
     2990
     2991        nextchild = (Win32BaseWindow *)nextchild->getNextChild();
     2992    }
     2993    retvalue = lastchild->getWindowHandle();
     2994END:
     2995    return retvalue;
     2996}
     2997//******************************************************************************
     2998//******************************************************************************
     2999BOOL Win32BaseWindow::MapDialogRect(LPRECT rect)
     3000{
     3001    rect->left   = (rect->left * xBaseUnit) / 4;
     3002    rect->right  = (rect->right * xBaseUnit) / 4;
     3003    rect->top    = (rect->top * yBaseUnit) / 8;
     3004    rect->bottom = (rect->bottom * yBaseUnit) / 8;
     3005    return TRUE;
     3006}
     3007//******************************************************************************
     3008//******************************************************************************
     3009BOOL Win32BaseWindow::fInitialized = FALSE;
     3010int  Win32BaseWindow::xBaseUnit    = 10;
     3011int  Win32BaseWindow::yBaseUnit    = 20;
    27413012//******************************************************************************
    27423013//******************************************************************************
  • trunk/src/user32/win32wbase.h

    r1490 r1525  
    1 /* $Id: win32wbase.h,v 1.35 1999-10-28 12:00:35 sandervl Exp $ */
     1/* $Id: win32wbase.h,v 1.36 1999-10-30 18:40:48 cbratschi Exp $ */
    22/*
    33 * Win32 Window Base Class for OS/2
     
    148148         BOOL   ShowWindow(ULONG nCmdShow);
    149149         BOOL   SetWindowPos(HWND hwndInsertAfter, int x, int y, int cx, int cy, UINT fuFlags);
    150         BOOL   SetWindowPlacement(WINDOWPLACEMENT *winpos);
     150        BOOL   SetWindowPlacement(WINDOWPLACEMENT *winpos);
    151151         BOOL   DestroyWindow();
    152152         HWND   SetActiveWindow();
     
    218218       ULONG getBorderHeight() { return borderHeight; };
    219219
    220 static  void  NC_AdjustRectInner(LPRECT rect, DWORD style, DWORD exStyle);
    221 static  void  NC_AdjustRectOuter(LPRECT rect, DWORD style, BOOL menu, DWORD exStyle);
    222 static  BOOL  WindowNeedsWMBorder( DWORD style, DWORD exStyle );
     220static  void  NC_AdjustRectInner(LPRECT rect, DWORD style, DWORD exStyle);
     221static  void  NC_AdjustRectOuter(LPRECT rect, DWORD style, BOOL menu, DWORD exStyle);
     222static  BOOL  WindowNeedsWMBorder( DWORD style, DWORD exStyle );
    223223
    224224       PVOID getOldWndProc() { return pOldWndProc; }
     
    303303#ifndef OS2_INCLUDED
    304304        void  GetMinMaxInfo(POINT *maxSize, POINT *maxPos, POINT *minTrack, POINT *maxTrack );
    305         LONG  HandleWindowPosChanging(WINDOWPOS *winpos);
     305        LONG  HandleWindowPosChanging(WINDOWPOS *winpos);
    306306        LONG  HandleSysCommand(WPARAM wParam, POINT *pt32);
    307307
     
    345345         BOOL   isPSErase()      { return EraseBkgndFlag | PSEraseFlag; }
    346346         BOOL   isSupressErase() { return SupressEraseFlag; }
     347
     348protected:
     349        BOOL    DIALOG_Init(void);
     350        BOOL    getCharSizeFromDC( HDC hDC, HFONT hFont, SIZE * pSize );
     351        BOOL    getCharSize( HFONT hFont, SIZE * pSize);
     352
     353public:
     354         HWND   getNextDlgTabItem(HWND hwndCtrl, BOOL fPrevious);
     355         HWND   getNextDlgGroupItem(HWND hwndCtrl, BOOL fPrevious);
     356
     357         BOOL   MapDialogRect(LPRECT rect);
     358
     359static   ULONG  GetDialogBaseUnits()  { return MAKELONG(xBaseUnit, yBaseUnit); };
     360static   int    getXBaseUnit() { return xBaseUnit; }
     361static   int    getYBaseUnit() { return yBaseUnit; }
     362
     363private:
     364 static BOOL    fInitialized;
     365 static int     xBaseUnit;
     366 static int     yBaseUnit;
    347367};
    348368
  • trunk/src/user32/windlg.cpp

    r1516 r1525  
    1 /* $Id: windlg.cpp,v 1.8 1999-10-30 10:55:16 sandervl Exp $ */
     1/* $Id: windlg.cpp,v 1.9 1999-10-30 18:40:49 cbratschi Exp $ */
    22/*
    33 * Win32 dialog apis for OS/2
     
    202202BOOL WIN32API MapDialogRect(HWND hwndDlg, LPRECT rect)
    203203{
    204   Win32Dialog *dialog;
    205 
    206     dialog = (Win32Dialog *)Win32BaseWindow::GetWindowFromHandle(hwndDlg);
    207     if(!dialog || !dialog->IsDialog()) {
     204  Win32BaseWindow *window;
     205
     206    window = Win32BaseWindow::GetWindowFromHandle(hwndDlg);
     207    if(!window) {
    208208        dprintf(("MapDialogRect, window %x not found", hwndDlg));
    209209        SetLastError(ERROR_INVALID_WINDOW_HANDLE);
     
    211211    }
    212212    dprintf(("USER32: MapDialogRect\n"));
    213     return dialog->MapDialogRect(rect);
     213    return window->MapDialogRect(rect);
    214214}
    215215//******************************************************************************
     
    218218{
    219219    dprintf(("USER32:  IsDlgButtonChecked\n"));
    220     //CB: get button state
     220
    221221    return (BOOL)SendDlgItemMessageA(hwnd, id,BM_GETCHECK,0,0);
    222222}
     
    225225HWND WIN32API GetNextDlgTabItem(HWND hwndDlg, HWND hwndCtrl, BOOL fPrevious)
    226226{
    227   Win32Dialog *dialog;
    228 
    229     dialog = (Win32Dialog *)Win32BaseWindow::GetWindowFromHandle(hwndDlg);
    230     if(!dialog || !dialog->IsDialog()) {
     227  Win32BaseWindow *window;
     228
     229    window = (Win32BaseWindow*)Win32BaseWindow::GetWindowFromHandle(hwndDlg);
     230    if(!window) {
    231231        dprintf(("GetNextDlgTabItem, window %x not found", hwndDlg));
    232232        SetLastError(ERROR_INVALID_WINDOW_HANDLE);
     
    234234    }
    235235    dprintf(("USER32:  GetNextDlgTabItem\n"));
    236     return dialog->getNextDlgTabItem(hwndCtrl, fPrevious);
     236    return window->getNextDlgTabItem(hwndCtrl, fPrevious);
    237237}
    238238//******************************************************************************
     
    251251    dlgcontrol = window->FindWindowById(id);
    252252    if(dlgcontrol) {
    253         dprintf(("USER32: GetDlgItem %x %d returned %x\n", hwnd, id, dlgcontrol->getWindowHandle()));
     253        dprintf(("USER32: GetDlgItem %x %d returned %x\n", hwnd, id, dlgcontrol->getWindowHandle()));
    254254        return dlgcontrol->getWindowHandle();
    255255    }
     
    369369HWND WIN32API GetNextDlgGroupItem( HWND hwnd, HWND hwndCtrl, BOOL fPrevious)
    370370{
    371   Win32Dialog *dialog;
    372 
    373     dialog = (Win32Dialog *)Win32BaseWindow::GetWindowFromHandle(hwnd);
    374     if(!dialog || !dialog->IsDialog()) {
     371  Win32BaseWindow *window;
     372
     373    window = Win32BaseWindow::GetWindowFromHandle(hwnd);
     374    if(!window) {
    375375        dprintf(("GetNextDlgGroupItem, window %x not found", hwnd));
    376376        SetLastError(ERROR_INVALID_WINDOW_HANDLE);
     
    378378    }
    379379    dprintf(("USER32:  GetNextDlgGroupItem\n"));
    380     return dialog->getNextDlgGroupItem(hwndCtrl, fPrevious);
     380    return window->getNextDlgGroupItem(hwndCtrl, fPrevious);
    381381}
    382382/***********************************************************************
Note: See TracChangeset for help on using the changeset viewer.