void MacIdle(void) { extern logical anywarns; static long time = 0; EventRecord myEvent; WindowPtr whichWindow; #if TARGET_API_MAC_CARBON Rect tempRect; #endif char theChar; if (TickCount()<time) return; if (mac_quit_now) { anywarns = FALSE; /* kludge so that window doesn't sit around */ my_exit(1); } #if !TARGET_API_MAC_CARBON SystemTask(); #endif if (WaitNextEvent(everyEvent, &myEvent, 1, nil)) { if (!SIOUXHandleOneEvent(&myEvent)) switch (myEvent.what) { case mouseDown: switch (FindWindow(myEvent.where,&whichWindow)) { case inMenuBar: MenuSelect(myEvent.where); break; #if !TARGET_API_MAC_CARBON case inSysWindow: SystemClick(&myEvent,whichWindow); break; #endif case inContent: SelectWindow(whichWindow); break; case inDrag: #if TARGET_API_MAC_CARBON GetRegionBounds(GetGrayRgn(),&tempRect); DragWindow(whichWindow,myEvent.where,&tempRect); #else DragWindow(whichWindow,myEvent.where,&qd.screenBits.bounds); #endif break; } break; case keyDown: theChar = myEvent.message & charCodeMask; break; case updateEvt: BeginUpdate((WindowPtr) myEvent.message); EndUpdate((WindowPtr) myEvent.message); break; } } time=TickCount()+20; }
void doEventLoop() { EventRecord event; WindowPtr window; short clickArea; Rect screenRect; RgnHandle rgnHandle = NewRgn(); for (;;) { if (WaitNextEvent( everyEvent, &event, 0, nil )) { if (event.what == mouseDown) { clickArea = FindWindow( event.where, &window ); if (clickArea == inDrag) { //screenRect = (**GetGrayRgn ()).rgnBBox; GetRegionBounds(GetGrayRgn(), &screenRect); DragWindow( window, event.where, &screenRect ); } else if (clickArea == inContent) { if (window != FrontWindow()) SelectWindow( window ); } else if (clickArea == inGoAway) if (TrackGoAway( window, event.where )) return; } else if (event.what == updateEvt) { window = (WindowPtr)event.message; //SetPort( window ); SetPortWindowPort( window ); BeginUpdate( window ); drawPixelImageData(); EndUpdate( window ); QDFlushPortBuffer(GetWindowPort(window), GetPortVisibleRegion(GetWindowPort(window), rgnHandle)); } else if (event.what == activateEvt) { /*if (event.modifiers & activeFlag) { window = (WindowPtr)event.message; SetPortWindowPort(window); drawPixelImageData(); QDFlushPortBuffer(GetWindowPort(window), GetPortVisibleRegion(GetWindowPort(window), rgnHandle)); }*/ /*if (event.modifiers & activeFlag) PostEvent(updateEvt, (unsigned long)gWindow);*/ } } } DisposeRgn(rgnHandle); }
void myShowMenuBar(void) { if (!savedgray) return; CopyRgn(savedgray,GetGrayRgn()); LMSetMBarHeight(savedmbh); DisposeRgn(savedgray); savedgray=NULL; }
void DoDrag(WindowPtr myWindow, Point mouseloc) { Rect dragBounds; dragBounds = (**GetGrayRgn()).rgnBBox; DragWindow(myWindow,mouseloc,&dragBounds); aglUpdateContext(aglGetCurrentContext()); }
void doEventLoop() { EventRecord anEvent; WindowPtr evtWind; short clickArea; Rect screenRect; Point thePoint; Rect zoomFrom, zoomTo; zoomFrom.top = zoomTo.top = -1; while (!gDone) { if (WaitNextEvent( everyEvent, &anEvent, 0, nil )) { if (anEvent.what == mouseDown) { clickArea = FindWindow( anEvent.where, &evtWind ); if (clickArea == inDrag) { GetRegionBounds( GetGrayRgn(), &screenRect ); DragWindow( evtWind, anEvent.where, &screenRect ); } else if (clickArea == inContent) { if (evtWind != FrontWindow()) SelectWindow( evtWind ); else { thePoint = anEvent.where; GlobalToLocal( &thePoint ); //Handle click in window content here GetRect(&zoomFrom, &zoomTo); } } else if (clickArea == inGoAway) if (TrackGoAway( evtWind, anEvent.where )) gDone = true; } else if (anEvent.what == updateEvt) { evtWind = (WindowPtr)anEvent.message; SetPortWindowPort( evtWind ); BeginUpdate( evtWind ); //Call Draw Function here.... if (zoomFrom.top != -1) FrameRect(&zoomFrom); if (zoomTo.top != -1) FrameRect(&zoomTo); EndUpdate (evtWind); } } } }
static void CenterWindow(WindowRef ref) { Rect rect, bounds; GetWindowPortBounds(ref, &rect); GetRegionBounds(GetGrayRgn(), &bounds); int lx = bounds.right - bounds.left; int ly = bounds.bottom - bounds.top; rect.left = bounds.left + ((lx - (rect.right - rect.left))/2); rect.top = bounds.top + ((ly - (rect.bottom - rect.top))/2); MoveWindow(ref, rect.left, rect.top, true); }
//_______________________________________________________________________________ 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); } }
/* restores former dialog size and (on Mac) position */ bool CDlgItemProperties::RestoreState() { wxConfigBase* pConfig = wxConfigBase::Get(FALSE); int iWidth, iHeight; wxASSERT(pConfig); if (!pConfig) return false; pConfig->SetPath(m_strBaseConfigLocation); pConfig->Read(wxT("Width"), &iWidth, wxDefaultCoord); pConfig->Read(wxT("Height"), &iHeight, wxDefaultCoord); #ifndef __WXMAC__ // Set size to saved values or defaults if no saved values SetSize(iWidth, iHeight); #else int iTop, iLeft; pConfig->Read(wxT("YPos"), &iTop, wxDefaultCoord); pConfig->Read(wxT("XPos"), &iLeft, wxDefaultCoord); // If either co-ordinate is less then 0 then set it equal to 0 to ensure // it displays on the screen. if ((iLeft < 0) && (iLeft != wxDefaultCoord)) iLeft = 30; if ((iTop < 0) && (iTop != wxDefaultCoord)) iTop = 30; // Set size and position to saved values or defaults if no saved values SetSize(iLeft, iTop, iWidth, iHeight, wxSIZE_USE_EXISTING); // Now make sure window is on screen GetScreenPosition(&iLeft, &iTop); GetSize(&iWidth, &iHeight); Rect titleRect = {iTop, iLeft, iTop+22, iLeft+iWidth }; InsetRect(&titleRect, 5, 5); // Make sure at least a 5X5 piece visible RgnHandle displayRgn = NewRgn(); CopyRgn(GetGrayRgn(), displayRgn); // Region encompassing all displays Rect menuRect = ((**GetMainDevice())).gdRect; menuRect.bottom = GetMBarHeight() + menuRect.top; RgnHandle menuRgn = NewRgn(); RectRgn(menuRgn, &menuRect); // Region hidden by menu bar DiffRgn(displayRgn, menuRgn, displayRgn); // Subtract menu bar region if (!RectInRgn(&titleRect, displayRgn)) { iTop = iLeft = 30; SetSize(iLeft, iTop, iWidth, iHeight, wxSIZE_USE_EXISTING); } DisposeRgn(menuRgn); DisposeRgn(displayRgn); #endif return true; }
void CDlgMessages::RestoreWindowDimensions() { wxString strBaseConfigLocation = wxString(wxT("/Simple/Messages")); wxConfigBase* pConfig = wxConfigBase::Get(FALSE); bool bWindowIconized = false; bool bWindowMaximized = false; int iHeight = 0; int iWidth = 0; int iTop = 0; int iLeft = 0; wxASSERT(pConfig); pConfig->SetPath(strBaseConfigLocation); pConfig->Read(wxT("YPos"), &iTop, 30); pConfig->Read(wxT("XPos"), &iLeft, 30); pConfig->Read(wxT("Width"), &iWidth, 640); pConfig->Read(wxT("Height"), &iHeight, 480); pConfig->Read(wxT("WindowIconized"), &bWindowIconized, false); pConfig->Read(wxT("WindowMaximized"), &bWindowMaximized, false); #ifndef __WXMAC__ Iconize(bWindowIconized); Maximize(bWindowMaximized); if (!IsIconized() && !IsMaximized()) { SetSize(-1, -1, iWidth, iHeight); } #else // ! __WXMAC__ // If the user has changed the arrangement of multiple // displays, make sure the window title bar is still on-screen. Rect titleRect = {iTop, iLeft, iTop+22, iLeft+iWidth }; InsetRect(&titleRect, 5, 5); // Make sure at least a 5X5 piece visible RgnHandle displayRgn = NewRgn(); CopyRgn(GetGrayRgn(), displayRgn); // Region encompassing all displays Rect menuRect = ((**GetMainDevice())).gdRect; menuRect.bottom = GetMBarHeight() + menuRect.top; RgnHandle menuRgn = NewRgn(); RectRgn(menuRgn, &menuRect); // Region hidden by menu bar DiffRgn(displayRgn, menuRgn, displayRgn); // Subtract menu bar retion if (!RectInRgn(&titleRect, displayRgn)) iTop = iLeft = 30; DisposeRgn(menuRgn); DisposeRgn(displayRgn); SetSize(iLeft, iTop, iWidth, iHeight); #endif // ! __WXMAC__ }
void doEventLoop() { EventRecord anEvent; WindowPtr evtWind; short clickArea; Rect screenRect; while (!gDone) { if (WaitNextEvent( everyEvent, &anEvent, 0, nil )) { if (anEvent.what == mouseDown) { clickArea = FindWindow( anEvent.where, &evtWind ); if (clickArea == inMenuBar) handleMenuSelection(MenuSelect(anEvent.where)); else if (clickArea == inDrag) { //screenRect = (**GetGrayRgn ()).rgnBBox; GetRegionBounds(GetGrayRgn(), &screenRect); DragWindow( evtWind, anEvent.where, &screenRect ); } else if (clickArea == inContent) { if (evtWind != FrontWindow()) SelectWindow( evtWind ); } else if (clickArea == inGoAway) if (TrackGoAway( evtWind, anEvent.where )) gDone = true; } else if (anEvent.what == updateEvt) { evtWind = (WindowPtr)anEvent.message; //SetPort( evtWind ); SetPortWindowPort( evtWind ); BeginUpdate( evtWind ); drawImage( evtWind ); EndUpdate (evtWind); } else if (anEvent.what == autoKey || anEvent.what == keyDown) handleKeyPress(&anEvent); } } }
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 ()); }
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 myHideMenuBar( GDHandle ignoredDev) { RgnHandle gray,rect; GDHandle dev; (void)ignoredDev; if (savedgray) return; gray=GetGrayRgn(); savedgray=NewRgn(); rect=NewRgn(); CopyRgn(gray,savedgray); for (dev=GetDeviceList(); dev; dev=GetNextDevice(dev)) { if (!TestDeviceAttribute(dev,screenDevice) || !TestDeviceAttribute(dev,screenActive)) continue; RectRgn(rect,&(*dev)->gdRect); UnionRgn(gray,rect,gray); } DisposeRgn(rect); savedmbh=LMGetMBarHeight(); LMSetMBarHeight(0); }
Boolean ThermDialog::DisplayTherm(int k,int maxk,unsigned char *st) { Rect r; int maxr; Handle h; short itemType; long temp; GrafPtr tdp; WindowPtr window; short thePart; Rect screenRect, updateRect; Point aPoint = {100, 100}; Boolean QuitFlag = FALSE; short item = 0; EventRecord event; short the_part; DialogPtr hitdp; GetPort(&tdp); SetPort(dp); if (st != NULL) { GetDItem (dp,ids[THERM_TEXT], &itemType, &h, &r); SetIText(h,st); } GetDItem (dp, ids[THERM_BOX], &itemType, &h, &r); if (k == -1) k = old_k; if (maxk == -1) maxk = old_maxk; maxr = r.right; temp = ((long)k*((long)r.right - (long)r.left))/(long)maxk; r.right = r.left + temp; if (r.right>maxr) r.right=maxr; old_k = k; old_maxk = maxk; PenNormal (); PenPat(&qd.gray); PaintRect(&r); PenNormal (); SetPort(tdp); if (GetNextEvent(0xFFFF,&event)) { if (event.what == mouseDown) { the_part = FindWindow(event.where, &window); if (IsDialogEvent(&event)) { DialogSelect(&event,&hitdp,&item); if ((hitdp == dp) && (item == ids[THERM_CANCEL])) { Quit = TRUE; return FALSE; } } else switch (the_part) { case inSysWindow: SystemClick (&event, window); break; case inDrag: screenRect = (**GetGrayRgn()).rgnBBox; DragWindow( window, event.where, &screenRect ); break; } } else if (event.what == keyDown) { if ((event.modifiers & 0x0100) && ( (event.message) & charCodeMask == 0x02E)) { Quit = TRUE; return FALSE; } } else if (event.what == updateEvt) { window = (WindowPtr)event.message; updateRect = (**(window->visRgn)).rgnBBox; SetPort( window ) ; BeginUpdate( window ); DrawDialog( window ); if (dp == window) box_d_item(dp,ids[THERM_BOX]); EndUpdate( window ); } } if (Quit) return FALSE; return TRUE; }
bool CBOINCGUIApp::SetActiveGUI(int iGUISelection, bool bShowWindow) { CBOINCBaseFrame* pNewFrame = NULL; CBOINCBaseFrame* pOldFrame = m_pFrame; wxInt32 iTop = 0; wxInt32 iLeft = 0; wxInt32 iHeight = 0; wxInt32 iWidth = 0; // Create the new window if ((iGUISelection != m_iGUISelected) || !m_pFrame) { // Reterieve the desired window state before creating the // desired frames if (BOINC_ADVANCEDGUI == iGUISelection) { m_pConfig->SetPath(wxT("/")); m_pConfig->Read(wxT("YPos"), &iTop, 30); m_pConfig->Read(wxT("XPos"), &iLeft, 30); m_pConfig->Read(wxT("Width"), &iWidth, 800); m_pConfig->Read(wxT("Height"), &iHeight, 600); } else { m_pConfig->SetPath(wxT("/Simple")); m_pConfig->Read(wxT("YPos"), &iTop, 30); m_pConfig->Read(wxT("XPos"), &iLeft, 30); #ifdef __WXMAC__ m_pConfig->Read(wxT("Width"), &iWidth, 409); m_pConfig->Read(wxT("Height"), &iHeight, 561); #else m_pConfig->Read(wxT("Width"), &iWidth, 416); m_pConfig->Read(wxT("Height"), &iHeight, 570); #endif } // Make sure that the new window is going to be visible // on a screen #ifdef __WXMAC__ Rect titleRect = {iTop, iLeft, iTop+22, iLeft+iWidth }; InsetRect(&titleRect, 5, 5); // Make sure at least a 5X5 piece visible RgnHandle displayRgn = NewRgn(); CopyRgn(GetGrayRgn(), displayRgn); // Region encompassing all displays Rect menuRect = ((**GetMainDevice())).gdRect; menuRect.bottom = GetMBarHeight() + menuRect.top; RgnHandle menuRgn = NewRgn(); RectRgn(menuRgn, &menuRect); // Region hidden by menu bar DiffRgn(displayRgn, menuRgn, displayRgn); // Subtract menu bar retion if (!RectInRgn(&titleRect, displayRgn)) iTop = iLeft = 30; DisposeRgn(menuRgn); DisposeRgn(displayRgn); #else // If either co-ordinate is less then 0 then set it equal to 0 to ensure // it displays on the screen. if ( iLeft < 0 ) iLeft = 30; if ( iTop < 0 ) iTop = 30; // Read the size of the screen wxInt32 iMaxWidth = wxSystemSettings::GetMetric( wxSYS_SCREEN_X ); wxInt32 iMaxHeight = wxSystemSettings::GetMetric( wxSYS_SCREEN_Y ); // Max sure that it doesn't go off to the right or bottom if ( iLeft + iWidth > iMaxWidth ) iLeft = iMaxWidth - iWidth; if ( iTop + iHeight > iMaxHeight ) iTop = iMaxHeight - iHeight; #endif // Create the main window // if (BOINC_ADVANCEDGUI == iGUISelection) { // Initialize the advanced gui window pNewFrame = new CAdvancedFrame( m_pSkinManager->GetAdvanced()->GetApplicationName(), m_pSkinManager->GetAdvanced()->GetApplicationIcon(), m_pSkinManager->GetAdvanced()->GetApplicationIcon32(), wxPoint(iLeft, iTop), wxSize(iWidth, iHeight) ); } else { // Initialize the simple gui window pNewFrame = new CSimpleFrame( m_pSkinManager->GetAdvanced()->GetApplicationName(), m_pSkinManager->GetAdvanced()->GetApplicationIcon(), m_pSkinManager->GetAdvanced()->GetApplicationIcon32(), wxPoint(iLeft, iTop), wxSize(iWidth, iHeight) ); } wxASSERT(pNewFrame); if (pNewFrame) { SetTopWindow(pNewFrame); // Store the new frame for future use m_pFrame = pNewFrame; // Hide the old one if it exists. We must do this // after updating m_pFrame to prevent Mac OSX from // hiding the application if (pOldFrame) pOldFrame->Hide(); // Delete the old one if it exists // Note: this has the side effect of hiding the Event Log if (pOldFrame) pOldFrame->Destroy(); // Show the new frame if needed (and show the Event Log if open) if (pNewFrame && bShowWindow) pNewFrame->Show(); } } // Show the new frame if needed if (m_pFrame && bShowWindow) { if (m_pEventLog) { m_pEventLog->Show(); m_pEventLog->Raise(); #ifdef __WXMSW__ ::SetForegroundWindow((HWND)m_pEventLog->GetHWND()); #endif } if (!m_pFrame->IsShown()) { m_pFrame->Show(); } m_pFrame->Raise(); #ifdef __WXMSW__ ::SetForegroundWindow((HWND)m_pFrame->GetHWND()); #endif } m_iGUISelected = iGUISelection; m_pConfig->SetPath(wxT("/")); m_pConfig->Write(wxT("GUISelection"), iGUISelection); return true; }
void init() { RgnHandle tempRgn; Rect BaseRect; OSErr err; long QDfeature/*, OSfeature*/; GDHandle SaveGD; CGrafPtr SavePort; /* Initialize Managaer. */ //InitGraf(&qd.thePort); //InitWindows(); //InitDialogs(nil); InitCursor(); FlushEvents(everyEvent, 0); /* Set up menus. */ mymenu0 = GetMenu(appleID); //AppendResMenu(mymenu0, 'DRVR'); InsertMenu(mymenu0,0); mymenu1 = GetMenu(fileID); InsertMenu(mymenu1,0); DrawMenuBar(); DoneFlag = false; ThePict = GetPicture(PictID); if (ThePict == nil) DoneFlag = true; /* Use Gestalt to find is QuickDraw is avaiable. */ /*if ((GetOSTrapAddress(Gestalttest) != GetOSTrapAddress(NoTrap))) { err = Gestalt(gestaltQuickdrawVersion, &QDfeature); if (err) DoneFlag = true; err = Gestalt(gestaltSystemVersion, &OSfeature); if (err) DoneFlag = true; if (!DoneFlag && (QDfeature & 0x0f00) != 0x0200 && OSfeature < 0x0605) DoneFlag = true; } else DoneFlag = true;*/ err = Gestalt(gestaltQuickdrawVersion, &QDfeature); if (err != noErr || QDfeature < gestalt32BitQD) DoneFlag = true; /* Set Rects. */ SetRect(&BaseRect, 40, 60, 472, 282); SetRect(&WinMinusScroll, BaseRect.left-40, BaseRect.top-60, BaseRect.right-60, BaseRect.bottom - 80); SetRect(&InitWindowSize, WinMinusScroll.left, WinMinusScroll.top, WinMinusScroll.right, WinMinusScroll.bottom); tempRgn = GetGrayRgn(); HLock ((Handle) tempRgn); //TotalRect = (**tempRgn).rgnBBox; GetRegionBounds(tempRgn, &TotalRect); /*SetRect(&minRect, 80, 80, (**tempRgn).rgnBBox.right - 40, (**tempRgn).rgnBBox.bottom - 40);*/ SetRect(&minRect, 80, 80, TotalRect.right - 40, TotalRect.bottom - 40); HUnlock ((Handle) tempRgn); /* Open window and set up picture. */ GetGWorld (&SavePort, &SaveGD); mycolors = GetCTable (clutID); (*mycolors)->ctFlags |= 0x4000; myWindow = NewCWindow(nil, &BaseRect, (ConstStr255Param)"", true, zoomDocProc, (WindowPtr) -1, true, 150); SetGWorld(GetWindowPort(myWindow), SaveGD); DrawGrowIcon (myWindow); srcPalette = NewPalette (((**mycolors).ctSize)+1, mycolors, pmTolerant + pmExplicit + pmAnimated, 0); SetPalette ((WindowPtr) myWindow, srcPalette, true); GetGWorld (&SavePort, &SaveGD); err = NewGWorld (&offscreenGWorld, 8, &InitWindowSize, mycolors, nil, 0); if (err) Debugger(); SetGWorld (offscreenGWorld, nil); EraseRect (&InitWindowSize); DrawPicture (ThePict, &InitWindowSize); SetGWorld (SavePort, SaveGD); }
// -------------------------------------------------------------------------------------- static void handleEvents(EventRecord *event) { WindowRef window; Boolean activate; WindowPartCode partCode; OSErr error; Rect tempRect, newSize; long menuChoice; MenuCommand commandID; RgnHandle grayRegion; switch (event->what) // handle events according to the priority { // determined by the system case activateEvt: window = (WindowRef)event->message; activate = (event->modifiers & activeFlag) != 0; HandleActivate(window, activate); break; case mouseDown: partCode = FindWindow(event->where, &window); switch(partCode) { case inMenuBar: menuChoice = MenuSelect(event->where); error = GetMenuItemCommandID(GetMenuRef(HiWord(menuChoice)), LoWord(menuChoice), &commandID); if (error == noErr) { if (commandID == 0) // if the menu item clicked on does not have commandID = (MenuCommand)menuChoice; // a command ID HandleMenuChoice(commandID); } break; case inSysWindow: if (window != NULL) SystemClick(event, window); break; case inContent: // the following window part codes will only be returned if (window != FrontWindow()) // for the preferences window SelectWindow(window); else HandleContentClick(window, event->where, event->modifiers); break; case inDrag: grayRegion = GetGrayRgn(); DragWindow(window, event->where, &((*grayRegion)->rgnBBox)); break; case inGrow: SetRect(&tempRect, kPrefsWindowPlatinumWidth, kPrefsWindowPlatinumHeight, SHRT_MAX, SHRT_MAX); ResizeWindow(window, event->where, &tempRect, &newSize); AdjustControls(window); break; case inGoAway: ClosePrefsWindow(window); break; } break; case keyDown: case autoKey: // a separate auto key handler would go after disk events if ((event->modifiers & cmdKey) != 0) { UInt32 keyMenuChoice; keyMenuChoice = MenuEvent(event); error = GetMenuItemCommandID(GetMenuRef(HiWord(keyMenuChoice)), LoWord(keyMenuChoice), &commandID); if (error == noErr) { if (commandID == 0) // if the menu item chosen does not have a commandID = (MenuCommand)keyMenuChoice; // command ID HandleMenuChoice(commandID); // (but they all should) } } else { window = FrontNonFloatingWindow(); if (window != NULL) { char keyCode = (event->message & keyCodeMask) >> 8; HandleKeyDown(keyCode, window); } } break; case diskEvt: if (HiWord(event->message) != noErr) { Point where; SetPt(&where, 70, 50); ShowCursor(); DIBadMount(where, event->message); } break; case updateEvt: window = (WindowRef)event->message; SetPortWindowPort(window); BeginUpdate(window); HandleDrawContent(window); EndUpdate(window); break; case kHighLevelEvent: // an OS Event handler would go before high level events AEProcessAppleEvent(event); break; }
void DoEvent(EventRecord *event) { short part; Boolean hit; char key; Rect tempRect; WindowRef whichWindow; switch (event->what) { case mouseDown: part = FindWindow(event->where, &whichWindow); switch (part) { case inMenuBar: /* process a moused menu command */ DoMenuCommand(MenuSelect(event->where)); break; case inSysWindow: break; case inContent: if (whichWindow != FrontWindow()) SelectWindow(whichWindow); break; case inDrag: /* pass screenBits.bounds */ GetRegionBounds(GetGrayRgn(), &tempRect); DragWindow(whichWindow, event->where, &tempRect); break; case inGrow: break; case inGoAway: DisposeWindow(whichWindow); ExitToShell(); break; case inZoomIn: case inZoomOut: hit = TrackBox(whichWindow, event->where, part); if (hit) { SetPort(GetWindowPort(whichWindow)); // window must be current port EraseRect(GetWindowPortBounds(whichWindow, &tempRect)); // inval/erase because of ZoomWindow bug ZoomWindow(whichWindow, part, true); InvalWindowRect(whichWindow, GetWindowPortBounds(whichWindow, &tempRect)); } break; } break; case keyDown: case autoKey: key = event->message & charCodeMask; if (event->modifiers & cmdKey) if (event->what == keyDown) DoMenuCommand(MenuKey(key)); case activateEvt: /* if you needed to do something special */ break; case updateEvt: DrawWindow((WindowRef) event->message); break; case kHighLevelEvent: AEProcessAppleEvent( event ); break; case diskEvt: break; } }
static void ROM_HideMenuBar(_THIS) { #if !TARGET_API_MAC_CARBON /* This seems not to be available? -sts Aug 2000 */ RgnHandle drawRgn = nil; RgnHandle tempRgn = nil; RgnHandle grayRgn = nil; WindowPtr window = nil; GDHandle gd = nil; GrafPtr savePort; long response; short height; EventRecord theEvent; height = GetMBarHeight(); if ( height > 0 ) { tempRgn = NewRgn(); drawRgn = NewRgn(); gSaveGrayRgn = NewRgn(); if ( ! tempRgn || ! drawRgn || ! gSaveGrayRgn ) { goto CLEANUP; } grayRgn = GetGrayRgn(); /* No need to check for this */ GetPort(&savePort); /* Hide the control strip if it's present, and record its previous position into the dirty region for redrawing. This isn't necessary, but may help catch stray bits. */ CopyRgn(grayRgn, tempRgn); if (!Gestalt(gestaltControlStripAttr, &response) && (response & (1L << gestaltControlStripExists))) { gSaveCSVis = SBIsControlStripVisible(); if (gSaveCSVis) SBShowHideControlStrip(false); } DiffRgn(grayRgn, tempRgn, drawRgn); /* Save the gray region once the control strip is hidden*/ CopyRgn(grayRgn, gSaveGrayRgn); /* Change the menu height in lowmem */ gSaveMenuBar = height; LMSetMBarHeight(0); /* Walk the monitor rectangles, and combine any pieces that aren't in GrayRgn: menubar, round corners, fake floaters. */ for(gd = GetDeviceList(); gd; gd = GetNextDevice(gd)) { if (!TestDeviceAttribute(gd, screenDevice)) continue; if (!TestDeviceAttribute(gd, screenActive)) continue; RectRgn(tempRgn, &(*gd)->gdRect); /* Get the whole screen */ DiffRgn(tempRgn, grayRgn, tempRgn); /* Subtract out GrayRgn */ UnionRgn(tempRgn, drawRgn, drawRgn);/* Combine all the bits */ } /* Add the bits into the GrayRgn */ UnionRgn(drawRgn, grayRgn, grayRgn); /* Modify the vis regions of exposed windows */ window = (FrontWindow()) ? FrontWindow() : (WindowPtr) -1L; PaintBehind(window, drawRgn); CalcVisBehind(window, drawRgn); SetPort(savePort); /* Yield time so that floaters can catch up */ EventAvail(0, &theEvent); EventAvail(0, &theEvent); EventAvail(0, &theEvent); EventAvail(0, &theEvent); } CLEANUP: if (tempRgn) DisposeRgn(tempRgn); if (drawRgn) DisposeRgn(drawRgn); #endif /* !TARGET_API_MAC_CARBON */ }
void eventLoop() { EventRecord event; WindowPtr window; short clickArea; Rect screenRect; long sleep = 30; Point point; for (;;) { if (WaitNextEvent( everyEvent, &event, sleep, (RgnHandle)nil )) { if (event.what == mouseDown) { clickArea = FindWindow( event.where, &window ); if (clickArea == inDrag) { //screenRect = (**GetGrayRgn()).rgnBBox; GetRegionBounds(GetGrayRgn(), &screenRect); DragWindow(window, event.where, &screenRect ); } else if (clickArea == inGoAway) { if (TrackGoAway( window , event.where )) ExitToShell(); } else if (clickArea == inMenuBar) { adjustMenus(); handleMenu( MenuSelect( event.where ) ); } else if (clickArea == inContent) { if (window != FrontWindow()) SelectWindow( window ); else { point = event.where; GlobalToLocal( &point ); handleMouseDown( point ); } } } else if (event.what == updateEvt) { window = (WindowPtr)event.message; //SetPort( window ); SetPortWindowPort( window ); BeginUpdate( window ); updateWindow(); EndUpdate( window ); } else if (event.what == keyDown || event.what == autoKey) { if ((event.modifiers & cmdKey) != 0) { adjustMenus(); handleMenu( MenuKey( (char)(event.message & charCodeMask) ) ); } } } } }
static void ROM_ShowMenuBar(_THIS) { #if !TARGET_API_MAC_CARBON /* This seems not to be available? -sts Aug 2000 */ RgnHandle drawRgn = nil; RgnHandle menuRgn = nil; RgnHandle tempRgn = nil; RgnHandle grayRgn = nil; WindowPtr window = nil; GrafPtr wMgrPort; GrafPtr savePort; Rect menuRect; long response; short height; EventRecord theEvent; RGBColor saveRGB; RGBColor blackRGB = { 0, 0, 0 }; height = GetMBarHeight(); if ((height <= 0) && (gSaveMenuBar > 0)) { drawRgn = NewRgn(); menuRgn = NewRgn(); tempRgn = NewRgn(); if ( ! tempRgn || ! drawRgn || ! gSaveGrayRgn ) { goto CLEANUP; } grayRgn = GetGrayRgn(); /* No need to check for this */ GetPort(&savePort); GetWMgrPort(&wMgrPort); /* Set the height properly */ LMSetMBarHeight(gSaveMenuBar); /* Restore the old GrayRgn: rounded corners, etc, but not the menubar -- subtract that out first! */ if (gSaveGrayRgn) { menuRect = (*GetMainDevice())->gdRect; menuRect.bottom = menuRect.top + gSaveMenuBar; RectRgn(menuRgn, &menuRect); DiffRgn(grayRgn, gSaveGrayRgn, drawRgn); /* What do we inval? */ DiffRgn(drawRgn, menuRgn, drawRgn); /* Clip out the menu */ /* Now redraw the corners and other bits black */ SetPort(wMgrPort); GetClip(tempRgn); SetClip(drawRgn); GetForeColor(&saveRGB); RGBForeColor(&blackRGB); PaintRgn(drawRgn); RGBForeColor(&saveRGB); SetClip(tempRgn); SetPort(savePort); UnionRgn(drawRgn, menuRgn, drawRgn); /* Put back the menu */ /* Now actually restore the GrayRgn */ CopyRgn(gSaveGrayRgn, grayRgn); DisposeRgn(gSaveGrayRgn); gSaveGrayRgn = nil; } /* Modify the vis regions of exposed windows and draw menubar */ window = (FrontWindow()) ? FrontWindow() : (WindowPtr) -1L; PaintBehind(window, drawRgn); CalcVisBehind(window, drawRgn); DrawMenuBar(); SetPort(savePort); gSaveMenuBar = 0; /* Now show the control strip if it's present */ if (!Gestalt(gestaltControlStripAttr, &response) && (response & (1L << gestaltControlStripExists))) { if (gSaveCSVis && !SBIsControlStripVisible()) SBShowHideControlStrip(true); gSaveCSVis = true; } /* Yield time so that floaters can catch up */ EventAvail(0, &theEvent); EventAvail(0, &theEvent); EventAvail(0, &theEvent); EventAvail(0, &theEvent); } CLEANUP: if (drawRgn) DisposeRgn(drawRgn); if (menuRgn) DisposeRgn(menuRgn); if (tempRgn) DisposeRgn(tempRgn); #endif /* !TARGET_API_MAC_CARBON */ }
static void process_event( EventRecord *event) { WindowPtr window; short part_code; Rect size_rect; long new_size; GrafPtr old_port; switch(event->what) { case kHighLevelEvent: AEProcessAppleEvent(event); break; case mouseDown: /* Did we hit one of the floaters? */ part_code= FindWindow(event->where, &window); switch (part_code) { case inSysWindow: break; case inMenuBar: do_menu_command(MenuSelect(event->where)); break; case inContent: if(window != FrontWindow()) SelectWindow(window); click_in_log_window(window,event->where,(event->modifiers & shiftKey) != 0); break; case inDrag: #ifdef OP_PLATFORM_MAC_CARBON_FLAG { Rect tempRect; GetRegionBounds(GetGrayRgn(), &tempRect); DragWindow(window, event->where, &tempRect); } #else DragWindow(window, event->where, &qd.screenBits.bounds); #endif break; case inGrow: #ifdef OP_PLATFORM_MAC_CARBON_FLAG GetRegionBounds(GetGrayRgn(), &size_rect); #else size_rect = qd.screenBits.bounds; #endif InsetRect(&size_rect, 4, 4); new_size= GrowWindow(window, event->where, &size_rect); if(new_size) { /* Resize the window */ SizeWindow(window, LoWord(new_size), HiWord(new_size), true); } break; case inGoAway: if(TrackGoAway(window, event->where)) { /* Close the window... */ handle_close(window); } break; case inZoomIn: case inZoomOut: if(TrackBox(window, event->where, part_code)) { GetPort(&old_port); SetPortWindowPort(window); #ifdef OP_PLATFORM_MAC_CARBON_FLAG { Rect windowBounds; GetWindowPortBounds(window, &windowBounds); EraseRect(&windowBounds); } #else EraseRect(&window->portRect); #endif ZoomWindow(window, part_code, true); SetPort(old_port); } break; } break; case keyDown: case autoKey: if(!process_key(event, event->message&charCodeMask)) { /* Not handled by anyone.. */ SysBeep(-1); } break; case updateEvt: /* Update the window.. */ update_window((WindowPtr)event->message); break; case activateEvt: /* Activate event->message, event->modifiers&activeFlag.. */ break; case osEvt: switch ((event->message>>24) & 0xff) { case suspendResumeMessage: if (event->message&resumeFlag) { /* resume */ #ifdef OP_PLATFORM_MAC_CARBON_FLAG { Cursor arrowCursor; SetCursor(GetQDGlobalsArrow(&arrowCursor)); } #else SetCursor(&qd.arrow); #endif } else { /* suspend */ } break; case mouseMovedMessage: break; } break; } return; }
OSErr SetupPickMonitorPane(ControlRef inPane, DisplayIDType inDefaultMonitor) { GDHandle dev = GetDeviceList(); OSErr err = noErr; // make the default monitor the selected device if (inDefaultMonitor) DMGetGDeviceByDisplayID(inDefaultMonitor, &sSelectedDevice, true); else sSelectedDevice = GetMainDevice(); // build the list of monitors sNumMonitors = 0; while (dev && sNumMonitors < kMaxMonitors) { if (TestDeviceAttribute(dev, screenDevice) && TestDeviceAttribute(dev, screenActive)) { sMonitors[sNumMonitors].device = dev; sMonitors[sNumMonitors].origRect = (**dev).gdRect; sMonitors[sNumMonitors].isMain = (dev == GetMainDevice()); sNumMonitors++; } dev = GetNextDevice(dev); } // calculate scaled rects if (sNumMonitors) { Rect origPaneRect, paneRect; Rect origGrayRect, grayRect, scaledGrayRect; float srcAspect, dstAspect, scale; int i; GetControlBounds(inPane, &origPaneRect); paneRect = origPaneRect; OffsetRect(&paneRect, -paneRect.left, -paneRect.top); GetRegionBounds(GetGrayRgn(), &origGrayRect); grayRect = origGrayRect; OffsetRect(&grayRect, -grayRect.left, -grayRect.top); srcAspect = (float)grayRect.right / (float)grayRect.bottom; dstAspect = (float)paneRect.right / (float)paneRect.bottom; scaledGrayRect = paneRect; if (srcAspect < dstAspect) { scaledGrayRect.right = (float)paneRect.bottom * srcAspect; scale = (float)scaledGrayRect.right / grayRect.right; } else { scaledGrayRect.bottom = (float)paneRect.right / srcAspect; scale = (float)scaledGrayRect.bottom / grayRect.bottom; } for (i = 0; i < sNumMonitors; i++) { Rect r = sMonitors[i].origRect; Rect r2 = r; // normalize rect and scale OffsetRect(&r, -r.left, -r.top); r.bottom = (float)r.bottom * scale; r.right = (float)r.right * scale; // offset rect wrt gray region OffsetRect(&r, (float)(r2.left - origGrayRect.left) * scale, (float)(r2.top - origGrayRect.top) * scale); sMonitors[i].scaledRect = r; } // center scaledGrayRect in the pane OffsetRect(&scaledGrayRect, (paneRect.right - scaledGrayRect.right) / 2, (paneRect.bottom - scaledGrayRect.bottom) / 2); // offset monitors to match for (i = 0; i < sNumMonitors; i++) OffsetRect(&sMonitors[i].scaledRect, scaledGrayRect.left, scaledGrayRect.top); } else return paramErr; // setup the procs for the pick monitor user pane err = SetupUserPaneProcs(inPane, drawProc, hitTestProc, trackingProc); return err; }
bool CDlgEventLog::Create( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style ) { ////@begin CDlgEventLog member initialisation m_iPreviousRowCount = 0; m_iTotalDocCount = 0; m_iPreviousTotalDocCount = 0; if (!s_bIsFiltered) { s_strFilteredProjectName.clear(); } m_iFilteredIndexes.Clear(); m_bProcessingRefreshEvent = false; m_bEventLogIsOpen = true; ////@end CDlgEventLog member initialisation CSkinAdvanced* pSkinAdvanced = wxGetApp().GetSkinManager()->GetAdvanced(); wxPoint oTempPoint; wxSize oTempSize; wxASSERT(pSkinAdvanced); wxASSERT(wxDynamicCast(pSkinAdvanced, CSkinAdvanced)); if ((pos == wxDefaultPosition) && (size == wxDefaultSize)) { // Get size and position from the previous configuration GetWindowDimensions( oTempPoint, oTempSize ); #ifdef __WXMSW__ // Windows does some crazy things if the initial position is a negative // value. oTempPoint.x = wxDefaultCoord; oTempPoint.y = wxDefaultCoord; #endif #ifdef __WXMAC__ // If the user has changed the arrangement of multiple // displays, make sure the window title bar is still on-screen. Rect titleRect = {oTempPoint.y, oTempPoint.x, oTempPoint.y+22, oTempPoint.x+oTempSize.x }; InsetRect(&titleRect, 5, 5); // Make sure at least a 5X5 piece visible RgnHandle displayRgn = NewRgn(); CopyRgn(GetGrayRgn(), displayRgn); // Region encompassing all displays Rect menuRect = ((**GetMainDevice())).gdRect; menuRect.bottom = GetMBarHeight() + menuRect.top; RgnHandle menuRgn = NewRgn(); RectRgn(menuRgn, &menuRect); // Region hidden by menu bar DiffRgn(displayRgn, menuRgn, displayRgn); // Subtract menu bar retion if (!RectInRgn(&titleRect, displayRgn)) oTempPoint.y = oTempPoint.x = 30; DisposeRgn(menuRgn); DisposeRgn(displayRgn); #endif // ! __WXMAC__ } else { oTempPoint = pos; oTempSize = size; } wxDialog::Create( parent, id, caption, oTempPoint, oTempSize, style ); SetExtraStyle(GetExtraStyle()|wxWS_EX_BLOCK_EVENTS); // Initialize Application Title wxString strCaption = caption; if (strCaption.IsEmpty()) { strCaption.Printf(_("%s - Event Log"), pSkinAdvanced->GetApplicationName().c_str()); } SetTitle(strCaption); // Initialize Application Icon wxIconBundle icons; icons.AddIcon(*pSkinAdvanced->GetApplicationIcon()); icons.AddIcon(*pSkinAdvanced->GetApplicationIcon32()); SetIcons(icons); CreateControls(); // Create List Pane Items m_pList->InsertColumn(COLUMN_PROJECT, _("Project"), wxLIST_FORMAT_LEFT, 109); m_pList->InsertColumn(COLUMN_TIME, _("Time"), wxLIST_FORMAT_LEFT, 130); m_pList->InsertColumn(COLUMN_MESSAGE, _("Message"), wxLIST_FORMAT_LEFT, 378); m_pMessageInfoAttr = new wxListItemAttr( wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT), wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW), wxNullFont ); m_pMessageErrorAttr = new wxListItemAttr( *wxRED, wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW), wxNullFont ); #if EVENT_LOG_STRIPES m_pMessageInfoGrayAttr = new wxListItemAttr( wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT), wxColour(240, 240, 240), wxNullFont ); m_pMessageErrorGrayAttr = new wxListItemAttr(*wxRED, wxColour(240, 240, 240), wxNullFont); #else m_pMessageInfoGrayAttr = new wxListItemAttr(*m_pMessageInfoAttr); m_pMessageErrorGrayAttr = new wxListItemAttr(*m_pMessageErrorAttr); #endif SetTextColor(); RestoreState(); return true; }