Geant4 Cross Reference |
1 // Copyright (C) 2010, Guy Barrand. All rights 2 // See the file tools.license for terms. 3 4 #ifndef tools_saui 5 #define tools_saui 6 7 #include "args" 8 9 namespace tools { 10 11 inline std::string gui_toolkit(args& a_args,bo 12 std::string driver; 13 a_args.find("-toolkit",driver); 14 if(a_rm_in_args) a_args.remove("-toolkit"); 15 if(driver.empty()) { 16 if(a_args.is_arg("-Xt")|| 17 a_args.is_arg("-xt")|| 18 a_args.is_arg("-Xm")|| 19 a_args.is_arg("-xm")|| 20 a_args.is_arg("-Motif")|| 21 a_args.is_arg("-motif")) { 22 driver = "Xt"; 23 if(a_rm_in_args) { 24 a_args.remove("-Xt"); 25 a_args.remove("-xt"); 26 a_args.remove("-Xm"); 27 a_args.remove("-xm"); 28 a_args.remove("-Motif"); 29 a_args.remove("-motif"); 30 } 31 } else if(a_args.is_arg("-Win")|| 32 a_args.is_arg("-win")|| 33 a_args.is_arg("-Win32")|| 34 a_args.is_arg("-win32")) { 35 driver = "Win"; 36 if(a_rm_in_args) { 37 a_args.remove("-Win"); 38 a_args.remove("-win"); 39 a_args.remove("-Win32"); 40 a_args.remove("-win32"); 41 } 42 } else if(a_args.is_arg("-NextStep")|| 43 a_args.is_arg("-nextstep")) { 44 driver = "NextStep"; 45 if(a_rm_in_args) { 46 a_args.remove("-NextStep"); 47 a_args.remove("-nextstep"); 48 } 49 } else if(a_args.is_arg("-Gtk")|| 50 a_args.is_arg("-gtk")) { 51 driver = "Gtk"; 52 if(a_rm_in_args) { 53 a_args.remove("-Gtk"); 54 a_args.remove("-gtk"); 55 } 56 } else if(a_args.is_arg("-Qt")|| 57 a_args.is_arg("-qt")) { 58 driver = "Qt"; 59 if(a_rm_in_args) { 60 a_args.remove("-Qt"); 61 a_args.remove("-qt"); 62 } 63 } else if(a_args.is_arg("-SDL")|| 64 a_args.is_arg("-sdl")) { 65 driver = "SDL"; 66 if(a_rm_in_args) { 67 a_args.remove("-SDL"); 68 a_args.remove("-sdl"); 69 } 70 } else if(a_args.is_arg("-Net")|| 71 a_args.is_arg("-net")) { 72 driver = "Net"; 73 if(a_rm_in_args) { 74 a_args.remove("-Net"); 75 a_args.remove("-net"); 76 } 77 } else if(a_args.is_arg("-inex")) { 78 driver = "inex"; 79 if(a_rm_in_args) { 80 a_args.remove("-inex"); 81 } 82 } 83 } 84 85 return driver; 86 } 87 88 inline bool window_size_from_args(const args& 89 // set a_ww,a_wh to some common window size 90 // return true if a_ww,a_wh set from a_args, 91 bool status = true; 92 if(a_args.is_arg("-iPod")||a_args.is_arg("-i 93 a_ww = 320; 94 a_wh = 480; 95 } else if(a_args.is_arg("-iPad")) { 96 a_ww = 768; 97 a_wh = 1024; 98 } else if(a_args.is_arg("-iPhone4")) { 99 a_ww = 640; 100 a_wh = 960; 101 } else if(a_args.is_arg("-wallino")) { //emu 102 a_ww = 1024; 103 a_wh = 512; 104 } else if(a_args.is_arg("-SGS")) { //Samsung 105 //a_ww = 320; 106 //a_wh = 533; 107 a_ww = 480; 108 a_wh = 800; 109 } else { 110 if(a_args.find<unsigned int>("-ww",a_ww)) 111 if(a_args.find<unsigned int>("-wh",a_wh) 112 //A4 : we have ww but not wh. Have wh in 113 a_wh = (unsigned int)(a_ww*(21.0f/29.7f) 114 } else { //we don't have ww. 115 if(a_args.find<unsigned int>("-wh",a_wh) 116 //A4 : we have wh but not ww. Have ww 117 a_ww = (unsigned int)(a_wh*(29.7f/21.0 118 } else { 119 //we have nothing. Take a ww of 1000 a 120 a_ww = 1000; 121 a_wh = (unsigned int)(a_ww*(21.0f/29.7 122 status = false; 123 } 124 } 125 } 126 if(a_args.is_arg("-land")){ 127 unsigned int _ww = a_ww; 128 unsigned int _wh = a_wh; 129 a_ww = mx(_ww,_wh); 130 a_wh = mn(_ww,_wh); 131 } 132 if(a_args.is_arg("-portrait")){ 133 unsigned int _ww = a_ww; 134 unsigned int _wh = a_wh; 135 a_ww = mn(_ww,_wh); 136 a_wh = mx(_ww,_wh); 137 } 138 return status; 139 } 140 141 inline void remove_window_size_args(args& a_ar 142 //use with Wt apps. 143 a_args.remove("-iPod"); 144 a_args.remove("-iPhone"); 145 a_args.remove("-iPad"); 146 a_args.remove("-iPhone4"); 147 a_args.remove("-SGS"); 148 a_args.remove("-ww"); 149 a_args.remove("-wh"); 150 a_args.remove("-land"); 151 } 152 153 } 154 155 #endif