void MCControl::layer_setrect(const MCRectangle& p_new_rect, bool p_redraw_all) { if (!opened) { setrect(p_new_rect); return; } // Check the visibility state of the object. bool t_is_visible; t_is_visible = isvisible() || MCshowinvisibles; // If we are not a sprite, and are invisible there is nothing to do; otherwise // we must at least try to dump cached updated parts of the sprite. if (!layer_issprite() && !t_is_visible) { setrect(p_new_rect); return; } MCRectangle t_old_effectiverect; t_old_effectiverect = geteffectiverect(); // If the rect has changed size and we aren't a scrolling layer, then we // redraw all. if (!layer_isscrolling() && (rect . width != p_new_rect . width || rect . height != p_new_rect . height)) p_redraw_all = true; setrect(p_new_rect); layer_changeeffectiverect(t_old_effectiverect, p_redraw_all, t_is_visible); }
static void MyThemeButtonDrawCallback ( const Rect *bounds, ThemeButtonKind kind, const ThemeButtonDrawInfo *info, UInt32 refcon, SInt16 depth, Boolean isColorDev) { #pragma unused (kind, info, refcon, depth, isColorDev) /* 7.0b48 PBS: draw the arrow for a pushbutton. It will be centered. */ Rect rarrow; //ptrstring bsptr = (ptrstring) refcon; setrect (&rarrow, 0, 0, 9, 9); centerrect (&rarrow, *bounds); rarrow.left++; /*it appears to need it*/ DrawThemePopupArrow (&rarrow, kThemeArrowRight, kThemeArrow9pt, kThemeStateActive, NULL, 0); } /*MyThemeButtonDrawCallback*/
static void remove_block(int x, int y, int z, int xw, int yw, int zw) { lpoint3d p1; p1.x = 1024-y; p1.y = 1024-x; p1.z = 256 - z; lpoint3d p2; p2.x = 1024-(y + yw); p2.y = 1024-(x + xw); p2.z = 256 - (z + zw); setrect(&p1, &p2, -1); updatevxl(); }
boolean wpverbnew (Handle hdata, hdlexternalvariable *hvariable) { /* 9/11/91 dmb: now take hdata parameter. note: for now, we're assuming that only tablescrap calls us with non-nil hdata. to allow it to be either WS text or plain text, we actually ignore hdata and let wppaste to the interpretation. */ register hdlwpvariable hv; hdlwprecord hwp; Rect r; if (!newwpvariable (true, false, 0L, (hdlwpvariable *) hvariable)) return (false); hv = (hdlwpvariable) *hvariable; /*copy into register*/ setrect (&r, 0, 0, infinity, infinity); /*very large clip & bounds area*/ if (!wpnewrecord (r, &hwp)) { disposehandle ((Handle) hv); return (false); } if (hdata != nil) { /*we've been given intial text*/ shellpushglobals (nil); /*preserve our globals*/ wppushdata (hwp); /* wpsettexthandle (hdata); */ wppaste (true); /*we're assuming that only tablescrap calls us with data*/ wppopdata (); shellpopglobals (); } wpverblinkvariable (hwp, hv); /*set up pointers to each other*/ return (true); } /*wpverbnew*/
static boolean drawline (hdlheadrecord hnode) { register hdlheadrecord h = hnode; Point pt; Rect r; short listnum; short iconnum; tyfinderinfo info; byte typestring [6]; boolean fltextmode = opeditingtext (hnode); opgetrefcon (hnode, &info, sizeof (info)); GetPen (&pt); setrect (&r, pt.v - 12, pt.h - 2, pt.v + 4, pt.h + 14); listnum = findersmalliconlist; if (fltextmode) ++listnum; plotsmallicon (r, listnum, geticonnum (h), false); movepento (pt.h + widthsmallicon, pt.v); if (info.flalias) pushstyle ((**outlinedata).fontnum, (**outlinedata).fontsize, italic); if (fltextmode) opeditupdate (); else pendrawstring ((**h).headstring); if (info.flalias) popstyle (); movepento (pt.h + namecolwidth, pt.v); ostypetostring (info.filetype, typestring); pendrawstring (typestring); return (true); } /*drawline*/
boolean shellinitprint (void) { /* 9/5/90 dmb: close print resources after initializing stuff 10/21/91 dmb: added margins field to print info; structure is now here to have user-settable margins. 12/31/91 dmb: initialize shellprintinfo.paperrect to standard 72dpi values in case no printer is chosen and shellcopyprintinfo never gets called 1/18/93 dmb: don't call shellcheckprinterror the first time; if PrOpen fails here, we don't want to raise an alert. */ #if MACVERSION && !TARGET_API_MAC_CARBON Handle h; #endif currentprintport = NULL; clearbytes (&shellprintinfo, longsizeof (shellprintinfo)); setrect (&shellprintinfo.margins, 36, 36, 36, 36); setrect (&shellprintinfo.paperrect, 5, 6, 725, 546); /*defaults in case PrOpen fails*/ shellprintinfo.scaleMult = 1; shellprintinfo.scaleDiv = 1; #ifdef MACVERSION # if TARGET_API_MAC_CARBON == 1 //I realized this is only called once during the startup of the app. //Carbon printing really doesn't need any global structures. Better to //allocate them as we use them. // Nope. // We need a global var for calling page setup shellprintinfo.printport = nil; shellprintinfo.printhandle = nil; shellprintinfo.pageformat = nil; shellprintinfo.printsettings = nil; // shellprintinfo.pagerect = {0,0,0,0}; # else if (!newclearhandle (longsizeof (TPrint), &h)) return (false); shellprintinfo.printhandle = (THPrint) h; /*copy into print record*/ PrOpen (); /*initialize the Mac print manager*/ if (PrError () != noErr) goto error; PrintDefault (shellprintinfo.printhandle); /*set default print record*/ PrClose (); /*shouldn't leave print resources open all the time*/ if (!shellcheckprinterror (false)) goto error; # endif #endif #ifdef WIN95VERSION ZeroMemory (&shellprintinfo.pagesetupinfo, sizeof (PAGESETUPDLG)); shellprintinfo.pagesetupinfo.lStructSize = sizeof (PAGESETUPDLG); shellprintinfo.pagesetupinfo.hwndOwner = NULL; shellprintinfo.pagesetupinfo.Flags = PSD_RETURNDEFAULT | PSD_NOWARNING; if (! PageSetupDlg (&shellprintinfo.pagesetupinfo)) { if (CommDlgExtendedError() != 0) goto error; } #endif //#if !TARGET_API_MAC_CARBON shellcopyprintinfo (); /*copies fields from handle into record*/ //#endif return (true); #if !defined(MACVERSION) || !TARGET_API_MAC_CARBON error: #endif /* shelldisposeprintinfo (); */ return (false); } /*shellinitprint*/
int main(int argc, char *argv[]) { Display *disp; int scr, prepare, tmp; Window selector, rootwin; XEvent event; cairo_surface_t *canvas; Atom setfull[2]; XWindowAttributes scrattr; XSetWindowAttributes winattr; XVisualInfo vis; ScreenshotLoc initloc, endloc; pngstream pngstr; XImage *ximg; // Get the user's display if (!(disp = XOpenDisplay(NULL))) { printf("Could not get display!\n"); } // Get screen, root scr = DefaultScreen(disp); rootwin = RootWindow(disp, scr); XMatchVisualInfo(disp, scr, 32, TrueColor, &vis); // Get screen stats for width/height XGetWindowAttributes(disp, rootwin, &scrattr); // Set window attributes winattr.colormap = XCreateColormap(disp, rootwin, vis.visual, AllocNone); winattr.event_mask = ExposureMask | KeyPressMask | KeyReleaseMask | ButtonPressMask | ButtonReleaseMask | Button1MotionMask; winattr.background_pixmap = None; winattr.border_pixel = 0; // Make the selector window selector = XCreateWindow(disp, rootwin, 0, 0, scrattr.width, scrattr.height, 0, vis.depth, InputOutput, vis.visual, CWColormap | CWEventMask | CWBackPixmap | CWBorderPixel, &winattr); XStoreName(disp, selector, "cloudselect"); // We need key release (any key == cancel), and button for hold/release //XSelectInput(disp, selector, ExposureMask|ButtonPressMask|ButtonReleaseMask|KeyReleaseMask); XMapWindow(disp, selector); // set our window to fullscreen setfull[0] = XInternAtom(disp, "_NET_WM_STATE_FULLSCREEN", False); setfull[1] = None; XChangeProperty(disp, selector, XInternAtom(disp, "_NET_WM_STATE", False), XA_ATOM, 32, PropModeReplace, (unsigned char *)setfull, 1); RemoveDecorations(disp, selector); // make a cairo surface to paint on canvas = cairo_xlib_surface_create(disp, selector, vis.visual, scrattr.width, scrattr.height); initloc.x = initloc.y = -1; prepare = 0; while (get_xevents(disp, &event)) { if (event.type == Expose) { paint(canvas, scrattr.width, scrattr.height); } else if (event.type == ButtonPress) { if (event.xbutton.button == Button1) { initloc.x = event.xbutton.x; initloc.y = event.xbutton.y; } else { printf("[INFO] Operation cancelled.\n"); break; } } else if (event.type == ButtonRelease) { // We have completed selecting! if (event.xbutton.button == Button1) { endloc.x = event.xbutton.x; endloc.y = event.xbutton.y; // Negative resolutions are bad and make no sense anyway if (endloc.x < initloc.x) { tmp = endloc.x; endloc.x = initloc.x; initloc.x = tmp; } if (endloc.y < initloc.y) { tmp = endloc.y; endloc.y = initloc.y; initloc.y = tmp; } // Debug printf()s printf("Initial co-ordinates: (%d, %d)\n", initloc.x, initloc.y); printf("Final co-ordinates: (%d, %d)\n", endloc.x, endloc.y); printf("Dimensions: %dx%d\n", endloc.y-initloc.y, endloc.x-initloc.x); // Get selection as XImage ximg = XGetImage(disp, rootwin, initloc.x, initloc.y, (endloc.x-initloc.x), (endloc.y-initloc.y), XAllPlanes(), ZPixmap); // Pass XImage to mkpngstream pngstr = mkpngstream(disp, DefaultScreen(disp), vis.visual, ximg, initloc, endloc); // Make PNG stream to send to CloudApp if (!pngstr.data) { printf("Making PNG stream failed...\n"); if (ximg) { XFree(ximg); // XFree doesn't like NULL pointers } } else { test_write_file(pngstr, "test.png"); } break; } else { // ... Wrong button! printf("[INFO Operation cancelled.\n"); break; } } else if (event.type == MotionNotify) { // We only track Button1Motion, so... endloc.x = event.xmotion.x; endloc.y = event.xmotion.y; printf("[INFO] endloc.x: %d\nendloc.y: %d\n", endloc.x, endloc.y); printf("[INFO] initloc.x: %d\ninitloc.y: %d\n", initloc.x, initloc.y); paint(canvas, scrattr.width, scrattr.height); setrect(canvas, initloc, endloc); } else if (event.type == KeyRelease) { if (prepare == 1) break; } else if (event.type == KeyPress) { prepare = 1; } } cairo_surface_destroy(canvas); XCloseDisplay(disp); return 0; }
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(); }