예제 #1
0
파일: main.c 프로젝트: trongrg/TST-Tree
int main(int argc, char *args[])
{
	if (argc <= 1)
		DoQuery(FILENAME, NULL);
	else if (argc <= 4)
	{
#ifdef TST_NODE
		if (strcmp(args[1], "--display")==0){
			DisplayMode(args[2], args[3]);
		} else 
#endif
			if (strcmp(args[1], "--db")==0)
			DoQuery(args[2], NULL);
		else if (strcmp(args[1], "--q")==0)
			DoQuery(FILENAME, args[2]);
		else 
			HelpMode();
	}
	else
	{
#ifdef TST_NODE
		if (strcmp(args[1], "--display")==0){
			DisplayMode(args[2], args[3]);
		} else 
#endif
		if (strcmp(args[1], "--db")==0&&strcmp(args[3], "--q")==0)
			DoQuery(args[2], args[4]);
		else
			HelpMode();
	}
	return EXIT_SUCCESS;
}
void
TimeFormat::SetFromNode(DataNode *parentNode)
{
    if(parentNode == 0)
        return;

    DataNode *searchNode = parentNode->GetNode("TimeFormat");
    if(searchNode == 0)
        return;

    DataNode *node;
    if((node = searchNode->GetNode("displayMode")) != 0)
    {
        // Allow enums to be int or string in the config file
        if(node->GetNodeType() == INT_NODE)
        {
            int ival = node->AsInt();
            if(ival >= 0 && ival < 3)
                SetDisplayMode(DisplayMode(ival));
        }
        else if(node->GetNodeType() == STRING_NODE)
        {
            DisplayMode value;
            if(DisplayMode_FromString(node->AsString(), value))
                SetDisplayMode(value);
        }
    }
    if((node = searchNode->GetNode("precision")) != 0)
        SetPrecision(node->AsInt());
}
예제 #3
0
void ARXMenu_Private_Options_Video_SetResolution(bool fullscreen, int _iWidth, int _iHeight) {
	
	if(!GRenderer) {
		return;
	}
	
	config.video.resolution = Vec2i(_iWidth, _iHeight);
	
	if(!fullscreen) {
		if(config.video.resolution == Vec2i_ZERO) {
			LogInfo << "Configuring automatic fullscreen resolution selection";
		} else {
			LogInfo << "Configuring fullscreen resolution to " << DisplayMode(config.video.resolution);
		}
	}
	
	RenderWindow * window = mainApp->getWindow();
	
	if(window->isFullScreen() != fullscreen || fullscreen) {
		
		GRenderer->Clear(Renderer::ColorBuffer | Renderer::DepthBuffer);
		
		mainApp->getWindow()->showFrame();
		
		mainApp->setWindowSize(fullscreen);
		
	}
}
예제 #4
0
bool getAvailableDisplayModes(list<DisplayMode> * lstDisplayModes)
{
	Display * display;
	XF86VidModeModeInfo ** modes;
	int nbModes;

	display = XOpenDisplay(0);
	int screen = DefaultScreen(display);
	int bpp = XDefaultDepth(display, screen);
	XF86VidModeGetAllModeLines(display, screen, &nbModes, &modes);
	for (int i = 0; i < nbModes; i++) {
		// Check it's not already added
		bool skip = false;
		for (DisplayMode &mode : (*lstDisplayModes)) {
			if (mode.iWidth == modes[i]->hdisplay && mode.iHeight == modes[i]->vdisplay) {
				skip = true;
				break;
			}
		}
		if (!skip) {
			lstDisplayModes->push_back(DisplayMode(modes[i]->hdisplay, modes[i]->vdisplay, bpp));
		}
	}
	XFree(modes);
	return true;
}
예제 #5
0
void NcursesControl(Connection *conn, const char *file)
{
	int input;

	void mysighand(int signum) {
		if (signum == 2) {
			waddstr(body, "Catching SIGINT\nClosing DB\n");
			PREFRESH;
			DatabaseClose(conn);
			exit(1);
		}
	}

	signal(SIGINT, mysighand);

	// user input
	do {
		DisplayMode("Mode: Master");
		input = getchar();

		switch(input) {
			case '?':
				NcursesUsage();
				break;

			case 'c':
				NcursesConsole(conn, file);
				break;

			case 'e':
				RefreshdbList(conn);
				if (has_colors() == TRUE)
					wattron(body, A_REVERSE);
				PREFRESH;
				NcursesExamine(conn, file);
				break;

			case 'o':
				ReloadListing();
				touchwin(body);
				wrefresh(body);
				if (has_colors() == TRUE)
					wattron(body, A_REVERSE);
				mvwprintw(body, 0, 0, "%s", lsbuf[0]);
				PREFRESH;
				NcursesOtherdb(conn, file);
				break;

			case 'r':
				NcursesResize(conn, file);
				break;

			default:
				break;
		}	
	} while (input != 'q');
}
예제 #6
0
void ON_3dmObjectAttributes::SetMode( ON::object_mode m )
{
  int om = ON::ObjectMode(m);
  int dm = DisplayMode();
  m_mode = (unsigned char)(16*dm+om);

  // temporary
  m_bVisible = (om != ON::hidden_object);
}
예제 #7
0
void CWsWindow::StatusDump(TDes &aBuf)
	{
	_LIT(KStatusString1,"CWsWindow[0x%x]RWindow[0x%x,%d],Pos(%d,%d),Size(%d,%d)");
	_LIT(KStatusString3,",Mode=%d");
	_LIT(KStatusInvisible,",Inv");
	aBuf.AppendFormat(KStatusString1,this,iClientHandle,LogHandle(),iRel.iTl.iX,iRel.iTl.iY,Size().iWidth,Size().iHeight);
	TDisplayMode displayMode = DisplayMode();
	aBuf.AppendFormat(KStatusString3,(TInt&)displayMode);
	if (!IsVisible())
		aBuf.Append(KStatusInvisible);
	}
