CaWindow *CMainFrame::GetWin(int id)
{
	CaWindow *win=CPosFrame::GetWin(id);
	win = (win != NULL) ? win :CreateWin(id);

	return win;
}
Esempio n. 2
0
// setup progress window
// called from progress window's own thread
void ProgressWindow::init()
{
    RECT rect;
    int mx,my;
    const int PROGRESS_WINDOW_WIDTH=175;
    const int PROGRESS_WINDOW_HEIGHT=75;
    
    
    // Get Overview Window Location for Progress window alignment
    GetWindowRect(GetDesktopWindow(),&rect);
    
    // create prefs window
    int result;
    result=CreateWin(0, "Parbat3D Progress Bar Window", "Parbat3D Loading...",
        WS_POPUP+WS_CAPTION,
	    (rect.right-PROGRESS_WINDOW_WIDTH)/2, (rect.bottom-PROGRESS_WINDOW_HEIGHT)/2, //rect.left+50, rect.bottom-150,
        PROGRESS_WINDOW_WIDTH, PROGRESS_WINDOW_HEIGHT,
        mainWindow.GetHandle(), NULL);
    assert(result==true);
	   
    
   	// set the background colour
	HBRUSH backBrush=CreateSolidBrush(GetSysColor(COLOR_3DFACE));
    SetBackgroundBrush(backBrush);
    
    
    // create the progress bar
    hProgressBar = CreateWindowEx(0, PROGRESS_CLASS, (LPSTR) NULL, WS_CHILD | WS_VISIBLE,
                                  10, 10, 150, 25,
                                  GetHandle(), (HMENU) 0, Window::GetAppInstance(), NULL);
    
    // set initial values for the progress bar
    PostMessage(hProgressBar, PBM_SETRANGE, 0, MAKELPARAM(0, 100)); 
    PostMessage(hProgressBar, PBM_SETSTEP, (WPARAM) 1, 0);
    
    
    // create a cancel button to stop loading
//    cancelButton = CreateWindowEx(0, "BUTTON", "Cancel", WS_CHILD | WS_VISIBLE, 120,
//            85, 55, 25, GetHandle(), (HMENU) 1, Window::GetAppInstance(), NULL);		
    
    
    prevProc = SetWindowProcedure(&WindowProcedure);	
    
    // progress bar will stick to screen edges even without being added to the manager
    //stickyWindowManager.AddStickyWindow(this);  // make the window stick to others
    
    // create timer for auto incrementing
    SetTimer(GetHandle(),1,100,NULL);
    
    // turn off looping once the end is reached
    loop_at_end = false;
    
    return;	
}
Esempio n. 3
0
File: qplot.c Progetto: WndSks/msys
int
main(int argc, char **argv)
{
    char           *file = NULL;
    int             Do_Start = 1, tmp;
    int             m, p, i, j, n, nchars, theight, twidth, xclick, yclick;
    int             downx = 1000, downy = 1000, upx, upy;
    long            id, winclick;
    Real            xmax, xmin, ymax, ymin, xdiff, ydiff, xgrid_spacing,
		    ygrid_spacing;
    Real           *x, *y, *nls;
    LineFunction    linetype = StartLine;
    char            axis[100], line[256];
    FILE           *fd;

    x = (Real *)malloc(1000000 * sizeof(Real));
    y = (Real *)malloc(1000000 * sizeof(Real));
    nls = (Real *)malloc(1000 * sizeof(Real));
    if (x == NULL || y == NULL || nls == NULL) {
	fprintf(stderr, "Can't allocate initial memory\n");
	exit(1);
    }

    ymax = xmax = -HUGE_VAL;
    ymin = xmin = HUGE_VAL;

    for (i = 1; i < argc; i++) {
	if (*argv[i] == '-') {
	    if (!strcmp(argv[i], "-nl"))
		linetype = StartPoint;
	    else if (argv[i][1] == '\0')	/* use stdin */
		file = argv[i];
	    else {

		fprintf(stderr, "Usage:\n\t %s [options] [file]\n\n", argv[0]);
		fprintf(stderr,
			"where options include:\n"
			"  -pt                   plot with points instead of lines\n\n");

		fprintf(stderr,
			"file name `-' specifies stdin\n"
			"if no file name is specified, "
			"the default is \"%s\"\n\n", DEFAULT_DATA_FILE);

		return EXIT_FAILURE;
	    }
	} else
	    file = argv[i];
    }

    if (file && !strcmp(file, "-")) {
	fd = stdin;
	file = "stdin";
    } else {
	if (file == NULL)
	    file = DEFAULT_DATA_FILE;

	if ((fd = fopen(file, "r")) == NULL) {
	    fprintf(stderr, "%s: can't open file \"%s\"\n", argv[0], file);
	    return EXIT_FAILURE;
	}
    }
    m = 0;
    p = 0;
    while (fgets(line, sizeof(line), fd) != NULL) {
	if (sscanf(line, "%f %f", &x[m], &y[m]) == 2) {
	    if (x[m] > xmax)
		xmax = x[m];
	    else if (x[m] < xmin)
		xmin = x[m];
	    if (y[m] > ymax)
		ymax = y[m];
	    else if (y[m] < ymin)
		ymin = y[m];
	    m++;
	} else {
	    nls[p] = m;
	    p++;
	}
    }
    nls[p++] = m;

    if (m == 0)
	return;

    signal(SIGTERM, nice_end);
    signal(SIGSTOP, nice_end);
    signal(SIGTSTP, nice_end);
    signal(SIGINT, nice_end);
    signal(SIGQUIT, nice_end);
    if (!InitializeGraphics(1))
	return EXIT_FAILURE;

    n = 1;
    do {
	axis_round(&xmin, &xmax, &xgrid_spacing);
	axis_round(&ymin, &ymax, &ygrid_spacing);

	id = CreateWin(0, 0, GRX_SCALE, GRX_SCALE);
	if (id == 0) {
	    fprintf(stderr, "Help id = 0\n");
	    return EXIT_FAILURE;
	}
	/* Fill the window in black for real eye-catching graphics! */
	ForeColor(0);
	StartFill(id);
	FillArea(0, 0, GRX_SCALE, GRX_SCALE);
	Done();

	/* draw outline box in white */
	ForeColor(7);

	/* Draw outline box */
	StartLine(id);
	Extend(1000, 1000);
	Extend(1000, 9000);
	Extend(9000, 9000);
	Extend(9000, 1000);
	Extend(1000, 1000);
	Done();

	/* Draw the data - either lines or dots */
	xdiff = 8000 / (xmax - xmin);
	ydiff = 8000 / (ymax - ymin);

	for (i = j = 0; j < p; j++) {
	    int             n = 0;

	    ForeColor(j % 6 + 1);
	    while (((x[i] < xmin) || (x[i] > xmax) ||
		    (y[i] < ymin) || (y[i] > ymax)) && (i < nls[j]))
		i++;

	    while (i < nls[j]) {
		if (n == 0)
		    linetype(id);
		Extend(1000 + (x[i] - xmin) * xdiff,
		       9000 - (y[i] - ymin) * ydiff);
		n++;
		if (n > 450) {
		    Done();
		    n = 0;
		    continue;
		}
		i++;
		while ((i < nls[j]) &&
		       ((x[i] < xmin) || (x[i] > xmax) ||
			(y[i] < ymin) || (y[i] > ymax)))
		    i++;
	    }
	    if (n > 0)
		Done();
	}

	/* Do axis labels in black */
	ForeColor(7);
	QueryWin(id, &twidth, &theight);
	PlaceText(id, GRX_SCALE / 2, 0, HCENTER_TEXT | TOP_TEXT, file);
	PlaceText(id, GRX_SCALE / 2, GRX_SCALE, HCENTER_TEXT | BOTTOM_TEXT,
		  "X");
	PlaceText(id, 0, GRX_SCALE / 2, LEFT_TEXT | VCENTER_TEXT, "Y");
	sprintf(axis, "%f", ymax);
	nchars = 1000 / twidth;
	axis[nchars] = 0;
	PlaceText(id, GRX_SCALE / 10, GRX_SCALE / 10,
		  RIGHT_TEXT | TOP_TEXT, axis);
	sprintf(axis, "%f", ymin);
	axis[nchars] = 0;
	PlaceText(id, GRX_SCALE / 10, 9 * GRX_SCALE / 10,
		  RIGHT_TEXT | BOTTOM_TEXT, axis);
	sprintf(axis, "%f", xmax);
	PlaceText(id, 9 * GRX_SCALE / 10, 9 * GRX_SCALE / 10,
		  HCENTER_TEXT | TOP_TEXT, axis);
	sprintf(axis, "%f", xmin);
	PlaceText(id, GRX_SCALE / 10, 9 * GRX_SCALE / 10,
		  HCENTER_TEXT | TOP_TEXT, axis);
	fflush(stdout);

	do {
	    n = WaitForCarriageReturn(&winclick, &xclick, &yclick);
	    switch (n) {
	    case 1:
		downx = xclick;
		downy = yclick;
		break;
	    case 2:
		upx = xclick;
		upy = yclick;
		if (upx < downx) {
		    tmp = downx;
		    downx = upx;
		    upx = tmp;
		}
		if (upy < downy) {
		    tmp = downy;
		    downy = upy;
		    upy = tmp;
		}
		xmin = (xmax - xmin) * (downx - 1000) / (8000) + xmin;
		xmax = (xmax - xmin) * (upx - 1000) / (8000) + xmin;
		ymax = ymax - (ymax - ymin) * (downy - 1000) / (8000);
		ymin = ymax - (ymax - ymin) * (upy - 1000) / (8000);
		break;
	    }
	} while (n && (n != 2));
    } while (n);
    nice_end(EXIT_SUCCESS);
    return EXIT_SUCCESS;
}
void FloatLimitControlDlg::Init(HWND in_hParent)
{
	mHWnd = CreateWin(in_hParent);
}
Esempio n. 5
0
	// Init the device
	void Device::InitWindow(int width, int height)
	{
		this->width = width;
		this->height = height;

		Logger::Info("Device", "Init Windows (%d - %d)", width, height);

#ifdef WIN32

		windowHandler = CreateWin("OpenGLES Window", (int) (width * WINDOW_SCALE),  (int) (height * WINDOW_SCALE));

		EGLint attribList[] =
		{
			EGL_RED_SIZE,       5,
			EGL_GREEN_SIZE,     6,
			EGL_BLUE_SIZE,      5,
			EGL_ALPHA_SIZE,     EGL_DONT_CARE,
			EGL_DEPTH_SIZE,     8,
			EGL_STENCIL_SIZE,   EGL_DONT_CARE,
			EGL_SAMPLE_BUFFERS, 0,
			EGL_NONE
		};

		EGLint numConfigs;
		EGLint majorVersion;
		EGLint minorVersion;	
		EGLConfig config;
		EGLint contextAttribs[] = { EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NONE, EGL_NONE };

		// Get Display
		display = eglGetDisplay(GetDC(windowHandler));

		if ( display == EGL_NO_DISPLAY )
		{
			Logger::Error("OpenGLESDevice", "Couldn't Get Display");
			return;
		}

		// Initialize EGL
		if ( !eglInitialize(display, &majorVersion, &minorVersion) )
		{
			Logger::Error("OpenGLESDevice", "Couldn't Initialize Display");
			return;
		}

		// Get configs
		if ( !eglGetConfigs(display, NULL, 0, &numConfigs) )
		{
			Logger::Error("OpenGLESDevice", "Couldn't Get Config");
			return;
		}

		// Choose config
		if ( !eglChooseConfig(display, attribList, &config, 1, &numConfigs) )
		{
			Logger::Error("OpenGLESDevice", "Couldn't Choose Config");
			return;
		}

		// Create a surface
		surface = eglCreateWindowSurface(display, config, (EGLNativeWindowType) windowHandler, NULL);
		if ( surface == EGL_NO_SURFACE )
		{
			Logger::Error("OpenGLESDevice", "Couldn't Create Window Surface");
			return;
		}

		// Create a GL context
		context = eglCreateContext(display, config, EGL_NO_CONTEXT, contextAttribs );

		if ( context == EGL_NO_CONTEXT )
		{
			Logger::Error("OpenGLESDevice", "Couldn't Get Context");
			return;
		}   

		// Make the context current
		if ( !eglMakeCurrent(display, surface, surface, context) )
		{
			Logger::Error("OpenGLESDevice", "Couldn't Make Current Display");
			return;
		}
#endif // if WIN32

		graphics = new Graphics(width, height);
	}
