Ejemplo n.º 1
0
void clViewport::AfterConstruction()
{
#ifdef OS_WINDOWS
    DWORD dwVersion = 0;
    DWORD dwMajorVersion = 0;

    dwVersion = GetVersion();

    // Get the Windows version.
    dwMajorVersion = ( DWORD )( LOBYTE( LOWORD( dwVersion ) ) );

    if ( dwMajorVersion > 5 )
    {
        /// Anything below WinXP without SP3 does not support High DPI, so we do not enable it on WinXP at all.
        SetHighDPIAware();
    }

    StoreAndDisableStickyKeys();

    if ( FTakeoverContext )
    {
        ResizeViewport( 0, 0 );
    }
    else
#endif
    {
#ifdef OS_WINDOWS

        if ( FRegisterWindowClass )
        {
            RegisterWindowClass();
        }

        if ( FExternalWindowHandle )
        {
            RECT Rect;

            GetWindowRect( FExternalWindowHandle, &Rect );

            FWidth  = Rect.right  - Rect.left;
            FHeight = Rect.bottom - Rect.top;
        }

#endif
        RecreateViewport();
    }

    ReinitializeViewport();

    FMouseX = Env->Console->GetVar( "Viewport.MouseX" );
    FMouseY = Env->Console->GetVar( "Viewport.MouseY" );

    Env->Connect( L_EVENT_SURFACE_CHANGED, BIND( &clViewport::Event_SURFACE_CHANGED ) );
}
Ejemplo n.º 2
0
int main( int argc, char** argv )
#endif
{
	try
	{
#ifdef _WIN32
		SetHighDPIAware();
		//disable system critical messageboxes (for example: no floppy disk :) )
		SetErrorMode( SEM_FAILCRITICALERRORS );

		Win32HInstance = hInstance;
		Win32HIconId = IDI_WCM;

		WSADATA wsaData;

		if ( WSAStartup( MAKEWORD( 2, 2 ), &wsaData ) ) { throw_syserr( 0, "WSAStartup failed" ); }

		std::string StartupDir;
#else
		setlocale( LC_ALL, "" );
		signal( SIGPIPE, SIG_IGN );

		std::string StartupDir = GetStartupDir( argv[0] );
#endif

		try
		{
			InitConfigPath();
			g_WcmConfig.Load( nullptr, StartupDir );

			const char* langId = g_WcmConfig.systemLang.data() ? g_WcmConfig.systemLang.data() : "+";
#ifdef _WIN32
			if ( !InitLocale( L"install-files/share/wcm/lang", langId ) )
			{
				InitLocale( carray_cat<sys_char_t>( GetAppPath().data(), utf8_to_sys( "lang" ).data() ).data(), langId );
			}
#else

			if ( !InitLocale( "install-files/share/wcm/lang", langId ) )
			{
				InitLocale( UNIX_CONFIG_DIR_PATH "/lang", langId );
			}

#endif


//			SetEditorColorStyle(g_WcmConfig.editColorMode);
//			SetViewerColorStyle(g_WcmConfig.viewColorMode);
		}
		catch ( cexception* ex )
		{
			fprintf( stderr, "%s\n", ex->message() );
			ex->destroy();
		}

		InitSSH();

		AppInit();

		SetColorStyle( g_WcmConfig.styleColorTheme);

		OldSysGetFont = SysGetFont;
		SysGetFont = MSysGetFont;

//		cfont* defaultFont = SysGetFont( 0, 0 );
		defaultGC = new wal::GC( ( Win* )0 );

#ifndef _WIN32
#include "icons/wcm.xpm"
		Win::SetIcon( wcm_xpm );
#endif

		InitFonts();
		InitOperCharsets();

		SetCmdIcons();

		NCWin ncWin;

		g_MainWin = &ncWin;

		// reload config with a valid NCWin
		g_WcmConfig.Load( &ncWin, StartupDir );

		ncWin.Enable();
		ncWin.Show();

		InitExtensionApp();

#if !defined( _WIN32 )

		// don't bother with this on Windows
		if ( !ParseCommandLine( argc, argv, &ncWin ) ) { return 0; }

#endif

		for ( auto i = g_Applets.begin(); i != g_Applets.end(); i++ )
		{
			if ( !( *i )->Run() ) { return 0; }
		}

		g_Applets.clear();

		AppRun();

		// clean up
		RemoveAllWcmTempDirs();

		dbg_printf( "App Quit!!!\n" );

	}
	catch ( cexception* ex )
	{
#ifdef _WIN32
		MessageBoxA( 0, ex->message(), "", MB_OK );
#else
		printf( "Error: %s\n", ex->message() );
#endif
	}


	return 0;
}