Exemplo n.º 1
0
/* Gets user clicked button */
DialogBoxButton Dialog::GetUserClick() {
	int x, y, oldX = 0, oldY = 0;
	while (1) {

		if (pWind->GetButtonState(LEFT_BUTTON, x, y) == BUTTON_UP) {

			if (IsButton(x, y) && !IsButton(oldX, oldY)) {

				if (x > UI.DialogMargin && x < UI.ButtonWidht + UI.DialogMargin) {
					pWind->DrawRectangle(UI.DialogMargin, UI.ButtonStartY, UI.DialogMargin + UI.ButtonWidht, UI.ButtonStartY + UI.ButtonHeight);
					pWind->DrawString(UI.DialogMargin + 34, UI.ButtonStartY + 5, "YES");
				}

				if (x > UI.ButtonWidht + 2 * UI.DialogMargin && x < 2 * UI.ButtonWidht + 2 * UI.DialogMargin) {
					pWind->DrawRectangle(2 * UI.DialogMargin + UI.ButtonWidht, UI.ButtonStartY, 2 * UI.DialogMargin + 2 * UI.ButtonWidht, UI.ButtonStartY + UI.ButtonHeight);
					if (mType == Type_A)
						pWind->DrawString(UI.ButtonWidht + 2 * UI.DialogMargin + 38, UI.ButtonStartY + 5, "NO");
					else
						pWind->DrawString(UI.ButtonWidht + 2 * UI.DialogMargin + 38, UI.ButtonStartY + 5, "OK");
				}

				if (x > 2 * UI.ButtonWidht + 3 * UI.DialogMargin && x < 3 * UI.ButtonWidht + 2 * UI.DialogMargin) {
					pWind->DrawRectangle(3 * UI.DialogMargin + 2 * UI.ButtonWidht, UI.ButtonStartY, 3 * UI.DialogMargin + 3 * UI.ButtonWidht, UI.ButtonStartY + UI.ButtonHeight);
					pWind->DrawString(2 * UI.ButtonWidht + 3 * UI.DialogMargin + 17, UI.ButtonStartY + 5, "CANCEL");
				}

			}

			else if (!IsButton(x, y) && IsButton(oldX, oldY)) {
				DrawDialog();
			}

			oldX = x;
			oldY = y;

		}
		else {

			if (IsButton(x, y)) {

				if (x > UI.DialogMargin && x < UI.ButtonWidht + UI.DialogMargin) {
					return YES;
				}

				if (x > UI.ButtonWidht + 2 * UI.DialogMargin && x < 2 * UI.ButtonWidht + 2 * UI.DialogMargin) {
					if (mType == Type_A)
						return NO;
					else
						return OK;
				}

				if (x > 2 * UI.ButtonWidht + 3 * UI.DialogMargin && x < 3 * UI.ButtonWidht + 2 * UI.DialogMargin) {
					return CANCEL;
				}

			}
		}
	}
}
Exemplo n.º 2
0
/* Constructor that initializes the user interface */
Dialog::Dialog(string s, DialogBoxType pType) {
	// Create and initialize the drawing window
	pWind = new window(UI.DialogWidth, UI.DialogHeight, UI.DialogStartX, UI.DialogStartY);
	pWind->SetWaitClose(false);
	mMsg = s;
	mType = pType;
	DrawDialog();
}
Exemplo n.º 3
0
void DoAbout()
{
DialogPtr ad;
EventRecord	e;

	ad=GetNewDialog(kAboutDlogID, nil, (DialogPtr)-1);
	DrawDialog(ad);
		
	while(!GetNextEvent(keyDownMask+mDownMask,&e)) ;
	DisposeDialog(ad);
}
Exemplo n.º 4
0
LRESULT CSet::DefWindowProc(UINT message, WPARAM wParam, LPARAM lParam) 
{
	LRESULT callBack = CDialog::DefWindowProc(message, wParam, lParam);
	if(!::IsWindow(m_hWnd))
    {
       return callBack ;
    }	
   if(message == WM_PAINT || message == WM_NCACTIVATE || message == WM_NOTIFY)
	{   
           DrawDialog();
    }	
	return callBack;	
}
static PyObject *
MacOS_splash(PyObject *self, PyObject *args)
{
    int resid = -1;
    static DialogPtr curdialog = NULL;
    DialogPtr olddialog;
    WindowRef theWindow;
    CGrafPtr thePort;
#if 0
    short xpos, ypos, width, height, swidth, sheight;
#endif

    if (!PyArg_ParseTuple(args, "|i", &resid))
        return NULL;
    olddialog = curdialog;
    curdialog = NULL;

    if ( resid != -1 ) {
        curdialog = GetNewDialog(resid, NULL, (WindowPtr)-1);
        if ( curdialog ) {
            theWindow = GetDialogWindow(curdialog);
            thePort = GetWindowPort(theWindow);
#if 0
            width = thePort->portRect.right - thePort->portRect.left;
            height = thePort->portRect.bottom - thePort->portRect.top;
            swidth = qd.screenBits.bounds.right - qd.screenBits.bounds.left;
            sheight = qd.screenBits.bounds.bottom - qd.screenBits.bounds.top - LMGetMBarHeight();
            xpos = (swidth-width)/2;
            ypos = (sheight-height)/5 + LMGetMBarHeight();
            MoveWindow(theWindow, xpos, ypos, 0);
            ShowWindow(theWindow);
#endif
            DrawDialog(curdialog);
        }
    }
    if (olddialog)
        DisposeDialog(olddialog);
    Py_INCREF(Py_None);
    return Py_None;
}
Exemplo n.º 6
0
/* showNetNumbers	- Show the current network numbers. */
void showNetNumbers( void)
{
	char		tmpout[256];			/* IP Number */

	DialogPtr	dptr;				/* dialog box pointer */
	short		scratchshort;
	int			tmp[4];				/* Integer copy of IP Number */
	unsigned char tmp2[4];

	if (TelInfo->ipModeless) {
		SelectWindow(TelInfo->ipModeless);
		return;
	}

	Mnetinit();						// RAB BetterTelnet 1.0fc4
	netgetip(tmp2);
	for(scratchshort=0; scratchshort<4; scratchshort++)
			tmp[scratchshort] = (int)tmp2[scratchshort];		/* Get integer numbers */

	sprintf(&tmpout[0],"IP Address:\r%d.%d.%d.%d",tmp[0],tmp[1],tmp[2],tmp[3]);
										/* create Human-readable numbers */


	c2pstr(tmpout);									/* BYU LSC */

//	RAB BetterTelnet 1.2 - we can't use ParamText() for modeless dialogs
//	ParamText(0L, (StringPtr)tmpout,0L,0L);				/* BYU LSC - Put Parms in Dlog */

	dptr = GetNewDialog(MyIPDLOG, NULL, kInFront);
	SetTEText(dptr, 1, (unsigned char *)tmpout);
	DrawDialog(dptr);							/* Display Dialog */
	TelInfo->ipModeless = dptr;

//	ModalDialog(NULL, &scratchshort);			/* Wait for a click */

//	DisposeDialog(dptr);
//	Alert(MyIPDLOG, 0L);
	AdjustMenus();
	DoTheMenuChecks();
}
Exemplo n.º 7
0
/** Show a confirm dialog. */
void ShowConfirmDialog(ClientNode *np, void (*action)(ClientNode*), ...)
{

    va_list ap;
    XSetWindowAttributes attrs;
    XSizeHints shints;
    Window window;
    char *str;
    int x;

    Assert(action);

    /* Only allow one dialog at a time. */
    if(dialog) {
        DestroyConfirmDialog();
    }

    dialog = Allocate(sizeof(DialogType));
    dialog->client = np ? np->window : None;
    dialog->action = action;
    dialog->buttonState = DBS_NORMAL;

    /* Get the number of lines. */
    va_start(ap, action);
    for(dialog->lineCount = 0; va_arg(ap, char*); dialog->lineCount++);
    va_end(ap);

    dialog->message = Allocate(dialog->lineCount * sizeof(char*));
    va_start(ap, action);
    for(x = 0; x < dialog->lineCount; x++) {
        str = va_arg(ap, char*);
        dialog->message[x] = CopyString(str);
    }
    va_end(ap);

    ComputeDimensions(np);

    /* Create the pixmap used for rendering. */
    dialog->pmap = JXCreatePixmap(display, rootWindow,
                                  dialog->width, dialog->height,
                                  rootDepth);

    /* Create the window. */
    attrs.background_pixel = colors[COLOR_MENU_BG];
    attrs.event_mask = ButtonPressMask
                       | ButtonReleaseMask
                       | KeyPressMask
                       | ExposureMask;
    window = JXCreateWindow(display, rootWindow,
                            dialog->x, dialog->y,
                            dialog->width, dialog->height, 0,
                            CopyFromParent, InputOutput, CopyFromParent,
                            CWBackPixel | CWEventMask, &attrs);
    shints.x = dialog->x;
    shints.y = dialog->y;
    shints.flags = PPosition;
    JXSetWMNormalHints(display, window, &shints);
    JXStoreName(display, window, _("Confirm"));
    SetAtomAtom(window, ATOM_NET_WM_WINDOW_TYPE,
                ATOM_NET_WM_WINDOW_TYPE_DIALOG);

    /* Draw the dialog. */
    DrawDialog();

    /* Add the client and give it focus. */
    dialog->node = AddClientWindow(window, 0, 0);
    Assert(dialog->node);
    if(np) {
        dialog->node->owner = np->window;
    }
    dialog->node->state.status |= STAT_WMDIALOG;
    FocusClient(dialog->node);

    /* Grab the mouse. */
    JXGrabButton(display, AnyButton, AnyModifier, window, True,
                 ButtonReleaseMask, GrabModeAsync, GrabModeAsync, None, None);


}
Exemplo n.º 8
0
McoStatus ThermDialog::SetUpTherm(int therm_num)
{

    Rect 		r;
    Handle 		h;
    short 		itemType;
    short 		wi,hi;
    short		ids1[] = THERM_IDs_1;
    short		ids2[] = THERM_IDs_2;
    int 		i;
    Str255		theString;

    Quit = FALSE;

    //if (therm_num == 3)
    for (i=0; i<NUM_THERM_IDS; i++) ids[i] = ids2[i];
    //else for (i=0; i<NUM_THERM_IDS; i++) ids[i] = ids1[i];

    GetPort(&olddp);

    dt = (DialogTHndl) GetResource ('DLOG',ids[THERM_DLG]);

    if (! dt) return(MCO_RSRC_ERROR);

    HNoPurge ((Handle) dt);

    r = (**dt).boundsRect;


#define menuHeight 20

    wi = qd.screenBits.bounds.right;
    hi = qd.screenBits.bounds.bottom;

    OffsetRect (&r, -r.left, -r.top);
    OffsetRect (&r, (wi - r.right) / 2,
                (hi - r.bottom - menuHeight) / 3 + menuHeight);
    (**dt).boundsRect = r;

#undef menuHeight


    dp = GetNewDialog (ids[THERM_DLG], nil, (WindowPtr) -1);



    if (! dp)
    {
        HPurge ((Handle) dt);
        return(MCO_RSRC_ERROR);
    }

    GetDItem (dp,ids[THERM_TEXT], &itemType, &h, &r);
    GetIndString(theString,THERM_MESS,therm_num);
    SetIText(h,theString);

    SetPort(dp);

    ShowWindow(dp);
    DrawDialog(dp);

    box_d_item(dp,ids[THERM_BOX]);
    return MCO_SUCCESS;
}
Exemplo n.º 9
0
Boolean ThermDialog::DisplayTherm(int k,int maxk,unsigned char *st)
{

    Rect r;
    int	maxr;
    Handle h;
    short itemType;
    long 	temp;
    GrafPtr	tdp;
    WindowPtr   	window;
    short       	thePart;
    Rect        	screenRect, updateRect;
    Point			aPoint = {100, 100};
    Boolean 		QuitFlag = FALSE;
    short			item = 0;
    EventRecord 	event;
    short		the_part;
    DialogPtr 	hitdp;

    GetPort(&tdp);
    SetPort(dp);

    if (st != NULL)
    {
        GetDItem (dp,ids[THERM_TEXT], &itemType, &h, &r);
        SetIText(h,st);
    }


    GetDItem (dp, ids[THERM_BOX], &itemType, &h, &r);

    if (k == -1) k = old_k;
    if (maxk == -1) maxk = old_maxk;

    maxr = r.right;
    temp = ((long)k*((long)r.right - (long)r.left))/(long)maxk;
    r.right = r.left + temp;
    if (r.right>maxr) r.right=maxr;

    old_k = k;
    old_maxk = maxk;

    PenNormal ();
    PenPat(&qd.gray);
    PaintRect(&r);

    PenNormal ();

    SetPort(tdp);

    if (GetNextEvent(0xFFFF,&event))
    {
        if (event.what == mouseDown)
        {
            the_part = FindWindow(event.where, &window);
            if (IsDialogEvent(&event))
            {
                DialogSelect(&event,&hitdp,&item);
                if ((hitdp == dp) && (item == ids[THERM_CANCEL]))
                {
                    Quit = TRUE;
                    return FALSE;
                }
            }
            else switch (the_part) {
                case inSysWindow:
                    SystemClick (&event, window);
                    break;
                case inDrag:
                    screenRect = (**GetGrayRgn()).rgnBBox;
                    DragWindow( window, event.where, &screenRect );
                    break;
                }
        }
        else if (event.what == keyDown)
        {
            if ((event.modifiers & 0x0100) && ( (event.message) & charCodeMask == 0x02E))
            {
                Quit = TRUE;
                return FALSE;
            }
        }
        else if (event.what == updateEvt)
        {
            window = (WindowPtr)event.message;
            updateRect = (**(window->visRgn)).rgnBBox;
            SetPort( window ) ;
            BeginUpdate( window );
            DrawDialog( window );
            if (dp == window) box_d_item(dp,ids[THERM_BOX]);
            EndUpdate( window );
        }
    }
    if (Quit) return FALSE;
    return TRUE;
}
Exemplo n.º 10
0
void AppLocal::DrawEyeViewsPostDistorted( Matrix4f const & centerViewMatrix, const int numPresents )
{
	const float TEXT_SCALE = 1.0f;

	// update vr lib systems after the app frame, but before rendering anything
	GetGuiSys().Frame( this, vrFrame, GetVRMenuMgr(), GetDefaultFont(), GetMenuFontSurface() );
	GetGazeCursor().Frame( this->lastViewMatrix, vrFrame.DeltaSeconds );

	if ( ShowFPS )
	{
		static double  LastFrameTime = TimeInSeconds();
		static double  AccumulatedFrameInterval = 0.0;
		static int   NumAccumulatedFrames = 0;
		static float LastFrameRate = 60.0f;

		double currentFrameTime = TimeInSeconds();
		double frameInterval = currentFrameTime - LastFrameTime;
		AccumulatedFrameInterval += frameInterval;
		NumAccumulatedFrames++;
		if ( NumAccumulatedFrames > FPS_NUM_FRAMES_TO_AVERAGE ) {
			double interval = ( AccumulatedFrameInterval / NumAccumulatedFrames );  // averaged
			AccumulatedFrameInterval = 0.0;
			NumAccumulatedFrames = 0;
			LastFrameRate = 1.0f / float( interval > 0.000001 ? interval : 0.00001 );
		}    
		fontParms_t fontParms;
		fontParms.CenterHoriz = true;
		fontParms.Billboard = true;
        fontParms.TrackRoll = true;
		const Vector3f viewPos( GetViewMatrixPosition( centerViewMatrix ) );
		const Vector3f viewFwd( GetViewMatrixForward( centerViewMatrix ) );
		const Vector3f textPos( viewPos + viewFwd * 1.5f );
		GetWorldFontSurface().DrawTextBillboarded3Df( GetDefaultFont(), 
                fontParms, textPos, TEXT_SCALE, Vector4f( 1.0f, 0.0f, 0.0f, 1.0f ), "%.1f fps", LastFrameRate );
		LastFrameTime = currentFrameTime;
	}

	if ( InfoTextEndFrame >= vrFrame.FrameNumber )
	{
		fontParms_t fontParms;
		fontParms.CenterHoriz = true;
		fontParms.Billboard = true;
        fontParms.TrackRoll = true;
		const Vector3f viewPos( GetViewMatrixPosition( centerViewMatrix ) );
		const Vector3f viewFwd( GetViewMatrixForward( centerViewMatrix ) );
		const Vector3f textPos( viewPos + viewFwd * 1.5f );
		GetWorldFontSurface().DrawTextBillboarded3Df( GetDefaultFont(), 
                fontParms, textPos, TEXT_SCALE, Vector4f( 1.0f, 1.0f, 1.0f, 1.0f ), InfoText.ToCStr() );
	}

	GetMenuFontSurface().Finish( centerViewMatrix );
	GetWorldFontSurface().Finish( centerViewMatrix );
	GetVRMenuMgr().Finish( centerViewMatrix );

	// Increase the fov by about 10 degrees if we are not holding 60 fps so
	// there is less black pull-in at the edges.
	//
	// Doing this dynamically based just on time causes visible flickering at the
	// periphery when the fov is increased, so only do it if minimumVsyncs is set.
	const float fovDegrees = hmdInfo.SuggestedEyeFov +
			( ( ( SwapParms.MinimumVsyncs > 1 ) || ovr_GetPowerLevelStateThrottled() ) ? 10.0f : 0.0f ) +
			( ( !showVignette ) ? 5.0f : 0.0f );

	// DisplayMonoMode uses a single eye rendering for speed improvement
	// and / or high refresh rate double-scan hardware modes.
	const int numEyes = renderMonoMode ? 1 : 2;

	// Flush out and report any errors
	GL_CheckErrors("FrameStart");

	if ( drawCalibrationLines && calibrationLinesDrawn )
	{
		// doing a time warp test, don't generate new images
		LOG( "drawCalibrationLines && calibrationLinesDrawn" );
	}
	else
	{
		// possibly change the buffer parameters
		EyeTargets->BeginFrame( vrParms );

		for (int eye = 0; eye < numEyes; eye++)
		{
			EyeTargets->BeginRenderingEye( eye );

			// Call back to the app for drawing.
			const Matrix4f mvp = appInterface->DrawEyeView( eye, fovDegrees );

			DrawActivity( mvp );

			DrawPassThroughCamera( fovDegrees, vrFrame.PoseState.Pose.Orientation );

			GetVRMenuMgr().RenderSubmitted( mvp.Transposed() );
			GetMenuFontSurface().Render3D( GetDefaultFont(), mvp.Transposed() );
			GetWorldFontSurface().Render3D( GetDefaultFont(), mvp.Transposed() );

			glDisable( GL_DEPTH_TEST );
			glDisable( GL_CULL_FACE );

			// Optionally draw thick calibration lines into the texture,
			// which will be overlayed by the thinner origin cross when
			// distorted to the window.
			if ( drawCalibrationLines )
			{
				EyeDecorations.DrawEyeCalibrationLines(fovDegrees, eye);
				calibrationLinesDrawn = true;
			}
			else
			{
				calibrationLinesDrawn = false;
			}

			DrawDialog( mvp );

			GetGazeCursor().Render( eye, mvp );

			GetDebugLines().Render( mvp.Transposed() );

			if ( showVignette )
			{
				// Draw a thin vignette at the edges of the view so clamping will give black
				// This will not be reflected correctly in overlay planes.
				// EyeDecorations.DrawEyeVignette();

				EyeDecorations.FillEdge( vrParms.resolution, vrParms.resolution );
			}

			EyeTargets->EndRenderingEye( eye );
		}
	}

	// This eye set is complete, use it now.
	if ( numPresents > 0 )
	{
		const CompletedEyes eyes = EyeTargets->GetCompletedEyes();

		for ( int eye = 0 ; eye < TimeWarpParms::MAX_WARP_EYES ; eye++ )
		{
			SwapParms.Images[eye][0].TexCoordsFromTanAngles = TanAngleMatrixFromFov( fovDegrees );
			SwapParms.Images[eye][0].TexId = eyes.Textures[renderMonoMode ? 0 : eye ];
			SwapParms.Images[eye][0].Pose = SensorForNextWarp.Predicted;
		}

		ovr_WarpSwap( OvrMobile, &SwapParms );
	}
}
Exemplo n.º 11
0
void AppLocal::DrawEyeViewsPostDistorted( Matrix4f const & centerViewMatrix, const int numPresents )
{
	// update vr lib systems after the app frame, but before rendering anything
	GetGuiSys().Frame( this, vrFrame, GetVRMenuMgr(), GetDefaultFont(), GetMenuFontSurface(), centerViewMatrix );
	GetGazeCursor().Frame( centerViewMatrix, vrFrame.DeltaSeconds );

	GetMenuFontSurface().Finish( centerViewMatrix );
	GetWorldFontSurface().Finish( centerViewMatrix );
	GetVRMenuMgr().Finish( centerViewMatrix );

	// Increase the fov by about 10 degrees if we are not holding 60 fps so
	// there is less black pull-in at the edges.
	//
	// Doing this dynamically based just on time causes visible flickering at the
	// periphery when the fov is increased, so only do it if minimumVsyncs is set.
	const float fovDegrees = hmdInfo.SuggestedEyeFov[0] +
			( ( ( SwapParms.MinimumVsyncs > 1 ) || ovr_GetPowerLevelStateThrottled() ) ? 10.0f : 0.0f ) +
			( ( !showVignette ) ? 5.0f : 0.0f );

	// DisplayMonoMode uses a single eye rendering for speed improvement
	// and / or high refresh rate double-scan hardware modes.
	const int numEyes = renderMonoMode ? 1 : 2;

	// Flush out and report any errors
	GL_CheckErrors("FrameStart");

	if ( drawCalibrationLines && calibrationLinesDrawn )
	{
		// doing a time warp test, don't generate new images
		LOG( "drawCalibrationLines && calibrationLinesDrawn" );
	}
	else
	{
		// possibly change the buffer parameters
		EyeTargets->BeginFrame( vrParms );

		for ( int eye = 0; eye < numEyes; eye++ )
		{
			EyeTargets->BeginRenderingEye( eye );

			// Call back to the app for drawing.
			const Matrix4f mvp = appInterface->DrawEyeView( eye, fovDegrees );

			GetVRMenuMgr().RenderSubmitted( mvp.Transposed(), centerViewMatrix );
			GetMenuFontSurface().Render3D( GetDefaultFont(), mvp.Transposed() );
			GetWorldFontSurface().Render3D( GetDefaultFont(), mvp.Transposed() );

			glDisable( GL_DEPTH_TEST );
			glDisable( GL_CULL_FACE );

			// Optionally draw thick calibration lines into the texture,
			// which will be overlayed by the thinner origin cross when
			// distorted to the window.
			if ( drawCalibrationLines )
			{
				EyeDecorations.DrawEyeCalibrationLines( fovDegrees, eye );
				calibrationLinesDrawn = true;
			}
			else
			{
				calibrationLinesDrawn = false;
			}

			DrawDialog( mvp );

			GetGazeCursor().Render( eye, mvp );

			GetDebugLines().Render( mvp.Transposed() );

			if ( showVignette )
			{
				// Draw a thin vignette at the edges of the view so clamping will give black
				// This will not be reflected correctly in overlay planes.
				// EyeDecorations.DrawEyeVignette();

				EyeDecorations.FillEdge( vrParms.resolution, vrParms.resolution );
			}

			EyeTargets->EndRenderingEye( eye );
		}
	}

	// This eye set is complete, use it now.
	if ( numPresents > 0 )
	{
		const CompletedEyes eyes = EyeTargets->GetCompletedEyes();

		for ( int eye = 0; eye < MAX_WARP_EYES; eye++ )
		{
			SwapParms.Images[eye][0].TexCoordsFromTanAngles = TanAngleMatrixFromFov( fovDegrees );
			SwapParms.Images[eye][0].TexId = eyes.Textures[renderMonoMode ? 0 : eye ];
			SwapParms.Images[eye][0].Pose = SensorForNextWarp.Predicted;
		}

		ovr_WarpSwap( OvrMobile, &SwapParms );
	}
}