1 #include <creaImageIOWxGimmickView.h>
2 #include <creaImageIOWxTreeView.h>
3 #include <creaImageIOSystem.h>
6 #include "icons/accept.xpm"
7 #include "icons/add.xpm"
8 #include "icons/folder-down.xpm"
9 #include "icons/page-down.xpm"
10 #include "icons/remove.xpm"
11 #include "icons/database-add.xpm"
12 #include "icons/help.xpm"
14 #include <wx/imaglist.h>
18 //======================================================================
19 // The ids of the different tools
25 TOOL_ADDDATABASE_ID = 4,
28 //======================================================================
30 //================================================================
32 const int icon_number = 7;
45 //================================================================
47 //================================================================
49 const icon_id Icon[5] = { Icon_Database,
55 //================================================================
58 //======================================================================
60 WxGimmickView::WxGimmickView(Gimmick* gimmick,
63 const wxPoint& pos, const wxSize& size,
65 int number_of_threads)
66 : wxPanel(parent,id,pos,size),
69 GimmickDebugMessage(1,"WxGimmickView::WxGimmickView"
71 // Create the list of icons (mIcon)
75 wxBoxSizer *sizer = new wxBoxSizer(wxVERTICAL);
77 // Create the tool bar
79 sizer->Add( mToolBar ,0, wxGROW ,0);
81 // Split part below toolbar into notebook for views and panel
82 // for preview, messages...
83 mSplitter = new wxSplitterWindow( this , -1);
87 mNotebook = new wxNotebook(mSplitter,
88 -1,wxDefaultPosition, wxDefaultSize, 0);
94 mBottomPanel = new wxPanel(mSplitter,-1);
97 int hsize = size.GetHeight();
98 int bottom_minsize = 200;
100 mSplitter->SetMinimumPaneSize( bottom_minsize );
101 mSplitter->SplitHorizontally( mNotebook, mBottomPanel,
102 hsize - bottom_minsize);
104 sizer->Add( mSplitter,1,wxGROW ,0);
112 //======================================================================
114 //======================================================================
116 WxGimmickView::~WxGimmickView()
118 GimmickDebugMessage(1,"WxGimmickView::~WxGimmickView"
121 //======================================================================
123 //======================================================================
124 /// Creates the tool bar
125 void WxGimmickView::CreateToolBar()
127 long style = wxTB_HORIZONTAL | wxNO_BORDER | wxTB_TEXT;
128 mToolBar = new wxToolBar(this,-1,wxDefaultPosition,wxDefaultSize,
131 mToolAddFile = mToolBar->AddTool( TOOL_ADDFILE_ID,
133 mIcon->GetBitmap(Icon_page_down),
134 _T("Add some file(s) to database")
136 mToolAddDir = mToolBar->AddTool( TOOL_ADDDIR_ID,
138 mIcon->GetBitmap(Icon_folder_down),
139 _T("Add the content of a folder to database")
141 mToolRemove = mToolBar->AddTool( TOOL_REMOVE_ID,
143 mIcon->GetBitmap(Icon_remove),
144 _T("Remove selected items")
146 mToolAddDatabase = mToolBar->AddTool( TOOL_ADDDATABASE_ID,
148 mIcon->GetBitmap(Icon_database_add),
149 _T("Open a local or distant database")
151 mToolHelp = mToolBar->AddTool( TOOL_HELP_ID,
153 mIcon->GetBitmap(Icon_help),
154 _T("Open help window")
156 //const wxBitmap& bitmap1, const wxString& shortHelpString = "", wxItemKind kind = wxITEM_NORMAL)
160 //======================================================================
163 //======================================================================
164 /// Create the tree view for TreeHandler provided
165 void WxGimmickView::CreateTreeView( TreeHandler* h)
167 std::string name(h->GetTree().GetAttribute("Name"));
168 GimmickMessage(2,"Creating the tree view for '"<<
169 name<<"'"<<std::endl);
170 // Create the WxTreeView
171 WxTreeView* view = new WxTreeView(h,mNotebook,-1);
173 // TO DO : TEST THAT A VIEW WITH SAME NAME IS NOT
174 // ALREADY IN THE MAP
175 GetTreeViewMap()[name] = view;
178 mNotebook->AddPage( view, crea::std2wx(name) );
181 //======================================================================
185 //=================================================
186 void WxGimmickView::CreateIconList()
188 // Size of the icons;
192 // should correspond to Icon_xxx enum
193 icons[Icon_accept] = wxIcon(accept_xpm);
194 icons[Icon_add] = wxIcon(add_xpm);
195 icons[Icon_folder_down] = wxIcon(folder_down_xpm);
196 icons[Icon_page_down] = wxIcon(page_down_xpm);
197 icons[Icon_remove] = wxIcon(remove_xpm);
198 icons[Icon_database_add] = wxIcon(database_add_xpm);
199 icons[Icon_help] = wxIcon(help_xpm);
201 // unsigned int NbIcons = 8;
202 // Make an image list containing small icons
203 mIcon = new wxImageList(size,size,true);
205 // Make all icons the same size = size of the first one
206 int sizeOrig = icons[0].GetWidth();
207 for ( size_t i = 0; i < icon_number; i++ )
209 if ( size == sizeOrig )
211 mIcon->Add(icons[i]);
215 mIcon->Add(wxBitmap(wxBitmap(icons[i]).ConvertToImage().Rescale(size, size)));
219 //=================================================
223 } // EO namespace creaImageIO