📄 progect.c
字号:
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); // +++ FIX THIS +++ // Okay, so now what if the type is extendedType or linkType(not supported)? // It'll blow up the GUI. // This should be fixed somehowe should it not? // +++ FIX THIS +++ 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 : 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 * Parm : * Out : * Auth : burgbach, 19.10.2000 * Mod : rw, 30.12.2000 * updated signature of TaskSetToDoStatus * Mod : lb, 2001-09-06 * adapt to 0.23 db format ***************************************************************************/void ProgressHandleEvent(void){ // only for leaves // not for directlink types TaskFormatType format; if (!gActualTask) return; format = TaskGetFormat(gdbP, gActualTask); if (format.itemType == actionType) { TaskSetCompleted(gdbP, gActualTask, TaskGetCompleted(gdbP, gActualTask) == ACTION_DONE ? ACTION_NOT_DONE : ACTION_DONE, true); if (format.hasToDo) { TaskSetToDoStatus(gdbP, gActualTask, toDoComplete, TaskGetCompleted(gdbP, gActualTask), 0, gNoDate, 0); // record completion date (always for ToDo linked tasks) if (TaskGetIsDone(gdbP, gActualTask)) TaskSetToDoStatus(gdbP, gActualTask, toDoDueDate, 0, 0, Today(), 0); } } else if (!TaskGetHasChild(gdbP, gActualTask) && (format.itemType == progressType)) { Int16 TInt16; ListPtr listP = GetObjectPtr(Lst_Percent); LstSetSelection(listP, TaskGetCompleted(gdbP, gActualTask)); TInt16 = LstPopupList(listP); if (TInt16 != -1) { TaskSetCompleted(gdbP, gActualTask, TInt16, true); } } else return; // record completion date if (TaskGetIsDone(gdbP, gActualTask) && gProjectPrefs.completionDate) TaskSetDueDate(gdbP, gActualTask, Today()); // update fathers if (TaskGetLevel(gdbP, gActualTask) > 1) { TaskCalcCompleted(gdbP, TaskGetFatherIndex(gdbP, gActualTask)); } FrmUpdateForm(FrmGetActiveFormID(), frmRedrawUpdateCode);}/**************************************************************************** * Name : PriorityHandleEvent * Desc : update the priority of the actualtask * Parm : * Out : * Auth : burgbach, 19.10.2000 ***************************************************************************/void PriorityHandleEvent(EventPtr e){ Coord lx, ly; // edit it in place Int16 TInt16; ListPtr listP = GetObjectPtr(Lst_Priority); TaskFormatType format; format = TaskGetFormat(gdbP, gActualTask); if (format.itemType == linkType) { return; } // init lx and ly depending on the active form if (FrmGetActiveFormID() == FrmFlat) { lx = 25; ly = 15 + e->data.tblSelect.row * 11; } else { lx = 4 + (1 + TaskGetLevel(gdbP, gActualTask) - gRefLevel) * 11; if (TaskGetType(gdbP, gActualTask) == informativeType) lx -= 11; ly = 15 + e->data.tblSelect.row * 11; } LstSetSelection(listP, TaskGetPriority(gdbP, gActualTask) - 1); ly -= (TaskGetPriority(gdbP, gActualTask) - 1) * 11; // don't get out the screen ly = ly < 1 ? 1 : ly; ly = ly > 103 ? 103 : ly; LstSetPosition(listP, lx, ly); TInt16 = LstPopupList(listP); if (TInt16 != -1) { TaskSetPriority(gdbP, gActualTask, TInt16 + 1); FrmUpdateForm(FrmGetActiveFormID(), frmRedrawUpdateCode); } if (TaskGetFormat(gdbP, gActualTask).hasToDo) { TaskSetToDoStatus(gdbP, gActualTask, toDoPriority, 0, TaskGetPriority(gdbP, gActualTask),
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -