コード例 #1
0
ファイル: CROSS.CPP プロジェクト: NOAA-ORR-ERD/PyGnome
void BasicInit()
#ifdef MAC
{
	void InitColors();
#if MACB4CARBON  
	short i;
	Ptr stackTop;
	// JLMextern _DataInit();
	
	stackTop = GetApplLimit();
	
	
	SetApplLimit((void *)(stackTop - (Ptr)30000));
	// SetApplLimit((void *)(*(long *)csb - 30000));
	MaxApplZone();
	for (i = 1 ; i <= 16 ; i++) MoreMasters();
	
	InitGraf(&qd.thePort);
	InitFonts();
	InitWindows();
	InitMenus();
	TEInit();
	InitDialogs(nil);
	FlushEvents(everyEvent, 0);
#endif
	InitCursor();
	
	InitColors();
}
コード例 #2
0
int main ()
{
	int ret;
	Rect windRect;
	long start,end,amount;
	
	/* Initialize all the needed managers. */
	InitGraf(&qd.thePort);
	InitFonts();
	InitWindows();
	InitMenus();
	TEInit();
	InitDialogs(nil);
	InitCursor();

	//ProfilerInit(collectDetailed, bestTimeBase, 1000, 50);
	//ProfilerSetStatus(true);

	windRect = qd.screenBits.bounds;
	InsetRect(&windRect, 50, 50);
	pWindow = NewCWindow(nil, &windRect, "\pMpeg", true, documentProc, (WindowPtr) -1, false, 0);
    
    start = TickCount();
    main2();
    end = TickCount();
    amount = end - start;
    fprintf(stderr, "Time taken %d memoryAllocator %d \n", amount,counter);

   //	ProfilerDump("\pProfile.out");
     
    do {
	} while (!Button());


}
コード例 #3
0
ファイル: iappmac.c プロジェクト: Feneric/xconq
static int
MacintoshInit()
{
    MaxApplZone();
    MoreMasters();
    MoreMasters();
    MoreMasters();
    MoreMasters();

    tcl_macQdPtr = &qd;

     if (TkMacHaveAppearance()) {
         RegisterAppearanceClient();
     }

    InitGraf(&tcl_macQdPtr->thePort);
    InitFonts();

    if (TkMacHaveAppearance() >= 0x110) {
	InitFloatingWindows();
    } else {
	InitWindows();
    }

    InitMenus();
    InitDialogs((long) NULL);		
    InitCursor();

    FlushEvents(everyEvent, 0);
    SetEventMask(everyEvent);
    Tcl_MacSetEventProc(TkMacConvertEvent);

    return TCL_OK;
}
コード例 #4
0
/*
=============
InitMacStuff
=============
*/
void InitMacStuff( void ) {
	Handle 		menuBar;
	char		dir[MAX_OSPATH];
	
	// init toolbox
	MaxApplZone();
	MoreMasters();
	
	InitGraf(&qd.thePort);
	InitFonts();
	FlushEvents(everyEvent, 0);
	SetEventMask( -1 );
	InitWindows();
	InitMenus();
	TEInit();
	InitDialogs(nil);
	InitCursor();

	// init menu
	menuBar = GetNewMBar(rMenuBar);
	if(!menuBar) {
		Com_Error( ERR_FATAL, "MenuBar not found.");
	}
	
	SetMenuBar(menuBar);
	DisposeHandle(menuBar);
	AppendResMenu(GetMenuHandle(mApple),'DRVR');
	DrawMenuBar();

	Sys_InitConsole();

	SetEventMask( -1 );
}
コード例 #5
0
ファイル: ugView.c プロジェクト: 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);
}
コード例 #6
0
// --------------------------------------------------------------------------------------
static void initialize(void)
{
	MenuBarHandle menuBar;
	OSErr error;
	
	MoreMasters();				// I doubt we actually need any extra master pointers 
	InitGraf(&qd.thePort);		// but I left the calls here as a reminder for where they 
	InitFonts();				// belong if they are needed
	InitWindows();
	InitMenus();
	TEInit();
	InitDialogs(NULL);
	
	InitCursor();
	RegisterAppearanceClient();
	
	menuBar = GetNewMBar(rMenuBar);		// draw the menu bar as soon as possible
	if (menuBar == NULL)
		ExitToShell();
	SetMenuBar(menuBar);
	DrawMenuBar();
	
		// do non time sensitive initialization after we get the application event loop going
	gOpenAppAEHandler = NewAEEventHandlerUPP(openApplicationAEHandler);
	error = AEInstallEventHandler(kCoreEventClass, kAEOpenApplication, gOpenAppAEHandler, 0, 
									false);
	if (error != noErr)
		ExitToShell();
	
		/* If we supported them, we would install open documents and print documents 
		   handlers here and we would do most of the same initialization stuff that we 
		   do in the open application handler. */
	
	FlushEvents(everyEvent, 0);
}
コード例 #7
0
ファイル: main.cpp プロジェクト: lbhoward/Feather-Engine
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR pScmdline, int iCmdshow)
{
	InitWindows(800, 600, false);

	GFX m_GFX = GFX(m_hwnd);

	// Main Loop
	MSG msg_Message;
	while (Running)
	{
		m_GFX.ClearScene(FColour(1.0f, 0.0f, 0.0f, 1.0f));
		m_GFX.Draw();
		//Check for quit
		if(PeekMessage(&msg_Message,m_hwnd,0,0,PM_REMOVE))
         {
             if(!IsDialogMessage(m_hwnd,&msg_Message))
             {
                 DispatchMessage(&msg_Message);
             }
         }
	}

	DestroyWindow(m_hwnd);

	return 0;
}
コード例 #8
0
static void InitMacToolbox (void)
{
	InitGraf (&qd.thePort);
	InitFonts ();
	InitWindows ();
	InitMenus ();
	TEInit ();
	InitDialogs (nil);
}
コード例 #9
0
ファイル: gui.c プロジェクト: chinese-opendesktop/oxim
void
gui_init(xccore_t *xccore)
{
    gui = oxim_malloc(sizeof(gui_t), True);

    if (! (gui->display = XOpenDisplay(xccore->display_name)))
    {
	oxim_perr(OXIMMSG_ERROR, N_("cannot open display: %s\n"),
			    xccore->display_name);
    }
    Atom oxim_atom = XInternAtom(gui->display, OXIM_ATOM, True);
    if (oxim_atom != None && XGetSelectionOwner(gui->display, oxim_atom) != None)
    {
	oxim_perr(OXIMMSG_WARNING, N_("OXIM already running!\n"));
	exit(0);
    }

    (void) XSetErrorHandler(errhandle);
    gui->screen = DefaultScreen(gui->display);
    gui->visual = DefaultVisual(gui->display, gui->screen);
    gui->colormap = DefaultColormap(gui->display, gui->screen);
    gui->display_width = DisplayWidth(gui->display, gui->screen);
    gui->display_height = DisplayHeight(gui->display, gui->screen);
    gui->root = RootWindow(gui->display, gui->screen);

    gui_cursor_hand = XCreateFontCursor(gui->display, XC_hand2);
    gui_cursor_move = XCreateFontCursor(gui->display, XC_fleur);
    gui_cursor_arrow = XCreateFontCursor(gui->display, XC_left_ptr);

    gui_init_xft();
    InitWindows(xccore);

    gui->xcin_style = False;
    if (strcasecmp("yes", oxim_get_config(XcinStyleEnabled)) == 0)
    {
	gui->xcin_style = True;
    }

    gui->onspot_enabled = False;
    if (strcasecmp("yes", oxim_get_config(OnSpotEnabled)) == 0)
    {
	gui->onspot_enabled = True;
    }

    xccore->display = gui->display;
    xccore->window  = gui->status_win->window;

    /* 利用計時中斷,偵測 WM 的 Tray Manager 是否 Ready */
    if(!xccore->hide_tray)
    {
	signal(SIGALRM, gui_tray_monitor);
	gui_tray_monitor(SIGALRM);
    }

}
コード例 #10
0
ファイル: shell.c プロジェクト: MaddTheSane/tntbasic
/* ----------- private code */
static void initialize_application(
	void)
{
	Handle menubar;
	StringHandle		userName;

#ifndef OP_PLATFORM_MAC_CARBON_FLAG
	MaxApplZone();
	MoreMasters();
	MoreMasters();
	MoreMasters();
	
	InitGraf(&qd.thePort);
	InitFonts();
	InitWindows();
	InitMenus();
	TEInit();
	InitDialogs(NULL);
#else
	MoreMasterPointers(192);
#endif // ! OP_PLATFORM_MAC_CARBON_FLAG

	InitCursor();

	FlushEvents(everyEvent, 0);

	menubar= GetNewMBar(rMENU_BAR_ID);
	op_assert(menubar);

	SetMenuBar(menubar);
	DisposeHandle(menubar);
	AppendResMenu(GetMenuHandle(mApple), 'DRVR');
	DrawMenuBar();

	//	Get the user name from the systemÉ
	
	userName = GetString (-16096);
	if (userName == NULL)
		strcpy(gNameString, "OpenPlay Test");
	else
	{
		doCopyP2CStr(*userName,gNameString);
		ReleaseResource ((Handle) userName);
	}

	// ecf - we wanna enable enumeration by default...
	check_menu_item(mSpecial, iActiveEnumeration, active_enumeration);
	
	//install apple event handler for quitting
	AEInstallEventHandler(kCoreEventClass,kAEQuitApplication,NewAEEventHandlerUPP((AEEventHandlerProcPtr)do_quit_apple_event),0L,false);
	
	return;
}
コード例 #11
0
ファイル: ftlint_m.c プロジェクト: anoopadvaitha/lincodelib
static void
init_toolbox()
{
    InitGraf(&qd.thePort);
    InitFonts();
    InitWindows();
    TEInit();
    InitDialogs((long)0);
    InitMenus();
    InitCursor();
    SIOUXSettings.asktosaveonclose = 0;
}
コード例 #12
0
ファイル: MacInstallWizard.c プロジェクト: rn10950/RetroZilla
void InitManagers(void)
{
	MaxApplZone();	
	MoreMasters(); MoreMasters(); MoreMasters();
	
	InitGraf(&qd.thePort);  
	InitFonts();			
	InitWindows();
	InitMenus();
	TEInit();				
	InitDialogs(NULL);
	
	InitCursor();		
	FlushEvents(everyEvent, 0);	
}
コード例 #13
0
ファイル: Retro68Test.c プロジェクト: clehner/Retro68Test
void Initialize(void)
{
	InitGraf((Ptr) &qd.thePort);
	InitFonts();
	FlushEvents(everyEvent, 0);

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

}
コード例 #14
0
static void
init_toolbox()
{
#ifndef USING_CARBON
	InitGraf(&qd.thePort);
	InitFonts();
	InitWindows();
	TEInit();
	InitDialogs((long)0);
	InitMenus();
	InitCursor();
#endif

	SIOUXSettings.asktosaveonclose = 0;
}
コード例 #15
0
ファイル: gui.c プロジェクト: chinese-opendesktop/oxim
void oxim_reload(void)
{
    winlist_t *win = gui->status_win;
    xccore_t *xccore = (xccore_t *)win->data;
    IC *ic = xccore->ic;

    /* 關掉所有視窗 */
    gui_hide_symbol();
    gui_hide_keyboard();
    gui_hide_menu();
    gui_hide_msgbox();
    gui_hide_selectmenu();
    reload_filter();

    /* 關掉輸入狀態,回復英數模式 */
    if (ic)
    {
	IM_Context_t *imc = ic->imc;
	inp_state_t inp_state = imc->inp_state;
	change_IM(ic, -1);
	if (inp_state & IM_2BYTES)
	{
	    imc->inp_state &= ~(IM_2BYTES|IM_2BFOCUS|IM_CINPUT);
	}
	gui_update_winlist();
    }

    /* 紀錄各個視窗位置 */
    gui_save_window_pos();

    /* 重新載入系統設定 */
    oxim_Reload();

    /* 重新初始化字型系統 */
    gui_init_xft();

    /* 重新初始化視窗 */
    InitWindows(xccore);

    /* 重設所有的 imc */
    imc_reset();

    /* 重設所有的 Trigger Keys */
    xim_set_trigger_keys();
    
    /* reload panel.conf */
    ReloadPanel(xccore);
}
コード例 #16
0
bool IApplication::Initialize()
{
	if(!InitWindows())
		return false;

	if(!InitD3D())
		return false;

	if(!LoadAssets())
		return false;

	if(FAILED(D3DXCreateFont(m_pD3DDevice, 20, 10, FW_BOLD, 1, FALSE, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, DEFAULT_QUALITY, (DEFAULT_PITCH | FF_DONTCARE), "Arial", &m_pFont)))
		return false;

	return true;		
}
コード例 #17
0
ファイル: bmpclock.c プロジェクト: turmary/smalls
extern int WINAPI WinMain(HINSTANCE hInstance,
	HINSTANCE hPrevInstance,
	LPSTR lpszCmdLIne,
	int nCmdShow) {
		MSG Msg;
		if (!InitWindowsClass(hInstance))
			return FALSE;
		if (!InitWindows(hInstance, nCmdShow))
			return FALSE;

		while(GetMessage(&Msg, NULL, 0, 0)) {
			TranslateMessage(&Msg);
			DispatchMessage(&Msg);
		}
		return Msg.wParam;
}
コード例 #18
0
ファイル: CRSVMAC.C プロジェクト: marcinch18/nasa-cosmic
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();
  }
