]> Creatis software - bbtk.git/blob - kernel/src/bbtkWxGUIPackageBrowser2.h
42bbe978b0977d591fb51be827af8e15031c4284
[bbtk.git] / kernel / src / bbtkWxGUIPackageBrowser2.h
1 /*=========================================================================                                                                               
2   Program:   bbtk
3   Module:    $RCSfile: bbtkWxGUIPackageBrowser2.h,v $
4   Language:  C++
5   Date:      $Date: 2010/03/25 15:24:50 $
6   Version:   $Revision: 1.7 $
7 =========================================================================*/
8
9 /* ---------------------------------------------------------------------
10
11 * Copyright (c) CREATIS-LRMN (Centre de Recherche en Imagerie Medicale)
12 * Authors : Eduardo Davila, Laurent Guigues, Jean-Pierre Roux
13 *
14 *  This software is governed by the CeCILL-B license under French law and 
15 *  abiding by the rules of distribution of free software. You can  use, 
16 *  modify and/ or redistribute the software under the terms of the CeCILL-B 
17 *  license as circulated by CEA, CNRS and INRIA at the following URL 
18 *  http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html 
19 *  or in the file LICENSE.txt.
20 *
21 *  As a counterpart to the access to the source code and  rights to copy,
22 *  modify and redistribute granted by the license, users are provided only
23 *  with a limited warranty  and the software's author,  the holder of the
24 *  economic rights,  and the successive licensors  have only  limited
25 *  liability. 
26 *
27 *  The fact that you are presently reading this means that you have had
28 *  knowledge of the CeCILL-B license and that you accept its terms.
29 * ------------------------------------------------------------------------ */                                                                         
30
31
32 /**
33  * \brief Short description in one line
34  * 
35  * Long description which 
36  * can span multiple lines
37  */
38 /**
39  * \file 
40  * \brief 
41  */
42 /**
43  * \class bbtk::
44  * \brief 
45  */
46
47
48 #ifdef _USE_WXWIDGETS_
49
50         
51 #ifndef __bbtkWxGUIPackageBrowser2_h__
52 #define __bbtkWxGUIPackageBrowser2_h__
53
54
55 #include "bbtkWx.h"
56
57 #include "bbtkInterpreter.h"
58 #include <wx/aui/aui.h>
59
60 //Drag and drop
61 #include <wx/dnd.h>
62 #include <wx/dataobj.h>
63 #include "wx/listctrl.h"
64 // not all ports have support for EVT_CONTEXT_MENU yet, don't define
65 // USE_CONTEXT_MENU for those which don't
66 #if defined(__WXMOTIF__) || defined(__WXPM__) || defined(__WXX11__) || defined(__WXMGL__)
67     #define USE_CONTEXT_MENU 0
68 #else
69     #define USE_CONTEXT_MENU 1
70 #endif
71
72
73 namespace bbtk
74 {
75   //================================================================
76   class WxGUIPackageBrowser2;
77   //================================================================
78  
79
80   //================================================================
81   /// Abstract class which defines the callbacks invoked by WxGUIPackageBrowser2
82   class BBTK_EXPORT WxGUIPackageBrowser2User
83   {
84   public:
85     WxGUIPackageBrowser2User() {}
86     virtual ~WxGUIPackageBrowser2User() {}
87     /// Callback invoked when the 'run' button is pressed
88     virtual void WxGUIPackageBrowser2Run() {}
89   };
90   //================================================================
91
92  
93   //================================================================
94   class WxGUIBlackBoxInfo : public wxPanel
95   {
96   public:
97     WxGUIBlackBoxInfo(wxWindow* parent);
98     ~WxGUIBlackBoxInfo();
99
100     void UpdateInfo(BlackBoxDescriptor* descr);
101     void InsertInputOutput(wxListCtrl* l, BlackBoxInputOutputDescriptor* i);
102   private:
103     BlackBoxDescriptor* mDescriptor;
104     wxStaticText* mName;
105     wxStaticText* mDescription;
106     wxStaticText* mAuthor;
107     wxStaticText* mCategory;
108       
109     wxListCtrl* mInputList;
110     wxListCtrl* mOutputList;
111   } ;
112   //================================================================
113   
114   //================================================================
115   class WxGUIBlackBoxListUser
116   {
117   public:
118     WxGUIBlackBoxListUser() {}
119     virtual ~WxGUIBlackBoxListUser() {}
120     
121     // User callback when a box is selected in the list 
122     virtual void WxGUIBlackBoxListUserOnSelected( BlackBoxDescriptor* ) {}
123   };
124   //================================================================
125
126   //================================================================
127   class WxGUIBlackBoxList: public wxListCtrl
128   {
129   public:
130     WxGUIBlackBoxList(wxWindow *parent,
131                    const wxWindowID id,
132                    const wxPoint& pos,
133                    const wxSize& size,
134                    long style);
135
136     // Set the user of the object
137     void SetUser(WxGUIBlackBoxListUser* u) { mUser = u; }
138
139     // add one item to the listctrl in report mode
140     void Insert(BlackBoxDescriptor::Pointer d);
141     
142     // 
143     void OnColClick(wxListEvent& event);
144     void OnColRightClick(wxListEvent& event);
145     void OnColBeginDrag(wxListEvent& event);
146     void OnColDragging(wxListEvent& event);
147     void OnColEndDrag(wxListEvent& event);
148     void OnBeginDrag(wxListEvent& event);
149     void OnBeginRDrag(wxListEvent& event);
150     void OnBeginLabelEdit(wxListEvent& event);
151     void OnEndLabelEdit(wxListEvent& event);
152     void OnDeleteItem(wxListEvent& event);
153     void OnDeleteAllItems(wxListEvent& event);
154 #if WXWIN_COMPATIBILITY_2_4
155     void OnGetInfo(wxListEvent& event);
156     void OnSetInfo(wxListEvent& event);
157 #endif
158     void OnSelected(wxListEvent& event);
159     void OnDeselected(wxListEvent& event);
160     void OnListKeyDown(wxListEvent& event);
161     void OnActivated(wxListEvent& event);
162     void OnFocused(wxListEvent& event);
163     void OnCacheHint(wxListEvent& event);
164
165     void OnChar(wxKeyEvent& event);
166
167 #if USE_CONTEXT_MENU
168     void OnContextMenu(wxContextMenuEvent& event);
169 #endif
170
171     void OnRightClick(wxMouseEvent& event);
172
173 private:
174     void ShowContextMenu(const wxPoint& pos);
175     //    wxLog *m_logOld;
176     void SetColumnImage(int col, int image);
177
178     void LogEvent(const wxListEvent& event, const wxChar *eventName);
179     void LogColEvent(const wxListEvent& event, const wxChar *eventName);
180
181     virtual wxString OnGetItemText(long item, long column) const;
182     virtual int OnGetItemColumnImage(long item, long column) const;
183     virtual wxListItemAttr *OnGetItemAttr(long item) const;
184     
185     WxGUIBlackBoxListUser* mUser;
186
187     wxListItemAttr m_attr;
188
189     //    DECLARE_NO_COPY_CLASS(WxGUIBlackBoxListCtrl)
190     DECLARE_EVENT_TABLE()
191 };
192   //================================================================
193
194   //================================================================
195   /// A package browser panel
196   class BBTK_EXPORT WxGUIPackageBrowser2 : public wxPanel,
197                                            public WxGUIBlackBoxListUser
198   {
199   public:
200     WxGUIPackageBrowser2( wxWindow *parent, 
201                          WxGUIPackageBrowser2User* user = 0 );
202     ~WxGUIPackageBrowser2();
203
204     void IncludeAll();
205     void BuildFromFactory(Factory::Pointer f);
206     void RebuildList();
207     bool IsVisible(BlackBoxDescriptor::Pointer d);
208
209     void OnFilter(wxCommandEvent&);
210  
211     // User callback when a box is selected in the list 
212     void WxGUIBlackBoxListUserOnSelected( BlackBoxDescriptor* );
213         
214         //RaC   
215         BlackBoxDescriptor* GetActualSelected();
216
217   private:
218     wxAuiManager m_mgr;
219     WxGUIPackageBrowser2User* mUser;
220     Interpreter::Pointer mInterpreter;
221     Factory::Pointer mFactory;
222     WxGUIBlackBoxList* mBoxList;
223     WxGUIBlackBoxInfo* mBoxInfo;
224
225     wxTextCtrl* mPackageFilter;
226     wxTextCtrl* mNameFilter;
227     wxTextCtrl* mDescriptionFilter;
228     wxTextCtrl* mCategoryFilter;
229     wxTextCtrl* mInputTypeFilter;
230     wxTextCtrl* mOutputTypeFilter;
231     wxTextCtrl* mInputNatureFilter;
232     wxTextCtrl* mOutputNatureFilter;
233
234     wxCheckBox* mShowWidgetsFilter;
235     wxCheckBox* mShowAdaptorsFilter;
236     wxCheckBox* mShowGUIsFilter;
237
238         //RaC
239         BlackBoxDescriptor *_actualSelected;
240
241    DECLARE_EVENT_TABLE()  
242   };
243   //================================================================
244
245   
246   //================================================================
247   /// Browser2 in a frame 
248   class BBTK_EXPORT WxGUIPackageBrowser2Window : public wxFrame
249                                               //, public WxGUICommandUser
250   {
251   public:
252     WxGUIPackageBrowser2Window( wxWindow *parent, wxString title, wxSize size);
253     ~WxGUIPackageBrowser2Window();
254     //    void Open(const std::string& filename) { mBrowser2->Open(filename); }
255     //    void WxGUICommandEnter(const std::string& s);
256
257
258   private :
259     
260     WxGUIPackageBrowser2* mBrowser;
261   };
262    //================================================================
263  
264
265 } // namespace bbtk
266
267
268 #endif // __bbtkWxGUIPackageBrowser_h__
269
270 #endif //_USE_WXWIDGETS_