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