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5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

  1 // Copyright (C) 2010, Guy Barrand. All rights reserved.
  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,bool a_rm_in_args){
 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& a_args,unsigned int& a_ww,unsigned int& a_wh) {
 89   // set a_ww,a_wh to some common window size (in pixels).
 90   // return true if a_ww,a_wh set from a_args, false if not.
 91   bool status = true;
 92   if(a_args.is_arg("-iPod")||a_args.is_arg("-iPhone")) {
 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")) { //emulate LAL/wallino aspect ratio.
102     a_ww = 1024;
103     a_wh = 512;
104   } else if(a_args.is_arg("-SGS")) { //Samsung Galaxy S
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)) return true;
112       //A4 : we have ww but not wh. Have wh in order to have A4 landscape :
113       a_wh = (unsigned int)(a_ww*(21.0f/29.7f)); //29.7/21 = 0.707
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 in order to have A4 landscape :
117         a_ww = (unsigned int)(a_wh*(29.7f/21.0f));
118       } else {
119         //we have nothing. Take a ww of 1000 and wh (707) so that to have A4 landscape :
120         a_ww = 1000;
121         a_wh = (unsigned int)(a_ww*(21.0f/29.7f)); // have A4 landscape.
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_args) {
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