Esempio n. 1
0
void main()
{
	WindowWithBars win;
	DisplayWindow(win);			//Window::display()
	DisplayWindowRef(win);		//WindowWithBars::display()
	DisplayWindowConstRef(win); //WindowWithBars::display()
}
Esempio n. 2
0
FullScreen::FullScreen()
{
#ifdef WIN32
	clan::D3DTarget::set_current();
#else
	clan::OpenGLTarget::set_current();
#endif

	DisplayWindowDescription window_description;
	window_description.set_title("ClanLib FullScreen Example");
	window_description.set_size(Size(700, 600), true);
	window_description.set_allow_resize(true);

	window = DisplayWindow(window_description);

	sc.connect(window.sig_window_close(), clan::bind_member(this, &FullScreen::on_window_close));
	sc.connect(window.get_keyboard().sig_key_down(), clan::bind_member(this, &FullScreen::on_input_down));
	canvas = Canvas(window);

	spr_logo = Sprite(canvas, "../Basic2D/Resources/logo.png");
	spr_background = Sprite(canvas, "../../Display/Path/Resources/lobby_background2.png");

	font = clan::Font("tahoma", 24);
	game_time.reset();
}
Esempio n. 3
0
Program::Program()
{
	clan::OpenGLTarget::enable();

	window = DisplayWindow("Hello ShaderEffect", 800, 600, false, true);
	sc.connect(window.sig_window_close(), this, &Program::exit_func);

	GraphicContext gc = window.get_gc();


	uniforms.time = 0.0f;
	uniforms.resolution = Vec3f(800, 600, 0);
	uniforms.particle_count = particle_count;
	for(int i=0; i<particle_count; ++i) 
	{
		uniforms.positions[i] = Vec4f(rand() % 300 + 200.0f, rand() % 300 + 200.0f, rand() % 15, 1.0f);
	}

	uniformVector = UniformVector<Uniforms>(gc, &uniforms, 1);

	ShaderEffectDescription effect_description;
	effect_description.set_vertex_shader(File::read_text("Resources/vertex_shader.glsl"));
	effect_description.set_fragment_shader(File::read_text("Resources/fragment_shader.glsl"));
	effect_description.set_attribute_screen_quad("PositionInProjection");
	effect_description.set_frag_data_to_back_buffer("FragColor");
	effect_description.set_uniform_block("Uniforms", uniformVector);
	effect_description.set_glsl_version(330);

	effect = ShaderEffect(gc, effect_description);
}
Esempio n. 4
0
void ShowCPUState()
{
	DisplayWindow(0,0,66,10);
    PrintAt(0x0F,0xFF,1,1," D0=%08X  D1=%08X  D2=%08x  D3=%08x",cpu_regs.D[0],cpu_regs.D[1],cpu_regs.D[2],cpu_regs.D[3]);
    PrintAt(0x0F,0xFF,1,2," D4=%08X  D5=%08X  D6=%08x  D7=%08x",cpu_regs.D[4],cpu_regs.D[5],cpu_regs.D[6],cpu_regs.D[7]);
    PrintAt(0x0F,0xFF,1,3," A0=%08X  A1=%08X  A2=%08x  A3=%08x",cpu_regs.A[0],cpu_regs.A[1],cpu_regs.A[2],cpu_regs.A[3]);
    PrintAt(0x0F,0xFF,1,4," A4=%08X  A5=%08X  A6=%08x  A7=%08x",cpu_regs.A[4],cpu_regs.A[5],cpu_regs.A[6],cpu_regs.A[7]);
    PrintAt(0x0F,0xFF,1,5,"USP=%08X ISP=%08x\n",cpu_regs.USP,cpu_regs.ISP);
    PrintAt(0x0F,0xFF,1,7,"          [ T1:T0: S: M:  :I2:I1:I0:  :  :  : X: N: Z: V: C ]");
    PrintAt(0x0F,0xFF,1,8," SR=%04X  [ %s:%s:%s:%s:%s:%s:%s:%s:%s:%s:%s:%s:%s:%s:%s:%s ]", cpu_regs.SR, 
		   cpu_regs.SR & 0x8000 ? " 1" : " 0",
		   cpu_regs.SR & 0x4000 ? " 1" : " 0",
		   cpu_regs.SR & 0x2000 ? " 1" : " 0",
		   cpu_regs.SR & 0x1000 ? " 1" : " 0",
		   cpu_regs.SR & 0x0800 ? " 1" : " 0",
		   cpu_regs.SR & 0x0400 ? " 1" : " 0",
		   cpu_regs.SR & 0x0200 ? " 1" : " 0",
		   cpu_regs.SR & 0x0100 ? " 1" : " 0",
		   cpu_regs.SR & 0x0080 ? " 1" : " 0",
		   cpu_regs.SR & 0x0040 ? " 1" : " 0",
		   cpu_regs.SR & 0x0020 ? " 1" : " 0",
		   cpu_regs.SR & 0x0010 ? " 1" : " 0",
		   cpu_regs.SR & 0x0008 ? " 1" : " 0",
		   cpu_regs.SR & 0x0004 ? " 1" : " 0",
		   cpu_regs.SR & 0x0002 ? " 1" : " 0",
		   cpu_regs.SR & 0x0001 ? " 1" : " 0");
}
	WindowsClass::WindowsClass(HINSTANCE PassedHandleInstance, int PassedWindowState):
	m_HandleToWindow(0),
	m_WindowWidth(600),
	m_WindowHeight( (m_WindowWidth/5) * 4),
	m_WindowWidthIncludingBorder(0),
	m_WindowHeightIncludingBorder(0),
	m_OldMousePos()
	{
		// Create a WNDCLASS which describes the window to be created
		WNDCLASS TheWindowDescription = CreateWindowDescription(PassedHandleInstance);

		// Calculate the window dimensions
		CalculateWindowDimensions();

		// Pass the newly created WNDCLASS to the function which creates a Windows window
		CreateTheWindow( PassedHandleInstance );

		// Display the window 
		DisplayWindow(PassedWindowState);

		// Stores a pointer to the instance of the class so that we can create a member windows procedure
		SetWindowLongPtr(m_HandleToWindow, GWLP_USERDATA, reinterpret_cast<LONG_PTR>(this) );

		// Initialise Direct 3D application
		m_Direct3DScene.reset(new Scene(m_HandleToWindow, m_WindowWidth, m_WindowHeight));
	}
