Beispiel #1
0
Datei: ugView.c Projekt: rolk/ug
int main (void)
{
  /* init the Macintosh toolbox */
  InitGraf(&qd.thePort);
  InitFonts();
  FlushEvents(everyEvent,0);
  InitWindows();
  InitMenus();
  TEInit();
  InitDialogs(nil);
  InitCursor();

  /* read the screen's size */
  screenx = ((qd.screenBits).bounds).right;
  screeny = ((qd.screenBits).bounds).bottom;
  SetRect(&dragRect,4,24,((qd.screenBits).bounds).right-4,((qd.screenBits).bounds).bottom-4);


  SetUpMenus ();
  SetState(CLOSED);
  OpenCommand();

  /* handle events till the end */
  while (!quitFlag)
  {
    ProcessEvent();
  }

  return(0);
}
Beispiel #2
0
void Initialize(void)
{
	InitGraf((Ptr) &qd.thePort);
	InitFonts();
	FlushEvents(everyEvent, 0);

	InitWindows();
	InitMenus();
	TEInit();
	InitDialogs(nil);
	InitCursor();
	
	SetUpMenus();

}
Beispiel #3
0
InitMacInterface() 
  {
   int myRsrc, i;
   int MainEvent();
    
   /*=====================================================*/
   /* Macintosh Incantation for initializing application. */
   /*=====================================================*/
	
   InitGraf(&thePort);
   InitFonts();
   InitWindows();
   InitMenus();
   TEInit();
   InitDialogs(0L);
	
   MaxApplZone();
   FlushEvents(everyEvent,0);
	  
   /*==================================*/
   /* Get the screen width and height. */
   /*==================================*/
   
   ScreenHeight = screenBits.bounds.bottom - screenBits.bounds.top;
   ScreenWidth = screenBits.bounds.right - screenBits.bounds.left;
   
   /*===============================*/
   /* Set up the menus and cursors. */
   /*===============================*/
   
   SetUpMenus();
   SetUpCursors();
   
   /*=====================================*/
   /* Initialize global window variables. */
   /*=====================================*/
   
   TheWindow = NULL;
   
   /*=========================*/
   /* Initialize the windows. */
   /*=========================*/
      
   InitDisplayWindow();
   InitFileListWindow();
  }
Beispiel #4
0
void C_API Program::LoadObject(const std::string & filename)
{
	clock_t end_time, start_time;

	if (m_LoadedObj.pMesh != NULL)
	{
		delete m_LoadedObj.pMesh;
		m_LoadedObj.pMesh = NULL;
	}

	try {

		start_time = clock();

		m_LoadedObj.pMesh = new WavefrontObject(filename);

		end_time = clock();

		m_LoadedObj.fLoadTimeInSecs = (float)(end_time - start_time)/CLOCKS_PER_SEC;

		m_LoadedObj.nNormalCount = m_LoadedObj.pMesh->NormalCount();
		m_LoadedObj.nVertexCount = m_LoadedObj.pMesh->VertexCount();
		m_LoadedObj.nUVCount = m_LoadedObj.pMesh->TexCoordCount();

		m_LoadedObj.nDrawByGroupID = -1; // -1 Render The Entire Mesh.
		m_LoadedObj.nSelectedGroup = -1; // -1 No Groups Selected.
		m_vMeshGroups.clear();

		SetUpMenus(m_LoadedObj.pMesh);
	}
	catch (std::runtime_error & except) {

		MessageBox(0, except.what(), "Error!", (MB_OK | MB_ICONERROR));
		delete m_LoadedObj.pMesh;
		m_LoadedObj.pMesh = NULL;
	}
}
Beispiel #5
0
void C_API Program::Initialize(int window_width, int window_height, int argc, char * argv[])
{
	// Init Glut:
	glutInit(&argc, argv);
	glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH);
	glutInitWindowSize(window_width, window_height);
	glutInitWindowPosition(0,0);
	m_WinId = glutCreateWindow("Wavefront Object Viewer");

	// Set Glut Function Pointers:
	glutReshapeFunc(Program::ResizeWindow);
	glutDisplayFunc(Program::Render);
	glutIdleFunc(Program::Render);
	glutKeyboardFunc(Program::KeyboardCallback);
	glutMouseFunc(Program::MouseCallback);
	glutMotionFunc(Program::MouseMotionCallback);
	atexit(Program::Shutdown);

	ResizeWindow(window_width, window_height);

	glCullFace(GL_NONE);
	glShadeModel(GL_SMOOTH);
	glEnable(GL_DEPTH_TEST);

	memset(&m_LoadedObj, 0, sizeof(Program::UserObjectInfo));

	m_MenuIds[0] = -1; // Set To An Invalid Menu Id.
	m_MenuIds[1] = -1;

	SetUpMenus(NULL);

	if (InitOpenGLExtensions() == 0)
		MessageBox(0, "Warning! Some OpenGL Extensions Are Not Available! The Program May Not Work Properly.", "Warning!", (MB_OK | MB_ICONWARNING));

	glClearColor(0.3f, 0.3f, 0.3f, 1.0f);
}
Beispiel #6
0
init_mac_interface() 
  {
   int myRsrc, i;
   int MainEvent();
    
   /*=====================================================*/
   /* Macintosh Incantation for initializing application. */
   /*=====================================================*/
	
   InitGraf(&thePort);
   InitFonts();
   InitWindows();
   InitMenus();
   TEInit();
   InitDialogs(0L);
	
   MaxApplZone();
   FlushEvents(everyEvent,0);
	  
   /*==================================*/
   /* Get the screen width and height. */
   /*==================================*/
   
   ScreenHeight = screenBits.bounds.bottom - screenBits.bounds.top;
   ScreenWidth = screenBits.bounds.right - screenBits.bounds.left;
   
   /*===============================*/
   /* Set up the menus and cursors. */
   /*===============================*/
   
   SetUpMenus();
   SetUpCursors();
   
   /*=====================================*/
   /* Initialize global window variables. */
   /*=====================================*/
   
   TheText = NULL;
   TheWindow = NULL;
   TheVScrollBar = NULL;
   TheHScrollBar = NULL;
   
   /*======================================*/
   /* Place any selected files in buffers. */
   /*======================================*/
   
   DoStartup();
   
   /*=======================*/
   /* Initialize the Scrap. */
   /*=======================*/
   
   InitializeScrap();
   
   /*=========================*/
   /* Set up for MultiFinder. */
   /*=========================*/
   
   MultiFinderSetup();
   
   /*===================================*/
   /* Set up routers for the interface. */
   /*===================================*/
   
   SetUpRouters();
   
   /*==================================================================*/
   /* Set up hook between CLIPS command loop and interface event loop. */
   /*==================================================================*/
   
   set_event_function(MainEvent);
   
   /*==================================================================*/
   /* Add execution function to update interface between rule firings. */
   /*==================================================================*/
   
   add_exec_function("macint",mac_exec_function);
  }