コード例 #19
0
ファイル: tclMacAppInit.c プロジェクト: AsvAgent/ASV
static int
MacintoshInit()
{
#if GENERATING68K && !GENERATINGCFM
    SetApplLimit(GetApplLimit() - (TCL_MAC_68K_STACK_GROWTH));
#endif
    MaxApplZone();

#if defined(THINK_C)

    /* Set options for Think C console package */
    /* The console package calls the Mac init calls */
    console_options.pause_atexit = 0;
    console_options.title = "\pTcl Interpreter";
		
#elif defined(__MWERKS__)

    /* Set options for CodeWarrior SIOUX package */
    SIOUXSettings.autocloseonquit = true;
    SIOUXSettings.showstatusline = true;
    SIOUXSettings.asktosaveonclose = false;
    SIOUXSettings.wasteusetempmemory = true;    
    InstallConsole(0);
    SIOUXSetTitle("\pTcl Interpreter");
		
#elif defined(applec)

    /* Init packages used by MPW SIOW package */
    InitGraf((Ptr)&qd.thePort);
    InitFonts();
    InitWindows();
    InitMenus();
    TEInit();
    InitDialogs(nil);
    InitCursor();
		
#endif

    Tcl_MacSetEventProc((Tcl_MacConvertEventPtr) SIOUXHandleOneEvent);
    
    /* No problems with initialization */
    return TCL_OK;
}
コード例 #20
0
bool CSystem::Init()
{
	HeapSetInformation(NULL, HeapEnableTerminationOnCorruption, NULL, 0);
	AllocConsole();
	consoleHandle = GetStdHandle(STD_OUTPUT_HANDLE);
	FILE* file = NULL;
	freopen_s(&file, "CONOUT$", "w", stdout);
	// Initialize the width and height of the screen to 0 before it is assigned
	int screenWidth = 0;
	int screenHeight = 0;
	bool result;

	// Init the windows api
	InitWindows(screenWidth, screenHeight);	
	WriteToConsole("Initialized Window", INFO);

	// Create a new input object used to handle user input
	m_pInput = new CInputManager();
	if(!m_pInput)
	{
		return false;
	}
	// Initialize the input object
	m_pInput->Init();
	WriteToConsole("Initialized Input", INFO);

	m_pRenderer = new CRenderer();
	if(!m_pRenderer)
	{
		return false;
	}
	// Initialize the renderer
	result = m_pRenderer->Init(screenWidth, screenHeight, m_hwnd);

	if(!result)
	{
		WriteToConsole("Renderer initialized with errors.", ERRORS);
		return false;
	}

	WriteToConsole("Renderer initialized successfully!", INFO);
	return true;	
}
コード例 #21
0
ファイル: np2.cpp プロジェクト: perabuss/np2wii
static void InitToolBox(void) {

#if !TARGET_CARBON
	MaxApplZone();
	InitGraf(&qd.thePort);
	InitFonts();
	InitWindows();
	InitMenus();
	TEInit();
	InitDialogs(0);
#endif
	FlushEvents(everyEvent, 0);
	InitCursor();

#ifdef TARGET_API_MAC_CARBON
	AEInstallEventHandler(kCoreEventClass, kAEQuitApplication,
						AEProc(handleQuitApp), 0L, false);
#endif
}
コード例 #22
0
ファイル: main.cpp プロジェクト: dianxiang/graphics
SINT WINAPI WinMain( 
		HINSTANCE hInstance,
		HINSTANCE hPrevInstance ,
		LPSTR lpCmdLine,
		SINT nCmdShow // how the window will be shown
	){
		SLONG width = 800;
		SLONG height = 600;

		HWND hWnd;

		InitWindows( hWnd, hInstance, nCmdShow, width, height );
		InitD3D( hWnd, (SFLOAT)width, (SFLOAT)height );

		//show the window
		ShowWindow( hWnd, nCmdShow );
		MSG msg;

		while( TRUE ){ //min and max are limitations on which messages we want to get from the queue

			if( PeekMessage( &msg, NULL, 0, 0, PM_REMOVE ) ){
				
				TranslateMessage( &msg );
				DispatchMessage( &msg ); // sends message to WindowProc

				if( msg.message == WM_QUIT ){
					break;
				}

			} else {
				Render();
			}
				
		}

		//cleaning up D3D
		CleanD3D();

		return msg.wParam;

}
コード例 #23
0
int WINAPI wWinMain(HINSTANCE hinstance,HINSTANCE hPrevInstance,LPWSTR lpCmdLine,int nCmdShow)
{
	UNREFERENCED_PARAMETER(hPrevInstance);
	UNREFERENCED_PARAMETER(lpCmdLine);

	if (FAILED(InitWindows(hinstance,nCmdShow)))
	{
		return 0;
	}

	MSG msg = { 0 };

	while (GetMessage(&msg,NULL,0,0))
	{
		TranslateMessage(&msg);
		DispatchMessage(&msg);
	}

	return (int)msg.wParam;
	
}
コード例 #24
0
ToolBox::ToolBox(void)
{
	short i;
	/* if you have stack requirements that differ from the default, 
		then you counld use SetApplLimit to increase StackSpace at
		this point, before calling MaxApplZone */
		
	MaxApplZone();
	for(i = 0; i < 50; i++)
		MoreMasters();

	//notice the following order is important
	InitGraf(&(qd.thePort));
	InitFonts();
	InitWindows();
	InitMenus();
	TEInit();
	InitDialogs(0L);
	InitCursor();
	FlushEvents( everyEvent, REMOVE_EVENTS);
}
コード例 #25
0
ファイル: main.c プロジェクト: dvincent/frontier
static void initmacintosh (void) {

	/*
	the magic stuff that every Macintosh application needs to do 
	before doing anything else.
	*/

	short i;
		
	MaxApplZone ();
	
	for (i = 0; i < 10; i++) 
		MoreMasters ();
	
	InitGraf (&qd.thePort);
	
	InitFonts ();
	
	FlushEvents (everyEvent, 0);
	
	InitWindows ();
	
	InitMenus ();
	
	TEInit ();
	
	InitDialogs (0L);
	
	InitCursor ();
	
	for (i = 0; i < 5; i++) { /*register with Multifinder*/
		
		EventRecord ev;
		
		EventAvail (everyEvent, &ev); /*see TN180 -- splash screen*/
		} /*for*/
	} /*initmacintosh*/