예제 #8
0
void NcursesUsage()
{
	DisplayMode("Mode: Usage");
	touchwin(border_usage);
	wrefresh(border_usage);
	touchwin(usage);
	wrefresh(usage);
	getch();
	PREFRESH;
	refresh();
}
예제 #9
0
TInt CDrawFourBppScreenBitmapGray::InitScreen()
	{
	TRect drawRect;
	GetDrawRect(drawRect);
    RWindows* window = ::WindowHandler(iScreenNo);
	window->iDisplayMode = DisplayMode();
	window->iEpocBitmapSize = drawRect.Size();
	window->iEpocBitmapLinePitch = (iScanLineWords*4);

	return KErrNone;
	}
예제 #10
0
std::vector<DisplayMode> cWindowSFML::GetDisplayModes() const {
	std::vector<DisplayMode> result;

	std::vector<sf::VideoMode> modes = sf::VideoMode::getFullscreenModes();

	for (std::size_t i = 0; i < modes.size(); ++i) {
		sf::VideoMode mode = modes[i];

		result.push_back( DisplayMode( mode.width, mode.height, 60, x ) );
	}

	return result;
}
예제 #11
0
		Display ( unsigned int index):
		index(index) {
			name = SDL_GetDisplayName(index);
			
			int numDisplayModes = SDL_GetNumDisplayModes(index);
			
			for (int i = 0; i < numDisplayModes; ++i) {
				SDL_DisplayMode displayMode;
				if (SDL_GetDisplayMode(index, i, &displayMode) != -1) {
					displayModes.push_back(DisplayMode(i, displayMode));
				}
			}
		}
