Main Page | Class Hierarchy | Class List | File List | Class Members | Related Pages

D:/Programming/GUI Editor (Source)/GUIEditorView.cpp

00001 // GUIEditView.cpp : implementation of the CGUIEditorView class 00002 // 00003 00004 #include "stdafx.h" 00005 #include "GUIEditor.h" 00006 00007 #include "GUIEditorDoc.h" 00008 #include "GUIEditorView.h" 00009 #include ".\guieditorview.h" 00010 00011 #ifdef _DEBUG 00012 #define new DEBUG_NEW 00013 #undef THIS_FILE 00014 static char THIS_FILE[] = __FILE__; 00015 #endif 00016 00018 // CGUIEditorView 00019 00020 IMPLEMENT_DYNCREATE(CGUIEditorView, CView) 00021 00022 BEGIN_MESSAGE_MAP(CGUIEditorView, CView) 00023 //{{AFX_MSG_MAP(CGUIEditorView) 00024 ON_COMMAND(ID_FILE_PRINT_PREVIEW, OnFilePrintPreview) 00025 //}}AFX_MSG_MAP 00026 // Standard printing commands 00027 ON_COMMAND(ID_FILE_PRINT_DIRECT, CView::OnFilePrint) 00028 ON_COMMAND(ID_FILE_PRINT_PREVIEW, CView::OnFilePrintPreview) 00029 ON_WM_CREATE() 00030 ON_WM_KEYDOWN() 00031 ON_WM_SIZE() 00032 ON_COMMAND(ID_RESOURCES_TEXTURES, OnResourcesTextures) 00033 ON_COMMAND(ID_RESOURCES_MATERIALS, OnResourcesMaterials) 00034 ON_WM_ERASEBKGND() 00035 ON_COMMAND(ID_RESOURCES_ANIMATIONS, OnResourcesAnimations) 00036 ON_COMMAND(ID_RESOURCES_FONTS, OnResourcesFonts) 00037 ON_COMMAND(ID_GUI_PROPERTIES, OnGuiProperties) 00038 ON_WM_DESTROY() 00039 ON_COMMAND(ID_ADD_ELEMENT, OnAddElement) 00040 ON_COMMAND(ID_ADD_STATIC, OnAddStatic) 00041 ON_COMMAND(ID_ADD_TEXTBOX, OnAddTextbox) 00042 ON_COMMAND(ID_ADD_BUTTON, OnAddButton) 00043 ON_COMMAND(ID_ADD_SCROLLBAR_HORIZONTAL, OnAddScrollbarHorizontal) 00044 ON_COMMAND(ID_ADD_SCROLLBAR_VERTICAL, OnAddScrollbarVertical) 00045 ON_COMMAND(ID_ADD_PROGRESSBAR_HORIZONTAL, OnAddProgressbarHorizontal) 00046 ON_COMMAND(ID_ADD_PROGRESSBAR_VERTICAL, OnAddProgressbarVertical) 00047 ON_COMMAND(ID_ADD_DROPLIST, OnAddDroplist) 00048 ON_COMMAND(ID_ADD_LISTBOX, OnAddListbox) 00049 ON_COMMAND(ID_ADD_MENU, OnAddMenu) 00050 ON_COMMAND(ID_ADD_TABCONTROL, OnAddTabcontrol) 00051 ON_COMMAND(ID_ADD_WINDOW, OnAddWindow) 00052 ON_COMMAND(ID_ADD_BORDER, OnAddBorder) 00053 ON_COMMAND(ID_REMOVE_BORDER, OnGuiRemoveBorder) 00054 ON_COMMAND(ID_FILE_SAVE_EX, OnFileSaveEx) 00055 ON_COMMAND(ID_FILE_SAVE_AS_EX, OnFileSaveAsEx) 00056 ON_COMMAND(ID_ADD_RADIOGROUP, OnAddRadiogroup) 00057 END_MESSAGE_MAP() 00058 00060 // CGUIEditorView construction/destruction 00061 00062 CGUIEditorView::CGUIEditorView() 00063 { 00064 00065 } 00066 00067 CGUIEditorView::~CGUIEditorView() 00068 { 00069 m_lstSelection.erase(false); 00070 } 00071 00072 BOOL CGUIEditorView::PreCreateWindow(CREATESTRUCT& cs) 00073 { 00074 // TODO: Modify the Window class or styles here by modifying 00075 // the CREATESTRUCT cs 00076 00077 return CView::PreCreateWindow(cs); 00078 } 00079 00081 // CGUIEditorView drawing 00082 00083 void CGUIEditorView::OnDraw(CDC* pDC) 00084 { 00085 00086 } 00087 00088 void CGUIEditorView::RenderGLScene() 00089 { 00090 glEnable(GL_TEXTURE_2D);// Enable Texture Mapping ( NEW ) 00091 glShadeModel(GL_SMOOTH);// Enable Smooth Shading 00092 glClearColor(0.0f, 0.0f, 0.0f, 0.5f);// Black Background 00093 glClearDepth(1.0f);// Depth Buffer Setup 00094 glEnable(GL_DEPTH_TEST);// Enables Depth Testing 00095 glDepthFunc(GL_LEQUAL);// The Type Of Depth Testing To Do 00096 glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);// Really Nice Perspective Calculations 00097 00098 // Device context for painting 00099 CGUIEditorDoc *pDoc = (CGUIEditorDoc *)GetDocument(); 00100 ASSERT_VALID(pDoc); 00101 00102 // Useful in multidoc templates 00103 HWND hWnd = GetSafeHwnd(); 00104 HDC hDC = m_hDC; 00105 00106 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 00107 glLoadIdentity(); 00108 00109 int viewport[4]; 00110 glGetIntegerv(GL_VIEWPORT, viewport); 00111 00112 BeginOrtho(); 00113 // Position / translation / scale 00114 00115 if(pDoc !=NULL) 00116 { 00117 if(pDoc->GetGUI() !=NULL) 00118 { 00119 pDoc->GetGUI()->Update(); 00120 pDoc->GetGUI()->Draw(); 00121 } 00122 } 00123 00124 EndOrtho(); 00125 00126 // Double buffer 00127 glFlush(); 00128 SwapBuffers(m_hDC); 00129 } 00130 00131 BOOL CGUIEditorView::OnPreparePrinting(CPrintInfo* pInfo) 00132 { 00133 // default preparation 00134 return DoPreparePrinting(pInfo); 00135 } 00136 00137 void CGUIEditorView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/) 00138 { 00139 // TODO: add extra initialization before printing 00140 } 00141 00142 void CGUIEditorView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/) 00143 { 00144 // TODO: add cleanup after printing 00145 } 00146 00148 // CGUIEditorView diagnostics 00149 00150 #ifdef _DEBUG 00151 void CGUIEditorView::AssertValid() const 00152 { 00153 CView::AssertValid(); 00154 } 00155 00156 void CGUIEditorView::Dump(CDumpContext& dc) const 00157 { 00158 CView::Dump(dc); 00159 } 00160 00161 CGUIEditorDoc* CGUIEditorView::GetDocument() // non-debug version is inline 00162 { 00163 ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CGUIEditorDoc))); 00164 return (CGUIEditorDoc*)m_pDocument; 00165 } 00166 #endif //_DEBUG 00167 00168 CChildFrame *CGUIEditorView::GetActiveChild() 00169 { 00170 CMDIFrameWnd* pParent = ((CMDIFrameWnd *)AfxGetMainWnd()); 00171 return ((CChildFrame *)pParent->MDIGetActive()); 00172 } 00173 00174 void CGUIEditorView::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags) 00175 { 00176 switch(nChar) 00177 { 00178 case VK_DELETE: 00179 { 00180 CGUIElement *pIter = GetFirstSelection(); 00181 while(pIter !=NULL) 00182 { 00183 pIter->GetParent()->RemoveChild(pIter); 00184 pIter = GetNextSelection(); 00185 } 00186 00187 m_lstSelection.erase(false); 00188 CMainFrame *pMainFrame = (CMainFrame *)AfxGetMainWnd(); 00189 pMainFrame->SelectElement(NULL); 00190 00191 break; 00192 } 00193 00194 case VK_LEFT: 00195 { 00196 if(GetAsyncKeyState(VK_LSHIFT) < 0) 00197 { 00198 CGUIElement *pIter = GetFirstSelection(); 00199 while(pIter !=NULL) 00200 { 00201 tRect Rect = pIter->GetRect(); 00202 tRect NewRect(Rect.left - 1, Rect.right, Rect.top, Rect.bottom); 00203 pIter->Resize(NewRect); 00204 00205 pIter = GetNextSelection(); 00206 } 00207 } 00208 else 00209 { 00210 CGUIElement *pIter = GetFirstSelection(); 00211 while(pIter !=NULL) 00212 { 00213 tRect Rect = pIter->GetRect(); 00214 tRect NewRect(Rect.left - 1, Rect.right - 1, Rect.top, Rect.bottom); 00215 pIter->Resize(NewRect); 00216 00217 pIter = GetNextSelection(); 00218 } 00219 } 00220 00221 if(GetAsyncKeyState(VK_CONTROL) < 0) 00222 { 00223 CGUIElement *pIter = GetFirstSelection(); 00224 while(pIter !=NULL) 00225 { 00226 tRect Rect = pIter->GetRect(); 00227 tRect NewRect(Rect.left + 1, Rect.right, Rect.top, Rect.bottom); 00228 pIter->Resize(NewRect); 00229 00230 pIter = GetNextSelection(); 00231 } 00232 } 00233 00234 InvalidateRect(NULL, TRUE); 00235 break; 00236 } 00237 00238 case VK_RIGHT: 00239 { 00240 if(GetAsyncKeyState(VK_LSHIFT) < 0) 00241 { 00242 CGUIElement *pIter = GetFirstSelection(); 00243 while(pIter !=NULL) 00244 { 00245 tRect Rect = pIter->GetRect(); 00246 tRect NewRect(Rect.left, Rect.right + 1, Rect.top, Rect.bottom); 00247 pIter->Resize(NewRect); 00248 00249 pIter = GetNextSelection(); 00250 } 00251 } 00252 else 00253 { 00254 CGUIElement *pIter = GetFirstSelection(); 00255 while(pIter !=NULL) 00256 { 00257 tRect Rect = pIter->GetRect(); 00258 tRect NewRect(Rect.left + 1, Rect.right + 1, Rect.top, Rect.bottom); 00259 pIter->Resize(NewRect); 00260 00261 pIter = GetNextSelection(); 00262 } 00263 } 00264 00265 if(GetAsyncKeyState(VK_CONTROL) < 0) 00266 { 00267 CGUIElement *pIter = GetFirstSelection(); 00268 while(pIter !=NULL) 00269 { 00270 tRect Rect = pIter->GetRect(); 00271 tRect NewRect(Rect.left, Rect.right - 1, Rect.top, Rect.bottom); 00272 pIter->Resize(NewRect); 00273 00274 pIter = GetNextSelection(); 00275 } 00276 } 00277 00278 InvalidateRect(NULL, TRUE); 00279 break; 00280 } 00281 00282 case VK_UP: 00283 { 00284 if(GetAsyncKeyState(VK_LSHIFT) < 0) 00285 { 00286 CGUIElement *pIter = GetFirstSelection(); 00287 while(pIter !=NULL) 00288 { 00289 tRect Rect = pIter->GetRect(); 00290 tRect NewRect(Rect.left, Rect.right, Rect.top + 1, Rect.bottom); 00291 pIter->Resize(NewRect); 00292 00293 pIter = GetNextSelection(); 00294 } 00295 } 00296 else 00297 { 00298 CGUIElement *pIter = GetFirstSelection(); 00299 while(pIter !=NULL) 00300 { 00301 tRect Rect = pIter->GetRect(); 00302 tRect NewRect(Rect.left, Rect.right, Rect.top + 1, Rect.bottom + 1); 00303 pIter->Resize(NewRect); 00304 00305 pIter = GetNextSelection(); 00306 } 00307 } 00308 00309 if(GetAsyncKeyState(VK_CONTROL) < 0) 00310 { 00311 CGUIElement *pIter = GetFirstSelection(); 00312 while(pIter !=NULL) 00313 { 00314 tRect Rect = pIter->GetRect(); 00315 tRect NewRect(Rect.left, Rect.right, Rect.top - 1, Rect.bottom); 00316 pIter->Resize(NewRect); 00317 00318 pIter = GetNextSelection(); 00319 } 00320 } 00321 00322 InvalidateRect(NULL, TRUE); 00323 break; 00324 } 00325 00326 case VK_DOWN: 00327 { 00328 if(GetAsyncKeyState(VK_LSHIFT) < 0) 00329 { 00330 CGUIElement *pIter = GetFirstSelection(); 00331 while(pIter !=NULL) 00332 { 00333 tRect Rect = pIter->GetRect(); 00334 tRect NewRect(Rect.left, Rect.right, Rect.top, Rect.bottom - 1); 00335 pIter->Resize(NewRect); 00336 00337 pIter = GetNextSelection(); 00338 } 00339 } 00340 else 00341 { 00342 CGUIElement *pIter = GetFirstSelection(); 00343 while(pIter !=NULL) 00344 { 00345 tRect Rect = pIter->GetRect(); 00346 tRect NewRect(Rect.left, Rect.right, Rect.top - 1, Rect.bottom - 1); 00347 pIter->Resize(NewRect); 00348 00349 pIter = GetNextSelection(); 00350 } 00351 } 00352 00353 if(GetAsyncKeyState(VK_CONTROL) < 0) 00354 { 00355 CGUIElement *pIter = GetFirstSelection(); 00356 while(pIter !=NULL) 00357 { 00358 tRect Rect = pIter->GetRect(); 00359 tRect NewRect(Rect.left, Rect.right, Rect.top, Rect.bottom + 1); 00360 pIter->Resize(NewRect); 00361 00362 pIter = GetNextSelection(); 00363 } 00364 } 00365 00366 InvalidateRect(NULL, TRUE); 00367 break; 00368 } 00369 } 00370 } 00371 00372 int CGUIEditorView::OnCreate(LPCREATESTRUCT lpCreateStruct) 00373 { 00374 if(CView::OnCreate(lpCreateStruct) == -1) 00375 return -1; 00376 00377 m_hDC = this->GetDC()->GetSafeHdc(); 00378 HWND hWnd = GetSafeHwnd(); 00379 00380 CMainFrame *pMainFrame = (CMainFrame *)AfxGetMainWnd(); 00381 00382 pMainFrame->SetWindowPixelFormat(m_hDC); 00383 pMainFrame->CreateViewGLContext(m_hDC); 00384 00385 return 1; 00386 } 00387 00388 void CGUIEditorView::OnSize(UINT nType, int cx, int cy) 00389 { 00390 CView::OnSize(nType, cx, cy); 00391 00392 if(cx == 0 || cy == 0) 00393 return; 00394 00395 HWND hWnd = GetSafeHwnd(); 00396 HDC hDC = m_hDC; 00397 00398 CMainFrame *pMainFrame = (CMainFrame *)AfxGetMainWnd(); 00399 if(pMainFrame->m_hRC == NULL) 00400 return; 00401 00402 // Make the rendering context current 00403 glViewport(0, 0, cx, cy); // Reset The Current Viewport 00404 00405 int Viewport[4]; 00406 00407 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix 00408 glPushMatrix(); // Store The Projection Matrix 00409 glLoadIdentity(); // Reset The Projection Matrix 00410 glGetIntegerv(GL_VIEWPORT, Viewport); 00411 glOrtho(0, Viewport[2], 0, Viewport[3], 0, 100); // Set Up An Ortho Screen 00412 00413 glMatrixMode(GL_MODELVIEW); 00414 } 00415 00416 BOOL CGUIEditorView::OnEraseBkgnd(CDC* pDC) 00417 { 00418 // TODO: Add your message handler code here and/or call default 00419 00420 return TRUE; 00421 } 00422 00423 void CGUIEditorView::OnResourcesTextures() 00424 { 00425 CMainFrame *pMainFrame = (CMainFrame *)AfxGetMainWnd(); 00426 pMainFrame->m_pResourceSettings = pMainFrame->m_pTextureSettings; 00427 00428 pMainFrame->m_ResourceSettingsDlg.SetPropPointer(pMainFrame->m_pResourceSettings); 00429 pMainFrame->m_ResourceSettingsDlg.ShowWindow(SW_SHOW); 00430 } 00431 00432 void CGUIEditorView::OnResourcesMaterials() 00433 { 00434 CMainFrame *pMainFrame = (CMainFrame *)AfxGetMainWnd(); 00435 pMainFrame->m_pResourceSettings = pMainFrame->m_pMaterialSettings; 00436 00437 pMainFrame->m_ResourceSettingsDlg.SetPropPointer(pMainFrame->m_pResourceSettings); 00438 pMainFrame->m_ResourceSettingsDlg.ShowWindow(SW_SHOW); 00439 } 00440 00441 void CGUIEditorView::OnResourcesAnimations() 00442 { 00443 CMainFrame *pMainFrame = (CMainFrame *)AfxGetMainWnd(); 00444 pMainFrame->m_pResourceSettings = pMainFrame->m_pAnimationSettings; 00445 00446 pMainFrame->m_ResourceSettingsDlg.SetPropPointer(pMainFrame->m_pResourceSettings); 00447 pMainFrame->m_ResourceSettingsDlg.ShowWindow(SW_SHOW); 00448 } 00449 00450 void CGUIEditorView::OnResourcesFonts() 00451 { 00452 CMainFrame *pMainFrame = (CMainFrame *)AfxGetMainWnd(); 00453 pMainFrame->m_pResourceSettings = pMainFrame->m_pFontSettings; 00454 00455 pMainFrame->m_ResourceSettingsDlg.SetPropPointer(pMainFrame->m_pResourceSettings); 00456 pMainFrame->m_ResourceSettingsDlg.ShowWindow(SW_SHOW); 00457 } 00458 00459 void CGUIEditorView::OnGuiProperties() 00460 { 00461 CMainFrame *pMainFrame = (CMainFrame *)AfxGetMainWnd(); 00462 pMainFrame->m_GUISettingsDlg.ShowWindow(SW_SHOW); 00463 } 00464 00465 LRESULT CGUIEditorView::WindowProc(UINT uiMessage, WPARAM wParam, LPARAM lParam) 00466 { 00467 switch(uiMessage) 00468 { 00469 case WM_LBUTTONDOWN: 00470 { 00471 CInputEngine::GetSingleton().GetMouse()->SetKeyState(VK_LBUTTON, KEY_DOWN); 00472 break; 00473 } 00474 00475 case WM_LBUTTONUP: 00476 { 00477 CInputEngine::GetSingleton().GetMouse()->SetKeyState(VK_LBUTTON, KEY_UP); 00478 00479 CMainFrame *pMainFrame = (CMainFrame *)AfxGetMainWnd(); 00480 CGUIEditorDoc *pDoc = (CGUIEditorDoc *)GetDocument(); 00481 ASSERT_VALID(pDoc); 00482 00483 if(pMainFrame !=NULL) 00484 { 00485 if(pDoc !=NULL) 00486 { 00487 if(pDoc->GetGUI() !=NULL) 00488 { 00489 pDoc->GetGUI()->Update(); 00490 00491 pMainFrame->m_pGUIElement = pDoc->GetGUI()->GetActiveElement(); 00492 00493 if(GetAsyncKeyState(VK_LSHIFT) < 0) 00494 AddToSelection(pMainFrame->m_pGUIElement); 00495 else 00496 { 00497 if(GetSelectionCount() >= 0) 00498 { 00499 ClearSelection(); 00500 AddToSelection(pMainFrame->m_pGUIElement); 00501 } 00502 } 00503 00504 if(pMainFrame->m_pGUIElement !=NULL) 00505 pMainFrame->m_pGUIElement->m_bUpdateRequired = true; 00506 } 00507 } 00508 } 00509 00510 break; 00511 } 00512 00513 case WM_RBUTTONDOWN: 00514 { 00515 CInputEngine::GetSingleton().GetMouse()->SetKeyState(VK_RBUTTON, KEY_DOWN); 00516 break; 00517 } 00518 00519 case WM_RBUTTONUP: 00520 { 00521 CInputEngine::GetSingleton().GetMouse()->SetKeyState(VK_RBUTTON, KEY_UP); 00522 } 00523 } 00524 00525 return CView::WindowProc(uiMessage, wParam, lParam); 00526 } 00527 00528 void CGUIEditorView::OnDestroy() 00529 { 00530 CMainFrame *pMainFrame = (CMainFrame *)AfxGetMainWnd(); 00531 pMainFrame->m_pGUIElement = NULL; 00532 00533 ::ReleaseDC(m_hWnd, m_hDC); 00534 } 00535 00536 void CGUIEditorView::OnAddElement() 00537 { 00538 CMainFrame *pMainFrame = (CMainFrame *)AfxGetMainWnd(); 00539 CGUIEditorDoc *pDoc = (CGUIEditorDoc *)GetDocument(); 00540 ASSERT_VALID(pDoc); 00541 00542 if(pMainFrame !=NULL) 00543 { 00544 if(pDoc !=NULL) 00545 { 00546 if(pDoc->GetGUI() !=NULL) 00547 { 00548 tRect WidgetRect = GenerateRandomRect(20, 200, 20, 200); 00549 CGUIElement *pNewElement = new CGUIElement; 00550 00551 pNewElement->Create(pDoc->GetGUI(), WidgetRect); 00552 pDoc->GetGUI()->push_back(pNewElement); 00553 } 00554 } 00555 } 00556 } 00557 00558 void CGUIEditorView::OnAddStatic() 00559 { 00560 CMainFrame *pMainFrame = (CMainFrame *)AfxGetMainWnd(); 00561 CGUIEditorDoc *pDoc = (CGUIEditorDoc *)GetDocument(); 00562 ASSERT_VALID(pDoc); 00563 00564 if(pMainFrame !=NULL) 00565 { 00566 if(pDoc !=NULL) 00567 { 00568 if(pDoc->GetGUI() !=NULL) 00569 { 00570 tRect WidgetRect = GenerateRandomRect(40, 200, 20, 200); 00571 CGUIStatic *pNewStatic = new CGUIStatic; 00572 00573 pNewStatic->Create(pDoc->GetGUI(), WidgetRect); 00574 pDoc->GetGUI()->push_back(pNewStatic); 00575 } 00576 } 00577 } 00578 } 00579 00580 void CGUIEditorView::OnAddTextbox() 00581 { 00582 CMainFrame *pMainFrame = (CMainFrame *)AfxGetMainWnd(); 00583 CGUIEditorDoc *pDoc = (CGUIEditorDoc *)GetDocument(); 00584 ASSERT_VALID(pDoc); 00585 00586 if(pMainFrame !=NULL) 00587 { 00588 if(pDoc !=NULL) 00589 { 00590 if(pDoc->GetGUI() !=NULL) 00591 { 00592 tRect WidgetRect = GenerateRandomRect(20, 200, 20, 200); 00593 CGUITextBox *pNewTextBox = new CGUITextBox; 00594 00595 pNewTextBox->Create(pDoc->GetGUI(), WidgetRect); 00596 pDoc->GetGUI()->push_back(pNewTextBox); 00597 } 00598 } 00599 } 00600 } 00601 00602 void CGUIEditorView::OnAddButton() 00603 { 00604 CMainFrame *pMainFrame = (CMainFrame *)AfxGetMainWnd(); 00605 CGUIEditorDoc *pDoc = (CGUIEditorDoc *)GetDocument(); 00606 ASSERT_VALID(pDoc); 00607 00608 if(pMainFrame !=NULL) 00609 { 00610 if(pDoc !=NULL) 00611 { 00612 if(pDoc->GetGUI() !=NULL) 00613 { 00614 tRect WidgetRect = GenerateRandomRect(40, 200, 20, 40); 00615 CGUIButton *pNewButton = new CGUIButton; 00616 00617 pNewButton->Create(pDoc->GetGUI(), WidgetRect); 00618 pDoc->GetGUI()->push_back(pNewButton); 00619 } 00620 } 00621 } 00622 } 00623 00624 void CGUIEditorView::OnAddScrollbarHorizontal() 00625 { 00626 CMainFrame *pMainFrame = (CMainFrame *)AfxGetMainWnd(); 00627 CGUIEditorDoc *pDoc = (CGUIEditorDoc *)GetDocument(); 00628 ASSERT_VALID(pDoc); 00629 00630 if(pMainFrame !=NULL) 00631 { 00632 if(pDoc !=NULL) 00633 { 00634 if(pDoc->GetGUI() !=NULL) 00635 { 00636 tRect WidgetRect = GenerateRandomRect(100, 200, 20, 40); 00637 CGUIScrollBar *pNewScrollBar = new CGUIScrollBar; 00638 00639 pNewScrollBar->Create(pDoc->GetGUI(), WidgetRect, GUI_HorizontalScrollBar); 00640 pDoc->GetGUI()->push_back(pNewScrollBar); 00641 } 00642 } 00643 } 00644 } 00645 00646 void CGUIEditorView::OnAddScrollbarVertical() 00647 { 00648 CMainFrame *pMainFrame = (CMainFrame *)AfxGetMainWnd(); 00649 CGUIEditorDoc *pDoc = (CGUIEditorDoc *)GetDocument(); 00650 ASSERT_VALID(pDoc); 00651 00652 if(pMainFrame !=NULL) 00653 { 00654 if(pDoc !=NULL) 00655 { 00656 if(pDoc->GetGUI() !=NULL) 00657 { 00658 tRect WidgetRect = GenerateRandomRect(20, 40, 100, 200); 00659 CGUIScrollBar *pNewScrollBar = new CGUIScrollBar; 00660 00661 pNewScrollBar->Create(pDoc->GetGUI(), WidgetRect, GUI_VerticalScrollBar); 00662 pDoc->GetGUI()->push_back(pNewScrollBar); 00663 } 00664 } 00665 } 00666 } 00667 00668 void CGUIEditorView::OnAddProgressbarHorizontal() 00669 { 00670 CMainFrame *pMainFrame = (CMainFrame *)AfxGetMainWnd(); 00671 CGUIEditorDoc *pDoc = (CGUIEditorDoc *)GetDocument(); 00672 ASSERT_VALID(pDoc); 00673 00674 if(pMainFrame !=NULL) 00675 { 00676 if(pDoc !=NULL) 00677 { 00678 if(pDoc->GetGUI() !=NULL) 00679 { 00680 tRect WidgetRect = GenerateRandomRect(100, 200, 20, 40); 00681 CGUIProgressBar *pNewProgressBar = new CGUIProgressBar; 00682 00683 pNewProgressBar->Create(pDoc->GetGUI(), WidgetRect, GUI_HorizontalProgressBar); 00684 pDoc->GetGUI()->push_back(pNewProgressBar); 00685 } 00686 } 00687 } 00688 } 00689 00690 void CGUIEditorView::OnAddProgressbarVertical() 00691 { 00692 CMainFrame *pMainFrame = (CMainFrame *)AfxGetMainWnd(); 00693 CGUIEditorDoc *pDoc = (CGUIEditorDoc *)GetDocument(); 00694 ASSERT_VALID(pDoc); 00695 00696 if(pMainFrame !=NULL) 00697 { 00698 if(pDoc !=NULL) 00699 { 00700 if(pDoc->GetGUI() !=NULL) 00701 { 00702 tRect WidgetRect = GenerateRandomRect(20, 40, 100, 200); 00703 CGUIProgressBar *pNewProgressBar = new CGUIProgressBar; 00704 00705 pNewProgressBar->Create(pDoc->GetGUI(), WidgetRect, GUI_VerticalProgressBar); 00706 pDoc->GetGUI()->push_back(pNewProgressBar); 00707 } 00708 } 00709 } 00710 } 00711 00712 void CGUIEditorView::OnAddDroplist() 00713 { 00714 CMainFrame *pMainFrame = (CMainFrame *)AfxGetMainWnd(); 00715 CGUIEditorDoc *pDoc = (CGUIEditorDoc *)GetDocument(); 00716 ASSERT_VALID(pDoc); 00717 00718 if(pMainFrame !=NULL) 00719 { 00720 if(pDoc !=NULL) 00721 { 00722 if(pDoc->GetGUI() !=NULL) 00723 { 00724 tRect WidgetRect = GenerateRandomRect(40, 200, 20, 40); 00725 CGUIDropList *pNewDropList = new CGUIDropList; 00726 00727 pNewDropList->Create(pDoc->GetGUI(), WidgetRect); 00728 pDoc->GetGUI()->push_back(pNewDropList); 00729 } 00730 } 00731 } 00732 } 00733 00734 void CGUIEditorView::OnAddListbox() 00735 { 00736 CMainFrame *pMainFrame = (CMainFrame *)AfxGetMainWnd(); 00737 CGUIEditorDoc *pDoc = (CGUIEditorDoc *)GetDocument(); 00738 ASSERT_VALID(pDoc); 00739 00740 if(pMainFrame !=NULL) 00741 { 00742 if(pDoc !=NULL) 00743 { 00744 if(pDoc->GetGUI() !=NULL) 00745 { 00746 tRect WidgetRect = GenerateRandomRect(20, 200, 20, 200); 00747 CGUIListBox *pNewListBox = new CGUIListBox; 00748 00749 pNewListBox->Create(pDoc->GetGUI(), WidgetRect); 00750 pDoc->GetGUI()->push_back(pNewListBox); 00751 } 00752 } 00753 } 00754 } 00755 00756 00757 void CGUIEditorView::OnAddRadiogroup() 00758 { 00759 CMainFrame *pMainFrame = (CMainFrame *)AfxGetMainWnd(); 00760 CGUIEditorDoc *pDoc = (CGUIEditorDoc *)GetDocument(); 00761 ASSERT_VALID(pDoc); 00762 00763 if(pMainFrame !=NULL) 00764 { 00765 if(pDoc !=NULL) 00766 { 00767 if(pDoc->GetGUI() !=NULL) 00768 { 00769 tRect WidgetRect = GenerateRandomRect(20, 200, 20, 200); 00770 CGUIRadioGroup *pNewRadioGroup = new CGUIRadioGroup; 00771 00772 pNewRadioGroup->Create(pDoc->GetGUI(), WidgetRect); 00773 pDoc->GetGUI()->push_back(pNewRadioGroup); 00774 } 00775 } 00776 } 00777 } 00778 00779 void CGUIEditorView::OnAddMenu() 00780 { 00781 CMainFrame *pMainFrame = (CMainFrame *)AfxGetMainWnd(); 00782 CGUIEditorDoc *pDoc = (CGUIEditorDoc *)GetDocument(); 00783 ASSERT_VALID(pDoc); 00784 00785 if(pMainFrame !=NULL) 00786 { 00787 if(pDoc !=NULL) 00788 { 00789 if(pDoc->GetGUI() !=NULL) 00790 { 00791 tRect WidgetRect = GenerateRandomRect(40, 200, 20, 40); 00792 CGUIMenu *pNewMenu = new CGUIMenu; 00793 00794 pNewMenu->Create(pDoc->GetGUI(), WidgetRect); 00795 pDoc->GetGUI()->push_back(pNewMenu); 00796 } 00797 } 00798 } 00799 } 00800 00801 void CGUIEditorView::OnAddTabcontrol() 00802 { 00803 CMainFrame *pMainFrame = (CMainFrame *)AfxGetMainWnd(); 00804 CGUIEditorDoc *pDoc = (CGUIEditorDoc *)GetDocument(); 00805 ASSERT_VALID(pDoc); 00806 00807 if(pMainFrame !=NULL) 00808 { 00809 if(pDoc !=NULL) 00810 { 00811 if(pDoc->GetGUI() !=NULL) 00812 { 00813 tRect WidgetRect = GenerateRandomRect(40, 200, 20, 200); 00814 CGUITabControl *pNewTabControl = new CGUITabControl; 00815 00816 pNewTabControl->Create(pDoc->GetGUI(), WidgetRect); 00817 pDoc->GetGUI()->push_back(pNewTabControl); 00818 } 00819 } 00820 } 00821 } 00822 00823 void CGUIEditorView::OnAddWindow() 00824 { 00825 CMainFrame *pMainFrame = (CMainFrame *)AfxGetMainWnd(); 00826 CGUIEditorDoc *pDoc = (CGUIEditorDoc *)GetDocument(); 00827 ASSERT_VALID(pDoc); 00828 00829 if(pMainFrame !=NULL) 00830 { 00831 if(pDoc !=NULL) 00832 { 00833 if(pDoc->GetGUI() !=NULL) 00834 { 00835 tRect WidgetRect = GenerateRandomRect(100, 200, 100, 200); 00836 CGUIWindow *pNewWindow = new CGUIWindow; 00837 00838 pNewWindow->Create(pDoc->GetGUI(), WidgetRect); 00839 pDoc->GetGUI()->push_back(pNewWindow); 00840 } 00841 } 00842 } 00843 } 00844 00845 void CGUIEditorView::OnAddBorder() 00846 { 00847 CMainFrame *pMainFrame = (CMainFrame *)AfxGetMainWnd(); 00848 CGUIEditorDoc *pDoc = (CGUIEditorDoc *)GetDocument(); 00849 ASSERT_VALID(pDoc); 00850 00851 if(pMainFrame !=NULL) 00852 { 00853 if(pDoc !=NULL) 00854 { 00855 if(pDoc->GetGUI() !=NULL) 00856 { 00857 if(pDoc->GetGUI()->GetActiveElement() !=NULL && pDoc->GetGUI()->GetActiveElement()->GetType() !=GUI) 00858 { 00859 if(pDoc->GetGUI()->GetActiveElement()->GetChild(GUI_Border) !=NULL) 00860 return; 00861 else 00862 { 00863 CGUIBorder *pBorder = new CGUIBorder; 00864 pBorder->Create(pDoc->GetGUI()->GetActiveElement()); 00865 if(pBorder->LoadXML(NULL, "Data/Editor/XML/Border/default_border.xml")) 00866 { 00867 pDoc->GetGUI()->GetActiveElement()->push_back(pBorder); 00868 pDoc->GetGUI()->GetActiveElement()->Resize(pDoc->GetGUI()->GetActiveElement()->GetRect()); 00869 } 00870 else 00871 SAFEDEL(pBorder) 00872 } 00873 } 00874 } 00875 } 00876 } 00877 } 00878 00879 tRect CGUIEditorView::GenerateRandomRect(int MinWidth, int MaxWidth, int MinHeight, int MaxHeight) 00880 { 00881 tRect RetRect; 00882 00883 RetRect.left = Random(0, 300); 00884 RetRect.bottom = Random(0, 300); 00885 RetRect.right = RetRect.left + Random(MinWidth, MaxWidth); 00886 RetRect.top = RetRect.bottom + Random(MinHeight, MaxHeight); 00887 00888 return RetRect; 00889 } 00890 00891 00892 void CGUIEditorView::OnGuiRemoveBorder() 00893 { 00894 CMainFrame *pMainFrame = (CMainFrame *)AfxGetMainWnd(); 00895 CGUIEditorDoc *pDoc = (CGUIEditorDoc *)GetDocument(); 00896 ASSERT_VALID(pDoc); 00897 00898 if(pMainFrame !=NULL) 00899 { 00900 if(pDoc !=NULL) 00901 { 00902 if(pDoc->GetGUI() !=NULL) 00903 { 00904 if(pDoc->GetGUI()->GetActiveElement() !=NULL && pDoc->GetGUI()->GetActiveElement()->GetType() !=GUI) 00905 pDoc->GetGUI()->GetActiveElement()->RemoveChild(pDoc->GetGUI()->GetActiveElement()->GetChild(GUI_Border)); 00906 } 00907 } 00908 } 00909 } 00910 00911 void CGUIEditorView::OnFileSaveEx() 00912 { 00913 00914 } 00915 00916 void CGUIEditorView::OnFileSaveAsEx() 00917 { 00918 CMainFrame *pMainFrame = (CMainFrame *)AfxGetMainWnd(); 00919 CGUIEditorDoc *pDoc = (CGUIEditorDoc *)GetDocument(); 00920 ASSERT_VALID(pDoc); 00921 00922 if(pMainFrame !=NULL) 00923 { 00924 if(pDoc !=NULL) 00925 { 00926 if(pDoc->GetGUI() !=NULL) 00927 { 00928 CFileDialog FileDialog(TRUE, NULL, NULL, OFN_HIDEREADONLY|OFN_FILEMUSTEXIST, "XML Files (*.xml)|*.xml|All Files (*.*)|*.*||", AfxGetMainWnd()); 00929 00930 if ( FileDialog.DoModal() == IDOK) 00931 { 00932 if(pDoc->GetGUI() !=NULL) 00933 pDoc->GetGUI()->GetActiveElement()->SaveXML(NULL, FileDialog.GetPathName()); 00934 } 00935 } 00936 } 00937 } 00938 } 00939 00940 void CGUIEditorView::AddToSelection(CGUIElement *pElement) 00941 { 00942 m_lstSelection.push_back(pElement); 00943 } 00944 00945 void CGUIEditorView::ClearSelection() 00946 { 00947 m_lstSelection.erase(false); 00948 } 00949 00950 int CGUIEditorView::GetSelectionCount() 00951 { 00952 return m_lstSelection.size(); 00953 } 00954 00955 CGUIElement *CGUIEditorView::GetFirstSelection() 00956 { 00957 if(m_lstSelection.size() > 0) 00958 { 00959 m_lstSelection.set_ptr(m_lstSelection.begin()); 00960 return m_lstSelection.begin(); 00961 } 00962 00963 return NULL; 00964 } 00965 00966 CGUIElement *CGUIEditorView::GetNextSelection() 00967 { 00968 return m_lstSelection.next(); 00969 } 00970 00971

Generated on Sun Jul 17 21:34:26 2005 for OpenGL GUI by doxygen 1.3.8