Changeset 1525 for trunk/src/user32
- Timestamp:
- Oct 30, 1999, 8:40:49 PM (26 years ago)
- Location:
- trunk/src/user32
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/user32/button.cpp
r1433 r1525 1 /* $Id: button.cpp,v 1.1 5 1999-10-24 22:56:00 sandervlExp $ */1 /* $Id: button.cpp,v 1.16 1999-10-30 18:40:43 cbratschi Exp $ */ 2 2 /* File: button.cpp -- Button type widgets 3 3 * … … 626 626 } 627 627 628 static 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 628 647 /********************************************************************** 629 648 * This method will actually do the drawing of the pushbutton … … 692 711 if (textLen > 0 && (!(dwStyle & (BS_ICON|BS_BITMAP)))) 693 712 { 713 INT format = BUTTON_GetTextFormat(dwStyle,DT_CENTER,DT_VCENTER); 714 694 715 textLen++; 695 716 text = (char*)malloc(textLen); 696 717 GetWindowTextA(hwnd,text,textLen); 697 718 698 if (dwStyle & WS_DISABLED) DrawDisabledText(hDC,text,&rc, DT_SINGLELINE | DT_CENTER | DT_VCENTER); else719 if (dwStyle & WS_DISABLED) DrawDisabledText(hDC,text,&rc,format); else 699 720 { 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); 703 723 /* do we have the focus? 704 724 * Win9x draws focus last with a size prop. to the button … … 903 923 if( text && action != ODA_SELECT ) 904 924 { 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); 908 929 } 909 930 } … … 916 937 SetRectEmpty(&rbox); 917 938 if(textLen > 0) 918 DrawTextA( hDC, text, -1, &rbox, 919 DT_SINGLELINE | DT_CALCRECT ); 939 DrawTextA(hDC,text,-1,&rbox,DT_SINGLELINE | DT_CALCRECT); 920 940 textLen = rbox.bottom - rbox.top; 921 941 delta = ((rtext.bottom - rtext.top) - textLen)/2; … … 943 963 parent = GetParent(hwnd); 944 964 /* assure that starting control is not disabled or invisible */ 945 //start = sibling = GetNextDlgGroupItem( parent, hwnd, TRUE );965 start = sibling = GetNextDlgGroupItem( parent, hwnd, TRUE ); 946 966 //@YD: bugfix 947 start = sibling = GetNextDlgGroupItem( parent, hwnd, FALSE ); 967 //CB: doesn't work! 968 //start = sibling = GetNextDlgGroupItem( parent, hwnd, FALSE ); 948 969 do 949 970 { … … 987 1008 if (textLen > 0) 988 1009 { 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); 1003 1025 } 1004 1026 } -
trunk/src/user32/dc.cpp
r1405 r1525 1 /* $Id: dc.cpp,v 1.1 7 1999-10-22 18:11:43 sandervlExp $ */1 /* $Id: dc.cpp,v 1.18 1999-10-30 18:40:43 cbratschi Exp $ */ 2 2 3 3 /* … … 1342 1342 HRGN hrgn; 1343 1343 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 1344 1352 LONG lComplexity = WinScrollWindow (window->getOS2WindowHandle(), dx, dy, 1345 1353 (pScroll) ? &scrollRect : NULL, -
trunk/src/user32/dc.h
r1405 r1525 1 /* $Id: dc.h,v 1. 5 1999-10-22 18:11:44 sandervlExp $ */1 /* $Id: dc.h,v 1.6 1999-10-30 18:40:44 cbratschi Exp $ */ 2 2 /* 3 3 * public dc functions … … 145 145 #define SW_INVALIDATE_W 0x0002 146 146 #define SW_ERASE_W 0x0004 147 #define SW_SMOOTHSCROLL_W 0x0010 147 148 148 149 /*********************/ … … 164 165 165 166 return yyrc; 166 } 167 } 167 168 168 169 //LONG APIENTRY GpiQueryYInversion (HPS hps); … … 179 180 180 181 return yyrc; 181 } 182 } 182 183 183 184 PVOID APIENTRY _GpiQueryDCData (HPS hps); … … 192 193 193 194 return yyrc; 194 } 195 } 195 196 196 197 HDC OPEN32API _HPSToHDC (HWND hwnd, HPS hps, HDC hdc, PVOID a); … … 205 206 206 207 return yyrc; 207 } 208 } 208 209 209 210 void OPEN32API _DeleteHDC (HDC hdc); … … 215 216 _DeleteHDC(hdc); 216 217 SetFS(sel); 217 } 218 } 218 219 219 220 BOOL OPEN32API _O32_EndPaint (HWND hwnd, const PAINTSTRUCT_W *lpps); … … 228 229 229 230 return yyrc; 230 } 231 } 231 232 232 233 int OPEN32API _O32_GetUpdateRgn (HWND hwnd, HRGN hrgn, BOOL erase); … … 241 242 242 243 return yyrc; 243 } 244 } 244 245 245 246 ULONG OPEN32API _O32_GetRegionData (HRGN hrgn, ULONG count, PRGNDATA_W pData); … … 254 255 255 256 return yyrc; 256 } 257 } 257 258 258 259 BOOL OPEN32API _O32_DeleteObject (LHANDLE hgdiobj); … … 267 268 268 269 return yyrc; 269 } 270 } 270 271 271 272 int OPEN32API _O32_ReleaseDC (HWND hwnd, HDC hdc); … … 280 281 281 282 return yyrc; 282 } 283 } 283 284 284 285 VOID OPEN32API _O32_SetLastError( DWORD ); … … 290 291 _O32_SetLastError(a); 291 292 SetFS(sel); 292 } 293 } 293 294 294 295 BOOL OPEN32API _O32_SetRectRgn (HRGN dest, int left, int top, int right, int bottom); … … 303 304 304 305 return yyrc; 305 } 306 } 306 307 307 308 int OPEN32API _O32_CombineRgn (HRGN dest, HRGN src1, HRGN src2, int mode); … … 316 317 317 318 return yyrc; 318 } 319 } 319 320 320 321 HRGN OPEN32API _O32_CreateRectRgn (int left, int top, int right, int bottom); … … 329 330 330 331 return yyrc; 331 } 332 } 332 333 333 334 BOOL OPEN32API _O32_CreateCaret (HWND hwnd, HBITMAP hbm, int width, int height); … … 342 343 343 344 return yyrc; 344 } 345 } 345 346 346 347 BOOL APIENTRY __DestroyCaret (void); … … 355 356 356 357 return yyrc; 357 } 358 } 358 359 359 360 UINT APIENTRY __GetCaretBlinkTime (void); … … 368 369 369 370 return yyrc; 370 } 371 } 371 372 372 373 BOOL APIENTRY __HideCaret (HWND hwnd); … … 382 383 return yyrc; 383 384 } 384 385 385 386 BOOL APIENTRY __SetCaretBlinkTime (UINT mSecs); 386 387 … … 394 395 395 396 return yyrc; 396 } 397 } 397 398 398 399 BOOL APIENTRY __ShowCaret (HWND hwnd); … … 407 408 408 409 return yyrc; 409 } 410 } 410 411 411 412 #endif //INCLUDED_BY_DC -
trunk/src/user32/pmframe.cpp
r1511 r1525 1 /* $Id: pmframe.cpp,v 1.1 3 1999-10-29 16:06:55cbratschi Exp $ */1 /* $Id: pmframe.cpp,v 1.14 1999-10-30 18:40:44 cbratschi Exp $ */ 2 2 /* 3 3 * Win32 Frame Managment Code for OS/2 … … 387 387 388 388 PosChangedEnd: 389 389 RestoreOS2TIB(); 390 390 return rc; 391 391 } … … 426 426 #else 427 427 case WM_ACTIVATE: 428 { 429 RestoreOS2TIB(); 430 MRESULT rc = OldFrameProc(hwnd,msg,mp1,mp2); 431 //CB: overwrite OS/2's default frame 428 432 DrawActivate(win32wnd, hwnd); 429 goto RunDefFrameProc; 433 return rc; 434 } 435 430 436 #endif 431 437 #else -
trunk/src/user32/scroll.cpp
r1511 r1525 1 /* $Id: scroll.cpp,v 1.1 6 1999-10-29 16:06:56cbratschi Exp $ */1 /* $Id: scroll.cpp,v 1.17 1999-10-30 18:40:45 cbratschi Exp $ */ 2 2 /* 3 3 * Scrollbar control … … 9 9 * 10 10 * WINE version: 990923 11 * 12 * Status: complete 13 * Version: 5.00 11 14 */ 12 15 … … 879 882 if (msg == WM_LBUTTONUP) 880 883 KillSystemTimer(hwnd,SCROLL_TIMER); 881 else if (msg == WM_LBUTTONDOWN || !timerRunning)884 else if (msg == WM_LBUTTONDOWN || (!timerRunning && msg == WM_SYSTIMER)) 882 885 { 883 886 SetSystemTimer( hwnd, SCROLL_TIMER, (msg == WM_LBUTTONDOWN) ? … … 900 903 if (msg == WM_LBUTTONUP) 901 904 KillSystemTimer(hwnd,SCROLL_TIMER); 902 else if (msg == WM_LBUTTONDOWN || !timerRunning)905 else if (msg == WM_LBUTTONDOWN || (!timerRunning && msg == WM_SYSTIMER)) 903 906 { 904 907 SetSystemTimer( hwnd, SCROLL_TIMER, (msg == WM_LBUTTONDOWN) ? … … 974 977 if (msg == WM_LBUTTONUP) 975 978 KillSystemTimer(hwnd,SCROLL_TIMER); 976 else if (msg == WM_LBUTTONDOWN || !timerRunning)979 else if (msg == WM_LBUTTONDOWN || (!timerRunning && msg == WM_SYSTIMER)) 977 980 { 978 981 SetSystemTimer( hwnd, SCROLL_TIMER, (msg == WM_LBUTTONDOWN) ? … … 998 1001 if (msg == WM_LBUTTONUP) 999 1002 KillSystemTimer(hwnd,SCROLL_TIMER); 1000 else if (msg == WM_LBUTTONDOWN || !timerRunning)1003 else if (msg == WM_LBUTTONDOWN || (!timerRunning && msg == WM_SYSTIMER)) 1001 1004 { 1002 1005 SetSystemTimer( hwnd, SCROLL_TIMER, (msg == WM_LBUTTONDOWN) ? … … 1606 1609 return TRUE; 1607 1610 } 1611 1608 1612 /************************************************************************* 1609 1613 * EnableScrollBar (USER32.171) … … 1677 1681 } 1678 1682 } 1683 1684 return TRUE; 1685 } 1686 1687 //CB: not listed in user32.exp -> don't know the id! 1688 1689 BOOL 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 1679 1729 1680 1730 return TRUE; -
trunk/src/user32/static.cpp
r1433 r1525 1 /* $Id: static.cpp,v 1. 7 1999-10-24 22:56:07 sandervlExp $ */1 /* $Id: static.cpp,v 1.8 1999-10-30 18:40:46 cbratschi Exp $ */ 2 2 /* 3 3 * Static control 4 4 * 5 * Copyright 1999 Christoph Bratschi (ported from WINE)5 * Copyright 1999 Christoph Bratschi 6 6 * 7 7 * Copyright David W. Metcalfe, 1993 8 8 * 9 9 * WINE version: 990923 10 * 11 * Status: complete 12 * Version: 5.00 10 13 */ 11 14 … … 21 24 static void STATIC_PaintIconfn( HWND hwnd, HDC hdc ); 22 25 static void STATIC_PaintBitmapfn( HWND hwnd, HDC hdc ); 26 static void STATIC_PaintMetafilefn(HWND hwnd,HDC hdc); 27 static void STATIC_PaintOwnerDrawfn(HWND hwnd,HDC hdc); 23 28 static void STATIC_PaintEtchedfn( HWND hwnd, HDC hdc ); 24 29 … … 40 45 STATIC_PaintRectfn, /* SS_GRAYFRAME */ 41 46 STATIC_PaintRectfn, /* SS_WHITEFRAME */ 42 NULL, /* Not defined*/47 NULL, /* SS_USERITEM */ 43 48 STATIC_PaintTextfn, /* SS_SIMPLE */ 44 49 STATIC_PaintTextfn, /* SS_LEFTNOWORDWRAP */ 45 NULL,/* SS_OWNERDRAW */50 STATIC_PaintOwnerDrawfn, /* SS_OWNERDRAW */ 46 51 STATIC_PaintBitmapfn, /* SS_BITMAP */ 47 NULL,/* SS_ENHMETAFILE */52 STATIC_PaintMetafilefn, /* SS_ENHMETAFILE */ 48 53 STATIC_PaintEtchedfn, /* SS_ETCHEDHORIZ */ 49 54 STATIC_PaintEtchedfn, /* SS_ETCHEDVERT */ … … 51 56 }; 52 57 58 static 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 } 53 68 54 69 /*********************************************************************** … … 71 86 infoPtr->hIcon = hicon; 72 87 73 GetIconInfo(hicon,&ii);88 if (!GetIconInfo(hicon,&ii)) return prevIcon; 74 89 GetObjectA(ii.hbmColor,sizeof(BITMAP),(LPVOID)&bmp); 75 90 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); 77 92 78 93 return prevIcon; … … 98 113 hOldBitmap = infoPtr->hIcon; 99 114 infoPtr->hIcon = hBitmap; 100 if (hBitmap )115 if (hBitmap && !(dwStyle & (SS_CENTERIMAGE | SS_REALSIZEIMAGE))) 101 116 { 102 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); 106 121 } 122 107 123 return hOldBitmap; 124 } 125 126 static 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; 108 139 } 109 140 … … 142 173 } 143 174 175 static HBITMAP STATIC_LoadMetafile(HWND hwnd,LPCSTR name) 176 { 177 HENHMETAFILE hMetafile; 178 179 hMetafile = GetEnhMetaFileA(name); //CB: right? 180 181 return hMetafile; 182 } 183 144 184 /* message handler */ 145 185 146 186 LRESULT STATIC_NCCreate(HWND hwnd,WPARAM wParam,LPARAM lParam) 147 187 { 148 CREATESTRUCTA *cs = (CREATESTRUCTA 188 CREATESTRUCTA *cs = (CREATESTRUCTA*)lParam; 149 189 STATICINFO* infoPtr; 150 190 DWORD dwStyle = GetWindowLongA(hwnd,GWL_STYLE); … … 166 206 if (style == SS_ICON) 167 207 { 168 if (cs->lpszName) 208 if (cs->lpszName) //CB: is 0 a valid icon id? winhlp32: lpszName = NULL 169 209 { 170 210 if (!HIWORD(cs->lpszName) || cs->lpszName[0]) … … 179 219 return TRUE; 180 220 } 221 if (style == SS_ENHMETAFILE) 222 { 223 if (cs->lpszName) STATIC_SetMetafile(hwnd,STATIC_LoadMetafile(hwnd,cs->lpszName)); 224 return TRUE; 225 } 181 226 if (!HIWORD(cs->lpszName) && (cs->lpszName)) return TRUE; 182 227 … … 213 258 { 214 259 DeleteObject(infoPtr->hIcon); 260 } else if (style == SS_ENHMETAFILE && infoPtr->hIcon) 261 { 262 DeleteEnhMetaFile((HENHMETAFILE)infoPtr->hIcon); 215 263 } 216 264 … … 234 282 LRESULT STATIC_Enable(HWND hwnd,WPARAM wParam,LPARAM lParam) 235 283 { 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 236 288 InvalidateRect(hwnd,NULL,FALSE); 237 289 … … 258 310 else if (style == SS_BITMAP) 259 311 STATIC_SetBitmap(hwnd,STATIC_LoadBitmap(hwnd,(LPCSTR)lParam)); 312 else if (style == SS_ENHMETAFILE) 313 STATIC_SetMetafile(hwnd,STATIC_LoadMetafile(hwnd,(LPCSTR)lParam)); 260 314 else 261 315 DefWindowProcA(hwnd,WM_SETTEXT,wParam,lParam); … … 274 328 if (style == SS_ICON) return 0; 275 329 if (style == SS_BITMAP) return 0; 330 if (style == SS_ENHMETAFILE) return 0; 276 331 277 332 infoPtr->hFont = (HFONT)wParam; … … 310 365 } 311 366 367 LRESULT 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 312 394 LRESULT STATIC_SetImage(HWND hwnd,WPARAM wParam,LPARAM lParam) 313 395 { 314 LRESULT lResult ;396 LRESULT lResult = 0; 315 397 316 398 switch (wParam) … … 320 402 lResult = STATIC_SetIcon(hwnd,(HICON)lParam); 321 403 break; 404 322 405 case IMAGE_BITMAP: 323 406 lResult = STATIC_SetBitmap(hwnd,(HBITMAP)lParam); 407 break; 408 324 409 case IMAGE_ENHMETAFILE: 325 return 0; //CB: not supported! 410 lResult = STATIC_SetMetafile(hwnd,(HENHMETAFILE)lParam); 411 break; 412 326 413 default: 327 414 return 0; 328 415 } 329 416 417 if (lResult) InvalidateRect(hwnd,NULL,FALSE); 418 419 return lResult; 420 } 421 422 LRESULT STATIC_SetIconMsg(HWND hwnd,WPARAM wParam,LPARAM lParam) 423 { 424 LRESULT lResult; 425 426 lResult = STATIC_SetIcon(hwnd,(HICON)wParam); 427 330 428 InvalidateRect(hwnd,NULL,FALSE); 331 UpdateWindow(hwnd);332 429 333 430 return lResult; 334 431 } 335 432 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; 433 LRESULT 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 442 LRESULT 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); 346 449 } 347 450 … … 386 489 return STATIC_GetDlgCode(hwnd,wParam,lParam); 387 490 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 388 499 case STM_GETIMAGE: 500 return STATIC_GetImage(hwnd,wParam,lParam); 501 389 502 case STM_GETICON: 390 503 return STATIC_GetIcon(hwnd,wParam,lParam); … … 394 507 395 508 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! 397 513 398 514 default: … … 411 527 WORD wFormat; 412 528 DWORD dwStyle = GetWindowLongA(hwnd,GWL_STYLE); 413 LONG style = dwStyle;414 529 STATICINFO *infoPtr = (STATICINFO *)GetInfoPtr(hwnd); 415 530 INT textLen; … … 417 532 GetClientRect(hwnd,&rc); 418 533 419 switch ( style & SS_TYPEMASK)534 switch (dwStyle & SS_TYPEMASK) 420 535 { 421 case SS_LEFT:536 case SS_LEFT: 422 537 wFormat = DT_LEFT | DT_EXPANDTABS | DT_WORDBREAK | DT_NOCLIP; 423 538 break; 424 539 425 case SS_CENTER: 540 case SS_CENTER: 541 case SS_CENTERIMAGE: 426 542 wFormat = DT_CENTER | DT_EXPANDTABS | DT_WORDBREAK | DT_NOCLIP; 427 543 break; 428 544 429 case SS_RIGHT:545 case SS_RIGHT: 430 546 wFormat = DT_RIGHT | DT_EXPANDTABS | DT_WORDBREAK | DT_NOCLIP; 431 547 break; 432 548 433 case SS_SIMPLE:549 case SS_SIMPLE: 434 550 wFormat = DT_LEFT | DT_SINGLELINE | DT_VCENTER | DT_NOCLIP; 435 551 break; 436 552 437 case SS_LEFTNOWORDWRAP:553 case SS_LEFTNOWORDWRAP: 438 554 wFormat = DT_LEFT | DT_EXPANDTABS | DT_VCENTER; 439 555 break; 440 556 441 default:557 default: 442 558 return; 443 559 } 444 560 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; 447 565 448 566 if (infoPtr->hFont) SelectObject( hdc, infoPtr->hFont ); … … 462 580 text = (char*)malloc(textLen); 463 581 GetWindowTextA(hwnd,text,textLen); 464 DrawText A( hdc, text, -1, &rc, wFormat);582 DrawTextExA(hdc,text,-1,&rc,wFormat,NULL); 465 583 free(text); 466 584 } … … 513 631 HBRUSH hbrush; 514 632 STATICINFO *infoPtr = (STATICINFO *)GetInfoPtr(hwnd); 633 DWORD dwStyle = GetWindowLongA(hwnd,GWL_STYLE); 515 634 516 635 GetClientRect( hwnd, &rc ); … … 518 637 hdc, hwnd ); 519 638 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); 521 648 } 522 649 … … 526 653 HBRUSH hbrush; 527 654 STATICINFO *infoPtr = (STATICINFO *)GetInfoPtr(hwnd); 655 DWORD dwStyle = GetWindowLongA(hwnd,GWL_STYLE); 528 656 HDC hMemDC; 529 657 HBITMAP oldbitmap; … … 544 672 GetBitmapDimensionEx(infoPtr->hIcon, &sz); 545 673 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); 548 678 SelectObject(hMemDC, oldbitmap); 549 679 DeleteDC(hMemDC); … … 551 681 } 552 682 683 static 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 696 static 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 } 553 712 554 713 static void STATIC_PaintEtchedfn( HWND hwnd, HDC hdc ) -
trunk/src/user32/win32dlg.cpp
r1523 r1525 1 /* $Id: win32dlg.cpp,v 1.2 4 1999-10-30 18:08:19 dengertExp $ */1 /* $Id: win32dlg.cpp,v 1.25 1999-10-30 18:40:47 cbratschi Exp $ */ 2 2 /* 3 3 * Win32 Dialog Code for OS/2 … … 46 46 47 47 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(); 59 50 60 51 /* Parse dialog template */ … … 236 227 dprintf(("********* DIALOG CREATION FAILED! ************")); 237 228 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;248 229 } 249 230 /*********************************************************************** … … 331 312 } 332 313 /*********************************************************************** 333 * DIALOG_Init334 *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_GetCharSizeFromDC353 *354 *355 * Calculates the *true* average size of English characters in the356 * 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 returned383 * by tmAveCharWidth. This works better when dealing with384 * proportional spaced fonts and (more important) that's385 * how Microsoft's dialog creation code calculates the size386 * of the font387 */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 else396 {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_GetCharSize408 *409 *410 * Calculates the *true* average size of English characters in the411 * 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 /***********************************************************************422 314 * DIALOG_ParseTemplate32 423 315 * … … 1012 904 } 1013 905 //****************************************************************************** 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 else1043 {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 else1111 {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 //******************************************************************************1168 906 //****************************************************************************** 1169 907 BOOL Win32Dialog::endDialog(int retval) … … 1240 978 //****************************************************************************** 1241 979 //****************************************************************************** 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 sandervlExp $ */1 /* $Id: win32dlg.h,v 1.6 1999-10-30 18:40:47 cbratschi Exp $ */ 2 2 /* 3 3 * Win32 Dialog Code for OS/2 … … 69 69 Win32BaseWindow *getDlgItem(int id) { return FindWindowById(id); }; 70 70 71 HWND getNextDlgTabItem(HWND hwndCtrl, BOOL fPrevious);72 HWND getNextDlgGroupItem(HWND hwndCtrl, BOOL fPrevious);73 71 BOOL endDialog(int retval); 74 75 BOOL MapDialogRect(LPRECT rect);76 72 77 73 virtual ULONG MsgCreate(HWND hwndFrame, HWND hwndClient); 78 74 79 virtual 80 virtual 75 virtual LONG SetWindowLongA(int index, ULONG value); 76 virtual ULONG GetWindowLongA(int index); 81 77 82 static ULONG GetDialogBaseUnits() { return MAKELONG(xBaseUnit, yBaseUnit); }; 83 84 INT doDialogBox(); 78 INT doDialogBox(); 85 79 86 80 protected: 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); 91 82 WORD *getControl(const WORD *p, DLG_CONTROL_INFO *info, BOOL dialogEx); 92 93 94 83 BOOL createControls(LPCSTR dlgtemplate, HINSTANCE hInst); 84 85 LRESULT DefDlg_Proc(UINT msg, WPARAM wParam, LPARAM lParam); 95 86 LRESULT DefDlg_Epilog(UINT msg, BOOL fResult); 96 87 97 98 99 100 101 88 BOOL setDefButton(HWND hwndNew ); 89 HWND findDefButton(); 90 BOOL saveFocus(); 91 BOOL restoreFocus(); 92 void setFocus(HWND hwndCtrl ); 102 93 103 104 DLGPROC Win32DlgProc;//DWL_WNDPROC105 ULONG msgResult;//DWL_MSGRESULT106 ULONG userDlgData;//DWL_USER94 // values normally contained in the standard dialog words 95 DLGPROC Win32DlgProc; //DWL_WNDPROC 96 ULONG msgResult; //DWL_MSGRESULT 97 ULONG userDlgData; //DWL_USER 107 98 108 99 DLG_TEMPLATE dlgInfo; 109 110 111 112 113 114 115 100 WORD xUnit; 101 WORD yUnit; 102 HWND hwndFocus; 103 HFONT hUserFont; 104 HMENU hMenu; 105 DWORD idResult; 106 DWORD dialogFlags; 116 107 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 123 110 }; 124 111 -
trunk/src/user32/win32wbase.cpp
r1513 r1525 1 /* $Id: win32wbase.cpp,v 1.6 8 1999-10-30 09:19:45 sandervlExp $ */1 /* $Id: win32wbase.cpp,v 1.69 1999-10-30 18:40:48 cbratschi Exp $ */ 2 2 /* 3 3 * Win32 Window Base Class for OS/2 … … 16 16 */ 17 17 #include <os2win.h> 18 #include <windowsx.h> 18 19 #include <win.h> 19 20 #include <stdlib.h> … … 190 191 191 192 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 192 205 } 193 206 //****************************************************************************** … … 1584 1597 case WM_SETTEXT: 1585 1598 { 1586 if(!fInternalMsg) 1599 if(!fInternalMsg) 1587 1600 { 1588 1601 LRESULT result; … … 2739 2752 // else return hwnd; //OS/2 window handle 2740 2753 } 2754 /*********************************************************************** 2755 * DIALOG_Init 2756 * 2757 * Initialisation of the dialog manager. 2758 */ 2759 BOOL 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 */ 2780 BOOL 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 */ 2836 BOOL 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 //****************************************************************************** 2846 HWND 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 2909 END: 2910 return retvalue; 2911 } 2912 //****************************************************************************** 2913 //****************************************************************************** 2914 HWND 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(); 2994 END: 2995 return retvalue; 2996 } 2997 //****************************************************************************** 2998 //****************************************************************************** 2999 BOOL 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 //****************************************************************************** 3009 BOOL Win32BaseWindow::fInitialized = FALSE; 3010 int Win32BaseWindow::xBaseUnit = 10; 3011 int Win32BaseWindow::yBaseUnit = 20; 2741 3012 //****************************************************************************** 2742 3013 //****************************************************************************** -
trunk/src/user32/win32wbase.h
r1490 r1525 1 /* $Id: win32wbase.h,v 1.3 5 1999-10-28 12:00:35 sandervlExp $ */1 /* $Id: win32wbase.h,v 1.36 1999-10-30 18:40:48 cbratschi Exp $ */ 2 2 /* 3 3 * Win32 Window Base Class for OS/2 … … 148 148 BOOL ShowWindow(ULONG nCmdShow); 149 149 BOOL SetWindowPos(HWND hwndInsertAfter, int x, int y, int cx, int cy, UINT fuFlags); 150 150 BOOL SetWindowPlacement(WINDOWPLACEMENT *winpos); 151 151 BOOL DestroyWindow(); 152 152 HWND SetActiveWindow(); … … 218 218 ULONG getBorderHeight() { return borderHeight; }; 219 219 220 static 221 static 222 static 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 ); 223 223 224 224 PVOID getOldWndProc() { return pOldWndProc; } … … 303 303 #ifndef OS2_INCLUDED 304 304 void GetMinMaxInfo(POINT *maxSize, POINT *maxPos, POINT *minTrack, POINT *maxTrack ); 305 305 LONG HandleWindowPosChanging(WINDOWPOS *winpos); 306 306 LONG HandleSysCommand(WPARAM wParam, POINT *pt32); 307 307 … … 345 345 BOOL isPSErase() { return EraseBkgndFlag | PSEraseFlag; } 346 346 BOOL isSupressErase() { return SupressEraseFlag; } 347 348 protected: 349 BOOL DIALOG_Init(void); 350 BOOL getCharSizeFromDC( HDC hDC, HFONT hFont, SIZE * pSize ); 351 BOOL getCharSize( HFONT hFont, SIZE * pSize); 352 353 public: 354 HWND getNextDlgTabItem(HWND hwndCtrl, BOOL fPrevious); 355 HWND getNextDlgGroupItem(HWND hwndCtrl, BOOL fPrevious); 356 357 BOOL MapDialogRect(LPRECT rect); 358 359 static ULONG GetDialogBaseUnits() { return MAKELONG(xBaseUnit, yBaseUnit); }; 360 static int getXBaseUnit() { return xBaseUnit; } 361 static int getYBaseUnit() { return yBaseUnit; } 362 363 private: 364 static BOOL fInitialized; 365 static int xBaseUnit; 366 static int yBaseUnit; 347 367 }; 348 368 -
trunk/src/user32/windlg.cpp
r1516 r1525 1 /* $Id: windlg.cpp,v 1. 8 1999-10-30 10:55:16 sandervlExp $ */1 /* $Id: windlg.cpp,v 1.9 1999-10-30 18:40:49 cbratschi Exp $ */ 2 2 /* 3 3 * Win32 dialog apis for OS/2 … … 202 202 BOOL WIN32API MapDialogRect(HWND hwndDlg, LPRECT rect) 203 203 { 204 Win32 Dialog *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) { 208 208 dprintf(("MapDialogRect, window %x not found", hwndDlg)); 209 209 SetLastError(ERROR_INVALID_WINDOW_HANDLE); … … 211 211 } 212 212 dprintf(("USER32: MapDialogRect\n")); 213 return dialog->MapDialogRect(rect);213 return window->MapDialogRect(rect); 214 214 } 215 215 //****************************************************************************** … … 218 218 { 219 219 dprintf(("USER32: IsDlgButtonChecked\n")); 220 //CB: get button state 220 221 221 return (BOOL)SendDlgItemMessageA(hwnd, id,BM_GETCHECK,0,0); 222 222 } … … 225 225 HWND WIN32API GetNextDlgTabItem(HWND hwndDlg, HWND hwndCtrl, BOOL fPrevious) 226 226 { 227 Win32 Dialog *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) { 231 231 dprintf(("GetNextDlgTabItem, window %x not found", hwndDlg)); 232 232 SetLastError(ERROR_INVALID_WINDOW_HANDLE); … … 234 234 } 235 235 dprintf(("USER32: GetNextDlgTabItem\n")); 236 return dialog->getNextDlgTabItem(hwndCtrl, fPrevious);236 return window->getNextDlgTabItem(hwndCtrl, fPrevious); 237 237 } 238 238 //****************************************************************************** … … 251 251 dlgcontrol = window->FindWindowById(id); 252 252 if(dlgcontrol) { 253 253 dprintf(("USER32: GetDlgItem %x %d returned %x\n", hwnd, id, dlgcontrol->getWindowHandle())); 254 254 return dlgcontrol->getWindowHandle(); 255 255 } … … 369 369 HWND WIN32API GetNextDlgGroupItem( HWND hwnd, HWND hwndCtrl, BOOL fPrevious) 370 370 { 371 Win32 Dialog *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) { 375 375 dprintf(("GetNextDlgGroupItem, window %x not found", hwnd)); 376 376 SetLastError(ERROR_INVALID_WINDOW_HANDLE); … … 378 378 } 379 379 dprintf(("USER32: GetNextDlgGroupItem\n")); 380 return dialog->getNextDlgGroupItem(hwndCtrl, fPrevious);380 return window->getNextDlgGroupItem(hwndCtrl, fPrevious); 381 381 } 382 382 /***********************************************************************
Note:
See TracChangeset
for help on using the changeset viewer.