예제 #12
0
void QtLayerWin32::Resize(int32 width, int32 height)
{
    DisplayMode currentMode = DisplayMode(width, height, 16, 0);

    KeyedArchive * options = Core::Instance()->GetOptions();
    if (options)
    {
        currentMode.bpp = options->GetInt32("bpp");
    }

    RenderManager::Instance()->ChangeDisplayMode(currentMode, false);
    RenderManager::Instance()->Init(currentMode.width, currentMode.height);
    UIControlSystem::Instance()->SetInputScreenAreaSize(currentMode.width, currentMode.height);
    Core::Instance()->SetPhysicalScreenSize(currentMode.width, currentMode.height);
}
예제 #13
0
void SDLWindow::setWindowSize(Vec2i size) {
	
	if(!isFullscreen_ && size == getSize()) {
		return;
	}
	
	if(!setMode(DisplayMode(size, 0), false)) {
		return;
	}
	
	if(isFullscreen_) {
		isFullscreen_ = false;
		updateSize(true);
		onToggleFullscreen();
	}
}
예제 #14
0
void SDLWindow::setFullscreenMode(Vec2i resolution, unsigned _depth) {
	
	if(isFullscreen_ && size_ == resolution && depth_ == _depth) {
		return;
	}
	
	if(!setMode(DisplayMode(resolution, depth_), true)) {
		return;
	}
	
	if(!isFullscreen_) {
		isFullscreen_ = true;
		updateSize(true);
		onToggleFullscreen();
	} else {
		updateSize(true);
	}
	
}
예제 #15
0
/*
-------------------------------------------------------------------------------
Creates the data members cache screen buffer
-------------------------------------------------------------------------------
*/
void CWazeCameraView::CreateCacheScreenBufferL()
{
    iCacheGcScreenBuffer = new (ELeave) CWsBitmap( iCoeEnv->WsSession() );
    TSize size = Rect().Size();

    TInt error = iCacheGcScreenBuffer->Create( size, DisplayMode() );
    User::LeaveIfError( error );

    iCacheGcScreenDevice = CFbsBitmapDevice::NewL( iCacheGcScreenBuffer );

    error = iCacheGcScreenDevice->CreateBitmapContext( iCacheGcScreenContext );
    User::LeaveIfError( error );
    
	iCacheGcScreenContext->SetBrushColor( KRgbBlack );
	iCacheGcScreenContext->Clear();

	iCacheGcDirty = EFalse;

	iCacheGcInitialized = ETrue;
}
/** Called on key release.
*/
void
CAChampionshipScreen::on_key_released (const CL_InputEvent &key, const CL_InputState &state) 
{
    switch( key.id ) 
    {
        // Activate:
        //
    case CL_KEY_ENTER:
    case CL_KEY_SPACE:
    case CL_KEY_ESCAPE:
        if (m_displayMode != DISPLAY_CHAMPIONSHIP)
        {
            int displayInt = int(m_displayMode) + 1;
            m_displayMode = DisplayMode(displayInt);
            if (m_displayMode == DISPLAY_CHAMPIONSHIP)
            {
                for (unsigned int pl=0; pl < m_player.size(); pl++)
                {
                    m_player[pl]->addMoney( m_player[pl]->getRaceMoney() );
                    m_player[pl]->setTotalPoints( m_player[pl]->getTotalPoints() + m_player[pl]->getRacePoints() );
                    m_player[pl]->resetForRace(0, NULL); // Player doesn't belong to a race for now    
                }
                // players points have changed so we sort the player list again
                std::sort(m_player.begin(), m_player.end(), RankPredicate());
            }
        }
        else
        {
            done = true;
        }
        break;

    default:
        break;
    }
}
예제 #17
0
	namespace KetaGraphics
	{
		const DisplayMode DisplayMode::RGBA = DisplayMode(GLUT_RGBA);
		const DisplayMode DisplayMode::RGB = DisplayMode(GLUT_RGB);
		const DisplayMode DisplayMode::Index = DisplayMode(GLUT_INDEX);
		const DisplayMode DisplayMode::Single = DisplayMode(GLUT_SINGLE);
		const DisplayMode DisplayMode::Double = DisplayMode(GLUT_DOUBLE);
		const DisplayMode DisplayMode::Accum = DisplayMode(GLUT_ACCUM);
		const DisplayMode DisplayMode::Alpha = DisplayMode(GLUT_ALPHA);
		const DisplayMode DisplayMode::Depth = DisplayMode(GLUT_DEPTH);
		const DisplayMode DisplayMode::Stencil = DisplayMode(GLUT_STENCIL);
		const DisplayMode DisplayMode::MultiSample = DisplayMode(GLUT_MULTISAMPLE);
		const DisplayMode DisplayMode::Stereo = DisplayMode(GLUT_STEREO);
		const DisplayMode DisplayMode::Luminance = DisplayMode(GLUT_LUMINANCE);

		DisplayMode::DisplayMode(int type)
			: value(type)
		{ }

		DisplayMode::operator int() const
		{
			return value;
		}

		DisplayMode &DisplayMode::operator=(const DisplayMode &mode)
		{
			this->value = mode.value;
			return *this;
		}
	}