Esempio n. 6
0
DisplayWindow GUIWindowManagerProvider_System::get_display_window(GUITopLevelWindow *handle) const
{
    std::map<GUITopLevelWindow *, GUITopLevelWindowSystem *>::const_iterator it = window_map.find(handle);
    if (it != window_map.end())
        return it->second->window;
    else
        return DisplayWindow();
}
Esempio n. 7
0
void DisplayHelp()
{
	DisplayWindow(84,0,30,20);

	PrintAt(0x0F,0xFF,85,1,"T - Step Instruction");
	PrintAt(0x0F,0xFF,85,2,"H - Step hardware cycle");
	PrintAt(0x0F,0xFF,85,3,"G - Toggle Run in debugger");
	PrintAt(0x0F,0xFF,85,4,"<space> - Toggle Breakpoint");
	PrintAt(0x0F,0xFF,85,5,"<up/dn> - Move cursor");
	PrintAt(0x0F,0xFF,85,6,"M - Switch to cpu debug");
	PrintAt(0x0F,0xFF,85,7,"C - Show active copper");
	PrintAt(0x0F,0xFF,85,8,"P - Show cpu history");
}
Esempio n. 8
0
ClientGUI::ClientGUI()
{
	DisplayWindowDescription desc;
	desc.set_title("ClanLib - Dice War");
	desc.set_size(Size(1024, 768), true);
//	desc.set_allow_resize(true);
//	desc.set_multisampling(4);
	display_window = DisplayWindow(desc);

	//FIXME: Font_System::register_font("Resources\\bitstream_vera_sans\\VeraBd.ttf", "VeraBd");

	slot_quit = display_window.sig_window_close().connect(this, &ClientGUI::on_window_close);

	gui = GUIManager(display_window, "Resources/GUITheme");
}
Esempio n. 9
0
void DisplayCustomRegs()
{
	int x,y;
	static char buffer[256];

	DisplayWindow(0,31,14*8+1,512/16+2);
	
	for (y=0;y<512/16;y++)
	{
		for (x=0;x<8;x++)
		{
			MEM_GetHardwareDebug(y*8+x,buffer);
			PrintAt(0x0F,0xFF,x*14+1, y+32, buffer);
		}
	}
}
Esempio n. 10
0
void DecodeCopper(int cpReg,int offs)
{
	u_int32_t copperAddress;
	int a;

	if (cpReg==0)
		copperAddress = CST_GETLNGU(CST_COP1LCH,CUSTOM_CHIP_RAM_MASK);
	else
		copperAddress = CST_GETLNGU(CST_COP2LCH,CUSTOM_CHIP_RAM_MASK);

	DisplayWindow(0,0,14*8+1,31+34);

	copperAddress+=4*offs;

	for (a=0;a<32+31;a++)
	{
		u_int16_t ins1 = MEM_getWord(copperAddress);
		u_int16_t ins2 = MEM_getWord(copperAddress+2);

		if (ins1&0x0001)
		{
			if (ins2&0x0001)
			{
				// Skip
				PrintAt(0x0F,0xFF,1, a+1, "%08X    Skip : %04X:%04X\n",copperAddress,ins1,ins2);
			}
			else
			{
				// Wait

				u_int8_t maskv=0x80|((ins2>>8)&0x7F);
				u_int8_t maskh=(ins2&0xFE);
				u_int8_t vpos=ins1>>8;
				u_int8_t hpos=ins1&0xFE;
					
				PrintAt(0x0F,0xFF,1, a+1, "%08X    Wait : %04X:%04X\n -- VPOS&%02X >= %02X  -- HPOS&%02X >= %02X",copperAddress,ins1,ins2,maskv,vpos,maskh,hpos);
			}
		}
		else
		{
			// Move
			PrintAt(0x0F,0xFF,1, a+1, "%08X    Move : %04X:%04X  = %04X -> %08X (%s)\n",copperAddress,ins1,ins2,ins2,0xDFF000 + (ins1&0x01FE),MEM_GetHardwareName((ins1&0x01FE)/2));
		}

		copperAddress+=4;
	}
Esempio n. 11
0
HSV::HSV()
{
	clan::OpenGLTarget::set_current();

	window = DisplayWindow("ClanLib HSV Sprite", 1024, 768);
	sc.connect(window.sig_window_close(), clan::bind_member(this, &HSV::on_close));
	sc.connect(window.get_keyboard().sig_key_up(), clan::bind_member(this, &HSV::on_input_up));
	canvas = Canvas(window);

	font = clan::Font("Tahoma", 11);

	sprite_batcher = std::make_shared<HSVSpriteBatch>(canvas);
	car1 = std::make_shared<HSVSprite>(canvas, sprite_batcher.get(), "Resources/spaceshoot_body_moving1.png");
	car2 = std::make_shared<HSVSprite>(canvas, sprite_batcher.get(), "Resources/ferrari_maranello.png");

	last_fps_update = System::get_time();
	last_time = last_fps_update;
}
Esempio n. 12
0
void FullScreen::create_window()
{
	DisplayWindowDescription window_description;
	window_description.set_title("ClanLib FullScreen Example");
	window_description.set_size(Size(700, 600), true);

	if (is_fullscreen)
	{
		window_description.set_fullscreen(true);
		window_description.show_caption(false);
	}
	else
	{
		window_description.set_allow_resize(true);
	}

	window = DisplayWindow(window_description);

	sc.connect(window.sig_window_close(), clan::bind_member(this, &FullScreen::on_window_close));
	sc.connect(window.get_ic().get_keyboard().sig_key_down(), clan::bind_member(this, &FullScreen::on_input_down));
	canvas = Canvas(window);
}
Esempio n. 13
0
int TestApp::main(const std::vector<std::string> &args)
{
	// Create a console window for text-output if not available
	ConsoleWindow console("Console");

	try
	{
		DisplayWindowDescription desc;
		desc.set_size(Size(800,600), true);
		desc.set_title("Fullscreen test");
		DisplayWindow window(desc);
		
		while (!window.get_ic().get_keyboard().get_keycode(keycode_escape))
		{
			if (window.get_ic().get_keyboard().get_keycode(keycode_f11))
			{
				desc.set_fullscreen(!desc.is_fullscreen());
				window = DisplayWindow(desc);
			}

			window.get_gc().clear(Colorf::gray30);

			window.flip();
			KeepAlive::process();
			System::sleep(50);
		}
	}
	catch(Exception error)
	{
		Console::write_line("Exception caught:");
		Console::write_line(error.message);

		console.display_close_message();
		return -1;
	}

	return 0;
}
Esempio n. 14
0
DisplayWindow::DisplayWindow(
	const std::string &title,
	int width,
	int height,
	bool start_fullscreen,
	bool allow_resize,
	int flipping_buffers)
{
	DisplayWindowDescription description;
	description.set_title(title);
	description.set_size(Size(width, height), false);
	description.set_fullscreen(start_fullscreen);

	if (start_fullscreen)
	{
		description.show_caption(false);
	}

	description.set_allow_resize(allow_resize);
	description.set_flipping_buffers(flipping_buffers);

	*this = DisplayWindow(description);
}
Esempio n. 15
0
Win32_App::Win32_App()
{
	SourceDLLName = "Game.dll";
	//GameCode = Win32_LoadGameCode(SourceDLLName);

#ifdef _DEBUG
	// Дебажная консоль
	FileLogger flogger("debug.log");
	log_event("SYSTEM", "Logger initialized");
#endif

	try
	{
		// We support all display targets, in order listed here
#ifdef WIN32
		D3DTarget::enable();
#endif
		OpenGLTarget::enable();
	}
	catch (Exception exception)
	{
		// Create a console window for text-output if not available
		ConsoleWindow console("Console", 80, 160);
		Console::write_line("Exception caught: " + exception.get_message_and_stack_trace());
		console.display_close_message();

		quit = true;
	}

	// TODO: сохранять настройки графики
	fullscreen = 0;
	// TODO: Масштабировать окно
	InitScreenSize = Sizef(1024.0f, 768.0f);
	ScreenSize = InitScreenSize;
	DisplayWindowDescription window_description;
	window_description.set_title("Robot Game");
	window_description.set_size(ScreenSize, true);
	window_description.set_allow_resize(true);
	//window_description.set_type(WindowType::tool);
	window = DisplayWindow(window_description);

	canvas = Canvas(window);

	// Подключим коллбэки на слоты пользовательского ввода
	keyboard = window.get_ic().get_keyboard();
	sc.connect(window.sig_window_close(), bind_member(this, &Win32_App::Win32_OnWindowClose));
	sc.connect(window.get_ic().get_keyboard().sig_key_up(), bind_member(this, &Win32_App::Win32_OnKeyUp));
	sc.connect(window.get_ic().get_keyboard().sig_key_down(), bind_member(this, &Win32_App::Win32_OnKeyDown));
	sc.connect(window.get_ic().get_mouse().sig_key_down(), bind_member(this, &Win32_App::Win32_OnMouseDown));

	// Sound
	SoundOutput sound_output(48000);
/*
	SoundBuffer sbuffer("cheer1.ogg");
	sbuffer.play();
*/


	// Game memory
	LPVOID BaseAddress = 0;
	GameMemory.PermanentStorageSize = Megabytes(256);
	GameMemory.TransientStorageSize = Megabytes(256);
	size_t TotalStorageSize = (size_t)(GameMemory.PermanentStorageSize + GameMemory.TransientStorageSize);
	GameMemory.PermanentStorage = VirtualAlloc(BaseAddress, TotalStorageSize, MEM_RESERVE | MEM_COMMIT, PAGE_READWRITE);
	GameMemory.TransientStorage = ((uint8*)GameMemory.PermanentStorage + GameMemory.PermanentStorageSize);

	// Game state
	GameState = (game_state*)GameMemory.PermanentStorage;
	*GameState = {};
	GameState->ScreenSize = ScreenSize;


	// Resources
	//OpenGLTarget::set_current();
	GameState->game_resources = clan::XMLResourceManager::create(clan::XMLResourceDocument("sprites.xml"));

	GameState->LoadGameSpriteFromImage = &LoadGameSpriteFromImage;
	GameState->LoadGameSpriteFromResource = &LoadGameSpriteFromResource;
	GameState->AddGameSpriteFrameFromImage = &AddGameSpriteFrameFromImage;

	// Main display buffers
	//GameState->MainDisplayBuffer = PixelBuffer(1024, 768, TextureFormat::tf_rgba8, GameMemory.TransientStorage);


	// Win32 Timings
	CanSleepSafe = (timeBeginPeriod(1) == TIMERR_NOERROR);
	QueryPerformanceFrequency(&PerfCounterFrequencyQ);
	PerfCounterFrequency = PerfCounterFrequencyQ.QuadPart;

	QueryPerformanceCounter(&LastCounter);

	LastCycleCount = __rdtsc();

	game_time.reset();

	//console.display_close_message();
	//timeEndPeriod(1);
}
Esempio n. 16
0
App::App()
{
#if defined(WIN32) && !defined(__MINGW32__)
	clan::D3DTarget::set_current();
#else
	clan::OpenGLTarget::set_current();
#endif

	DisplayWindowDescription win_desc;
	win_desc.set_allow_resize(true);
	win_desc.set_title("Font Example Application");
	win_desc.set_size(Size( 1000, 700 ), false);

	window = DisplayWindow(win_desc);
	slots.connect(window.sig_window_close(), this, &App::on_window_close);
	slots.connect(window.get_keyboard().sig_key_up(), this, &App::on_input_up);

	clan::XMLResourceFactory::set_display();
	resources = clan::XMLResourceManager::create(clan::XMLResourceDocument("Resources/resources.xml"));

	canvas = Canvas(window);

	clan::Texture2D gui_texture = clan::Texture2D(canvas, (int)std::round(250 * canvas.get_pixel_ratio()), (int)std::round(500 * canvas.get_pixel_ratio()));
	gui_texture.set_pixel_ratio(canvas.get_pixel_ratio());
	gui_image = clan::Image(gui_texture, gui_texture.get_size());
	clan::FrameBuffer gui_framebuffer = clan::FrameBuffer(canvas);
	gui_framebuffer.attach_color(0, gui_texture);
	gui_canvas = clan::Canvas(canvas, gui_framebuffer);

	clan::FileResourceDocument doc(clan::FileSystem("../../ThemeAero"));
	clan::ResourceManager resources = clan::FileResourceManager::create(doc);
	ui_thread = clan::UIThread(resources);

	root = std::make_shared<clan::TextureWindow>(gui_canvas);

	root->set_window(window);

	root->set_viewport(gui_image.get_size());

	int offset_x = 10;
	int offset_y = 8;
	int width = 220;
	int small_width = 70;
	int height = 20;
	const int gap = 38;

	auto button_class_system = Theme::create_button();
	button_class_system->style()->set("position: absolute; left:%1px; top:%2px; width:%3px; height:auto;", offset_x, offset_y, width);
	button_class_system->func_clicked() = clan::bind_member(this, &App::on_button_clicked_class_system);
	button_class_system->label()->set_text("Class: System");
	root->add_child(button_class_system);
	offset_y += gap;

	auto button_class_sprite = Theme::create_button();
	button_class_sprite->style()->set("position: absolute; left:%1px; top:%2px; width:%3px; height:auto;", offset_x, offset_y, width);
	button_class_sprite->func_clicked() = bind_member(this, &App::on_button_clicked_class_sprite);
	button_class_sprite->label()->set_text("Class: Sprite");
	root->add_child(button_class_sprite);
	offset_y += gap;

	button_typeface_tahoma = Theme::create_button();
	button_typeface_tahoma->style()->set("position: absolute; left:%1px; top:%2px; width:%3px; height:auto;", offset_x, offset_y, width);
	button_typeface_tahoma->func_clicked() = bind_member(this, &App::on_button_clicked_typeface_tahoma);
	button_typeface_tahoma->label()->set_text("Typeface: Tahoma");
	root->add_child(button_typeface_tahoma);
	offset_y += gap;

	button_typeface_sans = Theme::create_button();
	button_typeface_sans->style()->set("position: absolute; left:%1px; top:%2px; width:%3px; height:auto;", offset_x, offset_y, width);
	button_typeface_sans->func_clicked() = bind_member(this, &App::on_button_clicked_typeface_sans);
	button_typeface_sans->label()->set_text("Typeface: Microsoft Sans Serif");
	root->add_child(button_typeface_sans);
	offset_y += gap;

	button_typeface_bitstream = Theme::create_button();
	button_typeface_bitstream->style()->set("position: absolute; left:%1px; top:%2px; width:%3px; height:auto;", offset_x, offset_y, width);
	button_typeface_bitstream->func_clicked() = bind_member(this, &App::on_button_clicked_typeface_bitstream);
	button_typeface_bitstream->label()->set_text("Typeface: Bitstream Vera Sans");
	root->add_child(button_typeface_bitstream);
	offset_y += gap;

	checkbox_italic = Theme::create_checkbox();
	checkbox_italic->style()->set("position: absolute; left:%1px; top:%2px", offset_x, offset_y);
	checkbox_italic->func_state_changed() = bind_member(this, &App::on_checkbox_state_italic);
	root->add_child(checkbox_italic);
	auto label = Theme::create_label();
	label->set_text("Italic");
	label->style()->set("position: absolute; left:%1px; top:%2px", offset_x + 16, offset_y - 3);
	root->add_child(label);

	checkbox_antialias = Theme::create_checkbox();
	checkbox_antialias->set_check(true);
	checkbox_antialias->style()->set("position: absolute; left:%1px; top:%2px", offset_x + 100, offset_y);
	checkbox_antialias->func_state_changed() = bind_member(this, &App::on_checkbox_state_antialias);
	root->add_child(checkbox_antialias);
	label = Theme::create_label();
	label->set_text("Anti Alias");
	label->style()->set("position: absolute; left:%1px; top:%2px", offset_x + 100+ 16, offset_y - 3);
	root->add_child(label);
	offset_y += gap;

	checkbox_subpixel = Theme::create_checkbox();
	checkbox_subpixel->set_check(true);
	checkbox_subpixel->style()->set("position: absolute; left:%1px; top:%2px", offset_x, offset_y);
	checkbox_subpixel->func_state_changed() = bind_member(this, &App::on_checkbox_state_subpixel);
	root->add_child(checkbox_subpixel);
	label = Theme::create_label();
	label->set_text("SubPixel Rendering");
	label->style()->set("position: absolute; left:%1px; top:%2px", offset_x + 16, offset_y - 3);
	root->add_child(label);
	offset_y += gap;

	auto button_weight_light = Theme::create_button();
	button_weight_light->style()->set("position: absolute; left:%1px; top:%2px; width:%3px; height:auto;", offset_x, offset_y, small_width);
	button_weight_light->func_clicked() = bind_member(this, &App::on_button_clicked_weight_light);
	button_weight_light->label()->set_text("Light");
	root->add_child(button_weight_light);
	auto button_weight_normal = Theme::create_button();
	button_weight_normal->style()->set("position: absolute; left:%1px; top:%2px; width:%3px; height:auto;", offset_x + small_width + 5, offset_y, small_width);
	button_weight_normal->func_clicked() = bind_member(this, &App::on_button_clicked_weight_normal);
	button_weight_normal->label()->set_text("Normal");
	root->add_child(button_weight_normal);
	auto button_weight_bold = Theme::create_button();
	button_weight_bold->style()->set("position: absolute; left:%1px; top:%2px; width:%3px; height:auto;", offset_x + (small_width + 5) * 2, offset_y, small_width);
	button_weight_bold->func_clicked() = bind_member(this, &App::on_button_clicked_weight_bold);
	button_weight_bold->label()->set_text("Bold");
	root->add_child(button_weight_bold);
	offset_y += gap;

	auto button_size_16 = Theme::create_button();
	button_size_16->style()->set("position: absolute; left:%1px; top:%2px; width:%3px; height:auto;", offset_x, offset_y, small_width);
	button_size_16->func_clicked() = bind_member(this, &App::on_button_clicked_size_16);
	button_size_16->label()->set_text("Size 16");
	root->add_child(button_size_16);
	auto button_size_32 = Theme::create_button();
	button_size_32->style()->set("position: absolute; left:%1px; top:%2px; width:%3px; height:auto;", offset_x + small_width + 5, offset_y, small_width);
	button_size_32->func_clicked() = bind_member(this, &App::on_button_clicked_size_32);
	button_size_32->label()->set_text("Size 32");
	root->add_child(button_size_32);
	auto button_size_64 = Theme::create_button();
	button_size_64->style()->set("position: absolute; left:%1px; top:%2px; width:%3px; height:auto;", offset_x + (small_width + 5) * 2, offset_y, small_width);
	button_size_64->func_clicked() = bind_member(this, &App::on_button_clicked_size_64);
	button_size_64->label()->set_text("Size 64");
	root->add_child(button_size_64);
	offset_y += gap + 8;

	lineedit_text = std::make_shared<clan::TextFieldView>();
	lineedit_text->style()->set("font: 11px/20px 'Segoe UI'");
	lineedit_text->style()->set("margin: 5px");
	lineedit_text->style()->set("background: #efefef");
	lineedit_text->style()->set("border: 1px solid black");
	lineedit_text->style()->set("border-radius: 3px");
	lineedit_text->style()->set("padding: 2px 5px 2px 5px");
	lineedit_text->style()->set("width: 128px");
	lineedit_text->style()->set("box-shadow: 0 0 5px rgba(100,100,200,0.2)");
	lineedit_text->style()->set("position: absolute; left:%1px; top:%2px; width:%3px; height:auto;", offset_x, offset_y, width);
	font_text = "Ω(The quick brown fox 0123456789)";
	lineedit_text->set_text(font_text);
	slots.connect(lineedit_text->sig_selection_changed(), bind_member(this, &App::on_lineedit_changed));
	root->add_child(lineedit_text);

	last_fps = 0.0f;
	selected_fontclass = font_ttf;
	font_typeface = "Microsoft Sans Serif";
	font_filename = "";
	font_desc.set_height(32);
	font_desc.set_weight(clan::FontWeight::normal);
	select_font();

	small_font = clan::Font("Tahoma", 16);

	premultiply_src_blend = BlendState(canvas, BlendStateDescription::blend(true));

	game_time.reset();
}
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) {
	int wmId, wmEvent;
	LPMINMAXINFO minInfo;
	static SOCKET serverSocket;
	static SOCKET clientSocket;

	switch (message) {
	case WM_CREATE:
		serverSocket = CreateSocket(hWnd);
		connectionStatus = statusNotConnected;
		EnableMenuItem(GetMenu(hWnd), IDM_DISCONNECT, MF_BYCOMMAND | MF_GRAYED);
		ListAddresses();
		break;
	case WM_NETWORK:
		switch (WSAGETSELECTEVENT(lParam)) {
		case FD_ACCEPT:
			clientSocket = AcceptSocket(hWnd, serverSocket);
			break;
		case FD_CLOSE:
			if (connectionStatus == statusConnected)
				CloseSocket(hWnd, clientSocket);
			break;
		}
		break;
	case WM_COMMAND:
		wmId = LOWORD(wParam);
		wmEvent = HIWORD(wParam);
		switch (wmId) {
		case IDM_ABOUT:
			DialogBox(hInst, MAKEINTRESOURCE(IDD_ABOUTBOX), hWnd, About);
			break;
		case IDM_EXIT:
			Shell_NotifyIcon(NIM_DELETE, &trayIcon[trayIconNotConnected]);
			DestroyWindow(hWnd);
			break;
		case IDM_TRAY:
			HideInTray(hWnd, TRUE);
			break;
		case IDM_DISCONNECT:
			if (connectionStatus == statusConnected)
				CloseSocket(hWnd, clientSocket);
			break;
		case IDM_OPEN:
			HideInTray(hWnd, FALSE);
			break;
		default:
			return DefWindowProc(hWnd, message, wParam, lParam);
		}
		break;
	case WM_GETMINMAXINFO:
		minInfo = (LPMINMAXINFO)lParam;
		minInfo->ptMinTrackSize.x = kWidthMin;
		minInfo->ptMinTrackSize.y = kHeightMin;
		break;
	case WM_PAINT:
		DisplayWindow(hWnd);
		break;
	case WM_SYSCOMMAND:
		if (wParam == SC_MINIMIZE)
			HideInTray(hWnd, TRUE);
		else
			return DefWindowProc(hWnd, message, wParam, lParam);
		break;
	case WM_CLOSE:
		HideInTray(hWnd, TRUE);
		break;
	case WM_DESTROY:
		PostQuitMessage(0);
		break;
	case WM_TRAYMENU:
		if (wParam == kTrayId) {
			switch (lParam) {
			case WM_RBUTTONDOWN:
				DisplayTrayMenu(hWnd);
				break;
			case WM_LBUTTONDBLCLK:
				HideInTray(hWnd, !bInTray);
				break;
			default:
				break;
			}
		}
		break;
	default:
		return DefWindowProc(hWnd, message, wParam, lParam);
	}
	return 0;
}
Esempio n. 18
0
// The start of the Application
int App::start(const std::vector<std::string> &args)
{
	// Setup the window
	DisplayWindowDescription win_desc;
	win_desc.set_allow_resize(true);
	win_desc.set_title("Input Example");
	win_desc.set_size(Size( 1000, 700 ), false);
	window = DisplayWindow(win_desc);

	// Connect the slots that we require
	Slot slot_quit = window.sig_window_close().connect(this, &App::on_window_close);
	Slot slot_input_down = (window.get_ic().get_keyboard()).sig_key_down().connect(this, &App::on_input_down);
	Slot slot_mouse_down = (window.get_ic().get_mouse()).sig_key_down().connect(this, &App::on_mouse_down);
	Slot slot_mouse_dblclick = (window.get_ic().get_mouse()).sig_key_dblclk().connect(this, &App::on_mouse_down);

	std::vector<Slot> slot_joystick;
	int max_joysticks = window.get_ic().get_joystick_count();
	for (int joystick_number=0; joystick_number < max_joysticks; joystick_number++)
	{
		Slot current_joystick = window.get_ic().get_joystick(joystick_number).sig_key_down().connect(this, &App::on_joystick_down, joystick_number);
		slot_joystick.push_back(current_joystick);
	}

	canvas = Canvas(window);

	font = clan::Font(canvas, "tahoma", 16);
	vector_font = VectorFont(canvas, "Bitstream Vera Sans", 256, "../../Display_Text/Font/Resources/bitstream_vera_sans/VeraBd.ttf");

	calculate_matrix(canvas);

	while(!quit)
	{
		canvas.set_map_mode(map_2d_upper_left);

		canvas.fill_rect(Rect(0, 0, canvas.get_width(), canvas.get_height()/2), Gradient(Colorf(0.2f, 0.2f, 0.8f, 1.0f), Colorf(0.0f, 0.0f, 0.2f, 1.0f)));
		canvas.fill_rect(Rect(0, canvas.get_height()/2, canvas.get_width(), canvas.get_height()), Gradient(Colorf(0.0f, 0.0f, 0.2f, 1.0f), Colorf(0.2f, 0.2f, 0.8f, 1.0f)));

		font.draw_text(canvas, 8, 20, "Press any key, mouse button or joystick button to fire text. Use mouse to control direction.");

		int yoffset = canvas.get_height() - 20;
		const int y_gap = 20;

		// Draw Keyboard Information
		draw_keyboard_state(canvas, yoffset);
		yoffset -= y_gap;

		// Draw Mouse Information
		draw_mouse_state(canvas, yoffset);
		yoffset -= y_gap;
	
		// Draw Joysticks Information
		for (int joystick_number=0; joystick_number < max_joysticks; joystick_number++)
		{
			draw_joystick_state(canvas, joystick_number, yoffset);
			yoffset -= y_gap;
		}

		// Draw Tablet Information
		int max_tablets = window.get_ic().get_tablet_count();
		for (int tablet_number=0; tablet_number < max_tablets; tablet_number++)
		{
			draw_tablet_state(canvas, tablet_number, yoffset);
			yoffset -= y_gap;
		}

		canvas.set_map_mode(map_user_projection);
		canvas.set_projection(projection_matrix);

		draw_text_shooter(canvas);

		window.flip(1);

		KeepAlive::process();
	}

	return 0;
}
Esempio n. 19
0
void GUIWindowManagerProvider_System::create_window(
    GUITopLevelWindow *handle,
    GUITopLevelWindow *owner,
    GUIComponent *component,
    GUITopLevelDescription description)
{
    description.set_update_supported(true);

    GUITopLevelWindowSystem *owner_window = 0;
    if (owner)
    {
        owner_window = window_map[owner];
        description.set_owner_window(owner_window->window);
    }

    GUITopLevelWindowSystem *top_level_window;

#ifdef WIN32	// Cached windows do not work on Linux
    if (description.get_using_gui_window_cache())
    {
        used_cached_windows++;

        if (used_cached_windows <= cached_windows.size())
        {
            top_level_window = cached_windows[used_cached_windows-1];
            top_level_window->slots = SlotContainer();
            cache_window_handles[handle] = top_level_window->window.get_hwnd();
        }
        else
        {
            top_level_window = new GUITopLevelWindowSystem;
            top_level_window->window = DisplayWindow(description);
            top_level_window->canvas = Canvas(top_level_window->window);
            cached_windows.push_back(top_level_window);
            cache_window_handles[handle] = top_level_window->window.get_hwnd();
        }
    }
    else
#endif
    {
        top_level_window = new GUITopLevelWindowSystem;
        top_level_window->window = DisplayWindow(description);
        top_level_window->canvas = Canvas(top_level_window->window);
    }

    top_level_window->canvas.set_map_mode(map_2d_upper_left);

    top_level_window->slots.connect(top_level_window->window.sig_lost_focus(), this, &GUIWindowManagerProvider_System::on_displaywindow_lost_focus, handle);
    top_level_window->slots.connect(top_level_window->window.sig_got_focus(), this, &GUIWindowManagerProvider_System::on_displaywindow_got_focus, handle);
    top_level_window->slots.connect(top_level_window->window.sig_resize(), this, &GUIWindowManagerProvider_System::on_displaywindow_resize, handle);
    top_level_window->slots.connect(top_level_window->window.sig_paint(), this, &GUIWindowManagerProvider_System::on_displaywindow_paint, handle);
    top_level_window->slots.connect(top_level_window->window.sig_window_close(), this, &GUIWindowManagerProvider_System::on_displaywindow_window_close, handle);
    top_level_window->slots.connect(top_level_window->window.sig_window_destroy(), this, &GUIWindowManagerProvider_System::on_displaywindow_window_destroy, handle);

    InputContext ic = top_level_window->window.get_ic();
    top_level_window->slots.connect(ic.get_mouse().sig_key_up(), this, &GUIWindowManagerProvider_System::on_input, handle);
    top_level_window->slots.connect(ic.get_mouse().sig_key_down(), this, &GUIWindowManagerProvider_System::on_input, handle);
    top_level_window->slots.connect(ic.get_mouse().sig_key_dblclk(), this, &GUIWindowManagerProvider_System::on_input, handle);
    top_level_window->slots.connect(ic.get_mouse().sig_pointer_move(), this, &GUIWindowManagerProvider_System::on_input, handle);
    top_level_window->slots.connect(ic.get_keyboard().sig_key_up(), this, &GUIWindowManagerProvider_System::on_input, handle);
    top_level_window->slots.connect(ic.get_keyboard().sig_key_down(), this, &GUIWindowManagerProvider_System::on_input, handle);

    for (int i = 0; i < ic.get_tablet_count(); ++i)
    {
        top_level_window->slots.connect(ic.get_tablet(i).sig_axis_move(), this, &GUIWindowManagerProvider_System::on_input, handle);
        top_level_window->slots.connect(ic.get_tablet(i).sig_key_down(), this, &GUIWindowManagerProvider_System::on_input, handle);
        top_level_window->slots.connect(ic.get_tablet(i).sig_key_dblclk(), this, &GUIWindowManagerProvider_System::on_input, handle);
        top_level_window->slots.connect(ic.get_tablet(i).sig_key_up(), this, &GUIWindowManagerProvider_System::on_input, handle);
        top_level_window->slots.connect(ic.get_tablet(i).sig_proximity_change(), this, &GUIWindowManagerProvider_System::on_input, handle);
    }

    window_map[handle] = top_level_window;

    sig_toplevel_window_created.invoke(top_level_window->window);
}