00001
00002
00003 #ifndef OglGui_OglDemo_h
00004 #define OglGui_OglDemo_h
00005
00006 #include <stddef.h>
00007 #include "OglGui/Window.h"
00008 #include "OglGui/Tabs.h"
00009 #include "OglGui/TitledWindow.h"
00010 #include "OglGui/ScrollWnd.h"
00011 #include "OglGui/FourPanesWindow.h"
00012 #include "OglGui/DropDownWindow.h"
00013 #include "OglGui/ViewSphere.h"
00014 #include "OglGui/FramesPerSecond.h"
00015 #include "OglGui/Camera3DControl.h"
00016 #include "OglGui/Camera3DControlEx.h"
00017 #include "OglGui/SelectedViewControl.h"
00018 #include "OglGui/SixView2DWindow.h"
00019 #include "OglGui/ZoomPanControl.h"
00020 #include "OglGui/LenseControl.h"
00021 #include "OglGui/ClusterApp.h"
00022
00023 #include "OglGui/RadioGroup.h"
00024
00025
00026
00027
00028
00029 namespace OglGui {
00030
00031 class OglDemo : public Window, WindowListener
00032 {
00033 public:
00034 static const int scExtraControl = 333;
00035
00036 OglDemo(int width, int height) :
00037 Window(0, 0, width, height)
00038 {
00039 SetBackground(oglGUI_BG);
00040 BuildGUI(width, height);
00041 }
00042
00043 OglDemo(Window* parent, int x, int y, int width, int height) :
00044 Window(parent, x, y, 1100, 700)
00045 {
00046 SetBackground(oglGUI_BG);
00047 BuildGUI(1100, 700);
00048 SetDimensions(width, height);
00049 ConnectTo(parent);
00050 }
00051
00052 OglDemo(OGLWND* parent, int x, int y, int width, int height) :
00053 Window(parent, x, y, 1100, 700)
00054 {
00055 SetBackground(oglGUI_BG);
00056 BuildGUI(1100, 700);
00057 SetDimensions(width, height);
00058 Window* stub = new Window(parent);
00059 ConnectTo(stub);
00060 }
00061
00062
00063 void BuildGUI( int w, int h )
00064 {
00065 mTabs = new Tabs(this, w, h);
00066 mTabs->ConnectTo(this);
00067
00068 BuildTab_Basic2D3D(mTabs);
00069 BuildTab_ZoomPanLense(mTabs);
00070 BuildTab_SixViewers(mTabs);
00071 BuildTab_Animations(mTabs);
00072 BuildTab_Galaxy(mTabs);
00073 BuildTab_GalaxyGrid(mTabs);
00074 BuildTab_Regions(mTabs);
00075 BuildTab_TreeView(mTabs);
00076 mTabs->SetActiveTab(0);
00077 }
00078
00079 virtual void
00080 WindowKeyboardEvent(Window *src, int c, int state, void* userData)
00081 {
00082 if (userData == (void*)scExtraControl)
00083 {
00084 if (c == '!')
00085 {
00086 TitledViewControl(src, 4, 4, src);
00087 if (!src->Is2d())
00088 TitledCamera3DControl(src, 378, 4, src);
00089 }
00090 if (c == 'R' && src->Is2d())
00091 RotateSelectedViews(src);
00092 if (c == 'G' || c == 'g')
00093 SetOnDrawViewGraphics(src, c=='G');
00094 if (c == 'P' && src->Is2d())
00095 TitledPanControl(src, 30, 30, 100, 100, src);
00096 }
00097 }
00098
00099 void BuildTab_Basic2D3D(Tabs* tabs)
00100 {
00101 Window* tab = tabs->CreateTab( "Basic 2D/3D", 100 );
00102 int w = tab->W();
00103 int h = tab->H();
00104 TitledWindow* wnd;
00105
00106 wnd = TitledViews(tab, 10, 10, (w-30)/2, h-20, "Basic 2D", true);
00107 wnd->ContentPane()->SetWindowListener(this, scExtraControl);
00108 oglSys.SetAllowCameraMove(wnd->ContentPane()->GetOGLWND(), true);
00109
00110 wnd = TitledViews(tab,(w-30)/2+20,10, (w-30)/2,h-20, "Basic 3D", false);
00111 wnd->ContentPane()->SetWindowListener(this, scExtraControl);
00112 int mode = CamMove_Keys | CamMove_Mouse;
00113 oglSys.SetAllowCameraMove(wnd->ContentPane()->GetOGLWND(), mode);
00114 Camera3DControlEx* cam3DControl =
00115 new Camera3DControlEx(wnd->ContentPane(), 0, 0, 300, 150,
00116 wnd->ContentPane());
00117 }
00118
00119
00120 void BuildTab_ZoomPanLense(Tabs* tabs)
00121 {
00122 Window* tab = tabs->CreateTab("Zoom Pan Lense", 140);
00123
00124 TitledZoomPanLense(tab, 10, 10, tab->W()-20, tab->H()-20);
00125 }
00126
00127 void BuildTab_SixViewers(Tabs* tabs)
00128 {
00129 Window* tab = tabs->CreateTab("Six View Control", 140);
00130
00131 TitledSixViewer(tab, 10, 10, tab->W()-20, tab->H()-20);
00132 }
00133
00134 void MNAnimTab(Tabs* tabs)
00135 {
00136 Window* tab = tabs->CreateTab("MultimediaN", 100);
00137 MNAnimFuncs(tab->GetOGLWND());
00138 }
00139
00140 Window* WoggelWindow(Window* wnd, int x, int y, int w, int h)
00141 {
00142 OGLWND* oglWnd = oglSys.CreateOGLViewPort(wnd->GetOGLWND(),x,y,w,h);
00143
00144 WoggelFuncs(oglWnd);
00145 Window* woggelWnd = new Window(oglWnd, false);
00146 return woggelWnd;
00147 }
00148
00149 void WoggelTab(Tabs* tabs)
00150 {
00151 Window* tab = tabs->CreateTab("Woggel");
00152 Window* wogWnd = WoggelWindow(tab, 0, 0, tab->W(), tab->H());
00153
00154 wogWnd->ConnectTo(tab);
00155 }
00156
00157 void ViewSphereTab(Tabs* tabs)
00158 {
00159 Window* tab = tabs->CreateTab("ViewSphere");
00160 ViewSphere* vS = new ViewSphere(tab,0,0,tab->W(),tab->H());
00161
00162 vS->ConnectTo(tab);
00163 vS->SetBackground(0);
00164 vS->SetWindowListener(this,scExtraControl);
00165 }
00166
00167 TitledWindow* TitledAnimations(Window* parent, int x, int y, int w, int h)
00168 {
00169 TitledWindow* titledWnd = new TitledWindow(parent, x, y, w, h,
00170 "Animation Window",
00171 TitledWindow::BtnMax);
00172 Tabs* animTabs = new Tabs(titledWnd, 0, 0, w-8, h-32, 100);
00173
00174 titledWnd->SetContentPane(animTabs);
00175
00176 WoggelTab(animTabs);
00177 MNAnimTab(animTabs);
00178 ViewSphereTab(animTabs);
00179
00180 new FramesPerSecond(animTabs, 0, 0, 80, 24);
00181
00182 animTabs->SetActiveTab(0);
00183 return titledWnd;
00184 }
00185
00186 void BuildTab_Animations(Tabs* tabs)
00187 {
00188 Window* tab = tabs->CreateTab("Animations",100);
00189 TitledAnimations(tab, 10, 10, 800, 632);
00190 Titled4Woggels(tab, 200, 100, 400, 400);
00191 }
00192
00193 TitledWindow* TitledGalaxy(Window* parent, int x, int y, int w, int h)
00194 {
00195 TitledWindow* viewTW = TitledViews(parent, x, y, w, h, "Galaxy");
00196 Window* viewCP = viewTW->ContentPane();
00197 TitledWindow* navTW = new TitledWindow(viewCP,8,8,208,232,"Navigate");
00198 OGLWND* oglWnd = Navigate2DChild(navTW->GetOGLWND(),
00199 viewCP->GetOGLWND(),0,0,10,10);
00200 Window* navWnd = new Window(oglWnd);
00201
00202 oglSys.SetUserData(oglWnd, 2, (void*)1);
00203
00204 navTW->SetContentPane(navWnd);
00205 Lense2D(viewCP->GetOGLWND(), 200, 200, 200, 200);
00206 viewCP->SetWindowListener(this, scExtraControl);
00207 return viewTW;
00208 }
00209
00210 void BuildTab_Galaxy(Tabs* tabs)
00211 {
00212 Window* tab = tabs->CreateTab("Galaxy", 100);
00213
00214 TitledGalaxy(tab, 10, 10, tab->W()-100, tab->H()-100);
00215 }
00216
00217 class OnPixDisplay : public WindowListener
00218 {
00219 virtual void
00220 WindowDisplayEvent(Window *src, void* userData)
00221 {
00222 LENSE* detail = (LENSE*) userData;
00223 int w, h;
00224 src->GetDimensions(w,h);
00225 viewSys.SetDimensions(detail->view, -10, -10, w+20, h+20);
00226 }
00227 };
00228
00229 void BuildTab_GalaxyGrid(Tabs* tabs)
00230 {
00231 Window* tab = tabs->CreateTab("Large Grid", 120);
00232 TitledWindow* navTW = new TitledWindow(tab,0,0,300,300,"Navigate");
00233 TitledWindow* viewTW = new TitledWindow(tab,300,0,600,600,"ViewGrid");
00234 TitledWindow* pixTW = new TitledWindow(tab,0,304,300,300,"Pixel Info");
00235 Window* pixCP = pixTW->ContentPane();
00236 Window* viewCP = viewTW->ContentPane();
00237 OGLWND* oglWnd = Navigate2DChild(navTW->GetOGLWND(),
00238 viewCP->GetOGLWND(), 0,0, 10,10);
00239 Window* navWnd = new Window(oglWnd);
00240 OGLIMAGE* oglIms[6];
00241
00242
00243 for (int i=0; i<6; i++)
00244 {
00245 char buf[100];
00246 sprintf(buf, "Im_%d.png", i+1);
00247 oglIms[i] = TryReadPNG(buf);
00248 }
00249
00250 navTW->SetContentPane(navWnd);
00251
00252 oglWnd = viewCP->GetOGLWND();
00253 oglSys.AllowPicking(oglWnd, 1, 1);
00254
00255 for (int col=0; col<10; col++)
00256 for (int row=0; row<10; row++)
00257 {
00258 OGLVIEW* view = viewSys.View2D(oglWnd, oglIms[ABSRND(6)],
00259 4 + col*520, 4 + row*520, 512, 512);
00260 viewSys.SetZoom(view, 2.f, 2.f);
00261 viewSys.SetTexturing(view, true);
00262 viewSys.SetTags(view, FlexViewTags);
00263 }
00264
00265 for (int j=0; j<6; j++)
00266 oglSys.ReleaseOglImage(oglIms[j]);
00267
00268 int clW, clH;
00269 pixCP->GetDimensions(clW, clH);
00270 LENSE* lense = Lense2D(oglWnd, 200, 200, 200, 200);
00271 LENSE* detail = Lense2D(pixCP->GetOGLWND(), -10, -10, clW+20, clH+20);
00272 DetailLense(detail, lense);
00273 detail->absZooming = true;
00274 detail->zoomX = 100.f;
00275 detail->zoomY = 100.f;
00276 pixCP->SetWindowListener(new OnPixDisplay(), (void*) detail);
00277 }
00278
00279 void BuildTab_Regions(Tabs* tabs)
00280 {
00281 Window* tab = tabs->CreateTab("Regions", 120);
00282 int w, h;
00283
00284 tab->GetDimensions(w,h);
00285 ClusterApp* app = new ClusterApp(tab, 0, 0, w, h);
00286 OGLWND* oglWnd = app->ClusterWnd()->GetOGLWND();
00287
00288 ExampleViewers2dMinMax(oglWnd,100, 0,2000, 0,2000, 128,0, 128,0);
00289 app->ClusterWnd()->InitClusterViewers();
00290
00291 app->ConnectTo(tab);
00292 }
00293
00294 DropDownWindow*
00295 NestedDropDown(DropDownWindow *parent, strconst txt, int nest, int tNest)
00296 {
00297 DropDownWindow* dropDownWnd = new DropDownWindow(parent, 130, 20, txt);
00298
00299 for (int i=0; i<3; i++)
00300 {
00301 char buf[100];
00302 sprintf(buf, "Een text %d", i);
00303 dropDownWnd->AddWindow(new Button(dropDownWnd, 70, 20, buf));
00304
00305 sprintf(buf, "Try Level %d", tNest - nest + 2);
00306 if (nest && !i)
00307 dropDownWnd->AddWindow(NestedDropDown(dropDownWnd, buf,
00308 nest-1, tNest));
00309 if (nest == 1 && !i)
00310 {
00311 Window* wnd = new Window(dropDownWnd,0,0,700,400);
00312 wnd->SetBorderType(BEV_ETCHED);
00313 TitledSixViewer(wnd, 0, 0, 400, 300);
00314 dropDownWnd->AddWindow(wnd);
00315 }
00316 if (!i){
00317 Window* wogWnd = WoggelWindow(dropDownWnd,0,0,300,200);
00318 wogWnd->SetBorderType(BEV_ETCHED);
00319 dropDownWnd->AddWindow(wogWnd);
00320 }
00321 if (!nest && !i)
00322 {
00323 Window* wnd = new Window(dropDownWnd,0,0,900,400);
00324 wnd->SetBorderType(BEV_ETCHED);
00325 TitledGalaxy(wnd, 10, 10, 800, 360);
00326 dropDownWnd->AddWindow(wnd);
00327 }
00328 }
00329 if (!nest)
00330 return dropDownWnd;
00331
00332 ViewSphere* viewSphere = new ViewSphere(dropDownWnd, 0, 0, 300, 200);
00333 viewSphere->SetBackground(0);
00334 viewSphere->SetBorderType(BEV_ETCHED);
00335 viewSphere->SetWindowListener(this,scExtraControl);
00336
00337 dropDownWnd->AddWindow(viewSphere);
00338
00339 return dropDownWnd;
00340 }
00341
00342 void TitledFancyTreeView(Window* parent, int x, int y, int w, int h)
00343 {
00344 TitledWindow* treeTWnd = new TitledWindow(parent, x, y, w, h,
00345 "Fancy TreeView",
00346 TitledWindow::BtnMax);
00347 ScrollWnd* scrollWnd = new ScrollWnd(treeTWnd, 4, 4, w-8, h-32);
00348 Window* scrollHold = scrollWnd->ContentHolder();
00349 DropDownWindow* dDownWnd = new DropDownWindow(scrollHold,130,20,
00350 "Fancy Tree");
00351
00352 treeTWnd->SetContentPane(scrollWnd);
00353 scrollWnd->ReplaceContentPane(dDownWnd);
00354
00355 for (int i=0; i<2; i++)
00356 dDownWnd->AddWindow(NestedDropDown(dDownWnd, "Try Me", 1, 1));
00357 }
00358
00359 DropDownWindow*
00360 ControlDrop(DropDownWindow *parent, strconst txt, int nest)
00361 {
00362 DropDownWindow* dropDW = new DropDownWindow(parent, 130, 20, txt);
00363
00364 if (nest>0)
00365 dropDW->AddWindow(ControlDrop(dropDW, "Next", nest-1));
00366
00367 dropDW->AddWindow(new Button(dropDW, 70, 20, "A Button"));
00368
00369 StaticText* sT = new StaticText(dropDW, 0,0,150,20, "ScrollBar below");
00370 sT->SetAlign(oglLeftAlign, oglBottomAlign);
00371 dropDW->AddWindow(sT);
00372
00373 ScrollBar* sB = new ScrollBar(dropDW, 0, 0, 100, 20, true);
00374 sB->SetRange(100,10);
00375 dropDW->AddWindow(sB);
00376
00377 return dropDW;
00378 }
00379
00380 void TitledControlTreeView(Window* parent, int x, int y, int w, int h)
00381 {
00382 TitledWindow* treeTWnd = new TitledWindow(parent,x,y,w,h,"TreeView",
00383 TitledWindow::BtnMax);
00384 ScrollWnd* scrollWnd = new ScrollWnd(treeTWnd,4,4,w-8,h-32);
00385 Window* scrollHold = scrollWnd->ContentHolder();
00386 DropDownWindow* dDownWnd = new DropDownWindow(scrollHold,130,20,
00387 "Control Tree");
00388
00389 treeTWnd->SetContentPane(scrollWnd);
00390 scrollWnd->ReplaceContentPane(dDownWnd);
00391
00392 for (int i=0; i<3; i++)
00393 dDownWnd->AddWindow(ControlDrop(dDownWnd, "DropDown", 2));
00394 }
00395
00396 void BuildTab_TreeView(Tabs* tabs)
00397 {
00398 Window* tab = tabs->CreateTab("TreeView", 100);
00399
00400 TitledControlTreeView(tab, 10, 20, 300, 400);
00401 TitledFancyTreeView(tab, 320, 20, 300, 400);
00402 new FramesPerSecond(tab, 0, 0, 60, 30);
00403 }
00404
00405 TitledWindow*
00406 TitledViews(Window* parent, int x, int y, int w, int h,
00407 std::string title, bool is2D=true, int brdType=BEV_LINE)
00408 {
00409 TitledWindow* tWnd = new TitledWindow(parent, x, y, w, h, title,
00410 TitledWindow::BtnMaxClose, is2D);
00411 tWnd->SetBorderType(brdType);
00412
00413 OGLWND* pOGLWND = tWnd->ContentPane()->GetOGLWND();
00414 if (is2D)
00415 ExampleViewers2dMinMax(pOGLWND,100, 0,1000, 0,650, 100,30, 100,30);
00416 else
00417 ExampleViewers3d(pOGLWND, 6, 5, 4);
00418
00419 oglSys.AllowPicking(pOGLWND, true, true);
00420 oglSys.AllowDeleteView(pOGLWND, true);
00421 return tWnd;
00422 }
00423
00424 SelectedViewControl*
00425 TitledViewControl(Window* parent, int x, int y, Window* target)
00426 {
00427 TitledWindow* titleWnd;
00428 SelectedViewControl* selVC;
00429 int prefW, prefH;
00430
00431 SelectedViewControl::PreferredSize(prefW, prefH);
00432 titleWnd = new TitledWindow(parent, 4, 4, prefW+8, prefH+32,
00433 "Selected Viewers Control", 1);
00434
00435 selVC = new SelectedViewControl(titleWnd, 0, 0, prefW, prefH, target);
00436 selVC->SetBorderType(0);
00437 selVC->SetGroupBorderShading(0x40a0a0a0, 1);
00438 titleWnd->SetContentPane(selVC);
00439 return selVC;
00440 }
00441
00442 Camera3DControl*
00443 TitledCamera3DControl(Window *parent, int x, int y, Window* target)
00444 {
00445 int prefW, prefH;
00446 Camera3DControl::PreferredSize(prefW, prefH);
00447
00448 TitledWindow* titWnd = new TitledWindow(parent,x,y,prefW+8,prefH+32,
00449 "Camera Control", 1);
00450 Camera3DControl* camCtrl = new Camera3DControl(titWnd, 0, 0,
00451 prefW, prefH, target);
00452 titWnd->SetContentPane(camCtrl);
00453 camCtrl->SetGroupBorderShading(0x40a0a0a0, 1);
00454 return camCtrl;
00455 }
00456
00457 void Titled4Woggels(Window* wnd, int x, int y, int w, int h)
00458 {
00459 TitledWindow* tWnd;
00460 FourPanesWindow* panesWnd;
00461 Window* woggelWnd;
00462 int i, clX, clY, clW, clH;
00463
00464 tWnd = new TitledWindow(wnd, x, y, w, h, "Woggel",
00465 TitledWindow::NoContent |
00466 TitledWindow::BtnMaxClose);
00467
00468 tWnd->SetMinMaxSizes(250, RETAIN, 250, RETAIN);
00469 tWnd->GetClientArea(clX, clY, clW, clH);
00470 panesWnd = new FourPanesWindow(tWnd, clX, clY, clW, clH);
00471 tWnd->SetContentPane(panesWnd);
00472
00473 for (i=0; i<4; i++)
00474 {
00475 woggelWnd = WoggelWindow(panesWnd, 0, 0, 100, 100);
00476 panesWnd->RegisterPane(woggelWnd, i);
00477 }
00478 panesWnd->LayoutPanes();
00479 FramesPerSecond* fpsWnd = new FramesPerSecond(panesWnd, 0, 0, 100, 20);
00480 }
00481
00482 void FillScrollContent(Window *wnd, char *str, int n, int m)
00483 {
00484 char buf[100];
00485 Button* btn;
00486 int i, j;
00487
00488 wnd->SetDisableOGLViewKeys(true);
00489 wnd->SetDisableOGLViewMouse(true);
00490
00491 wnd->SetDimensions(0, 0, 4 + m * 180, 4 + n * 80);
00492 for (i=0; i<n; i++)
00493 for (j=0; j<m; j++)
00494 {
00495 sprintf(buf, "%s[%d,%d]", str, i, j);
00496 btn = new Button(wnd, 2 + j * 180, 2 + i * 80, 70, 60,
00497 buf, 1 + (j+i)%6, !(i%2));
00498 if (i < (n/2))
00499 btn->SetBorderFillShaded(1 );
00500 }
00501 }
00502
00503 void RotateSelectedViews(Window* wnd)
00504 {
00505 TitledWindow* titW = new TitledWindow(wnd, 20, 20, 408, 332, "Rotating",
00506 TitledWindow::BtnMaxClose);
00507 Window* pane = new Window(GroupRotateChild(titW->GetOGLWND(),
00508 0, 0, 10, 10), false);
00509 OGLWND* oglW = wnd->GetOGLWND();
00510 LIST* obj = oglW->objectList;
00511
00512 if (!obj) return;
00513
00514 titW->SetContentPane(pane);
00515
00516 float z = -5.0;
00517 while (obj->next) obj = obj->next;
00518 while (obj)
00519 {
00520 OGLVIEW* view = (OGLVIEW *) obj->info;
00521 if (viewSys.HasTags(view,selectedTag))
00522 {
00523 float x = -2.0f + view->x / 100.0f;
00524 float y = -2.0f + view->y / 100.0f;
00525 OGLVIEW3D* v3D = ImToGroupRotate(pane->GetOGLWND(), view->im,
00526 x, y, z, view->w/100.f,
00527 view->h/100.f,1.f );
00528 view3DSys.SetZoom(v3D, view->w/100.0f, view->h/100.f);
00529
00530 view3DSys.SetTags(v3D, selectedTag);
00531 z -= 0.2f;
00532 }
00533 obj = obj->prev;
00534 }
00535 pane->KeyboardFunc('s', 0);
00536 oglSys.AllowPicking(pane->GetOGLWND(),true,true);
00537 oglSys.SetAllowCameraMove(pane->GetOGLWND(),true);
00538 }
00539
00540 TitledWindow* TitledSixViewer(Window* parent, int x, int y, int w, int h)
00541 {
00542 TitledWindow* titWnd = new TitledWindow(parent, 0, 0, 508, 532,
00543 "Six Viewer Control",
00544 TitledWindow::BtnMax);
00545 Window* pane = titWnd->ContentPane();
00546 int W = pane->W();
00547 int H = pane->H();
00548 SixView2DWindow* v6Wnd = new SixView2DWindow(pane,0,108,W,H-112);
00549 ZoomPanControl* zPanC = new ZoomPanControl(pane,0,0,W/2,108,v6Wnd,10);
00550 LenseControl* lenseC = new LenseControl(pane,W/2+2,2,W/2-2,104,100);
00551 LENSE* lense = Lense2D(v6Wnd->GetOGLWND(),100,200,128,128);
00552
00553 for (int i=0; i<6; i++)
00554 {
00555 OGLIMAGE* oglIm;
00556 char buf[100];
00557 sprintf(buf, "Im_%d.png", i+1);
00558 oglIm = TryReadPNG(buf);
00559 v6Wnd->SetImage(oglIm, i);
00560 oglSys.ReleaseOglImage( oglIm );
00561 }
00562
00563 viewSys.SetTags(v6Wnd->GetView(0), selectedTag);
00564 v6Wnd->SetWindowListener(this, scExtraControl);
00565 v6Wnd ->ConnectTo(pane);
00566 zPanC ->ScaleTo(pane, NoVertical);
00567 lenseC->ScaleTo(pane, NoVertical);
00568 lenseC->ScaleChildren(0, 1);
00569 lenseC->SetLenseTarget(lense);
00570 titWnd->SetDimensions(x, y, w, h);
00571 return titWnd;
00572 }
00573
00574 TitledWindow*
00575 TitledZoomControl(Window* parent, int x,int y, int w,int h, Window* target)
00576 {
00577 TitledWindow* titWnd = new TitledWindow(parent,x,y,w,h,"Zoom Control");
00578 Window* pane = titWnd->ContentPane();
00579 ZoomControl* zoomC = new ZoomControl(pane,0,0,pane->W(),pane->H(),10);
00580 zoomC->SetZoomTarget(target);
00581 zoomC->ConnectTo(pane);
00582 return titWnd;
00583 }
00584
00585 TitledWindow*
00586 TitledPanControl(Window* parent, int x,int y, int w,int h, Window* target)
00587 {
00588 TitledWindow* titWnd = new TitledWindow(parent,x,y,w,h,"Pan Control",
00589 TitledWindow::BtnMaxClose);
00590 Window* pane = titWnd->ContentPane();
00591 Window* panC = new Window(pane, 0, 0, pane->W(), pane->H());
00592
00593 ZoomPanFuncs(panC->GetOGLWND(), target->GetOGLWND(), 1, 1, "Pan");
00594 panC->SetBorderFillShaded(2);
00595 panC->ConnectTo(pane);
00596 return titWnd;
00597 }
00598
00599 TitledWindow*
00600 TitledLenseControl(Window* parent, int x,int y,int w,int h, Window* target)
00601 {
00602 TitledWindow* titWnd = new TitledWindow(parent,x,y,w,h,"Lense Control");
00603 Window* pane = titWnd->ContentPane();
00604 int pW = pane->W();
00605 int pH = pane->H();
00606
00607 LenseControl* lenseC = new LenseControl(pane,0, 0, pW, pH, 100);
00608 LENSE* lense = Lense2D(target->GetOGLWND(), 100, 200, 128, 128);
00609 lenseC->SetLenseTarget(lense);
00610 lenseC->ConnectTo(pane);
00611 return titWnd;
00612 }
00613
00614 TitledWindow*
00615 TitledZoomPanLense(Window* parent, int x, int y, int w, int h)
00616 {
00617 TitledWindow* titWnd = TitledViews(parent,x,y,w,h,"Zoom Pan Lense");
00618 Window* pane = titWnd->ContentPane();
00619 int pW = pane->W();
00620
00621 TitledZoomControl(pane, 0, 0, pW/2, 140, pane);
00622 TitledPanControl(pane, 0, 160, 160, 160, pane);
00623 TitledLenseControl(pane, pW/2+2, 0, pW/2, 140, pane);
00624 pane->SetWindowListener(this, scExtraControl);
00625
00626 return titWnd;
00627 }
00628
00629 static void MyOnDrawView2D(OGLVIEW* view)
00630 {
00631 OGC myOGC;
00632 int bInfo[3];
00633
00634 OGCSave(&myOGC);
00635 glPushMatrix();
00636 oglSys.StartBlend(bInfo);
00637
00638 SetFillColors(oglRED, oglGREEN, oglBLUE, oglWHITE, 0x80000000);
00639
00640 viewSys.View2DNormTransform(view);
00641 FillOval(1.f, 1.f, 0.25f, 0.25f);
00642
00643
00644 viewSys.View2DImageNormTransform(view);
00645 FillOval(0.f,0.f, 0.25f, 0.25f);
00646
00647 oglSys.EndBlend(bInfo);
00648 glPopMatrix();
00649 OGCRestore(&myOGC);
00650 }
00651
00652 static void MyOnDrawView3D(OGLVIEW3D* view)
00653 {
00654 OGC myOGC;
00655 int bInfo[3];
00656
00657 OGCSave(&myOGC);
00658 glPushMatrix();
00659 oglSys.StartBlend(bInfo);
00660
00661 SetFillColors(oglRED, oglGREEN, oglBLUE, oglBLACK, 0x80ffffff);
00662
00663 view3DSys.View3DNormTransform(view);
00664 FillEllipse3D(0.5f, 0.5f, 0.01f, 0.25f, 0.25f, 0.35f, 0.15f);
00665
00666 SetFillColors(oglBLACK, oglBLACK, oglBLACK, oglRED, oglTrWHITE);
00667
00668 view3DSys.View3DImageNormTransform(view);
00669 FillOval3D(0.0f, 0.0f, 0.01f, 0.25f, 0.25f);
00670
00671 oglSys.EndBlend(bInfo);
00672 glPopMatrix();
00673 OGCRestore(&myOGC);
00674 }
00675
00676 void SetOnDrawViewGraphics(Window* src, bool drawGraphics=true)
00677 {
00678 OGLWND* oglWnd = src->GetOGLWND();
00679 LIST* obj;
00680
00681 ForAllElements(obj, oglWnd->objectList)
00682 {
00683 if (src->Is2d())
00684 {
00685 OGLVIEW* view = (OGLVIEW*) obj->info;
00686 if (viewSys.HasTags(view, selectedTag))
00687 view->OnDrawView = drawGraphics ? MyOnDrawView2D : 0;
00688 }
00689 else
00690 {
00691 OGLVIEW3D* view = (OGLVIEW3D*) obj->info;
00692 if (view3DSys.HasTags(view, selectedTag))
00693 view->OnDrawView = drawGraphics ? MyOnDrawView3D : 0;
00694 }
00695 }
00696 }
00697
00698 private:
00699 Tabs *mTabs;
00700 };
00701
00702 }
00703
00704 extern "C" OGLWND* C_OglDemo(OGLWND* parent, int x, int y ,int w, int h)
00705 {
00706 OglGui::OglDemo* oglDemo = new OglGui::OglDemo(parent, x, y, w, h);
00707 return oglDemo->GetOGLWND();
00708 }
00709 #endif