[1251] | 1 | // Classe CxxExecWindow : Control Window for CxxExecutor
|
---|
| 2 | // Classe CxxExecOptWindow : Option Window for CxxExecutor
|
---|
| 3 | // (c) DAPNIA (CEA) LAL (IN2P3/CNRS)
|
---|
| 4 | // R. Ansari 10/2000
|
---|
| 5 |
|
---|
| 6 | #include "cxxexecutor.h"
|
---|
| 7 | #include "cxxexecwin.h"
|
---|
| 8 |
|
---|
| 9 | /* --Methode-- */
|
---|
| 10 | CxxExecWind::CxxExecWind(PIStdImgApp* par, CxxExecutor * cxxexec)
|
---|
| 11 | : PIWindow((PIMsgHandler *)par, "CxxExecutor", PIWK_normal, 400, 300, 150, 150)
|
---|
| 12 | {
|
---|
| 13 | dap = par;
|
---|
| 14 | cxxex = cxxexec;
|
---|
| 15 |
|
---|
| 16 | int bsx, bsy, szx, szy;
|
---|
| 17 | int px, py, spx, spy;
|
---|
| 18 | // On definit la taille a partir de la taille par defaut des composantes
|
---|
| 19 | PIApplicationPrefCompSize(bsx, bsy);
|
---|
| 20 | // On redefinit la taille de la fenetre
|
---|
| 21 | spx = bsx/6;
|
---|
| 22 | spy = bsy/6;
|
---|
| 23 | szx = 8*bsx+2*spx;
|
---|
| 24 | szy = 10*bsy+8*spy;
|
---|
| 25 | SetSize(szx, szy);
|
---|
| 26 |
|
---|
| 27 | // Creation de champs "labels"
|
---|
| 28 | px = (szx-6*bsx)/2;
|
---|
| 29 | py = 2*spy;
|
---|
| 30 | mLab = new PILabel(this, "File", bsx*6, bsy, bsx, py);
|
---|
| 31 | mLab->SetLabel("No File Name");
|
---|
| 32 | mLab->SetBorderWidth(1);
|
---|
| 33 | mLab->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
|
---|
| 34 |
|
---|
| 35 | px = spx;
|
---|
| 36 | py = 4*spy+bsy;
|
---|
| 37 |
|
---|
| 38 | // Creation du champ texte
|
---|
| 39 | mText = new PIText(this, "helptext", true, true, bsx*8, 8*bsy, px, py);
|
---|
| 40 | // mText->SetMutiLineMode(true);
|
---|
| 41 | mText->SetTextEditable(true);
|
---|
| 42 | mText->SetText("");
|
---|
| 43 | mText->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
|
---|
| 44 |
|
---|
| 45 | // Creation de bouton d'action
|
---|
| 46 |
|
---|
| 47 | py += 2*spy+8*bsy;
|
---|
| 48 | px = (szx-6*bsx-8*spx)/2;
|
---|
| 49 | mBut[0] = new PIButton(this, "Exec", 400, bsx*1.2, bsy, px, py);
|
---|
| 50 | px += 1.2*bsx+2*spx;
|
---|
| 51 | mBut[1] = new PIButton(this, "Open", 500, bsx*1.2, bsy, px, py);
|
---|
| 52 | px += 1.2*bsx+2*spx;
|
---|
| 53 | mBut[2] = new PIButton(this, "Save", 600, bsx*1.2, bsy, px, py);
|
---|
| 54 | px += 1.2*bsx+2*spx;
|
---|
| 55 | mBut[3] = new PIButton(this, "Save As", 660, bsx*1.2, bsy, px, py);
|
---|
| 56 | px += 1.2*bsx+2*spx;
|
---|
| 57 | mBut[4] = new PIButton(this, "Dismiss", 700, bsx*1.2, bsy, px, py);
|
---|
| 58 |
|
---|
| 59 | // Taille et position proportionnelles a la taille de la fenetre pour les elements
|
---|
| 60 | for(int ii=0; ii<5; ii++)
|
---|
| 61 | mBut[ii]->SetBinding(PIBK_elastic , PIBK_elastic , PIBK_elastic , PIBK_elastic);
|
---|
| 62 |
|
---|
| 63 | // Notre File Chooser
|
---|
| 64 | pfc = new PIFileChooser(this,"CxxExec-FileChooser", 5000);
|
---|
| 65 | }
|
---|
| 66 |
|
---|
| 67 | /* --Methode-- */
|
---|
| 68 | CxxExecWind::~CxxExecWind()
|
---|
| 69 | {
|
---|
| 70 | delete mLab;
|
---|
| 71 | delete mText;
|
---|
| 72 | for(int i=0; i<5; i++) delete mBut[i];
|
---|
| 73 | delete pfc;
|
---|
| 74 | }
|
---|
| 75 |
|
---|
| 76 |
|
---|
| 77 | /* --Methode-- */
|
---|
| 78 | void CxxExecWind::Show()
|
---|
| 79 | {
|
---|
| 80 | mLab->SetLabel(flnm);
|
---|
| 81 | PIWindow::Show();
|
---|
| 82 | }
|
---|
| 83 |
|
---|
| 84 | /* --Methode-- */
|
---|
| 85 | void CxxExecWind::Process(PIMessage msg, PIMsgHandler* /*sender*/, void* data)
|
---|
| 86 | {
|
---|
| 87 |
|
---|
| 88 | switch (UserMsg(msg)) {
|
---|
| 89 |
|
---|
| 90 | case 400: // Bouton Execute C++
|
---|
| 91 | {
|
---|
| 92 | dap->SetBusy();
|
---|
| 93 | mBut[0]->SetUnSensitive();
|
---|
[1262] | 94 | cxxex->ExecuteCxx(mText->GetText());
|
---|
[1251] | 95 | mBut[0]->SetSensitive();
|
---|
| 96 | dap->SetReady();
|
---|
| 97 | break;
|
---|
| 98 | }
|
---|
| 99 |
|
---|
| 100 | case 500: // Open File
|
---|
| 101 | pfc->AcceptNewFile(false);
|
---|
| 102 | pfc->SetMsg(5500);
|
---|
| 103 | dap->SetBlocked();
|
---|
| 104 | pfc->Show();
|
---|
| 105 | break;
|
---|
| 106 |
|
---|
| 107 | case 5500: // Return from open-file dialog
|
---|
| 108 | dap->SetBusy();
|
---|
| 109 | if (data) {
|
---|
| 110 | flnm = pfc->GetFileName();
|
---|
| 111 | mLab->SetLabel(flnm);
|
---|
| 112 | // We have to read the file
|
---|
| 113 | mText->SetText("REZA A FAIRE \n Fichier non lu !");
|
---|
| 114 | }
|
---|
| 115 | dap->SetReady();
|
---|
| 116 | break;
|
---|
| 117 |
|
---|
| 118 | case 600:
|
---|
| 119 | case 660:
|
---|
| 120 | if ( (UserMsg(msg) == 600) && (flnm.length() > 0) ) {
|
---|
| 121 | cerr << " REZA A FAIRE ! Il faut sauver le champ texte ds fichier "
|
---|
| 122 | << flnm << endl;
|
---|
| 123 | }
|
---|
| 124 | else {
|
---|
| 125 | pfc->AcceptNewFile(true);
|
---|
| 126 | pfc->SetMsg(5600);
|
---|
| 127 | dap->SetBlocked();
|
---|
| 128 | pfc->Show();
|
---|
| 129 | }
|
---|
| 130 | break;
|
---|
| 131 |
|
---|
| 132 | case 5600: // Return from Save-file dialog
|
---|
| 133 | dap->SetBusy();
|
---|
| 134 | if (data) {
|
---|
| 135 | flnm = pfc->GetFileName();
|
---|
| 136 | mLab->SetLabel(flnm);
|
---|
| 137 | // We have to save to the file
|
---|
| 138 | cerr << " REZA A FAIRE ! Il faut sauver le champ texte ds fichier (2)"
|
---|
| 139 | << flnm << endl;
|
---|
| 140 | }
|
---|
| 141 | dap->SetReady();
|
---|
| 142 | break;
|
---|
| 143 |
|
---|
| 144 | case 700: // Bouton Dismiss - On cache la fenetre
|
---|
| 145 | this->Hide();
|
---|
| 146 | break;
|
---|
| 147 | }
|
---|
| 148 |
|
---|
| 149 | // In case of compile errors, we end-up here !
|
---|
| 150 | mBut[0]->SetSensitive();
|
---|
| 151 | dap->SetReady();
|
---|
| 152 | return;
|
---|
| 153 | }
|
---|
| 154 |
|
---|
| 155 | // --------------------------------------------------------------------
|
---|
| 156 | // --------------------------------------------------------------------
|
---|
| 157 | // --------------------------------------------------------------------
|
---|
| 158 |
|
---|
| 159 | /* --Methode-- */
|
---|
| 160 | CxxOptionWind::CxxOptionWind(PIStdImgApp* par, CxxExecutor * cxxexec)
|
---|
| 161 | : PIWindow((PIMsgHandler *)par, "CxxOption", PIWK_normal, 400, 300, 150, 150)
|
---|
| 162 | {
|
---|
| 163 |
|
---|
| 164 | dap = par;
|
---|
| 165 | cxxex = cxxexec;
|
---|
| 166 |
|
---|
| 167 | int bsx, bsy, szx, szy;
|
---|
| 168 | int px, py, spx, spy;
|
---|
| 169 | // On definit la taille a partir de la taille par defaut des composantes
|
---|
| 170 | PIApplicationPrefCompSize(bsx, bsy);
|
---|
| 171 | // On redefinit la taille de la fenetre
|
---|
| 172 | spx = bsx/6;
|
---|
| 173 | spy = bsy/6;
|
---|
| 174 | szx = 7*bsx+5*spx;
|
---|
| 175 | szy = 6*bsy+12*spy;
|
---|
| 176 | SetSize(szx, szy);
|
---|
| 177 |
|
---|
| 178 | // Creation de champs "labels"
|
---|
| 179 | px = (szx-6*bsx)/2;
|
---|
| 180 | py = 2*spy;
|
---|
| 181 | mTit = new PILabel(this, "CxxExecutor Options", bsx*6, bsy, bsx, py);
|
---|
| 182 | mTit->SetBorderWidth(1);
|
---|
| 183 |
|
---|
| 184 | px = 2*spx;
|
---|
| 185 | py = 4*spy+bsy;
|
---|
| 186 | mLab[0] = new PILabel(this, "Include Files", bsx*2, bsy, px, py);
|
---|
| 187 | py += spy+bsy;
|
---|
| 188 | mLab[1] = new PILabel(this, "Compile Options", bsx*2, bsy, px, py);
|
---|
| 189 | py += spy+bsy;
|
---|
| 190 | mLab[2] = new PILabel(this, "Link Options", bsx*2, bsy, px, py);
|
---|
| 191 | py += spy+bsy;
|
---|
| 192 | mLab[3] = new PILabel(this, "Libraries", bsx*2, bsy, px, py);
|
---|
| 193 |
|
---|
| 194 | px = 3*spx+2*bsx;
|
---|
| 195 | py = 4*spy+bsy;
|
---|
| 196 |
|
---|
| 197 | // Creation de champs textes
|
---|
| 198 | mText[0] = new PIText(this, "IncFiles", bsx*5, bsy, px, py);
|
---|
| 199 | mText[0]->SetText("");
|
---|
| 200 | py += spy+bsy;
|
---|
| 201 | mText[1] = new PIText(this, "CompOpt", bsx*5, bsy, px, py);
|
---|
| 202 | mText[1]->SetText("");
|
---|
| 203 | py += spy+bsy;
|
---|
| 204 | mText[2] = new PIText(this, "LinkOpt", bsx*5, bsy, px, py);
|
---|
| 205 | mText[2]->SetText("");
|
---|
| 206 | py += spy+bsy;
|
---|
| 207 | mText[3] = new PIText(this, "LinkLib", bsx*5, bsy, px, py);
|
---|
| 208 | mText[3]->SetText("");
|
---|
| 209 |
|
---|
| 210 | // Creation de bouton d'action
|
---|
| 211 |
|
---|
| 212 | py += 3*spy+bsy;
|
---|
| 213 | px = (szx-6*bsx-6*spx)/2;
|
---|
| 214 | mBut[0] = new PIButton(this, "Set Options", 500, bsx*2, bsy, px, py);
|
---|
| 215 | px += 2*bsx+2*spx;
|
---|
| 216 | mBut[1] = new PIButton(this, "Get Option", 600, bsx*2, bsy, px, py);
|
---|
| 217 | px += 2*bsx+2*spx;
|
---|
| 218 | mBut[2] = new PIButton(this, "Dismiss", 700, bsx*2, bsy, px, py);
|
---|
| 219 |
|
---|
| 220 | // Taille et position proportionnelles a la taille de la fenetre pour les elements
|
---|
| 221 | mTit->SetBinding(PIBK_elastic , PIBK_elastic , PIBK_elastic , PIBK_elastic);
|
---|
| 222 |
|
---|
| 223 | for(int i=0; i<4; i++) {
|
---|
| 224 | mLab[i]->SetBinding(PIBK_elastic , PIBK_elastic , PIBK_elastic , PIBK_elastic);
|
---|
| 225 |
|
---|
| 226 | mText[i]->SetBinding(PIBK_elastic , PIBK_elastic , PIBK_elastic , PIBK_elastic);
|
---|
| 227 | }
|
---|
| 228 | for(int ii=0; ii<3; ii++)
|
---|
| 229 | mBut[ii]->SetBinding(PIBK_elastic , PIBK_elastic , PIBK_elastic , PIBK_elastic);
|
---|
| 230 |
|
---|
| 231 | }
|
---|
| 232 |
|
---|
| 233 | /* --Methode-- */
|
---|
| 234 | CxxOptionWind::~CxxOptionWind()
|
---|
| 235 | {
|
---|
| 236 | for(int i=0; i<4; i++) {
|
---|
| 237 | delete mLab[i];
|
---|
| 238 | delete mText[i];
|
---|
| 239 | }
|
---|
| 240 | delete mTit;
|
---|
| 241 | delete mBut[0];
|
---|
| 242 | delete mBut[1];
|
---|
| 243 | delete mBut[2];
|
---|
| 244 | }
|
---|
| 245 |
|
---|
| 246 |
|
---|
| 247 | /* --Methode-- */
|
---|
| 248 | void CxxOptionWind::Show()
|
---|
| 249 | {
|
---|
| 250 | mText[0]->SetText(cxxex->GetInclude());
|
---|
| 251 | mText[1]->SetText(cxxex->GetCompileOpt());
|
---|
| 252 | mText[2]->SetText(cxxex->GetLinkOpt());
|
---|
| 253 | mText[2]->SetText(cxxex->GetLinkLibs());
|
---|
| 254 | PIWindow::Show();
|
---|
| 255 | }
|
---|
| 256 |
|
---|
| 257 | /* --Methode-- */
|
---|
| 258 | void CxxOptionWind::Process(PIMessage msg, PIMsgHandler* /*sender*/, void* /*data*/)
|
---|
| 259 | {
|
---|
| 260 |
|
---|
| 261 | string opt;
|
---|
| 262 |
|
---|
| 263 | switch (UserMsg(msg)) {
|
---|
| 264 |
|
---|
| 265 | case 500: // Bouton Set Options
|
---|
| 266 | // On recupere les textes des 3 champs :
|
---|
| 267 | opt = mText[0]->GetText();
|
---|
| 268 | cxxex->FillInclude(opt);
|
---|
| 269 | opt = mText[1]->GetText();
|
---|
| 270 | cxxex->FillCompileOpt(opt);
|
---|
| 271 | opt = mText[2]->GetText();
|
---|
| 272 | cxxex->FillLinkOpt(opt);
|
---|
| 273 | opt = mText[3]->GetText();
|
---|
| 274 | cxxex->FillLinkLibs(opt);
|
---|
| 275 | break;
|
---|
| 276 |
|
---|
| 277 | case 600: // Bouton Get Options
|
---|
| 278 | mText[0]->SetText(cxxex->GetInclude());
|
---|
| 279 | mText[1]->SetText(cxxex->GetCompileOpt());
|
---|
| 280 | mText[2]->SetText(cxxex->GetLinkOpt());
|
---|
| 281 | mText[2]->SetText(cxxex->GetLinkLibs());
|
---|
| 282 | break;
|
---|
| 283 |
|
---|
| 284 | case 700: // Bouton Dismiss - On cache la fenetre
|
---|
| 285 | this->Hide();
|
---|
| 286 | break;
|
---|
| 287 | }
|
---|
| 288 |
|
---|
| 289 | return;
|
---|
| 290 | }
|
---|
| 291 |
|
---|
| 292 |
|
---|