Diff for /np2/macosx/dialog/dialog.cpp between versions 1.4 and 1.7

version 1.4, 2003/11/08 17:54:27 version 1.7, 2004/01/23 17:37:39
Line 1 Line 1
 #include        "compiler.h"  #include        "compiler.h"
 #include        "resource.h"  #include        "resource.h"
 #include        "sysmng.h"  #include        "sysmng.h"
 #include        "dialog.h"  
 #include        "pccore.h"  #include        "pccore.h"
 #include        "fddfile.h"  #include        "dialog.h"
 #include        "diskdrv.h"  #include        "diskdrv.h"
 #if 0  
 #include        "newdisk.h"  
 #endif  
 #include        "font.h"  #include        "font.h"
 #include        "iocore.h"  #include        "iocore.h"
 #include        "np2.h"  #include        "np2.h"
Line 19 Line 15
 #include        "fdefine.h"  #include        "fdefine.h"
 #include        "toolwin.h"  #include        "toolwin.h"
   
 static Handle GetDlgItem(DialogPtr hWnd, short pos) {  
   
         Handle  ret;  
         Rect    rct;  
         short   s;  
   
         GetDialogItem(hWnd, pos, &s, &ret, &rct);  
         return(ret);  
 }  
   
 void AboutDialogProc(void) {  
   
         DialogPtr       hDlg;  
         Str255          verstr;  
         int                     done;  
         short           item;  
   
         hDlg = GetNewDialog(IDD_ABOUT, NULL, (WindowPtr)-1);  
         if (!hDlg) {  
                 return;  
         }  
         mkstr255(verstr, np2version);  
         SetDialogItemText(GetDlgItem(hDlg, IDD_VERSION), verstr);  
         SetDialogDefaultItem(hDlg, IDOK);  
   
         done = 0;  
         while(!done) {  
                 ModalDialog(NULL, &item);  
                 switch(item) {  
                         case IDOK:  
                                 done = 1;  
                                 break;  
                 }  
         }  
         DisposeDialog(hDlg);  
 }  
   
   
 // ----  // ----
   
 static const BYTE pathsep[2] = {0x01, ':'};  static const BYTE pathsep[2] = {0x01, ':'};
