/* * This function is based on the DrawIntro and DrawBlinds * functions in Vexed, a Cool GPL Palm Game by * "James McCombe" <*****@*****.**> * http://spacetube.tsx.org */ void DrawIntro () { VoidHand Title_Handle; BitmapPtr Title; char text[40]; SWord penx, peny; Boolean bstate; /* If a game is on, don't do the splash */ if( stor.currplayer >= 0 ) return; // load bitmap resource and get handle Title_Handle = DmGet1Resource ('Tbmp', bmpTitle); // lock the bitmap resource into memory and get a pointer to it Title = MemHandleLock (Title_Handle); // draw the bitmap ( 160x160 ) WinDrawBitmap (Title, 0, 0); /* Text Strings */ StrPrintF (text, IntroVersionString, VERSION); WinDrawChars (text, StrLen (text), 5, 6); StrPrintF (text, IntroForPalmString, 153); WinDrawChars (text, StrLen (text), 52, 50); StrPrintF (text, IntroTapHereString, VERSION); WinDrawChars (text, StrLen (text), 45, 85); // unload the bitmap from memory (unlock) MemHandleUnlock (Title_Handle); // Loop till screen is tapped while (bstate) EvtGetPen (&penx, &peny, &bstate); while (!bstate) EvtGetPen (&penx, &peny, &bstate); /* If the user clicked in the drawing area, then * do a Draw Blinds and clear the PenQueue. */ if( peny < 160 ) { // DrawBlinds int i, x; float delay; EvtFlushPenQueue(); delay = .01 * SysTicksPerSecond(); for (i = 0; i < 16; i++) { for (x = i; x < 160; x += 16) { WinEraseLine( 0,x, 159,x ); } SysTaskDelay(delay); } } /* if( peny < 160 ) */ }
/* Callback function that draws list items */ static void DrawListItem ( Int16 itemNum, /* item number */ RectangleType* bounds, /* pointer to a RectangleType structure that specifies the bounds for the list item */ Char** itemsText /* pointer to an array of text strings */ ) { FontID oldFont; FontID newFont; if ( bookmarkList[ itemNum ] == NULL ) return; switch ( bookmarkList[ itemNum ]->kind ) { case BOOKMARK_ANNOTATION: case BOOKMARK_BOOKMARK: newFont = stdFont; break; default: newFont = boldFont; break; } oldFont = FntSetFont( newFont ); if ( itemsText[ itemNum ] != NULL ) WinDrawChars( itemsText[ itemNum ], StrLen( itemsText[ itemNum ] ), bounds->topLeft.x, bounds->topLeft.y ); FntSetFont( oldFont ); }
/* Callback function that draws list items */ static void DrawListItem ( Int16 itemNum, /* item number */ RectangleType* bounds, /* pointer to a RectangleType structure that specifies the bounds for the list item */ Char** itemsText /* pointer to an array of text strings */ ) { FontID oldFont; if ( isPopupList && ( itemNum == ADD_BOOKMARK || itemNum == EDIT_BOOKMARK || itemNum <= CountExtBookmarks() + 1 ) ) oldFont = FntSetFont( boldFont ); else if ( itemNum < CountExtBookmarks() ) oldFont = FntSetFont( boldFont ); else oldFont = FntSetFont( stdFont ); if ( itemsText[ itemNum ] != NULL ) WinDrawChars( itemsText[ itemNum ], StrLen( itemsText[ itemNum ] ), bounds->topLeft.x, bounds->topLeft.y ); FntSetFont( oldFont ); }
/*********************************************************************** * * FUNCTION: PrvTimeZoneListDrawItem * * DESCRIPTION: Draw the itemNum item of the time zone list. Used as draw * callback routine for the time zone list object. * * PARAMETERS: * itemNum -> what item to draw * bounds -> rectangle to draw into * itemsText -> ptr to array of TimeZoneEntryType records. * * RETURNED: nothing * * HISTORY: * 03/07/00 peter initial revision * 07/31/00 kwk Modified to use TimeZoneEntryType records. * ***********************************************************************/ static void PrvTimeZoneListDrawItem(Int16 itemNum, RectanglePtr bounds, Char** itemsText) { const TimeZoneEntryType* tzList = (const TimeZoneEntryType*)itemsText; Char gmtOffset[maxGmtOffsetLength + 1]; // Skip to appropriate item to draw. tzList += itemNum; // Draw the name left-justified, and truncated. // DOLATER kwk - should we worry about the text in ZeroTimeZoneOffsetString // being wider than gmtOffsetColumnWidth? WinDrawTruncChars(tzList->tzName, StrLen(tzList->tzName), bounds->topLeft.x + descriptionColumnOffset, bounds->topLeft.y, usableListWidth - descriptionColumnOffset - gmtOffsetColumnWidth); // Draw the offset right-justified. if (tzList->tzOffset == 0) { SysCopyStringResource(gmtOffset, ZeroTimeZoneOffsetString); } else { PrvOffsetToString(gmtOffset, tzList->tzOffset); } WinDrawChars( gmtOffset, StrLen(gmtOffset), bounds->topLeft.x + usableListWidth - gmtColumnOffset - FntCharsWidth(gmtOffset, StrLen(gmtOffset)), bounds->topLeft.y); } // PrvTimeZoneListDrawItem
void Graphics::drawText(const char_t* text, ulong_t length, const Point& topLeft, bool inverted) { FontEffects fx = font_.effects(); PalmUnderlineSetter setUnderline(convertUnderlineMode(fx.underline())); ScalingSetter setScaling(*this); uint_t height = fontHeight(); uint_t top=topLeft.y; if (fx.subscript()) top+=(height/3); if (inverted) WinDrawInvertedChars(text, length, topLeft.x, top); else WinDrawChars(text, length, topLeft.x, top); if (fx.strikeOut()) { uint_t baseline = fontBaseline(); top=topLeft.y + (baseline*2)/3; uint_t width = FntCharsWidth(text, length); Color_t color=setTextColor(0); setTextColor(color); // Quite strange method of querying current text color... color=setForegroundColor(color); WinDrawOperation old; if (inverted) old=WinSetDrawMode(winInvert); drawLine(topLeft.x, top, topLeft.x+width, top); if (inverted) WinSetDrawMode(old); setForegroundColor(color); } }
Boolean v4pDisplayError(char *formatString, ...) { va_list args ; Char text[0x100] ; va_start(args, formatString) ; StrVPrintF(text, formatString, args) ; va_end(args); WinDrawChars(text, StrLen(text), 0, 0) ; }
/*------------------------------------------------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; }
void _WinDrawChars(const Char *chars, Int16 len, Coord x, Coord y) { if (hires) HRWinDrawChars(hires, chars, len, x, y); else WinDrawChars(chars, len, x, y); }
//------------------------------------------------------------------------ // Clears the screen on the palm device // void ClearScreen(int row) { #ifdef __MC68K__ int i; for(i=row;i<16;i++) WinDrawChars((char *) " ",80,5,i*10); #endif }
/* ** Draw transfer list. */ static void XferListDrawFunc(Int16 item, RectangleType* b, Char** itemsText) { const Int16 absolute_item = PlugIndex(item, false); Char str[48]; DrawPlugBitmap(absolute_item, boogerID_lilbutton, b->topLeft.x, b->topLeft.y + 1); GetPlugString(absolute_item, boogerID_plugname, str); WinDrawChars(str, StrLen(str), b->topLeft.x + 19, b->topLeft.y); }
// Right justify. Short WinDrawChars_rj(Char *buf, Short len, Short x_right, Short y) { Short x, width; width = FntCharsWidth(buf, len); x = x_right - width; if (x < 0) x = 0; WinDrawChars(buf, len, x, y); return x; }
// Draw text centered around x_mid, at y. Short WinDrawChars_ctr(Char *buf, Short len, Short x_mid, Short y) { Short x, width; width = FntCharsWidth(buf, len); x = x_mid - width / 2; if (x < 0) x = 0; WinDrawChars(buf, len, x, y); return x; }
/***************************************************************************** * 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); } }
static void ListDrawDataFunc(Int16 itemNum, RectangleType *bounds, Char **itemsText) { char string[20]; StrNCopy(string, GetDisplayString(itemNum), 19); WinSetUnderlineMode(noUnderline); FntSetFont(stdFont); Int16 width = bounds->extent.x; Int16 len = StrLen(string); Boolean noFit = false; FntCharsInWidth(string, &width, &len, &noFit); WinEraseRectangle(bounds, 0); WinDrawChars(string, len, bounds->topLeft.x, bounds->topLeft.y); }
static void XferDoneListDrawFunc(Int16 item, RectangleType* b, Char** itemsText) { Char str[48]; const FontID old_font = FntSetFont(symbol11Font); if (d.xfer.status[d.xfer.choice_map[item]] & TRACKXFERDONE_ALWAYS) { FntSetFont(symbolFont); WinDrawChar('\23', b->topLeft.x + 3, b->topLeft.y); /* diamond */ } else if (d.xfer.status[d.xfer.choice_map[item]] & TRACKXFERDONE_CHECKED) { WinDrawChar('\01', b->topLeft.x, b->topLeft.y); /* completed checkbox */ } else { WinDrawChar('\00', b->topLeft.x, b->topLeft.y); /* empty checkbox */ } FntSetFont(old_font); SysCopyStringResource(str, XferMenuOptionsStrings + d.xfer.choice_map[item]); /* Draw the text label on the right pos (* 1.5 for HandEra) */ WinDrawChars(str, StrLen(str), b->topLeft.x + handera(15), b->topLeft.y); }
void HanderaUpdateSilkVerticalOffset ( const Char* offText ) { WinHandle silkWindow, origWindow; FontID origFont; silkWindow = SilkGetWindow(); origWindow = WinSetDrawWindow( silkWindow ); origFont = FntSetFont( stdFont ); WinEraseRectangle( &( iconList[ 1 ].bounds[ currentSilkStatus ] ), 0 ); WinDrawChars( offText, StrLen( offText ), iconList[ 1 ].bounds[ currentSilkStatus ].topLeft.x, iconList[ 1 ].bounds[ currentSilkStatus ].topLeft.y ); FntSetFont( origFont ); WinSetDrawWindow( origWindow ); }
// 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; }
static void ListDrawDataFunc(Int16 itemNum, RectangleType *bounds, Char **itemsText) { char string[50]; if (itemNum < g_PhoneGroups.size()) { PhoneGroupPtr group = g_PhoneGroups[itemNum]; StrNCopy(string, group->GetGroupName(), 49); } else { StrCopy(string, ""); } WinSetUnderlineMode(noUnderline); FntSetFont(stdFont); Int16 width = bounds->extent.x; Int16 len = StrLen(string); Boolean noFit = false; FntCharsInWidth(string, &width, &len, &noFit); WinEraseRectangle(bounds, 0); WinDrawChars(string, len, bounds->topLeft.x, bounds->topLeft.y); }
/* write document name in details form */ static void AddDocNameTitle ( Char* name ) { FontID oldFont; Coord x; Coord y; UInt16 oldCoordSys; oldCoordSys = PalmSetCoordinateSystem( STANDARD ); oldFont = FntSetFont( HiResFont( boldFont ) ); x = ( MaxExtentX() - FntCharsWidth( name, StrLen( name ) ) ) / 2; y = 20; HiResAdjust( &y, sonyHiRes | handeraHiRes ); WinDrawChars( name, StrLen( name ), x, y ); FntSetFont( oldFont ); PalmSetCoordinateSystem( oldCoordSys ); }
static void BookmarksListDrawFunc(Int16 itemNum, RectangleType * bounds, char **data) { Int16 stringWidthP = 160; // max width of the string in the list selection window Int16 stringLenP; Boolean truncatedP = false; MemHandle recHandle; char * str; AppContext* appContext=GetAppContext(); Assert(itemNum >= 0); recHandle = DmQueryRecord(appContext->bookmarksDb, itemNum); Assert(recHandle); // no reason it shouldn't work if (recHandle) { str = (char*)MemHandleLock(recHandle); stringLenP = StrLen(str); FntCharsInWidth(str, &stringWidthP, &stringLenP, &truncatedP); WinDrawChars(str, stringLenP, bounds->topLeft.x, bounds->topLeft.y); MemHandleUnlock(recHandle); } }
//-------------------------------------------------------------------------- // output status message // void output_status(int level, char *st) { char *p; static char linebuf[256]; static int cnt = 0; // skip null strings if (st[0] == 0) return; // check if in verbose mode if ((level >= LV_ALWAYS) || VERBOSE) { // look for embedded \n for (p = st; *p; p++) { if (*p == 0x0A || ((cnt>33) && (*p==' ')) || (*(p + 1) == 0)) { // zero terminate the line linebuf[cnt] = 0; // print it out ???????? replace #ifndef __MC68K__ printf("%s",linebuf); #else WinDrawChars(linebuf,StrLen(linebuf),5,10*current_line++); #endif // check if too many lines if (current_line == MAXLINE) reset_screen(); cnt = 0; } else linebuf[cnt++] = *p; } } }
/* Display the example font character centred in the given object ID */ void DisplayChar ( FontID fontID, /* font to print */ const char letter, /* letter to display */ FormType* form, /* pointer form to print to */ UInt16 objID /* object to print in form */ ) { RectangleType bounds; Coord x; Coord y; #ifdef HAVE_GRAY_FONT Char orientation; orientation = GrayFntSetOrientation( GRAY_FONT_NORMAL ); #endif FrmGetObjectBounds( form, FrmGetObjectIndex( form, objID ), &bounds ); FntSetFont( fontID ); /* double our input values for sony */ HiResAdjustBounds( &bounds, sonyHiRes ); /* find approximate centered position for character */ x = bounds.topLeft.x + ( bounds.extent.x / 2 ) - ( FntCharWidth( letter ) / 2 ); y = bounds.topLeft.y + ( bounds.extent.y / 2 ) - ( FntCharHeight() / 2 ); WinDrawChars( &letter, 1, x, y ); #ifdef HAVE_GRAY_FONT GrayFntSetOrientation( orientation ); #endif }
static Boolean MainFormHandleEvent (EventPtr e) { Boolean handled = false; FormPtr frm; static UInt32 start_sec=0; static UInt32 start_tik; static UInt32 end_sec; static UInt32 end_tik; //static int run = 0; switch (e->eType) { case frmOpenEvent: frm = FrmGetActiveForm(); FrmDrawForm(frm); // resume interrupted count // note now stopWatchPrefs.tik_timestamp != stopWatchPrefs.timestamp // now this does work okay when switching away from app BUT // not when palm is turned off & on but stays in app // I think possibly GetTicks gets ticks from start of app // when palm off the ticks do not increment if (stopWatchPrefs.timestamp != 0) { stopWatchPrefs.tik_timestamp = TimGetSeconds(); start_tik = TimGetTicks(); RunCount(start_tik); } handled = true; break; case menuEvent: MenuEraseStatus(NULL); switch(e->data.menu.itemID) { // TODO add to TestTemp code //case itemBar: case itemRun: if (start_sec == 0) { stopWatchPrefs.tik_timestamp = stopWatchPrefs.timestamp = start_sec = TimGetSeconds(); start_tik = TimGetTicks(); } RunCount(start_tik); break; case itemHold: // break the run loop run = 0; break; case itemStop: // break the run loop run = 0; end_sec = TimGetSeconds(); end_tik = TimGetTicks(); break; case itemClear: // break the run loop run = 0; start_sec = 0; stopWatchPrefs.timestamp = 0; stopWatchPrefs.tik_timestamp = 0; end_tik = 0; drawCount(0); break; case itemPrefs: FrmPopupForm(PrefForm); break; case itemTest1: WinDrawLine(20,20,50,50); //void WinDrawChar (WChar theChar, Coord x, Coord y) ///void WinDrawChars (const Char *chars, Int16 len, Coord x, Coord y) //void WinPaintChar (WChar theChar, Coord x, Coord y) //void WinPaintChars (const Char *chars, Int16 len, Coord x, Coord y) ///opt/palmdev/sdk-5/include/Core/System/Window.h // Font.h WinDrawChar('X',20,50); FntSetFont(symbol11Font); WinDrawChar('Y',40,50); FntSetFont(largeFont); WinDrawChar('Z',60,50); WinDrawChars("large Font",10,80,50); FntSetFont(largeBoldFont); WinDrawChars("large Bold",10,110,50); { char buf[100]; int l=0; UInt32 t = SysTicksPerSecond(); l+=StrPrintF(buf+l, "SysTicksPerSec is %lu", t); FntSetFont(largeBoldFont); WinPaintChars(buf,l,1,20); } if (0){ digiFontType ft; ft.h = 20; ft.w = 16; ft.th = 4; ft.tw = 7; drawHSeg(11,9,ft,WinDrawLineF); drawVSeg(10,10,ft,WinDrawLineF); drawHSeg(11,36,ft,WinDrawLineF); drawVSeg(39,10,ft,WinDrawLineF); } if (0){ digiFontType ft; ft.h = 20; ft.w = 12; ft.th = 4; ft.tw = 7; drawHSeg(11,59,ft,WinDrawLineF); drawVSeg(10,60,ft,WinDrawLineF); drawVSeg(38,60,ft,WinDrawLineF); drawHSeg(11,79,ft,WinDrawLineF); drawVSeg(10,80,ft,WinDrawLineF); drawVSeg(38,80,ft,WinDrawLineF); drawHSeg(11,99,ft,WinDrawLineF); } bigDigit(5,20,'2',WinDrawLineF); bigDigit(40,20,'5',WinDrawLineF); bigDigit(5,70,'7',WinDrawLineF); break; case itemTest2: bigDigit(5,20,'8',WinEraseLineF); bigDigit(40,20,'8',WinEraseLineF); bigDigit(5,70,'8',WinEraseLineF); WinDrawChars("Hello",5,20,80); WinPaintChars("Paint",5,20,110); //Err err; err = TimInit(); { char buf[100]; int l=0; UInt32 s,t; UInt32 hour,min,sec; UInt32 day; // seconds since 1/1/1904 //void TimSetSeconds(UInt32 seconds) // ticks since power on t = TimGetTicks(); s = TimGetSeconds(); l+=StrPrintF(buf+l, "Secs %lu", s); FntSetFont(largeBoldFont); WinPaintChars(buf,l,1,20); l=0; l+=StrPrintF(buf+l, "Ticks %lu", t); FntSetFont(largeBoldFont); WinPaintChars(buf,l,1,40); day = s / (UInt32)(24 * 60 * 60); s = s - day * (24 * 60 * 60); hour = s / (60 * 60); s = s - hour * (60 * 60); min = s / 60; sec = s - min * 60; l=0; l+=StrPrintF(buf+l, "%07d:%02d:%02d:%02d", day, hour,min,sec); FntSetFont(largeBoldFont); WinPaintChars(buf,l,1,60); } break; // call this periodically to hold off auto off // Err EvtResetAutoOffTimer(void) // SystemMgr.h //Err SysTimerCreate(UInt32 *timerIDP, UInt32 *tagP, // SysTimerProcPtr timerProc, UInt32 periodicDelay, UInt32 param) //Err SysTimerDelete(UInt32 timerID) //Err SysTimerWrite(UInt32 timerID, UInt32 value) //Err SysTimerRead(UInt32 timerID, UInt32 *valueP) // SysTaskDelay((100 * SysTicksPerSecond())/1000); case itemOptHelp: FrmHelp(hlpHelp); break; //case itemOptDbgDump: //debugDump(e->eType); //break; case itemOptCopy: FrmHelp(hlpCopy); break; case itemOptAbout: FrmCustomAlert(alertInfo, "stopWatch v" VERSION " not even Alpha. " "Built " __DATE__ ", " __TIME__ ". " "James Coleman http://www.dspsrv.com/~jamesc " "copyleft me.", "", ""); break; } //DEBUGBOX("menuEvent",""); handled = true; break; case ctlSelectEvent: switch(e->data.ctlSelect.controlID) { case btnRun: if (start_sec == 0) { stopWatchPrefs.tik_timestamp = stopWatchPrefs.timestamp = start_sec = TimGetSeconds(); start_tik = TimGetTicks(); } RunCount(start_tik); break; case btnHold: // break the run loop run = 0; break; case btnStop: // break the run loop run = 0; end_sec = TimGetSeconds(); end_tik = TimGetTicks(); break; case btnClear: // break the run loop run = 0; stopWatchPrefs.timestamp = start_sec = 0; stopWatchPrefs.tik_timestamp = 0; end_tik = 0; drawCount(0); break; } break; //case ctlRepeatEvent: //break; case penDownEvent: case penMoveEvent: doPenAction( e->eType, e->screenX, e->screenY, 0, 0); //FrmCustomAlert(alertInfo, "pen down", "ARGSTR1", "ARGSTR2"); break; case penUpEvent: doPenAction( penUpEvent, e->data.penUp.start.x, e->data.penUp.start.y, e->data.penUp.end.x, e->data.penUp.end.y); break; case keyDownEvent: { char buf[1000]; int l=0; l+=StrPrintF(buf+l, "Char: %c %02x\n",e->data.keyDown.chr,e->data.keyDown.chr); buf[l]=0; DEBUGBOX("keyDownEvent",buf); } switch(e->data.keyDown.chr) { case pageUpChr: case pageDownChr: handled = true; break; case prevFieldChr: case nextFieldChr: case '\n': handled = true; break; default: if (!TxtCharIsCntrl(e->data.keyDown.chr)) { handled = true; /* Swallow event */ } break; } break; default: break; } return handled; }
static void draw_chars(const char*s,int x,int y) {if(facunde)WinDrawChars(s,StrLen(s),x,y); if(facunde>1)SysTaskDelay(50); }
/*********************************************************************** * * FUNCTION: DrawRecordName * * DESCRIPTION: Draws an address book record name. It is used * for the list view and note view. * * PARAMETERS: name1, name2 - first and seconds names to draw * nameExtent - the space the names must be drawn in * *x, y - where the names are drawn * * RETURNED: x is set after the last char drawn * * REVISION HISTORY: * Name Date Description * ---- ---- ----------- * roger 6/20/95 Initial Revision * frigino 970813 Rewritten. Now includes a variable ratio for * name1/name2 width allocation, a prioritization * parameter, and a word break search to allow * reclaiming of space from the low priority * name. * jmjeong 99/12/22 Abridged version. make the num of * parameters small * ***********************************************************************/ void DrawRecordName( char* name1, char* name2, UInt16 nameExtent, Int16 *x, Int16 y, Boolean center, Boolean priorityIsName1) { Int16 name1MaxWidth; Int16 name2MaxWidth; Boolean ignored; Int16 totalWidth; Char * lowPriName; Int16 highPriNameWidth; Int16 lowPriNameWidth; Int16 highPriMaxWidth; Int16 lowPriMaxWidth; Char * spaceP; UInt16 shortenedFieldWidth; UInt16 fieldSeparatorWidth; Int16 name1Length, name1Width; Int16 name2Length, name2Width; shortenedFieldWidth = FntCharsWidth(shortenedFieldString, shortenedFieldLength); fieldSeparatorWidth = FntCharsWidth(fieldSeparatorString, fieldSeparatorLength); if (*name1) { /* Only show text from the first line in the field */ name1Length = nameExtent; /* longer than possible */ name1Width = nameExtent; /* wider than possible */ FntCharsInWidth(name1, &name1Width, &name1Length, &ignored); } else { /* Set the name to the unnamed string */ name1 = UnnamedRecordStringPtr; name1Length = StrLen(UnnamedRecordStringPtr); name1Width = FntCharsWidth(UnnamedRecordStringPtr, name1Length); } if (*name2) { /* Only show text from the first line in the field */ name2Length = nameExtent; /* longer than possible */ name2Width = nameExtent; /* wider than possible */ FntCharsInWidth(name2, &name2Width, &name2Length, &ignored); } else { name2Length = 0; name2Width = 0; } /* Check if both names fit */ totalWidth = name1Width + (*name2 ? fieldSeparatorWidth : 0) + name2Width; /* * If we are supposed to center the names then move in the x position * by the amount that centers the text */ if (center && (nameExtent > totalWidth)) { *x += (nameExtent - totalWidth) / 2; } /* Special case if only name1 is given */ if (!*name2) { /* * For some reason, OS3 changed the code so that it doesn't show * ellipses if there is only name1. I liked it the old way! */ /* Does name1 fit in its maximum width? */ if (name1Width > nameExtent) { /* No. Draw it to max width minus the ellipsis */ name1Width = nameExtent-shortenedFieldWidth; FntCharsInWidth(name1, &name1Width, &name1Length, &ignored); WinDrawChars(name1, name1Length, *x, y); *x += name1Width; /* Draw ellipsis */ WinDrawChars(shortenedFieldString, shortenedFieldLength, *x, y); *x += shortenedFieldWidth; } else { /* Yes. Draw name1 within its width */ FntCharsInWidth(name1, &name1Width, &name1Length, &ignored); WinDrawChars(name1, name1Length, *x, y); *x += name1Width; } return; } /* Remove name separator width */ nameExtent -= fieldSeparatorWidth; /* Test if both names fit */ if ((name1Width + name2Width) <= nameExtent) { name1MaxWidth = name1Width; name2MaxWidth = name2Width; } else { /* * They dont fit. One or both needs truncation * Establish name priorities and their allowed widths * Change this to alter the ratio of the low and high * priority name spaces */ highPriMaxWidth = (nameExtent << 1)/3; /* 1/3 to low and 2/3 to high */ lowPriMaxWidth = nameExtent-highPriMaxWidth; /* Save working copies of names and widths based on priority */ if (priorityIsName1) { /* Priority is name1 */ highPriNameWidth = name1Width; lowPriName = name2; lowPriNameWidth = name2Width; } else { /* Priority is name2 */ highPriNameWidth = name2Width; lowPriName = name1; lowPriNameWidth = name1Width; } /* Does high priority name fit in high priority max width? */ if (highPriNameWidth > highPriMaxWidth) { /* No. Look for word break in low priority name */ spaceP = StrChr(lowPriName, spaceChr); if (spaceP != NULL) { /* Found break. Set low priority name width to break width */ lowPriNameWidth = FntCharsWidth(lowPriName, spaceP-lowPriName); /* * Reclaim width from low pri name width to low pri max width, * if smaller. */ if (lowPriNameWidth < lowPriMaxWidth) { lowPriMaxWidth = lowPriNameWidth; /* Set new high pri max width */ highPriMaxWidth = nameExtent-lowPriMaxWidth; } } } else { /* Yes. Adjust maximum widths */ highPriMaxWidth = highPriNameWidth; lowPriMaxWidth = nameExtent-highPriMaxWidth; } /* Convert priority widths back to name widths */ if (priorityIsName1) { /* Priority is name1 */ name1Width = highPriNameWidth; name2Width = lowPriNameWidth; name1MaxWidth = highPriMaxWidth; name2MaxWidth = lowPriMaxWidth; } else { /* Priority is name2 */ name1Width = lowPriNameWidth; name2Width = highPriNameWidth; name1MaxWidth = lowPriMaxWidth; name2MaxWidth = highPriMaxWidth; } } /* Does name1 fit in its maximum width? */ if (name1Width > name1MaxWidth) { /* No. Draw it to max width minus the ellipsis */ name1Width = name1MaxWidth-shortenedFieldWidth; FntCharsInWidth(name1, &name1Width, &name1Length, &ignored); WinDrawChars(name1, name1Length, *x, y); *x += name1Width; /* Draw ellipsis */ WinDrawChars(shortenedFieldString, shortenedFieldLength, *x, y); *x += shortenedFieldWidth; } else { /* Yes. Draw name1 within its width */ FntCharsInWidth(name1, &name1Width, &name1Length, &ignored); WinDrawChars(name1, name1Length, *x, y); *x += name1Width; } if (*name1 && *name2) { /* Draw name separator */ WinDrawChars(fieldSeparatorString, fieldSeparatorLength, *x, y); *x += fieldSeparatorWidth; } /* Draw name2 within its maximum width */ FntCharsInWidth(name2, &name2MaxWidth, &name2Length, &ignored); WinDrawChars(name2, name2Length, *x, y); *x += name2MaxWidth; }
/*------------------------------------------------------CIRexxApp::FindLaunch-+ | | +----------------------------------------------------------------------------*/ Err CIRexxApp::FindLaunch(FindParamsPtr pFindParams) { //<<<JAL TODO: This is currently dependent on the Rexx category. // I'm not sure if we'll ever need to change/add-to this, // but if we do, then this code will have to be changed // along with the GoTo command. Err err; LocalID dbID; UInt16 cardNo = 0; DmOpenRef dbP; DmSearchStateType searchState; UInt16 recordNum; MemHandle hRecord; UInt32 pos; UInt16 matchLength; Boolean match, full; RectangleType r; UInt32 type; UInt32 creator; // Open our database (should we search MemoPad and pedit, too?) // and do our Find. We define the semantics of Find, so // instead of searching the whole records for the search string, // let's just search for scripts with the search string as their "name." if (FindDrawHeader(pFindParams, "Rexx Scripts")) { goto m_return; } if ((err = DmGetNextDatabaseByTypeCreator( true, &searchState, 'data', CREATORID, true, &cardNo, &dbID)) != errNone) { pFindParams->more = false; return errNone; } if ((err = DmDatabaseInfo(0, dbID, 0, 0, 0, 0, 0, 0, 0, 0, 0, &type, &creator)) != errNone || (type != 'data' && creator != CREATORID)) { pFindParams->more = false; return errNone; } if ((dbP = DmOpenDatabase(cardNo, dbID, pFindParams->dbAccesMode)) == 0 || DmGetAppInfoID(dbP) == 0) { /* if categories not initialized then CategoryGetName throws fatal error */ pFindParams->more = false; return errNone; } UInt16 category; char categoryName[dmCategoryLength]; for (category = 0; category < dmRecNumCategories; ++category) { CategoryGetName(dbP, category, categoryName); if (!StrCaselessCompare(categoryName, "REXX")) { break; } } if (category == dmRecNumCategories) { goto m_return; } // set it to dmAllCategories? UInt32 romVersion; FtrGet(sysFtrCreator, sysFtrNumROMVersion, &romVersion); full = false; recordNum = pFindParams->recordNum; while (true) { // Because applications can take a long time to finish a Find when // the result may already be on the screen, or for other reasons, // users like to be able to stop the Find. So, stop it if any event // is pending, i.e., if the user does something with the device. // Because actually checking if an event is pending slows the // search itself, just check it every so many records. if ((recordNum & 0x000f) == 0 && EvtSysEventAvail(true)) { pFindParams->more = true; break; } if (!(hRecord = DmQueryNextInCategory(dbP, &recordNum, category))) { pFindParams->more = false; break; } Char * p = (char *)MemHandleLock(hRecord); UInt32 isInternational; err = FtrGet(sysFtrCreator, sysFtrNumIntlMgr, &isInternational); if (err == errNone && isInternational) { match = TxtFindString(p, pFindParams->strToFind, &pos, &matchLength); } else { match = TxtGlueFindString(p, pFindParams->strToFind, &pos, &matchLength); } if (match) { // Add the match to the find paramter block. // If there is no room to display the match // then the following function will return true. full = FindSaveMatch(pFindParams, recordNum, (UInt16)pos, 0, 0, cardNo, dbID); if (!full) { // Get the bounds of the region where we will draw the results, and // display the title of the description neatly in that area. FindGetLineBounds(pFindParams, &r); Int16 x = r.topLeft.x + 1; Int16 y = r.topLeft.y; Int16 w = r.extent.x - 2; Char * cr = StrChr(p, linefeedChr); UInt16 titleLen = (cr == 0)? StrLen(p) : cr - p; Int16 fntWidthToOffset; if (romVersion >= sysMakeROMVersion(3, 1, 0, sysROMStageRelease, 0)) { fntWidthToOffset = FntWidthToOffset(p, titleLen, w, 0, 0); } else { fntWidthToOffset = FntGlueWidthToOffset(p, titleLen, w, 0, 0); } if (fntWidthToOffset == titleLen) { WinDrawChars(p, titleLen, x, y); } else { Int16 titleWidth; titleLen = FntWidthToOffset(p, titleLen, w - FntCharWidth(chrEllipsis), 0, &titleWidth); WinDrawChars(p, titleLen, x, y); WinDrawChar (chrEllipsis, x + titleWidth, y); } ++pFindParams->lineNumber; } } MemHandleUnlock(hRecord); if (full) { break; } ++recordNum; } m_return: DmCloseDatabase(dbP); return errNone; }
const void drawSprite(SpritePtr sprite){ WinDrawChars(sprite->letter, 3, sprite->x, sprite->y); }
void PrivDrawCell(void* table, Int16 row, Int16 column, RectanglePtr bounds) { char string[50]; FontID font = stdFont; if (g_CurrentRow != row) { if (g_CurrentMemHandle) { MemHandleUnlock(g_CurrentMemHandle); g_CurrentMemHandle = NULL; } } if (g_CurrentMemHandle == NULL) { Err err = GetSMSRecord(g_SmsDb, g_SelectedCategory, row + g_CurrentPage * TABLE_PAGE_SIZE, g_CurrentRecord, g_CurrentMemHandle, true); if (err) return; g_CurrentRow = row; } switch(column) { case 0: StrCopy(string, ""); if (g_SelectedCategory == CAT_INBOX) { if (IsRecordRead(&g_CurrentRecord)) { StrCopy(string, ""); } else { font = symbolFont; StrCopy(string, "\020"); } } else if (g_SelectedCategory == CAT_SENT) { if (IsRecordRequestReport(&g_CurrentRecord)) { font = symbolFont; if (IsRecordDelivered(&g_CurrentRecord)) { StrCopy(string, "\026"); } else { StrCopy(string, "\024"); } } } break; case 1: StrNCopy(string, g_CurrentRecord.personName, 48); if (StrLen(string) == 0) { StrNCopy(string, g_CurrentRecord.phoneNumber, 48); } break; case 2: StrNCopy(string, g_CurrentRecord.content, 48); break; case 3: { DateTimeType smsDatetime; TimSecondsToDateTime(g_CurrentRecord.time, &smsDatetime); UInt32 nowSeconds = TimGetSeconds(); DateTimeType nowDatetime; TimSecondsToDateTime(nowSeconds, &nowDatetime); if ((nowDatetime.year == smsDatetime.year) && (nowDatetime.month == smsDatetime.month) && (nowDatetime.day == smsDatetime.day)) { TimeToAscii(smsDatetime.hour, smsDatetime.minute, tfColon24h, string); } else { StrCopy(string, DayOfWeekInChinese[DayOfWeek(smsDatetime.month, smsDatetime.day, smsDatetime.year)]); DateTemplateToAscii(" ^3z-^0z", smsDatetime.month, smsDatetime.day, smsDatetime.year, string + 2, 47); } MemHandleUnlock(g_CurrentMemHandle); g_CurrentMemHandle = NULL; } break; default: StrCopy(string, ""); } WinPushDrawState(); RGBColorType foreColor, backColor; foreColor.index = 0; backColor.index = 0; if ((row == g_CurrentSelection) && (column != 0)) { foreColor.r = 255; foreColor.g = 255; foreColor.b = 255; backColor.r = 10; backColor.g = 36; backColor.b = 106; } else if (row % 2 == 0) { backColor.r = 255; backColor.g = 255; backColor.b = 255; foreColor.r = 0; foreColor.g = 0; foreColor.b = 0; } else { backColor.r = 220; backColor.g = 220; backColor.b = 220; foreColor.r = 0; foreColor.g = 0; foreColor.b = 0; } WinSetForeColorRGB(&foreColor, NULL); WinSetTextColorRGB(&foreColor, NULL); WinSetBackColorRGB(&backColor, NULL); WinSetUnderlineMode(noUnderline); FntSetFont(font); Int16 width = bounds->extent.x - 2; Int16 len = StrLen(string); Boolean noFit = false; FntCharsInWidth(string, &width, &len, &noFit); UInt16 x = bounds->topLeft.x; UInt16 y = bounds->topLeft.y; bounds->topLeft.x += - 1; bounds->topLeft.y += 0; bounds->extent.x += 2; bounds->extent.y += 0; WinEraseRectangle(bounds, 0); WinDrawGrayLine( bounds->topLeft.x + bounds->extent.x - 2, bounds->topLeft.y, bounds->topLeft.x + bounds->extent.x - 2, bounds->topLeft.y + bounds->extent.y);// - 2); WinDrawChars(string, len, x, y); 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); }