Exemplo n.º 1
0
static void mac_groweventlog(WindowPtr window, EventRecord *event)
{
    Session *s = mac_windowsession(window);
    Rect limits;
    long grow_result;
#if TARGET_API_MAC_CARBON
    Rect rect;
    Point cellsize;
#else
    GrafPtr saveport;
#endif

    SetRect(&limits, 15, 0, SHRT_MAX, SHRT_MAX);
    grow_result = GrowWindow(window, event->where, &limits);
    if (grow_result == 0) return;
    SizeWindow(window, LoWord(grow_result), HiWord(grow_result), TRUE);
    LSize(LoWord(grow_result) - 15, HiWord(grow_result), s->eventlog);
    mac_adjusteventlogscrollbar(s);
    /* We would use SetListCellSize in Carbon, but it's missing. */
    (*s->eventlog)->cellSize.h = LoWord(grow_result) - 15;
#if TARGET_API_MAC_CARBON
    cellsize.h = LoWord(grow_result) - 15;
    GetListViewBounds(s->eventlog, &rect);
    InvalWindowRect(window, &rect);
#else
    GetPort(&saveport);
    SetPort(window);
    InvalRect(&(*s->eventlog)->rView);
    SetPort(saveport);
#endif
}
Exemplo n.º 2
0
extended DoubleToExtended(double q)
{
  extended x;
  uint32 mant, mant2;
  int16 sign;
  uint16 exp;
  
  sign = q<0 ? 0x8000 : 0;
  
  if (sign)
  {
    q = -q;
  }
  
  exp = (uint16) (log(q)/log(2.));
  
  mant = (uint32)(q/pow(2., (double)exp-31.));
  
  q -= (double )mant * pow(2.,(double)exp-31.);
  mant2 = (uint32)(q/pow(2.,(double)exp-63));
  
  exp += 0x3FFF;
  exp |= sign;
  
  x.exp[0] = exp;
  x.man[0] = HiWord(mant);
  x.man[1] = LoWord(mant);
  x.man[2] = HiWord(mant2);
  x.man[3] = LoWord(mant2);
  
  return x;
}
Exemplo n.º 3
0
static void DoMenuCommand( long menuAndItem ) {
	int			myMenuNum;
	int			myItemNum;
	int			myResult;
	Str255		myDAName;
	WindowPtr	myWindow;
	
	myMenuNum	= HiWord(menuAndItem);
	myItemNum	= LoWord(menuAndItem);
	
	GetPort(&myWindow);
	
	switch (myMenuNum)  {
	case mApple:
		switch( myItemNum ) {
		case iAbout: 
			DoAboutBox();
			break;
		default: 
			GetMenuItemText(GetMenuHandle(mApple), myItemNum, myDAName);
			myResult = OpenDeskAcc(myDAName);
			break;
		}
		break;
	case mFile:
		switch (myItemNum) {
		case iQuit:
			Com_Quit_f();
			break;
		}
		break;
	}
	
	HiliteMenu(0);
}
Exemplo n.º 4
0
void handleMenuSelection(long result)
{
	int menuID, menuItem;
	RgnHandle rgnHandle = NewRgn();
	
	menuID = HiWord(result);
	menuItem = LoWord(result);
	
	if (menuID == FILE_MENU) {
		if (menuItem == FILE_SAVE)
			saveToPICTFile();
		else if (menuItem == FILE_QUIT)
			gDone = true;
		else if (menuItem == FILE_CLOSE) {
			DisposeWindow(FrontWindow());
			if (FrontWindow() == NULL)
				gDone = true;
		}
		else if (menuItem == FILE_NEW) {
		
		}
		else if (menuItem == FILE_REFRESH) {
			createImage();
			drawImage(FrontWindow());
			QDFlushPortBuffer(GetWindowPort(FrontWindow()), GetPortVisibleRegion(GetWindowPort(FrontWindow()), rgnHandle));
		}
	}
	HiliteMenu(0);
	DisposeRgn(rgnHandle);
}
bool GHOST_SystemCarbon::handleMenuCommand(GHOST_TInt32 menuResult)
{
	short menuID;
	short menuItem;
	UInt32 command;
	bool handled;
	OSErr err;
	
	menuID = HiWord(menuResult);
	menuItem = LoWord(menuResult);

	err = ::GetMenuItemCommandID(::GetMenuHandle(menuID), menuItem, &command);

	handled = false;
	
	if (err || command == 0) {
	}
	else {
		switch (command) {
		}
	}

	::HiliteMenu(0);
	return handled;
}
Exemplo n.º 6
0
boolean clickcolorpopup (Point pt, RGBColor *rgb) {
	
	long result;
	short lo, hi;
	
	if (!flpopupinit)
		flpopupinit = initcolorpopup ();
	
	setcursortype (cursorisarrow);
	
	CalcMenuSize (colormenu);
	
	InsertMenu (colormenu, hierMenu);

	LocalToGlobal (&pt);
	
	result = PopUpMenuSelect (colormenu, pt.v, pt.h, -1);

	DeleteMenu ((**colormenu).menuID);
	
	lo = LoWord (result);
	
	hi = HiWord (result);
	
	if (hi > 0) { /*something was selected*/
	
		*rgb = (*ctable) [lo - 1].rgb;
		
		return (true);
		}
	
	return (false);
	} /*clickcolorpopup*/