예제 #18
0
	bool CoreWin32Platform::CreateWin32Window(HINSTANCE hInstance)
	{	
		this->hInstance = hInstance;

		//single instance check
		TCHAR fileName[MAX_PATH];
		GetModuleFileName(NULL, fileName, MAX_PATH);
		fileName[MAX_PATH-1] = 0; //string can be not null-terminated on winXP
		for(int32 i = 0; i < MAX_PATH; ++i)
		{
			if(fileName[i] == L'\\') //symbol \ is not allowed in CreateMutex mutex name
			{
				fileName[i] = ' ';
			}
		}
		hMutex = CreateMutex(NULL, FALSE, fileName);
		if(ERROR_ALREADY_EXISTS == GetLastError())
		{
			return false;
		}

		windowedMode = DisplayMode(800, 600, 16, 0);
		fullscreenMode = DisplayMode(800, 600, 16, 0);
		currentMode = windowedMode;
		isFullscreen = false;

		// create the window, only if we do not use the null device
		LPCWSTR className = L"DavaFrameworkWindowsDevice";

		// Register Class

		WNDCLASSEX wcex;
		wcex.cbSize = sizeof(WNDCLASSEX); 
		wcex.style			= CS_BYTEALIGNCLIENT | CS_HREDRAW | CS_VREDRAW;
		wcex.lpfnWndProc	= (WNDPROC)WndProc;
		wcex.cbClsExtra		= 0;
		wcex.cbWndExtra		= 0;
		wcex.hInstance		= hInstance;
		wcex.hIcon			= 0;
		wcex.hCursor		= LoadCursor(NULL, IDC_ARROW);
		wcex.hbrBackground	= (HBRUSH)(COLOR_WINDOW+1);
		wcex.lpszMenuName	= 0;
		wcex.lpszClassName	= className;
		wcex.hIconSm		= 0;

		RegisterClassEx(&wcex);

		// calculate client size

		RECT clientSize;
		clientSize.top = 0;
		clientSize.left = 0;
		clientSize.right = currentMode.width;
		clientSize.bottom = currentMode.height;

		ULONG style = WINDOWED_STYLE | WS_CLIPCHILDREN;

		// Create the rendering window
		if (isFullscreen)
		{
			style  = WS_VISIBLE | WS_POPUP;
		} // End if Fullscreen


		AdjustWindowRect(&clientSize, style, FALSE);

		int32 realWidth = clientSize.right - clientSize.left;
		int32 realHeight = clientSize.bottom - clientSize.top;

		int32 windowLeft = -10000;//(GetSystemMetrics(SM_CXSCREEN) - realWidth) / 2;
		int32 windowTop = -10000;//(GetSystemMetrics(SM_CYSCREEN) - realHeight) / 2;

		if (isFullscreen)
		{
			windowLeft = 0;
			windowTop = 0;
		}

		// create window
		hWindow = CreateWindow( className, L"", style, windowLeft, windowTop, 
			realWidth, realHeight,	NULL, NULL, hInstance, NULL);

		ShowWindow(hWindow, SW_SHOW);
		UpdateWindow(hWindow);

		// fix ugly ATI driver bugs. Thanks to ariaci (Taken from Irrlight).
		MoveWindow(hWindow, windowLeft, windowTop, realWidth, realHeight, TRUE);
	
#if defined(__DAVAENGINE_DIRECTX9__)
		RenderManager::Create(Core::RENDERER_DIRECTX9);
#elif defined(__DAVAENGINE_OPENGL__)
		RenderManager::Create(Core::RENDERER_OPENGL);
#endif
		RenderManager::Instance()->Create(hInstance, hWindow);

		FrameworkDidLaunched();
		KeyedArchive * options = Core::GetOptions();

		//fullscreenMode = GetCurrentDisplayMode();
		fullscreenMode = GetCurrentDisplayMode();//FindBestMode(fullscreenMode);
		if (options)
		{
			windowedMode.width = options->GetInt32("width");
			windowedMode.height = options->GetInt32("height");
			windowedMode.bpp = options->GetInt32("bpp");
			
			// get values from config in case if they are available
			fullscreenMode.width = options->GetInt32("fullscreen.width", fullscreenMode.width);
			fullscreenMode.height = options->GetInt32("fullscreen.height", fullscreenMode.height);
			fullscreenMode.bpp = windowedMode.bpp;

			fullscreenMode = FindBestMode(fullscreenMode);

			isFullscreen = (0 != options->GetInt32("fullscreen"));	
			String title = options->GetString("title", "[set application title using core options property 'title']");
			WideString titleW = StringToWString(title);
			SetWindowText(hWindow, titleW.c_str());
		}

		Logger::FrameworkDebug("[PlatformWin32] best display fullscreen mode matched: %d x %d x %d refreshRate: %d", fullscreenMode.width, fullscreenMode.height, fullscreenMode.bpp, fullscreenMode.refreshRate);

		currentMode = windowedMode;
		if (isFullscreen)
		{
			currentMode = fullscreenMode;
		}

		clientSize.top = 0;
		clientSize.left = 0;
		clientSize.right = currentMode.width;
		clientSize.bottom = currentMode.height;

		AdjustWindowRect(&clientSize, style, FALSE);

		realWidth = clientSize.right - clientSize.left;
		realHeight = clientSize.bottom - clientSize.top;

		windowLeft = (GetSystemMetrics(SM_CXSCREEN) - realWidth) / 2;
		windowTop = (GetSystemMetrics(SM_CYSCREEN) - realHeight) / 2;
		MoveWindow(hWindow, windowLeft, windowTop, realWidth, realHeight, TRUE);
	
        RAWINPUTDEVICE Rid;

        Rid.usUsagePage = 0x01; 
        Rid.usUsage = 0x02; 
        Rid.dwFlags = 0;
        Rid.hwndTarget = 0;

        RegisterRawInputDevices(&Rid, 1, sizeof(Rid));

		RenderManager::Instance()->ChangeDisplayMode(currentMode, isFullscreen);
		RenderManager::Instance()->Init(currentMode.width, currentMode.height);
		UIControlSystem::Instance()->SetInputScreenAreaSize(currentMode.width, currentMode.height);
		Core::Instance()->SetPhysicalScreenSize(currentMode.width, currentMode.height);

		return true;
	}
