IO_stat MCImage::import(MCStringRef newname, IO_handle stream, IO_handle mstream) { bool t_success = true; MCImageCompressedBitmap *t_compressed = nil; MCImageBitmap *t_bitmap = nil; MCStringRef t_name = nil; MCPoint t_hotspot = {1, 1}; t_success = MCImageImport(stream, mstream, t_hotspot, t_name, t_compressed, t_bitmap); if (t_success) { if (t_compressed == nil) t_success = setbitmap(t_bitmap, 1.0); else t_success = setcompressedbitmap(t_compressed); } MCImageFreeCompressedBitmap(t_compressed); MCImageFreeBitmap(t_bitmap); uindex_t t_width, t_height; if (t_success) t_success = getsourcegeometry(t_width, t_height); if (t_success) { xhot = t_hotspot.x; yhot = t_hotspot.y; bool t_resize = true; t_resize = !(flags & F_LOCK_LOCATION); if (t_resize) { rect.width = t_width; rect.height = t_height; } if (m_rep->GetFrameCount() > 1) { if ((flags & F_REPEAT_COUNT) == 0) repeatcount = -1; irepeatcount = repeatcount; state |= CS_DO_START; } if (isunnamed() && t_name != nil) { MCNewAutoNameRef t_name_nameref; /* UNCHECKED */ MCNameCreate(t_name, &t_name_nameref); setname(*t_name_nameref); } if (isunnamed() && newname != nil) { MCNewAutoNameRef t_name_nameref; uindex_t t_offset; if (MCStringLastIndexOfChar(newname, PATH_SEPARATOR, UINDEX_MAX, kMCCompareExact, t_offset)) { /* UNCHECKED */ MCStringCopySubstring(newname, MCRangeMakeMinMax(t_offset + 1, MCStringGetLength(newname)), t_name); /* UNCHECKED */ MCNameCreate(t_name, &t_name_nameref); } else /* UNCHECKED */ MCNameCreate(newname, &t_name_nameref); setname(*t_name_nameref); } } MCValueRelease(t_name); return t_success ? IO_NORMAL : IO_ERROR; }
IO_stat MCImage::import(const char *newname, IO_handle stream, IO_handle mstream) { bool t_success = true; MCImageCompressedBitmap *t_compressed = nil; MCImageBitmap *t_bitmap = nil; char *t_name = nil; MCPoint t_hotspot = {1, 1}; t_success = MCImageImport(stream, mstream, t_hotspot, t_name, t_compressed, t_bitmap); if (t_success) { if (t_compressed == nil) t_success = setbitmap(t_bitmap); else t_success = setcompressedbitmap(t_compressed); } MCImageFreeCompressedBitmap(t_compressed); MCImageFreeBitmap(t_bitmap); uindex_t t_width, t_height; if (t_success) t_success = m_rep->GetGeometry(t_width, t_height); if (t_success) { xhot = t_hotspot.x; yhot = t_hotspot.y; bool t_resize = true; t_resize = !(flags & F_LOCK_LOCATION); if (t_resize) { rect.width = t_width; rect.height = t_height; } if (m_rep->GetFrameCount() > 1) { if ((flags & F_REPEAT_COUNT) == 0) repeatcount = -1; irepeatcount = repeatcount; state |= CS_DO_START; } if (isunnamed() && t_name != nil) setname_cstring(t_name); if (isunnamed() && newname != nil) { const char *tname = strrchr(newname, PATH_SEPARATOR); if (tname != NULL) tname += 1; else tname = newname; setname_cstring(tname); } } MCCStringFree(t_name); return t_success ? IO_NORMAL : IO_ERROR; }
Exec_stat MCObject::getproparray(MCExecPoint &ep, uint4 parid, bool effective) { PropList *table; uint2 tablesize; switch (gettype()) { case CT_STACK: table = stackprops; tablesize = ELEMENTS(stackprops); break; case CT_CARD: table = cardprops; tablesize = ELEMENTS(cardprops); break; case CT_GROUP: table = groupprops; tablesize = ELEMENTS(groupprops); break; case CT_BUTTON: table = buttonprops; tablesize = ELEMENTS(buttonprops); break; case CT_FIELD: table = fieldprops; tablesize = ELEMENTS(fieldprops); break; case CT_IMAGE: table = imageprops; tablesize = ELEMENTS(imageprops); break; case CT_GRAPHIC: table = graphicprops; tablesize = ELEMENTS(graphicprops); break; case CT_SCROLLBAR: table = scrollbarprops; tablesize = ELEMENTS(scrollbarprops); break; case CT_PLAYER: table = playerprops; tablesize = ELEMENTS(playerprops); break; case CT_EPS: table = epsprops; tablesize = ELEMENTS(epsprops); break; case CT_COLOR_PALETTE: table = colorpaletteprops; tablesize = ELEMENTS(colorpaletteprops); break; case CT_AUDIO_CLIP: table = audioclipprops; tablesize = ELEMENTS(audioclipprops); break; case CT_VIDEO_CLIP: table = videoclipprops; tablesize = ELEMENTS(videoclipprops); break; default: return ES_NORMAL; } MCVariableValue *v = new MCVariableValue; v->assign_new_array(64); MCerrorlock++; while (tablesize--) { const char * t_token = table[tablesize].token; if ((Properties)table[tablesize].value > P_FIRST_ARRAY_PROP) getarrayprop(parid, (Properties)table[tablesize].value, ep, kMCEmptyName, effective); else { // MERG-2013-05-07: [[ RevisedPropsProp ]] Special-case the props that could // be either Unicode or native (ensure minimal encoding is used). // MERG-2013-06-24: [[ RevisedPropsProp ]] Treat the short name specially to ensure // round-tripping. If the name is empty, then return empty for 'name'. switch ((Properties)table[tablesize].value) { case P_SHORT_NAME: if (isunnamed()) ep.clear(); else getprop(parid, P_SHORT_NAME, ep, effective); break; case P_LABEL: getprop(parid, P_UNICODE_LABEL, ep, effective); if (!ep.trytoconvertutf16tonative()) { if (gettype() == CT_STACK) t_token = "unicodeTitle"; else t_token = "unicodeLabel"; } break; case P_TOOL_TIP: getprop(parid, P_UNICODE_TOOL_TIP, ep, effective); if (!ep.trytoconvertutf16tonative()) t_token = "unicodeToolTip"; break; case P_TEXT: if (gettype() == CT_BUTTON) { getprop(parid, P_UNICODE_TEXT, ep, effective); if (!ep.trytoconvertutf16tonative()) t_token = "unicodeText"; break; } default: getprop(parid, (Properties)table[tablesize].value, ep, effective); break; } } v->store_element(ep, t_token); } MCerrorlock--; ep.setarray(v, True); return ES_NORMAL; }
void MCStack::realize() { //create window if (!MCnoui && MCModeMakeLocalWindows()) { if ( getextendedstate(ECS_FULLSCREEN) ) { //TS-2008-08-01 : [[Bug 5703 - fullscreen stack prop interacts badly with HideMenuBar]] if (!((MCScreenDC*)MCscreen)->getmenubarhidden()) SetSystemUIMode(kUIModeAllHidden, kUIOptionAutoShowMenuBar); const MCDisplay *t_display; t_display = MCscreen -> getnearestdisplay(rect); MCRectangle t_workarea, t_viewport; t_workarea = t_display -> workarea; t_viewport = t_display -> viewport ; setrect(t_viewport); } else { if (!((MCScreenDC*)MCscreen)->getmenubarhidden()) SetSystemUIMode(kUIModeNormal, NULL); } Rect wrect; MCScreenDC *psdc = (MCScreenDC *)MCscreen; psdc->MCRect2MacRect(rect, wrect); window = new _Drawable; window->type = DC_WINDOW; window->handle.window = 0; char *tmpname = NULL; const unsigned char *namePascal; if (!isunnamed()) { //set window title to name of stack temporarily. tmpname = strclone(getname_cstring()); //it will be changed by setname() later. namePascal = c2pstr(tmpname); } else namePascal = (unsigned char*)"\p"; loadwindowshape(); window->handle.window = NULL; uint32_t wclass; uint32_t wattributes; getWinstyle(wattributes,wclass); wattributes |= kWindowCompositingAttribute; long testdecorations = WD_TITLE | WD_MENU | WD_CLOSE | WD_MINIMIZE | WD_MAXIMIZE; if (m_window_shape != NULL) { static WindowDefUPP s_window_mask_proc = NULL; if (s_window_mask_proc == NULL) s_window_mask_proc = NewWindowDefUPP(WindowMaskProc); WindowDefSpec t_spec; t_spec . defType = kWindowDefProcPtr; t_spec . u . defProc = s_window_mask_proc; CreateCustomWindow(&t_spec, wclass, wattributes, &wrect, (WindowPtr *)&window -> handle . window); HIWindowChangeFeatures((WindowPtr)window -> handle . window, 0, kWindowIsOpaque); } else if (((flags & F_DECORATIONS && !(decorations & testdecorations)) || wclass == kPlainWindowClass)) { static WindowDefUPP s_borderless_proc = NULL; if (s_borderless_proc == NULL) s_borderless_proc = NewWindowDefUPP(BorderlessWindowProc); WindowDefSpec t_spec; t_spec . defType = kWindowDefProcPtr; t_spec . u . defProc = s_borderless_proc; if (wclass == kPlainWindowClass) wclass = kUtilityWindowClass; CreateCustomWindow(&t_spec, wclass, wattributes, &wrect, (WindowPtr *)&window->handle.window); } else CreateNewWindow(wclass, wattributes,&wrect, (WindowPtr *)&window->handle.window); if (wclass == kFloatingWindowClass) ChangeWindowAttributes((WindowPtr)window -> handle . window, kWindowNoAttributes, kWindowHideOnSuspendAttribute); // MW-2009-10-31: Make sure we can collapse any rev window HIWindowChangeFeatures((WindowPtr)window -> handle . window, kWindowCanCollapse, 0); if (window->handle.window == NULL) SetWTitle((WindowPtr)window->handle.window, namePascal); SetWTitle((WindowPtr)window->handle.window, namePascal); setopacity(blendlevel * 255 / 100); SetWRefCon((WindowPtr)window->handle.window, mode); ControlRef t_control; MCRevolutionStackViewCreate(this, &t_control); ControlRef t_root_control; GetRootControl((WindowPtr)window -> handle . window, &t_root_control); HIViewAddSubview(t_root_control, t_control); ShowControl(t_control); if (wclass == kDrawerWindowClass) { Window pwindow = NULL; if (parentwindow != DNULL) pwindow = parentwindow; else if (MCdefaultstackptr && MCdefaultstackptr->getw() != DNULL ) pwindow = MCdefaultstackptr->getw(); if (pwindow && GetWRefCon((WindowPtr)pwindow->handle.window) != WM_DRAWER) { SetDrawerParent((WindowPtr)window->handle.window, (WindowPtr)pwindow->handle.window); WindowAttributes watt; GetWindowAttributes((WindowPtr)pwindow->handle.window,&watt); if (wattributes & kWindowResizableAttribute) ChangeWindowAttributes((WindowPtr)pwindow->handle.window, kWindowLiveResizeAttribute, 0); OptionBits draweredge; switch (wposition) { case WP_PARENTTOP: draweredge = kWindowEdgeTop; break; case WP_PARENTRIGHT: draweredge = kWindowEdgeRight; break; case WP_PARENTBOTTOM: draweredge = kWindowEdgeBottom; break; case WP_PARENTLEFT: draweredge = kWindowEdgeLeft; break; default: draweredge = kWindowEdgeDefault; break; } SetDrawerPreferredEdge((WindowPtr)window->handle.window, draweredge); if (walignment) { MCRectangle parentwindowrect; MCscreen->getwindowgeometry(pwindow, parentwindowrect); int2 wspace = 0; RgnHandle r = NewRgn(); GetWindowRegion((WindowPtr)window->handle.window, kWindowStructureRgn, r); Rect tRect; GetRegionBounds(r, &tRect); DisposeRgn(r); MCRectangle drawerwindowrect; psdc->MacRect2MCRect(tRect, drawerwindowrect); if (wposition == WP_PARENTTOP || wposition == WP_PARENTBOTTOM) { wspace = parentwindowrect.width - drawerwindowrect.width; if (watt & kWindowMetalAttribute) if (wspace) wspace += 10; //for metal } else { wspace = parentwindowrect.height - drawerwindowrect.height; if (watt & kWindowMetalAttribute) if (wspace) wspace += 5; //for metal } if (wspace > 0) switch (walignment) { case OP_CENTER: SetDrawerOffsets ((WindowPtr)window->handle.window,ceil(wspace/2) -1,floor(wspace/2) + 1); break; case OP_RIGHT: case OP_BOTTOM: SetDrawerOffsets ((WindowPtr)window->handle.window,wspace,0); break; case OP_TOP: case OP_LEFT: SetDrawerOffsets ((WindowPtr)window->handle.window,0,wspace); break; } } } } delete tmpname; // MW-2005-11-06: We also need to catch window constraining events so we can flush // the screen geometry cache. EventTypeSpec list[] = { {kEventClassWindow, kEventWindowCollapsed}, {kEventClassWindow, kEventWindowExpanded}, {kEventClassMouse, kEventMouseWheelMoved}, {kEventClassWindow, kEventWindowBoundsChanging}, {kEventClassWindow, kEventWindowBoundsChanged}, {kEventClassWindow, kEventWindowConstrain}, {kEventClassWindow, kEventWindowFocusAcquired}, {kEventClassWindow, kEventWindowFocusRelinquish}, {kEventClassWindow, kEventWindowActivated}, {kEventClassWindow, kEventWindowDeactivated}, {kEventClassWindow, kEventWindowClose}, }; EventHandlerRef ref; // MW-2005-09-07: Pass the window handle as user data, otherwise 'takewindow' causes problems InstallWindowEventHandler((WindowPtr)window->handle.window, MCS_weh, sizeof(list) / sizeof(EventTypeSpec), list, (WindowPtr)window -> handle . window, &ref); ChangeWindowAttributes((WindowPtr)window->handle.window, 0, kWindowHideOnFullScreenAttribute); updatemodifiedmark(); } start_externals(); }