source: Sophya/trunk/SophyaPI/PIext/pisiadw.cc@ 293

Last change on this file since 293 was 293, checked in by ercodmgr, 26 years ago

Adaptation aux "normes DPC", introduction des classes CmdExecutor, ...
Fenetre d'aide en lignes, gestion de modules, ... Reza 11/05/99

File size: 6.0 KB
Line 
1#include "machdefs.h"
2#include <stdlib.h>
3#include <stdio.h>
4#include <string.h>
5
6#include "perrors.h"
7#include "ctimer.h"
8
9#include "nbmath.h"
10
11#include "pistdimgapp.h"
12#include "nobjmgr.h"
13#include "servnobjm.h"
14
15
16
17/* ........................................................... */
18/* Classe ObjMgrWind interface de gestion d'objets nommes */
19/* ........................................................... */
20
21/* --Methode-- */
22ObjMgrWind::ObjMgrWind(PIStdImgApp *par)
23: PIWindow((PIMsgHandler *)par, "objmgr", PIWK_dialog,
24 400, 300, 250, 250)
25{
26int i;
27dap = par;
28
29int bsx, bsy;
30int tsx, tsy;
31int spx, spy;
32// On definit la taille a partir de la taille par defaut des composantes
33PIApplicationPrefCompSize(bsx, bsy);
34spx = bsx/4; spy = bsy/3;
35tsx = 5*bsx+6*spx; tsy = 7*bsy+4*spy;
36SetSize(tsx,tsy);
37objlist = new PIList(this, "objlist", tsx-spx, tsy-4*spy-bsy, spx/2, spy/2);
38objlist->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
39objlist->SetBorderWidth(2);
40
41int py = tsy-2*spy-bsy;
42int px = spx;
43mBut[0] = new PIButton(this, "Display", 100, bsx, bsy, px, py); px += (bsx+spx);
44mBut[1] = new PIButton(this, "Print", 200, bsx, bsy, px, py); px += (bsx+spx);
45mBut[2] = new PIButton(this, "SavePPF", 300, bsx, bsy, px, py); px += (bsx+spx);
46mBut[3] = new PIButton(this, "Delete", 400, bsx, bsy, px, py); px += (bsx+spx);
47mBut[4] = new PIButton(this, "Dismiss", 900, bsx, bsy, px, py); px += (bsx+spx);
48
49for(i=0; i<5; i++)
50 mBut[i]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
51
52// FinishCreate(); pas necessaire ?
53}
54
55/* --Methode-- */
56ObjMgrWind::~ObjMgrWind()
57{
58int i;
59delete objlist;
60for(i=0; i<5; i++) delete mBut[i];
61}
62
63/* --Methode-- */
64void ObjMgrWind::Show()
65{
66dap->SetBlocked();
67PIWindow::Show();
68return;
69}
70
71/* --Methode-- */
72void ObjMgrWind::Process(PIMessage msg, PIMsgHandler* /*sender*/, void* /*data*/)
73{
74
75 // PIMessage ssg = ModMsg(msg);
76msg = UserMsg(msg);
77if (msg == 900) {
78 dap->SetReady();
79 this->Hide();
80 return;
81}
82
83string nom = "";
84if ( (msg == 100) || (msg == 200) || (msg == 300) || (msg == 400) ) {
85 string sel = objlist->GetSelectionStr();
86 // size_t p = sel.find_first_not_of(" \t");
87 // if (p<0) p = 0;
88 size_t l = sel.length();
89 size_t q = sel.find_first_of(" \t");
90 if (q > l) q = l;
91 nom = sel.substr(0, q);
92}
93
94NamedObjMgr* om = dap->ObjMgr();
95if (om == NULL) return;
96if (nom == "") return;
97
98switch (msg)
99 {
100 case 100:
101 om->DisplayObj(nom);
102 break;
103 case 200:
104 om->PrintObj(nom);
105 break;
106 case 300:
107 if (dap->mPpfout) om->SaveObj(nom, *(dap->mPpfout));
108 break;
109 case 400:
110 om->DelObj(nom);
111 break;
112
113 case 900:
114 dap->SetReady();
115 Hide();
116 break;
117
118 default:
119 // printf("DEBUG/ObjMgrW::Process %d %d \n", (int)msg, (int)ssg);
120 break;
121 }
122
123return;
124}
125
126
127/* ........................................................... */
128/* Classe PPInMgrWind interface de gestion d'objets nommes */
129/* ........................................................... */
130
131/* --Methode-- */
132PPInMgrWind::PPInMgrWind(PIStdImgApp *par)
133: PIWindow((PIMsgHandler *)par, "PPF-FileManager", PIWK_dialog,
134 400, 300, 250, 250)
135{
136int i;
137dap = par;
138
139int bsx, bsy;
140int tsx, tsy;
141int spx, spy;
142// On definit la taille a partir de la taille par defaut des composantes
143PIApplicationPrefCompSize(bsx, bsy);
144spx = bsx/4; spy = bsy/3;
145bsx *= 1.25;
146ttx = tsx = 3*bsx+8*spx; tty = tsy = 7*bsy+5*spy;
147SetSize(tsx,tsy);
148
149mLab[0] = new PILabel(this, "filename", tsx-spx, bsy-spy, spx/2, spy/2);
150mLab[0]->SetLabel("");
151mLab[0]->SetBinding(PIBK_elastic, PIBK_elastic, PIBK_elastic,PIBK_elastic);
152mLab[0]->SetBorderWidth(1);
153
154polx = spx/2; poly = bsy+1.5*spy;
155tolx = tsx-spx; toly = tsy-2*bsy-5*spy;
156int py = tsy-2*spy-bsy;
157int px = 2*spx;
158mBut[0] = new PIButton(this, "Read", 2500, bsx, bsy, px, py); px += (bsx+2*spx);
159mBut[1] = new PIButton(this, "ReadAll", 2600, bsx, bsy, px, py); px += (bsx+2*spx);
160mBut[2] = new PIButton(this, "Close", 2700, bsx, bsy, px, py); px += (bsx+2*spx);
161
162for(i=0; i<3; i++)
163 mBut[i]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
164
165objlist = NULL;
166mLab[1] = NULL;
167mPin = NULL;
168
169// FinishCreate(); pas necessaire
170}
171
172/* --Methode-- */
173PPInMgrWind::~PPInMgrWind()
174{
175int i;
176if (objlist) delete objlist;
177delete mLab[0];
178for(i=0; i<3; i++) delete mBut[i];
179}
180
181/* --Methode-- */
182void PPInMgrWind::SetFile(string flnm)
183{
184char strg[128];
185char* nom;
186char noms[32];
187int i, cid, key, ln;
188
189bool ok = true;
190
191TRY {
192 mPin = new PInPersist(flnm);
193} CATCH(merr)
194 { printf("ObjMgrWind::SetFile Exception= %ld (%s) \n", (long)merr, PeidaExc(merr));
195 ok = false; } ENDTRY;
196
197if (!ok) { mPin = NULL; dap->SetReady(); return; }
198
199if (mPin->NbTags() < 1) {
200 delete mPin; mPin = NULL;
201 dap->ObjMgr()->ReadObj(flnm);
202 return;
203}
204
205if (objlist) delete objlist;
206SetSize(ttx,tty);
207mLab[0]->SetLabel(flnm);
208objlist = new PIList(this, "infileobjlist", tolx, toly, polx, poly);
209objlist->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
210objlist->SetBorderWidth(2);
211
212
213for(i=0; i<mPin->NbTags(); i++) {
214 key = mPin->TagKey(i, cid, ln);
215 if (ln <= 0) nom = "?";
216 else { strncpy(noms, mPin->TagName(i).c_str(), 31); noms[31] = '\0'; nom = noms; }
217 sprintf(strg, "%s (T=%s, Key=%d)", nom, dap->ObjMgr()->GetServiceObj()->PClassIdToClassName(cid), key);
218 objlist->AppendItem(strg, 5000+i);
219}
220
221}
222
223/* --Methode-- */
224void PPInMgrWind::Show()
225{
226if (mPin == NULL) return;
227dap->SetBlocked();
228PIWindow::Show();
229return;
230}
231
232/* --Methode-- */
233void PPInMgrWind::Process(PIMessage msg, PIMsgHandler* /*sender*/, void* /*data*/)
234{
235
236int sel;
237msg = UserMsg(msg);
238
239if (msg == 2700) {
240 delete mPin; mPin = NULL;
241 delete objlist; objlist = NULL;
242 dap->SetReady();
243 this->Hide();
244 return;
245}
246
247NamedObjMgr* om = dap->ObjMgr();
248switch (msg)
249 {
250 case 2500:
251 sel = (PIMessage)objlist->GetSelection() - 5000;
252 if (sel >= 0) om->ReadObj((*mPin), sel);
253 break;
254 case 2600:
255 om->ReadObj((*mPin), -1);
256 dap->SetReady();
257 this->Hide();
258 break;
259
260 default:
261 break;
262 }
263
264return;
265}
Note: See TracBrowser for help on using the repository browser.