예제 #19
0
void NcursesExamine(Connection *conn, const char *file)
{
	int y = 0, down = 0, selection = 0; 
	int input;
	char examine_buf[MAX_DATA];
	char *arg1, *arg2;

	struct Information *rows = conn->core->db->rows;

	int *free_index = &(conn->core->cnf->free_index);
	int *delete_index = &(conn->core->cnf->delete_index);
	int *size = &(conn->core->cnf->size);

	mvwprintw(body, 0, 0, "%-2d %-10s %-10s", rows[0].index,
			rows[0].name, rows[0].phone);

	do {
		DisplayMode("Mode: Examine");
		/* debug
		   getyx(body, gety, getx);

		   mvprintw(maxy - 10, maxx - 30, 
		   "\ny = %d\nx = %d\ndown = %d\n", y, x, down);
		   mvprintw(maxy - 7, maxx - 30, 
		   "\ngety = %d\ngetx = %d\n", gety, getx);
		   mvprintw(maxy - 10, maxx - 30, 
		   "\ny = %d\nx = %d\ndown = %d\n", y, x, down);
		   refresh();
		 */

		PREFRESH_SCROLL;

		input = getchar();

		switch(input) {

			case 'a':
				touchwin(add);
				wrefresh(add);
				echo();
				wmove(add, 1, 1);
				wrefresh(add);
				wgetnstr(add, examine_buf, MAX_DATA);
				arg1 = strtok(examine_buf, " ");
				arg2 = strtok(NULL, " ");
				if ((arg1 == NULL) || (arg2 == NULL)) {
					DisplayError("name or phone is empty\n");
				} else {
					AddRecord(conn, &selection, arg1, arg2);
					DatabaseWrite(conn, file);
				}
				noecho();
				ClearLine(add);
				RefreshdbList(conn);
				break;

			case 'I':
				touchwin(add);
				wrefresh(add);
				echo();
				wmove(add, 1, 1);
				wrefresh(add);
				wgetnstr(add, examine_buf, MAX_DATA);
				arg1 = strtok(examine_buf, " ");
				arg2 = strtok(NULL, " ");
				if (arg1) {
					AddInsert(conn, &selection, arg1, arg2);
					DatabaseWrite(conn, file);
				}
				noecho();
				ClearLine(add);
				RefreshdbList(conn);
				break;

			case 'd':
				DeleteRecord(conn, &selection);
				DatabaseWrite(conn, file);
				RefreshdbList(conn);
				break;

			case 'D':
				DeleteInsert(conn, &selection);
				DatabaseWrite(conn, file);
				RefreshdbList(conn);
				break;

			case 'f':
				touchwin(find);
				wrefresh(find);
				echo();
				wmove(find, 1, 1);
				wrefresh(find);
				wgetnstr(find, examine_buf, MAX_DATA);
				arg1 = strtok(examine_buf, " ");
				if (arg1) {
					wmove(body, 0, 0);
					werase(body);
					DatabaseFind(conn, arg1, body);
					PREFRESH_SCROLL;
					getch();
				}
				noecho();
				ClearLine(find);
				RefreshdbList(conn);
				break;


				//case KEY_DOWN:
			case 'j':
				if (y != (maxy / 2) + 3) y++;
				wmove(body, y, 0);
				selection++;
				RefreshdbList(conn);
				if (y == (maxy / 2) + 3) down++;
				if (selection > (*size) - 1) {
					selection = 0;
					y = 0;
					down = 0;
				}
				ExamineSelection(&selection, conn);
				break;

				//case KEY_UP:
			case 'k':
				if (y != 0) y--;
				selection--;
				RefreshdbList(conn);
				if ((y == 0) && (down != 0)) down--;
				if (selection < 0) {
					selection = (*size) - 1;
					y = (*size) / 2;
					down = (*size) / 2;
				}
				ExamineSelection(&selection, conn);
				break;

			case 'r':
				touchwin(resize);
				wrefresh(resize);
				echo();
				wmove(resize, 1, 1);
				wrefresh(resize);
				wgetnstr(resize, examine_buf, MAX_DATA);
				arg1 = strtok(examine_buf, " ");
				if (arg1) {
					int i = atoi(arg1);
					if (i == *size) {
						DisplayError("database size is already that size\n");
					} else if (i <= *free_index || i <= (*delete_index) + 1) {
						DisplayError("cannot resize below valid records\n");
					} else {
						DatabaseResize(conn, &i);
						DatabaseWrite(conn, file);
					}
				}
				noecho();
				ClearLine(resize);
				RefreshdbList(conn);
				break;

			case 'A':
				DatabaseArrange(conn);
				DatabaseWrite(conn, file);
				RefreshdbList(conn);
				break;

			case 's':
				DatabaseSort(conn);
				DatabaseWrite(conn, file);
				RefreshdbList(conn);
				break;

			default:
				break;
		}

	} while (input != 'q');

	RefreshdbList(conn);
	PREFRESH_SCROLL;
}
예제 #20
0
void NcursesOtherdb(Connection *conn, const char *file)
{
	Connection *olddb, *newdb, *createdb;
	int y = 0, down = 0, selection = 0;
	int dbsize = 10;
	int signature, input;
	char action;
	char create_buf[MAX_DATA];
	char *arg1;
	FILE *checksig;

	olddb = conn;

	getyx(body, gety, getx);

	do {
		DisplayMode("Mode: Otherdb");
		/* debug
		   getyx(body, gety, getx);

		   mvprintw(maxy - 10, maxx - 30, 
		   "\ny = %d\nx = %d\ndown = %d\n", y, x, down);
		   mvprintw(maxy - 7, maxx - 30, 
		   "\ngety = %d\ngetx = %d\n", gety, getx);
		   mvprintw(maxy - 10, maxx - 30, 
		   "\ny = %d\nx = %d\ndown = %d\n", y, x, down);
		   refresh();
		 */

		prefresh(body, down, 0, 6, 2, (maxy  / 2) + 8, maxx - 3);
		input = getchar();

		switch(input) {

			case 'c':
				touchwin(create);
				wrefresh(create);
				echo();
				wmove(create, 1, 1);
				wrefresh(create);
				wgetnstr(create, create_buf, MAX_DATA);
				arg1 = strtok(create_buf, " ");

				action = 'c';

				createdb = DatabaseLoad(arg1, &action);
				DatabaseCreate(createdb, &dbsize);
				DatabaseWrite(createdb, arg1);
				DatabaseClose(createdb);

				conn = olddb;
				DisplayError("Database has been successfully created");

				noecho();
				ClearLine(create);
				ReloadListing();
				break;

			case 'e':

				checksig = fopen(lsbuf[selection], "r+");
				if (checksig == NULL) {
					DisplayError("ERROR 622: could not open file");
					break;
				}

				// check signature
				fread(&signature, sizeof(int), 1, checksig);
				if (signature != 53281) {
					DisplayError("ERROR 127: db file not weno");
					break;
				}

				DatabaseClose(conn);
				action = 'C';
				newdb = DatabaseLoad(lsbuf[selection], &action);
				DisplayError("Database has been successfully loaded, exit this mode");
				ReloadListing();
				break;

				//case KEY_DOWN:
			case 'j':
				if (y != (maxy / 2) + 3) y++;
				wmove(body, y, 0);
				selection++;
				ReloadListing();
				if (y == (maxy / 2) + 3) down++;
				if (selection > (lscount) - 1) {
					selection = 0;
					y = 0;
					down = 0;
				}
				OtherdbSelection(&selection);
				break;

				//case KEY_UP:
			case 'k':
				if (y != 0) y--;
				selection--;
				ReloadListing();
				if ((y == 0) && (down != 0)) down--;
				if (selection < 0) {
					selection = (lscount) - 1;
					y = (lscount + 1) / 2;
					down = (lscount) / 2;
				}
				OtherdbSelection(&selection);
				break;

			default:
				break;
		}
	} while (input != 'q');
	RefreshdbList(conn);
	touchwin(body);
	wrefresh(body);
	PREFRESH;
}
예제 #21
0
void SDLWindow::tick() {
	
	SDL_Event event;
	while(SDL_PollEvent(&event)) {
		
		switch(event.type) {
			
			case SDL_ACTIVEEVENT: {
				if(event.active.state & SDL_APPINPUTFOCUS) {
					// ignored
				}
				if(event.active.state & SDL_APPACTIVE) {
					if(event.active.gain) {
						onRestore();
					} else {
						onMinimize();
					}
				}
				if(input != NULL && (event.active.state & SDL_APPMOUSEFOCUS)) {
					input->onInputEvent(event);
				}
				break;
			}
			
			case SDL_KEYDOWN:
				
				// For some reason, release notes from SDL 1.2.12 says a SDL_QUIT message
				// should be sent when Command+Q is pressed on Mac OS or ALT-F4 on other platforms
				// but it doesn't look like it's working as expected...
#if ARX_PLATFORM == ARX_PLATFORM_MACOSX
				if(event.key.keysym.sym == SDLK_q
					&& (event.key.keysym.mod & KMOD_META) != KMOD_NONE) {
#else
				if(event.key.keysym.sym == SDLK_F4
					&& (event.key.keysym.mod & KMOD_ALT) != KMOD_NONE) {
#endif
					onDestroy();
					break;
				}
				
#if ARX_PLATFORM != ARX_PLATFORM_WIN32
				// The SDL X11 backend always grabs all keys when in fullscreen mode,
				// ufortunately breaking window manager shortcuts.
				// At least provide users with a way to switch to other windows.
				if(event.key.keysym.sym == SDLK_TAB
				   && (event.key.keysym.mod & KMOD_ALT) != KMOD_NONE) {
					SDL_WM_IconifyWindow();
				}
#endif
				
			case SDL_KEYUP:
			case SDL_MOUSEMOTION:
			case SDL_MOUSEBUTTONDOWN:
			case SDL_MOUSEBUTTONUP:
			case SDL_JOYAXISMOTION:
			case SDL_JOYBALLMOTION:
			case SDL_JOYHATMOTION:
			case SDL_JOYBUTTONDOWN:
			case SDL_JOYBUTTONUP: {
				if(input) {
					input->onInputEvent(event);
				}
				break;
			}
			
			case SDL_QUIT: {
				onDestroy();
				break;
			}
			
			case SDL_VIDEORESIZE: {
				Vec2i newSize(event.resize.w, event.resize.h);
				if(newSize != size_ && !isFullscreen_) {
					setMode(DisplayMode(newSize, depth_), false);
					updateSize(false);
				}
				break;
			}
			
			case SDL_VIDEOEXPOSE: {
				onPaint();
				break;
			}
			
		}
		
	}
	
}

Vec2i SDLWindow::getCursorPosition() const {
	int cursorPosX, cursorPosY;
	SDL_GetMouseState(&cursorPosX, &cursorPosY);
	return Vec2i(cursorPosX, cursorPosY);
}
예제 #22
0
void NcursesConsole(Connection *conn, const char *file)
{
	char console_buf[MAX_DATA];
	char *arg1, *arg2, *arg3, *arg4; 

	int *free_index = &(conn->core->cnf->free_index);
	int *delete_index = &(conn->core->cnf->delete_index);
	int *size = &(conn->core->cnf->size);

	wmove(console, 1, 1);
	touchwin(console);
	wrefresh(console);
	napms(100);
	wbkgd(border_console, COLOR_PAIR(5));
	touchwin(border_console);
	wrefresh(border_console);
	touchwin(console);
	wrefresh(console);
	echo();

	do {
		DisplayMode("Mode: Console");
		wmove(body, 0, 0);
		werase(body);
		DatabaseList(conn, body);
		PREFRESH;

		wgetnstr(console, console_buf, MAX_DATA);
		arg1 = strtok(console_buf, " ");
		arg2 = strtok(NULL, " ");
		arg3 = strtok(NULL, " ");
		arg4 = strtok(NULL, " ");

		ClearLine(console);

		if (arg1 != NULL) {

			if (strncmp(arg1, "add", 1) == 0) {
				if (arg4 == NULL) {
					if ((arg2 == NULL) || (arg3 == NULL)) {
						DisplayError("name or phone is empty\n");
					} else
						AddRecord(conn, NULL, arg2, arg3);
				} else {
					int i = atoi(arg2);
					if (i > *size || i < 0) {
						DisplayError("index out of bounds\n");
					} else {
						if ((arg3 == NULL) || (arg4 == NULL)) {
							DisplayError("name or phone is empty\n");
						} else {
							AddRecord(conn, &i, arg3, arg4);
						}
					}
				}
				DatabaseWrite(conn, file);
			}
			if (strncmp(arg1, "Insert", 1) == 0) {
				if (arg4 == NULL) {
					AddInsert(conn, NULL, arg2, arg3);
				} else {
					int i = atoi(arg2);
					if (i > *size || i < 0) {
						DisplayError("index out of bounds\n");
					} else {
						AddInsert(conn, &i, arg3, arg4);
					}
				}
				DatabaseWrite(conn, file);
			}
			if (strncmp(arg1, "delete", 1) == 0) {
				if (*free_index == 0 && *delete_index == 0) {
					DisplayError("database is already empty\n");
				} else if (arg2 == NULL) {
					DeleteRecord(conn, NULL);
				} else {
					int i = atoi(arg2);
					DeleteRecord(conn, &i);
				}
				DatabaseWrite(conn, file);
			}
			if (strncmp(arg1, "Delete", 1) == 0) {
				if (*free_index == 0 && *delete_index == 0) {
					DisplayError("database is already empty\n");
				} else if (arg2 == NULL) {
					DeleteInsert(conn, NULL);
				} else {
					int i = atoi(arg2);
					DeleteInsert(conn, &i);
				}
				DatabaseWrite(conn, file);
			}
			if (strncmp(arg1, "resize", 1) == 0) {
				int i = atoi(arg2);
				if (i == *size) {
					DisplayError("database size is already that size\n");
				} else if (i <= *free_index || i <= (*delete_index) + 1) {
					DisplayError("cannot resize below valid records\n");
				} else {
					DatabaseResize(conn, &i);
					DatabaseWrite(conn, file);
				}
			}
			if (strncmp(arg1, "Arrange", 1) == 0) {
				DatabaseArrange(conn);
				DatabaseWrite(conn, file);
			}
			if (strncmp(arg1, "sort", 1) == 0) {
				DatabaseSort(conn);
				DatabaseWrite(conn, file);
			}
			if (strncmp(arg1, "find", 1) == 0) {
				wmove(body, 0, 0);
				werase(body);
				DatabaseFind(conn, arg2, body);
				PREFRESH;
				getch();
			}
		} else
			break;
	} while (strncmp(arg1, "quit", 1) != 0);

	wbkgd(border_console, COLOR_PAIR(2));
	wrefresh(border_console);
	touchwin(console);
	wrefresh(console);
	noecho();
}
예제 #23
0
Graphics::DisplayMode IOSGraphics::getDesktopDisplayMode()
{
    return DisplayMode(0, 0,0,0);
};
예제 #24
0
bool SDLWindow::initialize(const std::string & title, Vec2i size, bool fullscreen,
                           unsigned depth) {
	
	arx_assert(!displayModes.empty());
	
	SDL_SetEventFilter(eventFilter);
	
	SDL_EventState(SDL_ACTIVEEVENT, SDL_ENABLE);
	SDL_EventState(SDL_QUIT, SDL_ENABLE);
	SDL_EventState(SDL_SYSWMEVENT, SDL_IGNORE);
	SDL_EventState(SDL_VIDEORESIZE, SDL_ENABLE);
	SDL_EventState(SDL_VIDEOEXPOSE, SDL_ENABLE);
	SDL_EventState(SDL_USEREVENT, SDL_IGNORE);
	
	SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
	SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 16);

	SDL_GL_SetAttribute(SDL_GL_SWAP_CONTROL, config.video.vsync ? 1 : 0);
	
	size_ = Vec2i_ZERO;
	depth_ = 0;
	
	for(int msaa = config.video.antialiasing ? 8 : 1; msaa >= 0; msaa--) {
		
		if(msaa > 1) {
			SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 1);
			SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, msaa);
		} else if(msaa > 0) {
			SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 0);
			SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, 0);
		} else {
			LogError << "Failed to initialize SDL Window: " << SDL_GetError();
			return false;
		}
		
		if(setMode(DisplayMode(size, fullscreen ? depth : 0), fullscreen)) {
			break;
		}
	}
	
	isFullscreen_ = fullscreen;
	
	SDL_WM_SetCaption(title.c_str(), title.c_str());
	title_ = title;
	
	SDL_ShowCursor(SDL_DISABLE);
	
	onCreate();
	
	renderer = new OpenGLRenderer;
	renderer->Initialize();
	
	updateSize(false);
	
	onShow(true);
	onFocus(true);
	
	onRendererInit();
	
	return true;
}
TimeFormat::DisplayMode
TimeFormat::GetDisplayMode() const
{
    return DisplayMode(displayMode);
}
예제 #26
0
TDisplayMode CWsWindow::SetRequiredDisplayModeL(TDisplayMode)
	{
	return DisplayMode();
	}
