acme
Foundational cross-platform layer of the ca2 framework
Loading...
Searching...
No Matches
aaa_tree_base_composite.h
1// From tree_base.h by camilo on 2025-03-29 00:33 <3ThomasBorregaardSorensen!!
2#pragma once
3
4
5#pragma once
6
7
8#include "acme/prototype/data/tree_base.h"
9
10
11namespace data
12{
13
14
15 class CLASS_DECL_ACME tree_base_composite :
16 virtual public ::data::tree_base
17 {
18 public:
19
20
21 ::pointer < tree_base > m_ptreebase;
22
23
24
25
26 tree_base_composite();
27 ~tree_base_composite() override;
28
29 void destroy() override;
30
31 virtual void _insert_tree(tree_base * ptree);
32
33 virtual ::i64 increment_reference_count() override
34 {
35 return ::matter::increment_reference_count();
36 }
37
38 virtual ::i64 decrement_reference_count() override
39 {
40 return ::matter::decrement_reference_count();
41 }
42
43
44 virtual void erase_all();
45
46 virtual void update_tree();
47
48 virtual ::collection::count _tree_count();
49 virtual tree_base * _tree_at(::collection::index iIndex);
50
51 virtual void predicate_each_tree(const ::function < void(tree_base *) > & callback);
52
53 virtual tree_item * _find(const ::item * pitem, ::collection::index * piIndex = nullptr);
54 virtual bool _contains(const ::item * pitem);
55
56 virtual bool _contains(const tree_item * pitem);
57
58 virtual void _001OnTreeDataChange();
59
60 virtual void _001OnItemExpand(tree_item * pitem, const ::action_context & action_context);
61 virtual void _001OnItemCollapse(tree_item * pitem, const ::action_context & action_context);
62 virtual void _001OnOpenItem(tree_item * pitem, const ::action_context & action_context);
63 virtual void _001OnItemContextMenu(tree_item * pitem, const ::action_context & action_context, ::user::element * ptree, const ::i32_point & point);
64
65 void _erase(::data::tree_item_ptr_array & itemptra);
66 void _erase(tree_item * pitem);
67 void _erase(::item * pitem, ::collection::index i = 0);
68
69
70 //tree_item * __previous() override;
71 //tree_item * __next() override;
72 //template < typename PRED >
73 //void sort_children(PRED pred)
74 //{
75
76 // tree_sort(this, pred);
77
78 //}
79 //void sort_children(const ::function < bool(const tree_item * p1, const tree_item * p2) > & functionLess) override;
80
81 virtual tree_item * __get_proper_item(::collection::index iIndex, ::collection::index * piLevel, ::collection::index * piCount = nullptr);
82 virtual tree_item * _get_proper_item(::collection::index iIndex, ::collection::index * piLevel) override;
83 virtual ::collection::index _get_proper_item_index(tree_item * pitemParam, ::collection::index * piLevel, ::collection::index * piCount = nullptr);
84 // virtual ::collection::count get_proper_item_count() override;
85
86 virtual void _update_levels();
87
88 virtual tree_item * _get_base_item();
89
90 virtual const tree_item * _get_base_item() const;
91
92 virtual tree_item * _insert_item(::item * pitemdataNew, enum_relative erelativeNewItem = e_relative_last_child, tree_item * pitemRelative = nullptr, bool bVoidTreeDataChangeEvent = false);
93 virtual bool _insert_item(tree_item * pitemNew, enum_relative erelativeNewItem = e_relative_last_child, tree_item * pitemRelative = nullptr, bool bVoidTreeDataChangeEvent = false);
94
95 ::image::image_list * get_tree_image_list() override;
96
97 virtual void _001ExpandItem(tree_item * pitem, const ::action_context & action_context, bool bExpand = true, bool bRedraw = true, bool bLayout = true);
98 virtual void _001EnsureVisible(tree_item * pitem);
99 virtual void _001SelectItem(tree_item * pitem);
100
101 virtual void _get_selection(::data::tree_item_base_ptr_array & itemptraSelected) const;
102 virtual bool _is_selected(const tree_item * pitem) const;
103 virtual bool _is_selected(const ::item * pitem) const;
104
105 virtual ::collection::count _selection_set(::data::tree_item_base_ptr_array & itemptra);
106 virtual bool _selection_set(tree_item * pitem, bool bIfNotInSelection = false, bool bIfParentInSelection = false);
107 virtual bool _selection_set(::item * pitem, bool bIfNotInSelection = false, bool bIfParentInSelection = false);
108 virtual bool _selection_set(::collection::index iIndex, ::item * pitem, bool bIfNotInSelection = false, bool bIfParentInSelection = false);
109
110
111 //void signal(::signal * psignal) override;
112 void handle(::topic * ptopic, ::handler_context * phandlercontext) override;
113
114
115 virtual void on_fill_children() override;
116 //virtual void start_fill_children();
117
118 virtual void on_tree_layout();
119
120 virtual void fill_children();
121
122
123 //virtual void tree_layout(::draw2d::graphics_pointer & pgraphics);
124
125
126 };
127
128 //template < prototype_item ::item * >
129 //tree < ::item * >::tree()
130 //{
131
132 // //defer_create_synchronization();
133
134 // m_bFill = false;
135
136 // //m_proot = allocateø tree_item();
137
138 // //if (m_proot == nullptr)
139 // //{
140
141 // // throw ::exception(error_no_memory);
142
143 // //}
144
145 // this->m_dwState |= ::data::e_tree_item_state_expandable;
146
147 // this->m_dwState |= ::data::e_tree_item_state_expanded;
148
149 // this->m_ptree = this;
150
151 // this->m_pparent = allocateø tree_item();
152
153 //}
154
155 //template < prototype_item ::item * >
156 //tree < ::item * >::~tree()
157 //{
158
159 //}
160
161 //template < prototype_item ::item * >
162 //tree_item * tree < ::item * >::find(const ::item * * pitem, ::collection::index * piIndex)
163 //{
164
165 // ::collection::index iIndex;
166
167 // if (pitem == nullptr)
168 // {
169
170 // return nullptr;
171
172 // }
173
174 // if (piIndex == nullptr)
175 // {
176
177 // iIndex = 0;
178
179 // }
180 // else
181 // {
182
183 // iIndex = *piIndex;
184
185 // }
186
187 // ::pointer<::data::tree_item>pitem = this;
188
189 // for (; pitem != nullptr; pitem = pitem->get_item(e_tree_navigation_expanded_forward))
190 // {
191
192 // if (pitem->m_pdataitem == pitem)
193 // {
194
195 // iIndex--;
196
197 // if (iIndex < 0)
198 // {
199
200 // return pitem;
201
202 // }
203
204 // }
205
206 // }
207
208 // if (piIndex != nullptr)
209 // {
210
211 // *piIndex = iIndex;
212
213 // }
214
215 // return nullptr;
216
217 //}
218
219 //template < prototype_item ::item * >
220 //bool tree < ::item * >::contains(const ::item * * pitem)
221 //{
222
223 // return find(pitem) != nullptr;
224
225 //}
226 //template < prototype_item ::item * >
227 //bool tree < ::item * >::contains(const tree_item * pitemParam)
228 //{
229
230 // return tree_item::contains(pitemParam);
231
232 // //if (pitemParam == this)
233 // //{
234
235 // // return true;
236
237 // //}
238 // //
239 // //::data::tree_item * pitem = this;
240
241 // //for(; pitem != nullptr; pitem = pitem->get_item(e_tree_navigation_expanded_forward))
242 // //{
243
244 // // if (pitem == pitemParam)
245 // // {
246
247 // // return true;
248
249 // // }
250
251 // //}
252
253 // //return false;
254
255 //}
256
257 //template < prototype_item ::item * >
258 //void tree < ::item * >::_001OnTreeDataChange()
259 //{
260
261 // update_levels();
262
263 //}
264
265 //template < prototype_item ::item * >
266 //void tree < ::item * >::erase(::item * * pitem, ::collection::index i)
267 //{
268
269 // tree_item * pitem = find(pitem, &i);
270
271 // if (pitem == nullptr)
272 // {
273
274 // return;
275
276 // }
277
278 // return erase(pitem);
279
280 //}
281
282 //template < prototype_item ::item * >
283 //void tree < ::item * >::erase(tree_item_ptr_array<::item *> & itemptra)
284 //{
285
286 // for (::i32 i = 0; i < itemptra.get_count(); i++)
287 // {
288
289 // erase(itemptra[i]);
290
291 // }
292
293 //}
294
295 //template < prototype_item ::item * >
296 //void tree < ::item * >::erase(tree_item * pitem)
297 //{
298
299 // if (pitem->m_ptree == this)
300 // {
301
302 // pitem->erase_tree_item();
303
304 // }
305
306 //}
307
308 //template < prototype_item ::item * >
309 //void tree < ::item * >::sort_children(const ::function < bool(const ::data::tree_item * p1, const ::data::tree_item * p2) > & functionLess)
310 //{
311
312 // this->m_treeitema2.predicate_sort(functionLess);
313
314 // this->m_treeitema2.predicate_each([](auto pitem) {pitem->clear_cache(); });
315
316 //}
317
318 //template < prototype_item ::item * >
319 //::data::tree_item * tree < ::item * >::_get_proper_item(::collection::index iIndex, ::collection::index * piLevel, ::collection::index * piCount)
320 //{
321
322 // ::collection::index iCount = 0;
323
324 // if (piLevel)
325 // {
326
327 // *piLevel = 0;
328
329 // }
330
331 // ::pointer<::data::tree_item>pitem = this;
332
333 // while (pitem && iIndex >= 0)
334 // {
335
336 // pitem = pitem->get_proper_next(piLevel);
337
338 // iIndex--;
339
340 // }
341
342 // if (iIndex < 0 && pitem)
343 // {
344
345 // return pitem;
346
347 // }
348
349 // if (piCount != nullptr)
350 // {
351
352 // *piCount = iCount;
353
354 // }
355
356 // return nullptr;
357
358 //}
359
360 //template < prototype_item ::item * >
361 //::data::tree_item * tree < ::item * >::get_proper_item(::collection::index iIndex, ::collection::index * piLevel)
362 //{
363
364 // if (piLevel)
365 // {
366
367 // *piLevel = 0;
368
369 // }
370
371 // ::pointer<::data::tree_item>pitem = this;
372
373 // while (pitem && iIndex >= 0)
374 // {
375
376 // pitem = pitem->get_proper_next(piLevel);
377
378 // iIndex--;
379
380 // }
381
382 // if (iIndex < 0 && pitem)
383 // {
384
385 // return pitem;
386
387 // }
388
389 // return nullptr;
390
391 //}
392
393 //template < prototype_item ::item * >
394 //::collection::index tree < ::item * >::get_proper_item_index(::data::tree_item * pitemParam, ::collection::index * piLevel, ::collection::index * piCount)
395 //{
396
397 // ::i32 iIndex = 0;
398
399 // ::collection::count iCount = 0;
400
401 // if (piLevel != nullptr)
402 // {
403
404 // *piLevel = 0;
405
406 // }
407
408 // ::pointer<::data::tree_item>pitem = get_base_item();
409
410 // while (pitem != nullptr)
411 // {
412
413 // pitem = pitem->get_proper_next(piLevel);
414
415 // if (pitem == pitemParam)
416 // {
417
418 // if (piCount != nullptr)
419 // {
420
421 // *piCount += iCount;
422
423 // }
424
425 // return iIndex;
426
427 // }
428
429 // iIndex++;
430
431 // iCount++;
432
433 // }
434
435 // if (piCount != nullptr)
436 // {
437
438 // *piCount += iCount;
439
440 // }
441
442 // return -1;
443
444 //}
445
446
449
451
453
455
456 //template < prototype_item ::item * >
457 //::data::tree_item * tree < ::item * >::get_base_item()
458 //{
459
460 // return this;
461
462 //}
463
464 //template < prototype_item ::item * >
465 //const ::data::tree_item * tree < ::item * >::get_base_item() const
466 //{
467
468 // return this;
469
470 //}
471 //template < prototype_item ::item * >
472
473 //::data::tree_item * tree < ::item * >::_____previous()
474 //{
475
476 // return nullptr;
477
478 //}
479
480 //template < prototype_item ::item * >
481 //::data::tree_item * tree < ::item * >::_____next()
482 //{
483
484 // return nullptr;
485
486 //}
487
488 //template < prototype_item ::item * >
489 //::data::tree_item * tree < ::item * >::insert_item(::item * * pitemdataNew, enum_relative erelativeNewItem, ::data::tree_item * pitemRelative, bool bVoidTreeDataChangeEvent)
490 //{
491
492 // if (pitemRelative == nullptr)
493 // {
494
495 // pitemRelative = this;
496
497 // }
498
499 // if (erelativeNewItem == e_relative_replace)
500 // {
501
502 // if (!contains(pitemRelative))
503 // return nullptr;
504
505 // pitemRelative->m_pdataitem = pitemdataNew;
506
507 // return pitemRelative;
508
509 // }
510
511 // ::pointer<::data::tree_item>pitemNew = allocateø tree_item();
512
513 // if (pitemNew == nullptr)
514 // return nullptr;
515
516 // if (!insert_item(pitemNew, erelativeNewItem, pitemRelative, bVoidTreeDataChangeEvent))
517 // {
518
519 // return nullptr;
520
521 // }
522
523 // pitemNew->m_pdataitem = pitemdataNew;
524
525 // return pitemNew;
526
527 //}
528 //template < prototype_item ::item * >
529 //void tree < ::item * >::destroy()
530 //{
531
532 // ::data::data::destroy();
533 // ::data::tree_item::destroy();
534
535 //}
536 //template < prototype_item ::item * >
537 //void tree < ::item * >::on_insert_tree(tree * ptree)
538 //{
539
540 // m_treea.add(ptree);
541
542 //}
543
544 //template < prototype_item ::item * >
545 //bool tree < ::item * >::insert_item(::data::tree_item * pitemNew, enum_relative erelativeNewItem, ::data::tree_item * pitemRelative, bool bVoidTreeDataChangeEvent)
546 //{
547
548 // ::pointer<tree>ptreeNew = pitemNew;
549
550 // if (ptreeNew)
551 // {
552
553 // on_insert_tree(ptreeNew);
554
555 // }
556
557 // if (pitemRelative == nullptr)
558 // {
559
560 // pitemRelative = this;
561
562 // }
563
564 // _synchronous_lock synchronouslock(this->synchronization(), DEFAULT_SYNCHRONOUS_LOCK_SUFFIX);
565
566 // if (pitemNew == nullptr)
567 // {
568
569 // return false;
570
571 // }
572
573 // if (!contains(pitemRelative))
574 // {
575
576 // return false;
577
578 // }
579
580 // if (erelativeNewItem == e_relative_parent)
581 // {
582
583 // return false;
584
585 // }
586
587 // if (erelativeNewItem == e_relative_last_sibling)
588 // {
589
590 // if (pitemRelative == this)
591 // {
592
593 // erelativeNewItem = e_relative_first_child;
594
595 // }
596
597 // }
598
599 // bool bOk = false;
600
601 // switch (erelativeNewItem)
602 // {
603 // case e_relative_first_child:
604 // {
605
606 // bOk = pitemRelative->insert(erelativeNewItem, pitemNew);
607
608 // }
609 // break;
610 // case e_relative_last_child:
611 // {
612
613 // bOk = pitemRelative->insert(erelativeNewItem, pitemNew);
614
615 // }
616 // break;
617 // case e_relative_previous_sibling:
618 // {
619
620 // bOk = pitemRelative->insert(erelativeNewItem, pitemNew);
621
622 // }
623 // break;
624 // case e_relative_next_sibling:
625 // {
626
627 // bOk = pitemRelative->insert(erelativeNewItem, pitemNew);
628
629 // }
630 // break;
631 // case e_relative_last_sibling:
632 // {
633
634 // bOk = pitemRelative->insert(erelativeNewItem, pitemNew);
635
636 // }
637 // break;
638 // case e_relative_replace:
639 // {
640
641 // pitemNew->m_dwUser = pitemRelative->m_dwUser;
642 // pitemNew->m_dwMetaData = pitemRelative->m_dwMetaData;
643 // pitemNew->m_dwState = pitemRelative->m_dwState;
644 // pitemNew->m_pdataitem = pitemRelative->m_pdataitem;
645
646 // pitemNew->m_iLevel = pitemRelative->m_iLevel;
647
648 // bOk = pitemRelative->insert(erelativeNewItem, pitemNew);
649
650 // }
651 // break;
652
653 // case e_relative_macro_record:
654 // {
655
656 // if (pitemRelative->get_next() != nullptr)
657 // {
658
659 // bOk = insert_item(pitemNew, ::data::e_relative_first_child, pitemRelative);
660
661 // }
662 // else
663 // {
664
665 // bOk = insert_item(pitemNew, ::data::e_relative_last_sibling, pitemRelative);
666
667 // }
668
669 // }
670 // break;
671 // default:
672
673 // throw ::exception(error_not_supported);
674
675 // }
676
677 // pitemNew->m_ptree = this;
678
679 // if (!bVoidTreeDataChangeEvent)
680 // {
681
682 // _001OnTreeDataChange();
683
684 // }
685
686 // return bOk;
687
688 //}
689
690 //template < prototype_item ::item * >
691 //void tree < ::item * >::erase_all()
692 //{
693
694 // this->erase_tree_item_descendants();
695
696 //}
697
698 //template < prototype_item ::item * >
699 //void tree < ::item * >::update_tree()
700 //{
701
702 // _001OnTreeDataChange();
703
704 //}
705
706
708
710
712
715
717
718
720
722
724 //template < prototype_item ::item * >
725 //void tree < ::item * >::update_levels()
726 //{
727
728 // ::collection::index iLevel = -1;
729
730 // ::pointer<tree_item>pitem = get_base_item();
731
732 // while (pitem != nullptr)
733 // {
734
735 // pitem->m_iLevel = iLevel;
736
737 // pitem = pitem->get_child_next_or_parent(&iLevel);
738
739 // }
740
741 //}
742
743 //template < prototype_item ::item * >
744 //void tree < ::item * >::_001ExpandItem(::data::tree_item * pitem, const ::action_context & context, bool bExpand, bool bRedraw, bool bLayout)
745 //{
746
747
748 //}
749 //template < prototype_item ::item * >
750 //void tree < ::item * >::_001EnsureVisible(::data::tree_item * pitem)
751 //{
752
753
754 //}
755
756 //template < prototype_item ::item * >
757 //void tree < ::item * >::_001SelectItem(::data::tree_item * pitem)
758 //{
759
760
761 //}
762 //template < prototype_item ::item * >
763 //void tree < ::item * >::get_selection(::data::tree_item_ptr_array<::item *> & itemptraSelected) const
764 //{
765
766
767 //}
768 //template < prototype_item ::item * >
769
770 //bool tree < ::item * >::is_selected(const ::data::tree_item * pitem) const
771 //{
772
773
774 // return false;
775
776 //}
777
778 //template < prototype_item ::item * >
779 //bool tree < ::item * >::is_selected(const ::item * * pitem) const
780 //{
781
782
783 // return false;
784
785 //}
786
787 //template < prototype_item ::item * >
788 //void tree < ::item * >::_001OnItemExpand(::data::tree_item * pitem, const ::action_context & context)
789 //{
790
791 // if (pitem->is_expanded())
792 // return;
793
794 // pitem->on_fill_children();
795
796 // if (pitem->get_children_count() > 0)
797 // {
798 // pitem->m_dwState |= ::data::e_tree_item_state_expanded;
799 // pitem->m_dwState |= ::data::e_tree_item_state_expandable;
800 // }
801
802 // /* for (::collection::index i = 0; i < m_treeptra.get_count(); i++)
803 // {
804
805 // m_treeptra[i]._001OnItemExpand(pitem, context);
806
807 // }*/
808
809
810
811
812 //}
813
814 //template < prototype_item ::item * >
815 //void tree < ::item * >::_001OnItemCollapse(::data::tree_item * pitem, const ::action_context & context)
816 //{
817
818 // if (!pitem->is_expanded())
819 // return;
820 // if (pitem->get_children_count() > 0)
821 // {
822 // pitem->m_dwState |= ::data::e_tree_item_state_expandable;
823 // }
824 // pitem->m_dwState &= ~::data::e_tree_item_state_expanded;
825 // /*for (::collection::index i = 0; i < m_treeptra.get_count(); i++)
826 // {
827
828 // m_treeptra[i]._001OnItemCollapse(pitem);
829
830 // }*/
831
832 //}
833
834 //template < prototype_item ::item * >
835 //void tree < ::item * >::_001OnOpenItem(::data::tree_item * pitem, const ::action_context & context)
836 //{
837
838
839 //}
840
841 //template < prototype_item ::item * >
842 //void tree < ::item * >::_001OnItemContextMenu(::data::tree_item * pitem, const ::action_context & context, ::user::element * ptree, const ::i32_point & point)
843 //{
844
845
846 //}
847
848 //template < prototype_item ::item * >
849 //::collection::count tree < ::item * >::selection_set(::data::tree_item_ptr_array<::item *> & itemptra)
850 //{
851
852 // return 0;
853
854 //}
855
856 //template < prototype_item ::item * >
857 //bool tree < ::item * >::selection_set(::data::tree_item * pitem, bool bIfNotInSelection, bool bIfParentInSelection)
858 //{
859
860 // return false;
861
862 //}
863
864 //template < prototype_item ::item * >
865 //bool tree < ::item * >::selection_set(::item * * pitem, bool bIfNotInSelection, bool bIfParentInSelection)
866 //{
867
868 // return false;
869
870 //}
871
872 //template < prototype_item ::item * >
873 //bool tree < ::item * >::selection_set(::collection::index iIndex, ::item * * pitem, bool bIfNotInSelection, bool bIfParentInSelection)
874 //{
875
876 // return false;
877
878 //}
879
880 //template < prototype_item ::item * >
881 //::image::image_list * tree < ::item * >::get_image_list() const
882 //{
883
884 // return nullptr;
885
886 //}
887
888
891
893
894 //template < prototype_item ::item * >
895 //void tree < ::item * >::handle(::topic * ptopic, ::handler_context * phandlercontext)
896 //{
897
898 // for (auto & ptree : m_treea)
899 // {
900
901 // ptree->handle(ptopic, phandlercontext);
902
903 // }
904
905 //}
906
907
908
911
913
914
915 //template < prototype_item ::item * >
916 //void tree < ::item * >::on_fill_children()
917 //{
918
919 //}
920
921
924
926
928
931
933
935
937
938 //template < prototype_item ::item * >
939 //void tree < ::item * >::on_tree_layout()
940 //{
941
942 //}
943
944 //template < prototype_item ::item * >
945 //void tree < ::item * >::fill_children()
946 //{
947
948 // try
949 // {
950
951 // on_fill_children();
952
953 // }
954 // catch (...)
955 // {
956
957 // }
958
959
960 // try
961 // {
962
963 // //auto pgraphics = ::draw2d::create_memory_graphics();
964
965 // //tree_layout(pgraphics);
966
967 // on_tree_layout();
968
969 // }
970 // catch (...)
971 // {
972
973 // }
974
975 // m_bFill = false;
976
977 //}
978
979
982
984
985
986
987} // namespace data
988
989//
990//
991//inline stream & operator <<(stream & s, const ::data::tree & tree);
992//
993//inline stream & operator >>(stream & s, ::data::tree & tree);
994//
995//
996