Ejemplo n.º 1
0
void
x_full_screen(int do_full)
{
	
#if 0
	WindowRef new_window;
	short	width, height;
	OSErr	ret;
	
	width = 640;
	height = 480;
	if(do_full && (g_mac_fullscreen_state == 0)) {
		g_main_window_saved = g_main_window;
		
		GetWindowBounds(g_main_window, kWindowContentRgn,
						&g_main_window_saved_rect);
		ret = BeginFullScreen(&g_mac_fullscreen_state, 0,
							  &width, &height, &new_window, 0, 0);
		printf("Ret beginfullscreen: %d\n", (int)ret);
		printf("New width: %d, new height: %d\n", width, height);
		if(ret == noErr) {
			g_main_window = new_window;
		} else {
			g_mac_fullscreen_state = 0;
		}
	} else if(!do_full && (g_mac_fullscreen_state != 0)) {
		ret = EndFullScreen(g_mac_fullscreen_state, 0);
		printf("ret endfullscreen: %d\n", (int)ret);
		g_main_window = g_main_window_saved;
		g_mac_fullscreen_state = 0;
		//InitCursor();
		SetWindowBounds(g_main_window, kWindowContentRgn,
						&g_main_window_saved_rect);
	}
	
	update_main_window_size();
	
	ShowWindow(g_main_window);
	BringToFront(g_main_window);
	update_window();
#endif
}
Ejemplo n.º 2
0
int
#ifdef ACTIVEGS
macmain
#else
main
#endif
  (int argc, char* argv[]) {
  ProcessSerialNumber my_psn;

  IBNibRef nibRef;
  EventHandlerUPP handlerUPP;
  EventTypeSpec cmd_event[3];
  GDHandle g_gdhandle;
  Rect win_rect;
  OSStatus err;
  char    *argptr;
  int slash_cnt;
  int i;

#ifndef ACTIVEGS
  /* Prepare argv0 */
  slash_cnt = 0;
  argptr = argv[0];
  for(i = strlen(argptr); i >= 0; i--) {
    if(argptr[i] == '/') {
      slash_cnt++;
      if(slash_cnt == 3) {
        strncpy(&(g_argv0_path[0]), argptr, i);
        g_argv0_path[i] = 0;
      }
    }
  }

  printf("g_argv0_path is %s\n", g_argv0_path);

  g_mac_argv[0] = argv[0];
  g_mac_argc = 1;
  i = 1;
  while((i < argc) && (g_mac_argc < MAX_MAC_ARGS)) {
    if(!strncmp(argv[i], "-psn", 4)) {
      /* skip this argument */
    } else {
      g_mac_argv[g_mac_argc++] = argv[i];
    }
    i++;
  }
#endif

  InitCursor();
  g_event_rgnhandle = NewRgn();
  g_status_font_family = FMGetFontFamilyFromName("\pCourier");

  SetRect(&win_rect, 0, 0, X_A2_WINDOW_WIDTH, X_A2_WINDOW_HEIGHT
          // OG Remove status line from ActiveGS window
#ifndef ACTIVEGS
          + MAX_STATUS_LINES*16 + 8
#endif
          );
  OffsetRect(&win_rect, 64, 50);


  // Create a Nib reference passing the name of the nib file
  // CreateNibReference only searches into the application bundle.
  err = CreateNibReference(CFSTR("main"), &nibRef);
  require_noerr( err, CantGetNibRef );
  // Once the nib reference is created, set the menu bar.
  err = SetMenuBarFromNib(nibRef, CFSTR("MenuBar"));
  require_noerr( err, CantSetMenuBar );


#ifndef ACTIVEGS
  err = CreateNewWindow(kDocumentWindowClass,
                        kWindowStandardDocumentAttributes |
                        kWindowStandardHandlerAttribute,
                        &win_rect, &g_main_window);

  err = SetWindowTitleWithCFString(g_main_window, CFSTR("GSport"));
#else
  err = CreateNewWindow(kDocumentWindowClass,
                        (kWindowCloseBoxAttribute /*| kWindowFullZoomAttribute */| kWindowCollapseBoxAttribute /*| kWindowResizableAttribute*/) /*kWindowStandardDocumentAttributes*/ |
                        kWindowStandardHandlerAttribute,
                        &win_rect, &g_main_window);
  extern CFStringRef activeGSversionSTR;
  err = SetWindowTitleWithCFString(g_main_window, activeGSversionSTR);
#endif

  //printf("CreateNewWindow ret: %d, g_main_window: %p\n", (int)err, g_main_window);


  // We don't need the nib reference anymore.
  DisposeNibReference(nibRef);

  SysBeep(120);

  handlerUPP = NewEventHandlerUPP( my_cmd_handler );

  cmd_event[0].eventClass = kEventClassCommand;
  cmd_event[0].eventKind = kEventProcessCommand;
  InstallWindowEventHandler(g_main_window, handlerUPP, 1, &cmd_event[0],
                            (void *)g_main_window, NULL);

  handlerUPP = NewEventHandlerUPP(my_win_handler);
  cmd_event[0].eventClass = kEventClassWindow;
  cmd_event[0].eventKind = kEventWindowDrawContent;
  cmd_event[1].eventClass = kEventClassWindow;
  cmd_event[1].eventKind = kEventWindowUpdate;
  cmd_event[2].eventClass = kEventClassWindow;
  cmd_event[2].eventKind = kEventWindowClose;
  err = InstallWindowEventHandler(g_main_window, handlerUPP, 3,
                                  &cmd_event[0], (void *)g_main_window, NULL);
  require_noerr(err, CantCreateWindow);

  // Get screen depth
  g_gdhandle = GetGDevice();
  g_screen_mdepth = (**((**g_gdhandle).gdPMap)).pixelSize;

  g_screen_depth = g_screen_mdepth;

  if(g_screen_depth > 16) {
    /* 32-bit display */
    g_red_mask = 0xff;
    g_green_mask = 0xff;
    g_blue_mask = 0xff;

    /*
       if (macUsingCoreGraphics)
       {
            g_red_left_shift = 0;
            g_green_left_shift = 8;
            g_blue_left_shift = 16;
       }
       else
     */
    {
      g_red_left_shift = 16;
      g_green_left_shift = 8;
      g_blue_left_shift = 0;

    }

    g_red_right_shift = 0;
    g_green_right_shift = 0;
    g_blue_right_shift = 0;
  } else if(g_screen_depth > 8) {
    /* 16-bit display */
    g_red_mask = 0x1f;
    g_green_mask = 0x1f;
    g_blue_mask = 0x1f;
    g_red_left_shift = 10;
    g_green_left_shift = 5;
    g_blue_left_shift = 0;
    g_red_right_shift = 3;
    g_green_right_shift = 3;
    g_blue_right_shift = 3;
  }

  // show_alert("About to show window", (int)g_main_window);
  update_main_window_size();

  update_window();


  // The window was created hidden so show it.
  ShowWindow( g_main_window );
  BringToFront( g_main_window );

  update_window();

  // Make us pop to the front a different way
  err = GetCurrentProcess(&my_psn);
  if(err == noErr) {
    (void)SetFrontProcess(&my_psn);
  }

  // Call the event loop
  temp_run_application_event_loop();


CantCreateWindow:
CantSetMenuBar:
CantGetNibRef:
  show_simple_alert("ending", "", "error code", err);
  return err;
}