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

button, static, scroll and dialog fixes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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
Note: See TracChangeset for help on using the changeset viewer.