]> Creatis software - bbtk.git/blob - kernel/src/bbtkWxGUIPackageBrowser2.h
#2997 BBTK Feature New Normal - ReadLinesString box in package std
[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   private:
110     BlackBoxDescriptor* mDescriptor;
111     wxStaticText* mName;
112     wxStaticText* mDescription;
113     wxStaticText* mAuthor;
114     wxStaticText* mCategory;
115
116     wxListCtrl* mInputList;
117     wxListCtrl* mOutputList;
118   } ;
119   //================================================================
120
121   //================================================================
122   class WxGUIBlackBoxListUser
123   {
124   public:
125     WxGUIBlackBoxListUser() {}
126     virtual ~WxGUIBlackBoxListUser() {}
127
128     // User callback when a box is selected in the list
129     virtual void WxGUIBlackBoxListUserOnSelected( BlackBoxDescriptor* ) {}
130   };
131   //================================================================
132
133   //================================================================
134   class WxGUIBlackBoxList: public wxListCtrl
135   {
136   public:
137     WxGUIBlackBoxList(wxWindow *parent,
138                    const wxWindowID id,
139                    const wxPoint& pos,
140                    const wxSize& size,
141                    long style);
142
143     // Set the user of the object
144     void SetUser(WxGUIBlackBoxListUser* u) { mUser = u; }
145
146     // add one item to the listctrl in report mode
147     void Insert(BlackBoxDescriptor::Pointer d);
148
149     //
150     void OnColClick(wxListEvent& event);
151     void OnColRightClick(wxListEvent& event);
152     void OnColBeginDrag(wxListEvent& event);
153     void OnColDragging(wxListEvent& event);
154     void OnColEndDrag(wxListEvent& event);
155     void OnBeginDrag(wxListEvent& event);
156     void OnBeginRDrag(wxListEvent& event);
157     void OnBeginLabelEdit(wxListEvent& event);
158     void OnEndLabelEdit(wxListEvent& event);
159     void OnDeleteItem(wxListEvent& event);
160     void OnDeleteAllItems(wxListEvent& event);
161 #if WXWIN_COMPATIBILITY_2_4
162     void OnGetInfo(wxListEvent& event);
163     void OnSetInfo(wxListEvent& event);
164 #endif
165     void OnSelected(wxListEvent& event);
166     void OnDeselected(wxListEvent& event);
167     void OnListKeyDown(wxListEvent& event);
168     void OnActivated(wxListEvent& event);
169     void OnFocused(wxListEvent& event);
170     void OnCacheHint(wxListEvent& event);
171
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
218     // User callback when a box is selected in the list
219     void WxGUIBlackBoxListUserOnSelected( BlackBoxDescriptor* );
220
221         //RaC
222         BlackBoxDescriptor* GetActualSelected();
223         Factory::Pointer GetFactory();
224
225   private:
226     wxAuiManager                                m_mgr;
227     WxGUIPackageBrowser2User*   mUser;
228     Interpreter::Pointer                mInterpreter;
229     Factory::Pointer                    mFactory;
230     WxGUIBlackBoxList*                  mBoxList;
231     WxGUIBlackBoxInfo*                  mBoxInfo;
232
233     wxTextCtrl                                  *mPackageFilter;
234     wxTextCtrl                                  *mNameFilter;
235     wxTextCtrl                                  *mDescriptionFilter;
236     wxTextCtrl                                  *mCategoryFilter;
237     wxTextCtrl                                  *mInputTypeFilter;
238     wxTextCtrl                                  *mOutputTypeFilter;
239     wxTextCtrl                                  *mInputNatureFilter;
240     wxTextCtrl                                  *mOutputNatureFilter;
241
242     wxCheckBox                                  *mShowWidgetsFilter;
243     wxCheckBox                                  *mShowAdaptorsFilter;
244     wxCheckBox                                  *mShowGUIsFilter;
245
246         //RaC
247         BlackBoxDescriptor          *_actualSelected;
248
249     bool findnpos(const std::string &strA, const std::string &strB );
250
251    DECLARE_EVENT_TABLE()
252   };
253   //================================================================
254
255
256   //================================================================
257   /// Browser2 in a frame
258   class BBTK_EXPORT WxGUIPackageBrowser2Window : public wxFrame
259                                               //, public WxGUICommandUser
260   {
261   public:
262     WxGUIPackageBrowser2Window( wxWindow *parent, wxString title, wxSize size);
263     ~WxGUIPackageBrowser2Window();
264     //    void Open(const std::string& filename) { mBrowser2->Open(filename); }
265     //    void WxGUICommandEnter(const std::string& s);
266
267
268   private :
269
270     WxGUIPackageBrowser2* mBrowser;
271
272   };
273    //================================================================
274
275
276 } // namespace bbtk
277
278
279 #endif // __bbtkWxGUIPackageBrowser_h__
280
281 #endif //_USE_WXWIDGETS_