コード例 #26
0
ファイル: RecogDlg.cpp プロジェクト: FlynnShek/facerecog
BOOL CRecogDlg::OnInitDialog()
{
	CDialog::OnInitDialog();

	faceSz = g_faceMngr->m_faceSz;
	showSz = faceSz;

	if (showSz.height != 160) // (160*130)是预定显示大小,如果归一化大小不是则进行调整
		showSz *= (160.0/showSz.height);
	if (showSz.width > 130)
		showSz *= (130.0/showSz.width);


	if (g_bHasWebcam)
	{
		m_bFoundFace = false;
		SetDlgItemText(IDC_INFO, "    如果显示\"no face found\",请调整姿态,光照和表情");
		m_frame = cvCreateImage(g_webcam.GetFrameSize(), IPL_DEPTH_8U, 3);
		m_bMatchStarted = true;
		m_thrdMatch = ::AfxBeginThread(ShowMatchProc, this);
		GetDlgItem(IDC_USEBUF)->ShowWindow(SW_SHOW);
	}
	else
	{
		SetDlgItemText(IDC_INFO, "");
		GetDlgItem(IDC_USEBUF)->EnableWindow(FALSE);
	}

	InitWindows();

	RECT rc;
	GetWindowRect(&rc);
	SetWindowPos(NULL, rc.left + 30, rc.top + 300, 0,0, SWP_NOSIZE | SWP_NOZORDER);

	ShowWindow(SW_SHOWNORMAL);
	return TRUE;
}
コード例 #27
0
ファイル: macpgen.c プロジェクト: LapsedAcademicsInc/putty
static void mac_startup(void) {
    Handle menuBar;
    TECInfoHandle ti;

#if !TARGET_API_MAC_CARBON
    /* Init Memory Manager */
    MaxApplZone();
    /* Init QuickDraw */
    InitGraf(&qd.thePort);
    /* Init Font Manager */
    InitFonts();
    /* Init Window Manager */
    InitWindows();
    /* Init Menu Manager */
    InitMenus();
    /* Init TextEdit */
    TEInit();
    /* Init Dialog Manager */
    InitDialogs(NULL);
#endif
    
    /* Get base system version (only used if there's no better selector) */
    if (Gestalt(gestaltSystemVersion, &mac_gestalts.sysvers) != noErr ||
	(mac_gestalts.sysvers &= 0xffff) < 0x700)
	fatalbox("PuTTYgen requires System 7 or newer");
    /* Find out if we've got Color Quickdraw */
    if (Gestalt(gestaltQuickdrawVersion, &mac_gestalts.qdvers) != noErr)
    	mac_gestalts.qdvers = gestaltOriginalQD;
    /* ... and the Appearance Manager? */
    if (Gestalt(gestaltAppearanceVersion, &mac_gestalts.apprvers) != noErr)
	if (Gestalt(gestaltAppearanceAttr, NULL) == noErr)
	    mac_gestalts.apprvers = 0x0100;
	else
	    mac_gestalts.apprvers = 0;
#if TARGET_RT_MAC_CFM
    /* Paranoia: Did we manage to pull in AppearanceLib? */
    if (&RegisterAppearanceClient == kUnresolvedCFragSymbolAddress)
	mac_gestalts.apprvers = 0;
#endif
#if TARGET_CPU_68K
    mac_gestalts.cntlattr = 0;
    mac_gestalts.windattr = 0;
#else
    /* Mac OS 8.5 Control Manager (proportional scrollbars)? */
    if (Gestalt(gestaltControlMgrAttr, &mac_gestalts.cntlattr) != noErr ||
	&SetControlViewSize == kUnresolvedCFragSymbolAddress)
	mac_gestalts.cntlattr = 0;
    /* Mac OS 8.5 Window Manager? */
    if (Gestalt(gestaltWindowMgrAttr, &mac_gestalts.windattr) != noErr ||
	&SetWindowContentColor == kUnresolvedCFragSymbolAddress)
	mac_gestalts.windattr = 0;
#endif
    /* Text Encoding Conversion Manager? */
    if (
#if TARGET_RT_MAC_CFM
	&TECGetInfo == kUnresolvedCFragSymbolAddress ||
#else
	InitializeUnicodeConverter(NULL) != noErr ||
#endif
	TECGetInfo(&ti) != noErr)
	mac_gestalts.encvvers = 0;
    else {
	mac_gestalts.encvvers = (*ti)->tecVersion;
	mac_gestalts.uncvattr = (*ti)->tecUnicodeConverterFeatures;
	DisposeHandle((Handle)ti);
    }
    /* Navigation Services? */
    if (NavServicesAvailable())
	mac_gestalts.navsvers = NavLibraryVersion();
    else
	mac_gestalts.navsvers = 0;

    /* We've been tested with the Appearance Manager */
    if (mac_gestalts.apprvers != 0)
	RegisterAppearanceClient();

    menuBar = GetNewMBar(128);
    if (menuBar == NULL)
	fatalbox("Unable to create menu bar.");
    SetMenuBar(menuBar);
    AppendResMenu(GetMenuHandle(mApple), 'DRVR');
    mac_adjustmenus();
    DrawMenuBar();
    InitCursor();
    windows.about = NULL;
    windows.licence = NULL;

    flags = FLAG_INTERACTIVE;

    /* Install Apple Event handlers. */
#if 0
    AEInstallEventHandler(kCoreEventClass, kAEOpenApplication,
			  NewAEEventHandlerUPP(&mac_aevt_oapp), 0, FALSE);
    AEInstallEventHandler(kCoreEventClass, kAEOpenDocuments,
			  NewAEEventHandlerUPP(&mac_aevt_odoc), 0, FALSE);
    AEInstallEventHandler(kCoreEventClass, kAEPrintDocuments,
			  NewAEEventHandlerUPP(&mac_aevt_pdoc), 0, FALSE);
#endif
    AEInstallEventHandler(kCoreEventClass, kAEQuitApplication,
			  NewAEEventHandlerUPP(&mac_aevt_quit), 0, FALSE);
}
コード例 #28
0
/*
 * MainWindowProc - procedure for main (root) window
 */
