static Int16 LoadIcon(Int16 start) { FormPtr frmP = FrmGetActiveForm(); Int8 i; Int16 num; Int16 iconButtonID = IconSelectIcon1Button; BitmapPtr pbmp; MemHandle h; Int16 x, y; RectangleType r; num = DmNumResources(IconDB); if (start > num) start = 0; for (i = 0; i < 9*8; i++) { UInt16 idx = FrmGetObjectIndex(frmP, iconButtonID + i); FrmGetObjectPosition(frmP, idx, &x, &y); FrmGetObjectBounds(frmP, idx, &r); r.topLeft.x = x; r.topLeft.y = y; WinEraseRectangle(&r, 0); if (i+start <num) { h = (MemPtr)GetIconByIndex(IconDB, i + start); pbmp = (h) ? MemHandleLock(h) : NULL; if (pbmp) { WinDrawBitmap(pbmp, x, y); MemHandleUnlock(h); DmReleaseResource(h); ShowObject(frmP, iconButtonID + i); } else { HideObject(frmP, iconButtonID + i); } } else { HideObject(frmP, iconButtonID + i); } } return num; }
/*********************************************************************** * * FUNCTION: ThumbnailViewLoadGadgets * * DESCRIPTION: This routine loads sketches into the thumbnail view form * thumbnail gadgets. * * PARAMETERS: recordNum index of the first record to display. * * RETURNED: nothing * ***********************************************************************/ static void ThumbnailViewLoadGadgets(FormType* frm) { UInt16 row; MemHandle recordH; DynamicButtonType* btn; MemPtr ptr; UInt16 attr; UInt16 recordNum = d.top_visible_record; const UInt16 max = Min(recordsPerPage, d.records_in_cat - d.top_row_pos_in_cat); for (row = 0; row < max; row++) { /* Get the next record in the current category. */ recordH = DmQueryNextInCategory (d.dbR, &recordNum, p.category); if(row == 0) { /* store the position of the first row so we can use */ /* d.top_row_pos_in_cat + row when drawing */ d.top_row_pos_in_cat = recordH ? DmPositionInCategory(d.dbR, recordNum, p.category) : 0; } btn = (DynamicButtonType*) FrmGetGadgetData(frm, FrmGetObjectIndex(frm, Thumb1 + row)); /* Store record number */ btn->value = recordNum; /* Clear old internal values */ btn->selected = false; /* Read record attributes */ DmRecordInfo(d.dbR, recordNum, &attr, NULL, NULL); if (attr & dmRecAttrSecret && d.privateRecordStatus == maskPrivateRecords) { DrawMaskedRecord(btn->content.bmpW, maskPattern); } else { /* WinHandle oldH = NULL; */ /* Err err = 0; */ /* BitmapType* bmp = BmpCreate(btn->contentRect.extent.x, */ /* btn->contentRect.extent.y, 1, NULL, &err); */ /* if (err) abort(); */ /* Uncompress thumbnail */ ptr = MemHandleLock(recordH); // MemMove(BmpGetBits(bmp), ptr + sketchDataOffset, sketchThumbnailSize); MemMove(BmpGetBits(WinGetBitmap(btn->content.bmpW)), ptr + sketchDataOffset, sketchThumbnailSize); MemHandleUnlock(recordH); /* Write thumbnail to content bitmap */ /* WinPushDrawState(); */ /* WinSetCoordinateSystem(kCoordinatesNative); */ /* oldH = WinSetDrawWindow(btn->content.bmpW); */ /* WinPaintBitmap(bmp, 0, 0); */ /* WinSetDrawWindow(oldH); */ /* WinPopDrawState(); */ /* Clean up */ /* BmpDelete(bmp); */ } recordNum++; /* Show the right gadgets... */ ShowObject(frm, Thumb1 + row); } /* ...store the index of the last visible thumbnail... */ d.lastVisibleThumbnail = row - 1; /* ... and hide the rest */ for (; row < recordsPerPage; row++) HideObject(frm, Thumb1 + row); /* Update the scroll arrows. */ ThumbnailViewUpdateScrollers (frm); }
/*********************************************************************** * * FUNCTION: RepeatChangeType * * DESCRIPTION: This routine changes the ui gadgets in the repeat dialog * such that they match the newly selected repeat type. The * routine is called when one of the repeat type push buttons * are pushed. * * PARAMETERS: event - pointer to and event * * RETURNED: nothing * ***********************************************************************/ static void RepeatChangeType(EventType* event) { UInt16 id; FormType* frm = FrmGetFormPtr(RepeatForm); const RepeatType oldType = d.repeat_event_type; RepeatType newType; RepeatInfoType repeat; /* If the type if monthly default to monthly-by-date. */ newType = (RepeatType) (event->data.ctlSelect.controlID - RepeatNone); if (newType > repeatWeekly) newType++; if (oldType == newType) return; /* Initialize the UI gadgets. */ if (newType == d.tmp_repeat.repeatType) { RepeatSetUIValues(frm, &d.tmp_repeat); /* ** If reselecting current repeat type, reset d.repeat_end_date global ** to current date so if user attemps to "choose" a new day, the ** default matches date displayed as opposed to last date picked ** last in choose form. */ d.repeat_end_date = d.tmp_repeat.repeatEndDate; } else { repeat.repeatType = newType; /* ** When switching to a repeat type different from the current ** setting, always start user with default end date and frequency ** settings. */ DateToInt(repeat.repeatEndDate) = defaultRepeatEndDate; DateToInt(d.repeat_end_date) = defaultRepeatEndDate; repeat.repeatFrequency = defaultRepeatFrequency; repeat.repeatStartOfWeek = PrefGetPreference(prefWeekStartDay); if (newType == repeatWeekly) { repeat.repeatOn = (1 << DayOfWeek(d.frm_date.month, d.frm_date.day, d.frm_date.year/*+firstYear*/)); } else if (newType == repeatMonthlyByDay) { repeat.repeatOn = DayOfMonth(d.frm_date.month, d.frm_date.day, d.frm_date.year/* + firstYear*/); } else { repeat.repeatOn = 0; } RepeatSetUIValues (frm, &repeat); } /* ** Hide the UI gadgets that are unique to the repeat type we are ** no longer editing. */ switch (oldType) { case repeatNone: HideObject(frm, RepeatNoRepeatLabel); break; case repeatHourly: HideObject(frm, RepeatHoursLabel); break; case repeatDaily: HideObject(frm, RepeatDaysLabel); break; case repeatWeekly: HideObject(frm, RepeatWeeksLabel); for (id = RepeatRepeatOnLabel; id <= RepeatDayOfWeek7PushButton; id++) HideObject (frm, id); break; case repeatMonthlyByDay: case repeatMonthlyByDate: HideObject(frm, RepeatMonthsLabel); for (id = RepeatByLabel; id <= RepeatByDatePushButton; id++) HideObject (frm, id); break; case repeatYearly: HideObject(frm, RepeatYearsLabel); break; } /* Handle switching to or from "no" repeat. */ if (oldType == repeatNone) { ShowObject(frm, RepeatEveryLabel); ShowObject(frm, RepeatFrequenceField); ShowObject(frm, RepeatEndOnLabel); ShowObject(frm, RepeatEndOnTrigger); } else if (newType == repeatNone) { HideObject(frm, RepeatEveryLabel); HideObject(frm, RepeatFrequenceField); HideObject(frm, RepeatEndOnLabel); HideObject(frm, RepeatEndOnTrigger); } /* Show the UI object that are appropriate for the new repeat type. */ switch (newType) { case repeatNone: ShowObject(frm, RepeatNoRepeatLabel); break; case repeatHourly: ShowObject(frm, RepeatHoursLabel); break; case repeatDaily: ShowObject(frm, RepeatDaysLabel); break; case repeatWeekly: ShowObject(frm, RepeatWeeksLabel); ShowObject(frm, RepeatRepeatOnLabel); for (id = RepeatRepeatOnLabel; id <= RepeatDayOfWeek7PushButton; id++) ShowObject(frm, id); break; case repeatMonthlyByDay: case repeatMonthlyByDate: ShowObject(frm, RepeatMonthsLabel); ShowObject(frm, RepeatByLabel); ShowObject(frm, RepeatByDayPushButton); ShowObject(frm, RepeatByDatePushButton); break; case repeatYearly: ShowObject(frm, RepeatYearsLabel); break; } d.repeat_event_type = newType; /* Update the display of the repeat descrition. */ RepeatDrawDescription(frm); }