Changeset 1526
- Timestamp:
- Oct 31, 1999, 2:14:44 AM (25 years ago)
- Location:
- trunk/src/user32
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified trunk/src/user32/win32dlg.cpp ¶
r1525 r1526 1 /* $Id: win32dlg.cpp,v 1.2 5 1999-10-30 18:40:47 cbratschiExp $ */1 /* $Id: win32dlg.cpp,v 1.26 1999-10-31 01:14:42 sandervl Exp $ */ 2 2 /* 3 3 * Win32 Dialog Code for OS/2 … … 46 46 47 47 dprintf(("********* CREATE DIALOG ************")); 48 xUnit = getXBaseUnit(); 49 yUnit = getYBaseUnit(); 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; 50 59 51 60 /* Parse dialog template */ … … 227 236 dprintf(("********* DIALOG CREATION FAILED! ************")); 228 237 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; 229 248 } 230 249 /*********************************************************************** … … 312 331 } 313 332 /*********************************************************************** 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 /*********************************************************************** 314 422 * DIALOG_ParseTemplate32 315 423 * … … 513 621 (LPCWSTR)info.className, 514 622 (LPCWSTR)info.windowName, 515 info.style | WS_CHILD | WS_CLIPSIBLINGS,623 info.style | WS_CHILD, 516 624 info.x * xUnit / 4, 517 625 info.y * yUnit / 8, … … 537 645 classNameA, 538 646 windowNameA, 539 info.style | WS_CHILD | WS_CLIPSIBLINGS,647 info.style | WS_CHILD, 540 648 info.x * xUnit / 4, 541 649 info.y * yUnit / 8, … … 978 1086 //****************************************************************************** 979 1087 //****************************************************************************** 980 1088 BOOL Win32Dialog::fInitialized = FALSE; 1089 int Win32Dialog::xBaseUnit = 10; 1090 int Win32Dialog::yBaseUnit = 20; -
TabularUnified trunk/src/user32/win32dlg.h ¶
r1525 r1526 1 /* $Id: win32dlg.h,v 1. 6 1999-10-30 18:40:47 cbratschiExp $ */1 /* $Id: win32dlg.h,v 1.7 1999-10-31 01:14:42 sandervl Exp $ */ 2 2 /* 3 3 * Win32 Dialog Code for OS/2 … … 71 71 BOOL endDialog(int retval); 72 72 73 BOOL MapDialogRect(LPRECT rect); 74 73 75 virtual ULONG MsgCreate(HWND hwndFrame, HWND hwndClient); 74 76 75 virtual 76 virtual 77 virtual LONG SetWindowLongA(int index, ULONG value); 78 virtual ULONG GetWindowLongA(int index); 77 79 78 INT doDialogBox(); 80 static ULONG GetDialogBaseUnits() { return MAKELONG(xBaseUnit, yBaseUnit); }; 81 82 INT doDialogBox(); 79 83 80 84 protected: 81 LPCSTR parseTemplate( LPCSTR dlgtemplate, DLG_TEMPLATE *result); 85 BOOL DIALOG_Init(void); 86 BOOL getCharSizeFromDC( HDC hDC, HFONT hFont, SIZE * pSize ); 87 BOOL getCharSize( HFONT hFont, SIZE * pSize); 88 LPCSTR parseTemplate( LPCSTR dlgtemplate, DLG_TEMPLATE *result); 82 89 WORD *getControl(const WORD *p, DLG_CONTROL_INFO *info, BOOL dialogEx); 83 84 85 90 BOOL createControls(LPCSTR dlgtemplate, HINSTANCE hInst); 91 92 LRESULT DefDlg_Proc(UINT msg, WPARAM wParam, LPARAM lParam); 86 93 LRESULT DefDlg_Epilog(UINT msg, BOOL fResult); 87 94 88 89 90 91 92 95 BOOL setDefButton(HWND hwndNew ); 96 HWND findDefButton(); 97 BOOL saveFocus(); 98 BOOL restoreFocus(); 99 void setFocus(HWND hwndCtrl ); 93 100 94 95 DLGPROC Win32DlgProc;//DWL_WNDPROC96 ULONG msgResult;//DWL_MSGRESULT97 ULONG userDlgData;//DWL_USER101 // values normally contained in the standard dialog words 102 DLGPROC Win32DlgProc; //DWL_WNDPROC 103 ULONG msgResult; //DWL_MSGRESULT 104 ULONG userDlgData; //DWL_USER 98 105 99 106 DLG_TEMPLATE dlgInfo; 100 101 102 103 104 105 106 107 WORD xUnit; 108 WORD yUnit; 109 HWND hwndFocus; 110 HFONT hUserFont; 111 HMENU hMenu; 112 DWORD idResult; 113 DWORD dialogFlags; 107 114 108 DWORD tmpParam; //set in ctor, used in MsgCreate method 109 LPSTR tmpDlgTemplate; //set in ctor, used in MsgCreate method 115 DWORD tmpParam; //set in ctor, used in MsgCreate method 116 LPSTR tmpDlgTemplate; //set in ctor, used in MsgCreate method 117 private: 118 static BOOL fInitialized; 119 static int xBaseUnit; 120 static int yBaseUnit; 110 121 }; 111 122 -
TabularUnified trunk/src/user32/win32wbase.cpp ¶
r1525 r1526 1 /* $Id: win32wbase.cpp,v 1. 69 1999-10-30 18:40:48 cbratschiExp $ */1 /* $Id: win32wbase.cpp,v 1.70 1999-10-31 01:14:42 sandervl Exp $ */ 2 2 /* 3 3 * Win32 Window Base Class for OS/2 … … 16 16 */ 17 17 #include <os2win.h> 18 #include <windowsx.h>19 18 #include <win.h> 20 19 #include <stdlib.h> … … 191 190 192 191 ownDC = 0; 193 194 //set dialog base units195 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 205 192 } 206 193 //****************************************************************************** … … 1597 1584 case WM_SETTEXT: 1598 1585 { 1599 if(!fInternalMsg) 1586 if(!fInternalMsg) 1600 1587 { 1601 1588 LRESULT result; … … 2752 2739 // else return hwnd; //OS/2 window handle 2753 2740 } 2754 /***********************************************************************2755 * DIALOG_Init2756 *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_GetCharSizeFromDC2775 *2776 *2777 * Calculates the *true* average size of English characters in the2778 * 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 returned2805 * by tmAveCharWidth. This works better when dealing with2806 * proportional spaced fonts and (more important) that's2807 * how Microsoft's dialog creation code calculates the size2808 * of the font2809 */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 else2818 {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_GetCharSize2830 *2831 *2832 * Calculates the *true* average size of English characters in the2833 * 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 2741 //****************************************************************************** 2844 2742 // GetNextDlgTabItem32 (USER32.276) … … 2995 2893 return retvalue; 2996 2894 } 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;3012 2895 //****************************************************************************** 3013 2896 //****************************************************************************** -
TabularUnified trunk/src/user32/win32wbase.h ¶
r1525 r1526 1 /* $Id: win32wbase.h,v 1.3 6 1999-10-30 18:40:48 cbratschiExp $ */1 /* $Id: win32wbase.h,v 1.37 1999-10-31 01:14:43 sandervl 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(); … … 205 205 BOOL EnumChildWindows(WNDENUMPROC lpfn, LPARAM lParam); 206 206 207 HWND getNextDlgTabItem(HWND hwndCtrl, BOOL fPrevious); 208 HWND getNextDlgGroupItem(HWND hwndCtrl, BOOL fPrevious); 209 207 210 static HWND Win32ToOS2Handle(HWND hwnd); 208 211 static HWND Win32ToOS2FrameHandle(HWND hwnd); … … 218 221 ULONG getBorderHeight() { return borderHeight; }; 219 222 220 static 221 static 222 static 223 static void NC_AdjustRectInner(LPRECT rect, DWORD style, DWORD exStyle); 224 static void NC_AdjustRectOuter(LPRECT rect, DWORD style, BOOL menu, DWORD exStyle); 225 static BOOL WindowNeedsWMBorder( DWORD style, DWORD exStyle ); 223 226 224 227 PVOID getOldWndProc() { return pOldWndProc; } … … 303 306 #ifndef OS2_INCLUDED 304 307 void GetMinMaxInfo(POINT *maxSize, POINT *maxPos, POINT *minTrack, POINT *maxTrack ); 305 308 LONG HandleWindowPosChanging(WINDOWPOS *winpos); 306 309 LONG HandleSysCommand(WPARAM wParam, POINT *pt32); 307 310 … … 345 348 BOOL isPSErase() { return EraseBkgndFlag | PSEraseFlag; } 346 349 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;367 350 }; 368 351 -
TabularUnified trunk/src/user32/windlg.cpp ¶
r1525 r1526 1 /* $Id: windlg.cpp,v 1. 9 1999-10-30 18:40:49 cbratschiExp $ */1 /* $Id: windlg.cpp,v 1.10 1999-10-31 01:14:44 sandervl Exp $ */ 2 2 /* 3 3 * Win32 dialog apis for OS/2 … … 202 202 BOOL WIN32API MapDialogRect(HWND hwndDlg, LPRECT rect) 203 203 { 204 Win32 BaseWindow *window;205 206 window =Win32BaseWindow::GetWindowFromHandle(hwndDlg);207 if(! window) {204 Win32Dialog *dialog; 205 206 dialog = (Win32Dialog *)Win32BaseWindow::GetWindowFromHandle(hwndDlg); 207 if(!dialog || !dialog->IsDialog()) { 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 window->MapDialogRect(rect);213 return dialog->MapDialogRect(rect); 214 214 } 215 215 //******************************************************************************
Note:
See TracChangeset
for help on using the changeset viewer.