/*================================ PointInSelection =================================*/ Boolean PTPaintSelection::PointInSelection( SInt32 h, SInt32 v ) { // if ( this->IsEmpty() ) return( false ); Point pt; SetPt( &pt, h, v ); return( PtInRgn( pt, mRegion ) ); }
static pascal long WindowMaskProc(short varCode, WindowRef window, short message, long param) { #pragma unused( varCode ) switch (message) { case kWindowMsgGetFeatures: *(OptionBits*) param = kWindowCanGetWindowRegion | kWindowDefSupportsColorGrafPort; return 1; case kWindowMsgGetRegion: { GetWindowRegionRec* rgnRec = (GetWindowRegionRec*) param; switch (rgnRec->regionCode) { case kWindowTitleBarRgn: case kWindowTitleTextRgn: case kWindowCloseBoxRgn: case kWindowZoomBoxRgn: case kWindowDragRgn: case kWindowGrowRgn: case kWindowCollapseBoxRgn: SetEmptyRgn(rgnRec->winRgn); break; case kWindowStructureRgn: case kWindowContentRgn: getWindowContentRegion(window, rgnRec->winRgn); break; case kWindowUpdateRgn: break; case kWindowOpaqueRgn: SetEmptyRgn(rgnRec -> winRgn); break; default: return errWindowRegionCodeInvalid; } return noErr; } case kWindowMsgHitTest: { Point hitPoint; static RgnHandle tempRgn = nil; if (!tempRgn) tempRgn = NewRgn(); SetPt(&hitPoint, LoWord(param), HiWord(param));//get the point clicked if (PtInRgn(hitPoint, getWindowContentRegion(window, tempRgn))) return wInContent; else return wNoHit; } break; default: break; } return 0; }
//_______________________________________________________________________________ void AdjustLocation (WindowPtr win) { Point pt; pt.h = win->portRect.left + 6; // 6 is enough to grab pt.v = win->portRect.top + 6; // 6 is enough to grab LocalToGlobal(&pt); if (!PtInRgn( pt, GetGrayRgn())) { MoveWindow (win, qd.screenBits.bounds.left + 50, qd.screenBits.bounds.top + 50, false); } }
SInt32 myWindowHitTest(WindowRef window,SInt32 param) { /*------------------------------------------------------ Determine the region of the window which was hit --------------------------------------------------------*/ Point hitPoint; static RgnHandle tempRgn=nil; if(!tempRgn) tempRgn=NewRgn(); SetPt(&hitPoint,LoWord(param),HiWord(param));//get the point clicked if(IsWindowHilited(window)){ //make sure the window is in front for these if(PtInRgn(hitPoint,getWindowGrowBoxRegion(window,tempRgn)))//in GrowBox? return wInGrow; if(PtInRgn(hitPoint,getWindowCloseBoxRegion(window,tempRgn)))//in the Close Box? return wInGoAway; if(PtInRgn(hitPoint,getWindowZoomBoxRegion(window,tempRgn)))//in the Zoom Box? return wInZoomOut; //Mac OS 8.0 or later if(PtInRgn(hitPoint,getWindowCollapseBoxRegion(window,tempRgn)))//in the Collapse Box? return wInCollapseBox; } //Mac OS 8.5 or later if(PtInRgn(hitPoint,getWindowContentRegion(window,tempRgn))) //in window content region? return wInContent; if(PtInRgn(hitPoint,getWindowDragRegion(window,tempRgn)))//in window drag region? return wInDrag; return wNoHit;//no significant area was hit. }
P2(PUBLIC pascal trap, void, SystemClick, EventRecord *, evp, WindowPtr, wp) { Point p; LONGINT pointaslong, val; Rect bounds; LONGINT templ; if (wp) { p.h = CW(evp->where.h); p.v = CW(evp->where.v); if (PtInRgn (p, WINDOW_STRUCT_REGION (wp))) { pointaslong = ((LONGINT)p.v << 16)|(unsigned short)p.h; val = WINDCALL((WindowPtr) wp, wHit, pointaslong); switch (val) { case wInContent: if (WINDOW_HILITED_X (wp)) { templ = (LONGINT) (long) RM(evp); Control (WINDOW_KIND (wp), accEvent, (Ptr) &templ); } else SelectWindow(wp); break; case wInDrag: bounds.top = CW (CW (MBarHeight) + 4); bounds.left = CW (CW (GD_BOUNDS (MR (TheGDevice)).left) + 4); bounds.bottom = CW (CW (GD_BOUNDS (MR (TheGDevice)).bottom) - 4); bounds.right = CW (CW (GD_BOUNDS (MR (TheGDevice)).right) - 4); DragWindow(wp, p, &bounds); break; case wInGoAway: if (TrackGoAway(wp, p)) CloseDeskAcc (WINDOW_KIND (wp)); break; } } else { if (DeskHook) { ROMlib_hook(desk_deskhooknumber); EM_D0 = -1; EM_A0 = (LONGINT) (long) US_TO_SYN68K(evp); CALL_EMULATOR((syn68k_addr_t) (long) CL((long) DeskHook)); } } } }
void QTApp_Idle (WindowReference theWindow) { WindowObject myWindowObject = NULL; GrafPtr mySavedPort; GetPort(&mySavedPort); MacSetPort(QTFrame_GetPortFromWindowReference(theWindow)); myWindowObject = QTFrame_GetWindowObjectFromWindow(theWindow); if (myWindowObject != NULL) { MovieController myMC = NULL; myMC = (**myWindowObject).fController; if (myMC != NULL) { // run any idle-time tasks for the movie #if TARGET_OS_MAC // restore the cursor to the arrow // if it's outside the front movie window or outside the window's visible region if (theWindow == QTFrame_GetFrontMovieWindow()) { Rect myRect; Point myPoint; RgnHandle myVisRegion; Cursor myArrow; GetMouse(&myPoint); myVisRegion = NewRgn(); GetPortVisibleRegion(QTFrame_GetPortFromWindowReference(theWindow), myVisRegion); GetWindowPortBounds(theWindow, &myRect); if (!MacPtInRect(myPoint, &myRect) || !PtInRgn(myPoint, myVisRegion)) MacSetCursor(GetQDGlobalsArrow(&myArrow)); DisposeRgn(myVisRegion); } #endif // TARGET_OS_MAC } } // grant the sequence grabber some processor time if (gSeqGrabber != NULL) SGIdle(gSeqGrabber); MacSetPort(mySavedPort); }
Boolean RetrieveSize (short kind, short top, short left, short *height, short *width) { Point p; if (kind < 0 || kind > kLastWindowKind) { return 0; } InitWinFile (); if (!savePos [kind].validSize) { return 0; } *width = savePos [kind].width; *height = savePos [kind].height; p.h = left + *width; p.v = top + *height; return PtInRgn (p, GetGrayRgn ()); }
void QTApp_Idle (WindowReference theWindow) { WindowObject myWindowObject = NULL; GrafPtr mySavedPort; GetPort(&mySavedPort); MacSetPort(QTFrame_GetPortFromWindowReference(theWindow)); myWindowObject = QTFrame_GetWindowObjectFromWindow(theWindow); if (myWindowObject != NULL) { MovieController myMC = NULL; myMC = (**myWindowObject).fController; if (myMC != NULL) { // run any idle-time tasks for the movie #if TARGET_OS_MAC // restore the cursor to the arrow // if it's outside the front movie window or outside the window's visible region if (theWindow == QTFrame_GetFrontMovieWindow()) { Rect myRect; Point myPoint; RgnHandle myVisRegion; Cursor myArrow; GetMouse(&myPoint); myVisRegion = NewRgn(); GetPortVisibleRegion(QTFrame_GetPortFromWindowReference(theWindow), myVisRegion); GetWindowPortBounds(theWindow, &myRect); if (!MacPtInRect(myPoint, &myRect) || !PtInRgn(myPoint, myVisRegion)) MacSetCursor(GetQDGlobalsArrow(&myArrow)); DisposeRgn(myVisRegion); } #endif // TARGET_OS_MAC } // see whether the user has added a text track behind our backs (e.g. by pasting some text) QTText_SyncWindowData(myWindowObject); } MacSetPort(mySavedPort); }
static SInt32 wxShapedMacWindowHitTest(WindowRef window,SInt32 param) { /*------------------------------------------------------ Determine the region of the window which was hit --------------------------------------------------------*/ Point hitPoint; static RgnHandle tempRgn=nil; if(!tempRgn) tempRgn=NewRgn(); SetPt(&hitPoint,LoWord(param),HiWord(param));//get the point clicked //Mac OS 8.5 or later wxShapedMacWindowStructureRegion(window, tempRgn); if (PtInRgn(hitPoint, tempRgn)) //in window content region? return wInContent; return wNoHit;//no significant area was hit. }
Boolean RetrievePosition (short kind, short *top, short *left) { Point p; if (kind < 0 || kind > kLastWindowKind) { dprintf ("Retrieve Bad kind %d", kind); return 0; } InitWinFile (); if (!savePos [kind].validPos) { dprintf ("Retrieve Not stored kind %d", kind); return 0; } p.v = savePos [kind].top; p.h = savePos [kind].left; *left = p.h; *top = p.v; dprintf ("Retrieve Kind %d Pt (%d,%d)", kind, p.h, p.v); return (PtInRgn (p, GetGrayRgn ())); }
void check_input_events() { OSStatus err; EventTargetRef target; EventRef event; UInt32 event_class, event_kind; byte mac_keycode; UInt32 keycode; UInt32 modifiers; Point mouse_point, mouse_delta_point; WindowRef window_ref; int button, button_state; EventMouseButton mouse_button; int handled; int mouse_events; int is_up; int in_win; int ignore; if(g_quit_seen) { exit(0); } SetPortWindowPort(g_main_window); mouse_events = 0; target = GetEventDispatcherTarget(); while(1) { err = ReceiveNextEvent(0, NULL, kEventDurationNoWait, true, &event); if(err == eventLoopTimedOutErr) { break; } if(err != noErr) { printf("ReceiveNextEvent err: %d\n", (int)err); break; } event_class = GetEventClass(event); event_kind = GetEventKind(event); handled = 0; switch(event_class) { case kEventClassKeyboard: handled = 1; keycode = 0; modifiers = 0; GetEventParameter(event, kEventParamKeyMacCharCodes, typeChar, NULL, sizeof(byte), NULL, &mac_keycode); GetEventParameter(event, kEventParamKeyCode, typeUInt32, NULL, sizeof(UInt32), NULL, &keycode); GetEventParameter(event, kEventParamKeyModifiers, typeUInt32, NULL, sizeof(UInt32), NULL, &modifiers); mac_update_modifiers((word32)modifiers); // Key up/down event is_up = -1; switch(event_kind) { case kEventRawKeyDown: is_up = 0; //printf("key down: %02x, %08x\n", // (int)mac_keycode, (int)keycode); break; case kEventRawKeyUp: is_up = 1; //printf("key up: %02x, %08x\n", // (int)mac_keycode, (int)keycode); break; case kEventRawKeyModifiersChanged: is_up = -1; //printf("key xxx: %08x\n", (int)modifiers); break; } if(is_up >= 0) { adb_physical_key_update((int)keycode, is_up); } break; case kEventClassMouse: handled = 2; mouse_events++; GetEventParameter(event, kEventParamMouseLocation, typeQDPoint, NULL, sizeof(Point), NULL, &mouse_point); GetWindowRegion(g_main_window, kWindowContentRgn, g_event_rgnhandle); in_win = PtInRgn(mouse_point, g_event_rgnhandle); // in_win = 1 if it was in the contect region of window err = GetEventParameter(event, kEventParamMouseDelta, typeQDPoint, NULL, sizeof(Point), NULL, &mouse_delta_point); button = 0; button_state = -1; switch(event_kind) { case kEventMouseDown: button_state = 7; handled = 3; break; case kEventMouseUp: button_state = 0; handled = 3; break; } if(button_state >= 0) { GetEventParameter(event, kEventParamMouseButton, typeMouseButton, NULL, sizeof(EventMouseButton), NULL, &mouse_button); button = mouse_button; if(button > 1) { button = 4 - button; button = 1 << button; } ignore = (button_state != 0) && (!in_win || g_ignore_next_click); ignore = ignore || !g_mainwin_active; if(ignore) { // Outside of A2 window, ignore clicks button = 0; } if(button_state == 0) { g_ignore_next_click = 0; } } GlobalToLocal(&mouse_point); if(g_warp_pointer) { if(err == 0) { g_mac_mouse_x += mouse_delta_point.h; g_mac_mouse_y += mouse_delta_point.v; } mac_warp_mouse(); } else { g_mac_mouse_x = mouse_point.h - g_video_act_margin_left; g_mac_mouse_y = mouse_point.v - g_video_act_margin_top; } #if 0 printf("Mouse %d at: %d,%d button:%d, button_st:%d\n", mouse_events, g_mac_mouse_x, g_mac_mouse_y, button, button_state); printf("Mouse deltas: err:%d, %d,%d\n", (int)err, mouse_delta_point.h, mouse_delta_point.v); #endif update_mouse(g_mac_mouse_x, g_mac_mouse_y, button_state, button & 7); if(g_warp_pointer) { g_mac_mouse_x = A2_WINDOW_WIDTH/2; g_mac_mouse_y = A2_WINDOW_HEIGHT/2; update_mouse(g_mac_mouse_x, g_mac_mouse_y,0,-1); } break; case kEventClassApplication: switch(event_kind) { case kEventAppActivated: handled = 1; g_mainwin_active = 1; window_ref = 0; GetEventParameter(event, kEventParamWindowRef, typeWindowRef, NULL, sizeof(WindowRef), NULL, &window_ref); if(window_ref == g_main_window) { g_ignore_next_click = 1; } break; case kEventAppDeactivated: handled = 1; g_mainwin_active = 0; g_ignore_next_click = 1; break; } break; } // show_event(event_class, event_kind, handled); if(handled != 1) { (void)SendEventToEventTarget(event, target); } ReleaseEvent(event); } return; }