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