Exemple #1
0
bool wxApp::Initialize(int& argc, wxChar **argv)
{
#ifdef __DJGPP__
    // VS: disable long filenames under DJGPP as the very first thing,
    //     since SciTech MGL doesn't like them much...
    wxSetEnv(wxT("LFN"), wxT("N"));
#endif

    // intialize MGL before creating wxFontsManager since it uses MGL funcs
    if ( MGL_init(".", NULL) == 0 )
    {
        wxLogError(_("Cannot initialize SciTech MGL!"));
        return false;
    }

    // must do it before calling wxAppBase::Initialize(), because fonts are
    // needed by stock lists which are created there
    wxTheFontsManager = new wxFontsManager;

    if ( !wxAppBase::Initialize(argc, argv) )
    {
        delete wxTheFontsManager;
        wxTheFontsManager = NULL;
        MGL_exit();
        return false;
    }

#if wxUSE_INTL
    wxFont::SetDefaultEncoding(wxLocale::GetSystemEncoding());
#endif

    return true;
}
Exemple #2
0
    void OnExit()
    {
        wxFontsManager::CleanUp();

        wxDestroyMGL_WM();
        MGL_exit();
    }
Exemple #3
0
ibool textDump(MGLDC *dc)
/****************************************************************************
*
* Function:     textDump
* Parameters:   dc  - Device context
*
* Description:  Displays all the characters in each of the fonts in
*               the distribution.
*
****************************************************************************/
{
	int         i,j,maxx;
	font_t      *font;
	char        buf[80];

	maxx = MGL_maxx();

    for (i = 0; i < NUM_FONTS; i++) {   /* For each available font      */
        /* Attempt to load the font file from disk. If it cannot be
         * found, then go onto the next one
		 */
		strcpy(buf,fontFilename[i]);
		font = MGL_loadFont(buf);
		err = MGL_result();
		if (err == grFontNotFound)
			continue;
		if ((err = MGL_result()) != grOK) {
            MGL_exit();
            exit(1);
			}
		if ((font->fontType & MGL_FONTTYPEMASK) == MGL_VECTORFONT)
			sprintf(buf,"Vector Font: '%s'", font->name);
		else
			sprintf(buf,"Bitmap Font: '%s' - %d Point", font->name, font->pointSize);
		mainWindow(dc,buf);

        /* Display all characters on the screen */
		MGL_useFont(font);
        buf[1] = '\0';
        for (j = ' '; j < 256; j++) {
			buf[0] = j;
            MGL_drawStr(buf);
			if (MGL_getX() + MGL_maxCharWidth() > maxx) {
				MGL_moveToCoord(0,MGL_getY() + MGL_textHeight());
				}
			}

		/* Unload the font from memory */
		MGL_unloadFont(font);
		MGL_useFont(defFont);
		if (!pause())
			return false;
		}

        defaultAttributes(dc);
	return true;
}
Exemple #4
0
int main(int argc, char **argv)
{
    XEvent   msg;
    XSetWindowAttributes xswa;
    XWMHints wmhints;
    Pixmap icon;
    const long evt_mask = ExposureMask | ButtonPressMask | ButtonReleaseMask | StructureNotifyMask | PointerMotionMask;

    dpy=XOpenDisplay(NULL);
    if (!dpy) {
        fprintf(stderr, "Could not open X11 display.\n");
        return 1;
        }

    scr = DefaultScreen(dpy);

    /* Create the main window and display it */
    wnd = XCreateSimpleWindow(dpy, RootWindow(dpy,scr), 0,0,400,400,0,
                              WhitePixel(dpy,scr), BlackPixel(dpy,scr));
    xswa.backing_store = Always;
    //  XChangeWindowAttributes(dpy, wnd, CWBackingStore, &xswa);

    if(!wnd){
        fprintf(stderr, "Window creation failed !\n");
        return 1;
        }

    XpmCreatePixmapFromData(dpy, wnd, mgldog_xpm, &icon, NULL, NULL);
    wmhints.icon_pixmap = icon;
    wmhints.flags = IconPixmapHint;
    XSetWMHints(dpy, wnd, &wmhints);

    /* Initialise the MGL */
    InitMGL();

    XSelectInput(dpy, wnd, evt_mask);
    XMapRaised(dpy,wnd);
    XStoreName(dpy,wnd,szAppName);
    XSync(dpy, false);


    MGL_bitBltCoord(winDC,memDC,0,0,sizex,sizey,0,0,MGL_REPLACE_MODE);
    /* Polling messages from event queue */
    for(;;) {
        XNextEvent(dpy, &msg);
        // XWindowEvent(dpy, wnd, evt_mask, &msg);
        ProcessEvent(wnd, &msg);
        }

    /* Clean up the MGL before exit */
    MGL_exit();
    XCloseDisplay(dpy);
    return 0;
}
Exemple #5
0
void wxApp::CleanUp()
{
    delete gs_rootWindow;

    wxAppBase::CleanUp();

    // must do this after calling base class CleanUp()
    delete wxTheFontsManager;
    wxTheFontsManager = (wxFontsManager*) NULL;

    wxDestroyMGL_WM();
    MGL_exit();
}
Exemple #6
0
/****************************************************************************
REMARKS:
Main program entry point
****************************************************************************/
int main(int argc,char *argv[])
{
    int status;

    /* Parse the command line */
    if (argc < 4)
        help();

    /* Register the ISV license file if desired */
#ifdef  ISV_LICENSE
    GA_registerLicense(OemLicense,false);
#endif

    /* Initialise the MGL */
    if (MGL_init("..\\..\\..\\",NULL) == 0)
        MGL_fatalError(MGL_errorMsg(MGL_result()));

    /* Do the conversion */
    status = ConvertBitmap(argv[1],argv[2],argv[3],argc > 4);

    /* Clean up and exit */
    MGL_exit();
    return status;
}
Exemple #7
0
int PASCAL WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR szCmdLine, int sw)
{
    MSG     msg;
    DWORD   lastTime,newTime;

    /* Detect if we have support for TrueColor */
    haveTrueColor = DetectTrueColor();

    /* Save instance handle for dialog boxes */
    hInstApp = hInst;

    if (!hPrev) {
        /* Register a class for the main application window */
        WNDCLASS cls;
        cls.hCursor        = LoadCursor(NULL,IDC_ARROW);
        cls.hIcon          = LoadIcon(hInst,"AppIcon");
        cls.lpszMenuName   = "AppMenu";
        cls.lpszClassName  = szAppName;
        cls.hbrBackground  = NULL;
        cls.hInstance      = hInst;
        cls.style          = CS_BYTEALIGNCLIENT | CS_VREDRAW | CS_HREDRAW | CS_DBLCLKS;
        cls.lpfnWndProc    = (LPVOID)AppWndProc;
        cls.cbWndExtra     = 0;
        cls.cbClsExtra     = 0;
        if (!RegisterClass(&cls))
            return FALSE;
        }

    /* Register the ISV license file if desired */
#ifdef  ISV_LICENSE
    GA_registerLicense(OemLicense,false);
#endif

    /* Initialise the MGL */
    InitMGL();

    /* Create the main window and display it */
    hwndApp = CreateWindow(szAppName,szAppName,WS_OVERLAPPEDWINDOW,
        CW_USEDEFAULT,0,400,400,NULL,NULL,hInst,NULL);
    ShowWindow(hwndApp,sw);
    CheckMenuItems(hwndApp);

    /* Polling messages from event queue */
    lastTime = timeGetTime();
    while (1) {
        if (PeekMessage(&msg, NULL, 0, 0,PM_REMOVE)) {
            if (msg.message == WM_QUIT)
                break;
            TranslateMessage(&msg);
            DispatchMessage(&msg);
            }
        else if (animatePalette) {
            newTime = timeGetTime();
            if ((newTime - lastTime) > 100) {
                int palsize;

                /* Rotate the hardware palette */
                palsize = MGL_getPaletteSize(winDC);
                MGL_rotatePalette(winDC,palsize-2,1,MGL_ROTATE_UP);
                MGL_realizePalette(winDC,palsize,0,true);
                lastTime = newTime;
                }
            }
        }

    /* Clean up the MGL before exit */
    MGL_exit();
    return msg.wParam;
}
Exemple #8
0
void wxApp::Exit()
{
    MGL_exit();
    exit(0);
}
Exemple #9
0
/****************************************************************************
REMARKS:
Main program entry point
****************************************************************************/
int main(void)
{
	MGLDC       	*dc,*memdc;
	event_t     	evt;
	pixel_format_t	pf;
	palette_t		pal[256];
	bitmap_t    	bmpHdr;

	/* Register the ISV license file if desired */
#ifdef	ISV_LICENSE
	GA_registerLicense(OemLicense,false);
#endif

	/* Start the MGL in 640x480 256 color mode */
	dc = MGL_quickInit(640,480,8,1);

	/* Now extract the information about the device surface to our
	 * global variables and draw on it. Note that we must check that we
	 * have direct access to the surface. If it is a bank switched
	 * surface then we cannot directly write to it, and the surface
	 * pointer will be NULL.
     *
     * Note that the MGL fully supports virtualised framebuffer surfaces,
     * so in most cases it would be very rare to get a bank switched
     * surface (in fact since we did not register the bank switched
     * drivers, it would be impossible in this sample program!).
     */
    if (MGL_surfaceAccessType(dc) == MGL_NO_ACCESS)
        MGL_fatalError("This program requires a linear access surface");
    maxx = dc->mi.xRes;
    maxy = dc->mi.yRes;
    bytesPerLine = dc->mi.bytesPerLine;
    surface = dc->surface;

    /* If we are drawing to a hardware accelerated surface, we must call
     * MGL_beginDirectAccess() and MGL_endDirectAccess() before and after
     * doing any direct surface access
     */
    if (MGL_getHardwareFlags(dc) != MGL_HW_NONE)
        MGL_beginDirectAccess();

    /* Now draw directly to display surface */
    moire();

    if (MGL_getHardwareFlags(dc) != MGL_HW_NONE)
        MGL_endDirectAccess();

    /* Wait for a keypress */
    EVT_halt(&evt,EVT_KEYDOWN);

	/* Now we allocate a system memory block for a 100x100 memory
     * surface manually and attach it to our bitmap header. Then we
     * will draw directly to it and then display it on our main device
     * context. Note that we allocate it without a palette and with
     * a pixel format info block.
     */
    bmpHdr.width = 320;
    bmpHdr.height = 240;
    bmpHdr.bitsPerPixel = 8;
    bmpHdr.bytesPerLine = bmpHdr.width;
    bmpHdr.pal = NULL;
    bmpHdr.pf = NULL;
    bmpHdr.surface = malloc(bmpHdr.bytesPerLine * bmpHdr.height);
    if (bmpHdr.surface == NULL)
        MGL_fatalError("Out of memory");
	maxx = bmpHdr.width-1;
	maxy = bmpHdr.height-1;
	bytesPerLine = bmpHdr.bytesPerLine;
	surface = bmpHdr.surface;
	memset(surface,0,bytesPerLine * (maxy+1));

	/* Now draw directly to bitmap surface and display it */
	moire();
	MGL_putBitmap(dc,160,120,&bmpHdr,MGL_REPLACE_MODE);

	/* Wait for a keypress */
	EVT_halt(&evt,EVT_KEYDOWN);

	/* Now we allocate a system memory device context and draw directly
	 * onto this surface, then blit it to the display. It is similar to
	 * the above code but does not use a lightweight bitmap as the drawing
	 * surface but a full memory device context (which you can also render
	 * to using the MGL functions).
	 */
	if ((memdc = MGL_createMemoryDC(160,120,8,&pf)) == NULL)
		MGL_fatalError(MGL_errorMsg(MGL_result()));
	maxx = memdc->mi.xRes;
	maxy = memdc->mi.yRes;
	bytesPerLine = memdc->mi.bytesPerLine;
	surface = memdc->surface;
	memset(surface,0,bytesPerLine * (maxy+1));

	/* Now set the palette for the memory device to the same as the display
	 * DC so that we avoid palette remapping (you could use a different
	 * palette and it would be automatically mapped to the screen when you
	 * do a blit, but this would be slower).
	 */
	MGL_getPalette(dc,pal,256,0);
	MGL_setPalette(memdc,pal,256,0);
	MGL_realizePalette(memdc,256,0,false);

	/* Now draw directly to bitmap surface and display it */
	moire();
	MGL_bitBltCoord(dc,memdc,0,0,160,120,240,180,MGL_REPLACE_MODE);

	/* Wait for a keypress */
	EVT_halt(&evt,EVT_KEYDOWN);

	MGL_exit();
	return 0;
}