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