📄 .#progect.c.1.81
字号:
} if (i != numRows) { TblSelectItem(table, i, 0); gLastSelected = gActualTask; } else { gLastSelected = gActualTask = 0; }} // void SelectActualTask(Boolean move)/**************************************************************************** * Name : InitFrmTaskEdit * Desc : init the form to edit the actual selected task * Parm : * Out : * Auth : lb, 03.08.2000 * Mod : rw, 30.12.2000 * support for syncing categories with ToDo * Mod : rw, 02.01.2001 * modified to use ItemType enumeration values * Mod : lb, 23.06.2001 * handera support : correct date trigger position * Mod : lb, 2001-09-06 * adapt to 0.23 db format ***************************************************************************/void InitFrmTaskEdit(void){ FieldPtr fld = GetObjectPtr(TaskDesc); MemHandle h; TaskExtendedRecordType *p; MemHandle textH = FldGetTextHandle(fld); Char *textP; UInt16 l; UInt8 priority, value; DateType dueDate; UInt16 category; ItemType type; TaskStandardFields *pf; // if there's already a handle, destroy it if (textH) { FldSetTextHandle(fld, NULL); MemHandleFree(textH); } h = DmQueryRecord(gdbP, gActualTask); p = MemHandleLock(h); pf = StdFields(p); l = StrLen(&pf->description); textH = MemHandleNew(l+1); textP = MemHandleLock(textH); SafeCopy(textP, &pf->description,l+1); MemHandleUnlock(h); MemHandleUnlock(textH); FldSetTextHandle(fld, textH); // see if we're synchronized with a ToDo if (TaskGetFormat(gdbP, gActualTask).hasToDo) { pgErr err; // check the status in ToDo and update this task err = TaskGetToDoStatus(gdbP, gActualTask, &value, &priority, &dueDate, &category); if (err == pgOK) { TaskSetCompleted(gdbP, gActualTask, value, true); TaskSetDueDate(gdbP, gActualTask, dueDate); TaskSetPriority(gdbP, gActualTask, priority); TaskSetCategory(gdbP, gActualTask, category); CtlSetValue(GetObjectPtr(Chk_Edit_ToDo_Link), 1); } } // get the date and set the selector trigger FrmTaskEditUpdateDateTrigger(GetObjectPtr(Pop_Due_Date), TaskGetDueDate(gdbP, gActualTask)); // get the priority and set it on the form priority = TaskGetPriority(gdbP, gActualTask); // to be compatible with not initialised db if (priority > 0 && priority < 7) { CtlSetValue(GetObjectPtr(Btn_Priority_X + priority - 1), true); } // initialize category popup trigger { Char* name = (Char*)CtlGetLabel(GetObjectPtr(Pop_Category)); category = TaskGetCategory(gdbP, gActualTask); CategoryGetName(gdbP, category, name); CategorySetTriggerLabel(GetObjectPtr(Pop_Category), name); } // initialize item type list and popup trigger type = TaskGetType(gdbP, gActualTask); LstSetSelection(GetObjectPtr(Lst_Item_Type), type); if (type == numericType) { UInt32 values; UInt16 size = sizeof(values); Char actualstr[16], limitstr[16]; UInt16 actual=0, limit=0; // show value fields FrmTaskEditPart(showValue); if (pgOK == TaskGetExtraChunk(gdbP, gActualTask, Extra_Numeric, 0, &values, &size)) { actual = (UInt16)(values & 0x0000FFFF); limit = (UInt16)(values >> 16 & 0x0000FFFF); } StrIToA(actualstr, actual); StrIToA(limitstr, limit); FldInsert(GetObjectPtr(TaskNumericActual), actualstr, StrLen(actualstr)); FldInsert(GetObjectPtr(TaskNumericLimit), limitstr, StrLen(limitstr)); } UpdatePopupTrigger(GetObjectPtr(Pop_Item_Type), GetObjectPtr(Lst_Item_Type));} // void InitFrmTaskEdit(void)/**************************************************************************** * Name : CleanUpFrmTaskEdit * Desc : clean up the form, save the work done * Parm : * Out : * Auth : lb, 03.08.2000 * Mod : lb, 2001-09-10 * adapt to 0.23 db format ***************************************************************************/Boolean CleanUpFrmTaskEdit(void){ FieldPtr fld = GetObjectPtr(TaskDesc); MemHandle textH = FldGetTextHandle(fld); Char *textP; TaskFormatType format; Boolean bDeleteTask=false; FldCompactText(fld); textP = MemHandleLock(textH); // if the string length is zero, we need to delete this task when this is all done :( if (StrLen(textP) == 0) bDeleteTask=true; DBGMSG((DBB, "In CleanUpFrmTaskEdit")); dbgPrintTask(gdbP, gActualTask); TaskSetDescription(gdbP, gActualTask, textP); MemHandleUnlock(textH); // update or create extrablock for numeric type format = TaskGetFormat(gdbP, gActualTask); format.newTask = 0; TaskSetFormat(gdbP, gActualTask, format); if (format.itemType == numericType) { Char *fieldTextPointer; UInt32 values, percentage; UInt16 limit=0, actual=0; // default to zero // fieldTextPointer _can_ be NULL, so assume default if it is.... fieldTextPointer = FldGetTextPtr(GetObjectPtr(TaskNumericLimit)); if (fieldTextPointer) limit = (UInt16)StrAToI(fieldTextPointer); values = limit; values <<= 16; // put it on the right // add the actual to the left // fieldTextPointer _can_ be NULL, so assume default if it is.... fieldTextPointer = FldGetTextPtr(GetObjectPtr(TaskNumericActual)); if (fieldTextPointer) actual =(UInt16)StrAToI(fieldTextPointer); values |= actual; TaskSetExtraChunk(gdbP, gActualTask, Extra_Numeric, 0, &values, sizeof(UInt32)); if (limit > 0) { percentage = (actual * 10) / limit; if (percentage > 10) percentage = 10; } else percentage = 0; TaskSetCompleted(gdbP, gActualTask, (UInt16)percentage, true); } else // not numeric, delete numeric extrablock { TaskRemoveExtraChunk(gdbP, gActualTask, Extra_Numeric, 0); } return !bDeleteTask;} // Boolean CleanUpFrmTaskEdit(void)/**************************************************************************** * Name : InitFrmNoteEdit * Desc : init the form to edit the actual selected task * Parm : * Out : * Auth : lb, 22.08.2000 ***************************************************************************/void InitFrmNoteEdit(void){ FieldPtr fld = GetObjectPtr(TaskNote); MemHandle textH = FldGetTextHandle(fld); Char *textP; UInt16 l; Char *note; DBGMSG((DBB, "InitFrmNoteEdit")); // if there's already a handle, destroy it if (textH) { FldSetTextHandle(fld, NULL); MemHandleFree(textH); } note = TaskGetNote(gdbP, gActualTask); // if there's a description already if (note) { l = StrLen(note); textH = MemHandleNew(l+1); textP = MemHandleLock(textH); // could change as we allocated memory note = TaskGetNote(gdbP, gActualTask); SafeCopy(textP, note,l+1); MemHandleUnlock(textH); FldSetTextHandle(fld, textH); } else { // set as empty string. Char* p; textH = MemHandleNew(1); p = MemHandleLock(textH); *p = '\0'; MemHandleUnlock(textH); FldSetTextHandle(fld, textH); } DBGMSG((DBB, "InitFrmNoteEdit Exit"));} // void InitFrmNoteEdit(void)/**************************************************************************** * Name : CleanUpFrmNoteEdit * Desc : clean up the form, save the work done * Parm : * Out : * Auth : lb, 22.08.2000 ***************************************************************************/void CleanUpFrmNoteEdit(void){ FieldPtr fld = GetObjectPtr(TaskNote); MemHandle textH = FldGetTextHandle(fld); Char *textP; FldCompactText(fld); textP = MemHandleLock(textH); TaskSetNote(gdbP, gActualTask, textP); MemHandleUnlock(textH); // set texthandle as NULL, or it'll be destroyed by the close event FldSetTextHandle(fld, NULL); MemHandleFree(textH);} // void CleanUpFrmNoteEdit(void)/**************************************************************************** * Name : FrmProjectListInit * Desc : init FrmProjectList * Parm : * Out : * Auth : lb, 08.08.2000 * Rem : no error handling ***************************************************************************/void FrmProjectListInit(void){ UInt16 num = 0; DmSearchStateType stateInfo; LocalID dbID; ListPtr listP; UInt16 cardNo = 0; UInt16 offset = 0; listP = GetObjectPtr(Lst_Project_List); LstEraseList(listP); // search the number of databases // begin the search if (DmGetNextDatabaseByTypeCreator(true, &stateInfo, 'DATA', CREATOR, false, &cardNo, &dbID) == errNone) { num++; // continue the search while (DmGetNextDatabaseByTypeCreator(false, &stateInfo, 'DATA', CREATOR, false, &cardNo, &dbID) == errNone) { num++; } } // deallocate old lists if necessary if (namesData) { MemPtrFree(namesData); } if (names) { MemPtrFree(names); } // allocate enough space for the names (+1 for NULL, used by GlobalFlat) namesData = MemPtrNew(num * 32); names = MemPtrNew((num+1)*sizeof(char*)); names[num] = NULL; // terminate names array num = 0; // get the names in our array // initial name if (DmGetNextDatabaseByTypeCreator(true, &stateInfo, 'DATA', CREATOR, false, &cardNo, &dbID) == errNone) { DmDatabaseInfo(cardNo, dbID, namesData, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); // if the name is prepended (new databases since V0.10) if (StrStr(namesData, gPrepend) == namesData) { MemMove(namesData, namesData + StrLen(gPrepend), StrLen(namesData+StrLen(gPrepend)) + 1); } names[num++] = namesData; offset += StrLen(namesData) + 1; while (DmGetNextDatabaseByTypeCreator(false, &stateInfo, 'DATA', CREATOR, false, &cardNo, &dbID) == errNone) { DmDatabaseInfo(cardNo, dbID, &namesData[offset], NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); // if the name is prepended (new databases since V0.10) if (StrStr(&namesData[offset], gPrepend) == &namesData[offset]) { MemMove(&namesData[offset], &namesData[offset] + StrLen(gPrepend), StrLen(&namesData[offset]+StrLen(gPrepend)) + 1); } names[num++] = &namesData[offset]; offset += StrLen(&namesData[offset]) + 1; } } // set the names in the list LstSetListChoices(listP, names, num); // draw the list LstDrawList(listP); // if the list is empty, deselect it if (num == 0) { LstSetSelection(listP, -1); }} // void FrmProjectListInit(void)/**************************************************************************** * Name : FrmProjectListCleanUp * Desc : clean up the form * Parm : * Out : * Auth : lb, 08.08.2000 ***************************************************************************/void FrmProjectListCleanUp(void){ } // void FrmProjectListCleanUp(void)/**************************************************************************** * Name : MessageBox * Desc : display a message for the user, just OK * Parm : * -> message id * Out : * Auth : lb, 11.09.2000 ***************************************************************************/void MessageBox(UInt16 id){ MemHandle h; char* p; UInt16 respond; h = DmGetResource('tSTR', id); p = MemHandleLock(h); respond = FrmCustomAlert(AltEmpty, p, " ", " "); MemHandleUnlock(h); DmReleaseResource(h);} // void MessageBox(UInt16 id)/**************************************************************************** * Name : GetLastInSub * Desc : return the last index of the parent's sub * Parm : * -> parent * Out : * Auth : lb, 21.10.2000 ***************************************************************************/UInt16 GetLastInSub(UInt16 parent){ UInt16 i = parent + 1; UInt8 refLevel = (parent == 1 ? 0 : TaskGetLevel(gdbP, parent)); UInt16 num = PgNumRecords(gdbP) - 1; while (i < num && TaskGetLevel(gdbP, i) > refLevel) { i++; } return i - 1;} // UInt16 GetLastInSub(UInt16 parent)/**************************************************************************** * Name : ConfirmCustom * Desc : display a custom confirmation message * Parm : * -> action id (StrActionDelete || StrActionResetDates * -> message id * Out : button pressed * Auth : seagull, 09.09.2000 * Mod : burgbach, 21.10.2000 -> custom message (not only delete messages) ***************************************************************************/UInt16 ConfirmCustom(UInt16 idAction, UInt16 id){ MemHandle h1, h2; char *p1, *p2; UInt16 respond; h1 = DmGetResource('tSTR', idAction); h2 = DmGetResource('tSTR', id); p1 = MemHandleLock(h1); p2 = MemHandleLock(h2); respond = FrmCustomAlert(AltConfirmCustom, p1, p2, " "); MemHandleUnlock(h1); DmReleaseResource(h1); MemHandleUnlock(h2); DmReleaseResource(h2); return respond;} // UInt16 ConfirmCustom(UInt16 idAction, UInt16 id)/**************************************************************************** * Name : ProgressHandleEvent * Desc : update the progress of the actualtask
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -