1 | #include <stdlib.h>
|
---|
2 | #include <stdio.h>
|
---|
3 | #include <string.h>
|
---|
4 |
|
---|
5 | #include <iostream.h>
|
---|
6 |
|
---|
7 | #include "pisysdep.h"
|
---|
8 | #include PIAPP_H
|
---|
9 | #include PIWIN_H
|
---|
10 | #include PIMENU_H
|
---|
11 | #include PISTDWDG_H
|
---|
12 | #include PIBWDG_H
|
---|
13 | #include "piscdrawwdg.h"
|
---|
14 | #include "pievthandler.h"
|
---|
15 | #include "parradapter.h"
|
---|
16 |
|
---|
17 |
|
---|
18 | /* Exemple d'utilisation PIBaseWdg - Creation d'une nouvelle composante graphique */
|
---|
19 |
|
---|
20 | // ---- Declaration de la classe ExBWdg --------
|
---|
21 | class ExBWdg : public PIBaseWdg
|
---|
22 | {
|
---|
23 | public:
|
---|
24 | // Les methodes ...
|
---|
25 |
|
---|
26 | ExBWdg(PIContainerGen *par, char *nom,
|
---|
27 | int sx=10, int sy=10, int px=0, int py=0);
|
---|
28 | virtual ~ExBWdg();
|
---|
29 |
|
---|
30 | // Traitement des evenements
|
---|
31 | // virtual void Resize();
|
---|
32 | virtual void Draw(PIGraphic* g, int x0, int y0, int dx, int dy);
|
---|
33 |
|
---|
34 | virtual void But1Press(int x, int y);
|
---|
35 | virtual void But1Release(int x, int y);
|
---|
36 | virtual void But2Press(int x, int y);
|
---|
37 | virtual void But2Release(int x, int y);
|
---|
38 | virtual void But3Press(int x, int y);
|
---|
39 | virtual void But3Release(int x, int y);
|
---|
40 | virtual void Keyboard(int key, PIKeyModifier kmod);
|
---|
41 |
|
---|
42 | protected:
|
---|
43 | int mfnt, mmrk;
|
---|
44 | int nc;
|
---|
45 | char str[32];
|
---|
46 | };
|
---|
47 |
|
---|
48 |
|
---|
49 | /* ........................................................... */
|
---|
50 | /* Classe ExBWdg (Implementation des methodes) */
|
---|
51 | /* ........................................................... */
|
---|
52 |
|
---|
53 | /* --Methode-- */
|
---|
54 | ExBWdg::ExBWdg(PIContainerGen *par, char *nom,
|
---|
55 | int sx, int sy, int px, int py)
|
---|
56 | : PIBaseWdg(par, nom, sx, sy, px, py)
|
---|
57 |
|
---|
58 | {
|
---|
59 | mmrk = mfnt = nc = 0;
|
---|
60 | strcpy(str, "Hello !");
|
---|
61 | for(int i=strlen(str); i<20; i++) str[i] = ' ';
|
---|
62 | str[20] = '\0';
|
---|
63 |
|
---|
64 | ActivateKeyboard();
|
---|
65 | ActivateButton(1);
|
---|
66 | ActivateButton(2);
|
---|
67 | ActivateButton(3);
|
---|
68 | }
|
---|
69 |
|
---|
70 | /* --Methode-- */
|
---|
71 | ExBWdg::~ExBWdg()
|
---|
72 | {
|
---|
73 | }
|
---|
74 |
|
---|
75 | /* --Methode--
|
---|
76 | void ExBWdg::Resize()
|
---|
77 | {
|
---|
78 | }
|
---|
79 | */
|
---|
80 |
|
---|
81 | /* --Methode-- */
|
---|
82 | void ExBWdg::Draw(PIGraphicGen* g, int /*x0*/, int /*y0*/, int /*dx*/, int /*dy*/)
|
---|
83 | {
|
---|
84 | PIFontAtt att[3] = { PI_RomanFont, PI_BoldFont, PI_ItalicFont};
|
---|
85 | PIMarker pmk[9] = { PI_DotMarker , PI_PlusMarker, PI_CrossMarker,
|
---|
86 | PI_CircleMarker, PI_FCircleMarker,
|
---|
87 | PI_BoxMarker, PI_FBoxMarker,
|
---|
88 | PI_TriangleMarker, PI_FTriangleMarker };
|
---|
89 | EraseWindow();
|
---|
90 | g->SelFont(PI_NormalSizeFont, att[mfnt]);
|
---|
91 | g->SelMarker(8, pmk[mmrk]);
|
---|
92 |
|
---|
93 | g->SelLine(PI_NormalLine);
|
---|
94 | g->DrawBox(10,10, XSize()-20, YSize()-20);
|
---|
95 |
|
---|
96 | g->SelLine(PI_ThinLine);
|
---|
97 | g->DrawFBox(20, 20, 20, 20);
|
---|
98 | g->DrawCircle(30, 30, 15);
|
---|
99 |
|
---|
100 | g->SelForeground(PI_Red);
|
---|
101 | g->DrawFCircle(70, 30, 15);
|
---|
102 |
|
---|
103 | g->SelForeground(PI_Yellow);
|
---|
104 | g->DrawFBox(10, 60, 120, 20);
|
---|
105 |
|
---|
106 | PIFont f0;
|
---|
107 | g->SelFont(f0);
|
---|
108 | g->SelForeground(PI_Black);
|
---|
109 | g->DrawString(20, 110, str);
|
---|
110 | PIFont f(PI_TimesFont);
|
---|
111 | g->SelFont(f);
|
---|
112 | g->DrawString(20, 130, "Times-Font");
|
---|
113 | PIFont f2(14,PI_CourierFont,PI_BoldFont);
|
---|
114 | g->SelFont(f2);
|
---|
115 | g->DrawString(20, 150, "Courier-Font");
|
---|
116 | PIFont f3(14,PI_TimesFont,PI_BoldFont);
|
---|
117 | g->SelFont(f3);
|
---|
118 | g->DrawString(20, 170, "Times-Font-Bold");
|
---|
119 | PIFont f4(14,PI_HelveticaFont,PI_BoldFont);
|
---|
120 | g->SelFont(f4);
|
---|
121 | g->DrawString(20, 190, "Helvetica-Font");
|
---|
122 | PIFont f5(14,PI_SymbolFont,PI_BoldFont);
|
---|
123 | g->SelFont(f5);
|
---|
124 | g->DrawString(20, 210, "Symbol-Font");
|
---|
125 | g->SelFont(f0);
|
---|
126 |
|
---|
127 |
|
---|
128 | g->SelLine(PI_ThinLine);
|
---|
129 | g->DrawLine(20, 140, 50, 130);
|
---|
130 | g->SelLine(PI_NormalLine);
|
---|
131 | g->DrawLine(50, 140, 80, 130);
|
---|
132 | g->SelLine(PI_ThickLine);
|
---|
133 | g->DrawLine(80, 140, 110, 130);
|
---|
134 |
|
---|
135 | g->SelForeground(PI_Magenta);
|
---|
136 | g->DrawFCircle(120, 30, 15);
|
---|
137 | g->SelForeground(PI_Grey);
|
---|
138 | g->DrawFCircle(120, 60, 15);
|
---|
139 |
|
---|
140 |
|
---|
141 |
|
---|
142 |
|
---|
143 | PIGrCoord x[5] = { 20, 35, 50, 65, 80 };
|
---|
144 | PIGrCoord y[5] = { 150, 150, 150, 150, 150 };
|
---|
145 |
|
---|
146 | g->SelForeground(PI_Black);
|
---|
147 | g->DrawMarkers(x, y, 5);
|
---|
148 | return;
|
---|
149 | }
|
---|
150 |
|
---|
151 |
|
---|
152 | static char strbuff[128];
|
---|
153 | /* --Methode-- */
|
---|
154 | void ExBWdg::But1Press(int x, int y)
|
---|
155 | {
|
---|
156 | SelPointerShape(PI_CrossPointer);
|
---|
157 | sprintf(strbuff,"Pos X= %d Y= %d", x, y);
|
---|
158 | mWGrC->SelFont(PI_NormalSizeFont, PI_BoldFont);
|
---|
159 | mWGrC->DrawString(x+10, y, strbuff);
|
---|
160 | Send(Msg(), PIMsg_Active);
|
---|
161 | return;
|
---|
162 | }
|
---|
163 |
|
---|
164 | /* --Methode-- */
|
---|
165 | void ExBWdg::But1Release(int x, int y)
|
---|
166 | {
|
---|
167 | SelPointerShape(PI_ArrowPointer);
|
---|
168 | Refresh();
|
---|
169 | return;
|
---|
170 | }
|
---|
171 |
|
---|
172 | /* --Methode-- */
|
---|
173 | void ExBWdg::But2Press(int x, int y)
|
---|
174 | {
|
---|
175 | if (++mfnt > 2) mfnt = 0;
|
---|
176 | if (++mmrk > 8) mmrk = 0;
|
---|
177 | return;
|
---|
178 | }
|
---|
179 |
|
---|
180 | /* --Methode-- */
|
---|
181 | void ExBWdg::But2Release(int x, int y)
|
---|
182 | {
|
---|
183 | Refresh();
|
---|
184 | return;
|
---|
185 | }
|
---|
186 |
|
---|
187 | /* --Methode-- */
|
---|
188 | void ExBWdg::But3Press(int x, int y)
|
---|
189 | {
|
---|
190 | SelPointerShape(PI_HandPointer);
|
---|
191 | mWGrC->SelForeground(PI_Blue);
|
---|
192 | mWGrC->DrawFBox(XSize()/3, YSize()/3, XSize()/8, YSize()/8);
|
---|
193 | return;
|
---|
194 | }
|
---|
195 |
|
---|
196 | /* --Methode-- */
|
---|
197 | void ExBWdg::But3Release(int x, int y)
|
---|
198 | {
|
---|
199 | mWGrC->SelForeground(PI_White);
|
---|
200 | mWGrC->DrawFBox(XSize()/3, YSize()/3, XSize()/8, YSize()/8);
|
---|
201 | mWGrC->SelForeground(PI_Black);
|
---|
202 | SelPointerShape(PI_ArrowPointer);
|
---|
203 | return;
|
---|
204 | }
|
---|
205 |
|
---|
206 | /* --Methode-- */
|
---|
207 | void ExBWdg::Keyboard(int key, PIKeyModifier kmod)
|
---|
208 | {
|
---|
209 | str[nc] = key; str[nc+1] = '\0';
|
---|
210 | if (++nc > 30) nc = 0;
|
---|
211 | char buf[16];
|
---|
212 |
|
---|
213 | if (key == PIK_Return) { Refresh(); nc = 0; return; }
|
---|
214 | mWGrC->SelFont(PI_NormalSizeFont, PI_BoldFont);
|
---|
215 | sprintf(buf," %c (%3d) ", (char) key, key, (int)kmod);
|
---|
216 | mWGrC->DrawOpaqueString(20, 75, buf);
|
---|
217 |
|
---|
218 | if ( (kmod == PIKM_Alt) && (key == 'c') ) {
|
---|
219 | printf("ExBWdg::Keyboard: Test-Copy ... \n");
|
---|
220 | ClaimSelection();
|
---|
221 | }
|
---|
222 | if ( (kmod == PIKM_Alt) && (key == 'v') ) {
|
---|
223 | printf("ExBWdg::Keyboard: Test-Paste ... \n");
|
---|
224 | RequestSelection();
|
---|
225 | }
|
---|
226 |
|
---|
227 | return;
|
---|
228 | }
|
---|
229 |
|
---|
230 | // ----- Exemple d'une classe heritant de PIScDrawWdg ----
|
---|
231 | /* ........................................................... */
|
---|
232 | /* Classe ScSample */
|
---|
233 | /* ........................................................... */
|
---|
234 |
|
---|
235 | class ScSample : public PIScDrawWdg {
|
---|
236 | public:
|
---|
237 | ScSample(PIContainerGen *par, char *nom,
|
---|
238 | int sx=10, int sy=10, int px=0, int py=0);
|
---|
239 | virtual ~ScSample();
|
---|
240 | };
|
---|
241 |
|
---|
242 | static double fpol(double x) {return (0.3*x*x*x-x*x+7.);}
|
---|
243 | static float xpts[10] = {-2.4, -2 , -1., 1., 1.7, 2.2, 3., 3.75, 4.3, 4.8};
|
---|
244 | static float ypts[10] = {-5 , -1.5, 2.5, 5., 8.0, 12., 9., 6.00, 2.2, -3.0};
|
---|
245 |
|
---|
246 | ScSample::ScSample(PIContainerGen *par, char *nom,
|
---|
247 | int sx, int sy, int px, int py)
|
---|
248 | :PIScDrawWdg(par, nom, sx, sy, px, py)
|
---|
249 |
|
---|
250 | {
|
---|
251 | // Definition des limites
|
---|
252 | SetLimits(-3,5,-10,15);
|
---|
253 |
|
---|
254 | // Creation et ajout d'un drawer de fonctions
|
---|
255 | PIFuncDrawer* mfd = new PIFuncDrawer(fpol);
|
---|
256 | mfd->SetColAtt(PI_Blue);
|
---|
257 | mfd->SetLineAtt(PI_NormalLine);
|
---|
258 | AddScDrawer(mfd,true);
|
---|
259 |
|
---|
260 | // Creation et ajout d'un drawer de points
|
---|
261 | PIYfXDrawer* mxyd = new PIYfXDrawer(new P1DAdapter<float>(xpts, 10, false),
|
---|
262 | new P1DAdapter<float>(ypts, 10, false), true);
|
---|
263 | mxyd->SetColAtt(PI_Magenta);
|
---|
264 | mxyd->SetMarkerAtt(7, PI_FBoxMarker);
|
---|
265 | AddScDrawer(mxyd, true);
|
---|
266 |
|
---|
267 | // Ajout de texte
|
---|
268 | BaseDrawer()->SetFontAtt(PI_NormalSizeFont, PI_BoldFont);
|
---|
269 | BaseDrawer()->ElAddText(-2.8, 12., "---- ScSample ----", PI_Red);
|
---|
270 | BaseDrawer()->ElAddText(-2.8, 10., "f(x)=0.3*x^3-x^2+7.", PI_Red);
|
---|
271 |
|
---|
272 | SetAxesFlags(kAxesDflt);
|
---|
273 | }
|
---|
274 |
|
---|
275 | ScSample::~ScSample()
|
---|
276 | {
|
---|
277 | }
|
---|
278 |
|
---|
279 | // ----------- Une classe EventHandler ----------
|
---|
280 | class MyEvHandler : public PIEventHandler {
|
---|
281 | public :
|
---|
282 | MyEvHandler();
|
---|
283 | ~MyEvHandler();
|
---|
284 | virtual void Draw(PIGraphic* g, int x0, int y0, int dx, int dy);
|
---|
285 | virtual void ProcessEvent();
|
---|
286 | inline bool GrabOK() { return(grabok); }
|
---|
287 |
|
---|
288 | protected :
|
---|
289 | PIScreenBuffer* mscb;
|
---|
290 | int mposx, mposy;
|
---|
291 | int mposx2, mposy2;
|
---|
292 | int msx, msy;
|
---|
293 | bool grabok;
|
---|
294 | };
|
---|
295 |
|
---|
296 | /* --Methode-- */
|
---|
297 | MyEvHandler::MyEvHandler()
|
---|
298 | : PIEventHandler()
|
---|
299 | {
|
---|
300 | mscb = new PIScreenBuffer(100, 100);
|
---|
301 | msx = 100; msy = 100;
|
---|
302 | mposx = mposy = 0;
|
---|
303 | mposx2 = mposy2 = 0;
|
---|
304 | grabok = false;
|
---|
305 | }
|
---|
306 |
|
---|
307 | /* --Methode-- */
|
---|
308 | MyEvHandler::~MyEvHandler()
|
---|
309 | {
|
---|
310 | delete mscb;
|
---|
311 | }
|
---|
312 |
|
---|
313 | /* --Methode-- */
|
---|
314 | void MyEvHandler::Draw(PIGraphic* g, int, int, int, int)
|
---|
315 | {
|
---|
316 | if (GrabOK()) {
|
---|
317 | printf("MyEvHandler::Draw() : Copying from ScreenBuffer to wdg (%lx) \n", (unsigned long)CurrentWdg());
|
---|
318 | mscb->CopyToWdg(CurrentWdg(), 0, 0, msx, msy, CurrentWdg()->XSize()/2, CurrentWdg()->YSize()/2);
|
---|
319 | }
|
---|
320 | else printf("MyEvHandler::Draw() : Grab first from source \n");
|
---|
321 | }
|
---|
322 |
|
---|
323 | /* --Methode-- */
|
---|
324 | void MyEvHandler::ProcessEvent()
|
---|
325 | {
|
---|
326 | printf("MyEvHandler::ProcessEvent() \n");
|
---|
327 | switch (EventType()) {
|
---|
328 |
|
---|
329 | case PIEvent_But3Press :
|
---|
330 | mposx = GetPosX();
|
---|
331 | mposy = GetPosY();
|
---|
332 | break;
|
---|
333 |
|
---|
334 | case PIEvent_But3Release :
|
---|
335 | mposx2 = GetPosX();
|
---|
336 | mposy2 = GetPosY();
|
---|
337 | printf("MyEvHandler::ProcessEvent(): Rectangle(%d,%d - %d,%d) \n", mposx, mposy, mposx2, mposy2);
|
---|
338 | // ((PIBaseWdg*)CurrentWdg())->WindowGraphic()->DrawBox(mposx, mposy, (mposx2-mposx), (mposy2-mposy));
|
---|
339 | break;
|
---|
340 |
|
---|
341 | case PIEvent_Keyboard :
|
---|
342 | if ((GetKeyMod() == PIKM_Alt) && ((GetKey() == 'G') || (GetKey() == 'g')) ) {
|
---|
343 | printf("MyEvHandler::ProcessEvent(): Grabbing(%dx%d) from Wdg(%lx)@(%d,%d) \n",
|
---|
344 | msx, msy, (unsigned long)CurrentWdg(), mposx, mposy);
|
---|
345 | mscb->CopyFromWdg(CurrentWdg(), mposx, mposy, msx, msy, 0, 0);
|
---|
346 | grabok = true;
|
---|
347 | }
|
---|
348 | break;
|
---|
349 |
|
---|
350 | default :
|
---|
351 | printf("MyEvHandler::ProcessEvent(): Unexpected Event (Type = %d) received \n", (int)EventType());
|
---|
352 | break;
|
---|
353 | }
|
---|
354 |
|
---|
355 | return;
|
---|
356 | }
|
---|
357 |
|
---|
358 | /* ........................................................... */
|
---|
359 | /* Classe PITApp */
|
---|
360 | /* ........................................................... */
|
---|
361 | class PITApp : public PIApplication {
|
---|
362 | public:
|
---|
363 | PITApp(int narg=0, char* arg[]=NULL);
|
---|
364 | ~PITApp();
|
---|
365 | virtual void Process(PIMessage msg, PIMsgHandler* sender, void* data=NULL);
|
---|
366 | private :
|
---|
367 | PIMenu* m[2];
|
---|
368 | PIText* txt;
|
---|
369 | MyEvHandler* evh;
|
---|
370 | PIWindow* mcurwin;
|
---|
371 | PIWdg* mdrhw;
|
---|
372 | PIWdg* mevhw;
|
---|
373 | PIWdg* mcurw;
|
---|
374 | };
|
---|
375 |
|
---|
376 |
|
---|
377 | /* --Methode-- */
|
---|
378 | PITApp::PITApp(int narg, char* arg[])
|
---|
379 | : PIApplication(300, 100, narg, arg)
|
---|
380 | {
|
---|
381 |
|
---|
382 | // Menus, les numeros ds AppendItem sont les numeros de messages
|
---|
383 | // qui seront passes a Process() et permettent d'identifier l'action
|
---|
384 |
|
---|
385 | // Creation du premier menu
|
---|
386 |
|
---|
387 | m[0] = new PIMenu(Menubar(),"Actions");
|
---|
388 | m[0]->AppendItem("Info", 10101);
|
---|
389 | m[0]->AppendItem("New ExBwdg", 10102);
|
---|
390 | m[0]->AppendItem("New ScSample", 10103);
|
---|
391 | m[0]->AppendItem("->eps", 10111);
|
---|
392 | m[0]->AppendItem("Exit", 10105);
|
---|
393 | // On accroche le menu au Menubar
|
---|
394 | AppendMenu(m[0]);
|
---|
395 |
|
---|
396 | m[1] = new PIMenu(Menubar(),"Edit");
|
---|
397 | m[1]->AppendItem("Copy", 10201);
|
---|
398 | m[1]->AppendItem("Paste", 10202);
|
---|
399 | // On accroche le menu au Menubar
|
---|
400 | AppendMenu(m[1]);
|
---|
401 |
|
---|
402 | // Creation d' zone texte multiligne
|
---|
403 | txt = new PIText(MainWin(), "mltext", true, true, 290, 90, 5, 5);
|
---|
404 | txt->SetBinding(PIBK_elastic,PIBK_elastic,PIBK_elastic,PIBK_elastic);
|
---|
405 | // txt->SetMutiLineMode(true);
|
---|
406 | txt->SetTextEditable(false);
|
---|
407 | txt->SetText("");
|
---|
408 |
|
---|
409 | evh = new MyEvHandler;
|
---|
410 | mcurwin = NULL;
|
---|
411 | mcurw = NULL;
|
---|
412 | mdrhw = NULL;
|
---|
413 | mdrhw = NULL;
|
---|
414 | SetReady();
|
---|
415 | }
|
---|
416 |
|
---|
417 | /* --Methode-- */
|
---|
418 | PITApp::~PITApp()
|
---|
419 | {
|
---|
420 | delete m[0]; delete m[1]; delete txt;
|
---|
421 | }
|
---|
422 |
|
---|
423 | static int numpsf = 0;
|
---|
424 | static int nbwin = 0;
|
---|
425 | /* --Methode-- */
|
---|
426 | void PITApp::Process(PIMessage msg, PIMsgHandler* sender, void* /*data*/)
|
---|
427 | {
|
---|
428 |
|
---|
429 | char strg[256];
|
---|
430 |
|
---|
431 | // Gestion des actions en fonctions des messages
|
---|
432 |
|
---|
433 | if ( ( ModMsg(msg) == PIMsg_Active) || (ModMsg(msg) == PIMsg_Close) ) {
|
---|
434 | PIWdg *sndw;
|
---|
435 | sndw = (PIWdg *)sender;
|
---|
436 | if (sndw->kind() == PIWindow::ClassId) {
|
---|
437 | if (ModMsg(msg) == PIMsg_Close) {
|
---|
438 | // printf("PITApp::Process()/Debug : Closing Window %lx \n", (long)sender);
|
---|
439 | if (mcurwin->UserData() == mcurw) mcurw = NULL;
|
---|
440 | if (mcurwin->UserData() == mdrhw) mdrhw = NULL;
|
---|
441 | if (mcurwin->UserData() == mevhw) mevhw = NULL;
|
---|
442 | delete (PIWindow *)sender;
|
---|
443 | mcurwin = NULL;
|
---|
444 | }
|
---|
445 | else mcurwin = (PIWindow *)sender;
|
---|
446 | }
|
---|
447 | else if ( ModMsg(msg) == PIMsg_Active) mcurw = sndw;
|
---|
448 | }
|
---|
449 |
|
---|
450 | else switch(UserMsg(msg)) {
|
---|
451 |
|
---|
452 | case 10101: // Info
|
---|
453 | txt->SetText("pit1: PITApp \n PIBaseWdg - PIScDrawWdg test \n ExBWdg (:PIBaseWdg) Creation \n ScSample (:PIScDrawWdg) creation");
|
---|
454 | break;
|
---|
455 |
|
---|
456 | case 10102: // Creation d'un ExBWdg
|
---|
457 | {
|
---|
458 | nbwin++;
|
---|
459 | sprintf(strg, "Creation ExBwdg \n Fenetre No %d \n Test keyborard, button 1/2/3", nbwin);
|
---|
460 | txt->SetText(strg);
|
---|
461 | sprintf(strg,"Window %d - ExBwdg", nbwin);
|
---|
462 | PIWindow* wp = new PIWindow(this, strg, PIWK_normal, 250, 250, 150, 150);
|
---|
463 | wp->SetAutoDelChilds(true);
|
---|
464 | ExBWdg* exb = new ExBWdg(wp, "bwdg", 250, 250, 0, 0);
|
---|
465 | exb->SetBinding(PIBK_fixed,PIBK_elastic,PIBK_elastic,PIBK_elastic);
|
---|
466 | wp->SetUserData(exb);
|
---|
467 | wp->Show();
|
---|
468 | }
|
---|
469 | break;
|
---|
470 |
|
---|
471 | case 10103: // Creation d'un ScSample
|
---|
472 | {
|
---|
473 | nbwin++;
|
---|
474 | sprintf(strg, "Creation Scsample \n Fenetre No %d \n Button 1 -> mouse position \n Button 2 -> Zoom \n keyboard <Alt>O <Alt>V", nbwin);
|
---|
475 | txt->SetText(strg);
|
---|
476 | sprintf(strg,"Window %d - ScSample", nbwin);
|
---|
477 | PIWindow* wp = new PIWindow(this, strg, PIWK_normal, 400, 400, 200, 200);
|
---|
478 | wp->SetAutoDelChilds(true);
|
---|
479 | ScSample* sc = new ScSample(wp, "scsample", 400, 400, 0, 0);
|
---|
480 | sc->SetBinding(PIBK_elastic,PIBK_elastic,PIBK_elastic,PIBK_elastic);
|
---|
481 | wp->SetUserData(sc);
|
---|
482 | wp->Show();
|
---|
483 | }
|
---|
484 | break;
|
---|
485 |
|
---|
486 | case 10111: // -> eps
|
---|
487 | if (mcurwin) {
|
---|
488 | char buff[64];
|
---|
489 | sprintf(buff, "pit_%d.eps", numpsf); numpsf++;
|
---|
490 | printf("Creating EPS File %s (Encapsulated PostScript) \n", buff);
|
---|
491 | PSFile *mps;
|
---|
492 | mps = new PSFile(buff);
|
---|
493 | mcurwin->PSPrint(mps,0,0);
|
---|
494 | delete mps;
|
---|
495 | }
|
---|
496 | break;
|
---|
497 | case 10105: // Sortie d'application
|
---|
498 | Stop();
|
---|
499 | break;
|
---|
500 |
|
---|
501 |
|
---|
502 | case 10201: // 2 eme menu Copy
|
---|
503 | if (mcurw == NULL) { printf("PITApp::Process()/Warning : Select a window for copy \n");
|
---|
504 | sprintf(strg, "Warning : Select a window for copy");
|
---|
505 | txt->SetText(strg);
|
---|
506 | }
|
---|
507 | else {
|
---|
508 | printf("Adding EventHandler to Wdg %lx", (long)mcurw);
|
---|
509 | sprintf(strg, "Adding EventHandler to Wdg %lx \n, Use button 3 to select copy zone \n, <Alt>G to Get copy",
|
---|
510 | (long)mcurw);
|
---|
511 | txt->SetText(strg);
|
---|
512 | if (mevhw != NULL) mevhw->RemoveEventHandler(evh); mevhw = NULL;
|
---|
513 | mcurw->AddEventHandler(evh, PIEvent_But3Press | PIEvent_But3Release | PIEvent_Keyboard, false);
|
---|
514 | }
|
---|
515 | break;
|
---|
516 |
|
---|
517 | case 10202: // 2eme Menu - Paste
|
---|
518 | if (mcurw == NULL) { printf("PITApp::Process()/Warning : Select a window for paste \n");
|
---|
519 | sprintf(strg, "Warning : Select a window for paste");
|
---|
520 | txt->SetText(strg);
|
---|
521 | }
|
---|
522 | else {
|
---|
523 | printf("Adding DrawHandler to Wdg %lx \n - Refreshing Wdg", (long)mcurw);
|
---|
524 | sprintf(strg, "Adding DrawHandler to Wdg %lx \n - Refreshing Wdg", (long)mcurw);
|
---|
525 | txt->SetText(strg);
|
---|
526 | mcurw->AddDrawHandler(evh, false);
|
---|
527 | mdrhw = mcurw;
|
---|
528 | ((PIBaseWdg*)mcurw)->Refresh();
|
---|
529 | }
|
---|
530 | break;
|
---|
531 |
|
---|
532 | default :
|
---|
533 | // printf("PITApp::Process() Msg= %d (%d - %d)??? \n",
|
---|
534 | // (int)msg, (int)UserMsg(msg),(int)ModMsg(msg));
|
---|
535 | break;
|
---|
536 |
|
---|
537 | }
|
---|
538 | return;
|
---|
539 | }
|
---|
540 |
|
---|
541 |
|
---|
542 | // ................................................................
|
---|
543 | // programme principal
|
---|
544 | // ................................................................
|
---|
545 |
|
---|
546 | int main(int narg, char *arg[])
|
---|
547 | {
|
---|
548 | if ( (narg > 1) && (strcmp(arg[1],"-h") == 0) ) {
|
---|
549 | printf("pit1 : ExBWdg (:PIBaseWdg) / ScSample (:PIScDrawWdg) test \n");
|
---|
550 | printf(" Usage : pit1 [Xt options] \n");
|
---|
551 | }
|
---|
552 | // Creation de l'objet application et appel de Run()
|
---|
553 | PITApp* app = new PITApp(narg, arg);
|
---|
554 | // puts("appel de Application.Run() ... ");
|
---|
555 | app->Run();
|
---|
556 |
|
---|
557 | delete app;
|
---|
558 | exit(0);
|
---|
559 | }
|
---|
560 |
|
---|
561 |
|
---|