Beispiel #7
0
static int ioSetFullScreenActual(int fullScreen) {
    Rect                screen;
    int                 width, height, maxWidth, maxHeight;
    int                 oldWidth, oldHeight;
    static Rect			rememberOldLocation = {0,0,0,0};		
    GDHandle            dominantGDevice;
	windowDescriptorBlock *	targetWindowBlock  = windowBlockFromIndex(1);
	extern Boolean gSqueakBrowserWasHeadlessButMadeFullScreen;
	extern Boolean gSqueakBrowserSubProcess;

	
	if (browserActiveAndDrawingContextOk()) {
		if (!gSqueakBrowserWasHeadlessButMadeFullScreen) {
			gSqueakBrowserWasHeadlessButMadeFullScreen = true;
			SetUpMenus();
			AdjustMenus();
		}
		sqShowWindowActual(1);
		if (targetWindowBlock->context)  //Set context to NULL, if screen is same size as fullscreen we wouldn't get new context
				QDEndCGContext(GetWindowPort(targetWindowBlock->handle),&targetWindowBlock->context);
		targetWindowBlock->context = NULL;
	}

	if ((targetWindowBlock == NULL) || (fullScreen && getFullScreenFlag() && !targetWindowBlock->isInvisible))
		return 0;

	dominantGDevice = getThatDominateGDevice(targetWindowBlock->handle);
    if (dominantGDevice == null) {
        success(false);
        return 0;
    }
    screen = (**dominantGDevice).gdRect;
	        
    if (fullScreen) {
		GetPortBounds(GetWindowPort(targetWindowBlock->handle),&rememberOldLocation);
		oldWidth =  rememberOldLocation.right -  rememberOldLocation.left;
		oldHeight =  rememberOldLocation.bottom -  rememberOldLocation.top;

		if (targetWindowBlock->isInvisible) {
			rememberOldLocation.top = 44;
			rememberOldLocation.left = 8;
		}
		QDLocalToGlobalRect(GetWindowPort(targetWindowBlock->handle),&rememberOldLocation);
		if (gSqueakBrowserSubProcess) {
			ProcessSerialNumber psn = { 0, kCurrentProcess };
			ProcessInfoRec info;
			info.processName = NULL;
			info.processAppSpec = NULL;
			info.processInfoLength = sizeof(ProcessInfoRec);
			GetProcessInformation(&psn,&info);
			SetFrontProcess(&psn);
		}
		MenuBarHide();
		width  = screen.right - screen.left; 
		height = (screen.bottom - screen.top);
		MoveWindow(targetWindowBlock->handle, screen.left, screen.top, true);
		SizeWindow(targetWindowBlock->handle, width, height, true);
		setFullScreenFlag(true);
	} else {
		MenuBarRestore();
	
		if (gSqueakBrowserWasHeadlessButMadeFullScreen) {
			HideWindow(targetWindowBlock->handle);
			{
				ProcessSerialNumber psn;
				pid_t parent;
				OSStatus err;
				parent = getppid();
				if (parent != 1) {
					err = GetProcessForPID(parent,&psn); 
					if(err == 0) 
						SetFrontProcess(&psn);
				}
			}
		}

		if (EmptyRect(&rememberOldLocation)) {
			/* get old window size */
			width  = (unsigned) getSavedWindowSize() >> 16;
			height = getSavedWindowSize() & 0xFFFF;

			/* minimum size is 1 x 1 */
			width  = (width  > 0) ?  width : 64;
			height = (height > 0) ? height : 64;

			/* maximum size is screen size inset slightly */
			maxWidth  = (screen.right  - screen.left) - 16;
			maxHeight = (screen.bottom - screen.top)  - 52;
			width  = (width  <= maxWidth)  ?  width : maxWidth;
			height = (height <= maxHeight) ? height : maxHeight;
			MoveWindow(targetWindowBlock->handle, 8, 44, true);
			SizeWindow(targetWindowBlock->handle, width, height, true);
		} else {