2 # ---------------------------------------------------------------------
4 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
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
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.
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
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 # ------------------------------------------------------------------------ */
28 /*=========================================================================
30 Module: $RCSfile: bbtkWxGUIPackageBrowser2.h,v $
32 Date: $Date: 2012/11/16 08:49:01 $
33 Version: $Revision: 1.10 $
34 =========================================================================*/
40 * \brief Short description in one line
42 * Long description which
43 * can span multiple lines
55 #ifdef _USE_WXWIDGETS_
58 #ifndef __bbtkWxGUIPackageBrowser2_h__
59 #define __bbtkWxGUIPackageBrowser2_h__
64 #include "bbtkInterpreter.h"
65 #include <wx/aui/aui.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
76 #define USE_CONTEXT_MENU 1
82 //================================================================
83 class WxGUIPackageBrowser2;
84 //================================================================
87 //================================================================
88 /// Abstract class which defines the callbacks invoked by WxGUIPackageBrowser2
89 class BBTK_EXPORT WxGUIPackageBrowser2User
92 WxGUIPackageBrowser2User() {}
93 virtual ~WxGUIPackageBrowser2User() {}
94 /// Callback invoked when the 'run' button is pressed
95 virtual void WxGUIPackageBrowser2Run() {}
97 //================================================================
100 //================================================================
101 class WxGUIBlackBoxInfo : public wxPanel
104 WxGUIBlackBoxInfo(wxWindow* parent);
105 ~WxGUIBlackBoxInfo();
107 void UpdateInfo(BlackBoxDescriptor* descr);
108 void InsertInputOutput(wxListCtrl* l, BlackBoxInputOutputDescriptor* i);
110 BlackBoxDescriptor* mDescriptor;
112 wxStaticText* mDescription;
113 wxStaticText* mAuthor;
114 wxStaticText* mCategory;
116 wxListCtrl* mInputList;
117 wxListCtrl* mOutputList;
119 //================================================================
121 //================================================================
122 class WxGUIBlackBoxListUser
125 WxGUIBlackBoxListUser() {}
126 virtual ~WxGUIBlackBoxListUser() {}
128 // User callback when a box is selected in the list
129 virtual void WxGUIBlackBoxListUserOnSelected( BlackBoxDescriptor* ) {}
131 //================================================================
133 //================================================================
134 class WxGUIBlackBoxList: public wxListCtrl
137 WxGUIBlackBoxList(wxWindow *parent,
143 // Set the user of the object
144 void SetUser(WxGUIBlackBoxListUser* u) { mUser = u; }
146 // add one item to the listctrl in report mode
147 void Insert(BlackBoxDescriptor::Pointer d);
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);
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);
172 void OnChar(wxKeyEvent& event);
175 void OnContextMenu(wxContextMenuEvent& event);
178 void OnRightClick(wxMouseEvent& event);
181 void ShowContextMenu(const wxPoint& pos);
183 void SetColumnImage(int col, int image);
185 void LogEvent(const wxListEvent& event, const wxChar *eventName);
186 void LogColEvent(const wxListEvent& event, const wxChar *eventName);
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;
192 WxGUIBlackBoxListUser* mUser;
194 wxListItemAttr m_attr;
196 // DECLARE_NO_COPY_CLASS(WxGUIBlackBoxListCtrl)
197 DECLARE_EVENT_TABLE()
199 //================================================================
201 //================================================================
202 /// A package browser panel
203 class BBTK_EXPORT WxGUIPackageBrowser2 : public wxPanel,
204 public WxGUIBlackBoxListUser
207 WxGUIPackageBrowser2( wxWindow *parent,
208 WxGUIPackageBrowser2User* user = 0 );
209 ~WxGUIPackageBrowser2();
212 void BuildFromFactory(Factory::Pointer f);
214 bool IsVisible(BlackBoxDescriptor::Pointer d);
216 void OnFilter(wxCommandEvent&);
218 // User callback when a box is selected in the list
219 void WxGUIBlackBoxListUserOnSelected( BlackBoxDescriptor* );
222 BlackBoxDescriptor* GetActualSelected();
223 Factory::Pointer GetFactory();
227 WxGUIPackageBrowser2User* mUser;
228 Interpreter::Pointer mInterpreter;
229 Factory::Pointer mFactory;
230 WxGUIBlackBoxList* mBoxList;
231 WxGUIBlackBoxInfo* mBoxInfo;
233 wxTextCtrl *mPackageFilter;
234 wxTextCtrl *mNameFilter;
235 wxTextCtrl *mDescriptionFilter;
236 wxTextCtrl *mCategoryFilter;
237 wxTextCtrl *mInputTypeFilter;
238 wxTextCtrl *mOutputTypeFilter;
239 wxTextCtrl *mInputNatureFilter;
240 wxTextCtrl *mOutputNatureFilter;
242 wxCheckBox *mShowWidgetsFilter;
243 wxCheckBox *mShowAdaptorsFilter;
244 wxCheckBox *mShowGUIsFilter;
247 BlackBoxDescriptor *_actualSelected;
249 bool findnpos(const std::string &strA, const std::string &strB );
251 DECLARE_EVENT_TABLE()
253 //================================================================
256 //================================================================
257 /// Browser2 in a frame
258 class BBTK_EXPORT WxGUIPackageBrowser2Window : public wxFrame
259 //, public WxGUICommandUser
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);
270 WxGUIPackageBrowser2* mBrowser;
273 //================================================================
279 #endif // __bbtkWxGUIPackageBrowser_h__
281 #endif //_USE_WXWIDGETS_