Ignore:
Timestamp:
Oct 31, 1999, 2:14:44 AM (26 years ago)
Author:
sandervl
Message:

Window size + paint fix + dialog fixes

File:
1 edited

Legend:

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

    r1525 r1526  
    1 /* $Id: win32wbase.cpp,v 1.69 1999-10-30 18:40:48 cbratschi Exp $ */
     1/* $Id: win32wbase.cpp,v 1.70 1999-10-31 01:14:42 sandervl Exp $ */
    22/*
    33 * Win32 Window Base Class for OS/2
     
    1616 */
    1717#include <os2win.h>
    18 #include <windowsx.h>
    1918#include <win.h>
    2019#include <stdlib.h>
     
    191190
    192191  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 
    205192}
    206193//******************************************************************************
     
    15971584    case WM_SETTEXT:
    15981585    {
    1599         if(!fInternalMsg)
     1586        if(!fInternalMsg) 
    16001587        {
    16011588           LRESULT result;
     
    27522739//    else    return hwnd;    //OS/2 window handle
    27532740}
    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 }
    28432741//******************************************************************************
    28442742// GetNextDlgTabItem32   (USER32.276)
     
    29952893    return retvalue;
    29962894}
    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;
    30122895//******************************************************************************
    30132896//******************************************************************************
Note: See TracChangeset for help on using the changeset viewer.