1 #include <creaImageIOWxTreeView.h>
2 #include <creaImageIOGimmickView.h>
3 #include <creaImageIOSystem.h>
4 #include <wx/splitter.h>
6 #include <boost/date_time/gregorian/gregorian.hpp>
8 const std::string empty_string("");
10 //=====================================================================
13 //=====================================================================
14 /// Data stored by the list items
17 ItemData() : node(0), id(-1), attr(&empty_string) {}
18 // The corresponding Node
22 // The pointer on the current attribute string to sort on
23 const std::string* attr;
24 // Was the item previously selected ?
25 // Useful for reselecting the item after sort
28 //=====================================================================
30 //=====================================================================
32 //=====================================================================
33 ///Comparing function for ordering algorithm. Takes parameters as strings.
34 int wxCALLBACK CompareFunctionStrings(long item1, long item2, long sortData)
36 creaImageIO::ItemData* data1 = (creaImageIO::ItemData*)item1;
37 creaImageIO::ItemData* data2 = (creaImageIO::ItemData*)item2;
39 const std::string& s1(*(data1->attr));
40 const std::string& s2(*(data2->attr));
62 //=====================================================================
64 //=====================================================================
65 ///Comparing function for ordering algorithm. Takes parameters as ints.
66 int wxCALLBACK CompareFunctionInts(long item1, long item2, long sortData)
68 creaImageIO::ItemData* data1 = (creaImageIO::ItemData*)item1;
69 creaImageIO::ItemData* data2 = (creaImageIO::ItemData*)item2;
71 const std::string& s1(*(data1->attr));
72 const std::string& s2(*(data2->attr));
74 int val1=atoi(s1.c_str());
75 int val2=atoi(s2.c_str());
100 //=====================================================================
103 //=====================================================================
104 namespace creaImageIO
106 //=====================================================================
108 WxTreeView::WxTreeView(TreeHandler* handler,
109 GimmickView* gimmick,
112 : wxPanel(parent,id),
113 TreeView(handler, gimmick)
115 GimmickDebugMessage(1,"WxTreeView::WxTreeView"
119 // Split part below toolbar into notebook for views and panel
120 // for preview, messages...
122 // mSplitter = new wxSplitterWindow( this , -1);
125 wxBoxSizer *sizer = new wxBoxSizer(wxHORIZONTAL);
127 int ctrl_style = wxLC_REPORT | wxLC_VRULES;
128 int col_style = wxLIST_FORMAT_LEFT;
130 // Creating the ListCtrl for the levels > 0 (not for Root level)
132 i < handler->GetTree().GetNumberOfLevels() -1;
135 GimmickDebugMessage(5,"Creating view for level "<<i
138 level.SelectedUpToDate = true;
139 level.SortColumn = 0;
141 // If the first level : parent = this
142 wxWindow* sparent = this;
143 // else parent = last splitter
145 sparent = mLevelList[i-1].wxSplitter;
147 level.wxSplitter = new wxSplitterWindow( sparent , -1);
150 level.wxSplitter->Show(false);
152 // level.wxSplitter->SetMinimumPaneSize(100);
154 wxListCtrl* ctrl = new wxListCtrl(level.wxSplitter,
160 level.wxSplitter->Initialize(ctrl);
162 // Create the columns : one for each attribute of the level
166 tree::LevelDescriptor::AttributeDescriptorListType::const_iterator a;
167 for (a = handler->GetTree().GetAttributeDescriptorList(i+1).begin();
168 a != handler->GetTree().GetAttributeDescriptorList(i+1).end();
173 GimmickDebugMessage(5,"Creating column "<<col<<" : "
177 if(a->GetFlags()!=creaImageIO::tree::AttributeDescriptor::PRIVATE)
180 if(a->GetName()=="UNKNOWN")
183 title += handler->GetTree().GetLevelDescriptor(i+1).GetName();
184 if (title[title.size()-1]!='s')
192 std::string temp = a->GetKey();
193 if (temp.compare("ID") != 0)
196 ctrl->InsertColumn(col,
201 level.key.push_back(a->GetKey());
206 mLevelList.push_back(level);
213 wxMenuItem* m1=menu->Append(wxID_ANY, _T("&Sort ascending"));
214 wxMenuItem* m2=menu->Append(wxID_ANY, _T("&Sort descending"));
215 wxMenuItem* m3=menu->Append(wxID_ANY, _T("&Filter"));
216 mAscendingID=m1->GetId();
217 mDescendingID=m2->GetId();
218 mFilterID=m3->GetId();
219 Connect( mAscendingID, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(WxTreeView::OnPopupSort) );
220 Connect( mDescendingID, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(WxTreeView::OnPopupSort) );
221 Connect( mFilterID, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(WxTreeView::OnPopupFilter) );
226 menuItem =new wxMenu;
227 wxMenuItem* m1Item=menuItem->Append(wxID_ANY, _T("&Anonymize"));
228 wxMenuItem* m2Item=menuItem->Append(wxID_ANY, _T("&Local Copy"));
229 wxMenuItem* m3Item=menuItem->Append(wxID_ANY, _T("&Edit Fields"));
231 mAnonymizingID=m1Item->GetId();
232 mLocalCopyID=m2Item->GetId();
233 mEditFieldID=m3Item->GetId();
234 //Connect( mAnonymizingID, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(WxTreeView::OnAnonymize) );
235 Connect( mLocalCopyID, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(WxTreeView::OnLocalCopy) );
236 Connect( mEditFieldID, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(WxTreeView::OnEditField) );
239 #endif // wxUSE_MENUS
240 /// Initialize the first level splitter
242 sizer->Add( mLevelList[0].wxSplitter ,1, wxGROW ,0);
243 // mColumnSelected=1;
248 mIgnoreSelectedChanged = false;
250 //CreateColorPalette();
258 //=====================================================================
260 //=====================================================================
262 WxTreeView::~WxTreeView()
264 GimmickDebugMessage(1,"WxTreeView::~WxTreeView"
267 //=====================================================================
271 //=====================================================================
272 const std::vector<tree::Node*>& WxTreeView::GetSelected(int level)
274 // if (GetSelectedUpToDate(level))
276 // the selection of upper level
277 std::vector<tree::Node*>& sel(mLevelList[l].Selected);
281 sel.push_back(GetTreeHandler()->GetTree().GetTree());
283 else if (level < mLevelList.size()+2 )
288 item = GetCtrl(l-1)->GetNextItem(item,
290 wxLIST_STATE_SELECTED);
293 long adr = GetCtrl(l-1)->GetItemData(item);
294 tree::Node* n = ((ItemData*)adr)->node;
295 if(mLastSelected==item)
297 std::vector<tree::Node*>::iterator it;
299 it = sel.insert ( it , n );
308 /*int n = GetCtrl(l-1)->GetItemCount();
309 for (int i = 0; i<n; i++)
311 std::cout<<GetCtrl(l-1)->GetItemState(i,wxLIST_STATE_SELECTED)<<std::endl;
312 if ( GetCtrl(l-1)->GetItemState(i,wxLIST_STATE_SELECTED))
314 long adr = GetCtrl(l-1)->GetItemData(i);
315 tree::Node* n = ((ItemData*)adr)->node;
318 std::vector<tree::Node*>::iterator it;
320 it = sel.insert ( it , n );
335 // return mLevelList[level-1].Selected;
339 //=====================================================================
341 //=====================================================================
342 ///Removes selected nodes on last selected level
344 void WxTreeView::RemoveSelected()
346 unsigned int tempLevel = mLastLevel;
348 const std::vector<tree::Node*>& sel=GetSelected(mLastLevel+1);
349 // if no selection, no remove action.
353 std::stringstream out;
354 std::string levelName=GetTreeHandler()->GetTree().GetLevelDescriptor(mLastLevel).GetName();
357 if(sel.size()>1&&levelName.at(levelName.size()-1)!='s')
364 out<<" "<<GetTreeHandler()->GetTree().GetLevelDescriptor(mLastLevel).GetName()<<"?";
366 if (wxMessageBox(crea::std2wx(out.str()),
368 wxYES_NO,this ) == wxYES)
374 GetGimmickView()->modifyValidationSignal(false);
375 bool needRefresh=false;
376 std::vector<tree::Node*>::const_iterator i;
377 for (i=sel.begin(); i!=sel.end(); ++i)
384 if((*i)->GetParent()->GetNumberOfChildren()<2)
388 tree::Node* n= (tree::Node*)(*i);
389 GetTreeHandler()->LoadChildren((*i),4);
390 GetGimmickView()->AddIgnoreFile(n);
391 GetTreeHandler()->Remove(*i);
394 if(needRefresh && mLastLevel>1)
396 UpdateLevel(mLastLevel-2);
398 else if(mLastLevel>1)
400 UpdateLevel(mLastLevel-1);
404 UpdateLevel(mLastLevel);
410 // no need to incremente level
411 mLastLevel = tempLevel;
417 //=====================================================================
418 /// Updates a level of the view (adds or removes children, etc.)
419 void WxTreeView::UpdateLevel( int level )
421 GimmickDebugMessage(1,
422 GetTreeHandler()->GetTree().GetLabel()
423 <<"WxTreeView::UpdateLevel(level "
429 RecursiveUpdateLevel(level);
431 for (i=0; i<level-1; i++)
433 if (!GetSplitter(i)->IsSplit())
434 GetSplitter(i)->SplitVertically( GetCtrl(i), GetSplitter(i+1),
437 if (GetSplitter(i)->IsSplit()) GetSplitter(i)->Unsplit();
440 //=====================================================================
442 //=====================================================================
443 /// Recursive method called upon by UpdateLevel to refresh all windows
444 void WxTreeView::RecursiveUpdateLevel( int level )
446 GimmickDebugMessage(1,
447 GetTreeHandler()->GetTree().GetLabel()
448 <<"WxTreeView::RecursiveUpdateLevel(level "
453 const std::vector<tree::Node*>& sel(GetSelected(level));
457 // to speed up inserting we hide the control temporarily
459 GetCtrl(l)->DeleteAllItems();
461 std::vector<tree::Node*>::const_iterator i;
463 for (i=sel.begin(); i!=sel.end(); ++i)
465 GimmickDebugMessage(1,
466 "adding children of '"
472 //Adds items and sets their attributes
474 GetTreeHandler()->LoadChildren(*i,1);
475 tree::Node::ChildrenListType::reverse_iterator j;
476 for (j = (*i)->GetChildrenList().rbegin();
477 j!= (*i)->GetChildrenList().rend();
480 GimmickDebugMessage(1,
487 item.SetMask(wxLIST_MASK_STATE |
489 // wxLIST_MASK_IMAGE |
491 // wxLIST_MASK_WIDTH |
495 ItemData* data = new ItemData;
503 GetCtrl(l)->InsertItem(item);
506 for (int k=0; k<GetCtrl(l)->GetColumnCount(); ++k)
509 // Temporary correction : it works but no explanation about the problem FCY
513 val = (*j)->GetAttribute("NumberOfChildren");
516 val = (*j)->GetAttribute(mLevelList[l].key[k]);
517 if(((*j)->GetAttributeDescriptor(mLevelList[l].key[k])).isDateEntry()) // Date
519 // std::cout << "["<<val<< "]" << std::endl;
520 std::string valtmp(val);
523 boost::gregorian::date d1(boost::gregorian::from_undelimited_string(val));
524 val = to_iso_extended_string(d1);
530 // std::cout << "["<<val<< "]" << std::endl;
532 else if(((*j)->GetAttributeDescriptor(mLevelList[l].key[k])).isTimeEntry()) // Time
534 if ((val.size()>6) &&
535 (val != "" || val != " "))
536 val = val.substr(0,2) + " : "
537 + val.substr(2,2) + " : "
544 if (val.size()==0) val = "?";
545 item.SetText( crea::std2wx(val));
547 GetCtrl(l)->SetItem(item);
556 //=====================================================================
559 //================================================================
560 void WxTreeView::OnItemDeSelected(wxListEvent& event)
562 GimmickDebugMessage(1,
563 GetTreeHandler()->GetTree().GetLabel()
564 <<" WxTreeView::OnItemDeselected"<<std::endl);
565 // retrieve the level
566 wxObject* obj = event.GetEventObject();
567 unsigned int level = 0;
568 for (level = 0; level<mLevelList.size(); ++level)
570 if ( GetCtrl(level) == obj ) break;
572 SetSelectedUpToDate(level,false);
573 // to allow a first selection in images TreeView
574 if (level==mLevelList.size()-1)
575 OnItemSelected(event);
577 //================================================================
579 //================================================================
580 void WxTreeView::OnItemSelected(wxListEvent& event)
583 GimmickDebugMessage(1,
584 GetTreeHandler()->GetTree().GetLabel()
585 <<" WxTreeView::OnItemSelected"<<std::endl);
587 if (mIgnoreSelectedChanged)
589 GimmickDebugMessage(1,
590 " mIgnoreSelectedChanged true: returning"
598 info.m_itemId = event.m_itemIndex;
599 mLastSelected = event.m_itemIndex;
600 // retrieve the level
601 wxObject* obj = event.GetEventObject();
602 unsigned int level = 0;
603 for (level = 0; level<mLevelList.size(); ++level)
605 if ( GetCtrl(level) == obj ) break;
608 GimmickDebugMessage(1,
612 // Update the children level (if selection not at last level)
613 if (level<mLevelList.size()-1)
616 UpdateLevel( level + 2 );
617 // Reset the viewer setting the default image
618 GetGimmickView()->ClearSelection();
620 // Select all images if the selection is at series level
621 if (level==mLevelList.size()-2) SelectAll(level+1);
622 // Validate selected images if the selection is at image level
623 if (level==(mLevelList.size()-1)) //&&mProcess)
625 if(event.GetEventType()==wxEVT_COMMAND_LIST_ITEM_SELECTED)
627 ValidateSelectedImages (true);
631 ValidateSelectedImages (false);
636 //================================================================
638 //================================================================
639 void WxTreeView::SelectAll(int level)
642 // int level=mLevelList.size()-1;
645 item = GetCtrl(level)->GetNextItem(item,
650 if(item==(GetCtrl(level)->GetItemCount()-1))
652 mIgnoreSelectedChanged = false;//mProcess=true;
656 mIgnoreSelectedChanged = true;// mProcess=false;
658 GetCtrl(level)->SetItemState(item,wxLIST_STATE_SELECTED, wxLIST_MASK_STATE
659 | wxLIST_MASK_TEXT |wxLIST_MASK_IMAGE | wxLIST_MASK_DATA | wxLIST_MASK_WIDTH | wxLIST_MASK_FORMAT);
663 //================================================================
664 //================================================================
666 void WxTreeView::OnColClick(wxListEvent& event)
668 mColumnSelected = event.m_col;
670 clientpt.x = wxGetMousePosition().x - this->GetScreenPosition().x;
671 clientpt.y = wxGetMousePosition().y - this->GetScreenPosition().y;
672 senderCtrl = event.GetEventObject();
673 unsigned int level = 0;
674 for (level = 0; level<mLevelList.size(); ++level)
676 if ( GetCtrl(level) == senderCtrl ) break;
678 PopupMenu(menu, clientpt);
682 //================================================================
683 //================================================================
685 void WxTreeView::OnItemMenu(wxListEvent &event)
688 clientpt.x = wxGetMousePosition().x - this->GetScreenPosition().x;
689 clientpt.y = wxGetMousePosition().y - this->GetScreenPosition().y;
690 senderCtrl = event.GetEventObject();
691 unsigned int level = 0;
692 for (level = 0; level<mLevelList.size(); ++level)
694 if ( GetCtrl(level) == senderCtrl ) break;
698 mLastRightLevel=level;
699 mLastRightSelected=GetCtrl(level)->HitTest(wxPoint(0,clientpt.y-8),flag,ptr);
700 PopupMenu(menuItem, clientpt);
704 //================================================================
705 //================================================================
707 void WxTreeView::OnPopupFilter(wxCommandEvent& event)
710 GimmickDebugMessage(7,
711 "WxTreeView::OnEndLabelEdit"
713 unsigned int level = 0;
714 for (level = 0; level<mLevelList.size(); ++level)
716 if ( GetCtrl(level) == senderCtrl ) break;
718 std::string filter = crea::wx2std(wxGetTextFromUser(_T("Enter the filter to apply"), _T("Filter On Column")));
723 UpdateLevel(level+1);
725 std::vector<long> items;
730 it = GetCtrl(level)->GetNextItem(it,
735 long adr = GetCtrl(level)->GetItemData(it);
736 tree::Node* nod = ((ItemData*)adr)->node;
737 att=(*nod).GetAttribute(mLevelList[level].key[mColumnSelected]);
740 if(att.find(filter)>900)
752 items.push_back(it-del);
756 std::vector<long>::iterator iter;
757 for(iter=items.begin();iter!=items.end();++iter)
759 GetCtrl(level)->DeleteItem(*iter);
761 GetGimmickView()->ClearSelection();
763 //================================================================
765 //================================================================
766 void WxTreeView::OnPopupSort(wxCommandEvent& event)
769 unsigned int level = 0;
770 for (level = 0; level<mLevelList.size(); ++level)
772 if ( GetCtrl(level) == senderCtrl ) break;
774 mLevelList[level].SortColumn = mColumnSelected;
776 if(event.GetId()==mAscendingID)
778 mLevelList[level].SortAscending = true;
780 else if(event.GetId()==mDescendingID)
782 mLevelList[level].SortAscending = false;
787 //================================================================
789 //================================================================
790 void WxTreeView::OnLocalCopy(wxCommandEvent& event)
794 unsigned int tempLevel = mLastLevel;
796 const std::vector<tree::Node*>& sel=GetSelected(mLastLevel+1);
801 std::stringstream out;
802 std::string levelName=GetTreeHandler()->GetTree().GetLevelDescriptor(mLastLevel).GetName();
805 if(sel.size()>1&&levelName.at(levelName.size()-1)!='s')
808 out<<"s to .gimmick?";
812 out<<" "<<GetTreeHandler()->GetTree().GetLevelDescriptor(mLastLevel).GetName()<<" to .gimmick?";
814 if (wxMessageBox(crea::std2wx(out.str()),
816 wxYES_NO,this ) == wxYES)
822 std::vector<std::string> s;
823 GetFilenamesAsString(sel,s);
824 GetGimmickView()->CopyFiles(s);
829 mLastLevel = tempLevel;
834 //================================================================
836 //================================================================
837 void WxTreeView::OnEditField(wxCommandEvent& event)
839 if(mLastRightSelected!=-1)
841 tree::Node* node=((ItemData*)GetCtrl(mLastRightLevel)->GetItemData(mLastRightSelected))->node;
842 tree::LevelDescriptor::AttributeDescriptorListType::const_iterator a;
843 std::vector<std::string> names;
844 std::vector<std::string> keys;
845 for (a = GetTreeHandler()->GetTree().GetAttributeDescriptorList(mLastRightLevel+1).begin();
846 a != GetTreeHandler()->GetTree().GetAttributeDescriptorList(mLastRightLevel+1).end();
849 if(a->GetFlags()==creaImageIO::tree::AttributeDescriptor::EDITABLE)
851 names.push_back(a->GetName());
852 keys.push_back(a->GetKey());
855 GetGimmickView()->CreateEditFieldsDialog(node,names,keys);
858 //================================================================
860 //================================================================
861 void WxTreeView::SortLevel(int level)
863 GimmickDebugMessage(1,
864 "WxTreeView::SortLevel("
867 //Obtain the column name and the level that needs to be organized
869 // int l = level - 1;
870 //Sets the data for the items to be sorted
874 int n = GetCtrl(level)->GetItemCount();
875 for (int i = 0; i < n; i++)
878 //Gets current item data
879 ItemData* data = (ItemData*)GetCtrl(level)->GetItemData(i);
881 //Extracts the node and the type of attribute
882 tree::Node* nod = data->node;
885 (*nod).GetAttributeDescriptor
886 (mLevelList[level].key[mLevelList[level].SortColumn])
889 //Obtains the organizing attribute
890 data->attr = & (*nod).GetAttribute
891 (mLevelList[level].key[mLevelList[level].SortColumn]);
893 data->selected = false;
894 if (GetCtrl(level)->GetItemState(i,wxLIST_STATE_SELECTED)>0)
896 data->selected = true;
901 GimmickDebugMessage(1,
902 "WxTreeView::OnSort : "
903 <<nbselected<<" selected before sorting"
906 mIgnoreSelectedChanged = true;
908 if (mLevelList[level].SortAscending)
913 GetCtrl(level)->SortItems(CompareFunctionInts, 0);
917 GetCtrl(level)->SortItems(CompareFunctionStrings, 0);
925 GetCtrl(level)->SortItems(CompareFunctionInts, 1);
929 GetCtrl(level)->SortItems(CompareFunctionStrings, 1);
934 // Reselects the unselected
935 n = GetCtrl(level)->GetItemCount();
937 for (int i = 0; i < n; i++)
940 //Gets current item data
941 ItemData* data = (ItemData*)GetCtrl(level)->GetItemData(i);
946 // item = GetCtrl(level)->GetNextItem(item,wxLIST_NEXT_ALL);
947 // if ( item == -1 ) break;
948 //Gets current item data
949 // ItemData* data = (ItemData*)GetCtrl(level)->GetItemData(item);
957 // if it is the last one we must process the selection
958 mIgnoreSelectedChanged = false;
960 GetCtrl(level)->SetItemState(i,
961 wxLIST_STATE_SELECTED,
967 | wxLIST_MASK_FORMAT);
969 if (GetCtrl(level)->GetItemState(i,wxLIST_STATE_SELECTED)>0)
976 mIgnoreSelectedChanged = false;
977 GimmickDebugMessage(1,
978 "WxTreeView::SortLevel : "
979 <<after<<" selected after sorting"
983 //================================================================
986 //================================================================
987 void WxTreeView::ValidateSelectedImages(bool isSelection)
989 GimmickDebugMessage(7,
990 "WxTreeView::ValidateSelectedImages"
992 const std::vector<tree::Node*>& sel(GetSelected(mLevelList.size()+1));
993 GetGimmickView()->OnSelectionChange(sel,
994 isSelection,(mLastSelected-1),
995 !mIgnoreSelectedChanged);
998 //================================================================
1001 //================================================================
1002 void WxTreeView::GetNodes(std::vector<tree::Node*>& nodes, bool direction)
1004 long item = mLastSelected;
1005 int level=mLevelList.size()-1;
1006 //Gets current item data
1007 long adr = GetCtrl(level)->GetItemData(item);
1009 tree::Node* nod = ((ItemData*)adr)->node;
1014 item = GetCtrl(level)->GetNextItem(item,
1019 item = GetCtrl(level)->GetNextItem(item,
1022 if ( item == -1 || item==0 )
1026 if(GetCtrl(level)->GetItemState(item, wxLIST_STATE_SELECTED)==0 )
1029 adr = GetCtrl(level)->GetItemData(item);
1030 nod = ((ItemData*)adr)->node;
1031 nodes.push_back(nod);
1036 //================================================================
1037 //=================================================
1038 void WxTreeView::OnKeyDown(wxListEvent &event)
1040 if(event.GetKeyCode() == WXK_DELETE)
1045 GetGimmickView()->ClearSelection();
1049 //================================================================
1051 //================================================================
1052 // Should be in another place : not specific !
1053 void WxTreeView::GetSelectedAsString(std::vector<std::string>&s)
1055 int level=mLevelList.size();
1056 const std::vector<tree::Node*>& sel=GetSelected(level+1);
1057 std::vector<tree::Node*>::const_iterator i;
1059 for (i=sel.begin(); i!=sel.end(); ++i)
1061 std::string filename=(*i)->GetAttribute("FullFileName");
1062 s.push_back(filename);
1066 //================================================================
1067 void WxTreeView::GetFilenamesAsString(const std::vector<tree::Node*>& nodes, std::vector<std::string>&s)
1069 std::vector<tree::Node*>::const_iterator i;
1071 for (i=nodes.begin(); i!=nodes.end(); ++i)
1073 if((*i)->GetLevel()<mLevelList.size())
1075 GetTreeHandler()->LoadChildren(*i,0);
1076 GetFilenamesAsString((*i)->GetChildrenList(),s);
1080 std::string filename=(*i)->GetAttribute("FullFileName");
1081 s.push_back(filename);
1086 //================================================================
1087 void WxTreeView::SetColor(int l, int item)
1090 GetCtrl(l)->SetItemTextColour(item, wxColourDatabase().Find
1091 (crea::std2wx(mColorPalette[colorId])));
1092 GetCtrl(l)->SetItemState(item,wxLIST_STATE_SELECTED | wxLIST_STATE_FOCUSED, wxLIST_STATE_SELECTED); /*
1094 //Setting the color according to the parent
1097 item.SetBackgroundColour
1098 (wxColourDatabase().Find
1099 (crea::std2wx(mColorPalette[colorId])));
1102 (*j,wxColourDatabase().Find
1103 (crea::std2wx(mColorPalette[colorId]))));
1113 else if(l!=mLevelList.size()-1)
1115 item.SetBackgroundColour(mColorMap[*i]);
1116 mColorMap.insert(NodeColorPair(*j,mColorMap[*i]));
1120 item.SetBackgroundColour(mColorMap[*i]);
1123 //================================================================
1124 void WxTreeView::CreateColorPalette()
1126 GimmickDebugMessage(6,"WxTreeView::CreateColorPalette");
1127 mColorPalette.push_back("WHITE");
1128 mColorPalette.push_back("LIGHT GREY");
1129 mColorPalette.push_back("AQUAMARINE");
1130 mColorPalette.push_back("MEDIUM FOREST GREEN");
1131 mColorPalette.push_back("INDIAN RED");
1132 mColorPalette.push_back("KHAKI");
1133 mColorPalette.push_back("ORANGE");
1134 mColorPalette.push_back("LIGHT BLUE");
1135 mColorPalette.push_back("LIGHT STEEL BLUE");
1136 mColorPalette.push_back("PINK");
1137 mColorPalette.push_back("PLUM");
1138 mColorPalette.push_back("PURPLE");
1139 mColorPalette.push_back("RED");
1140 mColorPalette.push_back("SEA GREEN");
1141 mColorPalette.push_back("SIENNA");
1142 mColorPalette.push_back("SKY BLUE");
1143 mColorPalette.push_back("SLATE BLUE");
1144 mColorPalette.push_back("SPRING GREEN");
1145 mColorPalette.push_back("TAN");
1146 mColorPalette.push_back("THISTLE");
1147 mColorPalette.push_back("TURQUOISE");
1148 mColorPalette.push_back("VIOLET");
1149 mColorPalette.push_back("VIOLET RED");
1150 mColorPalette.push_back("WHEAT");
1151 mColorPalette.push_back("YELLOW");
1152 mColorPalette.push_back("YELLOW GREEN");
1153 mColorPalette.push_back("BLUE");
1154 mColorPalette.push_back("BLUE VIOLET");
1155 mColorPalette.push_back("BROWN");
1156 mColorPalette.push_back("CADET BLUE");
1157 mColorPalette.push_back("CORAL");
1158 mColorPalette.push_back("CORNFLOWER BLUE");
1159 mColorPalette.push_back("CYAN");
1160 mColorPalette.push_back("DARK GREY");
1161 mColorPalette.push_back("DARK GREEN");
1162 mColorPalette.push_back("DARK OLIVE GREEN");
1163 mColorPalette.push_back("DARK ORCHID");
1164 mColorPalette.push_back("DARK SLATE BLUE");
1165 mColorPalette.push_back("DARK SLATE GREY");
1166 mColorPalette.push_back("DARK TURQUOISE");
1167 mColorPalette.push_back("FIREBRICK");
1168 mColorPalette.push_back("FOREST GREEN");
1169 mColorPalette.push_back("GOLD");
1170 mColorPalette.push_back("GOLDENROD");
1171 mColorPalette.push_back("GREY");
1172 mColorPalette.push_back("GREEN");
1173 mColorPalette.push_back("GREEN YELLOW");
1174 mColorPalette.push_back("LIME GREEN");
1175 mColorPalette.push_back("MAGENTA");
1176 mColorPalette.push_back("MAROON");
1177 mColorPalette.push_back("MEDIUM AQUAMARINE");
1178 mColorPalette.push_back("MEDIUM BLUE");
1179 mColorPalette.push_back("MEDIUM GOLDENROD");
1180 mColorPalette.push_back("MEDIUM ORCHID");
1181 mColorPalette.push_back("MEDIUM SEA GREEN");
1182 mColorPalette.push_back("MEDIUM SLATE BLUE");
1183 mColorPalette.push_back("MEDIUM SPRING GREEN");
1184 mColorPalette.push_back("MEDIUM TURQUOISE");
1185 mColorPalette.push_back("MEDIUM VIOLET RED");
1186 mColorPalette.push_back("MIDNIGHT BLUE");
1187 mColorPalette.push_back("NAVY");
1188 mColorPalette.push_back("ORANGE RED");
1189 mColorPalette.push_back("ORCHID, PALE GREEN");
1190 mColorPalette.push_back("STEEL BLUE");
1191 mColorPalette.push_back("BLACK");
1195 //================================================================
1196 BEGIN_EVENT_TABLE(WxTreeView, wxPanel)
1198 EVT_SIZE(MyFrame::OnSize)
1200 EVT_MENU(LIST_QUIT, MyFrame::OnQuit)
1201 EVT_MENU(LIST_ABOUT, MyFrame::OnAbout)
1202 EVT_MENU(LIST_LIST_VIEW, MyFrame::OnListView)
1203 EVT_MENU(LIST_REPORT_VIEW, MyFrame::OnReportView)
1204 EVT_MENU(LIST_ICON_VIEW, MyFrame::OnIconView)
1205 EVT_MENU(LIST_ICON_TEXT_VIEW, MyFrame::OnIconTextView)
1206 EVT_MENU(LIST_SMALL_ICON_VIEW, MyFrame::OnSmallIconView)
1207 EVT_MENU(LIST_SMALL_ICON_TEXT_VIEW, MyFrame::OnSmallIconTextView)
1208 EVT_MENU(LIST_VIRTUAL_VIEW, MyFrame::OnVirtualView)
1209 EVT_MENU(LIST_SMALL_VIRTUAL_VIEW, MyFrame::OnSmallVirtualView)
1211 EVT_MENU(LIST_FOCUS_LAST, MyFrame::OnFocusLast)
1212 EVT_MENU(LIST_TOGGLE_FIRST, MyFrame::OnToggleFirstSel)
1213 EVT_MENU(LIST_DESELECT_ALL, MyFrame::OnDeselectAll)
1214 EVT_MENU(LIST_SELECT_ALL, MyFrame::OnSelectAll)
1215 EVT_MENU(LIST_DELETE, MyFrame::OnDelete)
1216 EVT_MENU(LIST_ADD, MyFrame::OnAdd)
1217 EVT_MENU(LIST_EDIT, MyFrame::OnEdit)
1218 EVT_MENU(LIST_DELETE_ALL, MyFrame::OnDeleteAll)
1219 EVT_MENU(LIST_SORT, MyFrame::OnSort)
1220 EVT_MENU(LIST_SET_FG_COL, MyFrame::OnSetFgColour)
1221 EVT_MENU(LIST_SET_BG_COL, MyFrame::OnSetBgColour)
1222 EVT_MENU(LIST_TOGGLE_MULTI_SEL, MyFrame::OnToggleMultiSel)
1223 EVT_MENU(LIST_SHOW_COL_INFO, MyFrame::OnShowColInfo)
1224 EVT_MENU(LIST_SHOW_SEL_INFO, MyFrame::OnShowSelInfo)
1225 EVT_MENU(LIST_FREEZE, MyFrame::OnFreeze)
1226 EVT_MENU(LIST_THAW, MyFrame::OnThaw)
1227 EVT_MENU(LIST_TOGGLE_LINES, MyFrame::OnToggleLines)
1228 EVT_MENU(LIST_MAC_USE_GENERIC, MyFrame::OnToggleMacUseGeneric)
1230 EVT_UPDATE_UI(LIST_SHOW_COL_INFO, MyFrame::OnUpdateShowColInfo)
1231 EVT_UPDATE_UI(LIST_TOGGLE_MULTI_SEL, MyFrame::OnUpdateToggleMultiSel)
1234 BEGIN_EVENT_TABLE(MyListCtrl, wxListCtrl)
1235 EVT_LIST_BEGIN_DRAG(LIST_CTRL, MyListCtrl::OnBeginDrag)
1236 EVT_LIST_BEGIN_RDRAG(LIST_CTRL, MyListCtrl::OnBeginRDrag)
1238 EVT_LIST_BEGIN_LABEL_EDIT(-1, WxTreeView::OnBeginLabelEdit)
1239 EVT_LIST_END_LABEL_EDIT(-1, WxTreeView::OnEndLabelEdit)
1241 EVT_LIST_DELETE_ITEM(LIST_CTRL, MyListCtrl::OnDeleteItem)
1242 EVT_LIST_DELETE_ALL_ITEMS(LIST_CTRL, MyListCtrl::OnDeleteAllItems)
1243 #if WXWIN_COMPATIBILITY_2_4
1244 EVT_LIST_GET_INFO(LIST_CTRL, MyListCtrl::OnGetInfo)
1245 EVT_LIST_SET_INFO(LIST_CTRL, MyListCtrl::OnSetInfo)
1248 EVT_LIST_KEY_DOWN(-1, WxTreeView::OnKeyDown)
1249 EVT_LIST_ITEM_SELECTED(-1, WxTreeView::OnItemSelected)
1250 EVT_LIST_ITEM_RIGHT_CLICK(-1, WxTreeView::OnItemMenu)
1251 EVT_LIST_ITEM_DESELECTED(-1, WxTreeView::OnItemDeSelected)
1253 EVT_LIST_KEY_DOWN(LIST_CTRL, MyListCtrl::OnListKeyDown)
1254 EVT_LIST_ITEM_ACTIVATED(LIST_CTRL, MyListCtrl::OnActivated)
1255 EVT_LIST_ITEM_FOCUSED(LIST_CTRL, MyListCtrl::OnFocused)
1257 EVT_LIST_COL_RIGHT_CLICK(-1, WxTreeView::OnColClick)
1259 EVT_LIST_COL_CLICK(-1, WxTreeView::OnColClick)
1261 //EVT_LEFT_DOWN(WxTreeView::OnMouseClick)
1263 EVT_LIST_COL_BEGIN_DRAG(LIST_CTRL, MyListCtrl::OnColBeginDrag)
1264 EVT_LIST_COL_DRAGGING(LIST_CTRL, MyListCtrl::OnColDragging)
1265 EVT_LIST_COL_END_DRAG(LIST_CTRL, MyListCtrl::OnColEndDrag)
1267 EVT_LIST_CACHE_HINT(LIST_CTRL, MyListCtrl::OnCacheHint)
1269 #if USE_CONTEXT_MENU
1270 EVT_CONTEXT_MENU(MyListCtrl::OnContextMenu)
1272 EVT_CHAR(MyListCtrl::OnChar)
1274 EVT_RIGHT_DOWN(MyListCtrl::OnRightClick)
1278 } // EO namespace creaImageIO