Exemplo n.º 7
0
void DoMenuCommand(long menuResult)
{
    short	menuID;		/* the resource ID of the selected menu */
    short	menuItem;	/* the item number of the selected menu */
	
    menuID = HiWord(menuResult);    /* use macros to get item & menu number */
    menuItem = LoWord(menuResult);
	
    switch (menuID) 
    {
        case mApple:
            switch (menuItem) 
            {
                case iAbout:
                    DoAboutBox();
                    break;
                    
                case iQuit:
                    ExitToShell();
                    break;
				
                default:
                    break;
            }
            break;
        
        case mFile:
            break;
		
        case mEdit:
            break;
    }
    HiliteMenu(0);	/* unhighlight what MenuSelect (or MenuKey) hilited */
}
Exemplo n.º 8
0
SInt32 myWindowHitTest(WindowRef window,SInt32 param)
{
    /*------------------------------------------------------
        Determine the region of the window which was hit
    --------------------------------------------------------*/
    Point hitPoint;
    static RgnHandle tempRgn=nil;
    if(!tempRgn) tempRgn=NewRgn();
  
    SetPt(&hitPoint,LoWord(param),HiWord(param));//get the point clicked
    
    if(IsWindowHilited(window)){ //make sure the window is in front for these

        if(PtInRgn(hitPoint,getWindowGrowBoxRegion(window,tempRgn)))//in GrowBox?
            return wInGrow;
        if(PtInRgn(hitPoint,getWindowCloseBoxRegion(window,tempRgn)))//in the Close Box?
            return wInGoAway;
        if(PtInRgn(hitPoint,getWindowZoomBoxRegion(window,tempRgn)))//in the Zoom Box?
            return wInZoomOut;
            
        //Mac OS 8.0 or later
        if(PtInRgn(hitPoint,getWindowCollapseBoxRegion(window,tempRgn)))//in the Collapse Box?
            return wInCollapseBox;
    }
     //Mac OS 8.5 or later
    if(PtInRgn(hitPoint,getWindowContentRegion(window,tempRgn))) //in window content region?
        return wInContent;
    if(PtInRgn(hitPoint,getWindowDragRegion(window,tempRgn)))//in window drag region?
        return wInDrag;

    return wNoHit;//no significant area was hit.
}
Exemplo n.º 9
0
void DoCommand(long mResult)
{
	short theItem;
	short theMenu;
	Str255		daName;
	short		daRefNum;
	
	theItem = LoWord(mResult);
	theMenu = HiWord(mResult);
	
	switch (theMenu)
	{
		case appleID:
		{
			if (theItem == 1)
			{
				Alert(rUserAlert, nil);
			}
			else
			{
				/* all non-About items in this menu are DAs */
				/* type Str255 is an array in MPW 3 */
				GetMenuItemText(GetMenuHandle(appleID), theItem, daName);
				daRefNum = OpenDeskAcc(daName);
			}
			break;
		}
		case fileID:
		{
			quit = 1;
			break;
		}
		case editID:
		{
			if (!SystemEdit(theItem-1)) // call Desk Manager to handle editing command if desk accessory window is the active window
			{
				switch (theItem) {
					case cutCommand:
						TECut(textH);
						break;
					case copyCommand:
						TECopy(textH);
						break;
					case pasteCommand:
						TEPaste(textH);
						break;
					case clearCommand:
						TEDelete(textH);
						break;
					default:
						break;
				}
			}
		}
		default:
			break;
	}
	
	HiliteMenu(0);
}
Exemplo n.º 10
0
void doMouseDown(EventRecord *eventStrucPtr)
{
    WindowRef      windowRef;
    WindowPartCode partCode, zoomPart;
    BitMap         screenBits;
    Rect           constraintRect, mainScreenRect;
    Point          standardStateHeightAndWidth;
    long           newSize;

    partCode = FindWindow(eventStrucPtr->where,&windowRef);

    switch(partCode)
    {
    case inMenuBar:
        break;

    case inContent:
        if(windowRef != FrontWindow())
            SelectWindow(windowRef);
        else
            doInContent(eventStrucPtr,windowRef);
        break;

    case inDrag:
        DragWindow(windowRef,eventStrucPtr->where,NULL);
        break;

    case inGoAway:
        break;

    case inGrow:
        constraintRect.top   = 75;
        constraintRect.left = 250;
        constraintRect.bottom = constraintRect.right = 32767;
        newSize = GrowWindow(windowRef,eventStrucPtr->where,&constraintRect);
        if (newSize != 0)
            SizeWindow(windowRef,LoWord(newSize),HiWord(newSize),true);
        window_adjust_scrollbars(windowRef);
        window_invalidate(windowRef);
        break;

    case inZoomIn:
    case inZoomOut:
        mainScreenRect = GetQDGlobalsScreenBits(&screenBits)->bounds;
        standardStateHeightAndWidth.v = mainScreenRect.bottom;
        standardStateHeightAndWidth.h = mainScreenRect.right;

        if(IsWindowInStandardState(windowRef,&standardStateHeightAndWidth,NULL))
            zoomPart = inZoomIn;
        else
            zoomPart = inZoomOut;

        if(TrackBox(windowRef,eventStrucPtr->where,partCode))
        {
            ZoomWindowIdeal(windowRef,zoomPart,&standardStateHeightAndWidth);
            window_adjust_scrollbars(windowRef);
        }
        break;
    }
}
Exemplo n.º 11
0
static void mac_updatelicence(WindowPtr window)
{
    Handle h;
    int len;
    long fondsize;
    Rect textrect;

    SetPort((GrafPtr)GetWindowPort(window));
    BeginUpdate(window);
    fondsize = GetScriptVariable(smRoman, smScriptSmallFondSize);
    TextFont(HiWord(fondsize));
    TextSize(LoWord(fondsize));
    h = Get1Resource('TEXT', wLicence);
    len = GetResourceSizeOnDisk(h);
#if TARGET_API_MAC_CARBON
    GetPortBounds(GetWindowPort(window), &textrect);
#else
    textrect = window->portRect;
#endif
    if (h != NULL) {
	HLock(h);
	TETextBox(*h, len, &textrect, teFlushDefault);
	HUnlock(h);
    }
    EndUpdate(window);
}
Exemplo n.º 12
0
    void DataSerializer::Serialize<float>(const float& value)
    {
      const uint32_t& tmp = reinterpret_cast<const uint32_t&>(value);
      const uint16_t lo = LoWord(tmp);
      const uint16_t hi = HiWord(tmp);

      *this << HiByte(hi) << LoByte(hi) << HiByte(lo) << LoByte(lo);
    }
