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