Linux multi-monitor fullscreen support
[ryzomcore.git] / ryzom / tools / leveldesign / georges_dll / left_view.cpp
blobc0d8a69d922e84aae3bb0add4b5f6cbdabbd3615
1 // Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
2 // Copyright (C) 2010 Winch Gate Property Limited
3 //
4 // This source file has been modified by the following contributors:
5 // Copyright (C) 2019 Jan BOON (Kaetemi) <jan.boon@kaetemi.be>
6 //
7 // This program is free software: you can redistribute it and/or modify
8 // it under the terms of the GNU Affero General Public License as
9 // published by the Free Software Foundation, either version 3 of the
10 // License, or (at your option) any later version.
12 // This program is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU Affero General Public License for more details.
17 // You should have received a copy of the GNU Affero General Public License
18 // along with this program. If not, see <http://www.gnu.org/licenses/>.
20 #include "stdafx.h"
21 #include "georges_edit.h"
23 #include "main_frm.h"
24 #include "georges_edit_doc.h"
25 #include "georges_edit_view.h"
26 #include "left_view.h"
27 #include "action.h"
29 using namespace std;
30 using namespace NLGEORGES;
31 using namespace NLMISC;
35 // ***************************************************************************
36 // CLeftView
37 // ***************************************************************************
39 IMPLEMENT_DYNCREATE(CLeftView, CView)
41 // ***************************************************************************
43 BEGIN_MESSAGE_MAP(CLeftView, CView)
44 //{{AFX_MSG_MAP(CLeftView)
45 ON_WM_SIZE()
46 ON_WM_SETFOCUS()
47 ON_COMMAND(ID_EDIT_COPY, OnEditCopy)
48 ON_COMMAND(ID_EDIT_PASTE, OnEditPaste)
49 ON_COMMAND(ID_EDIT_CUT, OnEditCut)
50 ON_COMMAND(ID_INSERT, OnInsert)
51 ON_COMMAND(ID_DELETE, OnDelete)
52 ON_COMMAND(ID_EDIT_REDO, OnEditRedo)
53 ON_UPDATE_COMMAND_UI(ID_EDIT_REDO, OnUpdateEditRedo)
54 ON_COMMAND(ID_EDIT_UNDO, OnEditUndo)
55 ON_UPDATE_COMMAND_UI(ID_EDIT_UNDO, OnUpdateEditUndo)
56 ON_COMMAND(ID_EDIT_RENAME, OnEditRename)
57 ON_COMMAND(ID_EDIT_FETCH1, OnEditFetch1)
58 ON_COMMAND(ID_EDIT_FETCH2, OnEditFetch2)
59 ON_COMMAND(ID_EDIT_FETCH3, OnEditFetch3)
60 ON_COMMAND(ID_EDIT_FETCH4, OnEditFetch4)
61 ON_COMMAND(ID_EDIT_HOLD1, OnEditHold1)
62 ON_COMMAND(ID_EDIT_HOLD2, OnEditHold2)
63 ON_COMMAND(ID_EDIT_HOLD3, OnEditHold3)
64 ON_COMMAND(ID_EDIT_HOLD4, OnEditHold4)
65 ON_WM_KEYDOWN()
66 ON_COMMAND(ID_EDIT_COLLAPSEALL, OnEditCollapseall)
67 ON_COMMAND(ID_EDIT_EXPANDALL, OnEditExpandall)
68 //}}AFX_MSG_MAP
69 END_MESSAGE_MAP()
71 // ***************************************************************************
72 // CLeftView construction/destruction
73 // ***************************************************************************
75 CLeftView::CLeftView()
79 // ***************************************************************************
81 CLeftView::~CLeftView()
85 // ***************************************************************************
87 BOOL CLeftView::PreCreateWindow(CREATESTRUCT& cs)
89 // TODO: Modify the Window class or styles here by modifying
90 // the CREATESTRUCT cs
92 return CView::PreCreateWindow(cs);
95 // ***************************************************************************
96 // CLeftView drawing
97 // ***************************************************************************
99 void CLeftView::OnDraw(CDC* pDC)
101 CGeorgesEditDoc* pDoc = GetDocument();
102 ASSERT_VALID(pDoc);
104 // TODO: add draw code for native data here
107 // ***************************************************************************
109 void CLeftView::getSubObject (CGeorgesEditDocSub *subObject, HTREEITEM parent, HTREEITEM item)
111 // Is this child exist ?
112 if (!item)
114 int itemImage = subObject->getItemImage (GetDocument());
115 item = TreeCtrl.InsertItem(nlUtf8ToTStr(subObject->getName()), itemImage, itemImage, parent);
118 // Set name
119 TreeCtrl.SetItemText(item, nlUtf8ToTStr(subObject->getName()));
121 // Set item data
122 TreeCtrl.SetItemData (item, (DWORD_PTR)subObject);
124 // For each children
125 HTREEITEM child = TreeCtrl.GetChildItem (item);
126 for (uint i=0; i<subObject->getChildrenCount(); i++)
128 getSubObject (subObject->getChild (i), item, child);
129 if (child)
131 // Next child
132 child = TreeCtrl.GetNextSiblingItem (child);
136 // Remove old children
137 while (child)
139 HTREEITEM toDelete = child;
140 child = TreeCtrl.GetNextSiblingItem (child);
141 nlverify (TreeCtrl.DeleteItem (toDelete));
145 // ***************************************************************************
147 void CLeftView::expand ()
149 if (IsWindow (TreeCtrl))
151 HTREEITEM item = TreeCtrl.GetRootItem ();
152 if (item != NULL)
154 item = TreeCtrl.GetChildItem (item);
155 if (item != NULL)
157 item = TreeCtrl.GetNextSiblingItem (item);
158 expand (item);
164 // ***************************************************************************
166 void CLeftView::expand (HTREEITEM item)
168 TreeCtrl.Expand (item, TVE_EXPAND);
170 HTREEITEM child = TreeCtrl.GetChildItem (item);
171 while (child)
173 expand (child);
174 child = TreeCtrl.GetNextSiblingItem (child);
178 // ***************************************************************************
180 void CLeftView::collapse (HTREEITEM item)
182 TreeCtrl.Expand (item, TVE_COLLAPSE);
184 HTREEITEM child = TreeCtrl.GetChildItem (item);
185 while (child)
187 collapse (child);
188 child = TreeCtrl.GetNextSiblingItem (child);
192 // ***************************************************************************
194 void CLeftView::OnInitialUpdate()
196 CView::OnInitialUpdate();
198 // Create the tree
199 RECT rect;
200 GetClientRect (&rect);
201 TreeCtrl.Create (TVS_EDITLABELS|TVS_HASLINES|TVS_LINESATROOT|TVS_HASBUTTONS|WS_VISIBLE|WS_CHILD, rect, this, 0);
202 TreeCtrl.SetImageList( &(theApp.ImageList.ImageList), TVSIL_NORMAL);
204 getFromDocument ();
205 if (theApp.StartExpanded)
206 expand ();
208 HTREEITEM child = TreeCtrl.GetChildItem (TreeCtrl.GetRootItem ());
209 if (child)
211 child = TreeCtrl.GetNextItem (child, TVGN_NEXT);
212 if (child)
214 if (TreeCtrl.GetSelectedItem ())
215 TreeCtrl.SetItemState(TreeCtrl.GetSelectedItem (), 0, TVIS_BOLD);
216 TreeCtrl.Select (child, TVGN_CARET);
217 TreeCtrl.SetItemState(child, TVIS_BOLD, TVIS_BOLD);
222 // ***************************************************************************
223 // CLeftView diagnostics
224 // ***************************************************************************
226 #ifdef _DEBUG
227 void CLeftView::AssertValid() const
229 CView::AssertValid();
232 // ***************************************************************************
234 void CLeftView::Dump(CDumpContext& dc) const
236 CView::Dump(dc);
239 // ***************************************************************************
241 CGeorgesEditDoc* CLeftView::GetDocument() // non-debug version is inline
243 ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CGeorgesEditDocType)) ||
244 m_pDocument->IsKindOf(RUNTIME_CLASS(CGeorgesEditDocDfn)) ||
245 m_pDocument->IsKindOf(RUNTIME_CLASS(CGeorgesEditDocForm)));
246 return (CGeorgesEditDoc*)m_pDocument;
248 #endif //_DEBUG
250 // ***************************************************************************
251 // CLeftView message handlers
252 // ***************************************************************************
254 BOOL CLeftView::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult)
256 // Selection change ?
257 NMHDR *pnmh = (LPNMHDR) lParam;
258 switch (pnmh->code)
260 case TVN_BEGINLABELEDIT:
262 // Get tree selection
263 LPNMTVDISPINFO ptvdi = (LPNMTVDISPINFO) lParam;
264 if (ptvdi->item.hItem)
266 // Get the sub object
267 CGeorgesEditDocSub *subObject = (CGeorgesEditDocSub*)TreeCtrl.GetItemData (ptvdi->item.hItem);
268 if (subObject)
270 // Editable ?
271 if (subObject->isEditable ())
273 // Get some information about the current node
274 bool deleteInsert = false;
276 // Is a form child ?
277 CGeorgesEditDocSub *parent = subObject->getParent ();
278 if (parent && parent->getType () == CGeorgesEditDocSub::Form)
280 // Does the node in the same form ?
281 CGeorgesEditDoc *doc = GetDocument ();
282 if (doc)
284 // Get the parent node
285 const CFormDfn *parentDfn;
286 uint indexDfn;
287 const CFormDfn *nodeDfn;
288 const CType *nodeType;
289 CFormElm *parentNode;
290 UFormDfn::TEntryType type;
291 bool array;
292 bool parentVDfnArray;
293 CForm *form=doc->getFormPtr ();
294 CFormElm *elm = (CFormElm *)doc->getRootNode (subObject->getSlot ());
295 nlverify ( elm->getNodeByName (parent->getFormName (), &parentDfn, indexDfn,
296 &nodeDfn, &nodeType, &parentNode, type, array, parentVDfnArray, true, NLGEORGES_FIRST_ROUND) );
298 // Is a non empty array ?
299 if (array && parentNode)
301 // Edit the tree
302 *pResult = 0;
303 return TRUE;
310 *pResult = 1;
311 return TRUE;
313 break;
314 case TVN_ENDLABELEDIT:
316 // Get tree selection
317 LPNMTVDISPINFO ptvdi = (LPNMTVDISPINFO) lParam;
318 if (ptvdi->item.hItem)
320 // Get the sub object
321 CGeorgesEditDocSub *subObject = (CGeorgesEditDocSub*)TreeCtrl.GetItemData (ptvdi->item.hItem);
322 if (subObject)
324 // Editable ?
325 if (subObject->isEditable ())
327 // Get some information about the current node
328 bool deleteInsert = false;
330 // Is a form child ?
331 CGeorgesEditDocSub *parent = subObject->getParent ();
332 if (parent && parent->getType () == CGeorgesEditDocSub::Form)
334 // Does the node in the same form ?
335 CGeorgesEditDoc *doc = GetDocument ();
336 if (doc)
338 // Get the parent node
339 const CFormDfn *parentDfn;
340 uint indexDfn;
341 const CFormDfn *nodeDfn;
342 const CType *nodeType;
343 CFormElm *parentNode;
344 UFormDfn::TEntryType type;
345 bool array;
346 bool parentVDfnArray;
347 CForm *form=doc->getFormPtr ();
348 CFormElm *elm = (CFormElm *)doc->getRootNode (subObject->getSlot ());
349 nlverify ( elm->getNodeByName (parent->getFormName (), &parentDfn, indexDfn,
350 &nodeDfn, &nodeType, &parentNode, type, array, parentVDfnArray, true, NLGEORGES_FIRST_ROUND) );
352 // Is a non empty array ?
353 if (array && parentNode && (ptvdi->item.mask & TVIF_TEXT))
355 // Change the node name
356 TreeCtrl.SetItemText (ptvdi->item.hItem, ptvdi->item.pszText);
357 doc->modify (new CActionString(IAction::FormArrayRename, tStrToUtf8(ptvdi->item.pszText).c_str(), *doc,
358 subObject->getFormName().c_str(), toString (subObject->getIdInParent()).c_str(),
359 doc->getLeftView ()->getCurrentSelectionId (), subObject->getSlot ()));
360 return TRUE;
367 *pResult = 1;
368 return TRUE;
370 break;
371 case TVN_SELCHANGED:
373 LPNMTREEVIEW itemData = (LPNMTREEVIEW) lParam;
375 // Unbold old item
376 if (itemData->itemOld.hItem)
377 TreeCtrl.SetItemState(itemData->itemOld.hItem, 0, TVIS_BOLD);
379 CGeorgesEditDoc *doc = GetDocument();
380 if (doc)
382 CGeorgesEditDocSub *data = (CGeorgesEditDocSub *)TreeCtrl.GetItemData (itemData->itemNew.hItem);
383 nlassert (data);
384 doc->changeSubSelection (data, this);
385 TreeCtrl.SetFocus ();
388 break;
389 case NM_RCLICK:
391 // Get item clicked
392 TVHITTESTINFO tvhti;
393 GetCursorPos(&tvhti.pt);
394 ::ScreenToClient(TreeCtrl, &tvhti.pt);
395 tvhti.flags = LVHT_NOWHERE;
396 TreeView_HitTest(TreeCtrl, &tvhti);
398 // Item clicked ?
399 if(TVHT_ONITEM & tvhti.flags)
401 // Select the item
402 if (TreeCtrl.GetSelectedItem ())
403 TreeCtrl.SetItemState(TreeCtrl.GetSelectedItem (), 0, TVIS_BOLD);
404 TreeCtrl.SelectItem (tvhti.hItem);
405 TreeCtrl.SetItemState(tvhti.hItem, TVIS_BOLD, TVIS_BOLD);
407 // Get the sub object
408 CGeorgesEditDocSub *subObject = (CGeorgesEditDocSub*)TreeCtrl.GetItemData (tvhti.hItem);
409 if (subObject)
411 // Editable ?
412 if (subObject->isEditable ())
414 // Get some information about the current node
415 bool deleteInsert = false;
417 // Is a form child ?
418 CGeorgesEditDocSub *parent = subObject->getParent ();
419 if (parent && parent->getType () == CGeorgesEditDocSub::Form)
421 // Does the node in the same form ?
422 CGeorgesEditDoc *doc = GetDocument ();
423 if (doc)
425 // Get the node
426 const CFormDfn *parentDfn;
427 uint indexDfn;
428 const CFormDfn *nodeDfn;
429 const CType *nodeType;
430 CFormElm *node;
431 UFormDfn::TEntryType type;
432 bool array;
433 bool parentVDfnArray;
434 CForm *form=doc->getFormPtr ();
435 CFormElm *elm = (CFormElm *)doc->getRootNode (subObject->getSlot ());
436 nlverify ( elm->getNodeByName (parent->getFormName (), &parentDfn, indexDfn,
437 &nodeDfn, &nodeType, &node, type, array, parentVDfnArray, true, NLGEORGES_FIRST_ROUND) );
439 // Is the parent array ?
440 deleteInsert = array;
444 // Show right click menu
446 // Create menu
447 CMenu mainMenu;
448 mainMenu.LoadMenu (IDR_LEFT_VIEW_CONTEXT);
449 CMenu *popup = mainMenu.GetSubMenu (0);
451 // Enable disable items
452 popup->EnableMenuItem (4, MF_BYPOSITION|(deleteInsert?MF_ENABLED:MF_GRAYED));
453 popup->EnableMenuItem (5, MF_BYPOSITION|(deleteInsert?MF_ENABLED:MF_GRAYED));
454 popup->EnableMenuItem (6, MF_BYPOSITION|(deleteInsert?MF_ENABLED:MF_GRAYED));
456 ::ClientToScreen(TreeCtrl, &tvhti.pt);
457 popup->TrackPopupMenu (TPM_LEFTALIGN | TPM_RIGHTBUTTON, tvhti.pt.x, tvhti.pt.y, this, NULL);
462 break;
465 return CView::OnNotify(wParam, lParam, pResult);
468 // ***************************************************************************
470 void CLeftView::getFromDocument ()
472 CGeorgesEditDoc *doc = GetDocument();
473 if (doc && IsWindow (TreeCtrl))
475 // Get the tree root
476 //TreeCtrl.Expand (TreeCtrl.GetRootItem (), TVE_EXPAND);
477 getSubObject (&doc->RootObject, NULL, TreeCtrl.GetRootItem ());
481 // ***************************************************************************
483 void CLeftView::OnUpdate(CView* pSender, LPARAM lHint, CObject* pHint)
485 if (IsWindow (TreeCtrl))
487 getFromDocument ();
491 // ***************************************************************************
493 void CLeftView::OnSize(UINT nType, int cx, int cy)
495 CView::OnSize(nType, cx, cy);
497 if (IsWindow (TreeCtrl))
499 RECT rect;
500 GetClientRect (&rect);
501 TreeCtrl.SetWindowPos (NULL, 0, 0, rect.right-rect.left, rect.bottom-rect.top, SWP_NOZORDER|SWP_NOOWNERZORDER);
505 // ***************************************************************************
507 BOOL CLeftView::PreTranslateMessage(MSG* pMsg)
509 if (theApp.m_pMainWnd->PreTranslateMessage(pMsg))
510 return TRUE;
512 // Key ?
513 if (pMsg->message == WM_KEYDOWN)
515 // Tabulation ?
516 if ((int) pMsg->wParam == VK_TAB)
518 CGeorgesEditDoc *doc = (CGeorgesEditDoc*)GetDocument( );
519 if (doc)
521 // Right view ?
522 CGeorgesEditView* pView = doc->getRightView ();
523 if (pView->isFocusable ())
525 doc->switchToView (pView);
527 // Shift ?
528 if (GetAsyncKeyState (VK_SHIFT) & (1<<15))
529 pView->setFocusLastWidget ();
532 return TRUE;
534 else if ((int) pMsg->wParam == VK_INSERT)
536 OnInsert ();
537 return TRUE;
539 else if ((int) pMsg->wParam == VK_DELETE)
541 OnDelete ();
542 return TRUE;
546 return CView::PreTranslateMessage(pMsg);
549 // ***************************************************************************
551 void CLeftView::OnSetFocus(CWnd* pOldWnd)
553 CView::OnSetFocus(pOldWnd);
555 TreeCtrl.SetFocus ();
558 // ***************************************************************************
560 void CLeftView::OnEditCopy()
562 CGeorgesEditDoc *doc = (CGeorgesEditDoc*)GetDocument( );
563 if (doc)
565 // What is selected ?
566 HTREEITEM item = TreeCtrl.GetSelectedItem ();
567 if (item != NULL)
569 // Edit the label ?
570 CEdit *edit = TreeCtrl.GetEditControl();
571 if (edit)
573 edit->SendMessage (WM_COPY);
575 else
577 // Get the sub data
578 CGeorgesEditDocSub *subData = (CGeorgesEditDocSub*)TreeCtrl.GetItemData (item);
579 if (subData)
581 // Get thte node type
582 CGeorgesEditDocSub::TSub subType = subData->getType ();
584 // Good type for copy ?
585 if (subType == CGeorgesEditDocSub::Form)
587 theApp.SerialIntoMemStream (subData->getFormName ().c_str(), doc, subData->getSlot (), true);
595 // ***************************************************************************
597 void CLeftView::OnEditPaste()
599 CGeorgesEditDoc *doc = (CGeorgesEditDoc*)GetDocument( );
600 if (doc)
602 // What is selected ?
603 HTREEITEM item = TreeCtrl.GetSelectedItem ();
604 if (item != NULL)
606 // Edit the label ?
607 CEdit *edit = TreeCtrl.GetEditControl();
608 if (edit)
610 edit->SendMessage (WM_PASTE);
612 else
614 // Get the sub data
615 CGeorgesEditDocSub *subData = (CGeorgesEditDocSub*)TreeCtrl.GetItemData (item);
616 if (subData)
618 // Get thte node type
619 CGeorgesEditDocSub::TSub subType = subData->getType ();
621 // Good type for copy ?
622 if (subType == CGeorgesEditDocSub::Form)
624 // Document is modified by this view
625 if (theApp.FillMemStreamWithClipboard (subData->getFormName ().c_str(), doc, subData->getSlot ()))
627 doc->modify (new CActionBuffer (IAction::FormPaste, theApp.MemStream.buffer (), theApp.MemStream.length(),
628 *doc, subData->getFormName ().c_str(), "", doc->getLeftView ()->getCurrentSelectionId (), subData->getSlot ()));
637 // ***************************************************************************
639 CGeorgesEditDocSub *CLeftView::getSelectedObject ()
641 HTREEITEM item = TreeCtrl.GetSelectedItem ();
642 if (item != NULL)
644 return (CGeorgesEditDocSub *)TreeCtrl.GetItemData (item);
646 return NULL;
649 // ***************************************************************************
651 bool CLeftView::changeSubSelection (CGeorgesEditDocSub *sub, HTREEITEM item)
653 // First time ?
654 if (item == NULL)
655 item = TreeCtrl.GetRootItem ();
657 // Good one ?
658 if ( (CGeorgesEditDocSub *)TreeCtrl.GetItemData (item) == sub )
660 // Select it.
661 if (TreeCtrl.GetSelectedItem ())
662 TreeCtrl.SetItemState(TreeCtrl.GetSelectedItem (), 0, TVIS_BOLD);
663 nlverify (TreeCtrl.SelectItem (item));
664 TreeCtrl.SetItemState(item, TVIS_BOLD, TVIS_BOLD);
665 return true;
668 // Scan ohters
669 HTREEITEM child = TreeCtrl.GetChildItem (item);
670 while (child)
672 // Good one ?
673 if (changeSubSelection (sub, child))
674 return true;
676 // Get next item
677 child = TreeCtrl.GetNextSiblingItem (child);
680 // Selection not found
681 return false;
684 // ***************************************************************************
686 bool CLeftView::changeSubSelection (uint &sub, HTREEITEM item)
688 // First time ?
689 if (item == NULL)
690 item = TreeCtrl.GetRootItem ();
692 // Good one ?
693 if ( sub == 0 )
695 // Select it.
696 if (TreeCtrl.GetSelectedItem ())
697 TreeCtrl.SetItemState(TreeCtrl.GetSelectedItem (), 0, TVIS_BOLD);
698 nlverify (TreeCtrl.SelectItem (item));
699 TreeCtrl.SetItemState(item, TVIS_BOLD, TVIS_BOLD);
700 return true;
703 // Scan ohters
704 HTREEITEM child = TreeCtrl.GetChildItem (item);
705 while (child)
707 // Good one ?
708 if (changeSubSelection (--sub, child))
709 return true;
711 // Get next item
712 child = TreeCtrl.GetNextSiblingItem (child);
715 // Selection not found
716 return false;
719 // ***************************************************************************
721 uint CLeftView::getCurrentSelectionId (uint *count, HTREEITEM item)
723 if (IsWindow (TreeCtrl))
725 uint id = 0;
727 // Root item
728 if (item == NULL)
729 item = TreeCtrl.GetRootItem ();
731 // First id
732 if (count == NULL)
734 count = &id;
735 *count = 0;
738 // Good node ?
739 if (TreeCtrl.GetSelectedItem () == item)
741 return *count;
744 // Look in children
745 item = TreeCtrl.GetChildItem (item);
746 while (item)
748 // Increment id
749 (*count) ++;
751 // Found ?
752 if (getCurrentSelectionId (count, item) != 0xffffffff)
753 return *count;
755 // Next child
756 item = TreeCtrl.GetNextSiblingItem (item);
760 // Not found
761 return 0xffffffff;
764 // ***************************************************************************
766 bool CLeftView::setCurrentSelectionId (uint id, HTREEITEM item)
768 if (IsWindow (TreeCtrl))
770 // Root item
771 if (item == NULL)
773 item = TreeCtrl.GetRootItem ();
776 // Good node ?
777 if (id == 0)
779 // Select the node
780 if (TreeCtrl.GetSelectedItem ())
781 TreeCtrl.SetItemState(TreeCtrl.GetSelectedItem (), 0, TVIS_BOLD);
782 TreeCtrl.Select (item, TVGN_CARET);
783 TreeCtrl.SetItemState(item, TVIS_BOLD, TVIS_BOLD);
784 return true;
787 // Look in children
788 item = TreeCtrl.GetChildItem (item);
789 while (item)
791 // Increment id
792 id++;
794 // Found ?
795 if (setCurrentSelectionId (id, item))
796 return true;
798 // Next child
799 item = TreeCtrl.GetNextSiblingItem (item);
803 // Not found
804 return false;
807 // ***************************************************************************
809 void CLeftView::OnEditCut()
811 // Copy
812 OnEditCopy ();
814 // Delete
815 OnDelete ();
818 // ***************************************************************************
820 void CLeftView::OnInsert()
822 // Get tree selection
823 HTREEITEM item = TreeCtrl.GetSelectedItem ();
824 if (item)
826 // Get the sub object
827 CGeorgesEditDocSub *subObject = (CGeorgesEditDocSub*)TreeCtrl.GetItemData (item);
828 if (subObject)
830 // Editable ?
831 if (subObject->isEditable ())
833 // Get some information about the current node
834 bool deleteInsert = false;
836 // Is a form child ?
837 CGeorgesEditDocSub *parent = subObject->getParent ();
838 if (parent && parent->getType () == CGeorgesEditDocSub::Form)
840 // Does the node in the same form ?
841 CGeorgesEditDoc *doc = GetDocument ();
842 if (doc)
844 // Get the parent node
845 const CFormDfn *parentDfn;
846 uint indexDfn;
847 const CFormDfn *nodeDfn;
848 const CType *nodeType;
849 CFormElm *parentNode;
850 UFormDfn::TEntryType type;
851 bool array;
852 bool parentVDfnArray;
853 CForm *form=doc->getFormPtr ();
854 CFormElm *elm = (CFormElm *)doc->getRootNode (subObject->getSlot ());
855 nlverify ( elm->getNodeByName (parent->getFormName (), &parentDfn, indexDfn,
856 &nodeDfn, &nodeType, &parentNode, type, array, parentVDfnArray, true, NLGEORGES_FIRST_ROUND) );
858 // Is a non empty array ?
859 if (array && parentNode)
861 // Document modified
862 doc->modify (new CActionString (IAction::FormArrayInsert, toString (subObject->getIdInParent ()).c_str (),
863 *doc, subObject->getFormName ().c_str (), "", doc->getLeftView ()->getCurrentSelectionId (), subObject->getSlot ()));
872 // ***************************************************************************
874 void CLeftView::OnDelete()
876 // Get tree selection
877 HTREEITEM item = TreeCtrl.GetSelectedItem ();
878 if (item)
880 // Edit the label ?
881 CEdit *edit = TreeCtrl.GetEditControl();
882 if (edit)
884 edit->SetWindowText (_T(""));
886 else
888 // Get the sub object
889 CGeorgesEditDocSub *subObject = (CGeorgesEditDocSub*)TreeCtrl.GetItemData (item);
890 if (subObject)
892 // Editable ?
893 if (subObject->isEditable ())
895 // Get some information about the current node
896 bool deleteInsert = false;
898 // Is a form child ?
899 CGeorgesEditDocSub *parent = subObject->getParent ();
900 if (parent && parent->getType () == CGeorgesEditDocSub::Form)
902 // Does the node in the same form ?
903 CGeorgesEditDoc *doc = GetDocument ();
904 if (doc)
906 // Get the parent node
907 const CFormDfn *parentDfn;
908 uint indexDfn;
909 const CFormDfn *nodeDfn;
910 const CType *nodeType;
911 CFormElm *parentNode;
912 UFormDfn::TEntryType type;
913 bool array;
914 bool parentVDfnArray;
915 CForm *form=doc->getFormPtr ();
916 CFormElm *elm = (CFormElm *)doc->getRootNode (subObject->getSlot ());
917 nlverify ( elm->getNodeByName (parent->getFormName (), &parentDfn, indexDfn,
918 &nodeDfn, &nodeType, &parentNode, type, array, parentVDfnArray, true, NLGEORGES_FIRST_ROUND) );
920 // Is a non empty array ?
921 if (array && parentNode)
923 // Document modified
924 doc->modify (new CActionBuffer (IAction::FormArrayDelete, NULL, 0, *doc, subObject->getFormName ().c_str (),
925 toString (subObject->getIdInParent ()).c_str (), doc->getLeftView ()->getCurrentSelectionId (), subObject->getSlot ()));
935 // ***************************************************************************
938 void CLeftView::OnEditRedo()
940 CGeorgesEditDoc *doc = (CGeorgesEditDoc*)GetDocument( );
941 if (doc)
943 doc->OnEditRedo();
947 void CLeftView::OnUpdateEditRedo(CCmdUI* pCmdUI)
949 CGeorgesEditDoc *doc = (CGeorgesEditDoc*)GetDocument( );
950 if (doc)
952 doc->OnUpdateEditRedo(pCmdUI) ;
956 void CLeftView::OnEditUndo()
958 CGeorgesEditDoc *doc = (CGeorgesEditDoc*)GetDocument( );
959 if (doc)
961 doc->OnEditUndo();
965 void CLeftView::OnUpdateEditUndo(CCmdUI* pCmdUI)
967 CGeorgesEditDoc *doc = (CGeorgesEditDoc*)GetDocument( );
968 if (doc)
970 doc->OnUpdateEditUndo(pCmdUI) ;
974 void CLeftView::OnEditRename()
976 // Edit the tree
977 HTREEITEM item = TreeCtrl.GetSelectedItem ();
978 if (item)
979 TreeCtrl.EditLabel ( item );
982 void CLeftView::OnEditFetch1()
984 CGeorgesEditDoc *doc = (CGeorgesEditDoc*)GetDocument( );
985 if (doc)
987 if (doc->isForm ())
988 ((CGeorgesEditDocForm*)doc)->OnEditFetch1();
992 void CLeftView::OnEditFetch2()
994 CGeorgesEditDoc *doc = (CGeorgesEditDoc*)GetDocument( );
995 if (doc)
997 if (doc->isForm ())
998 ((CGeorgesEditDocForm*)doc)->OnEditFetch2();
1002 void CLeftView::OnEditFetch3()
1004 CGeorgesEditDoc *doc = (CGeorgesEditDoc*)GetDocument( );
1005 if (doc)
1007 if (doc->isForm ())
1008 ((CGeorgesEditDocForm*)doc)->OnEditFetch3();
1012 void CLeftView::OnEditFetch4()
1014 CGeorgesEditDoc *doc = (CGeorgesEditDoc*)GetDocument( );
1015 if (doc)
1017 if (doc->isForm ())
1018 ((CGeorgesEditDocForm*)doc)->OnEditFetch4();
1022 void CLeftView::OnEditHold1()
1024 CGeorgesEditDoc *doc = (CGeorgesEditDoc*)GetDocument( );
1025 if (doc)
1027 if (doc->isForm ())
1028 ((CGeorgesEditDocForm*)doc)->OnEditHold1();
1032 void CLeftView::OnEditHold2()
1034 CGeorgesEditDoc *doc = (CGeorgesEditDoc*)GetDocument( );
1035 if (doc)
1037 if (doc->isForm ())
1038 ((CGeorgesEditDocForm*)doc)->OnEditHold2();
1042 void CLeftView::OnEditHold3()
1044 CGeorgesEditDoc *doc = (CGeorgesEditDoc*)GetDocument( );
1045 if (doc)
1047 if (doc->isForm ())
1048 ((CGeorgesEditDocForm*)doc)->OnEditHold3();
1052 void CLeftView::OnEditHold4()
1054 CGeorgesEditDoc *doc = (CGeorgesEditDoc*)GetDocument( );
1055 if (doc)
1057 if (doc->isForm ())
1058 ((CGeorgesEditDocForm*)doc)->OnEditHold4();
1062 void CLeftView::OnEditCollapseall()
1064 // Edit the tree
1065 HTREEITEM item = TreeCtrl.GetSelectedItem ();
1066 if (item)
1067 collapse (item);
1070 void CLeftView::OnEditExpandall()
1072 // Edit the tree
1073 HTREEITEM item = TreeCtrl.GetSelectedItem ();
1074 if (item)
1075 expand (item);