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/help.xpm"
13 #include <wx/imaglist.h>
17 //======================================================================
18 // The ids of the different tools
26 //======================================================================
28 //================================================================
30 const int icon_number = 6;
42 //================================================================
44 //================================================================
46 const icon_id Icon[5] = { Icon_Database,
52 //================================================================
55 //======================================================================
57 WxGimmickView::WxGimmickView(Gimmick* gimmick,
60 const wxPoint& pos, const wxSize& size,
62 int number_of_threads)
63 : wxPanel(parent,id,pos,size),
66 GimmickDebugMessage(1,"WxGimmickView::WxGimmickView"
68 // Create the list of icons (mIcon)
72 wxBoxSizer *sizer = new wxBoxSizer(wxVERTICAL);
74 // Create the tool bar
76 sizer->Add( mToolBar ,0, wxGROW ,0);
78 // Split part below toolbar into notebook for views and panel
79 // for preview, messages...
80 mSplitter = new wxSplitterWindow( this , -1);
84 mNotebook = new wxNotebook(mSplitter,
85 -1,wxDefaultPosition, wxDefaultSize, 0);
91 mBottomPanel = new wxPanel(mSplitter,-1);
94 int hsize = size.GetHeight();
95 int bottom_minsize = 200;
97 mSplitter->SetMinimumPaneSize( bottom_minsize );
98 mSplitter->SplitHorizontally( mNotebook, mBottomPanel,
99 hsize - bottom_minsize);
101 sizer->Add( mSplitter,1,wxGROW ,0);
109 //======================================================================
111 //======================================================================
113 WxGimmickView::~WxGimmickView()
115 GimmickDebugMessage(1,"WxGimmickView::~WxGimmickView"
118 //======================================================================
120 //======================================================================
121 /// Creates the tool bar
122 void WxGimmickView::CreateToolBar()
124 long style = wxTB_HORIZONTAL | wxNO_BORDER;
125 mToolBar = new wxToolBar(this,-1,wxDefaultPosition,wxDefaultSize,
128 mToolAddFile = mToolBar->AddTool( TOOL_ADDFILE_ID,
130 mIcon->GetBitmap(Icon_page_down),
133 mToolAddDir = mToolBar->AddTool( TOOL_ADDDIR_ID,
135 mIcon->GetBitmap(Icon_folder_down),
138 mToolRemove = mToolBar->AddTool( TOOL_REMOVE_ID,
139 _T("Remove selected"),
140 mIcon->GetBitmap(Icon_remove),
141 _T("Remove selected")
143 mToolHelp = mToolBar->AddTool( TOOL_HELP_ID,
145 mIcon->GetBitmap(Icon_help),
148 //const wxBitmap& bitmap1, const wxString& shortHelpString = "", wxItemKind kind = wxITEM_NORMAL)
152 //======================================================================
155 //======================================================================
156 /// Create the tree view for TreeHandler provided
157 void WxGimmickView::CreateTreeView( TreeHandler* h)
159 std::string name(h->GetTree().GetAttribute("Name"));
160 GimmickMessage(2,"Creating the tree view for '"<<
161 name<<"'"<<std::endl);
162 // Create the WxTreeView
163 WxTreeView* view = new WxTreeView(h,mNotebook,-1);
165 // TO DO : TEST THAT A VIEW WITH SAME NAME IS NOT
166 // ALREADY IN THE MAP
167 GetTreeViewMap()[name] = view;
170 mNotebook->AddPage( view, crea::std2wx(name) );
173 //======================================================================
177 //=================================================
178 void WxGimmickView::CreateIconList()
180 // Size of the icons;
184 // should correspond to Icon_xxx enum
185 icons[Icon_accept] = wxIcon(accept_xpm);
186 icons[Icon_add] = wxIcon(add_xpm);
187 icons[Icon_folder_down] = wxIcon(folder_down_xpm);
188 icons[Icon_page_down] = wxIcon(page_down_xpm);
189 icons[Icon_remove] = wxIcon(remove_xpm);
190 icons[Icon_help] = wxIcon(help_xpm);
192 // unsigned int NbIcons = 8;
193 // Make an image list containing small icons
194 mIcon = new wxImageList(size,size,true);
196 // Make all icons the same size = size of the first one
197 int sizeOrig = icons[0].GetWidth();
198 for ( size_t i = 0; i < icon_number; i++ )
200 if ( size == sizeOrig )
202 mIcon->Add(icons[i]);
206 mIcon->Add(wxBitmap(wxBitmap(icons[i]).ConvertToImage().Rescale(size, size)));
210 //=================================================
214 } // EO namespace creaImageIO