#include <creaImageIOWxGimmickView.h>
+#include <creaImageIOWxTreeView.h>
#include <creaImageIOSystem.h>
+// Icons
+#include "../src/icons/database.xpm"
+#include "../src/icons/folder.xpm"
+#include "../src/icons/dicomdir.xpm"
+#include "../src/icons/patient.xpm"
+#include "../src/icons/study.xpm"
+#include "../src/icons/series.xpm"
+#include "../src/icons/image.xpm"
+#include "../src/icons/root.xpm"
+
+#include <wx/imaglist.h>
+
namespace creaImageIO
{
+ //======================================================================
+ // The ids of the different tools
+ enum
+ {
+ TOOL_ADDFILE_ID = 1
+ };
+ //======================================================================
+
+ //================================================================
+ //
+ const int icon_number = 8;
+ // Icon ids
+ typedef enum
+ {
+ Icon_Root,
+ Icon_Database,
+ Icon_Folder,
+ Icon_DicomDir,
+ Icon_Patient,
+ Icon_Study,
+ Icon_Series,
+ Icon_Image
+ }
+ icon_id;
+ //================================================================
+
+ //================================================================
+ /*
+ const icon_id Icon[5] = { Icon_Database,
+ Icon_Patient,
+ Icon_Study,
+ Icon_Series,
+ Icon_Image };
+ */
+ //================================================================
+
+
+ //======================================================================
// CTor
WxGimmickView::WxGimmickView(Gimmick* gimmick,
wxWindow *parent,
{
GimmickDebugMessage(1,"WxGimmickView::WxGimmickView"
<<std::endl);
+ // Create the list of icons (mIcon)
+ CreateIconList();
// Global sizer
- wxBoxSizer *sizer = new wxBoxSizer(wxHORIZONTAL);
+ wxBoxSizer *sizer = new wxBoxSizer(wxVERTICAL);
+
+ // Create the tool bar
+ CreateToolBar();
+ sizer->Add( mToolBar ,0, wxGROW ,0);
+
+ // Split part below toolbar into notebook for views and panel
+ // for preview, messages...
+ mSplitter = new wxSplitterWindow( this , -1);
+
+
// Notebook
- mNotebook = new wxNotebook(this,
+ mNotebook = new wxNotebook(mSplitter,
-1,wxDefaultPosition, wxDefaultSize, 0);
-
+
+ // Create the views
+ CreateTreeViews();
+
+ // Bottom panel
+ mBottomPanel = new wxPanel(mSplitter,-1);
+
+ // Splitting
+ int hsize = size.GetHeight();
+ int bottom_minsize = 200;
+
+ mSplitter->SetMinimumPaneSize( viewsminsize );
+ mSplitter->SplitHorizontally( mNotebook, mBottomPanel,
+ hsize - bottom_minsize);
+
+ sizer->Add( mSplitter,1,wxGROW ,0);
+
+
+ SetSizer( sizer );
+ SetAutoLayout(true);
+ Layout();
+
}
+ //======================================================================
+ //======================================================================
/// Destructor
WxGimmickView::~WxGimmickView()
{
GimmickDebugMessage(1,"WxGimmickView::~WxGimmickView"
<<std::endl);
}
+ //======================================================================
-
+ //======================================================================
+ /// Creates the tool bar
+ void WxGimmickView::CreateToolBar()
+ {
+ long style = wxTB_HORIZONTAL | wxNO_BORDER;
+ mToolBar = new wxToolBar(this,-1,wxDefaultPosition,wxDefaultSize,
+ style);
+
+ mToolAddFile = mToolBar->AddTool( TOOL_ADDFILE_ID,
+ _T("Add file"),
+ mIcon->GetBitmap(Icon_Database),
+ _T("Add file")
+ );
+ //const wxBitmap& bitmap1, const wxString& shortHelpString = "", wxItemKind kind = wxITEM_NORMAL)
+
+ mToolBar->Realize();
+ }
+ //======================================================================
+
+
+ //======================================================================
+ /// Create the tree view for TreeHandler provided
+ void WxGimmickView::CreateTreeView( TreeHandler* h)
+ {
+ std::string name(h->GetTree().GetAttribute("Name"));
+ GimmickMessage(2,"Creating the tree view for '"<<
+ name<<"'"<<std::endl);
+ // Create the WxTreeView
+ WxTreeView* view = new WxTreeView(h,mNotebook,-1);
+
+ // TO DO : TEST THAT A VIEW WITH SAME NAME IS NOT
+ // ALREADY IN THE MAP
+ GetTreeViewMap()[name] = view;
+
+ // Add Notebook page
+ mNotebook->AddPage( view, crea::std2wx(name) );
+
+ }
+ //======================================================================
+
+
+
+ //=================================================
+ void WxGimmickView::CreateIconList()
+ {
+ // Size of the icons;
+ int size = 32;
+
+ wxIcon icons[20];
+ // should correspond to Icon_xxx enum
+ icons[Icon_Patient] = wxIcon(patient_xpm);
+ icons[Icon_Study] = wxIcon(study_xpm);
+ icons[Icon_Series] = wxIcon(series_xpm);
+ icons[Icon_Image] = wxIcon(image_xpm);
+ icons[Icon_Database] = wxIcon(database_xpm);
+ icons[Icon_Folder] = wxIcon(folder_xpm);
+ icons[Icon_DicomDir] = wxIcon(dicomdir_xpm);
+ icons[Icon_Root] = wxIcon(root_xpm);
+
+ unsigned int NbIcons = 8;
+ // Make an image list containing small icons
+ mIcon = new wxImageList(size,size,true);
+
+ // Make all icons the same size = size of the first one
+ int sizeOrig = icons[0].GetWidth();
+ for ( size_t i = 0; i < NbIcons; i++ )
+ {
+ if ( size == sizeOrig )
+ {
+ mIcon->Add(icons[i]);
+ }
+ else
+ {
+ mIcon->Add(wxBitmap(wxBitmap(icons[i]).ConvertToImage().Rescale(size, size)));
+ }
+ }
+ }
+ //=================================================
+
+
} // EO namespace creaImageIO
#include <creaImageIOWxTreeView.h>
#include <creaImageIOSystem.h>
+#include <wx/splitter.h>
namespace creaImageIO
{
{
GimmickDebugMessage(1,"WxTreeView::WxTreeView"
<<std::endl);
+
+
+ // Split part below toolbar into notebook for views and panel
+ // for preview, messages...
+ // TO DO : Splitter
+ // mSplitter = new wxSplitterWindow( this , -1);
+
+ // Global sizer
+ wxBoxSizer *sizer = new wxBoxSizer(wxHORIZONTAL);
+
+ int ctrl_style = wxLC_REPORT;
+ int col_style = wxLIST_FORMAT_LEFT;
+
+ // Creating the ListCtrl for the levels > 0 (not for Root level)
+ for (int i = 1;
+ i < handler->GetTree().GetNumberOfLevels();
+ ++i)
+ {
+ GimmickDebugMessage(5,"Creating ListCtrl for level "<<i
+ <<std::endl);
+
+ wxListCtrl* ctrl = new wxListCtrl(this,
+ i,
+ wxDefaultPosition,
+ wxDefaultSize,
+ ctrl_style);
+
+ // Create the columns : one for each attribute of the level
+ int col = 0;
+ tree::LevelDescriptor::AttributeDescriptorListType::const_iterator a;
+ for (a = handler->GetTree().GetAttributeDescriptorList(i).begin();
+ a != handler->GetTree().GetAttributeDescriptorList(i).end();
+ ++a)
+ {
+ GimmickDebugMessage(5,"Creating column "<<col<<" : "
+ <<a->GetName()
+ <<std::endl);
+ ctrl->InsertColumn(col,
+ crea::std2wx(a->GetName()),
+ col_style);
+ col++;
+ }
+ mListCtrl.push_back(ctrl);
+ sizer->Add( ctrl ,1, wxGROW ,0);
+ }
+
+ SetSizer( sizer );
+ SetAutoLayout(true);
+ Layout();
+
}
/// Destructor