Exemplo n.º 13
0
 virtual void PopUp( wxWindow *WXUNUSED(win), int x, int y )
 {
     long menuResult = ::PopUpMenuSelect(m_osxMenu, y, x, 0) ;
     if ( HiWord(menuResult) != 0 )
     {
         MenuCommand macid;
         GetMenuItemCommandID( GetMenuHandle(HiWord(menuResult)) , LoWord(menuResult) , &macid );
         int id = wxMacCommandToId( macid );
         wxMenuItem* item = NULL ;
         wxMenu* realmenu ;
         item = m_peer->FindItem( id, &realmenu ) ;
         if ( item )
         {
             m_peer->HandleCommandProcess(item, NULL );
         }
     }
 }
Exemplo n.º 14
0
static pascal long WindowMaskProc(short varCode, WindowRef window, short message, long param)
{
#pragma unused( varCode ) 
	switch (message)
	{
	case kWindowMsgGetFeatures:
		*(OptionBits*) param = kWindowCanGetWindowRegion
		                       | kWindowDefSupportsColorGrafPort;
		return 1;
	case kWindowMsgGetRegion:
		{
			GetWindowRegionRec* rgnRec  = (GetWindowRegionRec*) param;
			switch (rgnRec->regionCode)
			{
			case kWindowTitleBarRgn:
			case kWindowTitleTextRgn:
			case kWindowCloseBoxRgn:
			case kWindowZoomBoxRgn:
			case kWindowDragRgn:
			case kWindowGrowRgn:
			case kWindowCollapseBoxRgn:
				SetEmptyRgn(rgnRec->winRgn);
				break;
			case kWindowStructureRgn:
			case kWindowContentRgn:
				getWindowContentRegion(window, rgnRec->winRgn);
				break;
			case kWindowUpdateRgn:
				break;
			case kWindowOpaqueRgn:
				SetEmptyRgn(rgnRec -> winRgn);
				break;
			default:
				return errWindowRegionCodeInvalid;
			}
			return noErr;
		}
	case kWindowMsgHitTest:
		{
			Point hitPoint;
			static RgnHandle tempRgn = nil;
			if (!tempRgn)
				tempRgn = NewRgn();
			SetPt(&hitPoint, LoWord(param), HiWord(param));//get the point clicked
			if (PtInRgn(hitPoint, getWindowContentRegion(window, tempRgn)))
				return wInContent;
			else
				return wNoHit;
		}
		break;
		
	default:
		break;
	}
	return 0;
}
Exemplo n.º 15
0
IPopupMenu* IGraphicsCarbon::CreateIPopupMenu(IPopupMenu* pMenu, IRECT* pAreaRect)
{
  // Get the plugin gui frame rect within the host's window
  HIRect rct;
  HIViewGetFrame(this->mView, &rct);

  // Get the host's window rect within the screen
  Rect wrct;
  GetWindowBounds(this->mWindow, kWindowContentRgn, &wrct);

  #ifdef RTAS_API
  int xpos = wrct.left + this->GetLeftOffset() + pAreaRect->L;
  int ypos = wrct.top + this->GetTopOffset() + pAreaRect->B + 5;
  #else
  HIViewRef contentView;
  HIViewFindByID(HIViewGetRoot(this->mWindow), kHIViewWindowContentID, &contentView);
  HIViewConvertRect(&rct, HIViewGetSuperview((HIViewRef)this->mView), contentView);

  int xpos = wrct.left + rct.origin.x + pAreaRect->L;
  int ypos = wrct.top + rct.origin.y + pAreaRect->B + 5;
  #endif

  MenuRef menuRef = CreateMenu(pMenu);

  if (menuRef)
  {
    int32_t popUpItem = 1;
    int32_t PopUpMenuItem = PopUpMenuSelect(menuRef, ypos, xpos, popUpItem);

    short result = LoWord(PopUpMenuItem) - 1;
    short menuIDResult = HiWord(PopUpMenuItem);
    IPopupMenu* resultMenu = 0;

    if (menuIDResult != 0)
    {
      MenuRef usedMenuRef = GetMenuHandle(menuIDResult);

      if (usedMenuRef)
      {
        if (GetMenuItemRefCon(usedMenuRef, 0, (URefCon*)&resultMenu) == noErr)
        {
          resultMenu->SetChosenItemIdx(result);
        }
      }
    }

    CFRelease(menuRef);

    return resultMenu;
  }
  else
  {
    return 0;
  }
}
Exemplo n.º 16
0
static void handlemenu (long codeword) {
	
	short idmenu, iditem;
	
	iditem = LoWord (codeword);
	
	idmenu = HiWord (codeword);
	
	if (SharedMenuHit (idmenu, iditem)) /*See Step #3*/	
		goto exit;
	
	switch (idmenu) {
	
		case applemenu: 
			switch (iditem) {
				
				case aboutitem:
					Alert (262, nil);
					
					break;
			
				default: {
					Str255 s;
					
					GetItem (happlemenu, iditem, s);
					
					OpenDeskAcc (s);
					
					break;
					}
				} /*switch*/
			
			break; /*apple menu*/

		case filemenu: 
			switch (iditem) {
				
				case quititem:
				
					flexitmainloop = true;
					
					break;
				} /*switch*/
			
			break; /*file menu*/
			
		} /*switching on which menu was invoked*/
		
	exit:
	
	HiliteMenu (0);
	} /*handlemenu*/
