bool MCSystemFindEvent(MCDateTime p_start_date, MCDateTime p_end_date, char *& r_result) { // TODO - IMPLEMENT SUPPORT FOR API LEVEL 14 char *t_result; r_result = s_calendar_events_selected.clone(); MCLog("MCSystemFindCalendarEvent result: %s", r_result); return true; }
bool MCSystemRemoveEvent(const char* p_calendar_event_id, bool p_reoccurring, char*& r_calendar_event_id_deleted) { // TODO - IMPLEMENT SUPPORT FOR API LEVEL 14 MCLog("MCSystemRemoveCalendarEvent: %s", p_calendar_event_id); MCAndroidEngineRemoteCall("removeCalendarEvent", "ss", &r_calendar_event_id_deleted, p_calendar_event_id); r_calendar_event_id_deleted = s_calendar_event_selected.clone(); return true; }
void MCError::copysvalue(const MCString &s, Boolean t) { delete buffer; buffer = s.clone(); thrown = t; if (thrown) svalue.set(buffer, strlen(buffer)); }
bool MCSystemShowEvent(const char* p_calendar_event_id, char*& r_result) { // TODO - IMPLEMENT SUPPORT FOR API LEVEL 14 MCLog("MCSystemShowCalendarEvent", NULL); MCAndroidEngineRemoteCall("showCalendarEvent", "vs", nil, p_calendar_event_id); s_calendar_event_status = kMCAndroidCalendarEventWaiting; while (s_calendar_event_status == kMCAndroidCalendarEventWaiting) MCscreen->wait(60.0, False, True); r_result = s_calendar_event_selected.clone(); MCLog("MCSystemShowCalendarEvent - finished", NULL); return true; }
bool MCSystemAddEvent(MCCalendar p_new_calendar_event_data, char*& r_result) { // TODO - IMPLEMENT SUPPORT FOR API LEVEL 14 MCLog("MCSystemAddCalendarEvent", NULL); MCAndroidEngineRemoteCall("addCalendarEvent", "issssbbbbiisiis", &r_result, p_new_calendar_event_data.mceventid.getstring(), p_new_calendar_event_data.mctitle.getstring(), p_new_calendar_event_data.mcnote.getstring(), p_new_calendar_event_data.mclocation.getstring(), p_new_calendar_event_data.mcalldayset, p_new_calendar_event_data.mcallday, p_new_calendar_event_data.mcstartdateset, p_new_calendar_event_data.mcenddateset, p_new_calendar_event_data.mcalert1, p_new_calendar_event_data.mcalert2, p_new_calendar_event_data.mcfrequency.getstring(), p_new_calendar_event_data.mcfrequencycount, p_new_calendar_event_data.mcfrequencyinterval, p_new_calendar_event_data.mccalendar.getstring()); r_result = s_calendar_event_selected.clone(); return true; }
void MCSort::additem(MCExecPoint &ep, MCSortnode *&items, uint4 &nitems, Sort_type form, MCString &s, MCExpression *by) { if (by != NULL) { MCerrorlock++; ep.setsvalue(s); MCeach->store(ep, False); if (by->eval(ep) == ES_NORMAL) s = ep.getsvalue(); else s = MCnullmcstring; MCerrorlock--; } switch (form) { case ST_DATETIME: ep.setsvalue(s); if (MCD_convert(ep, CF_UNDEFINED, CF_UNDEFINED, CF_SECONDS, CF_UNDEFINED)) { if (!MCU_stor8(ep.getsvalue(), items[nitems].nvalue)) items[nitems].nvalue = -MAXREAL8; } else items[nitems].nvalue = -MAXREAL8; break; case ST_NUMERIC: { const char *sptr = s.getstring(); uint4 length = s.getlength(); // MW-2013-03-21: [[ Bug ]] Make sure we skip any whitespace before the // number starts - making it consistent with string->number conversions // elsewhere. MCU_skip_spaces(sptr, length); // REVIEW - at the moment the numeric prefix of the string is used to // derive the sort key e.g. 1000abc would get processed as 1000. while (length && (isdigit((uint1)*sptr) || *sptr == '.' || *sptr == '-' || *sptr == '+')) { sptr++; length--; } s.setlength(s.getlength() - length); if (!MCU_stor8(s, items[nitems].nvalue)) items[nitems].nvalue = -MAXREAL8; } break; default: if (ep.getcasesensitive() && by == NULL) items[nitems].svalue = (char *)s.getstring(); else if (ep.getcasesensitive()) items[nitems].svalue = s.clone(); else { #if defined(_MAC_DESKTOP) || defined(_IOS_MOBILE) if (form == ST_INTERNATIONAL) { extern char *MCSystemLowercaseInternational(const MCString& s); items[nitems].svalue = MCSystemLowercaseInternational(s); } else #endif { items[nitems].svalue = new char[s.getlength() + 1]; MCU_lower(items[nitems].svalue, s); items[nitems].svalue[s.getlength()] = '\0'; } } break; } nitems++; }
MCFontnode::MCFontnode(const MCString &fname, uint2 &size, uint2 style, Boolean printer) { reqname = fname.clone(); reqsize = size; reqstyle = style; reqprinter = printer; font = new MCFontStruct; if (MCnoui) { memset(font, 0, sizeof(MCFontStruct)); return; } LOGFONTA logfont; memset(&logfont, 0, sizeof(LOGFONTA)); uint4 maxlength = MCU_min(LF_FACESIZE - 1U, fname.getlength()); strncpy(logfont.lfFaceName, fname.getstring(), maxlength); logfont.lfFaceName[maxlength] = '\0'; // MW-2012-05-03: [[ Bug 10180 ]] Make sure the default charset for the font // is chosen - otherwise things like WingDings don't work! logfont.lfCharSet = DEFAULT_CHARSET; //parse font and encoding char *sptr = logfont.lfFaceName; if (sptr = strchr(logfont.lfFaceName, ',')) { *sptr = '\0'; sptr++; } HDC hdc; // MW-2013-11-07: [[ Bug 11393 ]] 'printer' in the fontstruct now means use ideal // metrics for rendering and measuring. MCScreenDC *pms = (MCScreenDC *)MCscreen; hdc = pms->getsrchdc(); logfont.lfHeight = MulDiv(MulDiv(size, 7, 8), SCREEN_WIDTH_FOR_FONT_USE, 72); logfont.lfWeight = weighttable[MCF_getweightint(style)]; if (style & FA_ITALIC) logfont.lfItalic = TRUE; if (style & FA_OBLIQUE) logfont.lfOrientation = 3600 - 150; /* 15 degree forward slant */ HFONT newfont = CreateFontIndirectA(&logfont); SelectObject(hdc, newfont); char testname[LF_FACESIZE]; memset(testname, 0, LF_FACESIZE); GetTextFaceA(hdc, LF_FACESIZE, testname); // MW-2012-02-13: If we failed to find an exact match then remap the font name and // try again. if (newfont == NULL || (MCU_strncasecmp(testname, logfont.lfFaceName, strlen(testname) + 1))) { if (newfont != NULL) DeleteObject(newfont); mapfacename(logfont.lfFaceName, logfont.lfFaceName, printer == True); // Force the resulting font to be TrueType and with ANSI charset (otherwise // we get strange UI symbol font on XP). logfont.lfCharSet = ANSI_CHARSET; logfont.lfOutPrecision = OUT_TT_ONLY_PRECIS; newfont = CreateFontIndirectA(&logfont); SelectObject(hdc, newfont); } // At this point we will have either found an exact match for the textFont, mapped // using the defaults table and found a match, or been given a default truetype font. TEXTMETRICA tm; GetTextMetricsA(hdc, &tm); font->fid = (MCSysFontHandle)newfont; font->size = size; // MW-2013-12-19: [[ Bug 11606 ]] Use Mac-style metric adjustment in printer (ideal // layout mode). if (!printer) { font->ascent = MulDiv(tm.tmAscent, 15, 16); font->descent = tm.tmDescent; } else { font -> ascent = size - 1; font -> descent = size * 2 / 14 + 1; } font->printer = printer; }
Exec_stat MCEPS::setprop_legacy(uint4 parid, Properties p, MCExecPoint &ep, Boolean effective) { Boolean dirty = True; real8 n; int2 i; int2 i1, i2, i3, i4; MCString data = ep.getsvalue(); switch (p) { #ifdef /* MCEPS::setprop */ LEGACY_EXEC case P_TRAVERSAL_ON: case P_SHOW_BORDER: if (MCControl::setprop(parid, p, ep, effective) != ES_NORMAL) return ES_ERROR; resetscale(); break; case P_ANGLE: if (!MCU_stoi2(data, i)) { MCeerror->add (EE_OBJECT_NAN, 0, 0, data); return ES_ERROR; } angle = i; break; case P_POSTSCRIPT: delete postscript; postscript = data.clone(); size = data.getlength() + 1; setextents(); resetscale(); break; case P_PROLOG: delete prolog; prolog = data.clone(); break; case P_RETAIN_IMAGE: if (!MCU_matchflags(data, flags, F_RETAIN_IMAGE, dirty)) { MCeerror->add (EE_OBJECT_NAB, 0, 0, data); return ES_ERROR; } dirty = False; break; case P_RETAIN_POSTSCRIPT: if (!MCU_matchflags(data, flags, F_RETAIN_POSTSCRIPT, dirty)) { MCeerror->add (EE_OBJECT_NAB, 0, 0, data); return ES_ERROR; } dirty = False; break; case P_SCALE_INDEPENDENTLY: if (!MCU_matchflags(data, flags, F_SCALE_INDEPENDENTLY, dirty)) { MCeerror->add (EE_OBJECT_NAB, 0, 0, data); return ES_ERROR; } if (dirty) resetscale(); break; case P_BOUNDING_RECT: if (!MCU_stoi2x4(data, i1, i2, i3, i4)) { MCeerror->add (EE_OBJECT_NAR, 0, 0, data); return ES_ERROR; } if (tx != i1 || ty != i2 || tx + ex != i3 || ty + ey != i4) { tx = i1; ty = i2; ex = MCU_max(i3 - i1, 1); ey = MCU_max(i4 - i2, 1); resetscale(); } else dirty = False; break; case P_SCALE: if (!MCU_stor8(data, n)) { MCeerror->add (EE_OBJECT_NAN, 0, 0, data); return ES_ERROR; } xscale = yscale = n; break; case P_X_SCALE: if (!MCU_stor8(data, n)) { MCeerror->add (EE_OBJECT_NAN, 0, 0, data); return ES_ERROR; } xscale = n; ex = (uint2)(rect.width * xf / xscale + 0.5); flags |= F_SCALE_INDEPENDENTLY; break; case P_Y_SCALE: if (!MCU_stor8(data, n)) { MCeerror->add (EE_OBJECT_NAN, 0, 0, data); return ES_ERROR; } yscale = n; ey = (uint2)(rect.height * yf / yscale + 0.5); flags |= F_SCALE_INDEPENDENTLY; break; case P_X_OFFSET: if (!MCU_stoi2(data, i)) { MCeerror->add (EE_OBJECT_NAN, 0, 0, data); return ES_ERROR; } tx = i; break; case P_Y_OFFSET: if (!MCU_stoi2(data, i)) { MCeerror->add (EE_OBJECT_NAN, 0, 0, data); return ES_ERROR; } ty = i; break; case P_X_EXTENT: if (!MCU_stoi2(data, i)) { MCeerror->add (EE_OBJECT_NAN, 0, 0, data); return ES_ERROR; } ex = i; resetscale(); break; case P_Y_EXTENT: if (!MCU_stoi2(data, i)) { MCeerror->add (EE_OBJECT_NAN, 0, 0, data); return ES_ERROR; } ey = i; resetscale(); break; case P_CURRENT_PAGE: //set eps current page to display if (!MCU_stoi2(data, i)) { MCeerror->add (EE_OBJECT_NAN, 0, 0, data); return ES_ERROR; } if ((uint2)i > pagecount) curpage = pagecount; else curpage = i; break; #endif /* MCEPS::setprop */ default: return MCControl::setprop_legacy(parid, p, ep, effective); } if (dirty && opened) { // MW-2011-08-18: [[ Layers ]] Invalidate the whole object. layer_redrawall(); } return ES_NORMAL; }
Exec_stat MCF_parsetextatts(Properties which, const MCString &data, uint4 &flags, char *&fname, uint2 &height, uint2 &size, uint2 &style) { int2 i1; switch (which) { case P_TEXT_ALIGN: flags &= ~F_ALIGNMENT; if (data == MCleftstring || data.getlength() == 0) flags |= F_ALIGN_LEFT; else if (data == MCcenterstring) flags |= F_ALIGN_CENTER; else if (data == MCrightstring) flags |= F_ALIGN_RIGHT; else if (data == MCjustifystring) flags |= F_ALIGN_JUSTIFY; else { MCeerror->add(EE_OBJECT_BADALIGN, 0, 0, data); return ES_ERROR; } break; case P_TEXT_FONT: { fname = data.clone(); // MW-2012-02-17: [[ IntrinsicUnicode ]] Strip any lang tag from the // fontname. char *t_tag; t_tag = strchr(fname, ','); if (t_tag != nil) t_tag[0] = '\0'; } break; case P_TEXT_HEIGHT: if (!MCU_stoi2(data, i1)) { MCeerror->add (EE_OBJECT_TEXTHEIGHTNAN, 0, 0, data); return ES_ERROR; } height = i1; break; case P_TEXT_SIZE: if (data.getlength() == 0) i1 = 0; else if (!MCU_stoi2(data, i1)) { MCeerror->add (EE_OBJECT_TEXTSIZENAN, 0, 0, data); return ES_ERROR; } size = i1; break; case P_TEXT_STYLE: { // MW-2012-02-17: [[ SplitTextAttrs ]] If the string is empty, then // return 0 for the style - indicating to unset the property. uint4 l = data.getlength(); const char *sptr = data.getstring(); if (l == 0) style = 0; else { style = FA_DEFAULT_STYLE; while (l) { const char *startptr = sptr; if (!MCU_strchr(sptr, l, ',')) { sptr += l; l = 0; } MCString tdata(startptr, sptr - startptr); MCU_skip_char(sptr, l); MCU_skip_spaces(sptr, l); if (MCF_setweightstring(style, tdata)) continue; if (MCF_setexpandstring(style, tdata)) continue; if (MCF_setslantlongstring(style, tdata)) continue; if (tdata == MCplainstring) { style = FA_DEFAULT_STYLE; continue; } if (tdata == MCmixedstring) { style = FA_DEFAULT_STYLE; continue; } if (tdata == MCboxstring) { style &= ~FA_3D_BOX; style |= FA_BOX; continue; } if (tdata == MCthreedboxstring) { style &= ~FA_BOX; style |= FA_3D_BOX; continue; } if (tdata == MCunderlinestring) { style |= FA_UNDERLINE; continue; } if (tdata == MCstrikeoutstring) { style |= FA_STRIKEOUT; continue; } if (tdata == MCgroupstring || tdata == MClinkstring) { style |= FA_LINK; continue; } MCeerror->add(EE_OBJECT_BADSTYLE, 0, 0, data); return ES_ERROR; } } } break; default: break; } return ES_NORMAL; }
IO_stat MCDispatch::dosavestack(MCStack *sptr, const MCString &fname) { if (MCModeCheckSaveStack(sptr, fname) != IO_NORMAL) return IO_ERROR; char *linkname; if (fname.getlength() != 0) linkname = fname.clone(); else if ((linkname = strclone(sptr->getfilename())) == NULL) { MCresult->sets("stack does not have a filename"); return IO_ERROR; } if (linkname == NULL) { MCresult->sets("can't open stack file, bad path"); return IO_ERROR; } if (MCS_noperm(linkname)) { MCresult->sets("can't open stack file, no permission"); delete linkname; return IO_ERROR; } char *oldfiletype = MCfiletype; MCfiletype = MCstackfiletype; char *backup = new char[strlen(linkname) + 2]; strcpy(backup, linkname); strcat(backup, "~"); MCS_unlink(backup); if (MCS_exists(linkname, True) && !MCS_backup(linkname, backup)) { MCresult->sets("can't open stack backup file"); MCfiletype = oldfiletype; delete linkname; delete backup; return IO_ERROR; } IO_handle stream; if ((stream = MCS_open(linkname, IO_WRITE_MODE, True, False, 0)) == NULL) { MCresult->sets("can't open stack file"); cleanup(stream, linkname, backup); MCfiletype = oldfiletype; return IO_ERROR; } MCfiletype = oldfiletype; MCString errstring = "Error writing stack (disk full?)"; // MW-2012-03-04: [[ StackFile5500 ]] Work out what header to emit, and the size. const char *t_header; uint32_t t_header_size; if (MCstackfileversion >= 5500) t_header = newheader5500, t_header_size = 8; else if (MCstackfileversion >= 2700) t_header = newheader, t_header_size = 8; else t_header = header, t_header_size = HEADERSIZE; if (IO_write(t_header, sizeof(char), t_header_size, stream) != IO_NORMAL || IO_write_uint1(CHARSET, stream) != IO_NORMAL) { MCresult->sets(errstring); cleanup(stream, linkname, backup); return IO_ERROR; } if (IO_write_uint1(OT_NOTHOME, stream) != IO_NORMAL || IO_write_string(NULL, stream) != IO_NORMAL) { // was stackfiles MCresult->sets(errstring); cleanup(stream, linkname, backup); return IO_ERROR; } // MW-2012-02-22; [[ NoScrollSave ]] Adjust the rect by the current group offset. MCgroupedobjectoffset . x = 0; MCgroupedobjectoffset . y = 0; MCresult -> clear(); if (sptr->save(stream, 0, false) != IO_NORMAL || IO_write_uint1(OT_END, stream) != IO_NORMAL) { if (MCresult -> isclear()) MCresult->sets(errstring); cleanup(stream, linkname, backup); return IO_ERROR; } MCS_close(stream); uint2 oldmask = MCS_umask(0); uint2 newmask = ~oldmask & 00777; if (oldmask & 00400) newmask &= ~00100; if (oldmask & 00040) newmask &= ~00010; if (oldmask & 00004) newmask &= ~00001; MCS_umask(oldmask); MCS_chmod(linkname, newmask); if (sptr->getfilename() != NULL && !strequal(linkname, sptr->getfilename())) MCS_copyresourcefork(sptr->getfilename(), linkname); else if (sptr -> getfilename() != NULL) MCS_copyresourcefork(backup, linkname); sptr->setfilename(linkname); if (backup != NULL) { MCS_unlink(backup); delete backup; } return IO_NORMAL; }