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