CharsetDlg1(NCDialogParent *parent, int curCharset) : NCDialog(createDialogAsChild, 0, parent, utf8_to_unicode( _LT("Charset") ).ptr(), bListOkCancel), layout(10,10), list(this, 7), otherButton(0, this, utf8_to_unicode( _LT("Other...") ).ptr(), CMD_OTHER), addButton(0, this, utf8_to_unicode( carray_cat<char>(_LT("Add..."), "(Ins)").ptr() ).ptr(), CMD_ADD), delButton(0, this, utf8_to_unicode( carray_cat<char>(_LT("Del..."), "(Del)").ptr() ).ptr(), CMD_DEL) { int i; InitOperCharsets(); list.SetList(::csList.ptr(), ::csList.count()); list.MoveFirst(0); for (int i = 0; i < ::csList.count(); i++) if (::csList[i]->id == curCharset) { list.MoveCurrent(i); break; } /* LO L LA LD */ layout.AddWin(&list,0,0,3,0); list.Enable(); list.Show(); list.SetFocus(); layout.AddWin(&otherButton,0,1); otherButton.Enable(); otherButton.Show(); layout.AddWin(&addButton,2,1); addButton.Enable(); addButton.Show(); layout.AddWin(&delButton,3,1); delButton.Enable(); delButton.Show(); int mx = 0, my = 0; LSize ls; otherButton.GetLSize(&ls); if (mx < ls.x.maximal) mx = ls.x.maximal; if (my < ls.y.maximal) my = ls.y.maximal; addButton.GetLSize(&ls); if (mx < ls.x.maximal) mx = ls.x.maximal; if (my < ls.y.maximal) my = ls.y.maximal; delButton.GetLSize(&ls); if (mx < ls.x.maximal) mx = ls.x.maximal; if (my < ls.y.maximal) my = ls.y.maximal; ls.x.minimal = ls.x.maximal = mx; ls.y.minimal = ls.y.maximal = my; otherButton.SetLSize(ls); addButton.SetLSize(ls); delButton.SetLSize(ls); layout.SetLineGrowth(1); AddLayout(&layout); SetEnterCmd(CMD_OK); SetPosition(); };
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; }
int main( int argc, char** argv ) #endif { try { #ifndef _WIN32 for ( int i = 1; i < argc; i++ ) { if ( argv[i][0] == '-' && argv[i][1] == '-' && !strcmp( argv[i] + 2, "dlg" ) ) { createDialogAsChild = false; } } #endif #ifdef _WIN32 //disable system critical messageboxes (for example: no floppy disk :) ) SetErrorMode( SEM_FAILCRITICALERRORS ); #endif #ifdef _WIN32 Win32HInstance = hInstance; Win32HIconId = IDI_WCM; #endif #ifdef _WIN32 WSADATA wsaData; if ( WSAStartup( MAKEWORD( 2, 2 ), &wsaData ) ) { throw_syserr( 0, "WSAStartup failed" ); } #else setlocale( LC_ALL, "" ); signal( SIGPIPE, SIG_IGN ); #endif try { InitConfigPath(); g_WcmConfig.Load( NULL ); const char* langId = g_WcmConfig.systemLang.data() ? g_WcmConfig.systemLang.data() : "+"; #ifdef _WIN32 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.styleColorMode ); 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; // reload config with a valid NCWin g_WcmConfig.Load( &ncWin ); ncWin.Enable(); ncWin.Show(); InitExtensionApp(); AppRun(); dbg_printf( "App Quit!!!" ); } catch ( cexception* ex ) { #ifdef _WIN32 MessageBoxA( 0, ex->message(), "", MB_OK ); #else printf( "Error: %s\n", ex->message() ); #endif } return 0; }