Esempio n. 6
0
/* create main window */
int PrefsWindow::Create(HWND parent)
{
    RECT rect;
    int mx,my;
    const int PREFS_WINDOW_WIDTH=190;
    const int PREFS_WINDOW_HEIGHT=150;
   
    /* Get Overview Window Location for Prefs window alignment*/
    GetWindowRect(overviewWindow.GetHandle(),&rect);

    /* create prefs window */
    if (!CreateWin(0, "Parbat3D Prefs Window", "Preferences",
	     WS_POPUP+WS_SYSMENU+WS_CAPTION,
	     rect.left+50, rect.bottom-150, PREFS_WINDOW_WIDTH, PREFS_WINDOW_HEIGHT, parent, NULL))
	    return false;


	HBRUSH backBrush=CreateSolidBrush(GetSysColor(COLOR_3DFACE));
    SetBackgroundBrush(backBrush);

    cacheLabel =CreateWindowEx( 0, szStaticControl, "Cache size (MB):", 
		WS_CHILD | WS_CLIPSIBLINGS | WS_VISIBLE | SS_OWNERDRAW, 6,
		6, 120, 20, GetHandle(), NULL,
		GetAppInstance(), NULL);
	
	SetFont(cacheLabel, FONT_NORMAL);

	cacheEntry =CreateWindowEx( WS_EX_CLIENTEDGE, "EDIT", (settingsFile->getSetting("preferences", "cachesize")).c_str(), 
		WS_CHILD | WS_CLIPSIBLINGS | WS_VISIBLE | ES_LEFT | SS_OWNERDRAW, 138,
		6, 40, 20, GetHandle(), NULL,
		GetAppInstance(), NULL);

	SetFont(cacheEntry, FONT_NORMAL);

	texSizeLabel =CreateWindowEx( 0, szStaticControl, "Texture dimension (pixels):", 
		WS_CHILD | WS_CLIPSIBLINGS | WS_VISIBLE | SS_OWNERDRAW, 6,
		29, 130, 20, GetHandle(), NULL,
		GetAppInstance(), NULL);
	
	SetFont(texSizeLabel, FONT_NORMAL);

	texSizeEntry =CreateWindowEx( WS_EX_CLIENTEDGE, "EDIT", (settingsFile->getSetting("preferences", "texsize")).c_str(), 
		WS_CHILD | WS_CLIPSIBLINGS | WS_VISIBLE | ES_LEFT | SS_OWNERDRAW, 138,
		29, 40, 20, GetHandle(), NULL,
		GetAppInstance(), NULL);

	SetFont(texSizeEntry, FONT_NORMAL);
	
	displayCloseConfirmLabel =CreateWindowEx( 0, szStaticControl, "Display \'open file\' warning", 
		WS_CHILD | WS_CLIPSIBLINGS | WS_VISIBLE | SS_OWNERDRAW, 6,
		52, 130, 20, GetHandle(), NULL,
		GetAppInstance(), NULL);

	SetFont(displayCloseConfirmLabel, FONT_NORMAL);
	
	displayCloseConfirmCheckbox = CreateWindowEx( 0, "BUTTON", NULL,
        BS_AUTOCHECKBOX | WS_CHILD | WS_CLIPSIBLINGS | WS_VISIBLE, 138,
		52,	40, 20, GetHandle(), NULL,
        GetAppInstance(), NULL);
    
    if (settingsFile->getSettingi("preferences", "displayconfirmwindow", 1) == 1)
    {
		LRESULT theResult = SendMessage(displayCloseConfirmCheckbox, BM_SETCHECK, BST_CHECKED, 0);	
	}
	else
	{
		LRESULT theResult = SendMessage(displayCloseConfirmCheckbox, BM_SETCHECK, BST_UNCHECKED, 0);	
	}
	
	okButton = CreateWindowEx(0, "BUTTON", "OK", WS_CHILD | WS_VISIBLE, 60,
			85, 55, 25, GetHandle(), (HMENU) 1, Window::GetAppInstance(), NULL);

	SetFont(okButton, FONT_BOLD);
			
	cancelButton = CreateWindowEx(0, "BUTTON", "Cancel", WS_CHILD | WS_VISIBLE, 120,
			85, 55, 25, GetHandle(), (HMENU) 2, Window::GetAppInstance(), NULL);		

	SetFont(cancelButton, FONT_BOLD);

    prevProc=SetWindowProcedure(&WindowProcedure);	

    //stickyWindowManager.AddStickyWindow(this);  // make the window stick to others 

	return true;
}