| 1 | /* $Id: dlgconvert.cpp,v 1.4 1999-09-25 19:07:33 sandervl Exp $ */ | 
|---|
| 2 |  | 
|---|
| 3 | /* | 
|---|
| 4 | * Win32 runtime dialog conversion functions for OS/2 | 
|---|
| 5 | * | 
|---|
| 6 | * Copyright 1998 Sander van Leeuwen | 
|---|
| 7 | * Copyright 1998 Patrick Haller | 
|---|
| 8 | * Copyright 1998 Peter Fitzsimmons | 
|---|
| 9 | * | 
|---|
| 10 | * | 
|---|
| 11 | * Project Odin Software License can be found in LICENSE.TXT | 
|---|
| 12 | * | 
|---|
| 13 | */ | 
|---|
| 14 | #define INCL_DOSFILEMGR          /* File Manager values      */ | 
|---|
| 15 | #define INCL_DOSERRORS           /* DOS Error values         */ | 
|---|
| 16 | #define INCL_DOSPROCESS          /* DOS Process values       */ | 
|---|
| 17 | #define INCL_DOSMISC             /* DOS Miscellanous values  */ | 
|---|
| 18 | #define INCL_WIN | 
|---|
| 19 |  | 
|---|
| 20 | #define INCL_WINLISTBOXES       /* List box controls              */ | 
|---|
| 21 | #define INCL_WINSTDFIND         /* standard find/replace dialogs  */ | 
|---|
| 22 | #define INCL_WINSTDCOLOR        /* standard color dialog          */ | 
|---|
| 23 | #define INCL_WINSTDPRINT        /* standard print dialog          */ | 
|---|
| 24 | #define INCL_WINSTDMLE          /* Multiple Line Edit             */ | 
|---|
| 25 |  | 
|---|
| 26 | #include <os2ctlwx.h>           /* support for Open32 WinX styles */ | 
|---|
| 27 |  | 
|---|
| 28 | #include <os2wrap.h>    //Odin32 OS/2 api wrappers | 
|---|
| 29 | #include <stdio.h> | 
|---|
| 30 | #include <string.h> | 
|---|
| 31 | #include <stdlib.h> | 
|---|
| 32 | #include <string.h> | 
|---|
| 33 | #include <assert.h> | 
|---|
| 34 |  | 
|---|
| 35 | #define DWORD   ULONG | 
|---|
| 36 | #define LPVOID  VOID * | 
|---|
| 37 | #define WORD    USHORT | 
|---|
| 38 | #define WCHAR   USHORT | 
|---|
| 39 | #define HANDLE  ULONG | 
|---|
| 40 | #define LPWSTR  WCHAR * | 
|---|
| 41 |  | 
|---|
| 42 | #include "misc.h" | 
|---|
| 43 | #include "unicode.h" | 
|---|
| 44 | #include "nameid.h" | 
|---|
| 45 | #include "dlgconvert.h" | 
|---|
| 46 | #include "..\..\pe2lx\dialog.h" | 
|---|
| 47 |  | 
|---|
| 48 | #ifndef BS_TEXT /*PLF Sun  97-06-22 03:07:13  not in watcom's os/2 header */ | 
|---|
| 49 | #define BS_TEXT                 0x0010 | 
|---|
| 50 | #endif | 
|---|
| 51 |  | 
|---|
| 52 | #define DEFAULT_DLGFONT "9.WarpSans" | 
|---|
| 53 |  | 
|---|
| 54 | static int   ConvertClassAndStyle(int winclass, int style, USHORT *os2class, BOOL *fIconBmp); | 
|---|
| 55 | static int   ConvertDlgStyle(int style); | 
|---|
| 56 | static int   ConvertDlgItemStyle(int style); | 
|---|
| 57 | static void  ConvertCaption(ULONG style, char *caption); | 
|---|
| 58 | static int   ConvertFont(char *font, PRESPARAMS *dlgpparam, int fsize); | 
|---|
| 59 | DLGTEMPLATE *ConvertWin32DlgTemplateEx(WINDLGTEMPLATEEX *dhdr); | 
|---|
| 60 |  | 
|---|
| 61 | //****************************************************************************** | 
|---|
| 62 | //Dialog conversion: (win32 -> OS/2) | 
|---|
| 63 | //****************************************************************************** | 
|---|
| 64 | void DeleteWin32DlgTemplate(DLGTEMPLATE *os2dlg) | 
|---|
| 65 | { | 
|---|
| 66 | free(os2dlg); | 
|---|
| 67 | } | 
|---|
| 68 | //****************************************************************************** | 
|---|
| 69 | //****************************************************************************** | 
|---|
| 70 | DLGTEMPLATE *ConvertWin32DlgTemplate(DLGTEMPLATE *windlg) | 
|---|
| 71 | { | 
|---|
| 72 | WINDLGTEMPLATEEX *windlgex = (WINDLGTEMPLATEEX *)windlg; | 
|---|
| 73 | DialogBoxHeader *dhdr = (DialogBoxHeader *)windlg; | 
|---|
| 74 | DLGTEMPLATE *dlgt; | 
|---|
| 75 | DLGTITEM    *dlgitem; | 
|---|
| 76 | PRESPARAMS  *dlgpparam; | 
|---|
| 77 | char        *dlgdata, *dlgcurdata; | 
|---|
| 78 | WCHAR        *szCaption; | 
|---|
| 79 | WORD        *ptrArray; | 
|---|
| 80 | char        *ctrltext, *szClass, *font; | 
|---|
| 81 | FontHeader  *fhdr; | 
|---|
| 82 | ControlData *ctrldata; | 
|---|
| 83 | int          i, size; | 
|---|
| 84 | ULONG        ctrlflag, winclass; | 
|---|
| 85 | BOOL         fIconBmp; | 
|---|
| 86 |  | 
|---|
| 87 | if(windlgex->wDlgVer == 1 && windlgex->wSignature == 0xFFFF) { | 
|---|
| 88 | #ifdef DEBUG | 
|---|
| 89 | WriteLog("ConvertWin32DlgTemplate: DLGTEMPLATEEX!\n"); | 
|---|
| 90 | #endif | 
|---|
| 91 | return(ConvertWin32DlgTemplateEx(windlgex)); | 
|---|
| 92 | } | 
|---|
| 93 |  | 
|---|
| 94 | //should be enough | 
|---|
| 95 | size    = dhdr->NumberOfItems*sizeof(DLGTITEM) * 128; | 
|---|
| 96 | dlgt    = (DLGTEMPLATE *)malloc(sizeof(DLGTEMPLATE) + dhdr->NumberOfItems*sizeof(DLGTITEM) + size); | 
|---|
| 97 | dlgitem = &dlgt->adlgti[0]; | 
|---|
| 98 | dlgdata = (char *)&dlgt->adlgti[dhdr->NumberOfItems+1];  //for control data, presparams & strings | 
|---|
| 99 | memset((char *)dlgt, 0, sizeof(DLGTEMPLATE) + dhdr->NumberOfItems*sizeof(DLGTITEM) + size); | 
|---|
| 100 | dlgcurdata = dlgdata; | 
|---|
| 101 |  | 
|---|
| 102 | dlgt->codepage                          = 437; | 
|---|
| 103 | dlgt->offadlgti                         = 14; | 
|---|
| 104 | dlgt->fsTemplateStatus = 1; | 
|---|
| 105 | dlgt->iItemFocus       = 65535; | 
|---|
| 106 | dlgt->coffPresParams   = 0; | 
|---|
| 107 |  | 
|---|
| 108 | dlgitem->flStyle = ConvertDlgStyle(dhdr->lStyle) | WS_SYNCPAINT | WS_CLIPSIBLINGS; | 
|---|
| 109 |  | 
|---|
| 110 | ctrlflag = 0; | 
|---|
| 111 | if((dhdr->lStyle & WINWS_CAPTION) == WINWS_CAPTION) { | 
|---|
| 112 | ctrlflag |= FCF_TITLEBAR; | 
|---|
| 113 | dlgitem->flStyle |= FS_BORDER; | 
|---|
| 114 | } | 
|---|
| 115 | else | 
|---|
| 116 | if(dhdr->lStyle & WINWS_DLGFRAME)      //can't have title bar | 
|---|
| 117 | dlgitem->flStyle |= FS_DLGBORDER; | 
|---|
| 118 |  | 
|---|
| 119 | if((dhdr->lStyle & (WINWS_SYSMENU | WINWS_CAPTION)) == (WINWS_SYSMENU | WINWS_CAPTION)) | 
|---|
| 120 | ctrlflag |= FCF_SYSMENU; | 
|---|
| 121 | if(dhdr->lStyle & WINWS_VSCROLL) | 
|---|
| 122 | ctrlflag |= FCF_VERTSCROLL; | 
|---|
| 123 | if(dhdr->lStyle & WINWS_HSCROLL) | 
|---|
| 124 | ctrlflag |= FCF_HORZSCROLL; | 
|---|
| 125 | if(dhdr->lStyle & WINWS_MINIMIZEBOX) | 
|---|
| 126 | ctrlflag |= FCF_MINBUTTON; | 
|---|
| 127 | if(dhdr->lStyle & WINWS_MAXIMIZEBOX) | 
|---|
| 128 | ctrlflag |= FCF_MAXBUTTON; | 
|---|
| 129 | if(dhdr->lStyle & WINWS_THICKFRAME) | 
|---|
| 130 | dlgitem->flStyle |= FS_SIZEBORDER; | 
|---|
| 131 |  | 
|---|
| 132 | if(ctrlflag) { | 
|---|
| 133 | *(ULONG *)dlgcurdata = ctrlflag; | 
|---|
| 134 | dlgitem->offCtlData  = (USHORT)((int)dlgcurdata - (int)dlgt); | 
|---|
| 135 | dlgcurdata          += sizeof(ULONG); | 
|---|
| 136 | } | 
|---|
| 137 | else  dlgitem->offCtlData  = 0xFFFF; | 
|---|
| 138 | dlgitem->x           = dhdr->x; | 
|---|
| 139 | dlgitem->y           = dhdr->y; | 
|---|
| 140 | dlgitem->cx          = dhdr->cx; | 
|---|
| 141 | dlgitem->cy          = dhdr->cy; | 
|---|
| 142 | dlgitem->cChildren    = dhdr->NumberOfItems; | 
|---|
| 143 | dlgitem->id           = (USHORT)0;        //ord id or converted name id | 
|---|
| 144 | dlgitem->fsItemStatus = 1; | 
|---|
| 145 | dlgitem->offClassName = 1;             //WC_FRAME | 
|---|
| 146 |  | 
|---|
| 147 | #ifdef DEBUG | 
|---|
| 148 | WriteLog("Dialog Style         : %X\n", dhdr->lStyle); | 
|---|
| 149 | WriteLog("Extended Dialog Style: %X\n", dhdr->lExtendedStyle); | 
|---|
| 150 | WriteLog("Position             : (%d,%d)\n", dhdr->x ,dhdr->y); | 
|---|
| 151 | WriteLog("Size                 : (%d,%d)\n", dhdr->cx, dhdr->cy); | 
|---|
| 152 | WriteLog("Number of Items      : %d\n", dhdr->NumberOfItems); | 
|---|
| 153 | WriteLog("Sizeof(dhdr)         : %d\n", sizeof(*dhdr)); | 
|---|
| 154 | #endif | 
|---|
| 155 | //Menu id | 
|---|
| 156 | if(dhdr->fNameOrd == 0xFFFF) { | 
|---|
| 157 | #ifdef DEBUG | 
|---|
| 158 | WriteLog("Menu ID            : %d\n", (int)*(WORD *)(dhdr+1)); | 
|---|
| 159 | #endif | 
|---|
| 160 | ptrArray = (WORD *)((int)dhdr + sizeof(DialogBoxHeader) + sizeof(WORD)); | 
|---|
| 161 | } | 
|---|
| 162 | else { | 
|---|
| 163 | if(dhdr->fNameOrd == 0) {//SvL: 0 == no menu! | 
|---|
| 164 | ptrArray = (WORD *)((int)dhdr + sizeof(DialogBoxHeader)); | 
|---|
| 165 | } | 
|---|
| 166 | else { | 
|---|
| 167 | #ifdef DEBUG | 
|---|
| 168 | ctrltext = UnicodeToAsciiString((WCHAR *)&dhdr->fNameOrd); | 
|---|
| 169 | WriteLog("Menu namestring    : %s\n", ctrltext); | 
|---|
| 170 | FreeAsciiString(ctrltext); | 
|---|
| 171 | #endif | 
|---|
| 172 | ptrArray = (WORD *)((int)&dhdr->fNameOrd + UniStrlen((WCHAR *)(&dhdr->fNameOrd))*2 + sizeof(WCHAR)); | 
|---|
| 173 | } | 
|---|
| 174 | } | 
|---|
| 175 | //Class id | 
|---|
| 176 | if(*ptrArray == 0xFFFF) { | 
|---|
| 177 | #ifdef DEBUG | 
|---|
| 178 | winclass = (int)*(WORD *)(ptrArray+1); | 
|---|
| 179 | WriteLog("Class ID           : %d\n", winclass); | 
|---|
| 180 | #endif | 
|---|
| 181 | //SvL: shouldn't happen! (at least not with this code) | 
|---|
| 182 | assert(FALSE); | 
|---|
| 183 | ptrArray = (WORD *)((int)ptrArray + 2*sizeof(WORD)); | 
|---|
| 184 | } | 
|---|
| 185 | else { | 
|---|
| 186 | if(*ptrArray == 0) {//SvL: 0 == no class! | 
|---|
| 187 | ptrArray = (WORD *)((int)ptrArray + sizeof(WORD)); | 
|---|
| 188 | } | 
|---|
| 189 | else { | 
|---|
| 190 | szClass = UnicodeToAsciiString((WCHAR *)ptrArray); | 
|---|
| 191 | #ifdef DEBUG | 
|---|
| 192 | WriteLog("Class namestring    : %s\n", szClass); | 
|---|
| 193 | #endif | 
|---|
| 194 | //    cout << "Class Name            : " << szClass << endl; | 
|---|
| 195 |  | 
|---|
| 196 | dlgitem->cchClassName = strlen(szClass); | 
|---|
| 197 | dlgitem->offClassName = (USHORT)((int)dlgcurdata - (int)dlgt); | 
|---|
| 198 | strcpy((char *)dlgcurdata, szClass); | 
|---|
| 199 | //Open32 wants class name in upper case! | 
|---|
| 200 | strupr((char *)dlgcurdata); | 
|---|
| 201 | dlgcurdata           += dlgitem->cchClassName + 1;   //include terminating 0 (just to be sure) | 
|---|
| 202 | //TODO: SvL: Can they also be system classes? | 
|---|
| 203 | //    dlgitem->flStyle      = dhdr->lStyle; | 
|---|
| 204 | //    dlgitem->flStyle      = ConvertDlgItemStyle(dhdr->lStyle); | 
|---|
| 205 | ptrArray = (WORD *)((int)ptrArray + UniStrlen((WCHAR *)(ptrArray))*2 + sizeof(WORD)); | 
|---|
| 206 | FreeAsciiString(szClass); | 
|---|
| 207 | } | 
|---|
| 208 | } | 
|---|
| 209 |  | 
|---|
| 210 | //Title | 
|---|
| 211 | if(*ptrArray == 0) { | 
|---|
| 212 | #ifdef DEBUG | 
|---|
| 213 | WriteLog("No title\n"); | 
|---|
| 214 | #endif | 
|---|
| 215 | ctrldata = (ControlData *)((int)(int)ptrArray + sizeof(WORD)); | 
|---|
| 216 | } | 
|---|
| 217 | else { | 
|---|
| 218 | ctrltext = UnicodeToAsciiString((WCHAR *)(ptrArray)); | 
|---|
| 219 | #ifdef DEBUG | 
|---|
| 220 | WriteLog("Title                : %s\n", ctrltext); | 
|---|
| 221 | #endif | 
|---|
| 222 | ctrldata = (ControlData *)((int)(int)ptrArray + UniStrlen((WCHAR *)(ptrArray))*2 + sizeof(WORD)); | 
|---|
| 223 |  | 
|---|
| 224 | if(ctrltext[0] != 0) { | 
|---|
| 225 | dlgitem->cchText = strlen(ctrltext); | 
|---|
| 226 | dlgitem->offText = (USHORT)((int)dlgcurdata - (int)dlgt); | 
|---|
| 227 | strcpy((char *)dlgcurdata, ctrltext); | 
|---|
| 228 | dlgcurdata      += dlgitem->cchText + 1; //include terminating 0 (just to be sure) | 
|---|
| 229 | } else | 
|---|
| 230 | { //CB: cchText == 0, OS/2 uses offText anyway! (entryfields) | 
|---|
| 231 | dlgitem->offText = (USHORT)((int)dlgcurdata-(int)dlgt); | 
|---|
| 232 | dlgcurdata++; //0 at offText | 
|---|
| 233 | } | 
|---|
| 234 | FreeAsciiString(ctrltext); | 
|---|
| 235 | } | 
|---|
| 236 | dlgitem++; | 
|---|
| 237 |  | 
|---|
| 238 | if(dhdr->lStyle & DS_SETFONT) { | 
|---|
| 239 | fhdr = (FontHeader *)ctrldata; | 
|---|
| 240 | font = UnicodeToAsciiString(fhdr->szFontName); | 
|---|
| 241 | #ifdef DEBUG | 
|---|
| 242 | WriteLog("Font Point Size      : %d\n", fhdr->wPointSize); | 
|---|
| 243 | WriteLog("Font Name            : %s\n", font); | 
|---|
| 244 | #endif | 
|---|
| 245 | ctrldata = (ControlData *)((int)fhdr + sizeof(FontHeader) - 2 + UniStrlen(fhdr->szFontName)*2 + sizeof(WORD));  /*PLF Sat  97-06-21 20:22:44*/ | 
|---|
| 246 | //TODO: no pres params yet (font in win32 dialog ignored) | 
|---|
| 247 | dlgpparam = (PRESPARAMS *)dlgcurdata; | 
|---|
| 248 | dlgpparam->cb = 0; | 
|---|
| 249 | dlgpparam->aparam[0].id = PP_FONTNAMESIZE; | 
|---|
| 250 | dlgpparam->aparam[0].cb = 0; | 
|---|
| 251 | strupr(font); | 
|---|
| 252 | if(ConvertFont(font, dlgpparam, fhdr->wPointSize) == TRUE) { | 
|---|
| 253 | dlgpparam->cb           = sizeof(PARAM) + dlgpparam->aparam[0].cb - 1; | 
|---|
| 254 | dlgpparam->aparam[0].cb = strlen(dlgpparam->aparam[0].ab) + 1; | 
|---|
| 255 | dlgt->coffPresParams    = (int)dlgpparam; | 
|---|
| 256 | dlgcurdata += sizeof(PRESPARAMS) + dlgpparam->aparam[0].cb - 1; | 
|---|
| 257 | }  else | 
|---|
| 258 | { //CB: set default font | 
|---|
| 259 | dlgpparam = (PRESPARAMS*)dlgcurdata; | 
|---|
| 260 | dlgpparam->aparam[0].id = PP_FONTNAMESIZE; | 
|---|
| 261 | dlgpparam->aparam[0].cb = strlen(DEFAULT_DLGFONT)+1; | 
|---|
| 262 | strcpy((char*)&dlgpparam->aparam[0].ab,DEFAULT_DLGFONT); | 
|---|
| 263 | dlgpparam->cb           = dlgpparam->aparam[0].cb+2*sizeof(ULONG); | 
|---|
| 264 | dlgitem->offPresParams  = (USHORT)((int)dlgpparam-(int)dlgt); | 
|---|
| 265 | dlgt->coffPresParams++; | 
|---|
| 266 | dlgcurdata             += dlgpparam->cb+sizeof(dlgpparam->cb); | 
|---|
| 267 | } | 
|---|
| 268 | FreeAsciiString(font); | 
|---|
| 269 | }  else | 
|---|
| 270 | { //CB: set default font | 
|---|
| 271 | dlgpparam = (PRESPARAMS*)dlgcurdata; | 
|---|
| 272 | dlgpparam->aparam[0].id = PP_FONTNAMESIZE; | 
|---|
| 273 | dlgpparam->aparam[0].cb = strlen(DEFAULT_DLGFONT)+1; | 
|---|
| 274 | strcpy((char*)&dlgpparam->aparam[0].ab,DEFAULT_DLGFONT); | 
|---|
| 275 | dlgpparam->cb           = dlgpparam->aparam[0].cb+2*sizeof(ULONG); | 
|---|
| 276 | dlgitem->offPresParams  = (USHORT)((int)dlgpparam-(int)dlgt); | 
|---|
| 277 | dlgt->coffPresParams++; | 
|---|
| 278 | dlgcurdata             += dlgpparam->cb+sizeof(dlgpparam->cb); | 
|---|
| 279 | } | 
|---|
| 280 | ctrldata = (ControlData *)(((int)ctrldata+3) & ~3); | 
|---|
| 281 |  | 
|---|
| 282 | for(i=0;i<dhdr->NumberOfItems;i++) { | 
|---|
| 283 | //save as OS/2 DLGTITEM | 
|---|
| 284 | dlgitem->x             = ctrldata->x; | 
|---|
| 285 | //SvL: 3-8-'97 | 
|---|
| 286 | // OS/2  -> left bottom == origin and y coordinate == left bottom origin control | 
|---|
| 287 | // Win32 -> left top    == origin and y coordinate == left top origin | 
|---|
| 288 | dlgitem->y             = dlgt->adlgti[0].cy - ctrldata->y - ctrldata->cy; | 
|---|
| 289 | dlgitem->cx            = ctrldata->cx; | 
|---|
| 290 | dlgitem->cy            = ctrldata->cy; | 
|---|
| 291 | dlgitem->id            = ctrldata->wId; | 
|---|
| 292 | dlgitem->offCtlData    = 0xFFFF; | 
|---|
| 293 | dlgitem->offPresParams = 0xFFFF; | 
|---|
| 294 |  | 
|---|
| 295 | //TODO: Extended style | 
|---|
| 296 |  | 
|---|
| 297 | #ifdef DEBUG | 
|---|
| 298 | WriteLog("***** Control Style   : %X\n", ctrldata->lStyle); | 
|---|
| 299 | WriteLog("Extended Control Style: %X\n", ctrldata->lExtendedStyle); | 
|---|
| 300 | WriteLog("Position              : (%d,%d)\n", ctrldata->x, ctrldata->y); | 
|---|
| 301 | WriteLog("Size                  : (%d,%d)\n", ctrldata->cx, ctrldata->cy); | 
|---|
| 302 | WriteLog("wID                   : %d\n", ctrldata->wId); | 
|---|
| 303 | #endif | 
|---|
| 304 | winclass = 0; | 
|---|
| 305 | if(ctrldata->fClassId == 0xFFFF) { | 
|---|
| 306 | winclass = *(WORD *)(ctrldata+1); | 
|---|
| 307 | #ifdef DEBUG | 
|---|
| 308 | WriteLog("Class ID              : %d\n", winclass); | 
|---|
| 309 | #endif | 
|---|
| 310 | szCaption = (WCHAR *)((int)ctrldata + sizeof(ControlData) + sizeof(WORD)); | 
|---|
| 311 | dlgitem->flStyle      = ConvertClassAndStyle(winclass, ctrldata->lStyle, &dlgitem->offClassName, &fIconBmp); | 
|---|
| 312 | dlgitem->cchClassName = 0; | 
|---|
| 313 | } | 
|---|
| 314 | else { | 
|---|
| 315 | szClass = UnicodeToAsciiString((WCHAR *)&ctrldata->fClassId); | 
|---|
| 316 | #ifdef DEBUG | 
|---|
| 317 | WriteLog("Class Name            : %s\n", szClass); | 
|---|
| 318 | #endif | 
|---|
| 319 | szCaption = (WCHAR *)((int)ctrldata + sizeof(ControlData) + strlen(szClass)*2); | 
|---|
| 320 | dlgitem->cchClassName = strlen(szClass); | 
|---|
| 321 | dlgitem->offClassName = (USHORT)((int)dlgcurdata - (int)dlgt); | 
|---|
| 322 | strcpy((char *)dlgcurdata, szClass); | 
|---|
| 323 | //Open32 wants class name in upper case! | 
|---|
| 324 | strupr((char *)dlgcurdata); | 
|---|
| 325 | dlgcurdata           += dlgitem->cchClassName + 1;   //include terminating 0 (just to be sure) | 
|---|
| 326 | //TODO: SvL: Can they also be system classes? | 
|---|
| 327 | //    dlgitem->flStyle      = ctrldata->lStyle; | 
|---|
| 328 | dlgitem->flStyle      = ConvertDlgItemStyle(ctrldata->lStyle) ; | 
|---|
| 329 | FreeAsciiString(szClass); | 
|---|
| 330 | } | 
|---|
| 331 | if(*(USHORT *)szCaption == 0xFFFF) { | 
|---|
| 332 | szCaption += 2; | 
|---|
| 333 | dlgitem->cchText = 0; | 
|---|
| 334 | dlgitem->offText = (USHORT)((int)dlgcurdata-(int)dlgt); | 
|---|
| 335 | dlgcurdata += 1; //CB: offText == empty string | 
|---|
| 336 | } | 
|---|
| 337 | else {   //Handle Caption | 
|---|
| 338 | ctrltext = UnicodeToAsciiString(szCaption); | 
|---|
| 339 | //SvL: (16-9-'97) Convert '&' chars to '~' (for some classes) | 
|---|
| 340 | ConvertCaption(winclass, ctrltext); | 
|---|
| 341 | if(fIconBmp == TRUE) {//control contains bitmap or icon | 
|---|
| 342 | dlgitem->offText = (USHORT)((int)dlgcurdata - (int)dlgt); | 
|---|
| 343 | int resid =  ConvertNameId(NULL, ctrltext); | 
|---|
| 344 | *(char *)dlgcurdata = '#'; | 
|---|
| 345 | itoa(resid, (char *)dlgcurdata+1, 10); | 
|---|
| 346 | dlgitem->cchText = strlen((char *)dlgcurdata); //one USHORT for res id | 
|---|
| 347 | dlgcurdata      += dlgitem->cchText + 1; //include terminating 0 (just to be sure) | 
|---|
| 348 | } | 
|---|
| 349 | else { | 
|---|
| 350 | if(ctrltext[0] != 0) { | 
|---|
| 351 | dlgitem->cchText = strlen(ctrltext); | 
|---|
| 352 | dlgitem->offText = (USHORT)((int)dlgcurdata - (int)dlgt); | 
|---|
| 353 | strcpy((char *)dlgcurdata, ctrltext); | 
|---|
| 354 | dlgcurdata      += dlgitem->cchText + 1; //include terminating 0 (just to be sure) | 
|---|
| 355 | } else | 
|---|
| 356 | { //CB: cchText == 0, OS/2 uses offText anyway! (entryfields) | 
|---|
| 357 | dlgitem->offText = (USHORT)((int)dlgcurdata-(int)dlgt); | 
|---|
| 358 | dlgcurdata++; //0 at offText | 
|---|
| 359 | } | 
|---|
| 360 | } | 
|---|
| 361 | #ifdef DEBUG | 
|---|
| 362 | szClass = UnicodeToAsciiString(szCaption); | 
|---|
| 363 | WriteLog("Text                  : %s\n", szClass); | 
|---|
| 364 | FreeAsciiString(szClass); | 
|---|
| 365 | #endif | 
|---|
| 366 | szCaption = (WCHAR *)((int)szCaption + UniStrlen(szCaption)*2 + sizeof(WORD)); | 
|---|
| 367 | } | 
|---|
| 368 |  | 
|---|
| 369 | // cout << "Extra Stuff WORD      : " << *(WORD *)(szCaption) << endl; | 
|---|
| 370 | ctrldata = (ControlData *)((int)szCaption + sizeof(WORD)); | 
|---|
| 371 | ctrldata = (ControlData *)(((int)ctrldata+3) & ~3); | 
|---|
| 372 | dlgitem++; | 
|---|
| 373 | } | 
|---|
| 374 | //calculate dialog box length | 
|---|
| 375 | dlgt->cbTemplate = (USHORT)((int)dlgcurdata - (int)dlgt); | 
|---|
| 376 | return(dlgt); | 
|---|
| 377 | } | 
|---|
| 378 | //****************************************************************************** | 
|---|
| 379 | //****************************************************************************** | 
|---|
| 380 | DLGTEMPLATE *ConvertWin32DlgTemplateEx(WINDLGTEMPLATEEX *dhdr) | 
|---|
| 381 | { | 
|---|
| 382 | DLGTEMPLATE *dlgt; | 
|---|
| 383 | DLGTITEM    *dlgitem; | 
|---|
| 384 | PRESPARAMS  *dlgpparam; | 
|---|
| 385 | char        *dlgdata, *dlgcurdata; | 
|---|
| 386 | WCHAR        *szCaption; | 
|---|
| 387 | WORD        *ptrArray; | 
|---|
| 388 | char        *ctrltext, *szClass, *font; | 
|---|
| 389 | FontHeaderEx *fhdr; | 
|---|
| 390 | WINDLGITEMTEMPLATEEX *ctrldata; | 
|---|
| 391 | int          i, size; | 
|---|
| 392 | ULONG        ctrlflag, winclass; | 
|---|
| 393 | BOOL         fIconBmp; | 
|---|
| 394 |  | 
|---|
| 395 | //should be enough | 
|---|
| 396 | size    = dhdr->NumberOfItems*sizeof(DLGTITEM) * 128; | 
|---|
| 397 | dlgt    = (DLGTEMPLATE *)malloc(sizeof(DLGTEMPLATE) + dhdr->NumberOfItems*sizeof(DLGTITEM) + size); | 
|---|
| 398 | dlgitem = &dlgt->adlgti[0]; | 
|---|
| 399 | dlgdata = (char *)&dlgt->adlgti[dhdr->NumberOfItems+1];  //for control data, presparams & strings | 
|---|
| 400 | memset((char *)dlgt, 0, sizeof(DLGTEMPLATE) + dhdr->NumberOfItems*sizeof(DLGTITEM) + size); | 
|---|
| 401 | dlgcurdata = dlgdata; | 
|---|
| 402 |  | 
|---|
| 403 | dlgt->codepage                          = 437; | 
|---|
| 404 | dlgt->offadlgti                         = 14; | 
|---|
| 405 | dlgt->fsTemplateStatus = 1; | 
|---|
| 406 | dlgt->iItemFocus       = 65535; | 
|---|
| 407 | dlgt->coffPresParams   = 0; | 
|---|
| 408 |  | 
|---|
| 409 | //  dlgitem->flStyle = ConvertDlgStyle(dhdr->lStyle) | WS_SYNCPAINT | WS_CLIPSIBLINGS; | 
|---|
| 410 | dlgitem->flStyle = ConvertDlgStyle(dhdr->lStyle) | WS_VISIBLE; | 
|---|
| 411 |  | 
|---|
| 412 | ctrlflag = 0; | 
|---|
| 413 | if((dhdr->lStyle & WINWS_CAPTION) == WINWS_CAPTION) { | 
|---|
| 414 | ctrlflag |= FCF_TITLEBAR; | 
|---|
| 415 | dlgitem->flStyle |= FS_BORDER; | 
|---|
| 416 | } | 
|---|
| 417 | else | 
|---|
| 418 | if(dhdr->lStyle & WINWS_DLGFRAME)      //can't have title bar | 
|---|
| 419 | dlgitem->flStyle |= FS_DLGBORDER; | 
|---|
| 420 |  | 
|---|
| 421 | if((dhdr->lStyle & (WINWS_SYSMENU | WINWS_CAPTION)) == (WINWS_SYSMENU | WINWS_CAPTION)) | 
|---|
| 422 | ctrlflag |= FCF_SYSMENU; | 
|---|
| 423 | if(dhdr->lStyle & WINWS_VSCROLL) | 
|---|
| 424 | ctrlflag |= FCF_VERTSCROLL; | 
|---|
| 425 | if(dhdr->lStyle & WINWS_HSCROLL) | 
|---|
| 426 | ctrlflag |= FCF_HORZSCROLL; | 
|---|
| 427 | if(dhdr->lStyle & WINWS_MINIMIZEBOX) | 
|---|
| 428 | ctrlflag |= FCF_MINBUTTON; | 
|---|
| 429 | if(dhdr->lStyle & WINWS_MAXIMIZEBOX) | 
|---|
| 430 | ctrlflag |= FCF_MAXBUTTON; | 
|---|
| 431 | if(dhdr->lStyle & WINWS_THICKFRAME) | 
|---|
| 432 | dlgitem->flStyle |= FS_SIZEBORDER; | 
|---|
| 433 |  | 
|---|
| 434 | if(ctrlflag) { | 
|---|
| 435 | *(ULONG *)dlgcurdata = ctrlflag; | 
|---|
| 436 | dlgitem->offCtlData  = (USHORT)((int)dlgcurdata - (int)dlgt); | 
|---|
| 437 | dlgcurdata          += sizeof(ULONG); | 
|---|
| 438 | } | 
|---|
| 439 | else  dlgitem->offCtlData  = 0xFFFF; | 
|---|
| 440 | dlgitem->x           = dhdr->x; | 
|---|
| 441 | dlgitem->y           = dhdr->y; | 
|---|
| 442 | dlgitem->cx          = dhdr->cx; | 
|---|
| 443 | dlgitem->cy          = dhdr->cy; | 
|---|
| 444 | dlgitem->cChildren    = dhdr->NumberOfItems; | 
|---|
| 445 | dlgitem->id           = (USHORT)0;        //ord id or converted name id | 
|---|
| 446 | dlgitem->fsItemStatus = 1; | 
|---|
| 447 | dlgitem->offClassName = 1;             //WC_FRAME | 
|---|
| 448 |  | 
|---|
| 449 | #ifdef DEBUG | 
|---|
| 450 | WriteLog("Dialog Style         : %X\n", dhdr->lStyle); | 
|---|
| 451 | WriteLog("Extended Dialog Style: %X\n", dhdr->lExtendedStyle); | 
|---|
| 452 | WriteLog("Position             : (%d,%d)\n", dhdr->x ,dhdr->y); | 
|---|
| 453 | WriteLog("Size                 : (%d,%d)\n", dhdr->cx, dhdr->cy); | 
|---|
| 454 | WriteLog("Number of Items      : %d\n", dhdr->NumberOfItems); | 
|---|
| 455 | WriteLog("Sizeof(dhdr)         : %d\n", sizeof(*dhdr)); | 
|---|
| 456 | #endif | 
|---|
| 457 | //Menu id | 
|---|
| 458 | if(dhdr->fNameOrd == 0xFFFF) { | 
|---|
| 459 | #ifdef DEBUG | 
|---|
| 460 | WriteLog("Menu ID            : %d\n", (int)*(WORD *)(dhdr+1)); | 
|---|
| 461 | #endif | 
|---|
| 462 | ptrArray = (WORD *)((int)dhdr + sizeof(WINDLGTEMPLATEEX) + sizeof(WORD)); | 
|---|
| 463 | } | 
|---|
| 464 | else { | 
|---|
| 465 | if(dhdr->fNameOrd == 0) {//SvL: 0 == no menu! | 
|---|
| 466 | ptrArray = (WORD *)((int)dhdr + sizeof(WINDLGTEMPLATEEX)); | 
|---|
| 467 | } | 
|---|
| 468 | else { | 
|---|
| 469 | #ifdef DEBUG | 
|---|
| 470 | ctrltext = UnicodeToAsciiString((WCHAR *)&dhdr->fNameOrd); | 
|---|
| 471 | WriteLog("Menu namestring    : %s\n", ctrltext); | 
|---|
| 472 | FreeAsciiString(ctrltext); | 
|---|
| 473 | #endif | 
|---|
| 474 | ptrArray = (WORD *)((int)&dhdr->fNameOrd + UniStrlen((WCHAR *)(&dhdr->fNameOrd))*2 + sizeof(WCHAR)); | 
|---|
| 475 | } | 
|---|
| 476 | } | 
|---|
| 477 | //Class id | 
|---|
| 478 | if(*ptrArray == 0xFFFF) { | 
|---|
| 479 | #ifdef DEBUG | 
|---|
| 480 | WriteLog("Class ID           : %d\n", (int)*(WORD *)(ptrArray+1)); | 
|---|
| 481 | #endif | 
|---|
| 482 | ptrArray = (WORD *)((int)ptrArray + 2*sizeof(WORD)); | 
|---|
| 483 | } | 
|---|
| 484 | else { | 
|---|
| 485 | if(*ptrArray == 0) {//SvL: 0 == no class! | 
|---|
| 486 | ptrArray = (WORD *)((int)ptrArray + sizeof(WORD)); | 
|---|
| 487 | } | 
|---|
| 488 | else { | 
|---|
| 489 | szClass = UnicodeToAsciiString((WCHAR *)ptrArray); | 
|---|
| 490 | #ifdef DEBUG | 
|---|
| 491 | WriteLog("Class namestring    : %s\n", szClass); | 
|---|
| 492 | #endif | 
|---|
| 493 | //    cout << "Class Name            : " << szClass << endl; | 
|---|
| 494 | #if 1 | 
|---|
| 495 | dlgitem->cchClassName = strlen(szClass); | 
|---|
| 496 | dlgitem->offClassName = (USHORT)((int)dlgcurdata - (int)dlgt); | 
|---|
| 497 | strcpy((char *)dlgcurdata, szClass); | 
|---|
| 498 | //Open32 wants class name in upper case! | 
|---|
| 499 | strupr((char *)dlgcurdata); | 
|---|
| 500 | dlgcurdata           += dlgitem->cchClassName + 1;   //include terminating 0 (just to be sure) | 
|---|
| 501 | //TODO: SvL: Can they also be system classes? | 
|---|
| 502 | //    dlgitem->flStyle      = dhdr->lStyle; | 
|---|
| 503 | //    dlgitem->flStyle      = ConvertDlgItemStyle(dhdr->lStyle); | 
|---|
| 504 | #endif | 
|---|
| 505 | ptrArray = (WORD *)((int)ptrArray + UniStrlen((WCHAR *)(ptrArray))*2 + sizeof(WORD)); | 
|---|
| 506 | FreeAsciiString(szClass); | 
|---|
| 507 | } | 
|---|
| 508 | } | 
|---|
| 509 |  | 
|---|
| 510 | //Title | 
|---|
| 511 | if(*ptrArray == 0) { | 
|---|
| 512 | #ifdef DEBUG | 
|---|
| 513 | WriteLog("No title\n"); | 
|---|
| 514 | #endif | 
|---|
| 515 | ctrldata = (WINDLGITEMTEMPLATEEX *)((int)(int)ptrArray + sizeof(WORD)); | 
|---|
| 516 | } | 
|---|
| 517 | else { | 
|---|
| 518 | ctrltext = UnicodeToAsciiString((WCHAR *)(ptrArray)); | 
|---|
| 519 | #ifdef DEBUG | 
|---|
| 520 | WriteLog("Title                : %s\n", ctrltext); | 
|---|
| 521 | #endif | 
|---|
| 522 | ctrldata = (WINDLGITEMTEMPLATEEX *)((int)(int)ptrArray + UniStrlen((WCHAR *)(ptrArray))*2 + sizeof(WORD)); | 
|---|
| 523 |  | 
|---|
| 524 | if(ctrltext[0] != 0) { | 
|---|
| 525 | dlgitem->cchText = strlen(ctrltext); | 
|---|
| 526 | dlgitem->offText = (USHORT)((int)dlgcurdata - (int)dlgt); | 
|---|
| 527 | strcpy((char *)dlgcurdata, ctrltext); | 
|---|
| 528 | dlgcurdata      += dlgitem->cchText + 1; //include terminating 0 (just to be sure) | 
|---|
| 529 | } else | 
|---|
| 530 | { //CB: cchText == 0, OS/2 uses offText anyway! (entryfields) | 
|---|
| 531 | dlgitem->offText = (USHORT)((int)dlgcurdata-(int)dlgt); | 
|---|
| 532 | dlgcurdata++; //0 at offText | 
|---|
| 533 | } | 
|---|
| 534 | FreeAsciiString(ctrltext); | 
|---|
| 535 | } | 
|---|
| 536 | dlgitem++; | 
|---|
| 537 |  | 
|---|
| 538 | if(dhdr->lStyle & DS_SETFONT) { | 
|---|
| 539 | fhdr = (FontHeaderEx *)ctrldata; | 
|---|
| 540 | font = UnicodeToAsciiString(fhdr->szFontName); | 
|---|
| 541 | #ifdef DEBUG | 
|---|
| 542 | WriteLog("Font Point Size      : %d\n", fhdr->wPointSize); | 
|---|
| 543 | WriteLog("Font Name            : %s\n", font); | 
|---|
| 544 | #endif | 
|---|
| 545 | ctrldata = (WINDLGITEMTEMPLATEEX *)((int)fhdr + sizeof(FontHeaderEx) - 2 + UniStrlen(fhdr->szFontName)*2 + sizeof(WORD));  /*PLF Sat  97-06-21 20:22:44*/ | 
|---|
| 546 | //TODO: no pres params yet (font in win32 dialog ignored) | 
|---|
| 547 | dlgpparam = (PRESPARAMS *)dlgcurdata; | 
|---|
| 548 | dlgpparam->cb = 0; | 
|---|
| 549 | dlgpparam->aparam[0].id = PP_FONTNAMESIZE; | 
|---|
| 550 | dlgpparam->aparam[0].cb = 0; | 
|---|
| 551 | strupr(font); | 
|---|
| 552 | if(ConvertFont(font, dlgpparam, fhdr->wPointSize) == TRUE) { | 
|---|
| 553 | dlgpparam->cb           = sizeof(PARAM) + dlgpparam->aparam[0].cb - 1; | 
|---|
| 554 | dlgpparam->aparam[0].cb = strlen(dlgpparam->aparam[0].ab) + 1; | 
|---|
| 555 | dlgt->coffPresParams    = (int)dlgpparam; | 
|---|
| 556 | dlgcurdata += sizeof(PRESPARAMS) + dlgpparam->aparam[0].cb - 1; | 
|---|
| 557 | } else | 
|---|
| 558 | { //CB: set default font | 
|---|
| 559 | dlgpparam = (PRESPARAMS*)dlgcurdata; | 
|---|
| 560 | dlgpparam->aparam[0].id = PP_FONTNAMESIZE; | 
|---|
| 561 | dlgpparam->aparam[0].cb = strlen(DEFAULT_DLGFONT)+1; | 
|---|
| 562 | strcpy((char*)&dlgpparam->aparam[0].ab,DEFAULT_DLGFONT); | 
|---|
| 563 | dlgpparam->cb           = dlgpparam->aparam[0].cb+2*sizeof(ULONG); | 
|---|
| 564 | dlgitem->offPresParams  = (USHORT)((int)dlgpparam-(int)dlgt); | 
|---|
| 565 | dlgt->coffPresParams++; | 
|---|
| 566 | dlgcurdata             += dlgpparam->cb+sizeof(dlgpparam->cb); | 
|---|
| 567 | } | 
|---|
| 568 | FreeAsciiString(font); | 
|---|
| 569 | } else | 
|---|
| 570 | { //CB: set default font | 
|---|
| 571 | dlgpparam = (PRESPARAMS*)dlgcurdata; | 
|---|
| 572 | dlgpparam->aparam[0].id = PP_FONTNAMESIZE; | 
|---|
| 573 | dlgpparam->aparam[0].cb = strlen(DEFAULT_DLGFONT)+1; | 
|---|
| 574 | strcpy((char*)&dlgpparam->aparam[0].ab,DEFAULT_DLGFONT); | 
|---|
| 575 | dlgpparam->cb           = dlgpparam->aparam[0].cb+2*sizeof(ULONG); | 
|---|
| 576 | dlgitem->offPresParams  = (USHORT)((int)dlgpparam-(int)dlgt); | 
|---|
| 577 | dlgt->coffPresParams++; | 
|---|
| 578 | dlgcurdata             += dlgpparam->cb+sizeof(dlgpparam->cb); | 
|---|
| 579 | } | 
|---|
| 580 | ctrldata = (WINDLGITEMTEMPLATEEX *)(((int)ctrldata+3) & ~3); | 
|---|
| 581 |  | 
|---|
| 582 | for(i=0;i<dhdr->NumberOfItems;i++) { | 
|---|
| 583 | //save as OS/2 DLGTITEM | 
|---|
| 584 | dlgitem->x             = ctrldata->x; | 
|---|
| 585 | //SvL: 3-8-'97 | 
|---|
| 586 | // OS/2  -> left bottom == origin and y coordinate == left bottom origin control | 
|---|
| 587 | // Win32 -> left top    == origin and y coordinate == left top origin | 
|---|
| 588 | dlgitem->y             = dlgt->adlgti[0].cy - ctrldata->y - ctrldata->cy; | 
|---|
| 589 | dlgitem->cx            = ctrldata->cx; | 
|---|
| 590 | dlgitem->cy            = ctrldata->cy; | 
|---|
| 591 | dlgitem->id            = ctrldata->wId; | 
|---|
| 592 | dlgitem->offCtlData    = 0xFFFF; | 
|---|
| 593 | dlgitem->offPresParams = 0xFFFF; | 
|---|
| 594 |  | 
|---|
| 595 | //TODO: Extended style | 
|---|
| 596 | #ifdef DEBUG | 
|---|
| 597 | WriteLog("***** Control Style   : %X\n", ctrldata->lStyle); | 
|---|
| 598 | WriteLog("Extended Control Style: %X\n", ctrldata->lExtendedStyle); | 
|---|
| 599 | WriteLog("Position              : (%d,%d)\n", ctrldata->x, ctrldata->y); | 
|---|
| 600 | WriteLog("Size                  : (%d,%d)\n", ctrldata->cx, ctrldata->cy); | 
|---|
| 601 | WriteLog("wID                   : %d\n", ctrldata->wId); | 
|---|
| 602 | #endif | 
|---|
| 603 | winclass = 0; | 
|---|
| 604 | if(ctrldata->fClassId == 0xFFFF) { | 
|---|
| 605 | winclass = *(WORD *)(ctrldata+1); | 
|---|
| 606 | #ifdef DEBUG | 
|---|
| 607 | WriteLog("Class ID              : %d\n", winclass); | 
|---|
| 608 | #endif | 
|---|
| 609 | szCaption = (WCHAR *)((int)ctrldata + sizeof(WINDLGITEMTEMPLATEEX) + sizeof(WORD)); | 
|---|
| 610 | dlgitem->flStyle      = ConvertClassAndStyle(*(WORD *)(ctrldata+1), ctrldata->lStyle, &dlgitem->offClassName, &fIconBmp); | 
|---|
| 611 | dlgitem->cchClassName = 0; | 
|---|
| 612 | } | 
|---|
| 613 | else { | 
|---|
| 614 | szClass = UnicodeToAsciiString((WCHAR *)&ctrldata->fClassId); | 
|---|
| 615 | #ifdef DEBUG | 
|---|
| 616 | WriteLog("Class Name            : %s\n", szClass); | 
|---|
| 617 | #endif | 
|---|
| 618 | szCaption = (WCHAR *)((int)ctrldata + sizeof(WINDLGITEMTEMPLATEEX) + strlen(szClass)*2); | 
|---|
| 619 | dlgitem->cchClassName = strlen(szClass); | 
|---|
| 620 | dlgitem->offClassName = (USHORT)((int)dlgcurdata - (int)dlgt); | 
|---|
| 621 | strcpy((char *)dlgcurdata, szClass); | 
|---|
| 622 | //Open32 wants class name in upper case! | 
|---|
| 623 | strupr((char *)dlgcurdata); | 
|---|
| 624 | dlgcurdata           += dlgitem->cchClassName + 1;   //include terminating 0 (just to be sure) | 
|---|
| 625 | //TODO: SvL: Can they also be system classes? | 
|---|
| 626 | //    dlgitem->flStyle      = ctrldata->lStyle; | 
|---|
| 627 | dlgitem->flStyle      = ConvertDlgItemStyle(ctrldata->lStyle) ; | 
|---|
| 628 | FreeAsciiString(szClass); | 
|---|
| 629 | } | 
|---|
| 630 | if(*(USHORT *)szCaption == 0xFFFF) { | 
|---|
| 631 | szCaption += 2; | 
|---|
| 632 | } | 
|---|
| 633 | else {   //Handle Caption | 
|---|
| 634 | ctrltext = UnicodeToAsciiString(szCaption); | 
|---|
| 635 | //SvL: (16-9-'97) Convert '&' chars to '~' (for some classes) | 
|---|
| 636 | ConvertCaption(winclass, ctrltext); | 
|---|
| 637 | if(fIconBmp == TRUE) {//control contains bitmap or icon | 
|---|
| 638 | dlgitem->offText = (USHORT)((int)dlgcurdata - (int)dlgt); | 
|---|
| 639 | int resid =  ConvertNameId(NULL, ctrltext); | 
|---|
| 640 | *(char *)dlgcurdata = '#'; | 
|---|
| 641 | itoa(resid, (char *)dlgcurdata+1, 10); | 
|---|
| 642 | dlgitem->cchText = strlen((char *)dlgcurdata); //one USHORT for res id | 
|---|
| 643 | dlgcurdata      += dlgitem->cchText + 1; //include terminating 0 (just to be sure) | 
|---|
| 644 | } | 
|---|
| 645 | else { | 
|---|
| 646 | if(ctrltext[0] != 0) { | 
|---|
| 647 | dlgitem->cchText = strlen(ctrltext); | 
|---|
| 648 | dlgitem->offText = (USHORT)((int)dlgcurdata - (int)dlgt); | 
|---|
| 649 | strcpy((char *)dlgcurdata, ctrltext); | 
|---|
| 650 | dlgcurdata      += dlgitem->cchText + 1; //include terminating 0 (just to be sure) | 
|---|
| 651 | } else | 
|---|
| 652 | { //CB: cchText == 0, OS/2 uses offText anyway! (entryfields) | 
|---|
| 653 | dlgitem->offText = (USHORT)((int)dlgcurdata-(int)dlgt); | 
|---|
| 654 | dlgcurdata++; //0 at offText | 
|---|
| 655 | } | 
|---|
| 656 | } | 
|---|
| 657 | #ifdef DEBUG | 
|---|
| 658 | szClass = UnicodeToAsciiString(szCaption); | 
|---|
| 659 | WriteLog("Text                  : %s\n", szClass); | 
|---|
| 660 | FreeAsciiString(szClass); | 
|---|
| 661 | #endif | 
|---|
| 662 | szCaption = (WCHAR *)((int)szCaption + UniStrlen(szCaption)*2 + sizeof(WORD)); | 
|---|
| 663 | } | 
|---|
| 664 |  | 
|---|
| 665 | // cout << "Extra Stuff WORD      : " << *(WORD *)(szCaption) << endl; | 
|---|
| 666 | ctrldata = (WINDLGITEMTEMPLATEEX *)((int)szCaption + sizeof(WORD)); | 
|---|
| 667 | ctrldata = (WINDLGITEMTEMPLATEEX *)(((int)ctrldata+3) & ~3); | 
|---|
| 668 | dlgitem++; | 
|---|
| 669 | } | 
|---|
| 670 | //calculate dialog box length | 
|---|
| 671 | dlgt->cbTemplate = (USHORT)((int)dlgcurdata - (int)dlgt); | 
|---|
| 672 | return(dlgt); | 
|---|
| 673 | } | 
|---|
| 674 | //****************************************************************************** | 
|---|
| 675 | //****************************************************************************** | 
|---|
| 676 | static int ConvertClassAndStyle(int winclass, int style, USHORT *os2class, BOOL *fIconBmp) | 
|---|
| 677 | { | 
|---|
| 678 | int os2style = ConvertDlgItemStyle(style); | 
|---|
| 679 |  | 
|---|
| 680 | *fIconBmp = FALSE; | 
|---|
| 681 | style &= 0xFFFF; | 
|---|
| 682 |  | 
|---|
| 683 | switch(winclass) { | 
|---|
| 684 | case WIN_BUTTON: | 
|---|
| 685 | #if 0 | 
|---|
| 686 | if(style & WINBS_LEFTTEXT) | 
|---|
| 687 | os2style |= ; | 
|---|
| 688 | #endif | 
|---|
| 689 | style &= 0xF; | 
|---|
| 690 | //BS_TEXT, BS_BITMAP, BS_ICON, BS_MINIICON can only be used with BS_PUSHBUTTON | 
|---|
| 691 | *os2class = (int)WC_BUTTON & 0xFFFF; | 
|---|
| 692 | if(style == WINBS_PUSHBUTTON)        os2style |= BS_PUSHBUTTON; | 
|---|
| 693 | else | 
|---|
| 694 | if(style == WINBS_DEFPUSHBUTTON)     os2style |= (BS_PUSHBUTTON | BS_DEFAULT);   //TODO: Correct? | 
|---|
| 695 | else | 
|---|
| 696 | if(style == WINBS_CHECKBOX)          os2style |= BS_CHECKBOX; | 
|---|
| 697 | else | 
|---|
| 698 | if(style == WINBS_AUTOCHECKBOX)      os2style |= BS_AUTOCHECKBOX; | 
|---|
| 699 | else | 
|---|
| 700 | if(style == WINBS_RADIOBUTTON)       os2style |= BS_RADIOBUTTON; | 
|---|
| 701 | else | 
|---|
| 702 | if(style == WINBS_3STATE)            os2style |= BS_3STATE; | 
|---|
| 703 | else | 
|---|
| 704 | if(style == WINBS_AUTO3STATE)        os2style |= BS_AUTO3STATE; | 
|---|
| 705 | else | 
|---|
| 706 | if(style == WINBS_USERBUTTON)        os2style |= BS_USERBUTTON; //obsolete | 
|---|
| 707 | else | 
|---|
| 708 | if(style == WINBS_AUTORADIOBUTTON)   os2style |= BS_AUTORADIOBUTTON; | 
|---|
| 709 | else | 
|---|
| 710 | if(style == WINBS_GROUPBOX) | 
|---|
| 711 | { | 
|---|
| 712 | *os2class = (int)WC_STATIC & 0xFFFF;    /*PLF Sat  97-09-20 23:58:28*/ | 
|---|
| 713 | os2style  |= SS_GROUPBOX;   /*PLF Sun  97-09-21 00:11:07*/ | 
|---|
| 714 | } | 
|---|
| 715 | else | 
|---|
| 716 | if(style & WINBS_OWNERDRAW)          os2style |= BS_USERBUTTON;      //TODO:Correct?? | 
|---|
| 717 | else | 
|---|
| 718 | os2style |= (BS_TEXT | BS_PUSHBUTTON); | 
|---|
| 719 |  | 
|---|
| 720 | os2style |= BS_AUTOSIZE; | 
|---|
| 721 | break; | 
|---|
| 722 |  | 
|---|
| 723 | /*** | 
|---|
| 724 | * Edit Control | 
|---|
| 725 | ***/ | 
|---|
| 726 | case WIN_EDIT: | 
|---|
| 727 | if (style & WINES_MULTILINE) | 
|---|
| 728 | { | 
|---|
| 729 | *os2class = (int)WC_MLE & 0xFFFF; | 
|---|
| 730 | //    if(style & WINES_LEFT)        os2style |= ; | 
|---|
| 731 | //    if(style & WINES_CENTER)      os2style |= ; | 
|---|
| 732 | //    if(style & WINES_RIGHT)       os2style |= ; | 
|---|
| 733 | //    if(style & WINES_UPPERCASE)   os2style |= ; | 
|---|
| 734 | //    if(style & WINES_LOWERCASE)   os2style |= ; | 
|---|
| 735 | //    if(style & WINES_PASSWORD)    os2style |= ; | 
|---|
| 736 | if(style & WINES_AUTOVSCROLL) os2style |= MLS_VSCROLL; | 
|---|
| 737 | //    if(style & WINES_AUTOHSCROLL) os2style |= ; // @@@PH: experiment | 
|---|
| 738 | //    if(style & WINES_NOHIDESEL)   os2style |= ; | 
|---|
| 739 | //    if(style & WINES_OEMCONVERT)  os2style |= ; | 
|---|
| 740 | if(style & WINES_READONLY)    os2style |= MLS_READONLY; | 
|---|
| 741 | //        if(style & WINES_WANTRETURN)  os2style |= MLS_WANTRETURN; | 
|---|
| 742 | //    if(style & WINES_NUMBER)      os2style |= ; | 
|---|
| 743 | if(style & WINWS_BORDER)      os2style |= MLS_BORDER;   // @@@PH: experiment | 
|---|
| 744 | } | 
|---|
| 745 | else | 
|---|
| 746 | { | 
|---|
| 747 | *os2class = (int)WC_ENTRYFIELD & 0xFFFF; | 
|---|
| 748 | if(style & WINES_LEFT)        os2style |= ES_LEFT; | 
|---|
| 749 | if(style & WINES_CENTER)      os2style |= ES_CENTER; | 
|---|
| 750 | if(style & WINES_RIGHT)       os2style |= ES_RIGHT; | 
|---|
| 751 | //    if(style & WINES_UPPERCASE)   os2style |= ; | 
|---|
| 752 | //    if(style & WINES_LOWERCASE)   os2style |= ; | 
|---|
| 753 | if(style & WINES_PASSWORD)    os2style |= ES_UNREADABLE; | 
|---|
| 754 | //    if(style & WINES_AUTOVSCROLL) os2style |= ; | 
|---|
| 755 | if(style & WINES_AUTOHSCROLL) os2style |= ES_AUTOSCROLL; // @@@PH: experiment | 
|---|
| 756 | //    if(style & WINES_NOHIDESEL)   os2style |= ; | 
|---|
| 757 | //    if(style & WINES_OEMCONVERT)  os2style |= ; | 
|---|
| 758 | if(style & WINES_READONLY)    os2style |= ES_READONLY; | 
|---|
| 759 | //    if(style & WINES_WANTRETURN)  os2style |= ; | 
|---|
| 760 | //    if(style & WINES_NUMBER)      os2style |= ; | 
|---|
| 761 | //    if(style & WINWS_BORDER)      os2style |= ; | 
|---|
| 762 | } | 
|---|
| 763 | break; | 
|---|
| 764 |  | 
|---|
| 765 | case WIN_STATIC: | 
|---|
| 766 | *os2class = (int)WC_STATIC & 0xFFFF; | 
|---|
| 767 | if(style == WINSS_LEFT)                     os2style |= SS_TEXT | DT_LEFT; | 
|---|
| 768 | else | 
|---|
| 769 | if(style == WINSS_CENTER)                   os2style |= SS_TEXT | DT_CENTER; | 
|---|
| 770 | else | 
|---|
| 771 | if(style == WINSS_RIGHT)                    os2style |= SS_TEXT | DT_RIGHT; | 
|---|
| 772 | else | 
|---|
| 773 | if(style == WINSS_SIMPLE)                   os2style |= SS_TEXT | DT_LEFT; | 
|---|
| 774 | else | 
|---|
| 775 | if(style == WINSS_ICON) | 
|---|
| 776 | { | 
|---|
| 777 | os2style |= SS_ICON; | 
|---|
| 778 | *fIconBmp = TRUE; | 
|---|
| 779 | } | 
|---|
| 780 | else | 
|---|
| 781 | if(style == WINSS_BLACKRECT)               os2style |= SS_FGNDRECT; | 
|---|
| 782 | else | 
|---|
| 783 | if(style == WINSS_GRAYRECT)                os2style |= SS_HALFTONERECT; | 
|---|
| 784 | else | 
|---|
| 785 | if(style == WINSS_WHITERECT)               os2style |= SS_BKGNDRECT; | 
|---|
| 786 | else | 
|---|
| 787 | if(style == WINSS_BLACKFRAME)              os2style |= SS_FGNDFRAME; | 
|---|
| 788 | else | 
|---|
| 789 | if(style == WINSS_GRAYFRAME)               os2style |= SS_HALFTONEFRAME; | 
|---|
| 790 | else | 
|---|
| 791 | if(style == WINSS_WHITEFRAME)              os2style |= SS_BKGNDFRAME; | 
|---|
| 792 | else  os2style |= SS_TEXT; | 
|---|
| 793 |  | 
|---|
| 794 | //TODO | 
|---|
| 795 | //    if(style == WINSS_LEFTNOWORDWRAP)          os2style |= ; | 
|---|
| 796 | //    if(style == WINSS_USERITEM)                os2style |= ; | 
|---|
| 797 | //    if(style == WINSS_NOPREFIX)                os2style |= ; | 
|---|
| 798 | break; | 
|---|
| 799 |  | 
|---|
| 800 | case WIN_LISTBOX: | 
|---|
| 801 | *os2class = (int)WC_LISTBOX & 0xFFFF; | 
|---|
| 802 | if(style & WINLBS_NOTIFY)                  os2style |= LS_NOTIFY; | 
|---|
| 803 | //    if(style & WINLBS_SORT)                    os2style |= ; | 
|---|
| 804 | //    if(style & WINLBS_NOREDRAW)                os2style |= ; | 
|---|
| 805 | if(style & WINLBS_MULTIPLESEL)             os2style |= LS_MULTIPLESEL; | 
|---|
| 806 | if(style & WINLBS_OWNERDRAWFIXED)          os2style |= LS_OWNERDRAW;       //TODO: Correct? | 
|---|
| 807 | if(style & WINLBS_OWNERDRAWVARIABLE)       os2style |= LS_OWNERDRAWVARIABLE;       //TODO: Correct? | 
|---|
| 808 | if(style & WINLBS_HASSTRINGS)              os2style &= ~LS_NOSTRINGS; | 
|---|
| 809 | else                                       os2style |= LS_NOSTRINGS; | 
|---|
| 810 | if(style & WINLBS_USETABSTOPS)             os2style |= LS_TABSTOPS; | 
|---|
| 811 | //    if(style & WINLBS_NOINTEGRALHEIGHT)        os2style |= ; | 
|---|
| 812 | //    if(style & WINLBS_MULTICOLUMN)             os2style |= ; | 
|---|
| 813 | //    if(style & WINLBS_WANTKEYBOARDINPUT)       os2style |= ; | 
|---|
| 814 | if(style & WINLBS_EXTENDEDSEL)             os2style |= LS_EXTENDEDSEL; | 
|---|
| 815 | //    if(style & WINLBS_DISABLENOSCROLL)         os2style |= ; | 
|---|
| 816 | //    if(style & WINLBS_NODATA)                  os2style |= ; | 
|---|
| 817 | break; | 
|---|
| 818 |  | 
|---|
| 819 | case WIN_SCROLLBAR: | 
|---|
| 820 | *os2class = (int)WC_SCROLLBAR & 0xFFFF; | 
|---|
| 821 | if(style & WINSBS_HORZ)                    os2style |= SBS_HORZ; | 
|---|
| 822 | else | 
|---|
| 823 | if(style & WINSBS_VERT)                    os2style |= SBS_VERT; | 
|---|
| 824 |  | 
|---|
| 825 | //    if(style & WINSBS_TOPALIGN)                os2style |= ; | 
|---|
| 826 | //    if(style & WINSBS_LEFTALIGN)               os2style |= ; | 
|---|
| 827 | //    if(style & WINSBS_BOTTOMALIGN)             os2style |= ; | 
|---|
| 828 | //    if(style & WINSBS_RIGHTALIGN)              os2style |= ; | 
|---|
| 829 | //    if(style & WINSBS_SIZEBOXTOPLEFTALIGN)     os2style |= ; | 
|---|
| 830 | //    if(style & WINSBS_SIZEBOXBOTTOMRIGHTALIGN) os2style |= ; | 
|---|
| 831 | if(style & WINSBS_SIZEBOX)                 os2style |= SBS_AUTOSIZE;       //TODO: Correct? | 
|---|
| 832 | break; | 
|---|
| 833 |  | 
|---|
| 834 | case WIN_COMBOBOX: | 
|---|
| 835 | *os2class = (int)WC_COMBOBOX & 0xFFFF; | 
|---|
| 836 | if(style & WINCBS_SIMPLE)                  os2style |= CBS_SIMPLE; | 
|---|
| 837 | else | 
|---|
| 838 | if(style & WINCBS_DROPDOWN)                os2style |= CBS_DROPDOWN; | 
|---|
| 839 | else | 
|---|
| 840 | if(style & WINCBS_DROPDOWNLIST)            os2style |= CBS_DROPDOWNLIST; | 
|---|
| 841 |  | 
|---|
| 842 | if(style & WINCBS_OWNERDRAWFIXED)          os2style |= CBS_OWNERDRAW; | 
|---|
| 843 | if(style & WINCBS_OWNERDRAWVARIABLE)       os2style |= CBS_OWNERDRAWVARIABLE; | 
|---|
| 844 | //    if(style & WINCBS_AUTOHSCROLL)             os2style |= ; | 
|---|
| 845 | //    if(style & WINCBS_OEMCONVERT)              os2style |= ; | 
|---|
| 846 | //    if(style & WINCBS_SORT)                    os2style |= ; | 
|---|
| 847 | if(style & WINCBS_HASSTRINGS)              os2style &= ~CBS_NOSTRINGS; | 
|---|
| 848 | else                                       os2style |= CBS_NOSTRINGS; | 
|---|
| 849 | //    if(style & WINCBS_NOINTEGRALHEIGHT)        os2style |= ; | 
|---|
| 850 | //    if(style & WINCBS_DISABLENOSCROLL)         os2style |= ; | 
|---|
| 851 | break; | 
|---|
| 852 |  | 
|---|
| 853 | default: | 
|---|
| 854 | //SvL:9nov97 Special class control. Just copy style | 
|---|
| 855 | os2style = style; | 
|---|
| 856 | break; | 
|---|
| 857 | } | 
|---|
| 858 | return(os2style); | 
|---|
| 859 | } | 
|---|
| 860 | //****************************************************************************** | 
|---|
| 861 | //****************************************************************************** | 
|---|
| 862 | static int ConvertDlgStyle(int style) | 
|---|
| 863 | { | 
|---|
| 864 | int os2style = 0; | 
|---|
| 865 |  | 
|---|
| 866 | ///  if(style & WINWS_POPUP)     os2style |= | 
|---|
| 867 | ///  if(style & WINWS_CHILD)     os2style |= | 
|---|
| 868 | if(style & WINWS_MINIMIZE)     os2style |= WS_MINIMIZED; | 
|---|
| 869 | if(style & WINWS_MAXIMIZE)     os2style |= WS_MAXIMIZED; | 
|---|
| 870 | if(style & WINWS_VISIBLE)      os2style |= WS_VISIBLE; | 
|---|
| 871 | if(style & WINWS_DISABLED)     os2style |= WS_DISABLED; | 
|---|
| 872 | if(style & WINWS_CLIPSIBLINGS) os2style |= WS_CLIPSIBLINGS; | 
|---|
| 873 | if(style & WINWS_CLIPCHILDREN) os2style |= WS_CLIPCHILDREN; | 
|---|
| 874 | if(style & WINWS_TABSTOP)      os2style |= WS_TABSTOP; | 
|---|
| 875 |  | 
|---|
| 876 | return(os2style); | 
|---|
| 877 | } | 
|---|
| 878 | //****************************************************************************** | 
|---|
| 879 | //****************************************************************************** | 
|---|
| 880 | static int ConvertDlgItemStyle(int style) | 
|---|
| 881 | { | 
|---|
| 882 | int os2style = 0; | 
|---|
| 883 |  | 
|---|
| 884 | if(style & WINWS_VISIBLE)      os2style |= WS_VISIBLE; | 
|---|
| 885 | if(style & WINWS_DISABLED)     os2style |= WS_DISABLED; | 
|---|
| 886 | if(style & WINWS_CLIPSIBLINGS) os2style |= WS_CLIPSIBLINGS; | 
|---|
| 887 | if(style & WINWS_CLIPCHILDREN) os2style |= WS_CLIPCHILDREN; | 
|---|
| 888 | if(style & WINWS_TABSTOP)      os2style |= WS_TABSTOP; | 
|---|
| 889 | if(style & WINWS_GROUP)        os2style |= WS_GROUP; | 
|---|
| 890 |  | 
|---|
| 891 | return(os2style); | 
|---|
| 892 | } | 
|---|
| 893 | //****************************************************************************** | 
|---|
| 894 | //****************************************************************************** | 
|---|
| 895 | static void ConvertCaption(ULONG style, char *caption) | 
|---|
| 896 | { | 
|---|
| 897 | char os2caption[512]; | 
|---|
| 898 | int i, len = strlen(caption), j; | 
|---|
| 899 |  | 
|---|
| 900 | switch(style) | 
|---|
| 901 | { | 
|---|
| 902 | case WIN_BUTTON: | 
|---|
| 903 | case WIN_EDIT: | 
|---|
| 904 | case WIN_LISTBOX: | 
|---|
| 905 | case WIN_SCROLLBAR: | 
|---|
| 906 | case WIN_COMBOBOX: | 
|---|
| 907 | for(i=0; | 
|---|
| 908 | i<len; | 
|---|
| 909 | i++) | 
|---|
| 910 | { | 
|---|
| 911 | if(caption[i] == '&') | 
|---|
| 912 | caption[i] = '~'; | 
|---|
| 913 | } | 
|---|
| 914 | break; | 
|---|
| 915 |  | 
|---|
| 916 | case WIN_STATIC: | 
|---|
| 917 | // @@@PH: what to do if MNEMONIC style ? | 
|---|
| 918 | j = 0; | 
|---|
| 919 | for(i=0;i<=len;i++) | 
|---|
| 920 | { | 
|---|
| 921 | if(caption[i] != '&') | 
|---|
| 922 | os2caption[j++] = caption[i]; | 
|---|
| 923 | } | 
|---|
| 924 | strcpy(caption, os2caption); | 
|---|
| 925 | break; | 
|---|
| 926 | } | 
|---|
| 927 | } | 
|---|
| 928 | //****************************************************************************** | 
|---|
| 929 | //****************************************************************************** | 
|---|
| 930 | static int ConvertFont(char *font, PRESPARAMS *dlgpparam, int fsize) | 
|---|
| 931 | { | 
|---|
| 932 | char fontsize[16]; | 
|---|
| 933 |  | 
|---|
| 934 | if(strcmp(font, "MS SHELL DLG") == 0) { | 
|---|
| 935 | strcpy(dlgpparam->aparam[0].ab, "System VIO"); | 
|---|
| 936 | dlgpparam->aparam[0].cb = sizeof("System VIO"); | 
|---|
| 937 | sprintf(fontsize, ".%d", fsize); | 
|---|
| 938 | strcat(dlgpparam->aparam[0].ab, fontsize); | 
|---|
| 939 | return(TRUE); | 
|---|
| 940 | } | 
|---|
| 941 | //  else TODO: More fonts!!! | 
|---|
| 942 | return(FALSE);  //not found | 
|---|
| 943 | } | 
|---|
| 944 | //****************************************************************************** | 
|---|
| 945 | //****************************************************************************** | 
|---|