// MW-2011-09-11: [[ Redraw ]] Force an immediate update of the window within the given // region but using the pixmap given. void MCStack::updatewindowwithbuffer(Pixmap p_pixmap, MCRegionRef p_region) { HIViewRef t_root; GetRootControl((WindowPtr)window -> handle . window, &t_root); HIViewRef t_view; GetIndexedSubControl(t_root, 1, &t_view); HIViewSetNeedsDisplayInRegion(t_view, (RgnHandle)p_region, TRUE); // Set the file-local static to the pixmap to use (stacksurface picks this up!) s_update_pixmap = p_pixmap; HIViewRender(t_view); // Unset the file-local static. s_update_pixmap = nil; // MW-2011-10-18: [[ Bug 9798 ]] Make sure we force a screen update after every // update. // MW-2012-09-10: [[ Revert Bug 10333 ]] Delayed until IDE issues can be resolved. // HIWindowFlush((WindowPtr)window -> handle . window); // Update the shadow, if required. if (getextendedstate(ECS_MASK_CHANGED)) { // MW-2012-09-10: [[ Revert Bug 10333 ]] Delayed until IDE issues can be resolved. HIWindowFlush((WindowPtr)window -> handle . window); HIWindowInvalidateShadow((WindowPtr)window -> handle . window); EnableScreenUpdates(); setextendedstate(False, ECS_MASK_CHANGED); } }
void MCStack::updatemodifiedmark(void) { if (!MCModeMakeLocalWindows()) return; if (window != NULL) SetWindowModified((WindowPtr)window -> handle . window, getextendedstate(ECS_MODIFIED_MARK)); }
// MW-2011-09-11: [[ Redraw ]] Force an immediate update of the window within the given // region. The actual rendering is done by deferring to the 'redrawwindow' method. void MCStack::updatewindow(MCRegionRef p_region) { HIViewRef t_root; GetRootControl((WindowPtr)window -> handle . window, &t_root); HIViewRef t_view; GetIndexedSubControl(t_root, 1, &t_view); // MW-2011-10-07: [[ Bug 9792 ]] If the mask hasn't changed, use the update region, // else redraw the whole view. if (!getextendedstate(ECS_MASK_CHANGED)) HIViewSetNeedsDisplayInRegion(t_view, (RgnHandle)p_region, TRUE); else { HIViewSetNeedsDisplay(t_view, TRUE); DisableScreenUpdates(); } HIViewRender(t_view); // MW-2012-09-04: [[ Bug 10333 ]] Flush the window immediately to make sure // we see every update. // MW-2012-09-10: [[ Revert Bug 10333 ]] Delayed until IDE issues can be resolved. // HIWindowFlush((WindowPtr)window -> handle . window); // Update the shadow, if required. if (getextendedstate(ECS_MASK_CHANGED)) { // MW-2012-09-10: [[ Revert Bug 10333 ]] Delayed until IDE issues can be resolved. HIWindowFlush((WindowPtr)window -> handle . window); HIWindowInvalidateShadow((WindowPtr)window -> handle . window); EnableScreenUpdates(); setextendedstate(False, ECS_MASK_CHANGED); } }
Exec_stat MCStack::mode_getprop(uint4 parid, Properties which, MCExecPoint &ep, const MCString &carray, Boolean effective) { switch(which) { case P_REFERRING_STACK: if (m_mode_data -> referrer != NULL) return m_mode_data -> referrer -> getprop(0, P_LONG_ID, ep, False); else ep . clear(); break; case P_UNPLACED_GROUP_IDS: ep . clear(); if (controls != NULL) { uint4 t_count; t_count = 0; MCControl *t_control; t_control = controls; do { if (t_control -> gettype() == CT_GROUP && t_control -> getparent() != curcard) { ep . concatuint(t_control -> getid(), EC_RETURN, t_count == 0); t_count += 1; } t_control = t_control -> next(); } while(t_control != controls); } break; case P_IDE_OVERRIDE: ep.setboolean(getextendedstate(ECS_IDE)); break; default: return ES_NOT_HANDLED; } return ES_NORMAL; }
void MCStack::view_render(MCGContextRef p_target, MCRectangle p_rect) { if (getextendedstate(ECS_DONTDRAW)) return; // redraw borders if visible // scale & position stack redraw rect // update stack region // IM-2014-01-16: [[ StackScale ]] Transform redraw rect to stack coords in all cases MCRectangle t_update_rect; t_update_rect = MCRectangleGetTransformedBounds(p_rect, MCGAffineTransformInvert(m_view_transform)); MCGContextSave(p_target); MCGContextConcatCTM(p_target, m_view_transform); if (view_getfullscreen()) { // IM-2013-12-19: [[ ShowAll ]] Check if the view background needs to be drawn // IM-2013-12-20: [[ ShowAll ]] Draw the stack into its viewport if (!MCU_rect_in_rect(t_update_rect, m_view_stack_visible_rect)) { // IM-2013-10-08: [[ FullscreenMode ]] draw the view backdrop if the render area // falls outside the stack rect /* OVERHAUL - REVISIT: currently just draws black behind the stack area */ MCGContextAddRectangle(p_target, MCRectangleToMCGRectangle(t_update_rect)); MCGContextSetFillRGBAColor(p_target, 0.0, 0.0, 0.0, 1.0); MCGContextFill(p_target); } t_update_rect = MCU_intersect_rect(t_update_rect, m_view_stack_visible_rect); MCGContextClipToRect(p_target, MCRectangleToMCGRectangle(t_update_rect)); } render(p_target, t_update_rect); MCGContextRestore(p_target); }
void MCStack::realize() { if (MCnoui) { start_externals(); return; } if (MCModeMakeLocalWindows()) { uint32_t wstyle, exstyle; loadwindowshape(); getstyle(wstyle, exstyle); RECT wrect ; if ( getextendedstate(ECS_FULLSCREEN) ) { 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); } wrect = getwrect(rect, wstyle, exstyle); LONG x = wrect.left; LONG y = wrect.top; LONG width = wrect.right - wrect.left; LONG height = wrect.bottom - wrect.top; if (flags & F_WM_PLACE && !(state & CS_BEEN_MOVED)) x = CW_USEDEFAULT; window = new _Drawable; window->type = DC_WINDOW; window->handle.window = 0; // protect against creation callbacks // MW-2011-02-15: [[ Bug 9396 ]] Tooltips should have a shadow on Windows. Boolean isxpmenu = (mode == WM_PULLDOWN || mode == WM_POPUP || mode == WM_CASCADE || mode == WM_TOOLTIP) \ && (MCcurtheme && MCcurtheme->getthemeid() == LF_NATIVEWIN); // MW-2012-09-07: [[ Bug 10368 ]] If the 'no-shadow' bit is set, then we don't // want to use the menu class. if (getflag(F_DECORATIONS) && (decorations & WD_NOSHADOW) != 0) isxpmenu = False; HWND t_parenthwnd = NULL; // MW-2007-07-06: [[ Bug 3226 ]] If the platform is NT always create a Unicode window if ((MCruntimebehaviour & RTB_NO_UNICODE_WINDOWS) == 0 && !isxpmenu && mode < WM_PULLDOWN) window -> handle . window = (MCSysWindowHandle)CreateWindowExW(exstyle, MC_WIN_CLASS_NAME_W, WideCString(getname_cstring()),wstyle | WS_CLIPCHILDREN | WS_CLIPSIBLINGS, x, y, width, height, t_parenthwnd, NULL, MChInst, NULL); else window->handle.window = (MCSysWindowHandle)CreateWindowExA(exstyle, isxpmenu? MC_MENU_WIN_CLASS_NAME: mode >= WM_PULLDOWN ? MC_POPUP_WIN_CLASS_NAME : MC_WIN_CLASS_NAME, getname_cstring(), wstyle | WS_CLIPCHILDREN | WS_CLIPSIBLINGS, x, y, width, height, t_parenthwnd, NULL, MChInst, NULL); SetWindowLongA((HWND)window->handle.window, GWL_USERDATA, mode); if (flags & F_DECORATIONS && !(decorations & WD_SHAPE) && !(decorations & WD_CLOSE)) EnableMenuItem(GetSystemMenu((HWND)window->handle.window, False), SC_CLOSE, MF_BYCOMMAND | MF_GRAYED); if (m_window_shape != nil && m_window_shape -> is_sharp) { MCRegionRef t_region; t_region = (MCRegionRef)m_window_shape -> handle; MCRegionOffset(t_region, rect . x - wrect . left, rect . y - wrect . top); MCRegionSetAsWindowShape(t_region, window->handle.window); // The window now owns the region. m_window_shape -> handle = nil; } if ((m_window_shape == NULL || m_window_shape -> is_sharp) && blendlevel != 100) setopacity(blendlevel * 255 / 100); } start_externals(); }
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(); }