📄 .#progect.c.1.81
字号:
h = gIconHandle[ (p->format.bits.hasToDo? BtmLinkOn: BtmLinkOff) - BtmOffset]; bitmap = (BitmapPtr)MemHandleLock(h); // draw it WinDrawBitmap(bitmap, 1, y + 2); MemHandleUnlock(h); } x = 13; }#if 0 // test implement... but this is BAD idea... else if (gProjectPrefs.nIndentWidth <= 1) { // for short or very short indent x = (level - gRefLevel - 1) * 2; if (p->attr.bits.hasChild || gProjectPrefs.nIndentWidth == 1) { h = gIconHandle[(p->attr.bits.opened? BtmMinusAlone : BtmPlusAlone) - BtmOffset]; bitmap = (BitmapPtr)MemHandleLock(h); if (p->attr.bits.hasChild) WinDrawBitmap(bitmap, x, y); x += bitmap->width + 1; MemHandleUnlock(h); } }#endif else { // we can do this just because we only use attr and format x = DrawItemTreeLines((TaskRecordType*)p, row, x, y, 0); } // write the item description (with priority, due date, progress bar...) if (p->format.bits.itemType == extendedType) { ProjectDrawExtendedItemDesc((TaskExtendedRecordType*)p, x, y); } else { // Init lines to be limit of the # of lines to show for this item lines = (gProjectTableMaxY - y) / 11; if(lines > gProjectPrefs.wordWrapLines) lines = gProjectPrefs.wordWrapLines; // Now lines will be the actual # of lines that were used. lines = ProjectDrawItemDesc(p, x, y, lines); } if (lines * 11 != bounds->extent.y) { TblSetRowHeight(table, row, lines * 11); } // Draw continuation vertical lines for each additional // horizontal line belonging to this item. while (--lines > 0) { DrawItemTreeLines((TaskRecordType*)p, row, 0, y + 11*lines, lines); } MemHandleUnlock(taskH);} // static void ProjectItemDraw(MemPtr table, UInt16 row, UInt16 column, RectanglePtr bounds)/* * Table init */void ProjectTableInit(void){ TablePtr table; UInt16 numRows; UInt16 i; RectangleType tableBounds; DBGMSG((DBB, "In ProjectTableInit")); table = GetObjectPtr(ProjectTable); numRows = TblGetNumberOfRows(table); // Cache table's max Y for frequent use by ProjectItemDraw TblGetBounds(table, &tableBounds); gProjectTableMaxY = tableBounds.topLeft.y + tableBounds.extent.y; for (i = 0; i < numRows; i++) { TblSetItemStyle(table, i, 0, customTableItem); TblSetItemInt(table, i, 0, i + 1); // begin at task 1, never display task 0 TblSetRowSelectable(table, i, false); TblSetRowUsable(table, i, false); } TblSetColumnUsable(table, 0, true); TblSetCustomDrawProcedure(table, 0, (TableDrawItemFuncPtr)ProjectItemDraw); TblSetItemInt(table, 0, 0, gCurrentPrefs.topTask);} // static void ProjectTableInit(void)void ProjectTableEmpty(void){ TablePtr table; UInt16 numRows; UInt16 i; table = GetObjectPtr(ProjectTable); numRows = TblGetNumberOfRows(table); for (i = 0; i < numRows; i++) { // fill with empty items TblSetItemInt(table, i, 0, -1); TblSetRowSelectable(table, i, false); TblSetRowUsable(table, i, false); wVerticalLines[i] = 0; }}void ProjectTableUpdate(void){ TablePtr table; UInt16 numRows; UInt16 numRec; UInt16 i; Int32 next; UInt8 level; DBGMSG((DBB, "In ProjectTableUpdate")); table = GetObjectPtr(ProjectTable); numRows = TblGetNumberOfRows(table); numRec = PgNumRecords(gdbP); // need to set the first one selectable for when we come back of an empty // subview TblSetRowSelectable(table, 0, true); TblSetRowUsable(table, 0, true); // special case, db empty (just task 0) if (numRec == 1) { ProjectTableEmpty(); return; } // special case, the first row's item is -1, check if (TblGetItemInt(table, 0, 0) == -1 || TblGetItemInt(table, 0, 0) >= numRec) { if (gParentTask + 1 < numRec && TaskGetLevel(gdbP, gParentTask + 1) > gRefLevel) { TblSetItemInt(table, 0, 0, gParentTask + 1); TblSetRowSelectable(table, 0, true); TblSetRowUsable(table, 0, true); } else { ProjectTableEmpty(); return; } } // first item change if it is now invisible while (gProjectPrefs.hideDoneTasks && (next = TblGetItemInt(table, 0, 0)) != -1 && TaskGetIsDone(gdbP, next)) { next = TaskGetNextRelativeIndex(gdbP, next); if (next == 0) { ProjectTableEmpty(); return; } TblSetItemInt(table, 0, 0, next); TblSetRowSelectable(table, 0, true); TblSetRowUsable(table, 0, true); } if (TaskGetLevel(gdbP, TblGetItemInt(table, 0, 0)) <= gRefLevel) { ProjectTableEmpty(); return; } // // calc vertical line for first row. // // HCC NOTE: This loop for the first node is where most of the // performance penalty lies, because TaskGetPrevIndexByLevel can be // an expensive call. if(gProjectPrefs.drawTreeLines) { next = TblGetItemInt(table, 0, 0); level = TaskGetLevel(gdbP, next); wVerticalLines[0] = TaskGetHasNext(gdbP, next)? (1 << (level - 1)) : 0; for (i = gRefLevel + 1; i < level; i++) { UInt16 prev; if ( ( !TaskGetHasPrev(gdbP, next) && i == level - 1 && TaskGetHasNext(gdbP, next - 1) ) || ( (prev = TaskGetPrevIndexByLevel(gdbP, next, i)) != dmMaxRecordIndex && TaskGetHasNext(gdbP, prev) ) ) wVerticalLines[0] |= 1 << (i - 1); } } // other items for (i = 1; i < numRows; i++) { // get the previous item next = TblGetItemInt(table, i-1, 0); if (next != -1) { // if he is not opened if (TaskGetHasChild(gdbP, next) && !TaskIsOpened(gdbP, next)) { // get the next next = TaskGetNextRelativeIndex(gdbP, next); if (next == 0) next = -1; } else { // just go to the next next++; // if it's past the last record if (next >= numRec) next = -1; } // if he must not be drawn while (gProjectPrefs.hideDoneTasks && next > 0 && TaskGetIsDone(gdbP, next)) next = TaskGetNextRelativeIndex(gdbP, next); if (next <= 0) next = -1; // if we are drawing a subtree, stop when we reach the last child if (gParentTask != 0 && next != -1) { UInt8 levA; if ((levA = TaskGetLevel(gdbP, next)) <= (gRefLevel) || ( levA == gRefLevel + 1 && TaskGetFatherIndex(gdbP, next) != gParentTask) ) next = -1; } } // calc vertical line for each row. if(gProjectPrefs.drawTreeLines) { if (next == -1) wVerticalLines[i] = 0; else { UInt16 mask = 1 << (TaskGetLevel(gdbP, next) - 1); if (TaskGetHasNext(gdbP, next)) wVerticalLines[i] = wVerticalLines[i - 1] | mask; else wVerticalLines[i] = wVerticalLines[i - 1] & ~mask; } } TblSetItemInt(table, i, 0, next); TblSetRowSelectable(table, i, (next >= 0)); TblSetRowUsable(table, i, (next >= 0)); } gCurrentPrefs.topTask = TblGetItemInt(table, 0, 0);} // void ProjectTableUpdate(void)/**************************************************************************** * Name : Scroll * Desc : update the form to scroll up or down * Parm : * -> scroll type (scrollUp, scrollDown) * -> scroll step * Out : * Auth : lb, 02.08.2000 * Mod : lb, 18.08.2000 * fixed scroll up bug that displayed father in sub view ***************************************************************************/void Scroll(scrollType s, UInt8 step){ UInt16 value; TablePtr table; table = GetObjectPtr(ProjectTable); switch (s) { case scrollDown: if ((value = TblGetItemInt(table, step, 0)) != -1) { TblSetItemInt(table, 0, 0, value); //FrmUpdateForm(FrmMain, frmRedrawUpdateCode); ProjectTableUpdate(); } else { step--; while (step > 0) { if ((value = TblGetItemInt(table, step, 0)) != -1) { TblSetItemInt(table, 0, 0, value); //FrmUpdateForm(FrmMain, frmRedrawUpdateCode); ProjectTableUpdate(); break; } step--; } } break; case scrollUp: value = TblGetItemInt(table, 0, 0); if (value == -1) return; if (value > step + gParentTask) { UInt8 count = step; while (value > gParentTask + 1 && count) { value--; if (TaskIsVisible(gdbP, value)) { count--; } else { if (gProjectPrefs.hideDoneTasks) value--; else value = TaskGetFatherIndex(gdbP, value); if (value == gParentTask) { value = gParentTask + 1; } if (TaskIsVisible(gdbP, value)) { count--; } } } TblSetItemInt(table, 0, 0, value); //FrmUpdateForm(FrmMain, frmRedrawUpdateCode); ProjectTableUpdate(); } else { TblSetItemInt(table, 0, 0, gParentTask + 1); // never display task 0 ProjectTableUpdate(); //FrmUpdateForm(FrmMain, frmRedrawUpdateCode); } break; case scrollTop: if (TaskGetHasChild(gdbP, gParentTask)) TblSetItemInt(table, 0, 0, gParentTask + 1); else TblSetItemInt(table, 0, 0, -1); // update done in Btn_Sub //FrmUpdateForm(FrmMain, frmRedrawUpdateCode); break; default: break; }} // void Scroll(scrollType s, UInt8 step)/**************************************************************************** * Name : FrmTaskEditUpdateDateTrigger * Desc : update the date trigger * Parm : * -> trigger pointer * -> date to print * Out : * Auth : lb, 06.08.2000 ***************************************************************************/void FrmTaskEditUpdateDateTrigger(MemPtr trigger, DateType p){ // +++ FIX THIS +++ // This code should probably allocate a new buffer, or actually // maybe we can just use a static buffer here. We need to manage // the memory for it in any case. // This code does not seem reliable. // +++ FIX THIS +++ Char* date; date = (Char*)CtlGetLabel(trigger); if (p.month == 0) { StrCopy(date, "No date"); } else { DateToAscii(p.month, p.day, p.year + YEAR_OFFSET, PrefGetPreference(prefDateFormat), date); } CtlSetLabel(trigger, date);} // void FrmTaskEditUpdateDateTrigger(MemPtr trigger, DateType p)/**************************************************************************** * Name : FrmTaskEditUpdateDateTrigger * Desc : update the date trigger * Parm : * -> trigger pointer * -> date to print * Out : * Auth : lb, 06.08.2000 ***************************************************************************/void UpdatePopupTrigger(MemPtr trigger, MemPtr list){ Char* text; // +++ FIX THIS +++ // This code should probably allocate a new buffer, or actually // maybe we can just use a static buffer here. We need to manage // the memory for it in any case. // This code does not seem reliable. // +++ FIX THIS +++ text = (Char*)CtlGetLabel(trigger); StrCopy(text, LstGetSelectionText(list, LstGetSelection(list))); CtlSetLabel(trigger, text);} // void UpdatePopupTrigger(MemPtr trigger, MemPtr list)/**************************************************************************** * Name : SelectActualTask * Desc : select the tbl case of gActualTask. Move the screen if necessary * expand a branch if necessary * Parm : * -> move (must the actual task be on screen) * Out : * Auth : lb, 09.08.2000 * Mod : hcc, 05.05.2001 * Make compatible with word wrapping. ***************************************************************************/void SelectActualTask(Boolean move){ TablePtr table = GetObjectPtr(ProjectTable); UInt8 i = 0, numRows = TblGetNumberOfRows(table); DBGMSG((DBB, "In SelectActualTask : %hu", gActualTask)); gLastSelected = 0; TblUnhighlightSelection(table); if (gActualTask == 0 || gActualTask > PgNumRecords(gdbP)) return; // ensure the branch is expanded if (move && !TaskIsVisible(gdbP, gActualTask)) TaskMakeVisible(gdbP, gActualTask); // is actual task on screen ? while (i < numRows && TblGetItemInt(table, i, 0) != gActualTask) { i++; } // HCC: Test if it is actually on screen, since multi-line items // may push some table rows off bottom of table. if (i != numRows && TblGetRowHeight(table, i) == 0) { i = numRows; } if (i == numRows && move) { TblSetItemInt(table, 0, 0, gActualTask); // center it // HCC: Workaround to keep item on screen when using word wrapping. // Since I can't determine the height of each row without drawing it, // Assume each row is the max number of lines. if (gProjectPrefs.wordWrapLines < 1) // Paranoia gProjectPrefs.wordWrapLines = 1; Scroll(scrollUp, 11 / gProjectPrefs.wordWrapLines); // where is it now i = 0; while (i < numRows && TblGetItemInt(table, i, 0) != gActualTask) { i++; }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -