00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #include <Windows.h>
00027 #include "controlEngine.h"
00028 #include "MyString.h"
00029 #include "MyList.h"
00030 #include "input_instance.h"
00031
00032 #include "MyDebug.h"
00033 #include "control_instance.h"
00034 #include "button.h"
00035 #include "texture_instance.h"
00036 #include "textBox.h"
00037 #include "title.h"
00038 #include "container.h"
00039 #include "window.h"
00040 #include "effect.h"
00041
00042 #include "msgBox.h"
00043 #include "tip.h"
00044 #include "treeView.h"
00045 #include "slider.h"
00046 #include "calculator.h"
00047
00048 ControlEngine ce;
00049
00050 using namespace sigslot;
00051
00057 class Tutorial : public Window
00058 {
00059 public:
00060 TextBox info;
00061 Button btnReturn;
00062 EffectApparition effect;
00063 Tip tip;
00064
00065 Button btnUniversDemo;
00066 Button btnFaceDemo;
00067 Button btnBaseDemo;
00068 Button btnLayoutDemo;
00069 Button btnWindowDemo;
00070 Button btnApplicationDemo;
00071
00072 class Demo : public has_slots<>
00073 {
00074 public:
00075 Tutorial *parent;
00076
00077 Demo(Tutorial *_parent)
00078 {
00079 parent=_parent;
00080 parent->btnReturn.onButton.click.disconnect_all();
00081 parent->title.OnMin();
00082 ce.univers->HomePosition();
00083 }
00084
00085 void Ending()
00086 {
00087 parent->title.OnOriginal();
00088 parent->SetTutorialTipText();
00089 parent->btnReturn.onButton.click.disconnect_all();
00090 parent->btnReturn.onButton.click.connect(parent,Tutorial::OnEnd);
00091 parent->effect.Bind(parent->faceNode);
00092 parent->effect.Start(FALSE,1);
00093 }
00094 };
00095
00096 class FaceDemo : public Demo
00097 {
00098 public:
00099 Title *titleBasic;
00100 Control *controlBasic;
00101 Title *titleText;
00102 Control *controlText;
00103 Title *titleCurving;
00104 Control *controlCurving;
00105
00106 Timer timer;
00107 MyList<FaceNode *> nodes;
00108
00109 FaceDemo(Tutorial *_parent) : Demo (_parent)
00110 {
00111 parent->tip.SetText("Face is the base graphics primitive; for example a Box is just on combination of Face, and by extand, it was the same for all control");
00112 parent->btnReturn.onButton.click.connect(this,OnEnd);
00113 ce.Push(ce.univers);
00114 FaceNode *node;
00115 Face *face;
00116
00117
00118 controlBasic= new Control;
00119 controlBasic->faceNode = ce.primitive.AddFace("basic container",controlBasic->id,0,FALSE);
00120 face = controlBasic->faceNode->elem;
00121 face->position.x=-170;
00122 face->position.y=170;
00123 face->size.x=300;
00124 face->size.y=300;
00125 face->line=1;
00126 face->lineMaterial.SetDS(0.5,0.5,0.5);
00127 ce.Push(controlBasic);
00128 titleBasic = new Title;
00129 titleBasic->SetUses(FALSE,FALSE,FALSE,FALSE);
00130 titleBasic->Create(controlBasic);
00131 titleBasic->SetText("Basic: Outline,Red,Texture,Blend");
00132 titleBasic->XDockCenter(2,0);
00133 titleBasic->YDockTop(2,30);
00134
00135
00136
00137 node = ce.primitive.AddFace("outline",controlBasic->id,1,FALSE);
00138 nodes.i+=node;
00139 face = node->elem;
00140 face->position.x=-50;
00141 face->position.y=50;
00142 face->size.x=50;
00143 face->size.y=50;
00144 face->angle.Set(22,22,0);
00145 face->line=1;
00146 face->lineMaterial.SetDS(0,1,0);
00147
00148
00149 node = ce.primitive.AddFace("red",controlBasic->id,2,TRUE);
00150 nodes.i+=node;
00151 face = node->elem;
00152 face->position.x=50;
00153 face->position.y=50;
00154 face->size.x=50;
00155 face->size.y=50;
00156 face->angle.Set(22,22,0);
00157 face->material.SetDS(1,0,0);
00158
00159
00160 node = ce.primitive.AddFace("textured",controlBasic->id,3,TRUE);
00161 nodes.i+=node;
00162 face = node->elem;
00163 face->position.x=-50;
00164 face->position.y=-50;
00165 face->size.x=50;
00166 face->size.y=50;
00167 face->angle.Set(22,22,0);
00168 face->material.SetDS(1,1,1);
00169 face->texture=&ce.texture.iconBase;
00170
00171
00172 node = ce.primitive.AddFace("blending",controlBasic->id,4,TRUE);
00173 nodes.i+=node;
00174 face = node->elem;
00175 face->position.x=50;
00176 face->position.y=-50;
00177 face->size.x=50;
00178 face->size.y=50;
00179 face->angle.Set(22,22,0);
00180 face->material.SetDS(1,0,0.5);
00181 node = ce.primitive.AddFace("blending2",controlBasic->id,5,TRUE);
00182 nodes.i+=node;
00183 face = node->elem;
00184 face->position.x=50+10;
00185 face->position.y=-50+10;
00186 face->position.z=20;
00187 face->size.x=40;
00188 face->size.y=40;
00189 face->blending=TRUE;
00190 face->material.SetDS(0,1,0,0.5);
00191 ce.Pop();
00192
00193
00194 controlText = new Control;
00195 controlText->faceNode = ce.primitive.AddFace("text container",controlText->id,0,FALSE);
00196 face = controlText->faceNode->elem;
00197 face->position.x=-170;
00198 face->position.y=-170;
00199 face->size.x=300;
00200 face->size.y=300;
00201 face->line=1;
00202 face->lineMaterial.SetDS(0.5,0.5,0.5);
00203 ce.Push(controlText);
00204 titleText = new Title;
00205 titleText->SetUses(FALSE,FALSE,FALSE,FALSE);
00206 titleText->Create(controlText);
00207 titleText->SetText("Text & Alignement");
00208 titleText->XDockCenter(2,0);
00209 titleText->YDockTop(2,30);
00210
00211
00212
00213 int x,y=68;
00214 char xText[4][10]={"left","center","right","justify"};
00215 char yText[4][10]={"top","center","bottom","justify"};
00216 MyString text;
00217 for (int yAlign=0;yAlign<4;yAlign++)
00218 {
00219 x=-118;
00220 for (int xAlign=0;xAlign<4;xAlign++)
00221 {
00222 node = ce.primitive.AddFace("text",controlText->id,xAlign+yAlign*4,TRUE);
00223 nodes.i+=node;
00224 face = node->elem;
00225 face->position.x=x;
00226 face->position.y=y;
00227 face->size.x=60;
00228 face->size.y=50;
00229 face->angle.Set(22,22,0);
00230 face->text=new Text3D;
00231 face->text->SetJustifyLimit(100,100);
00232 face->text->Setup(ce.fontTexture,ft_texture);
00233 text<<clear<<xText[xAlign]<<"\n"<<yText[yAlign];
00234 face->text->SetText(text);
00235 face->text->SetAlign((TextAlign)xAlign,(TextAlign)yAlign);
00236 face->text->SetWrapping(TRUE,FALSE,TRUE);
00237 face->text->material.SetDS(0,0,1);
00238 face->line=1;
00239 face->lineMaterial.SetDS(1,0,0);
00240 x+=60;
00241 }
00242 y-=50;
00243 }
00244 ce.Pop();
00245
00246
00247 controlCurving= new Control;
00248 controlCurving->faceNode = ce.primitive.AddFace("curving container",controlCurving->id,0,FALSE);
00249 face = controlCurving->faceNode->elem;
00250 face->position.x=170;
00251 face->position.y=-170;
00252 face->size.x=300;
00253 face->size.y=300;
00254 face->line=1;
00255 face->lineMaterial.SetDS(0.5,0.5,0.5);
00256 ce.Push(controlCurving);
00257 titleCurving = new Title;
00258 titleCurving->SetUses(FALSE,FALSE,FALSE,FALSE);
00259 titleCurving->Create(controlCurving);
00260 titleCurving->SetText("Curving");
00261 titleCurving->XDockCenter(2,0);
00262 titleCurving->YDockTop(2,30);
00263
00264
00265
00266 Material material[4];
00267 material[0].SetDS(1,0.5,0);
00268 material[1].SetDS(0.5,1,0);
00269 material[2].SetDS(0.5,0,1);
00270 material[3].SetDS(0.5,0.5,0.5);
00271 int num=0;
00272
00273 y=50;
00274 for (float xCenter=0;xCenter<=1;xCenter+=0.5)
00275 {
00276 x=-50;
00277 for (float yCenter=0;yCenter<=1;yCenter+=0.5)
00278 {
00279 node = ce.primitive.AddFace("curving",controlCurving->id,num++,TRUE);
00280 nodes.i+=node;
00281 face = node->elem;
00282 face->position.x=x;
00283 face->position.y=y;
00284 face->size.x=50;
00285 face->size.y=50;
00286 face->material=material[num%4];
00287 if (xCenter==0.5&&yCenter==0.5) face->curve.Set(75,6,6);
00288 else face->curve.Set(50,yCenter==0.5?1:6,xCenter==0.5?1:6);
00289 face->curve.center.x=1-yCenter;
00290 face->curve.center.y=xCenter;
00291 x+=60;
00292 }
00293 y-=60;
00294 }
00295
00296 ce.Pop();
00297 ce.Pop();
00298
00299 BindTimer(timer,OnTimer,40);
00300 }
00301
00302 int OnTimer(Timer *timer)
00303 {
00304 double time = timer->GetDeltaTime();
00305 double decal = 0;
00306
00307 int num;
00308
00309 for (nodes.i=0,num=0;num<21;nodes.i++,num++)
00310 {
00311 FaceNode *node = nodes.i.GetElem();
00312 node->elem->angle.Set(sin(0.6*time*PI+decal)*20,cos(0.6*time*PI+decal)*20,0);
00313 decal+=PI/3.0;
00314 }
00315
00316
00317 decal = 0;
00318 for (;nodes.i.More();nodes.i++)
00319 {
00320 FaceNode *node = nodes.i.GetElem();
00321 node->elem->curve.center.z=sin(time*PI+decal)*50;
00322 decal+=PI/3.0;
00323 }
00324 return 0;
00325 }
00326
00327 int OnEnd()
00328 {
00329 timer.onTimer.disconnect_all();
00330 Ending();
00331 delete titleBasic;
00332 delete titleText;
00333 delete titleCurving;
00334 delete controlBasic;
00335 delete controlText;
00336 delete controlCurving;
00337 return 1;
00338 }
00339 };
00340
00341 class UniversDemo : public Demo
00342 {
00343 public:
00344 Control *control;
00345 Button *button[4*6];
00346 Timer timer;
00347 DockPos slideDirection;
00348 double countDirection;
00349
00350 UniversDemo(Tutorial *_parent) : Demo(_parent)
00351 {
00352 parent->tip.SetText("The Univers is the basic container, to move inside you can:\npush left button on the mouse and moving or using key HOME, directionnal (add Shift to rotate) or PRIOR/NEXT");
00353 parent->btnReturn.onButton.click.connect(this,OnEnd);
00354
00355 ce.Push(ce.univers);
00356 control= new Control;
00357 control->faceNode = ce.primitive.AddBox("Box test",control->id,100,TRUE);
00358 Face *face = control->faceNode->elem;
00359 face->size.x=100;
00360 face->size.y=100;
00361 face->position.z=-50;
00362
00363 SetFace(FACE_BACK,1,0,0,"Face\nBack");
00364 SetFace(FACE_FRONT,0,1,0,"Face\nFront");
00365 SetFace(FACE_LEFT,0,0,1,"Face\nLeft");
00366 SetFace(FACE_RIGHT,1,1,0,"Face\nRight");
00367 SetFace(FACE_TOP,1,0,1,"Face\nTop");
00368 SetFace(FACE_BOTTOM,0,1,1,"Face\nBottom");
00369
00370 ce.Pop();
00371 }
00372
00373 void SetFace(int numFace,float r,float g,float b,char *text)
00374 {
00375 Face *face = control->faceNode->Elems(numFace);
00376 face->material.SetDS(r,g,b);
00377 face->text= new Text3D;
00378 face->text->Setup(ce.fontTexture);
00379 face->text->SetAlign(align_center,align_center);
00380 face->text->SetText(text);
00381 face->text->material.SetDS(0,0,0);
00382 ce.primitive.GoTo(control->faceNode);
00383 ce.primitive.GoTo(numFace);
00384 for (int i=numFace;i<numFace+4;i++)
00385 {
00386 button[i] = new Button;
00387 button[i]->materialOnUp.SetDS(0.5,0.5,0.5,0.5);
00388 button[i]->materialOnDown.SetDS(1,1,1,0.5);
00389 button[i]->Create();
00390 button[i]->faceNode->Elems(FACE_FRONT)->texture = &ce.texture.arrow;
00391 button[i]->SetBlending(TRUE);
00392 }
00393
00394 button[numFace]->XDockLeft(3,15);
00395 button[numFace]->YDockCenter(15);
00396
00397 button[numFace+1]->XDockRight(3,15);
00398 button[numFace+1]->YDockCenter(15);
00399
00400 button[numFace+2]->XDockCenter(15);
00401 button[numFace+2]->YDockTop(3,15);
00402
00403 button[numFace+3]->XDockCenter(15);
00404 button[numFace+3]->YDockBottom(3,15);
00405
00406 button[numFace+1]->RotateTo(0,0,180);
00407 button[numFace+2]->RotateTo(0,0,-90);
00408 button[numFace+3]->RotateTo(0,0,90);
00409
00410 button[numFace+1]->MoveTo(-18,0,0);
00411 button[numFace+2]->MoveTo(9,-9,0);
00412 button[numFace+3]->MoveTo(9,9,0);
00413
00414 button[numFace]->onButton.click.connect(this,OnLeft);
00415 button[numFace+1]->onButton.click.connect(this,OnRight);
00416 button[numFace+2]->onButton.click.connect(this,OnTop);
00417 button[numFace+3]->onButton.click.connect(this,OnBottom);
00418 }
00419
00420 int OnTimer(Timer *timer)
00421 {
00422 double delta = 5.0;
00423 Face *face = control->faceNode->elem;
00424
00425 countDirection-=delta;
00426 if (countDirection<=0)
00427 {
00428 timer->onTimer.disconnect(this);
00429 delta = -countDirection;
00430 }
00431 switch (slideDirection)
00432 {
00433 case left: control->RotateQuaternion(delta,0,0); break;
00434 case right: control->RotateQuaternion(-delta,0,0); break;
00435 case top: control->RotateQuaternion(0,delta,0); break;
00436 case bottom:control->RotateQuaternion(0,-delta,0); break;
00437 }
00438 return 0;
00439 }
00440
00441 int OnLeft()
00442 {
00443 ConfigSlide(left);
00444 return 1;
00445 }
00446
00447 int OnRight()
00448 {
00449 ConfigSlide(right);
00450 return 1;
00451 }
00452
00453 int OnTop()
00454 {
00455 ConfigSlide(top);
00456 return 1;
00457 }
00458
00459 int OnBottom()
00460 {
00461 ConfigSlide(bottom);
00462 return 1;
00463 }
00464
00465 void ConfigSlide(DockPos direction)
00466 {
00467 slideDirection=direction;
00468 countDirection=50;
00469 timer.onTimer.disconnect(this);
00470 BindTimer(timer,OnTimer,20);
00471 }
00472
00473 int OnEnd()
00474 {
00475 Ending();
00476
00477 delete control;
00478 return 1;
00479 }
00480 };
00481
00482 class BaseDemo : public Demo
00483 {
00484 public:
00485 Button *button;
00486 Title *title;
00487 TextBox *textBox ;
00488 Window *winInfo;
00489 Window *winSlider;
00490 MsgBox *msgBox;
00491 Slider *xSlider,*ySlider;
00492 Tip *tipSlider;
00493 double xPercent,yPercent;
00494
00495 BaseDemo(Tutorial *_parent) : Demo(_parent)
00496 {
00497 parent->tip.SetText("Basic Control, like Button, TextBox, Title, Window and MsgBox");
00498 parent->btnReturn.onButton.click.connect(this,OnEnd);
00499 ce.taskWindow->title.OnOriginal();
00500
00501 ce.Push(ce.univers);
00502 button = new Button;
00503 button->Create();
00504 button->SetText("Button");
00505 button->text.SetAlign(align_justify,align_begin);
00506 button->Size(80,50);
00507 button->MoveTo(0,-100,0);
00508
00509 title = new Title;
00510 title->Create();
00511 title->SetText("Title");
00512 title->Size(200,20);
00513 title->MoveTo(0,0,0);
00514
00515 textBox = new TextBox;
00516 textBox->Create();
00517 textBox->SetText("Text");
00518 textBox->Size(50,20);
00519 textBox->MoveTo(0,100,0);
00520
00521 winSlider = new Window;
00522 winSlider->Create();
00523 winSlider->title="Slider";
00524 winSlider->Size(200,200);
00525 winSlider->MoveTo(0,200,0);
00526
00527 ce.Push(&winSlider->client);
00528 ce.primitive.GoTo(FACE_FRONT);
00529 xPercent=yPercent=0.5;
00530 xSlider = new Slider;
00531 xSlider->Create(10);
00532 xSlider->XDockCenter(2,15);
00533 xSlider->YDockBottom(2,15);
00534 xSlider->onSlidder.moving.connect(this,OnXSliderMove);
00535
00536 ySlider = new Slider;
00537 ySlider->Create(10);
00538 xSlider->XDockCenter(2,15);
00539 xSlider->YDockBottom(18,15);
00540 ySlider->onSlidder.moving.connect(this,OnYSliderMove);
00541
00542 tipSlider = new Tip;
00543 tipSlider->Create();
00544 tipSlider->XDockCenter(100);
00545 tipSlider->YDockCenter(100);
00546 tipSlider->text.SetWrapping(FALSE,FALSE,FALSE);
00547 tipSlider->Move(0,0,5);
00548 ce.Pop();
00549
00550 winInfo = new Window;
00551 winInfo->Create();
00552 winInfo->title="Window";
00553 winInfo->Size(200,200);
00554 winInfo->MoveTo(-200,0,0);
00555 winInfo->RotateTo(0,35,0);
00556
00557 winInfo->client.faceNode->Elems(FACE_FRONT)->texture=&ce.texture.tropique;
00558
00559 winInfo->client.onControl.mouse.move.connect(this,OnWinMove);
00560
00561 Face *face = winInfo->client.faceNode->Elems(FACE_FRONT);
00562 face->material.SetDS(1,1,1,0.5f);
00563 face->blending=TRUE;
00564 face->text = new Text3D;
00565 face->text->Setup(ce.fontTexture);
00566 face->text->SetAlign(align_center,align_center);
00567 face->text->material.SetDS(1,1,0);
00568 face->text->SetWrapping(FALSE,FALSE,FALSE);
00569 face->text->SetText("Moving inside\nGive local positions");
00570
00571 msgBox = new MsgBox;
00572 msgBox->Create();
00573 msgBox->Size(250,200);
00574 msgBox->title="3D Controls - MsgBox";
00575 msgBox->txtInfo="Hello Word !!\nVoici un example de l'utilisation de MsgBox";
00576 msgBox->txtTranche="3D Controls";
00577 msgBox->MoveTo(200,0,0);
00578 msgBox->RotateTo(0,-35,0);
00579 ce.Pop();
00580 }
00581
00582 int OnXSliderMove(double min,double max,double percent)
00583 {
00584 xPercent=percent;
00585 MyString temp;
00586 temp.Format("X=%.0lf%%\nY=%.0lf%%",xPercent*100.0,yPercent*100.0);
00587 tipSlider->SetText(temp);
00588 return 0;
00589 }
00590
00591 int OnYSliderMove(double min,double max,double percent)
00592 {
00593 yPercent=percent;
00594 MyString temp;
00595 temp.Format("X=%.0lf%%\nY=%.0lf%%",xPercent*100.0,yPercent*100.0);
00596 tipSlider->SetText(temp);
00597 return 0;
00598 }
00599
00600 int OnWinOut (Control *,int)
00601 {
00602 Face *face = winInfo->client.faceNode->Elems(FACE_FRONT);
00603 face->text->SetText("Moving inside\nGive local positions");
00604 return 0;
00605 }
00606
00607 int OnWinMove(StateMouse *mouse,int,int,int numFace)
00608 {
00609 MyString text;
00610 Point2D<double> pos(mouse->pos.x,mouse->pos.y);
00611 Point2D<double> localPos;
00612 localPos = winInfo->client.GetLocalPos(numFace,pos);
00613
00614 Point3D<double> corners[4];
00615 winInfo->client.GetCorners(numFace,corners);
00616 text.Format("Coordonate {x,y}\n%.2f , %.2f",localPos.x,localPos.y);
00617 winInfo->client.faceNode->Elems(FACE_FRONT)->text->SetText(text);
00618 return 0;
00619 }
00620
00621 int OnEnd()
00622 {
00623 ce.taskWindow->title.OnMin();
00624 Ending();
00625 delete button;
00626 delete textBox;
00627 delete winInfo;
00628 delete winSlider;
00629 delete title;
00630 delete msgBox;
00631 delete xSlider;
00632 delete ySlider;
00633 delete tipSlider;
00634 return 1;
00635 }
00636 };
00637
00638 class LayoutDemo : public Demo
00639 {
00640 public:
00641 Button btnToogleAll;
00642 Button btnToogle;
00643 Button btnResetAll;
00644 Button btnReset;
00645 Button btnSetAll;
00646 Button btnSet;
00647 Window window;
00648 TextBox text;
00649 Button btnTree;
00650 Button *lastSelected;
00651 MyList<Button> buttons;
00652
00653 LayoutDemo(Tutorial *_parent) : Demo(_parent)
00654 {
00655
00656 lastSelected=NULL;
00657 parent->tip.SetText("Layout cant be use to specify \"contact\" bitwin somme other Control\nIt's the easy way to create\"composite\" Controls");
00658 parent->btnReturn.onButton.click.connect(this,OnEnd);
00659
00660 ce.Push(ce.univers);
00661
00662 btnTree.Create(40);
00663 btnTree.XDockCenter(80);
00664 btnTree.YDockCenter(40);
00665 btnTree.ModePushLike(TRUE);
00666 btnTree.depth_min=btnTree.depth_max;
00667 btnTree.ModeAllButtons(TRUE);
00668 btnTree.faceNode->Elems(FACE_FRONT)->view=TRUE;
00669 ce.Push(&btnTree);
00670 CreateTreeButton(3);
00671 ce.Pop();
00672
00673
00674 window.Create();
00675 window.title.SetText("Composite controls");
00676 window.XDockCenter(300);
00677 window.YDockTop(10,130);
00678 window.faceNode->Elems(FACE_FRONT)->material.SetNull();
00679 window.title.OnMax();
00680 ce.Push(&window.client);
00681 ce.primitive.GoTo(FACE_FRONT);
00682 text.Create();
00683 text.SetText("Sample composite botton that use other button inside");
00684 text.XDockCenter(3,0);
00685 text.YDockTop(3,40);
00686
00687
00688 text.text.SetAlign(align_begin,align_center);
00689
00690
00691 btnToogle="Toogle";
00692 btnToogle.Create();
00693 btnToogle.XDockCenter(80);
00694 btnToogle.YDockBottom(3,40);
00695 btnToogle.text.SetAlign(align_begin,align_center);
00696 btnToogle.onButton.click.connect(this,OnToogle);
00697 btnToogleAll.onButton.click.connect(this,OnToogleAll);
00698 ce.Push(&btnToogle);
00699 ce.primitive.GoTo(FACE_FRONT);
00700 btnToogleAll="All";
00701 btnToogleAll.Create();
00702 btnToogleAll.XDockRight(3,30);
00703 btnToogleAll.YDockCenter(2,2);
00704 ce.Pop();
00705
00706
00707 btnSet="Set";
00708 btnSet.Create();
00709 btnSet.XDockLeft(3,80);
00710 btnSet.YDockBottom(3,40);
00711 btnSet.text.SetAlign(align_begin,align_center);
00712 btnSet.onButton.click.connect(this,OnSet);
00713 btnSetAll.onButton.click.connect(this,OnSetAll);
00714 ce.Push(&btnSet);
00715 ce.primitive.GoTo(FACE_FRONT);
00716 btnSetAll="All";
00717 btnSetAll.Create();
00718 btnSetAll.XDockRight(3,30);
00719 btnSetAll.YDockCenter(2,2);
00720 ce.Pop();
00721
00722
00723 btnReset="Reset";
00724 btnReset.Create();
00725 btnReset.XDockRight(3,80);
00726 btnReset.YDockBottom(3,40);
00727 btnReset.text.SetAlign(align_begin,align_center);
00728 btnReset.onButton.click.connect(this,OnReset);
00729 btnResetAll.onButton.click.connect(this,OnResetAll);
00730 ce.Push(&btnReset);
00731 ce.primitive.GoTo(FACE_FRONT);
00732 btnResetAll="All";
00733 btnResetAll.Create();
00734 btnResetAll.XDockRight(3,30);
00735 btnResetAll.YDockCenter(2,2);
00736 ce.Pop();
00737 ce.Pop();
00738 }
00739
00740 void CreateTreeButton(int level)
00741 {
00742 if (level)
00743 {
00744 Button *button;
00745 if (!(level%2))
00746 {
00747 button = buttons.i.AddNewLast();
00748 ce.primitive.GoTo(FACE_FRONT);
00749 ConfigTreeButton(button,level*6);
00750 ce.Push(button);
00751 CreateTreeButton(level-1);
00752 ce.Pop();
00753 }
00754 else
00755 {
00756 for (int i=0;i<6;i++)
00757 {
00758 button = buttons.i.AddNewLast();
00759 ce.primitive.GoTo(i);
00760 ConfigTreeButton(button,level*6+i);
00761 ce.Push(button);
00762 CreateTreeButton(level-1);
00763 ce.Pop();
00764 ce.primitive.GoToParent();
00765 }
00766 }
00767 }
00768 }
00769
00770 void ConfigTreeButton (Button *button,int num)
00771 {
00772 button->Create(40);
00773 button->ModePushLike(TRUE);
00774 button->ModeAllButtons(TRUE);
00775 button->XDockCenter(5,5);
00776 button->YDockCenter(5,5);
00777
00778 MyString txtButton;
00779 txtButton = materials[num%NB_MATERIAL].name;
00780
00781 button->SetBlending(TRUE);
00782 button->faceNode->Elems(FACE_BACK)->material.As((TypeMaterial)num);
00783 ConfigTextFace(&button->text,txtButton);
00784
00785 for (int i=1;i<5;i++)
00786 {
00787 Text3D *text = new Text3D;
00788 button->faceNode->Elems(i)->text = text;
00789 ConfigTextFace(text,txtButton);
00790 }
00791 }
00792
00793 void ConfigTextFace(Text3D *text,char *textValue)
00794 {
00795 text->Setup(ce.fontTexture);
00796 text->SetText(textValue);
00797 text->material.SetDS(1,0,0);
00798 text->scale=0.5;
00799 text->SetWrapping(FALSE,FALSE,TRUE);
00800 text->SetAlign(align_center,align_center);
00801 }
00802
00803 int OnTreeButtonClick(Control *sender)
00804 {
00805 Button *button = (Button *)sender;
00806 lastSelected = button;
00807 return 1;
00808 }
00809
00810 int OnToogle()
00811 {
00812 if (!lastSelected) return 1;
00813 lastSelected->SetPushToogle();
00814 return 1;
00815 }
00816
00817 int OnToogleAll()
00818 {
00819 for (buttons.i=0;buttons.i.More();buttons.i++)
00820 {
00821 buttons.i.GetElemPtr()->SetPushToogle();
00822 }
00823 return 1;
00824 }
00825
00826 int OnReset()
00827 {
00828 if (!lastSelected) return 1;
00829 lastSelected->SetPush(FALSE);
00830 return 1;
00831 }
00832
00833 int OnResetAll()
00834 {
00835 for (buttons.i=0;buttons.i.More();buttons.i++)
00836 buttons.i.GetElemPtr()->SetPush(FALSE);
00837 return 1;
00838 }
00839
00840 int OnSet()
00841 {
00842 if (!lastSelected) return 1;
00843 lastSelected->SetPush(TRUE);
00844 return 1;
00845 }
00846
00847 int OnSetAll()
00848 {
00849 for (buttons.i=0;buttons.i.More();buttons.i++)
00850 buttons.i.GetElemPtr()->SetPush(TRUE);
00851 return 1;
00852 }
00853
00854 int OnEnd()
00855 {
00856 btnTree.Delete();
00857 window.Delete();
00858 Ending();
00859 return 1;
00860 }
00861 };
00862
00863 class WindowDemo : public Demo
00864 {
00865 public:
00866 Window *windowLeft;
00867 Window *windowRight;
00868 Window *windowTop;
00869 Window *windowBottom;
00870
00871 WindowDemo(Tutorial *_parent) : Demo(_parent)
00872 {
00873 parent->tip.SetText("The Window as a docking Title, he can:\nMinimize, Maximize, Moving, Close and Rotate");
00874 parent->btnReturn.onButton.click.connect(this,OnEnd);
00875
00876 ce.taskWindow->title.OnOriginal();
00877
00878 ce.Push(ce.univers);
00879
00880 Face *face;
00881 windowLeft=new Window;
00882 windowLeft->titleDock=left;
00883 windowLeft->title.SetText("Left");
00884 windowLeft->Create();
00885 windowLeft->RotateTo(0,33,0);
00886 windowLeft->XDockLeft(10,150);
00887 windowLeft->YDockCenter(200);
00888 face = windowLeft->client.faceNode->Elems(FACE_FRONT);
00889 face->text = new Text3D;
00890 face->text->Setup(ce.fontTexture);
00891 face->text->SetAlign();
00892 face->text->material.SetDS(0,0,0);
00893 face->text->SetText("I can write text on client area !!");
00894
00895 windowRight=new Window;
00896 windowRight->titleDock=right;
00897 windowRight->Create();
00898 windowRight->title.SetText("Right");
00899 windowRight->RotateTo(0,-33,0);
00900 windowRight->XDockRight(10,150);
00901 windowRight->YDockCenter(200);
00902 face = windowRight->client.faceNode->Elems(FACE_FRONT);
00903 face->text = new Text3D;
00904 face->text->Setup(ce.fontTexture);
00905 face->text->SetAlign();
00906 face->text->material.SetDS(0,0,0);
00907 face->text->SetText("I can write text on client area !!");
00908
00909 windowTop=new Window;
00910 windowTop->titleDock=top;
00911 windowTop->Create();
00912 windowTop->title.SetText("Top");
00913 windowTop->RotateTo(33,0,0);
00914 windowTop->XDockCenter(200);
00915 windowTop->YDockTop(10,150);
00916 face = windowTop->client.faceNode->Elems(FACE_FRONT);
00917 face->text = new Text3D;
00918 face->text->Setup(ce.fontTexture);
00919 face->text->SetAlign();
00920 face->text->material.SetDS(0,0,0);
00921 face->text->SetText("I can write text on client area !!");
00922
00923 windowBottom=new Window;
00924 windowBottom->titleDock=bottom;
00925 windowBottom->Create();
00926 windowBottom->title.SetText("bottom");
00927 face = windowBottom->client.faceNode->Elems(FACE_FRONT);
00928 face->text = new Text3D;
00929 face->text->Setup(ce.fontTexture);
00930 face->text->SetAlign();
00931 face->text->material.SetDS(0,0,0);
00932 face->text->SetText("I can write text on client area !!");
00933
00934 windowBottom->RotateTo(-33,0,0);
00935 windowBottom->XDockCenter(200);
00936 windowBottom->YDockBottom(10,150);
00937
00938 ce.primitive.Pop();
00939 }
00940
00941 int OnEnd()
00942 {
00943 ce.taskWindow->title.OnMin();
00944 Ending();
00945 delete windowLeft;
00946 delete windowRight;
00947 delete windowTop;
00948 delete windowBottom;
00949 return 1;
00950 }
00951 };
00952
00953 class ApplicationDemo : public Demo
00954 {
00955 public:
00956 Calculator *calc;
00957 Window *winExplorer;
00958 Window *winBackground;
00959 TreeDirectory * tdBkg;
00960 TreeDirectory * tdExplorer;
00961 TextBox pathBox;
00962
00963 ApplicationDemo(Tutorial *_parent) : Demo(_parent)
00964 {
00965 parent->tip.SetText("This is some sample of basic application using 3D Controls");
00966 parent->btnReturn.onButton.click.connect(this,OnEnd);
00967 ce.taskWindow->title.OnOriginal();
00968 calc=new Calculator;
00969
00970 ce.Push(ce.univers);
00971 calc->Create();
00972 calc->XDockCenter(94);
00973 calc->YDockCenter(224);
00974
00975 winBackground = new Window;
00976 winBackground->Create();
00977 winBackground->title.SetText("Backgrounds");
00978 winBackground->XDockLeft(20,200);
00979 winBackground->YDockCenter(400);
00980 ce.Push(&winBackground->client);
00981 {
00982 tdBkg = new TreeDirectory;
00983 tdBkg->Create();
00984 tdBkg->XDockCenter(2,2);
00985 tdBkg->YDockCenter(2,2);
00986 tdBkg->Config(TRUE,TRUE);
00987 tdBkg->Loading("texture/background",FALSE);
00988 tdBkg->Draw();
00989 tdBkg->onTreeView.select.connect(this,OnSelectBkg);
00990 }
00991 ce.Pop();
00992
00993 winExplorer = new Window;
00994 winExplorer->Create();
00995 winExplorer->title.SetText("Explorer");
00996 winExplorer->XDockRight(20,200);
00997 winExplorer->YDockCenter(400);
00998 ce.Push(&winExplorer->client);
00999 {
01000 pathBox.Create();
01001 pathBox.XDockCenter(2,2);
01002 pathBox.YDockTop(2,60);
01003 pathBox.text.SetAlign(align_begin,align_begin);
01004 pathBox.text.SetWrapping(FALSE,FALSE,FALSE);
01005
01006 tdExplorer = new TreeDirectory;
01007 tdExplorer->Create();
01008 tdExplorer->XDockCenter(2,2);
01009 tdExplorer->YDockBottom(2,300);
01010 tdExplorer->Config(FALSE,TRUE);
01011 tdExplorer->Loading("c:",TRUE);
01012 tdExplorer->Draw();
01013 tdExplorer->onTreeView.select.connect(this,OnSelectExplorer);
01014 }
01015 ce.Pop();
01016 ce.Pop();
01017 }
01018
01019 int OnSelectBkg(TreeNode *treeNode)
01020 {
01021 MyString file;
01022 tdBkg->GetTreePath(treeNode,file);
01023 ce.texture.background.FromFile("background",file,TRUE);
01024 return 0;
01025 }
01026
01027 int OnSelectExplorer(TreeNode *treeNode)
01028 {
01029 MyString file;
01030 tdExplorer->GetTreePath(treeNode,file);
01031 MyString complete;
01032 complete<<"Path:\n"<<file;
01033 pathBox.text.SetText(complete);
01034 return 0;
01035 }
01036
01037 int OnEnd()
01038 {
01039 ce.taskWindow->title.OnMin();
01040 Ending();
01041 delete calc;
01042 return 1;
01043 }
01044 };
01045
01046 FaceDemo *fd;
01047 UniversDemo *ud;
01048 BaseDemo *db;
01049 LayoutDemo *ld;
01050 WindowDemo *wd;
01051 ApplicationDemo *ad;
01052
01053 Tutorial()
01054 {
01055 fd = NULL;
01056 ud = NULL;
01057 db = NULL;
01058 ld = NULL;
01059 wd =NULL;
01060 ad = NULL;
01061 ce.taskWindow->title.OnMin();
01062
01063 title="3D Controls - Tutorial";
01064 title.useClose=FALSE;
01065 title.useMax=FALSE;
01066 title.useMin=FALSE;
01067
01068 info="Here are 6 steps to familiarize with the 3D Controls.";
01069 info.text.SetAlign(align_justify,align_center);
01070
01071 btnUniversDemo="1°) How to move on the desktop:\nThe \"Univers\" concept.";
01072 btnUniversDemo.text.SetAlign(align_justify,align_center);
01073
01074 btnFaceDemo="2°) Basic graphical concepts:\nThe \"Face\" concept.";
01075 btnFaceDemo.text.SetAlign(align_justify,align_center);
01076
01077 btnBaseDemo="3°) See the basic controls.";
01078 btnBaseDemo.text.SetAlign(align_justify,align_center);
01079
01080 btnLayoutDemo="4°) How to position a control next to another ?";
01081 btnLayoutDemo.text.SetAlign(align_justify,align_center);
01082
01083 btnWindowDemo="5°) The Window is the basic container of the application.";
01084 btnWindowDemo.text.SetAlign(align_justify,align_center);
01085
01086 btnApplicationDemo="6°) Examples of applications for 3D Controls.";
01087 btnApplicationDemo.text.SetAlign(align_justify,align_center);
01088
01089 btnUniversDemo.onButton.click.connect(this,OnUniversDemo);
01090 btnFaceDemo.onButton.click.connect(this,OnFaceDemo);
01091 btnBaseDemo.onButton.click.connect(this,OnBaseDemo);
01092 btnLayoutDemo.onButton.click.connect(this,OnLayoutDemo);
01093 btnWindowDemo.onButton.click.connect(this,OnWindowDemo);
01094 btnApplicationDemo.onButton.click.connect(this,OnApplicationDemo);
01095 }
01096
01097 ~Tutorial()
01098 {
01099 ce.taskWindow->title.OnOriginal();
01100 }
01101
01102 void Create()
01103 {
01104 ce.Push(ce.masterContainer);
01105
01106 Window::Create();
01107 canResize=FALSE;
01108 canRotate=FALSE;
01109
01110 XDockCenter(300);
01111 YDockCenter(394);
01112 ce.Push(&client);
01113 ce.primitive.GoTo(FACE_FRONT);
01114 info.Create();
01115 int yPos = 2;
01116 info.XDockCenter(2,0);
01117 info.YDockTop(yPos,50);
01118
01119 yPos+=52;
01120 btnUniversDemo.Create();
01121 btnUniversDemo.XDockCenter(2,0);
01122 btnUniversDemo.YDockTop(yPos,50);
01123
01124 yPos+=52;
01125 btnFaceDemo.Create();
01126 btnFaceDemo.XDockCenter(2,0);
01127 btnFaceDemo.YDockTop(yPos,50);
01128
01129 yPos+=52;
01130 btnBaseDemo.Create();
01131 btnBaseDemo.XDockCenter(2,0);
01132 btnBaseDemo.YDockTop(yPos,50);
01133
01134 yPos+=52;
01135 btnLayoutDemo.Create();
01136 btnLayoutDemo.XDockCenter(2,0);
01137 btnLayoutDemo.YDockTop(yPos,50);
01138
01139 yPos+=52;
01140 btnWindowDemo.Create();
01141 btnWindowDemo.XDockCenter(2,0);
01142 btnWindowDemo.YDockTop(yPos,50);
01143
01144 yPos+=52;
01145 btnApplicationDemo.Create();
01146 btnApplicationDemo.XDockCenter(2,0);
01147 btnApplicationDemo.YDockTop(yPos,50);
01148
01149 yPos+=52;
01150
01151 ce.Push(ce.masterContainer);
01152 tip.Create();
01153 tip.XDockCenter(10,10);
01154 tip.YDockBottom(10,50);
01155 ce.Pop();
01156 SetTutorialTipText();
01157 ce.Pop();
01158
01159 btnReturn.Create();
01160 btnReturn.SetText("<< Back");
01161 btnReturn.XDockRight(10,65);
01162 btnReturn.YDockTop(10,20);
01163 btnReturn.onButton.click.connect(this,OnEnd);
01164 ce.Pop();
01165
01166 effect.Bind(faceNode);
01167 effect.Start(FALSE,1);
01168 }
01169
01170 void SetTutorialTipText()
01171 {
01172 tip.SetText("Welcom to \"3D Controls\" user tutorial");
01173 }
01174
01175 void DestroyDemos()
01176 {
01177 if (fd) { delete fd; fd=NULL;}
01178 if (ud) { delete ud; ud=NULL;}
01179 if (db) { delete db; db=NULL;}
01180 if (ld) { delete ld; ld=NULL;}
01181 if (wd) {delete wd; wd=NULL;}
01182 if (ad) {delete ad; ad=NULL;}
01183 }
01184
01185 int OnUniversDemo()
01186 {
01187 OnUniversDemoStart();
01188
01189
01190 return 1;
01191 }
01192
01193 int OnFaceDemo()
01194 {
01195 OnFaceDemoStart();
01196
01197
01198 return 1;
01199 }
01200
01201 int OnBaseDemo()
01202 {
01203 OnBaseDemoStart();
01204
01205
01206 return 1;
01207 }
01208
01209 int OnLayoutDemo()
01210 {
01211 OnLayoutDemoStart();
01212
01213
01214 return 1;
01215 }
01216
01217 int OnWindowDemo()
01218 {
01219 OnWindowDemoStart();
01220
01221
01222 return 1;
01223 }
01224
01225 int OnApplicationDemo()
01226 {
01227 OnApplicationDemoStart();
01228
01229
01230 return 1;
01231 }
01232 void OnUniversDemoStart()
01233 {
01234 DestroyDemos();
01235 UniversDemo * ud = new UniversDemo(this);
01236 }
01237
01238 void OnFaceDemoStart()
01239 {
01240 DestroyDemos();
01241 FaceDemo *fd = new FaceDemo(this);
01242 }
01243
01244 void OnBaseDemoStart()
01245 {
01246 DestroyDemos();
01247 BaseDemo *bd = new BaseDemo(this);
01248 }
01249
01250 void OnLayoutDemoStart()
01251 {
01252 DestroyDemos();
01253 LayoutDemo *ld = new LayoutDemo(this);
01254 }
01255
01256 void OnWindowDemoStart()
01257 {
01258 DestroyDemos();
01259 WindowDemo *wd = new WindowDemo(this);
01260 }
01261
01262 void OnApplicationDemoStart()
01263 {
01264 DestroyDemos();
01265 ApplicationDemo *ad = new ApplicationDemo(this);
01266 }
01267 int OnEnd()
01268 {
01269 ce.univers->ExitQuestion();
01270 return 1;
01271 }
01272 };
01273
01274 class Demo : public has_slots<>
01275 {
01276 public:
01277 Timer timer;
01278 Tip tip[6];
01279
01280 Demo()
01281 {
01282 ce.taskWindow->title.OnMin();
01283 ce.univers->faceNode->elem->position.z=-700;
01284
01285 char text[][100]={
01286 "Il y a bien longtemp",
01287 "Tres tres longtemp",
01288 "Trop même ...",
01289 "Mais c'est finis !",
01290 "Quoi ???",
01291 "DE TROP PARLER"
01292 };
01293
01294 ce.Push(ce.masterContainer);
01295 for (int i=0;i<6;i++)
01296 {
01297 tip[i].Create();
01298 tip[i].XDockCenter(200);
01299 tip[i].YDockCenter(200);
01300 tip[i].SetText(text[i]);
01301 tip[i].faceNode->elem->position.z=-i*800;
01302 tip[i].SetAlphaBlending(0);
01303 tip[i].text.material.SetDS(0,0,0,0.8f);
01304 }
01305 ce.Pop();
01306
01307 BindTimer(timer,OnTimer,10);
01308 }
01309
01310 int OnTimer(Timer *)
01311 {
01312 ce.univers->faceNode->elem->position.z.constValue +=10;
01313 ce.univers->Rotate(0.1,0.2,0);
01314 for (int i=0;i<6;i++)
01315 {
01316 tip[i].faceNode->elem->position.z.constValue+=10;
01317 }
01318 return 0;
01319 }
01320 };
01321
01322 int APIENTRY WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine,int nCmdShow)
01323 {
01324 MyDebug::Start();
01325 ce.Start(hInstance);
01326
01327
01328 Tutorial tutorial;
01329 tutorial.Create();
01330
01331 ce.Loop();
01332 return 0;
01333 }