예제 #27
0
Graphics::DisplayMode GlfwGraphics::getDesktopDisplayMode ()
{
	//TODO:
	return DisplayMode(0, 0,0,0);
}
예제 #28
0
SDLWindowManager::SDLWindowManager(Application* application):
	WindowManager(application)
{
	if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK | SDL_INIT_GAMECONTROLLER) == -1)
	{
		throw RuntimeException("SDL initialization failed.");
	}

	int displayCount = SDL_GetNumVideoDisplays();
	displays.resize(displayCount);
	primaryDisplay = &displays[0];

	for (int i = 0; i < displayCount; ++i)
	{
		Display* display = &displays[i];

		const char* displayName = SDL_GetDisplayName(i);
		if (displayName)
		{
			display->setName(displayName);
		}

		SDL_DisplayMode sdlCurrentDisplayMode;
		SDL_GetCurrentDisplayMode(i, &sdlCurrentDisplayMode);

		int displayModeCount = SDL_GetNumDisplayModes(i);
		for (int j = 0; j < displayModeCount; ++j)
		{
			SDL_DisplayMode sdlDisplayMode;
			SDL_GetDisplayMode(i, j, &sdlDisplayMode);
			
			SDL_PixelFormat* format = SDL_AllocFormat(sdlDisplayMode.format);
			if (!format)
			{
				std::cerr << "Failed to create SDL pixel format: " << SDL_GetPixelFormatName(sdlDisplayMode.format) << '\n';
				continue;
			}

			int width = sdlDisplayMode.w;
			int height = sdlDisplayMode.h;
			int refreshRate = sdlDisplayMode.refresh_rate;
			int redBits, greenBits, blueBits, alphaBits;
			SDLPixelFormatMap::getChannelBits(format, &redBits, &greenBits, &blueBits, &alphaBits);

			SDL_FreeFormat(format);

			display->addMode(
				DisplayMode(width, height, redBits, greenBits, blueBits, alphaBits, refreshRate));

			if (sdlCurrentDisplayMode.w == sdlDisplayMode.w &&
				sdlCurrentDisplayMode.h == sdlDisplayMode.h &&
				sdlCurrentDisplayMode.format == sdlDisplayMode.format &&
				sdlCurrentDisplayMode.refresh_rate == sdlDisplayMode.refresh_rate)
			{
				display->setCurrentMode(j);
			}
		}
	}

	keyboard = new Keyboard("Default Keyboard");
	mouse = new Mouse("Default Mouse");
	
	application->getInputManager()->registerKeyboard(keyboard);
	application->getInputManager()->registerMouse(mouse);
}
예제 #29
0
DisplayMode Core::GetCurrentDisplayMode()
{
	return DisplayMode();
}
예제 #30
0
void GraphicsDriverBase::OnModeReleased()
{
    _mode = DisplayMode();
    _dstRect = Rect();
}