WINEXPORT LRESULT CALLBACK MainWindowProc( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam )
{
    RECT        rect;
    vi_rc       rc;
    HANDLE      hfileinfo;
    int         cnt, i;
    char        *buff;

    switch( msg ) {
    case WM_CREATE:
        Root = hwnd;
        GetClientRect( hwnd, &rect );
        EditContainer = CreateContainerWindow( &rect );
        InitWindows();
        DragAcceptFiles( hwnd, TRUE );
        timerID = SetTimer( hwnd, TIMER_ID, 60L * 1000L, NULL );
        break;
    case WM_DROPFILES:
        hfileinfo = (HANDLE) wparam;
        cnt = DragQueryFile( hfileinfo, (UINT)-1, NULL, 0 );
        buff = alloca( FILENAME_MAX + 2 );   /* we add a " at the beginning and at the end so we can handle path- and filenames with spaces */
        if( buff != NULL ) {
            buff[0] = '"';      /* one " at the beginning of the filename */
            for( i = 0; i < cnt; i++ ) {
                if( DragQueryFile( hfileinfo, i, buff + 1, FILENAME_MAX ) == (UINT)-1 ) {
                    break;
                }
                strcat( buff, "\"" );
                rc = EditFile( buff, FALSE );
                if( rc > ERR_NO_ERR ) {
                    Error( GetErrorMsg( rc ) );
                }
            }
        }
        DragFinish( hfileinfo );
        break;
    case WM_TIMER:
        UpdateStatusWindow();
        break;
    case WM_KEYDOWN:
        if( WindowsKeyPush( wparam, HIWORD( lparam ) ) ) {
            return( 0 );
        }
        break;
    case WM_SIZE:
        DefFrameProc( hwnd, EditContainer, msg, wparam, lparam );
        RootState = wparam;
        if( wparam != SIZE_MINIMIZED ) {
            ResizeRoot();
            GetWindowRect( hwnd, &RootRect );
            if( wparam != SIZE_MAXIMIZED ) {
                RootState = 0;
            }
        }
        return( 0 );
    case WM_MOVE:
        DefFrameProc( hwnd, EditContainer, msg, wparam, lparam );
        if( RootState != SIZE_MINIMIZED ) {
            GetWindowRect( hwnd, &RootRect );
        }
        return( 0 );
    case WM_ACTIVATEAPP:
        if( BAD_ID( CurrentWindow ) ) {
            break;
        }
        SetFocus( Root );
#if 0
        if( !wparam ) {
            InactiveWindow( CurrentWindow );
        } else {
            SendMessage( EditContainer, WM_MDIACTIVATE, (WPARAM)CurrentWindow, 0L );
        }
#endif
        if( wparam ) {
            ResetEditWindowCursor( CurrentWindow );
        } else {
            GoodbyeCursor( CurrentWindow );
        }
        break;
    case WM_MOUSEACTIVATE:
        SetFocus( hwnd );
        return( MA_ACTIVATE );
    case WM_SETFOCUS:
        if( BAD_ID( CurrentWindow ) ) {
            break;
        }
        if( !IsIconic( CurrentWindow ) ) {
            SendMessage( EditContainer, WM_MDIACTIVATE, (WPARAM)CurrentWindow, 0L );
            DCUpdate();
            SetWindowCursor();
            SetWindowCursorForReal();
            return( 0 );
        }
        break;
    case WM_NCLBUTTONDBLCLK:
        break;
    case WM_COMMAND:
        if( LOWORD( wparam ) > 0xF000 ) {
            break;
        } else {
            rc = MenuCommand( LOWORD( wparam ) );
            if( rc != MENU_COMMAND_NOT_HANDLED ) {
                DCUpdateAll();
                if( rc > ERR_NO_ERR ) {
                    char        *msg;
                    msg = GetErrorMsg( rc );
                    Error( msg );
                }
            }
            SetWindowCursor();
        }
        return( 0 );
    case WM_INITMENU:
        if( (HMENU)wparam == GetMenu( hwnd ) ) {
            HandleInitMenu( (HMENU)wparam );
        } else {
            ResetMenuBits();
        }
        break;
    case WM_MENUSELECT:
        HandleMenuSelect( wparam, lparam );
        break;
    case WM_ENDSESSION:
        if( wparam ) {
            ExitEditor( 0 );
            // will not return
        }
        return( 0 );
    case WM_QUERYENDSESSION:
        return( ExitWithPrompt( FALSE, TRUE ) );
    case WM_CLOSE:
        ExitWithPrompt( TRUE, TRUE );
        return( 0 );
#ifdef __NT__        
    case WM_MOUSEWHEEL:
        {
            int     i, increment;
            ULONG   linesPerNotch;
            HWND    activeWnd;
            
            activeWnd = (HWND)SendMessage( EditContainer, WM_MDIGETACTIVE, 0, 0 );
            SystemParametersInfo( SPI_GETWHEELSCROLLLINES, 0, &linesPerNotch, 0 );
            
            increment = GET_WHEEL_DELTA_WPARAM( wparam ) / 120;
                // see WM_MOUSEWHEEL-documentation for information about the "120"

            if( increment > 0 ) {
                for( i = 0; i < increment * (int)linesPerNotch; i++ ) {
                    SendMessage( activeWnd, WM_VSCROLL, SB_LINEUP, 0 );
                }
            } else {
                for( i = 0; i < (-increment) * (int)linesPerNotch; i++ ) {
                    SendMessage( activeWnd, WM_VSCROLL, SB_LINEDOWN, 0 );
                }
            }
        }
        return( 0 );
#endif
    case WM_DESTROY:
        DestroyToolBar();
        DragAcceptFiles( hwnd, FALSE );
        EditContainer = 0;
        if( timerID ) {
            KillTimer( hwnd, TIMER_ID );
        }
        return( 0 );
    }
    return( DefFrameProc( hwnd, EditContainer, msg, wparam, lparam ) );

} /* MainWindowProc */
コード例 #29
0
ファイル: mac.c プロジェクト: pombredanne/Frontier
boolean initmacintosh (void) {
	
	/*
	the magic stuff that every Macintosh application needs to do 
	before doing anything else.
	
	4/24/91 dmb: added memory config resource stuff
	
	3.0.4 dmb: use LMGetCurStackBase, not CurStackBase global
	
	3.0.4 dmb: pass 0L to InitDialogs
	*/
	
	register short i;
	register hdlmemoryconfig h;
	register long ctbytes;
	//Code change by Timothy Paustian Thursday, June 8, 2000 3:45:13 PM
	//
	#if TARGET_API_MAC_CARBON == 0
	long ctstack;
	#endif
	long ctheap, ctcode;
	short ctmasters;
	
	h = (hdlmemoryconfig) Get1Resource ('MCFG', 1);
	
	if (h == nil)
		clearbytes (&macmemoryconfig, sizeof (macmemoryconfig));
	else
		macmemoryconfig = **h;
	
	//Code change by Timothy Paustian Saturday, June 3, 2000 10:13:20 PM
	//Changed to Opaque call for Carbon
	//we don't need this in carbon.
	#if TARGET_API_MAC_CARBON == 0
	if (h != nil) { /*first check stack size*/
		
		ctbytes = (**h).minstacksize;
		
		ctstack = LMGetCurStackBase () - GetApplLimit (); /*current stack size*/
		
		if (ctbytes > ctstack)
			SetApplLimit (LMGetCurStackBase () - ctbytes);
		}
	MaxApplZone ();
	
	#endif

	
	
	if (h != nil) { /*check heap size and master pointers*/
		
		ctbytes = (**h).minheapsize;
		
		//Code change by Timothy Paustian Thursday, June 8, 2000 3:04:31 PM
		//Changed to Opaque call for Carbon
		//This is meaningless for OS X since it has unlimited memory.
		
		#if TARGET_API_MAC_CARBON == 1
		//we need to do somethings else. FreeMem is going to return some large value
		//of all the available system memory
		//This whole thing is pointless. We can get as much memory as we need.

			#pragma unused (ctmasters)
			#pragma unused (ctcode)
			#pragma unused (ctheap)
		
		#else

		ctheap = FreeMem ();
		
		if (ctbytes > ctheap) {
			
			return (false);
			}
		
		ctbytes = (**h).avghandlesize;
		
		ctcode = (**h).reserveforcode;
		
		if ((ctbytes > 0) && (ctheap > ctcode)) {
			
			ctmasters = ((ctheap - ctcode) / ctbytes) / kNumberOfMasters;
			
			ctmasters = min (ctmasters, 1024);  /*7.1b37 PBS: You'd think 1024 calls would be enough. With large memory alottments on Mac
			  						  			Classic, we're calling MoreMasters in excess of 20,000 times. That makes the app take
			  						  			a minute or so to start up! So instead I've chosen an arbitrary limit.*/
			  						  
			for (i = 1; i < ctmasters; i++) 
				MoreMasters ();
			}
		#endif

		ReleaseResource ((Handle) h); /*we're done with it*/
		}
	
	//Code change by Timothy Paustian Thursday, June 8, 2000 3:21:06 PM
	//Changed to Opaque call for Carbon
	//we don't need this initialization in carbon
	#if TARGET_API_MAC_CARBON == 0
	InitGraf (&qd.thePort);
	
	InitFonts ();
	
	FlushEvents (everyEvent, 0);
	
	InitWindows ();
	
	InitMenus ();
	
	TEInit ();
	
	InitDialogs (0L);
	#endif

	
	InitCursor ();
	//Code change by Timothy Paustian Thursday, June 8, 2000 3:22:57 PM
	//Changed to Opaque call for Carbon
	//this is obsolete, we should be using gestalt for this.
	
	{	
		long quickDrawFeatures;
		OSErr theErr = Gestalt(gestaltSystemVersion, &gSystemVersion);
		if(oserror(theErr))
			ExitToShell();

		theErr = Gestalt(gestaltQuickdrawFeatures, &quickDrawFeatures);
		
		if(oserror(theErr))
			ExitToShell();
		gHasColorQD = (quickDrawFeatures & (1 << gestaltHasColor));
		//Nav services has to be present and we want the 1.1 or greater version.
		gCanUseNavServ = (NavServicesAvailable() && (NavLibraryVersion() >= 0x01108000));
	}
	
	
	//SysEnvirons (1, &macworld);
	
	//gee I bet this isn't required anymore either.
	for (i = 1; i <= 5; i++) { /*register with Multifinder*/
		
		EventRecord ev;
		
		EventAvail (everyEvent, &ev); /*see TN180 -- splash screen*/
		} /*for*/
	
	#if TARGET_API_MAC_CARBON == 1
	
		RegisterAppearanceClient ();
		
	#endif
	
	return (true);
	} /*initmacintosh*/
