static void mac_config(int midsession) { Session *s; WinInfo *wi; Str255 mactitle; char *str; if (midsession) { s = mac_windowsession(FrontWindow()); } else { s = snew(Session); memset(s, 0, sizeof(*s)); do_defaults(NULL, &s->cfg); s->hasfile = FALSE; s->session_closed = FALSE; } /* Copy the configuration somewhere else in case this is a * * reconfiguration and the user cancels the operation */ s->temp_cfg = s->cfg; if (HAVE_COLOR_QD()) s->settings_window = GetNewCWindow(wSettings, NULL, (WindowPtr)-1); else s->settings_window = GetNewWindow(wSettings, NULL, (WindowPtr)-1); s->ctrlbox = ctrl_new_box(); setup_config_box(s->ctrlbox, midsession, 0, 0); s->settings_ctrls.data = &s->temp_cfg; if (midsession) s->settings_ctrls.end = &mac_enddlg_reconfig; else s->settings_ctrls.end = &mac_enddlg_config; macctrl_layoutbox(s->ctrlbox, s->settings_window, &s->settings_ctrls); wi = snew(WinInfo); memset(wi, 0, sizeof(*wi)); wi->s = s; wi->mcs = &s->settings_ctrls; wi->wtype = wSettings; wi->update = &macctrl_update; wi->click = &macctrl_click; wi->key = &macctrl_key; wi->activate = &macctrl_activate; wi->adjustmenus = &macctrl_adjustmenus; wi->close = &mac_closedlg; SetWRefCon(s->settings_window, (long)wi); if (midsession) str = dupprintf("%s Reconfiguration", appname); else str = dupprintf("%s Configuration", appname); c2pstrcpy(mactitle, str); sfree(str); SetWTitle(s->settings_window, mactitle); ShowWindow(s->settings_window); }
void screenOpen(char *Title) { FontInfo fontInfo; int n; theWindow = GetNewWindow(screenWindow, nil, (WindowPtr)(-1)); if ((Title != NULL) && (*Title != '\0')) { c2pstr(Title); SetWTitle(theWindow, Title); p2cstr(Title); } ShowWindow(theWindow); SetPort(theWindow); TextFont(monaco); TextSize(9); GetFontInfo(&fontInfo); fontHeight = fontInfo.ascent + fontInfo.descent + fontInfo.leading; fontWidth = fontInfo.widMax; scrollRgn = NewRgn(); screenWidth = (theWindow->portRect.right - theWindow->portRect.left - 10) / fontWidth; screenHeight = (theWindow->portRect.bottom - theWindow->portRect.top) / fontHeight; maxPosition = screenHeight * fontHeight; pausePosition = maxPosition - (currentPosition = fontHeight); SetRect(&scrollRect, theWindow->portRect.left, theWindow->portRect.top + fontInfo.descent, theWindow->portRect.right, theWindow->portRect.bottom); SetRect(&pauseRect, theWindow->portRect.left, pausePosition + fontInfo.descent, theWindow->portRect.right, theWindow->portRect.bottom); MoveTo(5, currentPosition); n = (sizeof(char *) + sizeof(short) + screenWidth) * screenHeight; screenLine = (char **)NewPtr(n); screenLength = (short *)&screenLine[screenHeight]; screenImage = (char *)&screenLength[screenHeight]; for (n = 0; n < screenHeight; n++) { screenLine[n] = &screenImage[n * screenWidth]; screenLength[n] = 0; } startLine = endLine = 0; screenOptions = 0; return; }
static Boolean initmainwindow (void) { mainwindow = GetNewWindow (128, nil, (WindowPtr) -1); if (mainwindow == nil) return (false); ShowWindow (mainwindow); return (true); } /*initmainwindow*/
static void mac_openlicence(void) { WinInfo *wi; if (windows.licence) SelectWindow(windows.licence); else { windows.licence = GetNewWindow(wLicence, NULL, (WindowPtr)-1); wi = snew(WinInfo); memset(wi, 0, sizeof(*wi)); wi->wtype = wLicence; wi->update = &mac_updatelicence; wi->close = &mac_closelicence; SetWRefCon(windows.licence, (long)wi); ShowWindow(windows.licence); } }
static void mac_createeventlog(Session *s) { Rect view; ListBounds bounds = { 0, 0, 0, 1 }; /* 1 column, 0 rows */ Point csize = { 0, 0 }; GrafPtr saveport; long fondsize; WinInfo *wi; s->eventlog_window = GetNewWindow(wEventLog, NULL, (WindowPtr)-1); wi = snew(WinInfo); memset(wi, 0, sizeof(*wi)); wi->s = s; wi->wtype = wEventLog; wi->click = &mac_clickeventlog; wi->activate = &mac_activateeventlog; wi->grow = &mac_groweventlog; wi->update = &mac_updateeventlog; wi->close = &mac_closeeventlog; SetWRefCon(s->eventlog_window, (long)wi); GetPort(&saveport); SetPort((GrafPtr)GetWindowPort(s->eventlog_window)); fondsize = GetScriptVariable(smRoman, smScriptSmallFondSize); TextFont(HiWord(fondsize)); TextSize(LoWord(fondsize)); SetPort(saveport); #if TARGET_API_MAC_CARBON GetPortBounds(GetWindowPort(s->eventlog_window), &view); #else view = s->eventlog_window->portRect; #endif view.right -= 15; /* Scrollbar */ s->eventlog = LNew(&view, &bounds, csize, 0, s->eventlog_window, TRUE, TRUE, FALSE, TRUE); mac_adjusteventlogscrollbar(s); #if TARGET_API_MAC_CARBON SetListSelectionFlags(s->eventlog, lExtendDrag | lNoDisjoint | lNoExtend); #else (*s->eventlog)->selFlags = lExtendDrag | lNoDisjoint | lNoExtend; #endif }
static LRESULT CALLBACK GraphicsWindow_WndProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam ) { CHECKPOINT_M( ssprintf("%p, %u, %08x, %08x", hWnd, msg, wParam, lParam) ); // Suppress autorun. if( msg == g_iQueryCancelAutoPlayMessage ) return true; switch( msg ) { case WM_ACTIVATE: { const bool bInactive = (LOWORD(wParam) == WA_INACTIVE); const bool bMinimized = (HIWORD(wParam) != 0); const bool bHadFocus = g_bHasFocus; g_bHasFocus = !bInactive && !bMinimized; LOG->Trace( "WM_ACTIVATE (%i, %i): %s", bInactive, bMinimized, g_bHasFocus? "has focus":"doesn't have focus" ); if( !g_bHasFocus ) { RString sName = GetNewWindow(); static set<RString> sLostFocusTo; sLostFocusTo.insert( sName ); RString sStr; for( set<RString>::const_iterator it = sLostFocusTo.begin(); it != sLostFocusTo.end(); ++it ) sStr += (sStr.size()?", ":"") + *it; LOG->MapLog( "LOST_FOCUS", "Lost focus to: %s", sStr.c_str() ); } if( !g_bD3D && !g_CurrentParams.windowed && !g_bRecreatingVideoMode ) { /* In OpenGL (not D3D), it's our job to unset and reset the * full-screen video mode when we focus changes, and to hide * and show the window. Hiding is done in WM_KILLFOCUS, * because that's where most other apps seem to do it. */ if( g_bHasFocus && !bHadFocus ) { ChangeDisplaySettings( &g_FullScreenDevMode, CDS_FULLSCREEN ); ShowWindow( g_hWndMain, SW_SHOWNORMAL ); } else if( !g_bHasFocus && bHadFocus ) { ChangeDisplaySettings( NULL, 0 ); } } return 0; } case WM_KILLFOCUS: if( !g_bD3D && !g_CurrentParams.windowed && !g_bRecreatingVideoMode ) ShowWindow( g_hWndMain, SW_SHOWMINNOACTIVE ); break; /* Is there any reason we should care what size the user resizes * the window to? (who? -aj) * Short answer: yes. -aj */ // case WM_GETMINMAXINFO: case WM_SETCURSOR: if( !g_CurrentParams.windowed ) { SetCursor( NULL ); return 1; } break; case WM_SYSCOMMAND: switch( wParam&0xFFF0 ) { case SC_MONITORPOWER: case SC_SCREENSAVE: return 0; } break; case WM_PAINT: { PAINTSTRUCT ps; BeginPaint( hWnd, &ps ); EndPaint( hWnd, &ps ); break; } case WM_KEYDOWN: case WM_KEYUP: case WM_SYSKEYDOWN: case WM_SYSKEYUP: case WM_MOUSEWHEEL: // might want to use this for GET_WHEEL_DELTA_WPARAM(wParam) -aj // We handle all input ourself, via DirectInput. return 0; case WM_CLOSE: LOG->Trace("WM_CLOSE: shutting down"); ArchHooks::SetUserQuit(); return 0; case WM_WINDOWPOSCHANGED: { /* If we're fullscreen and don't have focus, our window is hidden, * so GetClientRect isn't meaningful. */ if( !g_CurrentParams.windowed && !g_bHasFocus ) break; RECT rect; GetClientRect( hWnd, &rect ); int iWidth = rect.right - rect.left; int iHeight = rect.bottom - rect.top; if( g_CurrentParams.width != iWidth || g_CurrentParams.height != iHeight ) { g_CurrentParams.width = iWidth; g_CurrentParams.height = iHeight; g_bResolutionChanged = true; } break; } case WM_COPYDATA: { PCOPYDATASTRUCT pMyCDS = (PCOPYDATASTRUCT) lParam; RString sCommandLine( (char*)pMyCDS->lpData, pMyCDS->cbData ); CommandLineActions::CommandLineArgs args; split( sCommandLine, "|", args.argv, false ); CommandLineActions::ToProcess.push_back( args ); break; } } CHECKPOINT_M( ssprintf("%p, %u, %08x, %08x", hWnd, msg, wParam, lParam) ); if( m_bWideWindowClass ) return DefWindowProcW( hWnd, msg, wParam, lParam ); else return DefWindowProcA( hWnd, msg, wParam, lParam ); }
pascal WindowRef SafeGetNewWindow(short windowID, void *wStorage, WindowRef behind) { StAcroResourceContext resContext; return GetNewWindow(windowID, wStorage, behind); }
void ProcessMenu(long menuCode) { short theMenu, theItem, daNum, err; Str255 daName; if(menuCode==0) return; theMenu = menuCode>>16; theItem = menuCode&0xffff; switch(theMenu) { case kAppleMenuID: { if(theItem==1) DoAbout(); else { GetMenuItemText(GetMenuHandle(kAppleMenuID), theItem, daName); daNum = OpenDeskAcc(daName); } break; } case kFileMenuID: switch(theItem) { case 1: err = OpenCart(); break; case 2: DoCloseWindow(FrontWindow()); break; case 4: gDone = true; } break; case kEditMenuID: switch(theItem) { case 8: // ROM Header if(ROM_HeaderEdit()) { NES_StoreHeader(); NES_Reset(); FullUpdate(); } break; case 10: // CONTROLS Keys_Edit(); break; case 11: // PREFERENCES Prefs_Edit(); break; } break; case kNESMenuID: switch(theItem) { case 1: // RUN if(!gRunning) { NES_Run(); } break; case 2: // STOP if(gRunning) { Stat_ForceUpdate(); FullUpdate(); NES_Stop(); } break; case 4: // RESET #ifdef GB_DEBUG TF_AddLine("== NES is reset."); #endif NES_Reset(); FullUpdate(); break; } break; #ifdef GB_DEBUG case kExtraMenuID: switch(theItem) { case 1: // PATTERN TABLES if(patWind) { DisposeWindow(patWind); patWind = 0L; } else { patWind = GetNewWindow(kPatWindID,0L,(WindowPtr)-1); NES_PatUpdate(); } break; case 2: // NAME TABLES if(namWind) { DisposeWindow(namWind); namWind = 0L; } else { namWind = GetNewWindow(kNamWindID,0L,(WindowPtr)-1); NES_NamUpdate(); } break; case 3: // PALETTES if(palWind) { DisposeWindow(palWind); palWind = 0L; } else { palWind = GetNewWindow(kPalWindID,0L,(WindowPtr)-1); NES_PalUpdate(); } break; case 5: // FRAME pnes->refreshFlag = 1; NES_Frame((long)pcpu); FullUpdate(); break; case 6: // STEP DisAsmLine(); NES_Step((long)pcpu); FullUpdate(); break; case 7: // EDIT MEM DoEditMem(0); FullUpdate(); break; case 9: // NMI P6502_NMI((long)pcpu); Stat_ForceUpdate(); break; case 10: // IRQ P6502_IRQ((long)pcpu); Stat_ForceUpdate(); break; case 12: // Blub Blub(); break; } break; #endif case kSearchMenuID: switch(theItem) { case 1: // SEARCH MEMORY Srch_Search(); break; case 3: // SAVE WP's WP_SaveWatchPoints(); break; case 5: // SEARCH RESULTS Srch_ShowResultsWindow(); break; case 6: // WATCH POINTS if(wpWind) { DisposeWindow(wpWind); wpWind = 0L; } else { WP_OpenWindow(); WP_Update(); } break; } break; case kLdsMenuID: // Load State SubMenu if((theItem>0) && (theItem<9)) NES_LoadState(theItem-1); // --> UPDATE FRAME case kStsMenuID: // Save State SubMenu if((theItem>0) && (theItem<9)) NES_SaveState(theItem-1); default: break; } if(!gRunning || !Prefs.doubleSize) HiliteMenu(0); }
static LRESULT CALLBACK GraphicsWindow_WndProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam ) { CHECKPOINT_M( ssprintf("%p, %u, %08x, %08x", hWnd, msg, wParam, lParam) ); /* Suppress autorun. */ if( msg == g_iQueryCancelAutoPlayMessage ) return true; switch( msg ) { case WM_ACTIVATE: { const bool bInactive = (LOWORD(wParam) == WA_INACTIVE); const bool bMinimized = (HIWORD(wParam) != 0); const bool bHadFocus = g_bHasFocus; g_bHasFocus = !bInactive && !bMinimized; LOG->Trace( "WM_ACTIVATE (%i, %i): %s", bInactive, bMinimized, g_bHasFocus? "has focus":"doesn't have focus" ); if( !g_bHasFocus ) { RString sName = GetNewWindow(); static set<RString> sLostFocusTo; sLostFocusTo.insert( sName ); RString sStr; for( set<RString>::const_iterator it = sLostFocusTo.begin(); it != sLostFocusTo.end(); ++it ) sStr += (sStr.size()?", ":"") + *it; LOG->MapLog( "LOST_FOCUS", "Lost focus to: %s", sStr.c_str() ); } if( !g_bD3D && !g_CurrentParams.windowed && !g_bRecreatingVideoMode ) { /* In OpenGL (not D3D), it's our job to unset and reset the full-screen video mode * when we focus changes, and to hide and show the window. Hiding is done in WM_KILLFOCUS, * because that's where most other apps seem to do it. */ if( g_bHasFocus && !bHadFocus ) { ChangeDisplaySettings( &g_FullScreenDevMode, CDS_FULLSCREEN ); ShowWindow( g_hWndMain, SW_SHOWNORMAL ); } else if( !g_bHasFocus && bHadFocus ) { ChangeDisplaySettings( NULL, 0 ); } } return 0; } case WM_KILLFOCUS: if( !g_bD3D && !g_CurrentParams.windowed && !g_bRecreatingVideoMode ) ShowWindow( g_hWndMain, SW_SHOWMINNOACTIVE ); break; /* Is there any reason we should care what size the user resizes the window to? */ // case WM_GETMINMAXINFO: case WM_SETCURSOR: if( !g_CurrentParams.windowed ) { SetCursor( NULL ); return 1; } break; case WM_SYSCOMMAND: switch( wParam&0xFFF0 ) { case SC_MONITORPOWER: case SC_SCREENSAVE: return 0; } break; case WM_POWERBROADCAST: if(wParam==PBT_APMPOWERSTATUSCHANGE) { SYSTEM_POWER_STATUS powerstatus; GetSystemPowerStatus(&powerstatus); Message msg("PowerSupplyChange"); switch(powerstatus.ACLineStatus) { case 0: msg.SetParam( "Online",false); break; case 1: msg.SetParam( "Online",true); break; default: case 255: msg.SetParam( "Online",false); break; } if(powerstatus.BatteryFlag & 8) { msg.SetParam( "Charging", true); } else { msg.SetParam( "Charging", false); } msg.SetParam( "BatteryExists", (powerstatus.BatteryFlag & 128) != 128); msg.SetParam( "BatteryCharge", (int)powerstatus.BatteryLifePercent); msg.SetParam( "BatteryLifetime", (int)powerstatus.BatteryLifeTime); msg.SetParam( "BatteryFullLifetime", (int)powerstatus.BatteryFullLifeTime); MESSAGEMAN->Broadcast( msg ); } break; case WM_PAINT: { PAINTSTRUCT ps; BeginPaint( hWnd, &ps ); EndPaint( hWnd, &ps ); break; } case WM_KEYDOWN: case WM_KEYUP: case WM_SYSKEYDOWN: case WM_SYSKEYUP: /* We handle all input ourself, via DirectInput. */ return 0; case WM_CLOSE: LOG->Trace("WM_CLOSE: shutting down"); ArchHooks::SetUserQuit(); return 0; case WM_WINDOWPOSCHANGED: { /* If we're fullscreen and don't have focus, our window is hidden, so GetClientRect * isn't meaningful. */ if( !g_CurrentParams.windowed && !g_bHasFocus ) break; RECT rect; GetClientRect( hWnd, &rect ); int iWidth = rect.right - rect.left; int iHeight = rect.bottom - rect.top; if( g_CurrentParams.width != iWidth || g_CurrentParams.height != iHeight ) { g_CurrentParams.width = iWidth; g_CurrentParams.height = iHeight; g_bResolutionChanged = true; } break; } } CHECKPOINT_M( ssprintf("%p, %u, %08x, %08x", hWnd, msg, wParam, lParam) ); if( m_bWideWindowClass ) return DefWindowProcW( hWnd, msg, wParam, lParam ); else return DefWindowProcA( hWnd, msg, wParam, lParam ); }