Example #1
0
void CXInfoTip::OnTimer( UINT nIDEvent ) 
{
	HRGN	hRegion;
	CSize	WindowSize;
	CDC		*pDC;
	CPoint	ptCursor;

	switch (nIDEvent)
	{
	
	
	
	case timerShow:
		KillTimer(m_nTimer);

		pDC = GetDC();
		GetWindowRegion(pDC, &hRegion, &WindowSize);
		ReleaseDC(pDC);

		::SetWindowRgn(m_hWnd, hRegion, TRUE);

		SetWindowPos(&wndTop, m_ptOrigin.x - WindowSize.cx + CX_ROUNDED, m_ptOrigin.y - WindowSize.cy + CY_ROUNDED, WindowSize.cx, WindowSize.cy, SWP_NOACTIVATE | SWP_SHOWWINDOW);
		m_bPlaced = false;

		m_nTimer = SetTimer(timerHide, m_nAutohideDelay, NULL);
		break;
	
	
	
	case timerHide:
		GetCursorPos(&ptCursor);
		if (ptCursor != m_ptOrigin)
		{
			KillTimer(m_nTimer);
			ShowWindow(SW_HIDE);
		}

		break;

	
	
	
	case timerShowNAH:
		KillTimer(m_nTimer);

		pDC = GetDC();
		GetWindowRegion(pDC, &hRegion, &WindowSize);
		ReleaseDC(pDC);

		::SetWindowRgn(m_hWnd, hRegion, TRUE);

		SetWindowPos(&wndTop, m_ptOrigin.x - WindowSize.cx + CX_ROUNDED, m_ptOrigin.y - WindowSize.cy + CY_ROUNDED, WindowSize.cx, WindowSize.cy, SWP_NOACTIVATE | SWP_SHOWWINDOW);
		m_bPlaced = false;
		break;
	}

	CWnd::OnTimer(nIDEvent);
}                          
/////////////////////////////////////////////////////////////////////
// 
// CXInfoTip::OnPaint()
// 
// DESCRIPTION
//     
//		Paint the window
//
// RETURNS
//
//		[void]
//
/////////////////////////////////////////////////////////////////////
void CXInfoTip::OnPaint() 
{
	CPaintDC dc( this ); // device context for painting

	CRect	rc;
	CBrush	WindowBrush;
	CBrush	FrameBrush;
	CBrush	InnerFrameBrush;
	HRGN	hRegion;
	CRgn	*pRegion;
	CFont	*pSysFont;

	// Get the client rectangle
	GetClientRect(rc);

	// Create the brushes
	InnerFrameBrush.CreateSolidBrush(::GetSysColor(COLOR_SCROLLBAR));
	FrameBrush.CreateSolidBrush(::GetSysColor(COLOR_WINDOWTEXT));
	WindowBrush.CreateSolidBrush(::GetSysColor(COLOR_WINDOW));

	// Get the window region
	GetWindowRegion(&dc, &hRegion);
	pRegion = CRgn::FromHandle(hRegion);

	// Draw the frame
	dc.FillRgn(pRegion, &WindowBrush);
	dc.FrameRgn(pRegion, &InnerFrameBrush, 3, 3);
	dc.FrameRgn(pRegion, &FrameBrush, 1, 1);

	// Adjust the area for the icon
	rc.DeflateRect(CX_ROUNDED, CY_ROUNDED, 0, 0);
	if (m_hIcon != NULL)
		rc.left = rc.left + m_IconSize.cx + CX_ICON_MARGIN;
	
	// Set the font
	pSysFont = (CFont *)dc.SelectObject(m_pFont);
	// Draw the tip text	
	dc.SetBkMode( TRANSPARENT );
	dc.DrawText(m_szText, &rc, DT_TOP | DT_LEFT);

	// Draw the icon
	if (m_hIcon != NULL)
		DrawIconEx(dc.m_hDC, CX_ROUNDED, CY_ROUNDED, m_hIcon, m_IconSize.cx, m_IconSize.cy, 0, NULL, DI_NORMAL);

	// Clean up GDI
	::DeleteObject(hRegion);
	dc.SelectObject(pSysFont);

}
Example #3
0
// New doMyDeviceLoop, now works with multiple monitors
void doMyDeviceLoop()
{
	int				depth;
	Rect			gDeviceRect;
	Rect			intersectingRect;
	GDHandle		gDevice;
	//WindowRecord	*windowRec = (WindowRecord *)gWindow;
	WindowPtr		windowRec = gWindow;
	Rect			windowRect; //= (**windowRec->contRgn).rgnBBox;
	RgnHandle		rgnHandle = NewRgn();
	
	GetWindowRegion(windowRec, kWindowContentRgn, rgnHandle);
	GetRegionBounds(rgnHandle, &windowRect);

	// Get the handle to the first device in the list. 
	gDevice = GetDeviceList();

	// Loop through all the devices in the list. 
	while (gDevice != nil)
	{
		// Get the device's gdRect  */
		gDeviceRect = (**gDevice).gdRect;
		depth = (**(**gDevice).gdPMap).pixelSize;

		// Check if the app's window rect intersects the device's, and if it 
		// does, set the clip region's rect to the intersection, then DRAW! 
		if (SectRect( &windowRect, &gDeviceRect, &intersectingRect ))
		{
			// The intersectingRect is in global coords. Convert to local 
			GlobalToLocal((Point *)&intersectingRect.top);
			GlobalToLocal((Point *)&intersectingRect.bottom);

			ClipRect( &intersectingRect );
			doDraw( depth, &intersectingRect );
		}

		// Get the next device in the list. 
		gDevice = GetNextDevice( gDevice );
	}
	
	DisposeRgn(rgnHandle);
}
Example #4
0
MCRectangle MCStack::getwindowrect() const
{
    if (window == DNULL)
        return rect;
    
    MCRectangle t_rect;
    Rect t_winrect;
    RgnHandle t_rgn;
    t_rgn = NewRgn();
    GetWindowRegion((WindowRef)window->handle.window, kWindowStructureRgn, t_rgn);
    GetRegionBounds(t_rgn, &t_winrect);
    DisposeRgn(t_rgn);
    
    t_rect.x = t_winrect.left;
    t_rect.y = t_winrect.top;
    t_rect.width = t_winrect.right - t_winrect.left;
    t_rect.height = t_winrect.bottom - t_winrect.top;
    
    return t_rect;
}
Example #5
0
void CXInfoTip::OnPaint() 
{
	CPaintDC dc( this ); 

	CRect	rc;
	CBrush	WindowBrush;
	CBrush	FrameBrush;
	CBrush	InnerFrameBrush;
	HRGN	hRegion;
	CRgn	*pRegion;
	CFont	*pSysFont;

	
	GetClientRect(rc);

	
	InnerFrameBrush.CreateSolidBrush(::GetSysColor(COLOR_SCROLLBAR));
	FrameBrush.CreateSolidBrush(::GetSysColor(COLOR_WINDOWTEXT));
	WindowBrush.CreateSolidBrush(::GetSysColor(COLOR_WINDOW));

	
	GetWindowRegion(&dc, &hRegion);
	pRegion = CRgn::FromHandle(hRegion);

	
	dc.FillRgn(pRegion, &WindowBrush);
	dc.FrameRgn(pRegion, &InnerFrameBrush, 3, 3);
	dc.FrameRgn(pRegion, &FrameBrush, 1, 1);

	
	rc.DeflateRect(CX_ROUNDED, CY_ROUNDED, 0, 0);
	if (m_hIcon != NULL)
		rc.left = rc.left + m_IconSize.cx + CX_ICON_MARGIN;
	
	
	pSysFont = (CFont *)dc.SelectObject(&m_fntBold);
	
	dc.SetBkMode( TRANSPARENT );

	dc.DrawText (m_strCaption, &rc, DT_TOP | DT_LEFT);

	dc.SelectObject(m_pFont);

	CRect rc2 = rc;
	rc2.top += m_nCaptionHeight;
	dc.DrawText(m_szText, &rc2, DT_TOP | DT_LEFT);

	if (m_bShowDSA && m_bPlaced == false)
	{
		m_bPlaced = true;
		m_btnDSA.MoveWindow (rc.left, m_yDSA, m_cxDSA + 10 + 20, 20);
	}

	
	if (m_hIcon != NULL)
		DrawIconEx(dc.m_hDC, CX_ROUNDED, CY_ROUNDED, m_hIcon, m_IconSize.cx, m_IconSize.cy, 0, NULL, DI_NORMAL);

	
	::DeleteObject(hRegion);
	dc.SelectObject(pSysFont);

}                                        
Example #6
0
void check_input_events()      {
  OSStatus err;
  EventTargetRef target;
  EventRef event;
  UInt32 event_class, event_kind;
  byte mac_keycode;
  UInt32 keycode;
  UInt32 modifiers;
  Point mouse_point, mouse_delta_point;
  WindowRef window_ref;
  int button, button_state;
  EventMouseButton mouse_button;
  int handled;
  int mouse_events;
  int is_up;
  int in_win;
  int ignore;

  if(g_quit_seen) {
    exit(0);
  }

  SetPortWindowPort(g_main_window);

  mouse_events = 0;
  target = GetEventDispatcherTarget();
  while(1) {
    err = ReceiveNextEvent(0, NULL, kEventDurationNoWait,
                           true, &event);

    if(err == eventLoopTimedOutErr) {
      break;
    }
    if(err != noErr) {
      printf("ReceiveNextEvent err: %d\n", (int)err);
      break;
    }

    event_class = GetEventClass(event);
    event_kind = GetEventKind(event);
    handled = 0;
    switch(event_class) {
      case kEventClassKeyboard:
        handled = 1;
        keycode = 0;
        modifiers = 0;
        GetEventParameter(event, kEventParamKeyMacCharCodes,
                          typeChar, NULL, sizeof(byte), NULL,
                          &mac_keycode);
        GetEventParameter(event, kEventParamKeyCode,
                          typeUInt32, NULL, sizeof(UInt32), NULL,
                          &keycode);
        GetEventParameter(event, kEventParamKeyModifiers,
                          typeUInt32, NULL, sizeof(UInt32), NULL,
                          &modifiers);

        mac_update_modifiers((word32)modifiers);

        // Key up/down event
        is_up = -1;
        switch(event_kind) {
          case kEventRawKeyDown:
            is_up = 0;
            //printf("key down: %02x, %08x\n",
            //	(int)mac_keycode, (int)keycode);
            break;
          case kEventRawKeyUp:
            is_up = 1;
            //printf("key up: %02x, %08x\n",
            //	(int)mac_keycode, (int)keycode);
            break;
          case kEventRawKeyModifiersChanged:
            is_up = -1;
            //printf("key xxx: %08x\n", (int)modifiers);
            break;
        }
        if(is_up >= 0) {
          adb_physical_key_update((int)keycode, is_up);
        }
        break;
      case kEventClassMouse:
        handled = 2;
        mouse_events++;
        GetEventParameter(event, kEventParamMouseLocation,
                          typeQDPoint, NULL, sizeof(Point), NULL,
                          &mouse_point);
        GetWindowRegion(g_main_window, kWindowContentRgn,
                        g_event_rgnhandle);
        in_win =  PtInRgn(mouse_point, g_event_rgnhandle);
        // in_win = 1 if it was in the contect region of window
        err = GetEventParameter(event, kEventParamMouseDelta,
                                typeQDPoint, NULL, sizeof(Point), NULL,
                                &mouse_delta_point);
        button = 0;
        button_state = -1;
        switch(event_kind) {
          case kEventMouseDown:
            button_state = 7;
            handled = 3;
            break;
          case kEventMouseUp:
            button_state = 0;
            handled = 3;
            break;
        }
        if(button_state >= 0) {
          GetEventParameter(event, kEventParamMouseButton,
                            typeMouseButton, NULL,
                            sizeof(EventMouseButton), NULL,
                            &mouse_button);
          button = mouse_button;
          if(button > 1) {
            button = 4 - button;
            button = 1 << button;
          }
          ignore = (button_state != 0) &&
                   (!in_win || g_ignore_next_click);
          ignore = ignore || !g_mainwin_active;
          if(ignore) {
            // Outside of A2 window, ignore clicks
            button = 0;
          }
          if(button_state == 0) {
            g_ignore_next_click = 0;
          }
        }

        GlobalToLocal(&mouse_point);

        if(g_warp_pointer) {
          if(err == 0) {
            g_mac_mouse_x += mouse_delta_point.h;
            g_mac_mouse_y += mouse_delta_point.v;
          }
          mac_warp_mouse();
        } else {
          g_mac_mouse_x = mouse_point.h -
                          g_video_act_margin_left;
          g_mac_mouse_y = mouse_point.v -
                          g_video_act_margin_top;
        }

#if 0
        printf("Mouse %d at: %d,%d button:%d, button_st:%d\n",
               mouse_events, g_mac_mouse_x, g_mac_mouse_y,
               button, button_state);
        printf("Mouse deltas: err:%d, %d,%d\n", (int)err,
               mouse_delta_point.h, mouse_delta_point.v);
#endif

        update_mouse(g_mac_mouse_x, g_mac_mouse_y,
                     button_state, button & 7);
        if(g_warp_pointer) {
          g_mac_mouse_x = A2_WINDOW_WIDTH/2;
          g_mac_mouse_y = A2_WINDOW_HEIGHT/2;
          update_mouse(g_mac_mouse_x, g_mac_mouse_y,0,-1);
        }
        break;
      case kEventClassApplication:
        switch(event_kind) {
          case kEventAppActivated:
            handled = 1;
            g_mainwin_active = 1;
            window_ref = 0;
            GetEventParameter(event, kEventParamWindowRef,
                              typeWindowRef, NULL, sizeof(WindowRef),
                              NULL, &window_ref);
            if(window_ref == g_main_window) {
              g_ignore_next_click = 1;
            }
            break;
          case kEventAppDeactivated:
            handled = 1;
            g_mainwin_active = 0;
            g_ignore_next_click = 1;
            break;
        }
        break;
    }
    //	show_event(event_class, event_kind, handled);
    if(handled != 1) {
      (void)SendEventToEventTarget(event, target);
    }
    ReleaseEvent(event);
  }

  return;
}
Example #7
0
void MCStack::realize()
{ //create window
	if (!MCnoui && MCModeMakeLocalWindows())
	{
		if ( getextendedstate(ECS_FULLSCREEN) )
		{
		//TS-2008-08-01 : [[Bug 5703 - fullscreen stack prop interacts badly with HideMenuBar]]
			if (!((MCScreenDC*)MCscreen)->getmenubarhidden())
				SetSystemUIMode(kUIModeAllHidden, kUIOptionAutoShowMenuBar);

			const MCDisplay *t_display;
			t_display = MCscreen -> getnearestdisplay(rect);
			MCRectangle t_workarea, t_viewport;
			t_workarea = t_display -> workarea;
			t_viewport = t_display -> viewport ;
			setrect(t_viewport);
		}
		else
		{
			if (!((MCScreenDC*)MCscreen)->getmenubarhidden())
				SetSystemUIMode(kUIModeNormal, NULL);
		}

		Rect wrect;
		MCScreenDC *psdc = (MCScreenDC *)MCscreen;
		psdc->MCRect2MacRect(rect, wrect);
		window = new _Drawable;
		window->type = DC_WINDOW;
		window->handle.window = 0;
		char *tmpname = NULL;
		const unsigned char *namePascal;
		if (!isunnamed())
		{ //set window title to name of stack temporarily.
			tmpname = strclone(getname_cstring()); //it will be changed by setname() later.
			namePascal = c2pstr(tmpname);
		}
		else
			namePascal = (unsigned char*)"\p";

		loadwindowshape();


		window->handle.window = NULL;
		uint32_t wclass;
		uint32_t wattributes;
		getWinstyle(wattributes,wclass);
		
		wattributes |= kWindowCompositingAttribute;

		long testdecorations = WD_TITLE | WD_MENU | WD_CLOSE | WD_MINIMIZE | WD_MAXIMIZE;

		if (m_window_shape != NULL)
		{
			static WindowDefUPP s_window_mask_proc = NULL;
			if (s_window_mask_proc == NULL)
				s_window_mask_proc = NewWindowDefUPP(WindowMaskProc);
			
			WindowDefSpec t_spec;
			t_spec . defType = kWindowDefProcPtr;
			t_spec . u . defProc = s_window_mask_proc;
			
			CreateCustomWindow(&t_spec, wclass, wattributes, &wrect, (WindowPtr *)&window -> handle . window);
			HIWindowChangeFeatures((WindowPtr)window -> handle . window, 0, kWindowIsOpaque);
		}
		else if (((flags & F_DECORATIONS && !(decorations & testdecorations))
		          || wclass == kPlainWindowClass))
		{
			static WindowDefUPP s_borderless_proc = NULL;
			if (s_borderless_proc == NULL)
				s_borderless_proc = NewWindowDefUPP(BorderlessWindowProc);
				
			WindowDefSpec t_spec;
			t_spec . defType = kWindowDefProcPtr;
			t_spec . u . defProc = s_borderless_proc;

			if (wclass == kPlainWindowClass)
				wclass = kUtilityWindowClass;

			CreateCustomWindow(&t_spec, wclass, wattributes, &wrect, (WindowPtr *)&window->handle.window);
		}
		else
			CreateNewWindow(wclass, wattributes,&wrect, (WindowPtr *)&window->handle.window);

		if (wclass == kFloatingWindowClass)
			ChangeWindowAttributes((WindowPtr)window -> handle . window, kWindowNoAttributes, kWindowHideOnSuspendAttribute);
		
		// MW-2009-10-31: Make sure we can collapse any rev window
		HIWindowChangeFeatures((WindowPtr)window -> handle . window, kWindowCanCollapse, 0);
		
		if (window->handle.window == NULL)
			SetWTitle((WindowPtr)window->handle.window, namePascal);
		SetWTitle((WindowPtr)window->handle.window, namePascal);
		setopacity(blendlevel * 255 / 100);
		SetWRefCon((WindowPtr)window->handle.window, mode);
		
		ControlRef t_control;
		MCRevolutionStackViewCreate(this, &t_control);
		ControlRef t_root_control;
		GetRootControl((WindowPtr)window -> handle . window, &t_root_control);
		HIViewAddSubview(t_root_control, t_control);
		ShowControl(t_control);
		
		if (wclass == kDrawerWindowClass)
		{
			Window pwindow = NULL;
			if (parentwindow != DNULL)
				pwindow = parentwindow;
			else
				if (MCdefaultstackptr && MCdefaultstackptr->getw() != DNULL )
					pwindow = MCdefaultstackptr->getw();
			if (pwindow && GetWRefCon((WindowPtr)pwindow->handle.window) != WM_DRAWER)
			{
				SetDrawerParent((WindowPtr)window->handle.window, (WindowPtr)pwindow->handle.window);
				WindowAttributes watt;
				GetWindowAttributes((WindowPtr)pwindow->handle.window,&watt);
				if (wattributes & kWindowResizableAttribute)
					ChangeWindowAttributes((WindowPtr)pwindow->handle.window, kWindowLiveResizeAttribute, 0);
				OptionBits draweredge;
				switch (wposition)
				{
				case WP_PARENTTOP:
					draweredge = kWindowEdgeTop;
					break;
				case WP_PARENTRIGHT:
					draweredge = kWindowEdgeRight;
					break;
				case WP_PARENTBOTTOM:
					draweredge = kWindowEdgeBottom;
					break;
				case WP_PARENTLEFT:
					draweredge = kWindowEdgeLeft;
					break;
				default:
					draweredge =  kWindowEdgeDefault;
					break;
				}
				SetDrawerPreferredEdge((WindowPtr)window->handle.window, draweredge);
				if (walignment)
				{
					MCRectangle parentwindowrect;
					MCscreen->getwindowgeometry(pwindow, parentwindowrect);
					int2 wspace = 0;
					RgnHandle r = NewRgn();
					GetWindowRegion((WindowPtr)window->handle.window, kWindowStructureRgn, r);
					Rect tRect;
					GetRegionBounds(r, &tRect);
					DisposeRgn(r);
					MCRectangle drawerwindowrect;
					psdc->MacRect2MCRect(tRect, drawerwindowrect);
					if (wposition == WP_PARENTTOP || wposition == WP_PARENTBOTTOM)
					{
						wspace = parentwindowrect.width - drawerwindowrect.width;
						if (watt & kWindowMetalAttribute)
							if (wspace)
								wspace += 10; //for metal
					}
					else
					{
						wspace = parentwindowrect.height - drawerwindowrect.height;
						if (watt & kWindowMetalAttribute)
							if (wspace)
								wspace += 5; //for metal
					}
					if (wspace > 0)
						switch (walignment)
						{
						case OP_CENTER:
							SetDrawerOffsets ((WindowPtr)window->handle.window,ceil(wspace/2) -1,floor(wspace/2) + 1);
							break;
						case OP_RIGHT:
						case OP_BOTTOM:
							SetDrawerOffsets ((WindowPtr)window->handle.window,wspace,0);
							break;
						case OP_TOP:
						case OP_LEFT:
							SetDrawerOffsets ((WindowPtr)window->handle.window,0,wspace);
							break;
						}
				}
			}
		}
		delete tmpname;


		// MW-2005-11-06: We also need to catch window constraining events so we can flush
		//   the screen geometry cache.
		EventTypeSpec list[] =
		{
		
			{kEventClassWindow, kEventWindowCollapsed},
			{kEventClassWindow, kEventWindowExpanded},
			{kEventClassMouse, kEventMouseWheelMoved},
			{kEventClassWindow, kEventWindowBoundsChanging},
			{kEventClassWindow, kEventWindowBoundsChanged},
			{kEventClassWindow, kEventWindowConstrain},
			{kEventClassWindow, kEventWindowFocusAcquired},
			{kEventClassWindow, kEventWindowFocusRelinquish},
			{kEventClassWindow, kEventWindowActivated},
			{kEventClassWindow, kEventWindowDeactivated},
			{kEventClassWindow, kEventWindowClose},
		};

		EventHandlerRef ref;
		
		// MW-2005-09-07: Pass the window handle as user data, otherwise 'takewindow' causes problems
		InstallWindowEventHandler((WindowPtr)window->handle.window, MCS_weh, sizeof(list) / sizeof(EventTypeSpec), list, (WindowPtr)window -> handle . window, &ref);
		
		ChangeWindowAttributes((WindowPtr)window->handle.window, 0, kWindowHideOnFullScreenAttribute);
		
		updatemodifiedmark();
	}
	start_externals();
}