Ejemplo n.º 1
0
int main(int argc, char **argv)
{
	if(SDL_Init(SDL_INIT_VIDEO) < 0)
		return 1;

	int videoflags = SDL_HWSURFACE | SDL_HWACCEL | SDL_FULLSCREEN | SDL_DOUBLEBUF;
	SDL_Surface * screen = OpenScreen(1024, 768, 32, videoflags);
	if(!screen)
		return 1;

	SDL_Event event;
	bool done = false;

	while(!done)
	{
		if(SDL_PollEvent(&event))
		{
			switch (event.type)
			{
				case SDL_KEYDOWN:
					if(event.key.keysym.sym == SDLK_LALT || event.key.keysym.sym == SDLK_TAB)
						break;
					if(event.key.keysym.sym == SDLK_RETURN)
					{
						videoflags ^= SDL_FULLSCREEN;
						screen = OpenScreen(screen->w, screen->h, screen->format->BitsPerPixel, videoflags);
						if(!screen)
							done = true;
						break;
					}
				case SDL_QUIT:
					done = true;
					break;
				default:
					break;
			}
		}
		else
		{
			Paint(screen);
			SDL_Flip(screen);
		}
	}
	SDL_FreeSurface(screen);
	SDL_Quit();
	return 0;
}
Ejemplo n.º 2
0
int main(int argc, char **argv) {

	OpenScreen();
	// SetOrientation

	int sw = ScreenWidth();
	int sh = ScreenHeight();
	fprintf(stderr, "[%ix%i]\n", sw, sh);

	if (sw >= 1200 || sh >= 1200) {
		cpar = &params[1];
	} else {
		cpar = &params[0];
	}

	cal_title_font = OpenFont(DEFAULTFONTB, cpar->tfontsize, 1);
	cal_month_font = OpenFont(DEFAULTFONTB, cpar->mfontsize, 1);
	cal_day_font = OpenFont(DEFAULTFONTB, cpar->dfontsize - (IsRTL() ? 2 : 0), 1);
	cal_date_font = OpenFont(DEFAULTFONT, cpar->dfontsize, 1);
	cal_date2_font = OpenFont(DEFAULTFONTB, cpar->dfontsize, 1);

 	CurTime=time(NULL);
 	CurDate=localtime(&CurTime);
 	if (year>CurDate->tm_year+1900)
 		step=-step;
 	FirstDay=MilleniumFirstDay;
 	while (year!=CurDate->tm_year+1900)
 		{
 		 if (year%4==0)
 		 	LongYear=1;
 		 	else
 		 	LongYear=0;
 		 if (LongYear && year%100==0 && year%400!=0)
 		 	LongYear=0;
 		 FirstDay=(FirstDay+365*(1-LongYear)+366*LongYear)%7;
 		 year+=step;
 		}
	InkViewMain(calendar_handler);
	return 0;

}
Ejemplo n.º 3
0
int main(int argc, char** argv)
{
        argc_main = argc;
        argv_main = argv;
	SplashColor paperColor;
	GooString* filename, *password;
	char* spwd;
	FILE* f = NULL;
	bookinfo* bi;
	char buf[1024];
	int i;

	mkdir(CACHEDIR, 0777);
	chmod(CACHEDIR, 0777);

	spwd = GetDeviceKey();

	if (setgid(102) != 0) fprintf(stderr, "warning: cannot set gid\n");
	if (setuid(102) != 0) fprintf(stderr, "warning: cannot set uid\n");

	if (spwd)
	{
		//fprintf(stderr, "password: %s\n", spwd);
		password = new GooString(spwd);
	}
	else
	{
		fprintf(stderr, "warning: cannot read password\n");
		password = NULL;
	}

	OpenScreen();

	signal(SIGFPE, sigfpe_handler);
	signal(SIGSEGV, sigsegv_handler);

	clock_left = GetThemeInt("panel.clockleft", 0);
	bmk_flag = GetResource("bmk_flag", NULL);

	if (argc < 2)
	{
		Message(ICON_WARNING, "PDF Viewer", "@Cant_open_file", 2000);
		return 0;
	}

	OriginalName = FileName = argv[1];
	bi = GetBookInfo(FileName);
	if (bi->title) book_title = strdup(bi->title);

	// read config file
	globalParams = new GlobalParams();

	globalParams->setEnableFreeType("yes");
	globalParams->setAntialias((char*)(ivstate.antialiasing ? "yes" : "no"));
	globalParams->setVectorAntialias("no");

	filename = new GooString(FileName);
	doc = new PDFDoc(filename, NULL, NULL);
	if (!doc->isOk())
	{
		int err = doc->getErrorCode();
		delete doc;
		if (err == 4)   // encrypted file
		{
			filename = new GooString(FileName);
			doc = new PDFDoc(filename, NULL, password);
			if (!doc->isOk())
			{
				delete doc;
				spwd = query_password();
				password = new GooString(spwd);
				filename = new GooString(FileName);
				doc = new PDFDoc(filename, NULL, password);
				if (!doc->isOk())
				{
					Message(ICON_WARNING, "PDF Viewer", "@Cant_open_file", 2000);
					return 0;
				}
			}
		}
		else
		{
			Message(ICON_WARNING, "PDF Viewer", "@Cant_open_file", 2000);
			return 0;
		}
	}

	npages = doc->getNumPages();
	paperColor[0] = 255;
	paperColor[1] = 255;
	paperColor[2] = 255;
	splashOut = new MySplashOutputDev(USE4 ? splashModeMono4 : splashModeMono8, 4, gFalse, paperColor);
	splashOut->startDoc(doc->getXRef());

	Outline* outline = doc->getOutline();
	if (outline && outline->getItems())
	{

		GooList* items = outline->getItems();
		if (items->getLength() == 1)
		{
			OutlineItem* first = (OutlineItem*)items->get(0);
			first->open();
			items = first->getKids();
			update_toc(items, 0);
			first->close();
		}
		else if (items->getLength() > 1)
		{
			update_toc(items, 0);
		}

	}

	DataFile = GetAssociatedFile(FileName, 0);
	f = fopen(DataFile, "rb");
	if (f == NULL || fread(&docstate, 1, sizeof(tdocstate), f) != sizeof(tdocstate) || docstate.magic != 0x9751)
	{
		docstate.magic = 0x9751;
		docstate.page = 1;
		docstate.offx = 0;
		docstate.offy = 0;
		docstate.scale = 100;
		docstate.rscale = 150;
		docstate.orient = 0;
		docstate.nbmk = 0;
	}
	if (f != NULL) fclose(f);

	cpage = docstate.page;
	subpage = docstate.subpage;
	offx = docstate.offx;
	offy = docstate.offy;
	if (docstate.scale == 0)
	{
		scale = get_fit_scale();
		ScaleZoomType = ZoomTypeFitWidth;
	}
	else
	{
		scale = docstate.scale;
	}
	rscale = docstate.rscale;
	reflow_mode = (docstate.orient & 0x80) ? 1 : 0;

	gcfg = GetGlobalConfig();
//	ko = ReadInt(gcfg, "keeporient", 0);
	ko = -1;
	if (GetGlobalOrientation() == -1 || ko == 0)
	{
		orient = GetOrientation();
	}
	else
	{
		orient = docstate.orient & 0x7f;
		SetOrientation(orient);
	}

	if (argc >= 3)
	{
		if (argv[2][0] == '=')
		{
#ifdef USESYNOPSIS
			long long position;
			TSynopsisItem::PositionToLong(argv[2] + 1, &position);
			cpage = position_to_page(position >> 40);
#else
//			cpage = atoi(position_to_page(argv[2] + 1));
			cpage = atoi(argv[2] + 1);
#endif
		}
		else
		{
Ejemplo n.º 4
0
int      __init_environment(void *  reserved){

#ifdef DEBUG_ME
    char    *cmdLineP = Command;
    if( cmdLineP[0] == '?' || ( cmdLineP[0] == '-' && cmdLineP[1] == 'h' ) ) {
        OutputToScreen( systemConsoleScreen, "Use -d[options]\r\n" );
        OutputToScreen( systemConsoleScreen, "  options are:\r\n" );
        OutputToScreen( systemConsoleScreen, "      b = initial break\r\n" );
        OutputToScreen( systemConsoleScreen, "      a = all\r\n" );
        OutputToScreen( systemConsoleScreen, "      t = threads\r\n" );
        OutputToScreen( systemConsoleScreen, "      d = debug regs\r\n" );
        OutputToScreen( systemConsoleScreen, "      e = events\r\n" );
        OutputToScreen( systemConsoleScreen, "      i = IO\r\n" );
        OutputToScreen( systemConsoleScreen, "      x = network events\r\n" );
        OutputToScreen( systemConsoleScreen, "      m = misc\r\n" );
        OutputToScreen( systemConsoleScreen, "      r = requests\r\n" );
        OutputToScreen( systemConsoleScreen, "      o = errors\r\n" );
        return( -1 );
    }
    if( cmdLineP[0] == '-' && lower( cmdLineP[1] ) == 'd' ) {
        DebugMode = 1;
        cmdLineP += 2;
        while( isalpha( *cmdLineP ) ) {
            switch( lower( *cmdLineP ) ) {
            case 'b':
                BreakPoint();
                break;
            case 'a':
                DebugClasses = -1;
                break;
            case 'r':
                DebugClasses |= D_REQ;
                break;
            case 'o':
                DebugClasses |= D_ERROR;
                break;
            case 't':
                DebugClasses |= D_THREAD;
                break;
            case 'd':
                DebugClasses |= D_DR;
                break;
            case 'e':
                DebugClasses |= D_EVENT;
                break;
            case 'i':
                DebugClasses |= D_IO;
                break;
            case 'x':
                DebugClasses |= D_NET;
                break;
            case 'm':
                DebugClasses |= D_MISC;
                break;
            }
            ++cmdLineP;
        }
        while( *cmdLineP == ' ' ) ++cmdLineP;
    }
#endif

    ScreenTag = AllocateResourceTag(
        MyNLMHandle,
        (BYTE *)"Debug server screens",
        ScreenSignature );
    AllocTag = AllocateResourceTag(
        MyNLMHandle,
        (BYTE *)"Debug server work area",
        AllocSignature );
    SemaphoreTag = AllocateResourceTag(
        MyNLMHandle,
        (BYTE *)"Debug server semaphores",
        SemaphoreSignature );
    ProcessTag = AllocateResourceTag(
        MyNLMHandle,
        (BYTE *)"Debug server processes",
        ProcessSignature );
    TimerTag = AllocateResourceTag(
        MyNLMHandle,
        (BYTE *)"Debugger time out",
        TimerSignature );
    InterruptTag = AllocateResourceTag(
        MyNLMHandle,
        (BYTE *)"Debugger interrupts",
        InterruptSignature );
    DebugTag = AllocateResourceTag(
        MyNLMHandle,
        (BYTE *)"WVIDEO Debugger",
        DebuggerSignature );
    BreakTag = AllocateResourceTag(
        MyNLMHandle,
        (BYTE *)"WVIDEO Break Points",
        BreakpointSignature );

    if( OpenScreen( TRP_The_WATCOM_Debugger, ScreenTag, &screenID ) != 0 ) {
        screenID = 0;
    }
    debugScreen = 0;

#ifdef DEBUG_ME
    if( DebugMode ) {
        if( OpenScreen( TRP_The_WATCOM_Debugger, ScreenTag, &debugScreen ) != 0 ) {
            debugScreen = 0;
        }
    }
#endif
    if( screenID == 0 || ( DebugMode && ( debugScreen == 0 ) ) ) {
        OutputToScreen( systemConsoleScreen, TRP_NLM_no_screen );
        OutputToScreen( systemConsoleScreen, "\r\n" );
    } else {
        EnableInputCursor( screenID );
    }
    return 0;
}