/*------------------------------------------------CIRexxApp::NewScriptIndexDB-+ | Load the scripts DB | +----------------------------------------------------------------------------*/ void CIRexxApp::NewScriptIndexDB() { //<<<JAL since searching for many scripts can be slow, // we draw a little indicator at the start. // palm os does provide a set of progress functions, // but their progress dialog is too much for something simple. Err err; RectangleType saveFrame; WinHandle saveWindow = 0; if (WinGetDrawWindow()) { // If we can't draw yet, forget it! const char * s = getRexxAppMessage(msgRexxIsStarting); // the text in the rectangle const int wFrame = 2; // the width of dialogFrame const int padding = 2; // padding for the text in the rectangle Int16 w = FntCharsWidth(s, StrLen(s)) + (padding * 2); Int16 h = FntCharHeight() + (padding * 2); RectangleType r; RctSetRectangle(&r, (160-w)/2, (160-h)/2, w, h); RctSetRectangle(&saveFrame, r.topLeft.x-wFrame, r.topLeft.y-wFrame, r.extent.x+(wFrame*2), r.extent.y+(wFrame*2)); saveWindow = WinSaveBits(&saveFrame, &err); WinDrawRectangleFrame(dialogFrame, &r); WinDrawChars(s, StrLen(s), r.topLeft.x+padding, r.topLeft.y+padding); } initializeIndexDatabase(); if (saveWindow) { WinRestoreBits(saveWindow, saveFrame.topLeft.x, saveFrame.topLeft.y); } return; }
/***************************************************************************** * Function: GadgetDrawHint * * Description: Draw the hintbox with the hint *****************************************************************************/ void GadgetDrawHint(const char *toptext, const char *bottext, UInt16 note) { RectangleType bounds; UInt16 gadgetIndex; RectangleType rect, textbox_top, textbox_bot; FontID oldFont; ControlType *ctl; Char noteSymb[2] = { GADGET_NOTESYMBOL, 0 }; // Not needed any longer, the hint now has its own Gadget // UInt16 top = GADGET_TOP + (GADGET_STRINGS_NUM-1) * GADGET_STRINGS_OFFSET + 5; // 6 - const = VALUE BELOW if (! gForm) return; gadgetIndex = FrmGetObjectIndex(gForm, gHintGadgetID); FrmGetObjectBounds(gForm, gadgetIndex, &bounds); WinEraseRectangle(&bounds, 0); RctSetRectangle(&rect, bounds.topLeft.x+1, // +1 for border bounds.topLeft.y+1, // Put VALUE BELOW here.... +top+1 removed because of own Gadget bounds.extent.x-3, bounds.extent.y - 3); // -4 for bottom border // Erase Gadget area WinSetForeColor(UIColorGetTableEntryIndex(UIObjectFrame)); WinDrawRectangleFrame(popupFrame, &rect); RctSetRectangle(&textbox_top, rect.topLeft.x+2, rect.topLeft.y, rect.extent.x-2,(Int16)((rect.extent.y-2)/2)); RctSetRectangle(&textbox_bot, textbox_top.topLeft.x, textbox_top.topLeft.y+textbox_top.extent.y+1, textbox_top.extent.x, textbox_top.extent.y); oldFont=FntSetFont(boldFont); TNDrawCharsToFitWidth(toptext, &textbox_top); FntSetFont(oldFont); TNDrawCharsToFitWidth(bottext, &textbox_bot); gHintNote = note; if (note) { // This time has a note oldFont = FntSetFont(symbolFont); RctSetRectangle(&rect, rect.topLeft.x+rect.extent.x-8, rect.topLeft.y+rect.extent.y-12, FntLineWidth(noteSymb, 1), FntLineHeight()); TNDrawCharsToFitWidth(noteSymb, &rect); FntSetFont(oldFont); } ctl=GetObjectPtr(BUTTON_edit); CtlShowControl(ctl); ctl=GetObjectPtr(BUTTON_beam); CtlShowControl(ctl); }
void GadgetTimeSetRect(RectangleType *rect, TimeType begin, TimeType end, UInt8 day, UInt8 num_times, UInt8 pos) { UInt8 top, height, width, width_base; RectangleType bounds; UInt16 gadgetIndex = FrmGetObjectIndex(gForm, gGadgetID); FrmGetObjectBounds(gForm, gadgetIndex, &bounds); height = GadgetCalcTimeHeight(begin, end); top = GadgetCalcTimeTop(begin); if ( (top + height) > GADGET_MAX_PIXELHEIGHT) height -= ((top + height) - GADGET_MAX_PIXELHEIGHT); width = gGadgetDaysWidth / num_times; width_base = width; if (pos == (GADGET_MAX_AT_A_TIME-1)) { // It's the last item, add any pixels that get cut off by the division otherwise // (like: width: 20, num_items = 3, item width = 6, 2 got cut off, add them to the last entry) width += (gGadgetDaysWidth - (num_times * width)); } RctSetRectangle(rect, // Left Left Offset Days to left lines between days position offset bounds.topLeft.x+GADGET_BASELEFT+GADGET_LEFT+(gGadgetDaysWidth*day)+day + pos * width_base, // Top Top Offset hours bounds.topLeft.y+GADGET_TOP +top, // Width width, // 2px per 15min height); }
void OSystem_PalmOS5::render_landscapeAny(RectangleType &r, PointType &p) { Coord x, y, o = 0; uint16 *dst = _workScreenP; if (_overlayVisible) { for (y = 0; y < _screenDest.h; y++) { uint16 *src = _overlayP + *(_scaleTableY + y); for (x = 0; x < _screenDest.w; x++) { *dst++ = *(src + *(_scaleTableX + x)); } } } else { o = _current_shake_pos; for (y = 0; y < _screenDest.h; y++) { byte *src = _offScreenP + *(_scaleTableY + y); for (x = 0; x < _screenDest.w; x++) { *dst++ = *(_nativePal + *(src + *(_scaleTableX + x))); } } } p.x = _screenOffset.x; p.y = _screenOffset.y + o; RctSetRectangle(&r, 0, 0, _screenDest.w, _screenDest.h - o); }
//////////////////////////////////////////////////////////////////////// // FUNCTION: WinEraseWindow // // DESCRIPTION: This routine earse the contents of the draw window. // // PARAMETERS: None. // // RETURNED: Returns nothing. // // REVISION HISTORY: // Name Date Description // ---- ---- ----------- // Jerry 5/06/01 Initial Revision //////////////////////////////////////////////////////////////////////// void WinEraseWindow (void) { RectangleType eraseRect; RctSetRectangle (&eraseRect, 0, 0, 160, 160); WinEraseRectangle (&eraseRect,0); }
/***************************************************************************** * Function: GadgetDrawTime * * Description: Show a time in the grid *****************************************************************************/ void GadgetDrawTime(TimeType begin, TimeType end, UInt8 day, RGBColorType *color, UInt16 courseID, UInt8 num_times, UInt8 pos) { RectangleType rect; RGBColorType prevColor, inverted; // Sort out bogus requests, could be more intelligent, maybe later... if (day >= gGadgetDaysNum) return; // do nothing if Gadget has not yet been GadgetSet if (! gForm) return; if (! gGadgetID) return; GadgetTimeSetRect(&rect, begin, end, day, num_times, pos); TNSetForeColorRGB(color, &prevColor); WinDrawRectangle(&rect, 0); if ( (gPrefs.showTypes || gPrefs.showShortNames) && (rect.extent.y >= FntLineHeight())) { RGBColorType oldBack, oldText; // Get inverted color inverted.r = 255 - color->r; inverted.g = 255 - color->g; inverted.b = 255 - color->b; RctSetRectangle(&rect, rect.topLeft.x+2, rect.topLeft.y, rect.extent.x-4, rect.extent.y); TNSetTextColorRGB(&inverted, &oldText); TNSetBackColorRGB(color, &oldBack); if (gPrefs.showTypes) { MemHandle shortName=MemHandleNew(1);; CourseTypeGetShortByCourseID(&shortName, courseID); TNDrawCharsToFitWidth((Char *)MemHandleLock(shortName), &rect); MemHandleUnlock(shortName); MemHandleFree(shortName); } else if (gPrefs.showShortNames) { MemHandle courseName=MemHandleNew(1); CourseGetName(courseID, &courseName, false); TNDrawCharsToFitWidth((Char *)MemHandleLock(courseName), &rect); MemHandleUnlock(courseName); MemHandleFree(courseName); } TNSetBackColorRGB(&oldBack, NULL); TNSetTextColorRGB(&oldText, NULL); } TNSetForeColorRGB(&prevColor, NULL); }
/***************************************************************************** * Function: GadgetDrawTimeline * * Description: Draws a line for the current time *****************************************************************************/ void GadgetDrawTimeline(GadgetTimelineDrawType drawType) { DateTimeType dt; TimeType now; TimSecondsToDateTime(TimGetSeconds(), &dt); if (drawType == gtDraw) { now.hours=dt.hour; now.minutes=dt.minute; gGadgetLastTimeline.hours=now.hours; gGadgetLastTimeline.minutes=now.minutes; GadgetDrawWeekdays(); } else { now.hours=gGadgetLastTimeline.hours; now.minutes=gGadgetLastTimeline.minutes; } if ( ((gGadgetCurScreen == GADGET_SCREEN_DAY) && (now.hours >= 8) && (now.hours < 20)) || ((gGadgetCurScreen == GADGET_SCREEN_NIGHT) && ((now.hours < 8) || (now.hours >= 20))) ) { UInt8 y, gadgetWidth; UInt16 gadgetIndex; FormType *frm; RectangleType bounds; RGBColorType red={0x00, 0xFF, 0x00, 0x00}, old; y = GadgetCalcTimeTop(now); frm = FrmGetActiveForm(); gadgetIndex = FrmGetObjectIndex(frm, gGadgetID); FrmGetObjectBounds(frm, gadgetIndex, &bounds); gadgetWidth=gGadgetDaysNum * gGadgetDaysWidth + gGadgetDaysNum - 1; WinInvertLine(bounds.topLeft.x+GADGET_BASELEFT+GADGET_LEFT, bounds.topLeft.y+GADGET_TOP+y, bounds.topLeft.x+GADGET_BASELEFT+GADGET_LEFT+gadgetWidth-1, bounds.topLeft.y+GADGET_TOP+y); if (drawType == gtDraw) { TNSetForeColorRGB(&red, &old); WinDrawPixel(bounds.topLeft.x+GADGET_BASELEFT+GADGET_LEFT+gGadgetDaysNum*gGadgetDaysWidth+gGadgetDaysNum+1, bounds.topLeft.y+GADGET_TOP+y); WinDrawLine(bounds.topLeft.x+GADGET_BASELEFT+GADGET_LEFT+gGadgetDaysNum*gGadgetDaysWidth+gGadgetDaysNum+2, bounds.topLeft.y+GADGET_TOP+y-1, bounds.topLeft.x+GADGET_BASELEFT+GADGET_LEFT+gGadgetDaysNum*gGadgetDaysWidth+gGadgetDaysNum+2, bounds.topLeft.y+GADGET_TOP+y+1); WinDrawLine(bounds.topLeft.x+GADGET_BASELEFT+GADGET_LEFT+gGadgetDaysNum*gGadgetDaysWidth+gGadgetDaysNum+3, bounds.topLeft.y+GADGET_TOP+y-2, bounds.topLeft.x+GADGET_BASELEFT+GADGET_LEFT+gGadgetDaysNum*gGadgetDaysWidth+gGadgetDaysNum+3, bounds.topLeft.y+GADGET_TOP+y+2); TNSetForeColorRGB(&old, NULL); } else if (drawType == gtErase) { RectangleType rect; RctSetRectangle(&rect, bounds.topLeft.x+GADGET_BASELEFT+GADGET_LEFT+gGadgetDaysNum*gGadgetDaysWidth+gGadgetDaysNum+1, bounds.topLeft.y+GADGET_TOP+y-2, bounds.topLeft.x+GADGET_BASELEFT+GADGET_LEFT+gGadgetDaysNum*gGadgetDaysWidth+gGadgetDaysNum+3, bounds.topLeft.y+GADGET_TOP+y+2); WinEraseRectangle(&rect, 0); } } }
/***************************************************************************** * Function: GadgetDrawWeekdays * * Description: Draws the weekdays, extra function since called in * GadgetDrawTimeline *****************************************************************************/ void GadgetDrawWeekdays(void) { UInt8 i; MemHandle mh; Char *text; RGBColorType color, prevColor; DateTimeType now; Int16 dow; RectangleType bounds, rect; UInt16 gadgetIndex; // Get info about Gadget gadgetIndex = FrmGetObjectIndex(gForm, gGadgetID); FrmGetObjectBounds(gForm, gadgetIndex, &bounds); // Initialize time constants TimSecondsToDateTime(TimGetSeconds(), &now); dow = DayOfWeek(now.month, now.day, now.year); RctSetRectangle(&rect, bounds.topLeft.x+GADGET_BASELEFT+GADGET_LEFT, bounds.topLeft.y, 130, FntLineHeight()+2); // Erase background WinEraseRectangle(&rect, 0); for (i=0; i < gGadgetDaysNum; ++i) { Int16 leftoff; mh = DmGetResource(strRsc, GADGET_STRINGS_WDAYSTART+i); text = MemHandleLock(mh); leftoff = (gGadgetDaysWidth+2 - FntLineWidth(text, MemPtrSize(text))) / 2; if (TNisColored() && (dow == i+1)) { color.r = 0xFF; color.g = 0x00; color.b = 0x00; TNSetTextColorRGB(&color, &prevColor); } WinDrawChars(text, StrLen(text), bounds.topLeft.x+GADGET_BASELEFT+GADGET_LEFT+i*gGadgetDaysWidth+i+leftoff+2, bounds.topLeft.y); if (dow == i+1) { if (TNisColored()) { TNSetTextColorRGB(&prevColor, NULL); } else { // Draw some kind of underline to determine current day Int16 lineWidth=FntLineWidth(text, StrLen(text)); WinDrawLine(rect.topLeft.x+i*gGadgetDaysWidth+i+leftoff+1, rect.topLeft.y+FntLineHeight(), rect.topLeft.x+i*gGadgetDaysWidth+i+leftoff+1+lineWidth, rect.topLeft.y+FntLineHeight()); } } MemHandleUnlock(mh); } }
void clear_visible() { Short i, j; Short v_h = visible_h_itsy; Short v_w = visible_w_itsy; /* Clear the physical screen. */ RectangleType r; RctSetRectangle(&r, 0, 23, 160, 114); qWinEraseRectangle(&r, 0); /* Update 'terminal' to represent the cleared screen. */ for (i = 0 ; i < v_h; i++) { for (j = 0; j < v_w; j++) { terminal[i][j] = ' '; } } // do we need to set things in floor_info to "NEW"? }
static void TableDrawSelection(void *table, Int16 row, Int16 column, RectangleType *bounds) { RGBColorType red={0x00, 0xFF, 0x00, 0x00}; RectangleType r; RctSetRectangle(&r, bounds->topLeft.x, bounds->topLeft.y+(bounds->extent.y/2)-3, 4, 7); if (gExamsSelRow == row) { TNSetForeColorRGB(&red, NULL); // WinDrawRectangle(&r,0); WinDrawPixel(r.topLeft.x, r.topLeft.y+3); WinDrawLine(r.topLeft.x+1, r.topLeft.y+2, r.topLeft.x+1, r.topLeft.y+4); WinDrawLine(r.topLeft.x+2, r.topLeft.y+1, r.topLeft.x+2, r.topLeft.y+5); WinDrawLine(r.topLeft.x+3, r.topLeft.y, r.topLeft.x+3, r.topLeft.y+6); } else { WinEraseRectangle(&r, 0); } }
// Equivalent of "at". static void put_char_at(Short row, Short col, Char ch, Boolean bold) { Short cheat, vcheat = DunTopY + (itsy_on ? 0 : 0);//center the map vertically RectangleType r; Short vc_w = itsy_on ? visible_char_w_itsy : visible_char_w; Short vc_h = itsy_on ? visible_char_h_itsy : visible_char_h; RctSetRectangle(&r, col * vc_w, row*vc_h+vcheat, vc_w, vc_h); if (!my_prefs.black_bg || IsColor) WinEraseRectangle(&r, 0); else WinDrawRectangle(&r, 0); // calculate pixel position of "row, col" and put char there cheat = vc_w - FntCharWidth(ch); // center the variable width characters if (cheat <= 1) cheat = 0; else cheat /= 2; if (ch != ' ') { #ifdef I_AM_COLOR // if (IsColor) { // WinSetTextColor(get_color(ch, col+visible_x, row+visible_y)); // } #endif if (!itsy_on && (ch== 'g' || ch== 'j' || ch== 'p' ||ch == 'q' ||ch == 'y')) vcheat--; // unfortunately, letters with dangling bits are a pain. if (!my_prefs.black_bg || IsColor) WinDrawChars(&ch, 1, col * vc_w + cheat, row * vc_h+vcheat); else WinDrawInvertedChars(&ch, 1, col * vc_w + cheat, row * vc_h+vcheat); if (bold) WinInvertRectangle(&r, 0); /* 0 for square corners */ } terminal[row][col] = ch; }
void OSystem_PalmOS5::render_landscape15x(RectangleType &r, PointType &p) { Coord x, y, o = 0; uint16 *dst = _workScreenP; if (_overlayVisible) { uint16 *src = _overlayP; for (y = 0; y < 100; y++) { // draw 2 lines for (x = 0; x < 320; x++) { *dst++ = *src++; *dst++ = *src; *dst++ = *src++; } // copy the second to the next line MemMove(dst, dst - 480, 480 * 2); dst += 480; } } else { byte *src = _offScreenP; o = _current_shake_pos; for (y = 0; y < 100; y++) { // draw 2 lines for (x = 0; x < 320; x++) { *dst++ = _nativePal[*src++]; *dst++ = _nativePal[*src]; *dst++ = _nativePal[*src++]; } // copy the second to the next line MemMove(dst, dst - 480, 480 * 2); dst += 480; } } p.x = _screenOffset.x; p.y = _screenOffset.y + o; RctSetRectangle(&r, 0, 0, 480, 300 - o); }
void OSystem_PalmOS5::render_1x(RectangleType &r, PointType &p) { Coord o = 0; if (_overlayVisible) { uint16 *src = _overlayP; uint16 *dst = _workScreenP; MemMove(dst, src, _screenWidth * _screenHeight * 2); } else { byte *src = _offScreenP; uint16 *dst = _workScreenP; int cnt = _screenWidth * _screenHeight; o = _current_shake_pos; do { *dst++ = _nativePal[*src++]; } while (--cnt); } p.x = _screenOffset.x; p.y = _screenOffset.y + o; RctSetRectangle(&r, 0, 0, _screenWidth, _screenHeight - o); }
/***************************************************************************** * Function: GadgetTap * * Description: Handles penDown events (taps) on the gadget *****************************************************************************/ void GadgetTap(FormGadgetType *pGadget, EventType *event) { //you may find it useful to track if they //lift the pen still within the boundaries of the gadget Boolean isPenDown = true; Int16 newPointX, newPointY, startPointX, startPointY; UInt16 index; RectangleType bounds; // This is just needed since we do not want to access internal structure // data directly in FormGadgetType (need rect field below) index = TNGetObjectIndexFromPtr(FrmGetActiveForm(), pGadget); FrmGetObjectBounds(FrmGetActiveForm(), index, &bounds); //track the pen down event EvtGetPen(&newPointX, &newPointY, &isPenDown); startPointX = newPointX; startPointY = newPointY; while (isPenDown){ EvtGetPen(&newPointX, &newPointY, &isPenDown); } if (RctPtInRectangle(newPointX, newPointY, &bounds)) { /* the pen up was also in the gadget This can mean two things: 1) we got a strike command 2) a field was tapped */ RectangleType topRight, bottomRight; Boolean found=false, foundTime=false; MemHandle m; TimeDBRecord *t; UInt16 index=0, wantCourse=0, tmp3_4th=0; GadgetTimeListType *gtl; TNlist *tmpl; /* Check for stroke commands */ tmp3_4th = (3 * bounds.extent.x) / 4; RctSetRectangle(&topRight, bounds.topLeft.x+ tmp3_4th, bounds.topLeft.y, bounds.extent.x - tmp3_4th, bounds.extent.y/2 ); RctSetRectangle(&bottomRight, bounds.topLeft.x + tmp3_4th, bounds.topLeft.y + (bounds.extent.y/2), bounds.extent.x - tmp3_4th, bounds.extent.y / 2 ); if (RctPtInRectangle(startPointX, startPointY, &bottomRight) && RctPtInRectangle(newPointX, newPointY, &topRight) ) { // Stroke Command: BACK GadgetDrawStep(winUp); return; } else if (RctPtInRectangle(startPointX, startPointY, &topRight) && RctPtInRectangle(newPointX, newPointY, &bottomRight) ) { // Stroke Command: NEXT GadgetDrawStep(winDown); return; } tmpl = gGadgetTimeList; while (tmpl != NULL) { gtl = (GadgetTimeListType *)tmpl->data; if (RctPtInRectangle(newPointX, newPointY, &(gtl->rect))) { m = DmQueryRecord(DatabaseGetRef(), gtl->index); if (m) { // mt may be null, for example if next is drawn after delete! t = (TimeDBRecord *)MemHandleLock(m); // we got a match wantCourse = t->course; gTimeIndex = gtl->index; foundTime = true; MemHandleUnlock(m); } } tmpl = tmpl->next; } // Search for the clicked time if (foundTime) { index = 0; while(! found && ((m = DmQueryNextInCategory(DatabaseGetRef(), &index, DatabaseGetCat())) != NULL)) { Char *s = (Char *)MemHandleLock(m); if (s[0] == TYPE_COURSE) { CourseDBRecord c; UnpackCourse(&c, s); if (c.id == wantCourse) { SndPlaySystemSound(sndClick); gCourseIndex = index; found=true; } } MemHandleUnlock(m); index += 1; } } if (found && foundTime) { GadgetDrawHintCurrent(); } else { SndPlaySystemSound(sndError); } } // else outside gadget bounds -> do nothing }
/***************************************************************************** * Function: GadgetHintTap * * Description: Handles penDown events (taps) on the hint gadget *****************************************************************************/ void GadgetHintTap(FormGadgetType *pGadget, EventType *event) { //you may find it useful to track if they //lift the pen still within the boundaries of the gadget Boolean isPenDown = true; Int16 newPointX, newPointY, startPointX, startPointY; UInt16 index; RectangleType bounds, rect; Char noteSymb[2] = { GADGET_NOTESYMBOL, 0 }; FontID oldFont; Boolean drawn=false; IndexedColorType curForeColor, curBackColor, curTextColor; // This is just needed since we do not want to access internal structure // data directly in FormGadgetType (need rect field below) index = TNGetObjectIndexFromPtr(FrmGetActiveForm(), pGadget); FrmGetObjectBounds(FrmGetActiveForm(), index, &bounds); oldFont = FntSetFont(symbolFont); RctSetRectangle(&rect, bounds.topLeft.x+1, // +1 for border bounds.topLeft.y+1, // Put VALUE BELOW here.... +top+1 removed because of own Gadget bounds.extent.x-3, bounds.extent.y - 3); // -4 for bottom border RctSetRectangle(&rect, rect.topLeft.x+rect.extent.x-8, rect.topLeft.y+rect.extent.y-12, FntLineWidth(noteSymb, 1), FntLineHeight()); //track the pen down event EvtGetPen(&newPointX, &newPointY, &isPenDown); startPointX = newPointX; startPointY = newPointY; while (isPenDown){ EvtGetPen(&newPointX, &newPointY, &isPenDown); if (gHintNote) { if (! drawn && RctPtInRectangle(newPointX, newPointY, &rect)) { curForeColor = WinSetForeColor(UIColorGetTableEntryIndex(UIObjectSelectedForeground)); curBackColor = WinSetBackColor(UIColorGetTableEntryIndex(UIObjectSelectedFill)); curTextColor = WinSetTextColor(UIColorGetTableEntryIndex(UIObjectSelectedForeground)); TNDrawCharsToFitWidth(noteSymb, &rect); WinSetForeColor(curForeColor); WinSetForeColor(curBackColor); WinSetForeColor(curTextColor); drawn = true; } else if (drawn && ! RctPtInRectangle(newPointX, newPointY, &rect)) { curForeColor = WinSetForeColor(UIColorGetTableEntryIndex(UIObjectForeground)); curBackColor = WinSetBackColor(UIColorGetTableEntryIndex(UIObjectFill)); curTextColor = WinSetTextColor(UIColorGetTableEntryIndex(UIObjectForeground)); TNDrawCharsToFitWidth(noteSymb, &rect); WinSetForeColor(curForeColor); WinSetForeColor(curBackColor); WinSetForeColor(curTextColor); drawn = false; } } } FntSetFont(oldFont); if (gHintNote && RctPtInRectangle(newPointX, newPointY, &rect)) { NoteSet(GadgetGetHintTimeIndex(), FORM_main); FrmPopupForm(NewNoteView); } // else outside gadget bounds -> do nothing }
static Int16 myStroke(PointType * start, PointType * end, RexxletHackPrefs * prefs) { int i; UInt32 romVersion = 0; UInt16 n; PenBtnInfoPtr buttons; enum StrokeEnum from, to; enum StrokeEnum stroke; // The only way of doing things for older devices(?), // otherwise we should use the newer Palm APIs. RectangleType rApps; // = {{ 0, 161}, { 24, 32}}; RectangleType rMenu; // = {{ 0, 191}, { 24, 32}}; RectangleType rCalc; // = {{136, 161}, { 24, 32}}; RectangleType rFind; // = {{136, 191}, { 24, 32}}; RectangleType rGrff; // = {{ 27, 161}, {107, 60}}; RectangleType rGrfA; // = {{ 27, 161}, { 70, 60}}; RectangleType rGrfN; // = {{100, 161}, { 34, 60}}; RectangleType rScrn; // = {{ 0, 0}, {160, 160}}; RctSetRectangle(&rApps, 0, 161, 24, 32); RctSetRectangle(&rMenu, 0, 191, 24, 32); RctSetRectangle(&rCalc, 136, 161, 24, 32); RctSetRectangle(&rFind, 136, 191, 24, 32); RctSetRectangle(&rGrff, 27, 161, 107, 60); RctSetRectangle(&rGrfA, 27, 161, 70, 60); RctSetRectangle(&rGrfN, 100, 161, 34, 60); RctSetRectangle(&rScrn, 0, 0, 160, 160); RectangleType * prApps = (RectangleType *)&rApps; RectangleType * prMenu = (RectangleType *)&rMenu; RectangleType * prCalc = (RectangleType *)&rCalc; RectangleType * prFind = (RectangleType *)&rFind; RectangleType * prGrff = (RectangleType *)&rGrff; RectangleType * prGrfA = (RectangleType *)&rGrfA; RectangleType * prGrfN = (RectangleType *)&rGrfN; RectangleType * prScrn = (RectangleType *)&rScrn; buttons = (PenBtnInfoPtr)EvtGetPenBtnList(&n); for (i = 0; i < n; ++i) { if (buttons[i].asciiCode == launchChr) prApps = &buttons[i].boundsR; else if (buttons[i].asciiCode == menuChr) prMenu = &buttons[i].boundsR; else if (buttons[i].asciiCode == calcChr) prCalc = &buttons[i].boundsR; else if (buttons[i].asciiCode == findChr) prFind = &buttons[i].boundsR; } if (RctPtInRectangle(start->x, start->y, prApps)) from = STROKEFROM_APPS; else if (RctPtInRectangle(start->x, start->y, prMenu)) from = STROKEFROM_MENU; else if (RctPtInRectangle(start->x, start->y, prCalc)) from = STROKEFROM_CALC; else if (RctPtInRectangle(start->x, start->y, prFind)) from = STROKEFROM_FIND; else return -1; /* err = FtrGet(sysFtrCreator, sysFtrNumROMVersion, &romVersion); if (romVersion >= sysMakeROMVersion(3, 5, 0,sysROMStageRelease, 0)) { const SilkscreenAreaType * silkscreen = EvtGetSilkscreenAreaList(&n); for (i = 0; i < n; ++i) { if (silkscreen[i].areaType == silkscreenRectGraffiti && silkscreen[i].index == alphaGraffitiSilkscreenArea) { prGrfA = (RectangleType *)&silkscreen[i].bounds; } else if (silkscreen[i].areaType == silkscreenRectGraffiti && silkscreen[i].index == numericGraffitiSilkscreenArea) { prGrfN = (RectangleType *)&silkscreen[i].bounds; } } //<<<JAL TODO get extent of a & n for whole graffiti area prGrff->left = (prGrfA->left < prGrfN->left)? prGrfA->left : prGrfN->left; prGrff->top = (prGrfA->top < prGrfN->top)? prGrfA->top : prGrfN->top; } */ if (RctPtInRectangle(end->x, end->y, prApps)) to = STROKETO_APPS; else if (RctPtInRectangle(end->x, end->y, prMenu)) to = STROKETO_MENU; else if (RctPtInRectangle(end->x, end->y, prCalc)) to = STROKETO_CALC; else if (RctPtInRectangle(end->x, end->y, prFind)) to = STROKETO_FIND; else if (RctPtInRectangle(end->x, end->y, prGrff)) to = STROKETO_GRAF; else if (RctPtInRectangle(end->x, end->y, prScrn)) to = STROKETO_SCRN; else return -1; stroke = (enum StrokeEnum)(from | to); for (i = 0; i < RexxletHackPrefs__numberOfStrokes(prefs); ++i) { if (stroke == RexxletHackPrefs__stroke(prefs, i)) { if (RexxletHackPrefs__strokeIsEnabled(prefs, i)) { return i; } return -1; } } return -1; }
/* ** TrackXferDone */ static void TrackXferDone(DynamicButtonType* btn) { RectangleType bounds[5], frame, popFrame, popShadowFrame; Boolean penDown, on_button; Int16 x, y, clicked_on = 0; Int16 state = 1; Int16 i = 0; WinHandle offscreenH = NULL; FormType* frm = FrmGetActiveForm(); const UInt16 listIdx = FrmGetObjectIndex(frm, XferDoneList); ListType* list = FrmGetObjectPtr(frm, listIdx); UInt16 width = 0, choices = 0; Err err = errNone; Char str[48]; Int16 n = 0; /* Save the old drawing context */ WinPushDrawState(); /* This should match the XferDoneButton bounds */ FrmGetObjectBounds(frm, FrmGetObjectIndex(frm, btn->id), &bounds[0]); /* Invert the done button */ SelectAndDrawButton(btn, true); SndPlaySystemSound(sndClick); /* Set the status of each menu pick */ for (; i < 4; i++) d.xfer.status[i] = 0x00; if (xferGotoIsAlways) d.xfer.status[0] = TRACKXFERDONE_ALWAYS; else if (xferGotoIsNever) d.xfer.status[0] = TRACKXFERDONE_NEVER; else if (p.flags&PFLAGS_XFER_GOTO) d.xfer.status[0] = TRACKXFERDONE_CHECKED; if (xferCompleteIsAlways) d.xfer.status[1] = TRACKXFERDONE_ALWAYS; else if (xferCompleteIsNever) d.xfer.status[1] = TRACKXFERDONE_NEVER; else if (d.xfer.complete) d.xfer.status[1] = TRACKXFERDONE_CHECKED; if (!d.linker_available) d.xfer.status[2] = TRACKXFERDONE_NEVER; else if (p.flags&PFLAGS_XFER_BACKLINK) d.xfer.status[2] = TRACKXFERDONE_CHECKED; if (p.flags&PFLAGS_XFER_DELETE) d.xfer.status[3] = TRACKXFERDONE_CHECKED; for (i = 0; i < 4; ++i) { if (!(d.xfer.status[i] & TRACKXFERDONE_NEVER)) { d.xfer.choice_map[choices] = i; ++choices; /* calculate list width */ SysCopyStringResource(str, XferMenuOptionsStrings + i); n = FntCharsWidth(str, StrLen(str)); width = Max(width, n); } } LstSetDrawFunction(list, XferDoneListDrawFunc); LstSetListChoices(list, 0, choices); LstSetHeight(list, Min(choices, 10)); FrmGetObjectBounds(frm, listIdx, &frame); frame.topLeft.y = 144 - frame.extent.y - 1; /* -1 to compensate for white border */ frame.extent.x = width + 15 + 6; FrmSetObjectBounds(frm, listIdx, &frame); WinGetFramesRectangle(popupFrame, &frame, &popFrame); WinGetFramesRectangle(rectangleFrame, &popFrame, &popShadowFrame); for (i = 0; i < choices; ++i) RctSetRectangle(&bounds[i+1], frame.topLeft.x, frame.topLeft.y + 10 * i, frame.extent.x, 10); /* Save the bits of the whole menu */ offscreenH = WinSaveBits(&popShadowFrame, &err); if (err) abort(); /* None selected */ LstSetSelection(list, -1); FrmShowObject(frm, listIdx); WinEraseRectangle(&popShadowFrame, 0); LstDrawList(list); WinEraseRectangleFrame(rectangleFrame, &frame); WinDrawRectangleFrame(popupFrame, &frame); do { EvtGetPen(&x, &y, &penDown); if (!state || !RctPtInRectangle(x, y, &bounds[state-1])) { on_button = false; for (i = 1; i <= choices + 1; i++) { if ((state != i) && RctPtInRectangle(x, y, &bounds[i-1])) { /* Invert the new state */ LstSetSelection(list, i - 2); LstDrawList(list); WinEraseRectangleFrame(rectangleFrame, &frame); WinDrawRectangleFrame(popupFrame, &frame); SelectAndDrawButton(btn, i == 1); state = i; on_button = true; } } if (state && !on_button) { /* Moved off the current button */ LstSetSelection(list, -1); LstDrawList(list); WinEraseRectangleFrame(rectangleFrame, &frame); WinDrawRectangleFrame(popupFrame, &frame); if (state == 1) SelectAndDrawButton(btn, false); state = 0; } } } while (penDown); FrmHideObject(frm, listIdx); LstEraseList(list); /* Restore the framed rect */ WinRestoreBits(offscreenH, popShadowFrame.topLeft.x, popShadowFrame.topLeft.y); /* Unselect the button */ SelectAndDrawButton(btn, false); /* Finish up if we just tapped the button */ if (RctPtInRectangle(x, y, &bounds[0])) { FinishXferMode(); /* Restore the old draw state */ WinPopDrawState(); return; } /* Change the setting for goto or delete */ for (i = 1; i <= choices; i++) { if (RctPtInRectangle(x, y, &bounds[i])) { clicked_on = i; break; } } if (clicked_on) clicked_on = d.xfer.choice_map[clicked_on-1] + 1; switch (clicked_on) { case 1: /* Goto */ if (d.xfer.status[0] & TRACKXFERDONE_CHECKED) p.flags &= ~PFLAGS_XFER_GOTO; else if (!d.xfer.status[0]) p.flags |= PFLAGS_XFER_GOTO; break; case 2: /* Complete */ if (d.xfer.status[1] & TRACKXFERDONE_CHECKED) d.xfer.complete = false; else if (!d.xfer.status[1]) d.xfer.complete = true; break; case 3: /* BackLink */ if (d.xfer.status[2] & TRACKXFERDONE_CHECKED) p.flags &= ~PFLAGS_XFER_BACKLINK; else if (!d.xfer.status[2]) { p.flags |= PFLAGS_XFER_BACKLINK; p.flags &= ~PFLAGS_XFER_DELETE; /* No delete if backlink */ } break; case 4: /* Delete */ if (d.xfer.status[3] & TRACKXFERDONE_CHECKED) p.flags &= ~PFLAGS_XFER_DELETE; else if (!d.xfer.status[3]) { p.flags |= PFLAGS_XFER_DELETE; p.flags &= ~PFLAGS_XFER_BACKLINK; /* No backlink if delete */ } break; } /* Click and redraw the button */ if (clicked_on) { DrawXferDoneButton(btn); DynBtnDraw(btn); if (d.xfer.status[clicked_on-1] & TRACKXFERDONE_ALWAYS) SndPlaySystemSound(sndWarning); else SndPlaySystemSound(sndClick); } /* Restore the old draw state */ WinPopDrawState(); }
/***************************************************************************** * Function: GadgetDraw * * Description: Draws the basic gadget (grid, days, times) *****************************************************************************/ void GadgetDraw(Boolean eraseFirst) { RectangleType bounds; UInt8 i, gadgetWidth; RGBColorType color, prevColor; UInt16 gadgetIndex; RectangleType rect; FormType *frm=gForm; // Check if GadgetSet has already been called. If not => die if (! frm) return; gadgetIndex = FrmGetObjectIndex(frm, gGadgetID); FrmGetObjectBounds(frm, gadgetIndex, &bounds); // Erase background if (eraseFirst) WinEraseRectangle(&bounds, 0); // Write Times if (gGadgetCurScreen == GADGET_SCREEN_DAY) { for (i=0; i < 7; i++) { // 7 because we have to write 7 times 08:00, 10:00,..., 20:00 Char time[timeStringLength]; if (i < 1) StrPrintF(time, "0%u:00", 8+i*2); else StrPrintF(time, "%u:00", 8+i*2); WinDrawChars(time, StrLen(time), bounds.topLeft.x+GADGET_BASELEFT, (i != 7 - 1) ? bounds.topLeft.y+GADGET_STRINGS_TOP+i*GADGET_STRINGS_OFFSET /* ^last^ */ : bounds.topLeft.y+GADGET_STRINGS_TOP+i*GADGET_STRINGS_OFFSET-2); } } else { for (i=0; i < 2; i++) { Char time[timeStringLength]; StrPrintF(time, "%u:00", 20+i*2); WinDrawChars(time, StrLen(time), bounds.topLeft.x+GADGET_BASELEFT, bounds.topLeft.y+GADGET_STRINGS_TOP+i*GADGET_STRINGS_OFFSET); } for (i=2; i < 7; i++) { Char time[timeStringLength]; StrPrintF(time, "0%u:00", (i-2)*2); WinDrawChars(time, StrLen(time), bounds.topLeft.x+GADGET_BASELEFT, (i != 7 - 1) ? bounds.topLeft.y+GADGET_STRINGS_TOP+i*GADGET_STRINGS_OFFSET /* ^last^ */ : bounds.topLeft.y+GADGET_STRINGS_TOP+i*GADGET_STRINGS_OFFSET-2); } } // Write Weekdays GadgetDrawWeekdays(); // Draw Grid: Color is light gray on colored palms, dark gray on gray palms if (TNisColored()) { color.r = 0x77; color.g = 0x77; color.b = 0x77; } else { color.r = 0x44; color.g = 0x44; color.b = 0x44; } TNSetForeColorRGB(&color, &prevColor); gadgetWidth=gGadgetDaysNum * gGadgetDaysWidth + gGadgetDaysNum - 1; RctSetRectangle(&rect, bounds.topLeft.x+GADGET_BASELEFT+GADGET_LEFT, bounds.topLeft.y+GADGET_TOP, gadgetWidth, GADGET_HEIGHT); WinDrawRectangleFrame(simpleFrame, &rect); for(i=1; i <= 5; ++i) { // Draw the 5 gray dashed lines if ( (gGadgetCurScreen == GADGET_SCREEN_NIGHT) && (i == 2)) { WinDrawLine(bounds.topLeft.x+GADGET_BASELEFT+GADGET_LEFT, bounds.topLeft.y+GADGET_TOP+i*GADGET_STRINGS_OFFSET, bounds.topLeft.x+GADGET_BASELEFT+GADGET_LEFT+gadgetWidth-1, bounds.topLeft.y+GADGET_TOP+i*GADGET_STRINGS_OFFSET); } else { WinDrawGrayLine(bounds.topLeft.x+GADGET_BASELEFT+GADGET_LEFT, bounds.topLeft.y+GADGET_TOP+i*GADGET_STRINGS_OFFSET, bounds.topLeft.x+GADGET_BASELEFT+GADGET_LEFT+gadgetWidth-1, bounds.topLeft.y+GADGET_TOP+i*GADGET_STRINGS_OFFSET); } } for(i=1; i <= gGadgetDaysNum -1; ++i) { WinDrawLine(bounds.topLeft.x+GADGET_BASELEFT+GADGET_LEFT+i*gGadgetDaysWidth+(i-1), bounds.topLeft.y+GADGET_TOP, bounds.topLeft.x+GADGET_BASELEFT+GADGET_LEFT+i*gGadgetDaysWidth+(i-1), bounds.topLeft.y+GADGET_TOP+GADGET_HEIGHT-1); } TNSetForeColorRGB(&prevColor, NULL); }
/***************************************************************************** * Function: GadgetDrawHintCurrent * * Description: Draw hint for current gTimeIndex if needed (may be forced NOT * to draw with GadgetSetNeedsRedraw(false)); *****************************************************************************/ void GadgetDrawHintCurrent(void) { Char *tmp, *bot, begin[timeStringLength], end[timeStringLength], *day; MemHandle mc, mt, mh, type; CourseDBRecord c; TimeDBRecord *tc; RectangleType rect, bounds; UInt16 gadgetIndex = FrmGetObjectIndex(gForm, gGadgetID); RGBColorType color, prevColor; UInt16 attr; // Need to check that due to damn f*** DmRecordInfo which will show a // fatal alert when called on non-existing record (this happens for example // right after creating the new database... if ((gTimeIndex >= DmNumRecords(DatabaseGetRef())) || (gCourseIndex >= DmNumRecords(DatabaseGetRef())) ) return; if (gHintDrawn) { // Delete border around previous entry if ( (gTimeDrawnIndex < DmNumRecords(DatabaseGetRef())) && (DmRecordInfo(DatabaseGetRef(), gTimeDrawnIndex, &attr, NULL, NULL) == errNone) ) { attr &= dmRecAttrCategoryMask; if (attr == DatabaseGetCat()) { mt = DmQueryRecord(DatabaseGetRef(), gTimeDrawnIndex); if (mt) { // mt may be null, for example if next is drawn after delete! tc = (TimeDBRecord *)MemHandleLock(mt); if ((tc->type == TYPE_TIME) && GadgetEventIsVisible(tc) ) { TNlist *tmpl = gGadgetTimeList; GadgetTimeListType *gtl = NULL; while (tmpl != NULL) { gtl = tmpl->data; if (gtl->index == gTimeDrawnIndex) { break; } tmpl = tmpl->next; } color.r=tc->color[0]; color.g=tc->color[1]; color.b=tc->color[2]; if (gPrefs.showTimeline) GadgetDrawTimeline(gtErase); if (gtl != NULL) { GadgetDrawTime(tc->begin, tc->end, tc->day, &color, tc->course, gtl->num, gtl->pos); } if (gPrefs.showTimeline) GadgetDrawTimeline(gtDraw); } MemHandleUnlock(mt); } } } } gTimeDrawnIndex=gTimeIndex; gHintDrawn=true; if (DmRecordInfo(DatabaseGetRef(), gCourseIndex, &attr, NULL, NULL) == errNone) { attr &= dmRecAttrCategoryMask; if (attr == DatabaseGetCat()) { // Record is in currently displayed category mc = DmQueryRecord(DatabaseGetRef(), gCourseIndex); if (! mc) return; mt = DmQueryRecord(DatabaseGetRef(), gTimeIndex); if (! mt) return; UnpackCourse(&c, MemHandleLock(mc)); tc = (TimeDBRecord *)MemHandleLock(mt); if ( GadgetEventIsVisible(tc) ) { TNlist *tmpl = gGadgetTimeList; GadgetTimeListType *gtl = NULL; while (tmpl != NULL) { gtl = tmpl->data; if (gtl->index == gTimeDrawnIndex) { break; } tmpl = tmpl->next; } mh = DmGetResource(strRsc, GADGET_STRINGS_WDAYSTART+tc->day); day = (Char *)MemHandleLock(mh); // Lecture Name (Teacher) [Typ] tmp=(Char *)MemPtrNew(StrLen(c.name)+StrLen(c.teacherName)+4+3+CTYPE_SHORT_MAXLENGTH); MemSet(tmp, MemPtrSize(tmp), 0); type = MemHandleNew(1); CourseTypeGetShort(&type, c.ctype); StrPrintF(tmp, "%s (%s) [%s]", c.name, c.teacherName, (Char *)MemHandleLock(type)); MemHandleUnlock(type); MemHandleFree(type); // Fr 08:00 - 09:30 (Room) <-- Example // 3 5 3 5 3+StrLen(room) <-- Num Chars for MemPtrNew bot=(Char *)MemPtrNew(20+sizeof(tc->room)+MemPtrSize(day)); MemSet(bot, MemPtrSize(bot), 0); TimeToAscii(tc->begin.hours, tc->begin.minutes, GadgetGetTimeFormat(), begin); TimeToAscii(tc->end.hours, tc->end.minutes, GadgetGetTimeFormat(), end); mh = DmGetResource(strRsc, GADGET_STRINGS_WDAYSTART+tc->day); StrPrintF(bot, "%s %s - %s (%s)", day, begin, end, tc->room); FrmGetObjectBounds(gForm, gadgetIndex, &bounds); if (gtl != NULL) { GadgetTimeSetRect(&rect, tc->begin, tc->end, tc->day, gtl->num, gtl->pos); RctSetRectangle(&rect, // + inset (two boxes, one black, one white) rect.topLeft.x + 2, rect.topLeft.y + 2, // width - 2 * inset rect.extent.x - 4, // height - 2 * inset rect.extent.y - 4 ); /* Invert color, looks not so nice aka bad color.r=255- tc->color[0]; color.g=255- tc->color[1]; color.b=255- tc->color[2]; */ color.r=255; color.g=255; color.b=255; TNSetForeColorRGB(&color, &prevColor); WinDrawRectangleFrame(simpleFrame, &rect); color.r=0; color.g=0; color.b=0; RctSetRectangle(&rect, rect.topLeft.x-1, rect.topLeft.y-1, rect.extent.x+2, rect.extent.y+2); TNSetForeColorRGB(&color, NULL); WinDrawRectangleFrame(simpleFrame, &rect); TNSetForeColorRGB(&prevColor, NULL); } // WinInvertRectangleFrame(simpleFrame, &rect); GadgetDrawHint(tmp, bot, tc->note); MemPtrFree((MemPtr) tmp); MemPtrFree((MemPtr) bot); MemHandleUnlock(mh); } else { MemHandleUnlock(mc); MemHandleUnlock(mt); GadgetDrawHintNext(); return; } MemHandleUnlock(mc); MemHandleUnlock(mt); } // End attr == current category } }