Exemplo n.º 17
0
void
dogrowwin (Point start, WindowPtr wp)
{
  Rect r;
  long newsize;

/* todo: find out what is normally done when there is no maximum size that needs to be enforced */
  SetRect (&r, ICONWIDTHUSED, ICONHEIGHTUSED, 32767, 32767);
  newsize = GrowWindow (wp, start, &r);
  SizeWindow (wp, LoWord (newsize), HiWord (newsize), true);
  InvalRect (&wp->portRect);
  straightenwindow (wp);
}
Exemplo n.º 18
0
static void mac_menucommand(long result)
{
    short menu, item;
    WindowPtr window;
#if !TARGET_API_MAC_CARBON
    Str255 da;
#endif

    menu = HiWord(result);
    item = LoWord(result);
    window = FrontWindow();
    /* Things which do the same whatever window we're in. */
    switch (menu) {
      case mApple:
        switch (item) {
          case iAbout:
	    mac_openabout();
            goto done;
#if !TARGET_API_MAC_CARBON
          default:
            GetMenuItemText(GetMenuHandle(mApple), item, da);
            OpenDeskAcc(da);
            goto done;
#endif
        }
        break;
      case mFile:
        switch (item) {
	  case iNew:
	    mac_newkey();
	    goto done;
          case iClose:
            mac_closewindow(window);
            goto done;
          case iQuit:
            cleanup_exit(0);
            goto done;
        }
        break;
    }
    /* If we get here, handling is up to window-specific code. */
    if (mac_wininfo(window)->menu != NULL)
	(*mac_wininfo(window)->menu)(window, menu, item);

  done:
    HiliteMenu(0);
}
Exemplo n.º 19
0
static void doMenu( long menuSelection )
{
	short whichMenu = HiWord(menuSelection);
	short whichMenuItem = LoWord(menuSelection);
	
	switch (whichMenu) {
	case kAppleMenuID:
		switch (whichMenuItem) {
		case kAppleMenuAbout:
			Alert(128, NULL);
			break;

		default:
			break;
		}
		break;

	case kFileMenuID:
		switch (whichMenuItem) {
		case kFileMenuQuit:
			gDone = true;
			break;
		}
		break;
	
	case kDemoMenuID:
		if (window) { DisposeWindow( window ); window = NULL; };
		switch (whichMenuItem) {
		case kDemoMenuDraw: DrawImage(); break;
		case kDemoMenuScaleRotate: ScaleAndRotate(); break;
		case kDemoMenuAlpha: AlphaComposite(); break;
		case kDemoMenuMoreInfo: GetMoreInfo(); break;
		case kDemoMenuMultipleImage: MultipleImage(); break;
		case kDemoMenuURLImage: ImageFromURL(); break;
		case kDemoMenuFiltersExport: FilterExport(); break;
		case kDemoMenuMovieImage: MovieToImage(); break;
		case kDemoMenuDeepImages: DeepImages(); break;
        case kDemoMenuDrawCMYK: DrawCMYK(); break;
        case kDemoMenuDrawUsingCGImage: DrawUsingCGImage(); break;
        case kDemoMenuExportFromCGBitmapContext: ExportFromCGBitmapContext(); break;
		default:
			break;
		} // switch
	}
	
	HiliteMenu(0);
}
int _handle_user_event( unsigned long ticks)
{
	EventRecord event;

	if( WaitNextEvent(everyEvent, &event, ticks, nil)){
		long      menuResult = 0;
		short     menuID, menuItem;
		WindowPtr window;
		Str255    daName;

		switch ( event.what ) {
		case mouseDown:
			if( FindWindow(event.where, &window) == inMenuBar)
				menuResult = MenuSelect(event.where);
			break;
		case keyDown:
			if( event.modifiers & cmdKey )
				menuResult = MenuKey((short)event.message & charCodeMask);
			break;
		case kHighLevelEvent:
			AEProcessAppleEvent(&event);
			break;
		}

		menuID = HiWord(menuResult);
		menuItem = LoWord(menuResult);
		switch ( menuID ) {
		case mFile:
			MLDone = MLAbort = 1;
			break;
		case mApple:
			switch ( menuItem ) {
			case iAbout:
				do_about_box();
				break;
			default:
				GetMenuItemText(GetMenuHandle(mApple), menuItem, daName);
				break;
			}
			HiliteMenu(0);
		}
	}
	return MLDone;
}
Exemplo n.º 21
0
long wait ()
{
  EventRecord event;
  WindowPtr window;
  MenuInfo **m;
  long r;
  Str255 tmp;
				/* wait for an event */
  WaitNextEvent (everyEvent,&event,(long) 6,NIL);
  switch (event.what) {		/* got one -- what is it? */
  case mouseDown:		/* mouse clicked */
    switch (FindWindow (event.where,&window)) {
    case inMenuBar:		/* menu bar item? */
				/* yes, interesting event? */	
      if (r = MenuSelect (event.where)) {
				/* round-about test for Apple menu */
	  if ((*(m = GetMHandle (HiWord (r))))->menuData[1] == appleMark) {
				/* get desk accessory name */ 
	  GetItem (m,LoWord (r),tmp);
	  OpenDeskAcc (tmp);	/* fire it up */
	  SetPort (window);	/* put us back at our window */
	}
	else SysBeep (60);	/* the fool forgot to disable it! */
      }
      HiliteMenu (0);		/* unhighlight it */
      break;
    case inContent:		/* some window was selected */
      if (window != FrontWindow ()) SelectWindow (window);
      break;
    default:			/* ignore all others */
      break;
    }
    break;
  case keyDown:			/* key hit - if COMMAND/. then punt */
    if ((event.modifiers & cmdKey) && (event.message & charCodeMask) == '.')
      return NIL;
    break;
  default:			/* ignore all others */
    break;
  }
  return T;			/* try wait test again */
}
Exemplo n.º 22
0
static SInt32 wxShapedMacWindowHitTest(WindowRef window,SInt32 param)
{
    /*------------------------------------------------------
        Determine the region of the window which was hit
    --------------------------------------------------------*/
    Point hitPoint;
    static RgnHandle tempRgn=nil;

    if(!tempRgn)
    	tempRgn=NewRgn();

    SetPt(&hitPoint,LoWord(param),HiWord(param));//get the point clicked

     //Mac OS 8.5 or later
    wxShapedMacWindowStructureRegion(window, tempRgn);
    if (PtInRgn(hitPoint, tempRgn)) //in window content region?
        return wInContent;

    return wNoHit;//no significant area was hit.
}
Exemplo n.º 23
0
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
}
Exemplo n.º 24
0
void nsNativeViewerApp::DispatchMenuItemWithoutWindow(PRInt32 menuResult)
{
    long menuID = HiWord(menuResult);
    long menuItem = LoWord(menuResult);
    switch (menuID)
    {
        case menu_Apple:
            switch (menuItem)
            {
                case cmd_About:
                    ::Alert(128, nil);
                    break;
                default:
                    Str255 daName;
                    GetMenuItemText(GetMenuHandle(menu_Apple), menuItem, daName);
                    #if !TARGET_CARBON
                    OpenDeskAcc(daName);
                    #endif
                    break;
            }
            break;

        case menu_File:
            
            switch (menuItem)
            {
                case cmd_New:
                    gTheApp->OpenWindow();
                    break;
                case cmd_Open:
                    nsBrowserWindow * newWindow;
                    gTheApp->OpenWindow((PRUint32)0, newWindow);
                    newWindow->DoFileOpen();
                    break;
                case cmd_Quit:
                    gTheApp->Exit();
                    break;
            }
            break;
        }
}
Exemplo n.º 25
0
Boolean InitAnimatedCursors( short acurID )
{
	register short i = 0;
	register short cursID;
	Boolean noErrFlag = 0;

	if ( gCursorList = (acurHandle) GetResource( 'acur',acurID ) ) 
	{
		/* Got it! */ 
		noErrFlag = 1;
		while ( (i < (*gCursorList)->numberOfFrames) && noErrFlag ) 
		{
			/* The id of the cursor is stored in the high word of the frame handle */ 
			cursID = (short) HiWord( (long) (*gCursorList)->frame[i] );
			(*gCursorList)->frame[i] = GetCursor( cursID );
			if ( (*gCursorList)->frame[i] )
				i++;								/* Get the next one */
			else
				noErrFlag = 0;						/* Couldn't find the cursor */
		}
	}
	
	if ( noErrFlag ) 
	{
		(*gCursorList)->whichFrame = 0;
	}
	else
	{
		/* Free up memory we won't use */
		if ( gCursorList )
		{
			(*gCursorList)->numberOfFrames = i;		/* These are all we managed to get */
			ReleaseAnimatedCursors();
		}
		gCursorList = NULL;
	}
	
	return noErrFlag;
}
Exemplo n.º 26
0
static void mac_event(EventRecord *event) {
    short part;
    WindowPtr window;

    switch (event->what) {
      case mouseDown:
	part = FindWindow(event->where, &window);
	switch (part) {
	  case inMenuBar:
	    mac_adjustmenus();
	    mac_menucommand(MenuSelect(event->where));
	    break;
#if !TARGET_API_MAC_CARBON
	  case inSysWindow:
	    SystemClick(event, window);
	    break;
#endif
	  case inContent:
	    if (window != FrontWindow())
	    	/* XXX: check for movable modal dboxes? */
		SelectWindow(window);
	    else
		mac_contentclick(window, event);
	    break;
	  case inGoAway:
	    if (TrackGoAway(window, event->where))
		mac_closewindow(window);
	    break;
	  case inDrag:
	    /* XXX: moveable modal check? */
#if TARGET_API_MAC_CARBON
	    {
		BitMap screenBits;

		GetQDGlobalsScreenBits(&screenBits);
		DragWindow(window, event->where, &screenBits.bounds);
	    }
#else
	    DragWindow(window, event->where, &qd.screenBits.bounds);
#endif
	    break;
	  case inGrow:
	    mac_growwindow(window, event);
	    break;
	  case inZoomIn:
	  case inZoomOut:
	    if (TrackBox(window, event->where, part))
		mac_zoomwindow(window, part);
	    break;
	}
	break;
      case keyDown:
      case autoKey:
        mac_keypress(event);
        break;
      case activateEvt:
	mac_activatewindow((WindowPtr)event->message, event);
        break;
      case updateEvt:
        mac_updatewindow((WindowPtr)event->message);
        break;
#if !TARGET_API_MAC_CARBON
      case diskEvt:
	if (HiWord(event->message) != noErr) {
	    Point pt;

	    SetPt(&pt, 120, 120);
	    DIBadMount(pt, event->message);
        }
        break;
#endif
      case osEvt:
	switch ((event->message & osEvtMessageMask) >> 24) {
	  case suspendResumeMessage:
	    mac_suspendresume(event);
	    break;
	}
	break;
      case kHighLevelEvent:
	AEProcessAppleEvent(event); /* errors? */
	break;
    }
}
Exemplo n.º 27
0
 void DataSerializer::Serialize<uint32_t>(const uint32_t& value)
 {
   Serialize(LoWord(value));
   Serialize(HiWord(value));
 }