Line 130  static pascal void dummyproc(NavEventCal Line 88  static pascal void dummyproc(NavEventCal
         (void)ud;          (void)ud;
 }  }
   
 BOOL dialog_fileselect(char *name, int size, WindowRef parent) {  static pascal Boolean NavLaunchServicesFilterProc( AEDesc* theItem, void* info, NavCallBackUserData ioUserData, NavFilterModes filterMode)
   {
           #pragma unused( info )
           OSStatus        err                     = noErr;
           Boolean         showItem        = false;
       FSSpec              fsSpec;
       int                 ret;
       char                name[MAX_PATH];
           AEDesc          coerceDesc      = { NULL, NULL };
                   
           if ( filterMode == kNavFilteringBrowserList ) {
                   if ( theItem->descriptorType != typeFSS ) {
                           err = AECoerceDesc( theItem, typeFSS, &coerceDesc );
                           theItem = &coerceDesc;
                   }
                   if ( err == noErr ) {
                           err = AEGetDescData( theItem, &fsSpec, sizeof(fsSpec) );
           }
                   AEDisposeDesc( &coerceDesc );
           
           if (err == noErr) {
               fsspec2path(&fsSpec, name, MAX_PATH);
               if (file_attr(name) == FILEATTR_DIRECTORY) {
                   showItem = true;
               }
               else {
                   ret = file_getftype(name);
                   switch (*(int*)ioUserData) {
                       case OPEN_FDD:
                           if (ret == FTYPE_D88 || ret == FTYPE_BETA) {
                               showItem = true;
                           }
                           break;
                       case OPEN_SASI:
                           if (ret == FTYPE_THD || ret == FTYPE_HDI) {
                               showItem = true;
                           }
                           break;
                        case OPEN_SCSI:
                           if (ret == FTYPE_HDD) {
                               showItem = true;
                           }
                           break;
                      case OPEN_FONT:
                           if (ret == FTYPE_BMP || ret == FTYPE_SMIL) {
                               showItem = true;
                           }
                           break;
                       case OPEN_INI:
                           if (ret == FTYPE_INI) {
                               showItem = true;
                           }
                           break;
                   }
               }
           }
           }
           return( showItem );
   }
   
   BOOL dialog_fileselect(char *name, int size, WindowRef parent, int opentype) {
   
         BOOL                            ret;          BOOL                            ret;
         OSErr                           err;          OSErr                           err;
Line 140  BOOL dialog_fileselect(char *name, int s Line 158  BOOL dialog_fileselect(char *name, int s
         long                            count;          long                            count;
         long                            i;          long                            i;
         FSSpec                          fss;          FSSpec                          fss;
       NavObjectFilterUPP  navFilterProc;
   
         ret = FALSE;          ret = FALSE;
     NavGetDefaultDialogCreationOptions(&optNav);      NavGetDefaultDialogCreationOptions(&optNav);
       optNav.clientName = CFSTR("Neko Project IIx");
     optNav.modality=kWindowModalityWindowModal;      optNav.modality=kWindowModalityWindowModal;
     optNav.parentWindow=parent;      optNav.parentWindow=parent;
     optNav.optionFlags+=kNavNoTypePopup;      switch (opentype) {
           case OPEN_FONT:
               optNav.message = CFCopyLocalizedString(CFSTR("Choose font file."),"FontSelect Message");
               break;
           case OPEN_INI:
               optNav.message = CFCopyLocalizedString(CFSTR("Choose a skin file for Tool Window."),"SkinSelect Message");
               break;
           default:
               break;
       }
         proc = NewNavEventUPP(dummyproc);          proc = NewNavEventUPP(dummyproc);
     ret=NavCreateChooseFileDialog(&optNav,NULL,proc,NULL,NULL,NULL,&navWin);      navFilterProc = NewNavObjectFilterUPP( NavLaunchServicesFilterProc );
       ret=NavCreateGetFileDialog(&optNav,NULL,proc,NULL,navFilterProc,&opentype,&navWin);
     NavDialogRun(navWin);      NavDialogRun(navWin);
     RunAppModalLoopForWindow(NavDialogGetWindow(navWin));      RunAppModalLoopForWindow(NavDialogGetWindow(navWin));
     NavDialogGetReply(navWin, &reply);      NavDialogGetReply(navWin, &reply);
       if (optNav.message) CFRelease(optNav.message);
     NavDialogDispose(navWin);      NavDialogDispose(navWin);
         DisposeNavEventUPP(proc);          DisposeNavEventUPP(proc);
           
Line 192  BOOL dialog_filewriteselect(OSType type, Line 223  BOOL dialog_filewriteselect(OSType type,
   
         InitCursor();          InitCursor();
     NavGetDefaultDialogCreationOptions(&copt);      NavGetDefaultDialogCreationOptions(&copt);
       copt.clientName = CFSTR("Neko Project IIx");
     copt.parentWindow = parentWindow;      copt.parentWindow = parentWindow;
     copt.saveFileName = CFStringCreateWithCString(NULL, title, CFStringGetSystemEncoding());      copt.saveFileName = CFStringCreateWithCString(NULL, title, CFStringGetSystemEncoding());
     copt.optionFlags += kNavNoTypePopup;      copt.optionFlags += kNavPreserveSaveFileExtension;
     copt.modality = kWindowModalityWindowModal;      copt.modality = kWindowModalityWindowModal;
       switch (type) {
           case 'AIFF':
               copt.message = CFCopyLocalizedString(CFSTR("Record playing sound as AIFF file."),"SoundRecord Message");
               break;
           case 'BMP ':
               copt.message = CFCopyLocalizedString(CFSTR("Save the screen as BMP file."),"ScreenShot Message");
               break;
           case '.S98':
               copt.message = CFCopyLocalizedString(CFSTR("Log playing sound as S98 file."),"S98Log Message");
               break;
           default:
               break;
       }
         eventUPP=NewNavEventUPP( dummyproc );          eventUPP=NewNavEventUPP( dummyproc );
     NavCreatePutFileDialog(&copt, type, sign, eventUPP, NULL, &navWin);      NavCreatePutFileDialog(&copt, type, sign, eventUPP, NULL, &navWin);
           
Line 229  void dialog_changefdd(BYTE drv) { Line 274  void dialog_changefdd(BYTE drv) {
         char    fname[MAX_PATH];          char    fname[MAX_PATH];
   
         if (drv < 4) {          if (drv < 4) {
                 if (dialog_fileselect(fname, sizeof(fname), hWndMain)) {                  if (dialog_fileselect(fname, sizeof(fname), hWndMain, OPEN_FDD)) {
             if (file_getftype(fname)==FTYPE_D88 || file_getftype(fname)==FTYPE_BETA) {              if (file_getftype(fname)==FTYPE_D88 || file_getftype(fname)==FTYPE_BETA) {
                 diskdrv_setfdd(drv, fname, 0);                  diskdrv_setfdd(drv, fname, 0);
                 toolwin_setfdd(drv, fname);                  toolwin_setfdd(drv, fname);
Line 242  void dialog_changehdd(BYTE drv) { Line 287  void dialog_changehdd(BYTE drv) {
   
         char    fname[MAX_PATH];          char    fname[MAX_PATH];
   
         if (drv < 2) {          if (!(drv & 0x20)) {            // SASI/IDE
                 if (dialog_fileselect(fname, sizeof(fname), hWndMain)) {                  if (drv < 2) {
             if (file_getftype(fname)==FTYPE_HDI || file_getftype(fname)==FTYPE_THD) {                          if (dialog_fileselect(fname, sizeof(fname), hWndMain, OPEN_SASI)) {
                 diskdrv_sethdd(drv, fname);                                  if (file_getftype(fname)==FTYPE_HDI || file_getftype(fname)==FTYPE_THD) {
             }                                          sysmng_update(SYS_UPDATEOSCFG);
                                           diskdrv_sethdd(drv, fname);
                                   }
                           }
                   }
           }
           else {                                          // SCSI
                   if ((drv & 0x0f) < 4) {
                           if (dialog_fileselect(fname, sizeof(fname), hWndMain, OPEN_SCSI)) {
                                   if (file_getftype(fname)==FTYPE_HDD) {
                                           sysmng_update(SYS_UPDATEOSCFG);
                                           diskdrv_sethdd(drv, fname);
                                   }
                           }
                 }                  }
         }          }
 }  }
Line 256  void dialog_font(void) { Line 314  void dialog_font(void) {
   
     char        name[1024];      char        name[1024];
   
         if (dialog_fileselect(name, 1024, hWndMain)) {          if (dialog_fileselect(name, sizeof(name), hWndMain, OPEN_FONT)) {
         if ((name != NULL) && (font_load(name, FALSE))) {          if ((name != NULL) && (font_load(name, FALSE))) {
             gdcs.textdisp |= GDCSCRN_ALLDRAW2;              gdcs.textdisp |= GDCSCRN_ALLDRAW2;
             milstr_ncpy(np2cfg.fontfile, name, sizeof(np2cfg.fontfile));              milstr_ncpy(np2cfg.fontfile, name, sizeof(np2cfg.fontfile));
Line 274  void dialog_writebmp(void) { Line 332  void dialog_writebmp(void) {
   
         bmp = scrnbmp();          bmp = scrnbmp();
         if (bmp) {          if (bmp) {
                 if (dialog_filewriteselect('BMP ', "np2.bmp", &fss, hWndMain)) {                  if (dialog_filewriteselect('BMP ', "Neko Project IIx ScreenShot.bmp", &fss, hWndMain)) {
             fsspec2path(&fss, path, MAX_PATH);              fsspec2path(&fss, path, MAX_PATH);
                         fh = file_create(path);                          fh = file_create(path);
                         if (fh != FILEH_INVALID) {                          if (fh != FILEH_INVALID) {

Removed from v.1.4  
changed lines
  Added in v.1.7


RetroPC.NET-CVS <cvs@retropc.net>