GPS4Palm

Source Code Documentation


FileselForm.c

Go to the documentation of this file.
00001 /*****************************************************************************
00002  *
00003  * $RCSfile: FileselForm_8c-source.html,v $
00004  *
00005  * GPS4Palm File Selector Form
00006  *   - search for map data bases and create directory data bases
00007  *   - show image files in table 
00008  *   - implement table scrolling, panning, and selection
00009  *   - implement file delete operation
00010  *
00011  * created: 2002-12-15
00012  *
00013  * History:
00014  * 2002-12-15:  first version
00015  * 2002-12-30:  added delete function, added Help->About Menu
00016  *
00017  * This program is Copyright (C) 12/2002 Matthias Prinke
00018  * <matthias.prinke@surfeu.de> and covered by GNU's GPL.
00019  * In particular, this program is free software and comes WITHOUT
00020  * ANY WARRANTY.
00021  *
00022  * $Author: mp $
00023  *
00024  * $Date: 2007-10-08 20:40:32 $
00025  *
00026  * $Revision: 1.7.2.1 $
00027  *
00028  * $Log: FileselForm_8c-source.html,v $
00028  * Revision 1.7.2.1  2007-10-08 20:40:32  mp
00028  * updated for gps4palm V0.9.5 beta
00028  *
00029  * Revision 1.18  2005-05-16 09:57:17  mp
00030  * added display of size, date, and dimension of selected map on frmOpenEvent
00031  *
00032  * Revision 1.17  2005/05/14 11:40:18  mp
00033  * fixed bug in FileSelDeleteButton event handling
00034  *
00035  * Revision 1.16  2005/05/14 11:35:36  mp
00036  * added image dimensions display
00037  *
00038  * Revision 1.15  2005/05/13 18:33:10  mp
00039  * modified filename/filecard variable usage
00040  *
00041  * Revision 1.14  2005/02/26 14:52:59  mp
00042  * added map file deletion,
00043  * fixed table selection highlighting for some OS versions
00044  *
00045  * Revision 1.13  2005/02/25 18:40:34  mp
00046  * replaced gCardNo by gPrefs.filecard
00047  *
00048  * Revision 1.12  2005/02/19 20:05:21  mp
00049  * changed filename[32] to filename[FILENAMEMAXLEN]
00050  *
00051  * Revision 1.11  2005/02/19 14:36:50  mp
00052  * moved VFS Feature Set check to GPS.c
00053  *
00054  * Revision 1.10  2005/02/19 14:00:58  mp
00055  * added display of file creation date
00056  *
00057  * Revision 1.9  2005/02/19 12:18:32  mp
00058  * added VFS support and file size display, removed unused code
00059  *
00060  * Revision 1.8  2004/11/24 21:07:47  mp
00061  * moved static function declarations from header to implementation file
00062  *
00063  * Revision 1.7  2004/11/23 17:53:39  mp
00064  * commented out unused variables
00065  *
00066  * Revision 1.6  2004/04/30 16:32:01  mp
00067  * replaced dopage()/doscroll() by common functions in Util.c
00068  *
00069  * Revision 1.5  2004/03/20 11:18:38  mp
00070  * changed scope of gTopRow
00071  *
00072  * Revision 1.4  2003/12/01 20:11:03  mp
00073  * removed old code, added AUTO button, USER/AUTO map selection
00074  *
00075  * Revision 1.3  2003/11/23 19:53:55  mp
00076  * moved CreateDatabase and DestroyDatabase to getdir.c
00077  *
00078  * Revision 1.2  2003/10/19 17:04:34  mp
00079  * removed/commented out table column <size>
00080  *
00081  * Revision 1.1  2003/10/18 16:29:39  mp
00082  * imported from piv, disabled Help->About and File->Delete functions
00083  *
00084  *
00085  ****************************************************************************/
00086 
00087 #define DO_NOT_ALLOW_ACCESS_TO_INTERNALS_OF_STRUCTS
00088 #include <BuildDefines.h>
00089 #ifdef DEBUG_BUILD
00090 #define ERROR_CHECK_LEVEL ERROR_CHECK_FULL
00091 #endif
00092 #include <PalmOS.h>
00093 #include "ResourceDefines.h"
00094 #include <Extensions/ExpansionMgr/VFSMgr.h>
00095 #include "stringil.h"
00096 #include "FileselForm.h"
00097 #include "file_io.h"
00098 #include "getdir.h"
00099 #include "imginfo.h"
00100 #include "Utils.h"
00101 #include "common.h"
00102 
00103 #define SORTPREFIX 4
00104 
00105 /** Name of selected file (passed to/from FileselForm) */
00106 #define SEL_FILENAME    gPrefs.filename
00107 
00108 /** Card/Volume of selected file (passed to/from FileselForm) */
00109 #define SEL_FILECARD    gPrefs.filecard
00110 
00111 /* Global Variables */
00112 extern PrefsType        gPrefs;                 /* application preferences */
00113 extern Boolean          gVfsManagerFtr;         /* VFS Feature Set available */
00114 extern Boolean          gFtrSet35;              /* 3.5 Feature Set available */
00115 
00116 /* Static Variables */
00117 static Boolean          vfs_flag[10];           /* one entry per visible row */
00118 
00119 /* Static Functions */
00120 static void FileSelFormInit(FormPtr frmP)               FILESEL_SECTION;
00121 static void FileSelFormDeinit(FormPtr frmP)             FILESEL_SECTION;
00122 static void TableDrawCell(void *tblP, Int16 row,
00123   Int16 column, RectangleType *bounds)                  FILESEL_SECTION;
00124 static void DrawTable(UInt16 files, char **filelp,
00125                       char *filecard,Int32 top,
00126                       UInt16 *sel)                      FILESEL_SECTION;
00127 static UInt32 GetFileCreationDate(const char *name,
00128   UInt32 card)                                          FILESEL_SECTION;
00129 static Err DeleteMap(const char *name,
00130   UInt32 card)                                          FILESEL_SECTION;
00131 
00132 static void FileSelFormInit(FormPtr frmP)
00133 {
00134 #pragma unused(frmP)
00135   // warning-- don't do any drawing in this routine.
00136   // Also, don't call FrmSetFocus from here (it must be called *after*
00137   // FrmDrawForm)
00138 }
00139 
00140 static void FileSelFormDeinit(FormPtr frmP)
00141 {
00142 #pragma unused(frmP)
00143 }
00144 
00145 
00146 /*
00147  * TableDrawCell:
00148  *   Custom table cell drawing function.
00149  *   The function's prototype is defined by PalmOS
00150  *   (TableDrawItemFuncType). 
00151  */
00152 TableDrawItemFuncType TableDrawCell;
00153 
00154 
00155 /**********************************************************************/
00156 /**
00157  * \brief       File table cell drawing function
00158  *
00159  * \note        The function's prototype is defined by PalmOS
00160  *              (TableDrawItemFuncType).
00161  *
00162  * \note        On PalmOS 5.2.1 and 3.5.0 (and maybe others) the selected
00163  *              row has to be highlighted manually.
00164  *
00165  ***********************************************************************/
00166 static void TableDrawCell(void *tblP, Int16 row, Int16 column,
00167                    RectangleType *bounds)
00168 {
00169   Char          *c;             /* filename */
00170   Char          **filelp;       /* pointer to filelist entry */
00171   Int16         sel_row;        /* selected table row */
00172   Int16         sel_col;        /* selected table column */
00173 
00174   filelp = (Char **)TblGetRowData(tblP, row);
00175   
00176   
00177   if (column == 0) {
00178     c = *filelp + SORTPREFIX;
00179     WinEraseRectangle(bounds, 0);
00180     
00181     TblGetSelection(tblP, &sel_row, &sel_col);
00182     if (row == sel_row) {
00183       /* Highlight selected row */
00184       if (gFtrSet35) {
00185         WinPushDrawState();
00186         WinSetBackColor(UIColorGetTableEntryIndex(UIObjectSelectedFill));
00187         WinSetTextColor(UIColorGetTableEntryIndex(UIObjectSelectedForeground));
00188         WinSetForeColor(UIColorGetTableEntryIndex(UIObjectSelectedForeground));
00189         WinFillRectangle(bounds, 0);
00190         WinPaintChars(c, strlen(c), bounds->topLeft.x + 1, bounds->topLeft.y);
00191       } else {
00192         WinDrawChars(c, strlen(c),
00193           bounds->topLeft.x + 1, bounds->topLeft.y);
00194       }
00195     } else {
00196       WinDrawChars(c, strlen(c), bounds->topLeft.x + 1, bounds->topLeft.y);
00197     }
00198     
00199     /* draw card icon if file is located on card */
00200     if (vfs_flag[row]) {
00201       WinDrawChar(chrCardIcon, bounds->extent.x + 1 -
00202         FntCharWidth(chrCardIcon), bounds->topLeft.y);
00203     }
00204   }
00205   
00206   if (gFtrSet35)
00207     WinPopDrawState();
00208   
00209 }
00210 
00211 
00212 /**********************************************************************/
00213 /**
00214  * \brief       File table drawing function
00215  *
00216  * \param       files           number of available files
00217  * \param       filelp          array of pointers to filelist entries
00218  * \param       filecard        file stream cards/VFS volumes per file
00219  * \param       top             top table row
00220  * \param       sel             selected table row
00221  *
00222  ***********************************************************************/
00223 static void DrawTable(UInt16 files, char **filelp, char *filecard, 
00224                       Int32 top, UInt16 *sel)
00225 {
00226   TablePtr      tblP;                   /* table ptr */
00227   FormPtr       frmP;                   /* form ptr */
00228   ScrollBarPtr  sclP;                   /* scrollbar ptr */
00229   UInt16        row;                    /* table row counter */
00230   UInt16        numRows;                /* number of rows */
00231   UInt32        card;                   /* card / volume no. and FS/VFS flag */  
00232   
00233   frmP = FrmGetActiveForm();
00234   tblP = FrmGetObjectPtr(frmP, FrmGetObjectIndex(frmP, FileSelTable));
00235   numRows = TblGetNumberOfRows(tblP);
00236 
00237   /* set column usable */
00238   TblSetColumnUsable(tblP, 0, true);
00239   
00240   for (row = 0; row < numRows; row++) {
00241     
00242     /* set row data to filelp entries */
00243     if (row + top < files) {
00244       TblSetRowData(tblP, row, (UInt32)(filelp + top + row));
00245 
00246       /* set all rows selectable */
00247       TblSetRowSelectable(tblP, row, true);
00248       
00249       /* set column to custom style, set custom cell drawing function */
00250       TblSetItemStyle(tblP, row, 0, customTableItem);  
00251       TblSetCustomDrawProcedure(tblP, 0, TableDrawCell);
00252       
00253       /* set vfs_flag-array for TableDrawCell() */
00254       memcpy(&card, &filecard[(top+row)*4], 4);
00255       vfs_flag[row] = (card & VFS_FLAG) ? true : false;
00256       
00257       /* mark all rows as invalid to trigger table update by FrmDrawForm() */
00258       TblMarkRowInvalid(tblP, row);
00259     } else {
00260       /* rows empty, mark as not usable */
00261       TblSetRowUsable(tblP, row, false);
00262     }
00263 
00264   }
00265 
00266   sclP = FrmGetObjectPtr(frmP, FrmGetObjectIndex(frmP, FileSelScrl));
00267 
00268   /* set scrollbar: value, min, max, pagesize */
00269   if (files <= numRows) {
00270     SclSetScrollBar(sclP, 0, 0, 0, numRows);
00271   } else {
00272     SclSetScrollBar(sclP, top, 0, files - numRows, numRows);
00273   }
00274 
00275   
00276   /*
00277    * Selected item scrolled below visible table rows,
00278    *   selection is switched to last visible entry.
00279    */
00280   if ( *sel > (top + numRows - 1) ) {
00281     *sel = top + numRows - 1;
00282   }
00283 
00284   /*
00285    * Selected item scrolled above visible table rows,
00286    *   selection is switched to first visible entry.
00287    */  
00288   if (*sel < top) {
00289     *sel = top;
00290   }
00291   
00292   for (row = 0; row < numRows; row++, top++) {
00293     if ((top < files) && (top == *sel)) {
00294       TblSelectItem(tblP, row, 0);
00295       break;
00296     }
00297   }
00298 
00299   FrmDrawForm(frmP);
00300 }
00301 
00302 
00303 /**********************************************************************/
00304 /**
00305  * \brief       Get file creation date (File Stream or VFS File)
00306  *
00307  * \param       name            pointer to filename
00308  * \param       card            File Stream card or VFS volume,
00309  *                              MSB: VFS-Flag
00310  *
00311  * \return      File creation date (seconds)
00312  ***********************************************************************/
00313 static UInt32 GetFileCreationDate(const char *name, UInt32 card)
00314 {
00315   Err           err = 0;        /* error code */
00316   MemPtr        pathNameP;      /* ptr to path name */
00317   FileRef       fileRef;        /* file reference */
00318   LocalID       lid;            /* local database ID */
00319   UInt32        date;           /* date */
00320   
00321   if (card & VFS_FLAG) {
00322     card &= ~VFS_FLAG;
00323     pathNameP = MemPtrNew(sizeof(FILEDIR) + StrLen(name) + 2);
00324     StrCopy(pathNameP, FILEDIR);
00325     StrCat(pathNameP, "/");
00326     StrCat(pathNameP, name);
00327     
00328     err = VFSFileOpen(card, pathNameP, vfsModeRead, &fileRef);
00329     MemPtrFree(pathNameP);
00330     
00331     if (!err) {
00332       err = VFSFileGetDate(fileRef, vfsFileDateCreated, &date);
00333       VFSFileClose(fileRef);
00334     }
00335   
00336   } else {
00337     lid = DmFindDatabase(card, name);
00338     
00339     if (lid) {
00340       err = DmDatabaseInfo(card,
00341                            lid,
00342                            NULL /*  *nameP */,
00343                            NULL /* *attributesP */,
00344                            NULL /* UInt16 *versionP */,
00345                            &date /* *crDateP */,
00346                            NULL /* UInt32 *modDateP */,
00347                            NULL /* *bckUpDateP */,
00348                            NULL /* UInt32 *modNumP */,
00349                            NULL /* LocalID *appInfoIDP */,
00350                            NULL /* LocalID *sortInfoIDP */,
00351                            NULL /* UInt32 *typeP */,
00352                            NULL /* UInt32 *creatorP*/
00353             );
00354     }  
00355   }
00356   
00357   if (err) {
00358     date = 0;
00359   }
00360   return date;
00361 }
00362 
00363 
00364 /**********************************************************************/
00365 /**
00366  * \brief       Delete Map File (File Stream or VFS File)
00367  *
00368  * \param       name            pointer to filename
00369  * \param       card            File Stream card or VFS volume,
00370  *                              MSB: VFS-Flag
00371  *
00372  * \return      File creation date (seconds)
00373  ***********************************************************************/
00374 static Err DeleteMap(const char *name, UInt32 card)
00375 {
00376   Err           err = 0;        /* error code */
00377   MemPtr        pathNameP;      /* ptr to path name */
00378 
00379   if (card & VFS_FLAG) {
00380     card &= ~VFS_FLAG;
00381     pathNameP = MemPtrNew(sizeof(FILEDIR) + StrLen(name) + 2);
00382     StrCopy(pathNameP, FILEDIR);
00383     StrCat(pathNameP, "/");
00384     StrCat(pathNameP, name);
00385     
00386     err = VFSFileDelete(card, pathNameP);
00387   
00388   } else {
00389     err = FileDelete(card, name);  
00390   
00391   }
00392   
00393   return err;
00394 }
00395 
00396 
00397 /**********************************************************************/
00398 /**
00399  * \brief       File Selection Form Event Handler.
00400  *
00401  * \param       eventP          pointer to event structure 
00402  *
00403  *
00404  * \return      Status flag: event handled
00405  ***********************************************************************/
00406 Boolean FileSelFormHandleEvent(EventPtr eventP)
00407 {
00408   EventType             event;                  /* event to queue */
00409   Err                   err;                    /* error code */
00410   Boolean               handled = false;        /* event handled flag */
00411   FormPtr               frmP;                   /* form ptr */
00412   TablePtr              tblP;                   /* table ptr */
00413   static DmOpenRef      scratch;                /* scratchpad DB reference */
00414   static char           *filelist;              /* filelist DB record */
00415   static char           *filecard;              /* filecard DB record */
00416   static char           **filelp;               /* filelp DB record */
00417   static UInt16         files;                  /* number of files found */
00418   UInt32                card;                   /* card/volume */
00419   char                  *filename;              /* ptr to filename */
00420   UInt32                seconds;                /* seconds (date) */
00421   DateTimeType          dt;                     /* date/time structure */
00422   UInt16                i;                      /* loop index */
00423   Char                  **c;                    /* pointer to file list entry */
00424   Char                  tmp[dateStringLength +
00425                             timeStringLength +
00426                             2];                 /* string buffer */
00427   UInt32                size;                   /* file size */
00428   static Int32          file_top = 0;           /* file table top */
00429   static UInt16         file_sel = 0;           /* file table selected row */
00430   FileDescrType         filedescr;              /* file descriptor */
00431   UInt16                width;                  /* image width */
00432   UInt16                height;                 /* image height */
00433   UInt8                 type;                   /* image type */
00434   
00435   frmP = FrmGetActiveForm();
00436   tblP = FrmGetObjectPtr(frmP, FrmGetObjectIndex(frmP, FileSelTable));
00437   
00438   switch (eventP->eType) {
00439   case frmOpenEvent:
00440     FileSelFormInit(frmP);
00441     FrmDrawForm(frmP);
00442     
00443     CreateDatabase(&scratch, &filelist, &filecard, &filelp);
00444     
00445     files = getdir(filelist, filecard, filelp);
00446     
00447     if (gVfsManagerFtr) {
00448       files = getdir_vfs(filelist, filecard, filelp, files);
00449     }
00450        
00451     if (files == 0) {
00452       /* No Image File found */
00453       if (gVfsManagerFtr) {
00454         FrmAlert(DirEmptyVfsAlert);
00455       } else {
00456         FrmAlert(DirEmptyAlert);
00457       }
00458     }
00459     
00460     /*
00461      * Compare current filename with filelist,
00462      * if matching entry is found, mark filename
00463      * in table as selected and store position in gFileSel.
00464      * The top row is adjusted to make sure the current
00465      * file is visible.
00466      */ 
00467     c = filelp;
00468     
00469     file_top = 0;
00470     file_sel = 0;
00471     
00472     /* find index of current file */
00473     for (i = 0; i<files; i++, c++) {
00474        memcpy(&card, &filecard[i*4], 4);
00475        
00476        if ( (StrCompare(SEL_FILENAME, *c+SORTPREFIX) == 0 ) &&
00477             (card == SEL_FILECARD) ) {
00478          
00479          /* file found, set table top row and selection */
00480          file_sel = i;
00481          file_top = (file_sel < TblGetNumberOfRows(tblP)) ? 0 :
00482            (file_sel - TblGetNumberOfRows(tblP) + 1);     
00483          
00484          /* show file size */
00485          memcpy(&size, filelp[file_sel], 4);
00486          StrIToA(tmp, size);
00487          SetFieldText(FileSelSizeField, tmp, false, true);
00488     
00489          /* show file creation date */
00490          seconds = GetFileCreationDate(filelp[file_sel] + SORTPREFIX, card);
00491 
00492          if (seconds > 0) {
00493            TimSecondsToDateTime(seconds, &dt);
00494 
00495            DateToAscii(dt.month, dt.day, dt.year, dfYMDWithDashes, tmp);
00496            StrCat(tmp, " ");
00497            TimeToAscii(dt.hour, dt.minute, tfColon24h, &tmp[StrLen(tmp)]);
00498            SetFieldText(FileSelDateField, tmp, false, true);
00499 
00500          } else {
00501            SetFieldText(FileSelDateField, NULL, false, true);
00502          }
00503     
00504          /* show dimensions of selected image */
00505          filedescr = fopen(card, filelp[file_sel] + SORTPREFIX, 
00506            FILEDIR, &err);
00507 
00508          if (!err) {
00509            if (!imginfo(filedescr, &type, &width, &height)) {
00510              StrPrintF(tmp, "%d x %d", width, height);
00511              SetFieldText(FileSelInfo1Field, tmp, false, true);
00512            } else {
00513              SetFieldText(FileSelInfo1Field, "", false, true);
00514            }
00515            fclose(filedescr);
00516          } else {
00517            SetFieldText(FileSelInfo1Field, "", false, true);
00518          }         
00519          break;
00520          
00521        }
00522     }
00523     
00524     /* draw the table */
00525     DrawTable(files, filelp, filecard, file_top, &file_sel);
00526 
00527     handled = true;
00528     break;
00529   
00530   case tblSelectEvent:
00531     /* show size and creation date of selected file */
00532     file_sel = eventP->data.tblSelect.row + file_top;
00533     memcpy(&size, filelp[file_sel], 4);
00534     memcpy(&card, &filecard[file_sel*4], 4);
00535     
00536     StrIToA(tmp, size);
00537     SetFieldText(FileSelSizeField, tmp, false, true);
00538     
00539     seconds = GetFileCreationDate(filelp[file_sel] + SORTPREFIX, card);
00540     
00541     if (seconds > 0) {
00542       TimSecondsToDateTime(seconds, &dt);
00543 
00544       DateToAscii(dt.month, dt.day, dt.year, dfYMDWithDashes, tmp);
00545       StrCat(tmp, " ");
00546       TimeToAscii(dt.hour, dt.minute, tfColon24h, &tmp[StrLen(tmp)]);
00547       SetFieldText(FileSelDateField, tmp, false, true);
00548     
00549     } else {
00550       SetFieldText(FileSelDateField, NULL, false, true);
00551     }
00552     
00553     /* show dimensions of selected image */
00554     filedescr = fopen(card, filelp[file_sel] + SORTPREFIX, 
00555       FILEDIR, &err);
00556     
00557     if (!err) {
00558       if (!imginfo(filedescr, &type, &width, &height)) {
00559         StrPrintF(tmp, "%d x %d", width, height);
00560         SetFieldText(FileSelInfo1Field, tmp, false, true);
00561       } else {
00562         SetFieldText(FileSelInfo1Field, "", false, true);
00563       }
00564       fclose(filedescr);
00565     } else {
00566       SetFieldText(FileSelInfo1Field, "", false, true);
00567     }
00568     
00569     DrawTable(files, filelp, filecard, file_top, &file_sel);
00570     handled = true;
00571     break;
00572   
00573   case sclRepeatEvent:
00574     /* handle scrollbar */
00575     Doscroll(FileSelTable, FileSelScrl, files, &file_top);
00576     DrawTable(files, filelp, filecard, file_top, &file_sel);
00577     /* Note: scrollbar needs to handle the event, too */
00578     handled = false;
00579     break;
00580   
00581   case keyDownEvent:
00582     switch (eventP->data.keyDown.chr) {
00583     
00584     case pageUpChr:
00585     case pageDownChr:
00586       Dopage(FileSelTable, (eventP->data.keyDown.chr == pageDownChr),
00587         files, &file_top);
00588       DrawTable(files, filelp, filecard, file_top, &file_sel);
00589       /* Note: scrollbar needs to handle the event, too */
00590       handled = false;
00591       break;
00592     }
00593   
00594   case ctlSelectEvent:
00595     switch (eventP->data.ctlSelect.controlID) {
00596 
00597     case FileSelOkButton:
00598       if (files == 0) {
00599         /* no files, quit */
00600         event.eType = appStopEvent;
00601         EvtAddEventToQueue(&event);
00602         break;
00603       }
00604       if (file_sel < files) {
00605         /* copy selected name and card no. of selected file to preferences */
00606         StrCopy(SEL_FILENAME, filelp[file_sel] + SORTPREFIX);
00607         memcpy(&SEL_FILECARD, &filecard[file_sel*4], 4);
00608       }
00609       /* user selected map, keep this map even if not showing current position */
00610       gPrefs.mapprefs.select = SEL_USER;
00611       FrmGotoForm(MapForm);
00612       handled = true;
00613       break;
00614     
00615     case FileSelAutoButton:
00616       /* automatically select map */
00617       gPrefs.mapprefs.select = SEL_AUTO;
00618       /* clear filename */
00619       StrCopy(SEL_FILENAME, "");
00620       FrmGotoForm(MapForm);
00621       handled = true;
00622       break;
00623     
00624     case FileSelCancelButton:
00625       if (files == 0) {
00626         /* no files, quit */
00627         event.eType = appStopEvent;
00628         EvtAddEventToQueue(&event);
00629         break;
00630       }
00631       FrmGotoForm(MapForm);
00632       handled = true;
00633       break;
00634 
00635     case FileSelDeleteButton:
00636       if (file_sel < files) {
00637         MemHandle               strH = NULL;            /* string handle */
00638         MemPtr                  strP = NULL;            /* string ptr */
00639         Boolean                 confirm = false;        /* delete confirmed */
00640         
00641         filename = filelp[file_sel] + SORTPREFIX;
00642         memcpy(&card, &filecard[file_sel*4], 4);
00643 
00644         /* get string from resource */
00645         strH = DmGetResource(strRsc, (card & VFS_FLAG) ? MapExtStr : MapIntStr);
00646 
00647         if (strH != NULL) {
00648           /* string handle valid, lock it */
00649           strP = MemHandleLock(strH);
00650         }
00651 
00652         confirm = (FrmCustomAlert(MapDelConfirmAlert, filename, 
00653           strP, "") == 0);
00654 
00655         if (strH != NULL) {
00656           /* unlock string handle */
00657           MemHandleUnlock(strH);
00658 
00659           /* release string resource */
00660           DmReleaseResource(strH);
00661         }
00662         if (confirm) {
00663           DeleteMap(filename, card);
00664           if (file_sel > 0) {
00665             file_sel--;
00666           }
00667           /* clear filename */
00668           StrCopy(SEL_FILENAME, "");
00669 
00670           FrmGotoForm(FileSelForm);
00671         }
00672       }
00673       handled = true;
00674       break;
00675       
00676     }
00677     break;
00678     
00679   case frmCloseEvent:
00680     SetFieldText(FileSelSizeField, NULL, false, true);
00681     SetFieldText(FileSelDateField, NULL, false, true);
00682     FileSelFormDeinit(FrmGetActiveForm());
00683     DestroyDatabase(scratch, filelist, filecard, filelp);
00684     handled = false;
00685     break;
00686 
00687   default:
00688     break;
00689   }
00690   
00691   return handled;
00692 }

Created: Mon, 08 Oct 2007 22:33:16 +0200
Copyright ©2004 M. Prinke