source: Sophya/trunk/SophyaPI/PIext/cxxexecwin.cc@ 1251

Last change on this file since 1251 was 1251, checked in by ercodmgr, 25 years ago

fenetre pour CxxExecutor - Reza 24/10/2000

File size: 8.0 KB
Line 
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-- */
10CxxExecWind::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-- */
68CxxExecWind::~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-- */
78void CxxExecWind::Show()
79{
80 mLab->SetLabel(flnm);
81 PIWindow::Show();
82}
83
84/* --Methode-- */
85void 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();
94 // $CHECK$ REZA + CMV 23/10/2000 - Faire quelque chose de mieux ici
95 vector<string> vs;
96 int rc;
97 vs.push_back(mText->GetText());
98 rc = cxxex->FillUserCode(vs, 0);
99 if (rc) break;
100 rc = cxxex->CrFile();
101 if (rc) break;
102 rc = cxxex->Compile();
103 if (rc) break;
104 rc = cxxex->Link();
105 if (rc) break;
106 rc = cxxex->Call();
107 if (rc) break;
108 // End de $CHECK$ REZA + CMV 23/10/2000
109 mBut[0]->SetSensitive();
110 dap->SetReady();
111 break;
112 }
113
114 case 500: // Open File
115 pfc->AcceptNewFile(false);
116 pfc->SetMsg(5500);
117 dap->SetBlocked();
118 pfc->Show();
119 break;
120
121 case 5500: // Return from open-file dialog
122 dap->SetBusy();
123 if (data) {
124 flnm = pfc->GetFileName();
125 mLab->SetLabel(flnm);
126 // We have to read the file
127 mText->SetText("REZA A FAIRE \n Fichier non lu !");
128 }
129 dap->SetReady();
130 break;
131
132 case 600:
133 case 660:
134 if ( (UserMsg(msg) == 600) && (flnm.length() > 0) ) {
135 cerr << " REZA A FAIRE ! Il faut sauver le champ texte ds fichier "
136 << flnm << endl;
137 }
138 else {
139 pfc->AcceptNewFile(true);
140 pfc->SetMsg(5600);
141 dap->SetBlocked();
142 pfc->Show();
143 }
144 break;
145
146 case 5600: // Return from Save-file dialog
147 dap->SetBusy();
148 if (data) {
149 flnm = pfc->GetFileName();
150 mLab->SetLabel(flnm);
151 // We have to save to the file
152 cerr << " REZA A FAIRE ! Il faut sauver le champ texte ds fichier (2)"
153 << flnm << endl;
154 }
155 dap->SetReady();
156 break;
157
158 case 700: // Bouton Dismiss - On cache la fenetre
159 this->Hide();
160 break;
161 }
162
163 // In case of compile errors, we end-up here !
164 mBut[0]->SetSensitive();
165 dap->SetReady();
166 return;
167}
168
169// --------------------------------------------------------------------
170// --------------------------------------------------------------------
171// --------------------------------------------------------------------
172
173/* --Methode-- */
174CxxOptionWind::CxxOptionWind(PIStdImgApp* par, CxxExecutor * cxxexec)
175: PIWindow((PIMsgHandler *)par, "CxxOption", PIWK_normal, 400, 300, 150, 150)
176{
177
178 dap = par;
179 cxxex = cxxexec;
180
181 int bsx, bsy, szx, szy;
182 int px, py, spx, spy;
183 // On definit la taille a partir de la taille par defaut des composantes
184 PIApplicationPrefCompSize(bsx, bsy);
185 // On redefinit la taille de la fenetre
186 spx = bsx/6;
187 spy = bsy/6;
188 szx = 7*bsx+5*spx;
189 szy = 6*bsy+12*spy;
190 SetSize(szx, szy);
191
192// Creation de champs "labels"
193 px = (szx-6*bsx)/2;
194 py = 2*spy;
195 mTit = new PILabel(this, "CxxExecutor Options", bsx*6, bsy, bsx, py);
196 mTit->SetBorderWidth(1);
197
198 px = 2*spx;
199 py = 4*spy+bsy;
200 mLab[0] = new PILabel(this, "Include Files", bsx*2, bsy, px, py);
201 py += spy+bsy;
202 mLab[1] = new PILabel(this, "Compile Options", bsx*2, bsy, px, py);
203 py += spy+bsy;
204 mLab[2] = new PILabel(this, "Link Options", bsx*2, bsy, px, py);
205 py += spy+bsy;
206 mLab[3] = new PILabel(this, "Libraries", bsx*2, bsy, px, py);
207
208 px = 3*spx+2*bsx;
209 py = 4*spy+bsy;
210
211// Creation de champs textes
212 mText[0] = new PIText(this, "IncFiles", bsx*5, bsy, px, py);
213 mText[0]->SetText("");
214 py += spy+bsy;
215 mText[1] = new PIText(this, "CompOpt", bsx*5, bsy, px, py);
216 mText[1]->SetText("");
217 py += spy+bsy;
218 mText[2] = new PIText(this, "LinkOpt", bsx*5, bsy, px, py);
219 mText[2]->SetText("");
220 py += spy+bsy;
221 mText[3] = new PIText(this, "LinkLib", bsx*5, bsy, px, py);
222 mText[3]->SetText("");
223
224// Creation de bouton d'action
225
226 py += 3*spy+bsy;
227 px = (szx-6*bsx-6*spx)/2;
228 mBut[0] = new PIButton(this, "Set Options", 500, bsx*2, bsy, px, py);
229 px += 2*bsx+2*spx;
230 mBut[1] = new PIButton(this, "Get Option", 600, bsx*2, bsy, px, py);
231 px += 2*bsx+2*spx;
232 mBut[2] = new PIButton(this, "Dismiss", 700, bsx*2, bsy, px, py);
233
234// Taille et position proportionnelles a la taille de la fenetre pour les elements
235 mTit->SetBinding(PIBK_elastic , PIBK_elastic , PIBK_elastic , PIBK_elastic);
236
237 for(int i=0; i<4; i++) {
238 mLab[i]->SetBinding(PIBK_elastic , PIBK_elastic , PIBK_elastic , PIBK_elastic);
239
240 mText[i]->SetBinding(PIBK_elastic , PIBK_elastic , PIBK_elastic , PIBK_elastic);
241 }
242 for(int ii=0; ii<3; ii++)
243 mBut[ii]->SetBinding(PIBK_elastic , PIBK_elastic , PIBK_elastic , PIBK_elastic);
244
245}
246
247/* --Methode-- */
248CxxOptionWind::~CxxOptionWind()
249{
250 for(int i=0; i<4; i++) {
251 delete mLab[i];
252 delete mText[i];
253 }
254 delete mTit;
255 delete mBut[0];
256 delete mBut[1];
257 delete mBut[2];
258}
259
260
261/* --Methode-- */
262void CxxOptionWind::Show()
263{
264 mText[0]->SetText(cxxex->GetInclude());
265 mText[1]->SetText(cxxex->GetCompileOpt());
266 mText[2]->SetText(cxxex->GetLinkOpt());
267 mText[2]->SetText(cxxex->GetLinkLibs());
268 PIWindow::Show();
269}
270
271/* --Methode-- */
272void CxxOptionWind::Process(PIMessage msg, PIMsgHandler* /*sender*/, void* /*data*/)
273{
274
275 string opt;
276
277 switch (UserMsg(msg)) {
278
279 case 500: // Bouton Set Options
280// On recupere les textes des 3 champs :
281 opt = mText[0]->GetText();
282 cxxex->FillInclude(opt);
283 opt = mText[1]->GetText();
284 cxxex->FillCompileOpt(opt);
285 opt = mText[2]->GetText();
286 cxxex->FillLinkOpt(opt);
287 opt = mText[3]->GetText();
288 cxxex->FillLinkLibs(opt);
289 break;
290
291 case 600: // Bouton Get Options
292 mText[0]->SetText(cxxex->GetInclude());
293 mText[1]->SetText(cxxex->GetCompileOpt());
294 mText[2]->SetText(cxxex->GetLinkOpt());
295 mText[2]->SetText(cxxex->GetLinkLibs());
296 break;
297
298 case 700: // Bouton Dismiss - On cache la fenetre
299 this->Hide();
300 break;
301 }
302
303return;
304}
305
306
Note: See TracBrowser for help on using the repository browser.