Back to home page

EIC code displayed by LXR

 
 

    


Warning, /include/Geant4/tools/saui is written in an unsupported language. File is not indexed.

0001 // Copyright (C) 2010, Guy Barrand. All rights reserved.
0002 // See the file tools.license for terms.
0003 
0004 #ifndef tools_saui
0005 #define tools_saui
0006 
0007 #include "args"
0008 
0009 namespace tools {
0010 
0011 inline std::string gui_toolkit(args& a_args,bool a_rm_in_args){
0012   std::string driver;
0013   a_args.find("-toolkit",driver);
0014   if(a_rm_in_args) a_args.remove("-toolkit");
0015   if(driver.empty()) {
0016     if(a_args.is_arg("-Xt")||
0017        a_args.is_arg("-xt")||
0018        a_args.is_arg("-Xm")||
0019        a_args.is_arg("-xm")||
0020        a_args.is_arg("-Motif")||
0021        a_args.is_arg("-motif")) {
0022       driver = "Xt";
0023       if(a_rm_in_args) {
0024         a_args.remove("-Xt");
0025         a_args.remove("-xt");
0026         a_args.remove("-Xm");
0027         a_args.remove("-xm");
0028         a_args.remove("-Motif");
0029         a_args.remove("-motif");
0030       }
0031     } else if(a_args.is_arg("-Win")||
0032               a_args.is_arg("-win")||
0033               a_args.is_arg("-Win32")||
0034               a_args.is_arg("-win32")) {
0035       driver = "Win";
0036       if(a_rm_in_args) {
0037         a_args.remove("-Win");
0038         a_args.remove("-win");
0039         a_args.remove("-Win32");
0040         a_args.remove("-win32");
0041       }
0042     } else if(a_args.is_arg("-NextStep")||
0043               a_args.is_arg("-nextstep")) {
0044       driver = "NextStep";
0045       if(a_rm_in_args) {
0046         a_args.remove("-NextStep");
0047         a_args.remove("-nextstep");
0048       }
0049     } else if(a_args.is_arg("-Gtk")||
0050               a_args.is_arg("-gtk")) {
0051       driver = "Gtk";
0052       if(a_rm_in_args) {
0053         a_args.remove("-Gtk");
0054         a_args.remove("-gtk");
0055       }
0056     } else if(a_args.is_arg("-Qt")||
0057               a_args.is_arg("-qt")) {
0058       driver = "Qt";
0059       if(a_rm_in_args) {
0060         a_args.remove("-Qt");
0061         a_args.remove("-qt");
0062       }
0063     } else if(a_args.is_arg("-SDL")||
0064               a_args.is_arg("-sdl")) {
0065       driver = "SDL";
0066       if(a_rm_in_args) {
0067         a_args.remove("-SDL");
0068         a_args.remove("-sdl");
0069       }
0070     } else if(a_args.is_arg("-Net")||
0071               a_args.is_arg("-net")) {
0072       driver = "Net";
0073       if(a_rm_in_args) {
0074         a_args.remove("-Net");
0075         a_args.remove("-net");
0076       }
0077     } else if(a_args.is_arg("-inex")) {
0078       driver = "inex";
0079       if(a_rm_in_args) {
0080         a_args.remove("-inex");
0081       }
0082     }
0083   }
0084 
0085   return driver;
0086 }
0087 
0088 inline bool window_size_from_args(const args& a_args,unsigned int& a_ww,unsigned int& a_wh) {
0089   // set a_ww,a_wh to some common window size (in pixels).
0090   // return true if a_ww,a_wh set from a_args, false if not.
0091   bool status = true;
0092   if(a_args.is_arg("-iPod")||a_args.is_arg("-iPhone")) {
0093     a_ww = 320;
0094     a_wh = 480;
0095   } else if(a_args.is_arg("-iPad")) {
0096     a_ww = 768;
0097     a_wh = 1024;
0098   } else if(a_args.is_arg("-iPhone4")) {
0099     a_ww = 640;
0100     a_wh = 960;
0101   } else if(a_args.is_arg("-wallino")) { //emulate LAL/wallino aspect ratio.
0102     a_ww = 1024;
0103     a_wh = 512;
0104   } else if(a_args.is_arg("-SGS")) { //Samsung Galaxy S
0105     //a_ww = 320;
0106     //a_wh = 533;
0107     a_ww = 480;
0108     a_wh = 800;
0109   } else {
0110     if(a_args.find<unsigned int>("-ww",a_ww)) {
0111       if(a_args.find<unsigned int>("-wh",a_wh)) return true;
0112       //A4 : we have ww but not wh. Have wh in order to have A4 landscape :
0113       a_wh = (unsigned int)(a_ww*(21.0f/29.7f)); //29.7/21 = 0.707
0114     } else { //we don't have ww.
0115       if(a_args.find<unsigned int>("-wh",a_wh)) {
0116         //A4 : we have wh but not ww. Have ww in order to have A4 landscape :
0117         a_ww = (unsigned int)(a_wh*(29.7f/21.0f));
0118       } else {
0119         //we have nothing. Take a ww of 1000 and wh (707) so that to have A4 landscape :
0120         a_ww = 1000;
0121         a_wh = (unsigned int)(a_ww*(21.0f/29.7f)); // have A4 landscape.
0122         status = false;
0123       }
0124     }
0125   }
0126   if(a_args.is_arg("-land")){
0127     unsigned int _ww = a_ww;
0128     unsigned int _wh = a_wh;
0129     a_ww = mx(_ww,_wh);
0130     a_wh = mn(_ww,_wh);
0131   }
0132   if(a_args.is_arg("-portrait")){
0133     unsigned int _ww = a_ww;
0134     unsigned int _wh = a_wh;
0135     a_ww = mn(_ww,_wh);
0136     a_wh = mx(_ww,_wh);
0137   }
0138   return status;
0139 }
0140 
0141 inline void remove_window_size_args(args& a_args) {
0142   //use with Wt apps.
0143   a_args.remove("-iPod");
0144   a_args.remove("-iPhone");
0145   a_args.remove("-iPad");
0146   a_args.remove("-iPhone4");
0147   a_args.remove("-SGS");
0148   a_args.remove("-ww");
0149   a_args.remove("-wh");
0150   a_args.remove("-land");
0151 }
0152 
0153 }
0154 
0155 #endif