Exemplo n.º 28
0
static void HandleMenuChoice(long wParam) {

	UINT	update;
	Str255	applname;
#if defined(SUPPORT_STATSAVE)
	UINT	num;
	char	ext[16];
#endif

	update = 0;
	switch(wParam) {
		case IDM_ABOUT:
			AboutDialogProc();
			break;

		case IDM_RESET:
			pccore_cfgupdate();
			pccore_reset();
			break;

		case IDM_CONFIGURE:
			ConfigDialogProc();
			break;

		case IDM_NEWDISK:
			dialog_newdisk();
			break;

		case IDM_FONT:
			dialog_font();
			break;

		case IDM_EXIT:
			np2running = FALSE;
			break;

		case IDM_FDD1OPEN:
			dialog_changefdd(0);
			break;

		case IDM_FDD1EJECT:
			diskdrv_setfdd(0, NULL, 0);
			break;

		case IDM_FDD2OPEN:
			dialog_changefdd(1);
			break;

		case IDM_FDD2EJECT:
			diskdrv_setfdd(1, NULL, 0);
			break;

		case IDM_FDD3OPEN:
			dialog_changefdd(2);
			break;

		case IDM_FDD3EJECT:
			diskdrv_setfdd(2, NULL, 0);
			break;

		case IDM_FDD4OPEN:
			dialog_changefdd(3);
			break;

		case IDM_FDD4EJECT:
			diskdrv_setfdd(3, NULL, 0);
			break;

		case IDM_SASI1OPEN:
			dialog_changehdd(0x00);
			break;

		case IDM_SASI1REMOVE:
			diskdrv_sethdd(0x00, NULL);
			break;

		case IDM_SASI2OPEN:
			dialog_changehdd(0x01);
			break;

		case IDM_SASI2REMOVE:
			diskdrv_sethdd(0x01, NULL);
			break;

		case IDM_SCSI0OPEN:
			dialog_changehdd(0x20);
			break;

		case IDM_SCSI0REMOVE:
			diskdrv_sethdd(0x20, NULL);
			break;

		case IDM_SCSI1OPEN:
			dialog_changehdd(0x21);
			break;

		case IDM_SCSI1REMOVE:
			diskdrv_sethdd(0x21, NULL);
			break;

		case IDM_SCSI2OPEN:
			dialog_changehdd(0x22);
			break;

		case IDM_SCSI2REMOVE:
			diskdrv_sethdd(0x22, NULL);
			break;

		case IDM_SCSI3OPEN:
			dialog_changehdd(0x23);
			break;

		case IDM_SCSI3REMOVE:
			diskdrv_sethdd(0x23, NULL);
			break;

		case IDM_ROLNORMAL:
			menu_setrotate(0);
			changescreen(scrnmode & (~SCRNMODE_ROTATEMASK));
			break;

		case IDM_ROLLEFT:
			menu_setrotate(1);
			changescreen((scrnmode & (~SCRNMODE_ROTATEMASK)) |
														SCRNMODE_ROTATELEFT);
			break;

		case IDM_ROLRIGHT:
			menu_setrotate(2);
			changescreen((scrnmode & (~SCRNMODE_ROTATEMASK)) |
														SCRNMODE_ROTATERIGHT);
			break;

		case IDM_DISPSYNC:
			menu_setdispmode(np2cfg.DISPSYNC ^ 1);
			update |= SYS_UPDATECFG;
			break;

		case IDM_RASTER:
			menu_setraster(np2cfg.RASTER ^ 1);
			update |= SYS_UPDATECFG;
			break;

		case IDM_NOWAIT:
			menu_setwaitflg(np2oscfg.NOWAIT ^ 1);
			update |= SYS_UPDATECFG;
			break;

		case IDM_AUTOFPS:
			menu_setframe(0);
			update |= SYS_UPDATECFG;
			break;

		case IDM_60FPS:
			menu_setframe(1);
			update |= SYS_UPDATECFG;
			break;

		case IDM_30FPS:
			menu_setframe(2);
			update |= SYS_UPDATECFG;
			break;

		case IDM_20FPS:
			menu_setframe(3);
			update |= SYS_UPDATECFG;
			break;

		case IDM_15FPS:
			menu_setframe(4);
			update |= SYS_UPDATECFG;
			break;

		case IDM_SCREENOPT:
			dialog_scropt();
			break;

		case IDM_MOUSE:
			mousemng_toggle(MOUSEPROC_SYSTEM);
			menu_setmouse(np2oscfg.MOUSE_SW ^ 1);
			update |= SYS_UPDATECFG;
			break;

		case IDM_MIDIOPT:
			MPU98DialogProc();
			break;

		case IDM_MIDIPANIC:
			rs232c_midipanic();
			mpu98ii_midipanic();
			pc9861k_midipanic();
			break;

		case IDM_KEY:
			menu_setkey(0);
			keystat_resetjoykey();
			update |= SYS_UPDATECFG;
			break;

		case IDM_JOY1:
			menu_setkey(1);
			keystat_resetjoykey();
			update |= SYS_UPDATECFG;
			break;

		case IDM_JOY2:
			menu_setkey(2);
			keystat_resetjoykey();
			update |= SYS_UPDATECFG;
			break;

		case IDM_MOUSEKEY:
			menu_setkey(3);
			keystat_resetjoykey();
			update |= SYS_UPDATECFG;
			break;

		case IDM_XSHIFT:
			menu_setxshift(np2cfg.XSHIFT ^ 1);
			keystat_forcerelease(0x70);
			update |= SYS_UPDATECFG;
			break;

		case IDM_XCTRL:
			menu_setxshift(np2cfg.XSHIFT ^ 2);
			keystat_forcerelease(0x74);
			update |= SYS_UPDATECFG;
			break;

		case IDM_XGRPH:
			menu_setxshift(np2cfg.XSHIFT ^ 4);
			keystat_forcerelease(0x73);
			update |= SYS_UPDATECFG;
			break;

		case IDM_F11KANA:
			menu_setf11key(0);
			mackbd_resetf11();
			update |= SYS_UPDATEOSCFG;
			break;

		case IDM_F11STOP:
			menu_setf11key(1);
			mackbd_resetf11();
			update |= SYS_UPDATEOSCFG;
			break;

		case IDM_F11NFER:
			menu_setf11key(3);
			mackbd_resetf11();
			update |= SYS_UPDATEOSCFG;
			break;

		case IDM_F11USER:
			menu_setf11key(4);
			mackbd_resetf11();
			update |= SYS_UPDATEOSCFG;
			break;

		case IDM_F12MOUSE:
			menu_setf12key(0);
			mackbd_resetf12();
			update |= SYS_UPDATEOSCFG;
			break;

		case IDM_F12COPY:
			menu_setf12key(1);
			mackbd_resetf12();
			update |= SYS_UPDATEOSCFG;
			break;

		case IDM_F12XFER:
			menu_setf12key(3);
			mackbd_resetf12();
			update |= SYS_UPDATEOSCFG;
			break;

		case IDM_F12USER:
			menu_setf12key(4);
			mackbd_resetf12();
			update |= SYS_UPDATEOSCFG;
			break;

		case IDM_BEEPOFF:
			menu_setbeepvol(0);
			beep_setvol(0);
			update |= SYS_UPDATECFG;
			break;

		case IDM_BEEPLOW:
			menu_setbeepvol(1);
			beep_setvol(1);
			update |= SYS_UPDATECFG;
			break;

		case IDM_BEEPMID:
			menu_setbeepvol(2);
			beep_setvol(2);
			update |= SYS_UPDATECFG;
			break;

		case IDM_BEEPHIGH:
			menu_setbeepvol(3);
			beep_setvol(3);
			update |= SYS_UPDATECFG;
			break;

		case IDM_NOSOUND:
			menu_setsound(0);
			update |= SYS_UPDATECFG;
			break;

		case IDM_PC9801_14:
			menu_setsound(0x01);
			update |= SYS_UPDATECFG;
			break;

		case IDM_PC9801_26K:
			menu_setsound(0x02);
			update |= SYS_UPDATECFG;
			break;

		case IDM_PC9801_86:
			menu_setsound(0x04);
			update |= SYS_UPDATECFG;
			break;

		case IDM_PC9801_26_86:
			menu_setsound(0x06);
			update |= SYS_UPDATECFG;
			break;

		case IDM_PC9801_86_CB:
			menu_setsound(0x14);
			update |= SYS_UPDATECFG;
			break;

		case IDM_PC9801_118:
			menu_setsound(0x08);
			update |= SYS_UPDATECFG;
			break;

		case IDM_SPEAKBOARD:
			menu_setsound(0x20);
			update |= SYS_UPDATECFG;
			break;

		case IDM_SPARKBOARD:
			menu_setsound(0x40);
			update |= SYS_UPDATECFG;
			break;

		case IDM_AMD98:
			menu_setsound(0x80);
			update |= SYS_UPDATECFG;
			break;

		case IDM_JASTSND:
			menu_setjastsnd(np2oscfg.jastsnd ^ 1);
			update |= SYS_UPDATEOSCFG;
			break;

		case IDM_SEEKSND:
			menu_setmotorflg(np2cfg.MOTOR ^ 1);
			update |= SYS_UPDATECFG;
			break;

		case IDM_MEM640:
			menu_setextmem(0);
			update |= SYS_UPDATECFG;
			break;

		case IDM_MEM16:
			menu_setextmem(1);
			update |= SYS_UPDATECFG;
			break;

		case IDM_MEM36:
			menu_setextmem(3);
			update |= SYS_UPDATECFG;
			break;

		case IDM_MEM76:
			menu_setextmem(7);
			update |= SYS_UPDATECFG;
			break;

		case IDM_MEM116:
			menu_setextmem(11);
			update |= SYS_UPDATECFG;
			break;

		case IDM_MEM136:
			menu_setextmem(13);
			update |= SYS_UPDATECFG;
			break;

		case IDM_BMPSAVE:
			dialog_writebmp();
			break;

		case IDM_CALENDAR:
			CalendarDialogProc();
			break;

		case IDM_DISPCLOCK:
			menu_setdispclk(np2oscfg.DISPCLK ^ 1);
			update |= SYS_UPDATECFG;
			break;

		case IDM_DISPFLAME:
			menu_setdispclk(np2oscfg.DISPCLK ^ 2);
			update |= SYS_UPDATECFG;
			break;

		case IDM_JOYX:
			menu_setbtnmode(np2cfg.BTN_MODE ^ 1);
			update |= SYS_UPDATECFG;
			break;

		case IDM_RAPID:
			menu_setbtnrapid(np2cfg.BTN_RAPID ^ 1);
			update |= SYS_UPDATECFG;
			break;

		case IDM_I286SAVE:
			debugsub_status();
			break;

		default:
			if (HiWord(wParam) == IDM_APPLE) {
				GetMenuItemText(GetMenuHandle(IDM_APPLE), 
											LoWord(wParam), applname);
#if !TARGET_API_MAC_CARBON
				(void)OpenDeskAcc(applname);
#endif
			}
#if defined(SUPPORT_STATSAVE)
			else if (HiWord(wParam) == IDM_STATSAVE) {
				num = LoWord(wParam);
				if ((num >= 1) && (num < (1 + 10))) {
					SPRINTF(ext, np2flagext, num - 1);
					flagsave(ext);
				}
				else if ((num >= 12) && (num < (12 + 10))) {
					SPRINTF(ext, np2flagext, num - 12);
					flagload(ext, TRUE);
				}
			}
#endif
			break;
	}
	sysmng_update(update);
	HiliteMenu(0);
}
Exemplo n.º 29
0
void 
TkMacHandleMenuSelect(
    long mResult,
    int optionKeyPressed)
{
    short theItem = LoWord(mResult);
    short theMenu = HiWord(mResult);
    Str255 name;
    Tk_Window tkwin;
    Window window;
    TkDisplay *dispPtr;

    if (mResult == 0) {
    	TkMacHandleTearoffMenu();
	TkMacClearMenubarActive();
	return;
    }

    switch (theMenu) {
	
	case kAppleMenu:
	    switch (theItem) {
		case kAppleAboutItem:
		    {
			Tcl_CmdInfo dummy;
			
			if (optionKeyPressed || gInterp == NULL ||
			    Tcl_GetCommandInfo(gInterp,
				    "tkAboutDialog", &dummy) == 0) {
			    TkAboutDlg();
			} else {
			    Tcl_Eval(gInterp, "tkAboutDialog");
			}
			break;
		    }
		default:
		    GetMenuItemText(tkAppleMenu, theItem, name);
		    HiliteMenu(0);
		    OpenDeskAcc(name);
		    return;
	    }
	    break;
	case kFileMenu:
	    switch (theItem) {
		case kSourceItem:
		    /* TODO: source script */
		    SourceDialog();
		    break;
		case kCloseItem:
		    /* Send close event */
		    if (TkMacHaveAppearance() >= 0x110) {
		        window = TkMacGetXWindow(FrontNonFloatingWindow());
		    } else {
		        window = TkMacGetXWindow(FrontWindow());
		    }
		    dispPtr = TkGetDisplayList();
		    tkwin = Tk_IdToWindow(dispPtr->display, window);
		    TkGenWMDestroyEvent(tkwin);
		    break;
		case kQuitItem:
		    /* Exit */
		    if (optionKeyPressed || gInterp == NULL) {
			Tcl_Exit(0);
		    } else {
			Tcl_Eval(gInterp, "exit");
		    }
		    break;
	    }
	    break;
	case kEditMenu:
	    /*
	     * This implementation just send keysyms
	     * the Tk thinks are associated with function keys that
	     * do Cut, Copy & Paste on a Sun keyboard.
	     */
	    GenerateEditEvent(theItem);
	    break;
	default:
	    TkMacDispatchMenuEvent(theMenu, theItem);
	    TkMacClearMenubarActive();
	    break;
    }

    /*
     * Finally we unhighlight the menu.
     */
    HiliteMenu(0);
} /* TkMacHandleMenuSelect */
Exemplo n.º 30
0
// --------------------------------------------------------------------------------------
static Boolean dialogFilter(EventRecord *event, DialogRef *theDialog, 
							DialogItemIndex *itemHit)
{
		/* See the comments for HandleKeyDown in PrefsWindow.c about why we're using 
		   virtual key codes instead of character codes. */
	Boolean eventHandled = false;
	char charCode, keyCode;
	
	switch (event->what)
	{
		case keyDown:	// handle key presses not handled by DialogSelect
		case autoKey:
			*theDialog = GetDialogFromWindow(FrontNonFloatingWindow());
			SetPortDialogPort(*theDialog);
			charCode = event->message & charCodeMask;
			keyCode = (event->message & keyCodeMask) >> 8;
			
			if ((event->modifiers & cmdKey) != 0)		// check to see if any menu commands 
			{					// were selected - this isn't necessarily handling the event
				UInt32 menuChoice;
				OSErr error;
				MenuCommand commandID;
				
				menuChoice = MenuEvent(event);
				error = GetMenuItemCommandID(GetMenuRef(HiWord(menuChoice)), 
												LoWord(menuChoice), &commandID);
				if (error == noErr)
				{
					if (commandID == 0)		// if the menu item chosen does not have a 
						commandID = (MenuCommand)menuChoice;	// command ID 
					HandleMenuChoice(commandID);				// (but they all should)
				}
			}
			
			if ( (keyCode == kEnterKeyCode) || (keyCode == kReturnKeyCode) || 
				(keyCode == kEscapeKeyCode) || 
				( ((event->modifiers & cmdKey) != 0) && (charCode == '.') ) )
			{
				ControlRef button;
				unsigned long finalTicks;
				
				if ( (keyCode == kEnterKeyCode) || (keyCode == kReturnKeyCode) )
				{
					GetDialogItemAsControl(*theDialog, kStdOkItemIndex, &button);
					*itemHit = kStdOkItemIndex;
				}
				else
				{
					GetDialogItemAsControl(*theDialog, kStdCancelItemIndex, &button);
					*itemHit = kStdCancelItemIndex;
				}
				
				HiliteControl(button, kControlButtonPart);
				Delay(8, &finalTicks);
				HiliteControl(button, kControlNoPart);
				eventHandled = true;
			}
	}
	
	return eventHandled;
}