コード例 #30
0
static int
MacintoshInit()
{
    int i;
    long result, mask = 0x0700; 		/* mask = system 7.x */

#if GENERATING68K && !GENERATINGCFM
    SetApplLimit(GetApplLimit() - (TK_MAC_68K_STACK_GROWTH));
#endif
    MaxApplZone();
    for (i = 0; i < 4; i++) {
	(void) MoreMasters();
    }

    /*
     * Tk needs us to set the qd pointer it uses.  This is needed
     * so Tk doesn't have to assume the availablity of the qd global
     * variable.  Which in turn allows Tk to be used in code resources.
     */
    tcl_macQdPtr = &qd;

    /*
     * If appearance is present, then register Tk as an Appearance client
     * This means that the mapping from non-Appearance to Appearance cdefs
     * will be done for Tk regardless of the setting in the Appearance
     * control panel.  
     */
     
     if (TkMacHaveAppearance()) {
         RegisterAppearanceClient();
     }

    InitGraf(&tcl_macQdPtr->thePort);
    InitFonts();
    if (TkMacHaveAppearance() >= 0x110) {
        InitFloatingWindows();
    } else {
    InitWindows();
    }
    InitMenus();
    InitDialogs((long) NULL);		
    InitCursor();

    /*
     * Make sure we are running on system 7 or higher
     */
     
    if ((NGetTrapAddress(_Gestalt, ToolTrap) == 
    	    NGetTrapAddress(_Unimplemented, ToolTrap))
    	    || (((Gestalt(gestaltSystemVersion, &result) != noErr)
	    || (result < mask)))) {
	panic("Tcl/Tk requires System 7 or higher.");
    }

    /*
     * Make sure we have color quick draw 
     * (this means we can't run on 68000 macs)
     */
     
    if (((Gestalt(gestaltQuickdrawVersion, &result) != noErr)
	    || (result < gestalt32BitQD13))) {
	panic("Tk requires Color QuickDraw.");
    }

    
    FlushEvents(everyEvent, 0);
    SetEventMask(everyEvent);


    Tcl_MacSetEventProc(TkMacConvertEvent);
    return TCL_OK;
}