]> Creatis software - creaImageIO.git/blob - src2/creaImageIOWxTreeView.cpp
Fixed number of children algorithm and repetition of nodes on add directory.
[creaImageIO.git] / src2 / creaImageIOWxTreeView.cpp
1 #include <creaImageIOWxTreeView.h>
2 #include <creaImageIOGimmickView.h>
3 #include <creaImageIOSystem.h>
4 #include <wx/splitter.h>
5 #include <wx/gdicmn.h>
6 ///Comparing function for ordering algorithm. Takes parameters as strings.
7 int wxCALLBACK CompareFunctionStrings(long item1, long item2, long sortData)
8 {       
9         std::string s1((char*)((long*)item1)[1]);
10         std::string s2((char*)((long*)item2)[1]);
11         if(sortData==1)
12         {
13                 // inverse the order
14                 if (s1 < s2)
15                         return 1;
16                 if (s1 > s2)
17                         return -1;
18
19                 return 0;
20         }
21         else
22         {
23                 if (s1 < s2)
24                         return -1;
25                 if (s1 > s2)
26                         return 1;
27
28                 return 0;
29
30         }
31         
32 }
33
34 ///Comparing function for ordering algorithm. Takes parameters as ints.
35 int wxCALLBACK CompareFunctionInts(long item1, long item2, long sortData)
36 {       
37         int val1=atoi((char*)((long*)item1)[1]);
38         int val2=atoi((char*)((long*)item2)[1]);
39         if(sortData==1)
40         {
41                 // inverse the order
42                 if (val1 < val2)
43                         return 1;
44                 if (val1 > val2)
45                         return -1;
46
47                 return 0;
48         }
49         else
50         {
51                 if (val1 < val2)
52                         return -1;
53                 if (val1 > val2)
54                         return 1;
55
56                 return 0;
57
58         }
59         
60 }
61
62 namespace creaImageIO
63 {
64   //=====================================================================
65   // CTor
66   WxTreeView::WxTreeView(TreeHandler* handler,
67                          GimmickView* gimmick,
68                          wxWindow* parent,
69                          const wxWindowID id)
70     : wxPanel(parent,id),
71       TreeView(handler,gimmick)
72   {
73     GimmickDebugMessage(1,"WxTreeView::WxTreeView"
74                         <<std::endl);
75
76     
77     // Split part below toolbar into notebook for views and panel
78     // for preview, messages...
79     // TO DO : Splitter
80     //    mSplitter = new wxSplitterWindow( this , -1);
81
82     // Global sizer
83     wxBoxSizer  *sizer = new wxBoxSizer(wxHORIZONTAL);
84     
85     int ctrl_style = wxLC_REPORT | wxLC_VRULES;
86     int col_style = wxLIST_FORMAT_LEFT;
87
88     // Creating the ListCtrl for the levels > 0 (not for Root level)
89     for (int i = 1;
90          i < handler->GetTree().GetNumberOfLevels();
91          ++i)
92       {
93
94         GimmickDebugMessage(5,"Creating view for level "<<i
95                             <<std::endl);
96         LevelType level;
97
98         // If the first level : parent = this
99         wxWindow* sparent = this;
100         // else parent = last splitter
101         if (i>1) sparent = mLevelList[i-2].wxSplitter;
102
103         level.wxSplitter = new wxSplitterWindow( sparent , -1);
104         if(i!=1)
105         {
106         level.wxSplitter->Show(false);
107         }
108         //          level.wxSplitter->SetMinimumPaneSize(100);
109         
110         wxListCtrl* ctrl = new wxListCtrl(level.wxSplitter,
111                                           i,
112                                           wxDefaultPosition, 
113                                           wxDefaultSize,
114                                           ctrl_style);
115         level.wxCtrl = ctrl;
116         level.wxSplitter->Initialize(ctrl);
117
118
119         // Create the columns : one for each attribute of the level
120         int col = 0;
121         std::string title;
122         tree::LevelDescriptor::AttributeDescriptorListType::const_iterator a;
123         for (a  = handler->GetTree().GetAttributeDescriptorList(i).begin();
124              a != handler->GetTree().GetAttributeDescriptorList(i).end();
125              ++a)
126           {
127         
128                 GimmickDebugMessage(5,"Creating column "<<col<<" : "
129                                 <<a->GetName()
130                                 <<std::endl);
131
132                 if(a->GetFlags()!=creaImageIO::tree::AttributeDescriptor::PRIVATE)
133                 {
134
135                 if(a->GetName()=="UNKNOWN")
136                 {
137            title = "#";
138                    title += handler->GetTree().GetLevelDescriptor(i+1).GetName();
139                 if (title[title.size()-1]!='s')
140               title += "s";
141
142                 }
143                 else
144                 {
145                         title=a->GetName();
146                 }
147                 ctrl->InsertColumn(col, 
148                                 crea::std2wx(title),
149                                 col_style);
150                 level.key.push_back(a->GetKey());
151                 //          ctrl->SetColumnWidth(col, wxLIST_AUTOSIZE );
152                 col++;
153                 }
154                 
155           }
156           
157         mLevelList.push_back(level);
158       }
159     
160 #if wxUSE_MENUS
161
162     menu =new wxMenu;
163         wxMenuItem* m1=menu->Append(wxID_ANY, _T("&Sort ascending"));
164         wxMenuItem* m2=menu->Append(wxID_ANY, _T("&Sort descending"));
165         wxMenuItem* m3=menu->Append(wxID_ANY, _T("&Filter"));
166         mAscendingID=m1->GetId();
167         mDescendingID=m2->GetId();
168         mFilterID=m3->GetId();
169         Connect( mAscendingID, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(WxTreeView::OnPopupSort) );
170         Connect( mDescendingID, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(WxTreeView::OnPopupSort) );
171         Connect( mFilterID, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(WxTreeView::OnPopupFilter) );
172         
173 #endif // wxUSE_MENUS
174
175
176     /// Initialize the first level splitter
177  
178       sizer->Add( mLevelList[0].wxSplitter ,1, wxGROW  ,0);
179         mColumnSelected=1;
180         mLastSelected=0;
181         mDirection=true;
182         mSelectionMade=false;
183         mProcess=true;
184         //CreateColorPalette();
185     UpdateLevel(1);
186
187     SetSizer( sizer );     
188     SetAutoLayout(true);
189     Layout();
190
191   }
192   //=====================================================================
193
194   //=====================================================================
195   /// Destructor
196   WxTreeView::~WxTreeView()
197   {
198     GimmickDebugMessage(1,"WxTreeView::~WxTreeView"
199                         <<std::endl);
200   }
201   //=====================================================================
202   
203   
204   //=====================================================================
205   struct ItemData
206   {
207     tree::Node* node;
208         int id;
209   };
210  
211   //=====================================================================
212    std::vector<tree::Node*> WxTreeView::GetSelected(int level)
213   {
214     int l = level - 1;
215     // the selection of upper level
216     std::vector<tree::Node*> sel;
217         
218     if (level == 1) 
219       {
220         sel.push_back(GetTreeHandler()->GetTree().GetTree());
221       }
222     else 
223       {
224         int n = GetCtrl(l-1)->GetItemCount();
225         for (int i = 0; i < n; i++)
226           {
227             if ( GetCtrl(l-1)->GetItemState(i,wxLIST_STATE_SELECTED))
228               {
229                 long adr = GetCtrl(l-1)->GetItemData(i);
230                 tree::Node* n = ((ItemData*)adr)->node;
231                         if(mLastSelected==i)
232                         {
233                                 std::vector<tree::Node*>::iterator it;
234                                 it = sel.begin();
235                                 it = sel.insert ( it , n );
236                         }
237                         else
238                         {
239                                 sel.push_back(n);
240                         }
241               }
242           }     
243       }
244          
245           return sel;
246   }
247
248   //=====================================================================
249   
250   ///Removes selected nodes on given level
251   void WxTreeView::RemoveSelected( int level )
252   {
253           std::vector<tree::Node*> sel=GetSelected(level+1);
254           bool erase=false;
255           if (wxMessageBox(_T("Delete file(s) ?"),
256                          _T("Remove Files"),
257                          wxYES_NO,this ) == wxYES)
258           {
259             erase = true;
260           }
261           if(erase)
262           {
263                 std::vector<tree::Node*>::iterator i;
264                 for (i=sel.begin(); i!=sel.end(); ++i)
265                 {
266                         GimmickDebugMessage(2,
267                                         "deleting '"
268                                         <<(*i)->GetLabel()
269                                         <<"'"<<level
270                                         <<std::endl);
271                                 GetTreeHandler()->Remove(*i);
272                 }
273
274                 UpdateLevel(level);
275           }
276           
277   }
278     
279
280   //=====================================================================
281
282  
283   //=====================================================================
284   /// Updates a level of the view (adds or removes children, proganizes, etc.)
285   void WxTreeView::UpdateLevel( int level )
286   {
287     GimmickDebugMessage(1,
288                         GetTreeHandler()->GetTree().GetLabel()
289                         <<" view : updating level "<<level
290                         <<std::endl);
291     
292     wxBusyCursor busy;
293     RecursiveUpdateLevel(level);
294     int i;
295     for (i=0; i<level-1; i++)
296       {
297         if (!GetSplitter(i)->IsSplit()) 
298           GetSplitter(i)->SplitVertically(  GetCtrl(i), GetSplitter(i+1),
299                                             100 );
300       }
301     if (GetSplitter(i)->IsSplit()) GetSplitter(i)->Unsplit();    
302     
303   }
304   //=====================================================================
305   
306   /// Recursive method called upon by UpdateLevel to refresh all windows
307   void WxTreeView::RecursiveUpdateLevel( int level )
308   {
309           GimmickDebugMessage(2,
310                         GetTreeHandler()->GetTree().GetLabel()
311                         <<" view : updating level (recursive)"<<level
312                         <<std::endl);
313
314
315     std::vector<tree::Node*> sel=GetSelected(level);
316
317           int l = level - 1;
318  
319     // to speed up inserting we hide the control temporarily
320     GetCtrl(l)->Hide();
321     GetCtrl(l)->DeleteAllItems();
322     
323     std::vector<tree::Node*>::iterator i;
324         
325         for (i=sel.begin(); i!=sel.end(); ++i)
326       {
327         GimmickDebugMessage(2,
328                             "adding children of '"
329                             <<(*i)->GetLabel()
330                             <<"'"
331                             <<std::endl);
332         int _id=1;
333         
334         //Adds items and sets their attributes 
335         GetCtrl(l)->InsertItem(0, _T(""));
336         GetTreeHandler()->LoadChildren(*i,1);
337         tree::Node::ChildrenListType::reverse_iterator j;
338         for (j = (*i)->GetChildrenList().rbegin(); 
339              j!= (*i)->GetChildrenList().rend(); 
340              ++j)
341           {
342                          wxListItem* item= new wxListItem;
343             item->SetMask(wxLIST_MASK_STATE | 
344                          wxLIST_MASK_TEXT |
345                          //                      wxLIST_MASK_IMAGE |
346                          wxLIST_MASK_DATA |
347                          //                      wxLIST_MASK_WIDTH |
348                          wxLIST_MASK_FORMAT
349                          );
350            
351             ItemData* data = new ItemData;
352             
353                 data->node = *j;
354                 item->SetId(_id);
355
356                 data->id = _id;
357             item->SetData(data);
358             
359                 _id++;
360                 GetCtrl(l)->InsertItem(*item);
361                 
362                 //Setting attributes
363
364                 for (int k=0; k<GetCtrl(l)->GetColumnCount(); k++)
365               {
366                           std::string val = (*j)->GetAttribute(mLevelList[l].key[k]);
367                         if (val.size()==0) val = "?";
368                         item->SetText( crea::std2wx(val));
369                         item->SetColumn(k);
370                         GetCtrl(l)->SetItem(*item);
371               } 
372                   
373           }
374         GetCtrl(l)->DeleteItem(0);
375       }
376     
377     GetCtrl(l)->Show();
378         
379  }
380   //=====================================================================
381
382
383   //================================================================
384   void WxTreeView::OnSelectedChanged(wxListEvent& event)
385   { 
386     GimmickDebugMessage(1,
387                         GetTreeHandler()->GetTree().GetLabel()
388                         <<" view : item selected "
389                         <<std::endl);
390     
391     wxListItem info;
392     info.m_itemId = event.m_itemIndex;
393     mLastSelected = event.m_itemIndex;
394     // retrieve the level
395     wxObject* obj = event.GetEventObject();   
396     unsigned int level = 0;
397     for (level = 0; level<mLevelList.size(); ++level)
398       {
399         if ( GetCtrl(level) == obj ) break;
400       }
401     GimmickDebugMessage(1,
402                         " Level "<<level+1
403                         <<std::endl);
404     
405     // Update the children level (if selection not at last level)
406     if (level<mLevelList.size()-1) 
407       {
408         UpdateLevel( level + 2 ); 
409         // Reset the viewer setting the default image
410         GetGimmickView()->ClearSelection();
411       }
412     // Select all images if the selection is at series level
413     if (level==mLevelList.size()-2) SelectLowerLevel();
414     // Validate selected images if the selection is at image level
415     if (level==(mLevelList.size()-1)&&mProcess) 
416       {
417         if(event.GetEventType()==10145)
418           {
419             ValidateSelectedImages (true);
420           }
421         else
422           {
423             ValidateSelectedImages (false);
424           }
425       }
426     
427   }
428   //================================================================
429
430   //================================================================
431   void WxTreeView::SelectLowerLevel()
432   {
433         long item = -1;
434         int level=mLevelList.size()-1;
435     for ( ;; )
436     {
437                 item = GetCtrl(level)->GetNextItem(item,
438                                      wxLIST_NEXT_ALL);
439         if ( item == -1 )
440             break;
441
442                 if(item==(GetCtrl(level)->GetItemCount()-1))
443                 {
444                         mProcess=true;
445                 }
446                 else
447                 {
448                         mProcess=false;
449                 }
450                 GetCtrl(level)->SetItemState(item,wxLIST_STATE_SELECTED, wxLIST_MASK_STATE 
451                 | wxLIST_MASK_TEXT |wxLIST_MASK_IMAGE | wxLIST_MASK_DATA | wxLIST_MASK_WIDTH | wxLIST_MASK_FORMAT);
452     }
453   }
454
455   //================================================================
456   //================================================================
457
458   void WxTreeView::OnColClick(wxListEvent& event)
459   { 
460         mColumnSelected=event.m_col;
461         wxPoint clientpt;
462         clientpt.x = wxGetMousePosition().x - this->GetScreenPosition().x;
463         clientpt.y = wxGetMousePosition().y - this->GetScreenPosition().y;
464         senderCtrl = event.GetEventObject(); 
465         unsigned int level = 0;
466         for (level = 0; level<mLevelList.size(); ++level)
467         {
468         if ( GetCtrl(level) == senderCtrl ) break;
469         }
470         PopupMenu(menu, clientpt);
471
472   }
473     
474   //================================================================
475   //================================================================
476
477   void WxTreeView::OnPopupFilter(wxCommandEvent& event)
478   {
479                 wxBusyCursor busy;
480                  GimmickDebugMessage(7,
481                         "WxTreeView::OnEndLabelEdit" 
482                         <<std::endl);
483           wxObject* ctrl = event.GetEventObject(); 
484                 unsigned int level = 0;
485                 for (level = 0; level<mLevelList.size(); ++level)
486                 {
487                 if ( GetCtrl(level) == senderCtrl ) break;
488                 }
489                 std::string filter = crea::wx2std(wxGetTextFromUser(_T("Enter the filter to apply"), _T("Filter On Column")));
490                 
491                 std::string att;
492                 
493                 long it = -1;
494                 UpdateLevel(level+1);
495                 
496                 std::vector<long> items;
497                 bool in=false;
498                 int del=0;
499                 for ( ;; )
500                 {
501                         it = GetCtrl(level)->GetNextItem(it,
502                                                                                 wxLIST_NEXT_ALL);
503                         if ( it == -1 )
504                                 break;
505                         
506                         long adr = GetCtrl(level)->GetItemData(it);
507                         tree::Node* nod = ((ItemData*)adr)->node;
508                         att=(*nod).GetAttribute(mLevelList[level].key[mColumnSelected]);
509                         
510                         
511                         if(att.find(filter)>900)
512                         {
513                                 
514                                 if(!in)
515                                 {
516                                         in=true;
517                                 }
518                                 else
519                                 {
520                                         del+=1;
521                                 }
522                                 
523                                 items.push_back(it-del);
524                         }
525                         
526                 }
527                 std::vector<long>::iterator iter;
528                 for(iter=items.begin();iter!=items.end();++iter)
529                 {
530                         GetCtrl(level)->DeleteItem(*iter);
531                 }
532                 GetGimmickView()->ClearSelection();
533   }
534   //================================================================
535
536   //================================================================
537   void WxTreeView::OnPopupSort(wxCommandEvent& event)
538   {
539                 wxBusyCursor busy;
540                 unsigned int level = 0;
541                 for (level = 0; level<mLevelList.size(); ++level)
542                 {
543                 if ( GetCtrl(level) == senderCtrl ) break;
544                 }
545                 if(event.GetId()==mAscendingID)
546                 {
547                         mDirection=true;
548                 }
549                 else if(event.GetId()==mDescendingID)
550                 {
551                         mDirection=false;
552                 }
553
554         OnSort(level);
555   }
556   //================================================================
557   void WxTreeView::OnSort(int level)
558   {       
559         //Obtain the column name and the level that needs to be organized
560
561                 int l = level - 1;
562                 //Sets the data for the items to be sorted
563                 std::string att;
564                 unsigned int ty=0;
565                 int n = GetCtrl(level)->GetItemCount();
566                 for (int i = 0; i < n; i++)
567                 {
568                           
569                         //Gets current item data
570                         long adr = GetCtrl(level)->GetItemData(i);
571                         
572                         //Extracts the node and the type of attribute
573                         tree::Node* nod = ((ItemData*)adr)->node;
574                         if(i==0)
575                         {
576                                 (*nod).GetAttributeDescriptor(mLevelList[level].key[mColumnSelected]).DecodeType(ty);
577                         }
578                         //Obtains the organizing attribute
579                         att=(*nod).GetAttribute(mLevelList[level].key[mColumnSelected]);
580                         
581                         char* d= new char [att.size()+1];
582                         strcpy (d, att.c_str());
583
584                         //Creates array
585                         long* lp= new long[2];
586                         lp[0]=adr;
587                         lp[1]=(long)d;
588                          
589                         //Sets it as the data
590                         GetCtrl(level)->SetItemData(i,(long)lp);
591                 }       
592                   
593                 if(mDirection)
594                 {
595                         if(ty==1)
596                         {
597                                 GetCtrl(level)->SortItems(CompareFunctionInts, 0);
598                         }
599                         else
600                         {
601                                 GetCtrl(level)->SortItems(CompareFunctionStrings, 0);
602                         }
603                         
604                 }
605                 else
606                 {
607                         if(ty==1)
608                         {
609                                 GetCtrl(level)->SortItems(CompareFunctionInts, 1);
610                         }
611                         else
612                         {
613                                 GetCtrl(level)->SortItems(CompareFunctionStrings, 1);
614                         }
615                 }
616
617                 //Resets original data
618                 
619                 std::vector<tree::Node*>::iterator selection;
620                 std::vector<long> change;
621                 long it = -1;
622                 for ( ;; )
623                 {
624                         it = GetCtrl(level)->GetNextItem(it,
625                                                                                 wxLIST_NEXT_ALL);
626                         if ( it == -1 )
627                                 break;
628                         
629                         //Gets current item data, extracts the node and resets it
630                         long item = GetCtrl(level)->GetItemData(it);
631                         GetCtrl(level)->SetItemData(it,((long*)item)[0]);
632                         tree::Node* n= ((ItemData*)((long*)item)[0])->node;                     
633                         
634                 }
635         
636    }
637  
638   //================================================================
639   void WxTreeView::ValidateSelectedImages(bool isSelection)
640   {
641     GimmickDebugMessage(7,
642                         "WxTreeView::ValidateSelectedImages" 
643                         <<std::endl);
644     std::vector<tree::Node*> sel(GetSelected(mLevelList.size()+1));
645         GetGimmickView()->OnSelectionChange(sel,isSelection,(mLastSelected-1), mProcess);
646  
647   }
648   //================================================================
649
650
651   //================================================================
652   void WxTreeView::GetNodes(std::vector<tree::Node*>& nodes, bool direction)
653   {
654         long item = mLastSelected;
655         int level=mLevelList.size()-1;
656         //Gets current item data
657         long adr = GetCtrl(level)->GetItemData(item);
658         //Extracts the node
659         tree::Node* nod = ((ItemData*)adr)->node;
660     for ( ;; )
661     {
662                 if(direction)
663                 {
664                         item = GetCtrl(level)->GetNextItem(item,
665                                      wxLIST_NEXT_ABOVE);
666                 }
667                 else
668                 {
669                         item = GetCtrl(level)->GetNextItem(item,
670                                      wxLIST_NEXT_BELOW);
671                 }
672         if ( item == -1  )
673                 {
674             break;
675                 }
676                 if(GetCtrl(level)->GetItemState(item, wxLIST_STATE_SELECTED)==0 /*&& item!=0*/)
677                 {
678                         adr = GetCtrl(level)->GetItemData(item);
679                         nod = ((ItemData*)adr)->node;
680                         nodes.push_back(nod);
681                 }
682     }
683
684   }
685
686   //================================================================
687   void WxTreeView::GetSelectedAsString(std::vector<std::string>&s)
688   {
689           int level=mLevelList.size();
690         std::vector<tree::Node*> sel=GetSelected(level+1);
691         std::vector<tree::Node*>::iterator i;
692         
693     for (i=sel.begin(); i!=sel.end(); ++i)
694       {
695                   std::string filename=(*i)->GetAttribute("FullFileName");
696                   s.push_back(filename);
697           }
698   }
699
700    //================================================================
701   void WxTreeView::SetColor(int l, int item)
702   {
703           int colorId=12;
704           GetCtrl(l)->SetItemTextColour(item, wxColourDatabase().Find
705                    (crea::std2wx(mColorPalette[colorId])));
706           GetCtrl(l)->SetItemState(item,wxLIST_STATE_SELECTED | wxLIST_STATE_FOCUSED, wxLIST_STATE_SELECTED);  /*
707           int colorId=0;
708           //Setting the color according to the parent
709                 if(l==0)
710                 {
711                 item.SetBackgroundColour
712                   (wxColourDatabase().Find
713                    (crea::std2wx(mColorPalette[colorId]))); 
714                 mColorMap.insert
715                   (NodeColorPair
716                    (*j,wxColourDatabase().Find
717                     (crea::std2wx(mColorPalette[colorId]))));
718                 if(colorId<64)
719                   {
720                     colorId++;
721                   }
722                 else
723                         {
724                           colorId=0;
725                         }
726                 }
727                 else if(l!=mLevelList.size()-1)
728                   {
729                     item.SetBackgroundColour(mColorMap[*i]); 
730                         mColorMap.insert(NodeColorPair(*j,mColorMap[*i]));
731                 }
732                 else
733                 {
734                         item.SetBackgroundColour(mColorMap[*i]); 
735                 }*/
736   }
737   //================================================================
738   void WxTreeView::CreateColorPalette()
739   {
740   GimmickDebugMessage(6,"WxTreeView::CreateColorPalette");
741   mColorPalette.push_back("WHITE");
742   mColorPalette.push_back("LIGHT GREY");
743   mColorPalette.push_back("AQUAMARINE");
744   mColorPalette.push_back("MEDIUM FOREST GREEN");
745   mColorPalette.push_back("INDIAN RED");
746   mColorPalette.push_back("KHAKI");
747   mColorPalette.push_back("ORANGE");
748   mColorPalette.push_back("LIGHT BLUE");
749   mColorPalette.push_back("LIGHT STEEL BLUE");
750   mColorPalette.push_back("PINK");
751   mColorPalette.push_back("PLUM");
752   mColorPalette.push_back("PURPLE");
753   mColorPalette.push_back("RED");
754   mColorPalette.push_back("SEA GREEN");
755   mColorPalette.push_back("SIENNA");
756   mColorPalette.push_back("SKY BLUE");
757   mColorPalette.push_back("SLATE BLUE");
758   mColorPalette.push_back("SPRING GREEN");
759   mColorPalette.push_back("TAN");
760   mColorPalette.push_back("THISTLE");
761   mColorPalette.push_back("TURQUOISE");
762   mColorPalette.push_back("VIOLET");
763   mColorPalette.push_back("VIOLET RED");
764   mColorPalette.push_back("WHEAT");
765   mColorPalette.push_back("YELLOW");
766   mColorPalette.push_back("YELLOW GREEN");
767   mColorPalette.push_back("BLUE");
768   mColorPalette.push_back("BLUE VIOLET");
769   mColorPalette.push_back("BROWN");
770   mColorPalette.push_back("CADET BLUE");
771   mColorPalette.push_back("CORAL");
772   mColorPalette.push_back("CORNFLOWER BLUE");
773   mColorPalette.push_back("CYAN");
774   mColorPalette.push_back("DARK GREY");
775   mColorPalette.push_back("DARK GREEN");
776   mColorPalette.push_back("DARK OLIVE GREEN");
777   mColorPalette.push_back("DARK ORCHID");
778   mColorPalette.push_back("DARK SLATE BLUE");
779   mColorPalette.push_back("DARK SLATE GREY");
780   mColorPalette.push_back("DARK TURQUOISE");
781   mColorPalette.push_back("FIREBRICK");
782   mColorPalette.push_back("FOREST GREEN");
783   mColorPalette.push_back("GOLD");
784   mColorPalette.push_back("GOLDENROD");
785   mColorPalette.push_back("GREY");
786   mColorPalette.push_back("GREEN");
787   mColorPalette.push_back("GREEN YELLOW");
788   mColorPalette.push_back("LIME GREEN");
789   mColorPalette.push_back("MAGENTA");
790   mColorPalette.push_back("MAROON");
791   mColorPalette.push_back("MEDIUM AQUAMARINE");
792   mColorPalette.push_back("MEDIUM BLUE");
793   mColorPalette.push_back("MEDIUM GOLDENROD");
794   mColorPalette.push_back("MEDIUM ORCHID");
795   mColorPalette.push_back("MEDIUM SEA GREEN");
796   mColorPalette.push_back("MEDIUM SLATE BLUE");
797   mColorPalette.push_back("MEDIUM SPRING GREEN");
798   mColorPalette.push_back("MEDIUM TURQUOISE");
799   mColorPalette.push_back("MEDIUM VIOLET RED");
800   mColorPalette.push_back("MIDNIGHT BLUE");
801   mColorPalette.push_back("NAVY");
802   mColorPalette.push_back("ORANGE RED");
803   mColorPalette.push_back("ORCHID, PALE GREEN");
804   mColorPalette.push_back("STEEL BLUE");
805   mColorPalette.push_back("BLACK");
806
807
808   }
809   //================================================================
810   BEGIN_EVENT_TABLE(WxTreeView, wxPanel)   
811   /*
812     EVT_SIZE(MyFrame::OnSize)
813
814     EVT_MENU(LIST_QUIT, MyFrame::OnQuit)
815     EVT_MENU(LIST_ABOUT, MyFrame::OnAbout)
816     EVT_MENU(LIST_LIST_VIEW, MyFrame::OnListView)
817     EVT_MENU(LIST_REPORT_VIEW, MyFrame::OnReportView)
818     EVT_MENU(LIST_ICON_VIEW, MyFrame::OnIconView)
819     EVT_MENU(LIST_ICON_TEXT_VIEW, MyFrame::OnIconTextView)
820     EVT_MENU(LIST_SMALL_ICON_VIEW, MyFrame::OnSmallIconView)
821     EVT_MENU(LIST_SMALL_ICON_TEXT_VIEW, MyFrame::OnSmallIconTextView)
822     EVT_MENU(LIST_VIRTUAL_VIEW, MyFrame::OnVirtualView)
823     EVT_MENU(LIST_SMALL_VIRTUAL_VIEW, MyFrame::OnSmallVirtualView)
824
825     EVT_MENU(LIST_FOCUS_LAST, MyFrame::OnFocusLast)
826     EVT_MENU(LIST_TOGGLE_FIRST, MyFrame::OnToggleFirstSel)
827     EVT_MENU(LIST_DESELECT_ALL, MyFrame::OnDeselectAll)
828     EVT_MENU(LIST_SELECT_ALL, MyFrame::OnSelectAll)
829     EVT_MENU(LIST_DELETE, MyFrame::OnDelete)
830     EVT_MENU(LIST_ADD, MyFrame::OnAdd)
831     EVT_MENU(LIST_EDIT, MyFrame::OnEdit)
832     EVT_MENU(LIST_DELETE_ALL, MyFrame::OnDeleteAll)
833     EVT_MENU(LIST_SORT, MyFrame::OnSort)
834     EVT_MENU(LIST_SET_FG_COL, MyFrame::OnSetFgColour)
835     EVT_MENU(LIST_SET_BG_COL, MyFrame::OnSetBgColour)
836     EVT_MENU(LIST_TOGGLE_MULTI_SEL, MyFrame::OnToggleMultiSel)
837     EVT_MENU(LIST_SHOW_COL_INFO, MyFrame::OnShowColInfo)
838     EVT_MENU(LIST_SHOW_SEL_INFO, MyFrame::OnShowSelInfo)
839     EVT_MENU(LIST_FREEZE, MyFrame::OnFreeze)
840     EVT_MENU(LIST_THAW, MyFrame::OnThaw)
841     EVT_MENU(LIST_TOGGLE_LINES, MyFrame::OnToggleLines)
842     EVT_MENU(LIST_MAC_USE_GENERIC, MyFrame::OnToggleMacUseGeneric)
843
844     EVT_UPDATE_UI(LIST_SHOW_COL_INFO, MyFrame::OnUpdateShowColInfo)
845     EVT_UPDATE_UI(LIST_TOGGLE_MULTI_SEL, MyFrame::OnUpdateToggleMultiSel)
846 END_EVENT_TABLE()
847
848 BEGIN_EVENT_TABLE(MyListCtrl, wxListCtrl)
849     EVT_LIST_BEGIN_DRAG(LIST_CTRL, MyListCtrl::OnBeginDrag)
850     EVT_LIST_BEGIN_RDRAG(LIST_CTRL, MyListCtrl::OnBeginRDrag)
851         
852     EVT_LIST_BEGIN_LABEL_EDIT(-1, WxTreeView::OnBeginLabelEdit)
853     EVT_LIST_END_LABEL_EDIT(-1, WxTreeView::OnEndLabelEdit)
854         
855     EVT_LIST_DELETE_ITEM(LIST_CTRL, MyListCtrl::OnDeleteItem)
856     EVT_LIST_DELETE_ALL_ITEMS(LIST_CTRL, MyListCtrl::OnDeleteAllItems)
857 #if WXWIN_COMPATIBILITY_2_4
858     EVT_LIST_GET_INFO(LIST_CTRL, MyListCtrl::OnGetInfo)
859     EVT_LIST_SET_INFO(LIST_CTRL, MyListCtrl::OnSetInfo)
860 #endif
861   */
862     EVT_LIST_ITEM_SELECTED(-1, WxTreeView::OnSelectedChanged)
863   
864     EVT_LIST_ITEM_DESELECTED(-1, WxTreeView::OnSelectedChanged)
865         /*
866     EVT_LIST_KEY_DOWN(LIST_CTRL, MyListCtrl::OnListKeyDown)
867     EVT_LIST_ITEM_ACTIVATED(LIST_CTRL, MyListCtrl::OnActivated)
868     EVT_LIST_ITEM_FOCUSED(LIST_CTRL, MyListCtrl::OnFocused)
869 */
870     EVT_LIST_COL_RIGHT_CLICK(-1, WxTreeView::OnColClick)
871         
872     EVT_LIST_COL_CLICK(-1, WxTreeView::OnColClick)
873
874         //EVT_LEFT_DOWN(WxTreeView::OnMouseClick)
875         /*
876     EVT_LIST_COL_BEGIN_DRAG(LIST_CTRL, MyListCtrl::OnColBeginDrag)
877     EVT_LIST_COL_DRAGGING(LIST_CTRL, MyListCtrl::OnColDragging)
878     EVT_LIST_COL_END_DRAG(LIST_CTRL, MyListCtrl::OnColEndDrag)
879
880     EVT_LIST_CACHE_HINT(LIST_CTRL, MyListCtrl::OnCacheHint)
881
882 #if USE_CONTEXT_MENU
883     EVT_CONTEXT_MENU(MyListCtrl::OnContextMenu)
884 #endif
885     EVT_CHAR(MyListCtrl::OnChar)
886
887     EVT_RIGHT_DOWN(MyListCtrl::OnRightClick)
888   */
889 END_EVENT_TABLE()
890   
891 } // EO namespace creaImageIO
892