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